Crate esp_pwm_reader
source ·Expand description
esp_pwm_reader
Wrapper around the mcpwm capture module for reading pwm signals.
Documentation
Usage
- you need to create a capture timer which can then be used by multiple channel readers
- f.e.
use channel_reader::{CaptureTimer, ChannelReader}; use esp_idf_hal::delay::FreeRtos; use esp_idf_sys::{ gpio_num_t_GPIO_NUM_16, gpio_num_t_GPIO_NUM_17 }; fn main() { let capture_timer = CaptureTimer::new(0).unwrap(); let channel1 = ChannelReader::new(&capture_timer, gpio_num_t_GPIO_NUM_16).unwrap(); let channel2 = ChannelReader::new(&capture_timer, gpio_num_t_GPIO_NUM_17).unwrap(); loop { println!( "ch1: {} ch2: {}", channel1.get_value(), channel2.get_value() ); FreeRtos::delay_ms(11); } }
Structs
- This timer is used by a capture Channel insinde a ChannelReader. It can be used by multiple ChannelReader instance. Also see https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/peripherals/mcpwm.html?highlight=mcpwm_new_capture_timer#capture
- Can read the current value of the PWM signal on the specified pin in microseconds
Enums
- Errors which can occur by calls to the mcpwm submodule of the esp-idf at different stages. See mcpwm_capture_timer_enable ff.: https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/peripherals/mcpwm.html?highlight=mcpwm_new_capture_timer#_CPPv426mcpwm_capture_timer_enable24mcpwm_cap_timer_handle_t
- Errors which can occur by calls to the mcpwm submodule of the esp-idf at different stages. See mcpwm_new_capture_channel ff.: https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/peripherals/mcpwm.html?highlight=mcpwm_new_capture_timer#_CPPv425mcpwm_new_capture_channel24mcpwm_cap_timer_handle_tPK30mcpwm_capture_channel_config_tP26mcpwm_cap_channel_handle_t