| // Copyright 2025 The Fuchsia Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| library fuchsia.hardware.google.nanohub; |
| |
| using zx; |
| |
| alias FirmwareName = string:64; |
| |
| type McuVersionInfo = struct { |
| hardware_type uint16; |
| hardware_version uint16; |
| bootloader_version uint16; |
| os_version uint16; |
| variant_version uint32; |
| }; |
| |
| type McuTimeSyncInfo = table { |
| 1: ap_boot_time zx.Time; |
| 2: mcu_boot_time zx.Time; |
| }; |
| |
| type McuWakeLockValue = strict enum : uint8 { |
| RELEASE = 0; |
| ACQUIRE = 1; |
| }; |
| |
| type PinState = strict enum { |
| LOW = 0; |
| HIGH = 1; |
| }; |
| |
| type HardwareResetPinStates = struct { |
| isp_pin_0 PinState; |
| isp_pin_1 PinState; |
| isp_pin_2 PinState; |
| }; |
| |
| /// Client is expected to pass the vmo handle to nanohub when issuing a DownloadFirmware request. |
| @discoverable |
| open protocol Device { |
| /// Request to sent to nanohub to load the firmware. |
| strict DownloadFirmware(resource struct { |
| firmware |
| zx.Handle:<VMO, zx.RIGHTS_BASIC | zx.Rights.EXECUTE | zx.Rights.GET_PROPERTY | zx.Rights.MAP | zx.Rights.READ>; |
| // Specify the location to jump to for reading the firmware. |
| offset uint64; |
| }) -> () error zx.Status; |
| |
| /// The name of the firmware binary running on the MCU. |
| strict GetFirmwareName() -> (struct { |
| firmware_name FirmwareName; |
| }); |
| |
| /// The version of the firmware binary running on the MCU. |
| strict GetFirmwareVersion() -> (struct { |
| version_info McuVersionInfo; |
| }); |
| |
| /// The time since boot recorded by the AP and the MCU. |
| strict GetTimeSync() -> (McuTimeSyncInfo) error zx.Status; |
| |
| /// Set an MCU wake lock request to prevent the MCU from entering a low-power state. |
| strict SetWakeLock(struct { |
| value McuWakeLockValue; |
| }) -> () error zx.Status; |
| |
| /// Get the current duration of time the MCU will remain awake. |
| strict GetWakeUpEventDuration() -> (struct { |
| duration zx.Duration; |
| }) error zx.Status; |
| |
| /// Set a duration of time for the MCU to remain awake. |
| strict SetWakeUpEventDuration(struct { |
| duration zx.Duration; |
| }) -> () error zx.Status; |
| |
| /// Initiates a hardware reset. |
| strict HardwareReset(HardwareResetPinStates) -> () error zx.Status; |
| }; |
| |
| service Service { |
| nanohub client_end:Device; |
| }; |