FREQM peripheral driver interface.
More...
FREQM peripheral driver interface.
This interface allows to configure and use the Frequency Meter (FREQM) peripheral.
The Frequency Meter uses the frequency of a known reference clock to determine the frequency of a signal connected via GPIO.
|
file | freqm.h |
| FREQM peripheral driver interface definitions.
|
|
|
typedef void(* | freqm_cb_t) (uint32_t result, bool overflow, void *context) |
| Frequency meter callback function.
|
|
typedef uint_fast8_t | freqm_t |
| Define default Frequency meter type identifier.
|
|
◆ freqm_cb_t
typedef void(* freqm_cb_t) (uint32_t result, bool overflow, void *context) |
Frequency meter callback function.
When a measurement is done the callbackfunction is called.
- Parameters
-
result | measured frequency in hz |
overflow | overflow in sticky counter |
context | pointer to user defined context data |
Definition at line 50 of file freqm.h.
◆ freqm_t
Define default Frequency meter type identifier.
Definition at line 56 of file freqm.h.
◆ freqm_frequency_get()
int freqm_frequency_get |
( |
freqm_t |
idx, |
|
|
uint32_t * |
result, |
|
|
uint32_t |
period_us |
|
) |
| |
Read number of periods of measured clock and calculate its frequency.
This function uses a blocking mutex to wait for the measurement to finish.
- Parameters
-
[in] | idx | index of the configuration |
[out] | result | calculated frequency |
[in] | period_us | measurement duration in microseconds |
- Returns
- -EOVERFLOW if FREQM sticky counter has an overflow
-
0 on success
◆ freqm_frequency_get_async()
void freqm_frequency_get_async |
( |
freqm_t |
idx, |
|
|
freqm_cb_t |
freqm_cb, |
|
|
void * |
context, |
|
|
uint32_t |
period_us |
|
) |
| |
Read number of periods of measured clock and calculate its frequency.
This function returns after triggering the measurement and calls freqm_callback
, with the calculated result and context
, when the measurement is done.
- Parameters
-
[in] | idx | index of the configuration |
[in] | freqm_cb | callback function when measurement is ready |
[in] | context | context for the callback function |
[in] | period_us | measurement duration in microseconds |
◆ freqm_init()
Initialize the frequency meter.
- Parameters
-
[in] | idx | index of the configuration |