esp_idf_sys/pcnt.rs
1#![allow(non_camel_case_types, non_upper_case_globals)]
2
3// The following is defined to remove a case where bindgen can't handle pcnt_unit_t being defined
4// in two different C namespaces (enum vs struct). The struct is opaque (used only as a pointer to an
5// opaque type via pcnt_channel_handle_t), so we use the enum definition here, taken from the v4
6// bindgen.
7
8/// Selection of all available PCNT units
9pub type pcnt_unit_t = core::ffi::c_int;
10
11/// PCNT unit 0
12pub const pcnt_unit_t_PCNT_UNIT_0: pcnt_unit_t = 0;
13
14/// PCNT unit 1
15pub const pcnt_unit_t_PCNT_UNIT_1: pcnt_unit_t = 1;
16
17/// PCNT unit 2
18pub const pcnt_unit_t_PCNT_UNIT_2: pcnt_unit_t = 2;
19
20/// PCNT unit 3
21pub const pcnt_unit_t_PCNT_UNIT_3: pcnt_unit_t = 3;
22
23// Ideally, we'd use a conditional off of SOC_PCNT_UNITS_PER_GROUP, but that's not possible in Rust.
24// Today, ESP32 is the only chip that has 8 units. All others have 4 (except ESP32-C3, which doesn't
25// have PCNT at all). For new chips, check $IDF_PATH/components/soc/$CHIP/include/soc/soc_caps.h for
26// for the value of SOC_PCNT_UNITS_PER_GROUP.
27
28#[cfg(esp32)]
29/// PCNT unit 4
30pub const pcnt_unit_t_PCNT_UNIT_4: pcnt_unit_t = 4;
31
32#[cfg(esp32)]
33/// PCNT unit 5
34pub const pcnt_unit_t_PCNT_UNIT_5: pcnt_unit_t = 5;
35
36#[cfg(esp32)]
37/// PCNT unit 6
38pub const pcnt_unit_t_PCNT_UNIT_6: pcnt_unit_t = 6;
39
40#[cfg(esp32)]
41/// PCNT unit 7
42pub const pcnt_unit_t_PCNT_UNIT_7: pcnt_unit_t = 7;
43
44// For some reason, this isn't defined in soc_caps.h for ESP32-H2 on ESP-IDF v4.x
45
46/// Maximum number of PCNT units
47#[cfg(not(all(esp32h2, esp_idf_version_major = "4")))]
48pub const pcnt_unit_t_PCNT_UNIT_MAX: pcnt_unit_t = crate::SOC_PCNT_UNITS_PER_GROUP as pcnt_unit_t;
49
50/// Maximum number of PCNT units
51#[cfg(all(esp32h2, esp_idf_version_major = "4"))]
52pub const pcnt_unit_t_PCNT_UNIT_MAX: pcnt_unit_t = 4;