esp32-freqcount
ESP32-compatible C library for ESP32-freqcount component.
All Data Structures Files Functions Variables
frequency_count.h
Go to the documentation of this file.
1 /*
2  * MIT License
3  *
4  * Copyright (c) 2018 Chris Morgan <chmorgan@gmail.com>
5  * Copyright (c) 2018 David Antliff
6  *
7  * Permission is hereby granted, free of charge, to any person obtaining a copy
8  * of this software and associated documentation files (the "Software"), to deal
9  * in the Software without restriction, including without limitation the rights
10  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11  * copies of the Software, and to permit persons to whom the Software is
12  * furnished to do so, subject to the following conditions:
13  *
14  * The above copyright notice and this permission notice shall be included in all
15  * copies or substantial portions of the Software.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23  * SOFTWARE.
24  */
25 
47 #pragma once
48 #ifndef FREQUENCY_COUNT_H
49 #define FREQUENCY_COUNT_H
50 
51 #include <stdint.h>
52 #include "driver/pcnt.h"
53 #include "driver/rmt.h"
54 
55 #ifdef __cplusplus
56 extern "C" {
57 #endif
58 
59 typedef struct
60 {
61  gpio_num_t pcnt_gpio;
62  pcnt_unit_t pcnt_unit;
63  pcnt_channel_t pcnt_channel;
64  gpio_num_t rmt_gpio;
65  rmt_channel_t rmt_channel;
66  uint8_t rmt_clk_div;
67  uint8_t rmt_max_blocks;
70  uint16_t filter_length;
71  void (*window_start_callback)(void);
72  void (*frequency_update_callback)(double hz);
74 
78 void frequency_count_task_function(void * pvParameter);
79 
80 #ifdef __cplusplus
81 }
82 #endif
83 
84 #endif // FREQUENCY_COUNT
Definition: frequency_count.h:59
void frequency_count_task_function(void *pvParameter)
Task function - pass this to xTaskCreate with a pointer to an instance of frequency_count_configurati...
Definition: frequency_count.c:139
pcnt_unit_t pcnt_unit
PCNT unit to use for counting.
Definition: frequency_count.h:62
uint8_t rmt_clk_div
RMT pulse length, as a divider of the APB clock.
Definition: frequency_count.h:66
gpio_num_t pcnt_gpio
count events on this GPIO
Definition: frequency_count.h:61
pcnt_channel_t pcnt_channel
PCNT channel to use for counting.
Definition: frequency_count.h:63
uint16_t filter_length
counter filter length in APB cycles
Definition: frequency_count.h:70
gpio_num_t rmt_gpio
used by RMT to define a sampling window
Definition: frequency_count.h:64
float sampling_window_seconds
sample window length (in seconds)
Definition: frequency_count.h:69
rmt_channel_t rmt_channel
The RMT channel to use.
Definition: frequency_count.h:65
float sampling_period_seconds
time (in seconds) between start of adjacent samples
Definition: frequency_count.h:68
uint8_t rmt_max_blocks
Maximum number of RMT RAM blocks that can be used by task. Each block provides 64 RMT items and each ...
Definition: frequency_count.h:67