freqm.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2023 ML!PA Consulting GmbH
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
28 #ifndef PERIPH_FREQM_H
29 #define PERIPH_FREQM_H
30 
31 #include <errno.h>
32 #include <mutex.h>
33 
34 #include "periph_cpu.h"
35 #include "periph/gpio.h"
36 #include "time_units.h"
37 
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41 
50 typedef void (*freqm_cb_t)(uint32_t result, bool overflow, void *context);
51 
55 #ifndef HAVE_FREQM_T
56 typedef uint_fast8_t freqm_t;
57 #endif
58 
64 void freqm_init(freqm_t idx);
65 
78 void freqm_frequency_get_async(freqm_t idx, freqm_cb_t freqm_cb, void *context,
79  uint32_t period_us);
80 
93 int freqm_frequency_get(freqm_t idx, uint32_t *result, uint32_t period_us);
94 
95 #ifdef __cplusplus
96 }
97 #endif
98 
100 #endif /* PERIPH_FREQM_H */
Low-level GPIO peripheral driver interface definitions.
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.
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.
void freqm_init(freqm_t idx)
Initialize the frequency meter.
uint_fast8_t freqm_t
Define default Frequency meter type identifier.
Definition: freqm.h:56
void(* freqm_cb_t)(uint32_t result, bool overflow, void *context)
Frequency meter callback function.
Definition: freqm.h:50
Mutex for thread synchronization.
Utility header providing time unit defines.