EFM32 Pearl Gecko 12 Software Documentation
efm32pg12-doc-5.1.2
|
Utility functions.
DO_NOT_INCLUDE_WITH_DOXYGEN
Functions | |
static void | adcDeInit (void) |
De-initializes the A/D converter. More... | |
static void | adcInit (void) |
Initializes the A/D converter. More... | |
static uint16_t | getAdcSample (void) |
Initiates an A/D conversion and reads the sample when done. More... | |
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. More... | |
static float | measureSupplyVoltage (unsigned int avg) |
Measures the supply voltage by averaging multiple readings. More... | |
static void | rtcCb (RTCDRV_TimerID_t id, void *user) |
RTC callback function, called when the timer expired. More... | |
void | SysTick_Handler (void) |
Interrupt Service Routine for system tick counter. More... | |
void | UTIL_delay (uint32_t ms) |
Delays number of msTick Systicks (1 ms) More... | |
uint32_t | UTIL_init (void) |
Sets up the SysTick timer for 1ms interrupts and initializes and starts the RTC timer. More... | |
bool | UTIL_isLowPower (void) |
Checks if the current power supply has low power capability. More... | |
void | UTIL_shutdown (void) |
Enter lowest power shutdown mode, EM4S. More... | |
void | UTIL_sleep (uint32_t ms) |
Delays number of milliseconds in sleep mode (EM2) using the RTC. More... | |
uint32_t | UTIL_sleepInit (void) |
Sets up the RTC timer used for sleep functions. More... | |
void | UTIL_supplyGetCharacteristics (uint8_t *type, float *voltage, float *ir) |
Retrieves the supply characteristic variables. More... | |
uint8_t | UTIL_supplyGetType (void) |
Returns the type of the power supply. More... | |
void | UTIL_supplyProbe (void) |
Probes the connected supply and determines its type. The results are stored in global variables. More... | |
uint32_t | UTIL_waitForEvent (uint32_t timeout) |
Delays number of milliseconds in sleep mode (EM2) using the RTC but but returns if an event wakes up the MCU. More... | |
|
static |
De-initializes the A/D converter.
Definition at line 101 of file util_supply.c.
References _CMU_CTRL_CLKOUTSEL1_MASK, CMU, and PRS_SourceAsyncSignalSet().
Referenced by measureSupplyVoltage().
|
static |
Initializes the A/D converter.
Definition at line 64 of file util_supply.c.
References _ADC_CTRL_RESETVALUE, ADC_InitSingle_TypeDef::acqTime, ADC0, ADC_Init(), ADC_INIT_DEFAULT, ADC_InitSingle(), ADC_INITSINGLE_DEFAULT, ADC_PrescaleCalc(), ADC_TimebaseCalc(), adcAcqTime16, adcPRSSELCh4, CMU_ClockEnable(), cmuClock_ADC0, cmuClock_PRS, ADC_InitSingle_TypeDef::negSel, ADC_InitSingle_TypeDef::posSel, ADC_Init_TypeDef::prescale, ADC_InitSingle_TypeDef::prsEnable, ADC_InitSingle_TypeDef::prsSel, ADC_InitSingle_TypeDef::reference, and ADC_Init_TypeDef::timebase.
Referenced by measureSupplyVoltage(), and MIC_init().
|
static |
Initiates an A/D conversion and reads the sample when done.
Definition at line 118 of file util_supply.c.
References ADC0, ADC_DataSingleGet(), ADC_IF_SINGLE, ADC_IntGet(), ADC_Start(), and adcStartSingle.
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.
[in] | loadSetting | Heater current setting of the Si7021 |
Definition at line 175 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.
[in] | avg | Number of measurements to average |
Definition at line 139 of file util_supply.c.
References adcDeInit(), adcInit(), and getAdcSample().
Referenced by measureSupplyIR(), and UTIL_supplyProbe().
|
static |
RTC callback function, called when the timer expired.
[in] | id | The id of the timer |
[in] | user | Extra parameter for user application (not used) |
Definition at line 132 of file util_sleep.c.
References rtcComplete.
Referenced by UTIL_sleep(), and UTIL_waitForEvent().
void SysTick_Handler | ( | void | ) |
void UTIL_delay | ( | uint32_t | ms | ) |
Delays number of msTick Systicks (1 ms)
[in] | ms | Number of ticks (ms) to delay |
Definition at line 97 of file util.c.
References EMU_EnterEM1().
Referenced by BMP_init(), BOARD_flashDeepPowerDown(), BOARD_init(), CCS811_init(), ICM20648_accelGyroCalibrate(), ICM20648_gyroCalibrate(), ICM20648_init(), ICM20648_lowPowerModeEnter(), ICM20648_reset(), ICM20648_wakeOnMotionITEnable(), IMU_config(), measureSupplyIR(), SI1133_init(), SI1133_measureLuxUvi(), SI1133_reset(), SI7021_init(), SI7021_measure(), and SI7210_init().
uint32_t UTIL_init | ( | void | ) |
Sets up the SysTick timer for 1ms interrupts and initializes and starts the RTC timer.
Definition at line 57 of file util.c.
References CMU_ClockFreqGet(), and cmuClock_CORE.
bool UTIL_isLowPower | ( | void | ) |
Checks if the current power supply has low power capability.
Definition at line 305 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.
Definition at line 118 of file util.c.
References _GPIO_EM4WUEN_EM4WUEN_SHIFT, BOARD_BUTTON_LEFT_PIN, BOARD_BUTTON_PORT, 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 RTC.
ms | Number of milliseconds to sleep |
Definition at line 78 of file util_sleep.c.
References EMU_EnterEM2(), rtcCb(), rtcComplete, RTCDRV_StartTimer(), rtcdrvTimerTypeOneshot, and rtcId.
uint32_t UTIL_sleepInit | ( | void | ) |
Sets up the RTC timer used for sleep functions.
Definition at line 53 of file util_sleep.c.
References ECODE_EMDRV_RTCDRV_OK, RTCDRV_AllocateTimer(), RTCDRV_Init(), and rtcId.
void UTIL_supplyGetCharacteristics | ( | uint8_t * | type, |
float * | voltage, | ||
float * | ir | ||
) |
Retrieves the supply characteristic variables.
[in] | type | Supply type |
[in] | voltage | Loaded supply voltage |
[in] | ir | Internal resistance of the supply |
Definition at line 273 of file util_supply.c.
uint8_t UTIL_supplyGetType | ( | void | ) |
Returns the type of the power supply.
Definition at line 291 of file util_supply.c.
void UTIL_supplyProbe | ( | void | ) |
Probes the connected supply and determines its type. The results are stored in global variables.
Definition at line 224 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 | timeout | ) |
Delays number of milliseconds in sleep mode (EM2) using the RTC but but returns if an event wakes up the MCU.
timeout | Timeout, the maximum number of milliseconds to sleep |
Definition at line 100 of file util_sleep.c.
References EMU_EnterEM2(), rtcCb(), rtcComplete, RTCDRV_StartTimer(), RTCDRV_TimeRemaining(), rtcdrvTimerTypeOneshot, and rtcId.