Skip to content

Commit

Permalink
Compat with ESP IDF master
Browse files Browse the repository at this point in the history
  • Loading branch information
ivmarkov committed Dec 23, 2024
1 parent 5048f05 commit 4829989
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
25 changes: 17 additions & 8 deletions src/can.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,63 +97,55 @@ pub mod config {
tseg_1: 16,
tseg_2: 8,
sjw: 3,
triple_sampling: false,
..Default::default()
},
Timing::B50K => twai_timing_config_t {
brp: 80,
tseg_1: 15,
tseg_2: 4,
sjw: 3,
triple_sampling: false,
..Default::default()
},
Timing::B100K => twai_timing_config_t {
brp: 40,
tseg_1: 15,
tseg_2: 4,
sjw: 3,
triple_sampling: false,
..Default::default()
},
Timing::B125K => twai_timing_config_t {
brp: 32,
tseg_1: 15,
tseg_2: 4,
sjw: 3,
triple_sampling: false,
..Default::default()
},
Timing::B250K => twai_timing_config_t {
brp: 16,
tseg_1: 15,
tseg_2: 4,
sjw: 3,
triple_sampling: false,
..Default::default()
},
Timing::B500K => twai_timing_config_t {
brp: 8,
tseg_1: 15,
tseg_2: 4,
sjw: 3,
triple_sampling: false,
..Default::default()
},
Timing::B800K => twai_timing_config_t {
brp: 4,
tseg_1: 16,
tseg_2: 8,
sjw: 3,
triple_sampling: false,
..Default::default()
},
Timing::B1M => twai_timing_config_t {
brp: 4,
tseg_1: 15,
tseg_2: 4,
sjw: 3,
triple_sampling: false,
..Default::default()
},
Timing::Custom {
Expand All @@ -167,7 +159,24 @@ pub mod config {
tseg_1: timing_segment_1,
tseg_2: timing_segment_2,
sjw: synchronization_jump_width,
#[cfg(
any(esp_idf_version_major = "4"),
esp_idf_version = "5.0",
esp_idf_version = "5.1",
esp_idf_version = "5.2",
esp_idf_version = "5.3"
)]
triple_sampling,
#[cfg(not(
any(esp_idf_version_major = "4"),
esp_idf_version = "5.0",
esp_idf_version = "5.1",
esp_idf_version = "5.2",
esp_idf_version = "5.3"
))]
__bindgen_anon_1: twai_timing_config_t__bindgen_ty_1 {
triple_sampling,
},
..Default::default()
},
}
Expand Down
11 changes: 7 additions & 4 deletions src/i2s/pdm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,8 @@ pub(super) mod config {
clk: PeripheralRef<'d, impl OutputPin>,
din: PeripheralRef<'d, impl InputPin>,
) -> i2s_pdm_rx_gpio_config_t {
let mut dins: [gpio_num_t; SOC_I2S_PDM_MAX_RX_LINES] = [-1; SOC_I2S_PDM_MAX_RX_LINES];
let mut dins: [gpio_num_t; SOC_I2S_PDM_MAX_RX_LINES as usize] =
[-1; SOC_I2S_PDM_MAX_RX_LINES as usize];
dins[0] = din.pin();

let pins = i2s_pdm_rx_gpio_config_t__bindgen_ty_1 { dins };
Expand Down Expand Up @@ -358,11 +359,11 @@ pub(super) mod config {
clk: PeripheralRef<'d, impl OutputPin>,
dins: &[PeripheralRef<'d, impl InputPin>],
) -> i2s_pdm_rx_gpio_config_t {
let mut din_pins: [gpio_num_t; SOC_I2S_PDM_MAX_RX_LINES] =
[-1; SOC_I2S_PDM_MAX_RX_LINES];
let mut din_pins: [gpio_num_t; SOC_I2S_PDM_MAX_RX_LINES as usize] =
[-1; SOC_I2S_PDM_MAX_RX_LINES as usize];

for (i, din) in dins.iter().enumerate() {
if i >= SOC_I2S_PDM_MAX_RX_LINES {
if i >= SOC_I2S_PDM_MAX_RX_LINES as usize {
break;
}

Expand Down Expand Up @@ -490,12 +491,14 @@ pub(super) mod config {
/// representation.
#[cfg(esp_idf_soc_i2s_supports_pdm_rx)]
#[inline(always)]
#[allow(clippy::needless_update)]
pub(super) fn as_sdk(&self) -> i2s_pdm_rx_slot_config_t {
i2s_pdm_rx_slot_config_t {
data_bit_width: self.data_bit_width.as_sdk(),
slot_bit_width: self.slot_bit_width.as_sdk(),
slot_mode: self.slot_mode.as_sdk(),
slot_mask: self.slot_mask.as_sdk(),
..Default::default()
}
}
}
Expand Down

0 comments on commit 4829989

Please sign in to comment.