Utility Functions
Detailed Description
Utility functions.
Macros |
|
#define | UTIL_SUPPLY_TYPE_AA 2 |
#define | UTIL_SUPPLY_TYPE_AAA 3 |
#define | UTIL_SUPPLY_TYPE_CR2032 4 |
#define | UTIL_SUPPLY_TYPE_UNKNOWN 0 |
#define | UTIL_SUPPLY_TYPE_USB 1 |
Functions |
|
static void | adcDeInit (void) |
De-initializes the A/D converter.
|
|
static void | adcInit (void) |
Initializes the A/D converter.
|
|
static uint16_t | getAdcSample (void) |
Initiates an A/D conversion and reads the sample when done.
|
|
static float | measureSupplyIR (uint8_t loadSetting) |
Measures the unladed and loaded supply voltage and calculates the intermal resistance of the connected supply. The load is provided by the heater element built in the Si7021.
|
|
static float | measureSupplyVoltage (unsigned int avg) |
Measures the supply voltage by averaging multiple readings.
|
|
void | SysTick_Handler (void) |
Interrupt Service Routine for system tick counter.
|
|
static void | timer_callback ( sl_sleeptimer_timer_handle_t *handle, void *data) |
sleeptmer callback function, called when the timer expired.
|
|
void | UTIL_delay (uint32_t ms) |
Delays number of msTick Systicks (1 ms)
|
|
uint32_t | UTIL_init (void) |
Sets up the SysTick timer for 1ms interrupts and initializes and starts the RTC timer.
|
|
bool | UTIL_isLowPower (void) |
Checks if the current power supply has low power capability.
|
|
void | UTIL_shutdown (void) |
Enter lowest power shutdown mode, EM4S.
|
|
void | UTIL_sleep (uint32_t ms) |
Delays number of milliseconds in sleep mode (EM2) using the sleeptimer.
|
|
uint32_t | UTIL_sleepInit (void) |
Sets up the sleeptimer used for sleep functions.
|
|
void | UTIL_supplyGetCharacteristics (uint8_t *type, float *voltage, float *ir) |
Retrieves the supply characteristic variables.
|
|
uint8_t | UTIL_supplyGetType (void) |
Returns the type of the power supply.
|
|
void | UTIL_supplyProbe (void) |
Probes the connected supply and determines its type. The results are stored in global variables.
|
|
uint32_t | UTIL_waitForEvent (uint32_t ms) |
Delays number of milliseconds in sleep mode (EM2) using the sleeptimer but returns if an event wakes up the MCU.
|
|
Macro Definition Documentation
#define UTIL_SUPPLY_TYPE_AA 2 |
The board powered from AA batteries
Definition at line
49
of file
util.h
.
#define UTIL_SUPPLY_TYPE_AAA 3 |
The board powered from AAA batteries
Definition at line
50
of file
util.h
.
Referenced by UTIL_supplyProbe() .
#define UTIL_SUPPLY_TYPE_CR2032 4 |
The board powered from a CR2032 battery
Definition at line
51
of file
util.h
.
Referenced by UTIL_isLowPower() , and UTIL_supplyProbe() .
#define UTIL_SUPPLY_TYPE_UNKNOWN 0 |
Unknown power supply type
Definition at line
47
of file
util.h
.
Referenced by UTIL_isLowPower() , and UTIL_supplyProbe() .
#define UTIL_SUPPLY_TYPE_USB 1 |
The board powered from the USB connector
Definition at line
48
of file
util.h
.
Referenced by UTIL_supplyProbe() .
Function Documentation
|
static |
De-initializes the A/D converter.
- Returns
- None
Definition at line
106
of file
util_supply.c
.
References PRS_SourceAsyncSignalSet() .
Referenced by measureSupplyVoltage() .
|
static |
Initializes the A/D converter.
- Returns
- None
Definition at line
72
of file
util_supply.c
.
References CMU_ClockEnable() , and cmuClock_PRS .
Referenced by measureSupplyVoltage() , and MIC_init() .
|
static |
Initiates an A/D conversion and reads the sample when done.
- Returns
- The output of the A/D conversion
Definition at line
121
of file
util_supply.c
.
Referenced by measureSupplyVoltage() .
|
static |
Measures the unladed and loaded supply voltage and calculates the intermal resistance of the connected supply. The load is provided by the heater element built in the Si7021.
- Parameters
-
[in] loadSetting
Heater current setting of the Si7021
- Returns
- The measured internal resistance of the connected supply
Definition at line
174
of file
util_supply.c
.
References measureSupplyVoltage() , SI7021_CMD_WRITE_HEATER_CTRL , SI7021_CMD_WRITE_USER_REG1 , SI7021_cmdWrite() , and UTIL_delay() .
Referenced by UTIL_supplyProbe() .
|
static |
Measures the supply voltage by averaging multiple readings.
- Parameters
-
[in] avg
Number of measurements to average
- Returns
- The measured voltage
Definition at line
140
of file
util_supply.c
.
References adcDeInit() , adcInit() , and getAdcSample() .
Referenced by measureSupplyIR() , and UTIL_supplyProbe() .
void SysTick_Handler | ( | void |
|
) |
Interrupt Service Routine for system tick counter.
- Returns
- None
Definition at line
82
of file
util.c
.
void UTIL_delay | ( | uint32_t |
ms
|
) |
Delays number of msTick Systicks (1 ms)
- Parameters
-
[in] ms
Number of ticks (ms) to delay
- Returns
- None
Definition at line
99
of file
util.c
.
References EMU_EnterEM1() .
Referenced by BAP_init() , BOARD_flashDeepPowerDown() , BOARD_gasSensorWake() , BOARD_init() , CCS811_init() , HALL_init() , ICM20648_accelGyroCalibrate() , ICM20648_gyroCalibrate() , ICM20648_init() , ICM20648_lowPowerModeEnter() , ICM20648_reset() , ICM20648_wakeOnMotionITEnable() , IMU_config() , measureSupplyIR() , SI1133_init() , SI1133_measureLuxUvi() , SI1133_reset() , SI7021_init() , and SI7021_measure() .
uint32_t UTIL_init | ( | void |
|
) |
Sets up the SysTick timer for 1ms interrupts and initializes and starts the RTC timer.
- Returns
- Returns zero on OK, non-zero otherwise
Definition at line
63
of file
util.c
.
References CMU_ClockFreqGet() , and cmuClock_CORE .
bool UTIL_isLowPower | ( | void |
|
) |
Checks if the current power supply has low power capability.
- Returns
- True if the supply is low power type, false otherwise
Definition at line
294
of file
util_supply.c
.
References UTIL_SUPPLY_TYPE_CR2032 , and UTIL_SUPPLY_TYPE_UNKNOWN .
void UTIL_shutdown | ( | void |
|
) |
Enter lowest power shutdown mode, EM4S.
- Returns
- None
Definition at line
118
of file
util.c
.
References EMU_EM4Init() , EMU_EM4INIT_DEFAULT , EMU_EnterEM4() , emuPinRetentionEm4Exit , GPIO_EM4EnablePinWakeup() , GPIO_PinModeSet() , gpioModeInputPullFilter , and EMU_EM4Init_TypeDef::pinRetentionMode .
void UTIL_sleep | ( | uint32_t |
ms
|
) |
Delays number of milliseconds in sleep mode (EM2) using the sleeptimer.
- Parameters
-
ms
Number of milliseconds to sleep.
- Returns
- None
Definition at line
91
of file
util_sleep.c
.
References EMU_EnterEM2() , sl_sleeptimer_start_timer_ms() , and timer_callback() .
uint32_t UTIL_sleepInit | ( | void |
|
) |
Sets up the sleeptimer used for sleep functions.
- Returns
- Returns zero on OK, non-zero otherwise.
Definition at line
74
of file
util_sleep.c
.
References sl_sleeptimer_init() .
void UTIL_supplyGetCharacteristics | ( | uint8_t * |
type,
|
float * |
voltage,
|
||
float * |
ir
|
||
) |
Retrieves the supply characteristic variables.
- Parameters
-
[in] type
Supply type [in] voltage
Loaded supply voltage [in] ir
Internal resistance of the supply
- Returns
- None
Definition at line
266
of file
util_supply.c
.
uint8_t UTIL_supplyGetType | ( | void |
|
) |
Returns the type of the power supply.
- Returns
- The type of the supply
Definition at line
282
of file
util_supply.c
.
void UTIL_supplyProbe | ( | void |
|
) |
Probes the connected supply and determines its type. The results are stored in global variables.
- Returns
- None
Definition at line
221
of file
util_supply.c
.
References measureSupplyIR() , measureSupplyVoltage() , SI7021_deInit() , SI7021_init() , UTIL_SUPPLY_TYPE_AAA , UTIL_SUPPLY_TYPE_CR2032 , UTIL_SUPPLY_TYPE_UNKNOWN , and UTIL_SUPPLY_TYPE_USB .
uint32_t UTIL_waitForEvent | ( | uint32_t |
ms
|
) |
Delays number of milliseconds in sleep mode (EM2) using the sleeptimer but returns if an event wakes up the MCU.
- Parameters
-
ms
The maximum number of milliseconds to sleep.
- Returns
- The number of milliseconds remained from the wait.
Definition at line
112
of file
util_sleep.c
.
References EMU_EnterEM2() , sl_sleeptimer_get_timer_time_remaining() , sl_sleeptimer_start_timer_ms() , sl_sleeptimer_stop_timer() , sl_sleeptimer_tick_to_ms() , and timer_callback() .