mirror of
https://github.com/esp-rs/esp-idf-hal.git
synced 2025-10-02 14:44:51 +00:00
🐛 fix wrong array indexing logic (#331)
* 🐛 fix wrong array indexing logic * using TIMER_MAX instead of TIMER_GROUP_MAX * 🐛 wrong TIMER11 index definition * update CHANGELOG * rearange indexing to - "[ [T00,T01], [T10, T11]]"
This commit is contained in:
parent
6ecb09b2f8
commit
bdbba132f3
@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
|
|||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
## [0.42.3] - 2023-10-29
|
||||||
|
* Fix Timer array index bug #331 - prevented the use of TIMER10 on devices that support only 2 Timers
|
||||||
|
* Fix wrong TIMER11 index definition that declared TIMER11 as TIMER10 #331
|
||||||
|
|
||||||
## [0.42.2] - 2023-10-28
|
## [0.42.2] - 2023-10-28
|
||||||
* Support for latest ESP IDF 5.2 dev (master)
|
* Support for latest ESP IDF 5.2 dev (master)
|
||||||
|
|
||||||
|
21
src/timer.rs
21
src/timer.rs
@ -226,8 +226,7 @@ impl<'d> TimerDriver<'d> {
|
|||||||
self.group(),
|
self.group(),
|
||||||
self.index(),
|
self.index(),
|
||||||
Some(Self::handle_isr),
|
Some(Self::handle_isr),
|
||||||
(self.group() * timer_group_t_TIMER_GROUP_MAX + self.index())
|
(self.group() * timer_idx_t_TIMER_MAX + self.index()) as *mut core::ffi::c_void,
|
||||||
as *mut core::ffi::c_void,
|
|
||||||
0,
|
0,
|
||||||
)
|
)
|
||||||
})?;
|
})?;
|
||||||
@ -267,14 +266,12 @@ impl<'d> TimerDriver<'d> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn reset_wait(&mut self) {
|
pub fn reset_wait(&mut self) {
|
||||||
let notif =
|
let notif = &PIN_NOTIF[(self.group() * timer_idx_t_TIMER_MAX + self.index()) as usize];
|
||||||
&PIN_NOTIF[(self.group() * timer_group_t_TIMER_GROUP_MAX + self.index()) as usize];
|
|
||||||
notif.reset();
|
notif.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn wait(&mut self) -> Result<(), EspError> {
|
pub async fn wait(&mut self) -> Result<(), EspError> {
|
||||||
let notif =
|
let notif = &PIN_NOTIF[(self.group() * timer_idx_t_TIMER_MAX + self.index()) as usize];
|
||||||
&PIN_NOTIF[(self.group() * timer_group_t_TIMER_GROUP_MAX + self.index()) as usize];
|
|
||||||
|
|
||||||
notif.wait().await;
|
notif.wait().await;
|
||||||
|
|
||||||
@ -297,7 +294,7 @@ impl<'d> TimerDriver<'d> {
|
|||||||
|
|
||||||
let callback: Box<dyn FnMut() + Send + 'd> = Box::new(callback);
|
let callback: Box<dyn FnMut() + Send + 'd> = Box::new(callback);
|
||||||
|
|
||||||
ISR_HANDLERS[(self.group() * timer_group_t_TIMER_GROUP_MAX + self.index()) as usize] =
|
ISR_HANDLERS[(self.group() * timer_idx_t_TIMER_MAX + self.index()) as usize] =
|
||||||
Some(unsafe { core::mem::transmute(callback) });
|
Some(unsafe { core::mem::transmute(callback) });
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
@ -310,8 +307,7 @@ impl<'d> TimerDriver<'d> {
|
|||||||
self.disable_interrupt()?;
|
self.disable_interrupt()?;
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
ISR_HANDLERS[(self.group() * timer_group_t_TIMER_GROUP_MAX + self.index()) as usize] =
|
ISR_HANDLERS[(self.group() * timer_idx_t_TIMER_MAX + self.index()) as usize] = None;
|
||||||
None;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
@ -355,11 +351,10 @@ impl<'d> Drop for TimerDriver<'d> {
|
|||||||
|
|
||||||
#[cfg(feature = "alloc")]
|
#[cfg(feature = "alloc")]
|
||||||
unsafe {
|
unsafe {
|
||||||
ISR_HANDLERS[(self.group() * timer_group_t_TIMER_GROUP_MAX + self.index()) as usize] =
|
ISR_HANDLERS[(self.group() * timer_idx_t_TIMER_MAX + self.index()) as usize] = None;
|
||||||
None;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PIN_NOTIF[(self.group() * timer_group_t_TIMER_GROUP_MAX + self.index()) as usize].reset();
|
PIN_NOTIF[(self.group() * timer_idx_t_TIMER_MAX + self.index()) as usize].reset();
|
||||||
|
|
||||||
esp!(unsafe { timer_deinit(self.group(), self.index()) }).unwrap();
|
esp!(unsafe { timer_deinit(self.group(), self.index()) }).unwrap();
|
||||||
}
|
}
|
||||||
@ -432,4 +427,4 @@ impl_timer!(TIMER01: timer_group_t_TIMER_GROUP_0, timer_idx_t_TIMER_1);
|
|||||||
#[cfg(not(esp32c2))]
|
#[cfg(not(esp32c2))]
|
||||||
impl_timer!(TIMER10: timer_group_t_TIMER_GROUP_1, timer_idx_t_TIMER_0);
|
impl_timer!(TIMER10: timer_group_t_TIMER_GROUP_1, timer_idx_t_TIMER_0);
|
||||||
#[cfg(any(esp32, esp32s2, esp32s3))]
|
#[cfg(any(esp32, esp32s2, esp32s3))]
|
||||||
impl_timer!(TIMER11: timer_group_t_TIMER_GROUP_1, timer_idx_t_TIMER_0);
|
impl_timer!(TIMER11: timer_group_t_TIMER_GROUP_1, timer_idx_t_TIMER_1);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user