Wirepas SDK
hardware.h File Reference

Detailed Description

The hardware library allows telling the stack that a certain hardware peripheral is in use by the application, so that the stack does not use the peripheral at the same time. Also vice versa, hardware library tells application if it is trying to use hardware peripheral used by the stack. The stack needs to know chip temperature to do periodic RF calibrations on some platforms, and that may require the stack to access hardware peripherals that the application also uses.

The application may use a peripheral either intermittently or permanently.

This library also allows the activation of a hardware peripheral. In fact, some peripheral may be needed by the application or the stack with a concurrent access as the activation of an external crystal for more precision.

Library services are accessed via lib_hw handle.

Definition in file hardware.h.

Go to the source code of this file.

Typedefs

typedef app_res_e(* app_lib_hardware_reserve_peripheral_f) (app_lib_hardware_peripheral_e peripheral)
 Reserve a hardware peripheral. More...
 
typedef app_res_e(* app_lib_hardware_release_peripheral_f) (app_lib_hardware_peripheral_e peripheral)
 Release a reserved hardware peripheral back for stack use. More...
 
typedef uint16_t(* app_lib_hardware_read_supply_voltage_f) (void)
 Query voltage value. More...
 
typedef int32_t(* app_lib_hardware_read_temperature_f) (void)
 Ask the last read chip temperature from the stack. More...
 
typedef app_res_e(* app_lib_hardware_activate_peripheral_f) (app_lib_hardware_activable_peripheral_e peripheral)
 Request for peripheral activation. More...
 
typedef app_res_e(* app_lib_hardware_deactivate_peripheral_f) (app_lib_hardware_activable_peripheral_e peripheral)
 Request for peripheral deactivation. More...
 
typedef app_res_e(* app_lib_hardware_is_peripheral_activated_f) (app_lib_hardware_activable_peripheral_e peripheral, bool *activated_p, uint32_t timeout_us)
 Request for peripheral status. More...
 

Data Structures

struct  app_lib_hardware_t
 List of library functions. More...
 

Enumerations

enum  app_lib_hardware_peripheral_e { APP_LIB_HARDWARE_PERIPHERAL_RESERVED = 3 }
 Hardware peripherals to reserve. More...
 
enum  app_lib_hardware_activable_peripheral_e { APP_LIB_HARDWARE_PERIPHERAL_HFXO = 0 }
 Hardware peripherals to activate. More...
 

Macros

#define APP_LIB_HARDWARE_NAME   0x014eff15
 Library symbolic name
More...
 
#define APP_LIB_HARDWARE_VERSION   0x202
 Maximum supported library version. More...
 

Typedef Documentation

◆ app_lib_hardware_activate_peripheral_f

typedef app_res_e(* app_lib_hardware_activate_peripheral_f) (app_lib_hardware_activable_peripheral_e peripheral)

Request for peripheral activation.

Parameters
peripheralHardware peripheral to activate
Returns
If peripheral is not recognized or not reservable, APP_RES_RESOURCE_UNAVAILABLE is returned. Otherwise, APP_RES_OK is returned.

Definition at line 133 of file hardware.h.

◆ app_lib_hardware_deactivate_peripheral_f

typedef app_res_e(* app_lib_hardware_deactivate_peripheral_f) (app_lib_hardware_activable_peripheral_e peripheral)

Request for peripheral deactivation.

Parameters
peripheralHardware peripheral to deactivate
Returns
If peripheral is not recognized or not reservable, APP_RES_RESOURCE_UNAVAILABLE is returned. If peripheral was not previously activated, APP_RES_INVALID_CONFIGURATION. Otherwise, APP_RES_OK is returned.

Definition at line 146 of file hardware.h.

◆ app_lib_hardware_is_peripheral_activated_f

typedef app_res_e(* app_lib_hardware_is_peripheral_activated_f) (app_lib_hardware_activable_peripheral_e peripheral, bool *activated_p, uint32_t timeout_us)

Request for peripheral status.

The given timeout_us is the maximum time to wait for peripheral activation. Each peripheral has a maximum timeout dependent on the platform.

Parameters
peripheralHardware peripheral to check status
activated_pPointer to store the status: true if activated, false otherwise
timeout_usMaximum time to wait for activation
Returns
If peripheral is not recognized or not reservable, APP_RES_RESOURCE_UNAVAILABLE is returned. If peripheral was not previously activated, APP_RES_INVALID_CONFIGURATION. If timeout_us is too long APP_RES_INVALID_VALUE is returned. Otherwise, APP_RES_OK is returned and activated_p is updated.
Note
Each peripheral has a maximum timeout dependent on the platform

