EFM32 Happy Gecko Software Documentation
efm32hg-doc-4.2.1
|
USTIMER Microsecond delay timer module, see USTIMER Microsecond delay timer module page for detailed documentation.
. More...
Macros | |
#define | ECODE_EMDRV_USTIMER_OK ( ECODE_OK ) |
Success return value. | |
Functions | |
Ecode_t | USTIMER_Init (void) |
Activate and initialize the hardware timer used to pace the 1 microsecond delay functions. More... | |
Ecode_t | USTIMER_DeInit (void) |
Deinitialize USTIMER driver. More... | |
Ecode_t | USTIMER_Delay (uint32_t usec) |
Delay a given number of microseconds. More... | |
Ecode_t | USTIMER_DelayIntSafe (uint32_t usec) |
Delay a given number of microseconds. More... | |
The USTIMER driver implements microsecond delay functions. The delay is timed using a hardware TIMER resource. Two delay functions are available, one which use energy mode EM1 to preserve energy while waiting, and one which performs busy wait.
By default the module use TIMER0. Timer resource selection is stored in a file named ustimer_config.h. A template for this file, containing default value, resides in the emdrv/config folder.
To configure USTIMER, provide your own configuration file. Here is a sample ustimer_config.h file:
#ifndef __SILICON_LABS_USTIMER_CONFIG_H__ #define __SILICON_LABS_USTIMER_CONFIG_H__ /// USTIMER configuration option. Use this define to select a TIMER resource. #define USTIMER_TIMER USTIMER_TIMER3 #endif
This section contain brief descriptions of the functions in the API. You will find detailed information on input and output parameters and return values by clicking on the hyperlinked function names. Most functions return an error code, ECODE_EMDRV_USTIMER_OK is returned on success, see ecode.h and ustimer.h for other error codes.
Your application code must include one header file: ustimer.h.
USTIMER_Init(), USTIMER_DeInit()
These functions initializes or deinitializes the USTIMER driver. Typically USTIMER_Init() is called once in your startup code.
USTIMER_Delay() Delay a given number of microseconds. The mcu is put in EM1 during the delay.
USTIMER_DelayIntSafe() Delay a given number of microseconds. The mcu is not put in EM1 during the delay. This function can be called in any context and is also thread safe.
#include "ustimer.h" int main( void ) { // Initialization of USTIMER driver USTIMER_Init(); // Wait for 250 microseconds USTIMER_Delay( 250 ); }
Ecode_t USTIMER_Init | ( | void | ) |
Definition at line 86 of file ustimer.c.
References _TIMER_CTRL_PRESC_DIV1, _TIMER_CTRL_PRESC_DIV1024, CMU_ClockEnable(), CMU_ClockFreqGet(), cmuClock_CORE, cmuClock_HFPER, ECODE_EMDRV_USTIMER_OK, TIMER_InitCC_TypeDef::mode, TIMER_Init_TypeDef::prescale, TIMER_IEN_CC0, TIMER_Init(), TIMER_INIT_DEFAULT, TIMER_InitCC(), TIMER_INITCC_DEFAULT, TIMER_IntDisable(), TIMER_TopSet(), and timerCCModeCompare.
Referenced by ezradio_reset().
Ecode_t USTIMER_DeInit | ( | void | ) |
Will disable interrupts and turn off the clock to the underlying hardware timer.
Definition at line 137 of file ustimer.c.
References CMU_ClockEnable(), ECODE_EMDRV_USTIMER_OK, TIMER_Enable(), TIMER_IEN_CC0, TIMER_IFC_CC0, TIMER_IntClear(), and TIMER_IntDisable().
Referenced by ezradio_reset().
Ecode_t USTIMER_Delay | ( | uint32_t | usec | ) |
The mcu is put in EM1 during the delay.
[in] | usec | Number of microseconds to delay. |
Definition at line 168 of file ustimer.c.
References ECODE_EMDRV_USTIMER_OK.
Referenced by ezradio_reset().
Ecode_t USTIMER_DelayIntSafe | ( | uint32_t | usec | ) |
This is a busy wait delay not using energy modes to conserve power.
[in] | usec | Number of microseconds to delay. |
Definition at line 203 of file ustimer.c.
References ECODE_EMDRV_USTIMER_OK.