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 
9 #pragma once
10 
30 #include <errno.h>
31 #include <mutex.h>
32 
33 #include "periph_cpu.h"
34 #include "periph/gpio.h"
35 #include "time_units.h"
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
49 typedef void (*freqm_cb_t)(uint32_t result, bool overflow, void *context);
50 
54 #ifndef HAVE_FREQM_T
55 typedef uint_fast8_t freqm_t;
56 #endif
57 
63 void freqm_init(freqm_t idx);
64 
77 void freqm_frequency_get_async(freqm_t idx, freqm_cb_t freqm_cb, void *context,
78  uint32_t period_us);
79 
92 int freqm_frequency_get(freqm_t idx, uint32_t *result, uint32_t period_us);
93 
94 #ifdef __cplusplus
95 }
96 #endif
97 
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:55
void(* freqm_cb_t)(uint32_t result, bool overflow, void *context)
Frequency meter callback function.
Definition: freqm.h:49
Mutex for thread synchronization.
Utility header providing time unit defines.