Definition at line 169 of file hardware.h.

◆ app_lib_hardware_read_supply_voltage_f

typedef uint16_t(* app_lib_hardware_read_supply_voltage_f) (void)

Query voltage value.

Note
This is for stack versions <5.1.0.
Returns
Return always 0

Example: See inventory_app_tag example.

Definition at line 111 of file hardware.h.

◆ app_lib_hardware_read_temperature_f

typedef int32_t(* app_lib_hardware_read_temperature_f) (void)

Ask the last read chip temperature from the stack.

Note
This is for stack versions <5.1.0.
Returns
Return always 0

Definition at line 121 of file hardware.h.

◆ app_lib_hardware_release_peripheral_f

typedef app_res_e(* app_lib_hardware_release_peripheral_f) (app_lib_hardware_peripheral_e peripheral)

Release a reserved hardware peripheral back for stack use.

Note
This is for stack versions <5.1.0. For 5.1.0 devices, stack does not reserve any peripherals, therefore APP_RES_OK is returned.
Parameters
peripheralHardware peripheral to reserve
Returns
Returns APP_RES_RESOURCE_OK

Definition at line 99 of file hardware.h.

◆ app_lib_hardware_reserve_peripheral_f

typedef app_res_e(* app_lib_hardware_reserve_peripheral_f) (app_lib_hardware_peripheral_e peripheral)

Reserve a hardware peripheral.

Note
This is for stack versions <5.1.0. For 5.1.0 devices, stack does not reserve any peripherals, therefore APP_RES_OK is returned.
Parameters
peripheralHardware peripheral to reserve
Returns
Returns APP_RES_OK

Definition at line 85 of file hardware.h.


Data Structure Documentation

◆ app_lib_hardware_t

struct app_lib_hardware_t

List of library functions.

Definition at line 177 of file hardware.h.

Data Fields
app_lib_hardware_activate_peripheral_f activatePeripheral
app_lib_hardware_deactivate_peripheral_f deactivatePeripheral
app_lib_hardware_is_peripheral_activated_f isPeripheralActivated
app_lib_hardware_read_supply_voltage_f readSupplyVoltage
app_lib_hardware_read_temperature_f readTemperature
app_lib_hardware_release_peripheral_f releasePeripheral
app_lib_hardware_reserve_peripheral_f reservePeripheral

Enumeration Type Documentation

◆ app_lib_hardware_activable_peripheral_e

Hardware peripherals to activate.

To be used with services lib_hw->activatePeripheral() and lib_hw->deactivatePeripheral().

Note
Not all platforms have all peripherals available.
Enumerator
APP_LIB_HARDWARE_PERIPHERAL_HFXO 

General high frequency external crystal

Definition at line 67 of file hardware.h.

◆ app_lib_hardware_peripheral_e

Hardware peripherals to reserve.

To be used with services lib_hw->reservePeripheral() and lib_hw->releasePeripheral().

Note
Not all platforms have all peripherals available.
Enumerator
APP_LIB_HARDWARE_PERIPHERAL_RESERVED 

Reserved for future use

Definition at line 52 of file hardware.h.

Macro Definition Documentation

◆ APP_LIB_HARDWARE_NAME

#define APP_LIB_HARDWARE_NAME   0x014eff15

Library symbolic name

"HWARE"

Definition at line 38 of file hardware.h.

◆ APP_LIB_HARDWARE_VERSION

#define APP_LIB_HARDWARE_VERSION   0x202

Maximum supported library version.

Definition at line 41 of file hardware.h.

APP_LIB_HARDWARE_PERIPHERAL_HFXO
@ APP_LIB_HARDWARE_PERIPHERAL_HFXO
Definition: hardware.h:70
APP_LIB_HARDWARE_PERIPHERAL_RESERVED
@ APP_LIB_HARDWARE_PERIPHERAL_RESERVED
Definition: hardware.h:55
app_lib_hardware_activable_peripheral_e
app_lib_hardware_activable_peripheral_e
Hardware peripherals to activate.
Definition: hardware.h:67
app_lib_hardware_peripheral_e
app_lib_hardware_peripheral_e
Hardware peripherals to reserve.
Definition: hardware.h:52