mirror of
https://github.com/esp-rs/esp-hal.git
synced 2025-09-28 04:40:52 +00:00
Erase TWAI (#2359)
* Swap order of generics * Don't refer to Instance in irq handler * Deduplicate a bit * Take &self * Reduce nesting * Erase TWAI instance
This commit is contained in:
parent
1de2483609
commit
c163b0586a
@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- `AnyPin` now implements `From<GpioPin<N>>`. (#2326)
|
||||
- Added `AnySpi` and `AnySpiDmaChannel`. (#2334)
|
||||
- Added `AnyI2s` and `AnyI2sDmaChannel`. (#2367)
|
||||
- Added `AnyTwai`. (#2359)
|
||||
- `Pins::steal()` to unsafely obtain GPIO. (#2335)
|
||||
- `I2c::with_timeout` (#2361)
|
||||
|
||||
@ -23,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- Peripheral type erasure for SPI (#2334)
|
||||
- Peripheral type erasure for I2S (#2367)
|
||||
- Peripheral type erasure for I2C (#2361)
|
||||
- Peripheral type erasure for TWAI (#2359)
|
||||
|
||||
### Fixed
|
||||
|
||||
|
@ -31,6 +31,7 @@ peripherals:
|
||||
- SPI (both master and slave)
|
||||
- I2S
|
||||
- I2C
|
||||
- TWAI
|
||||
|
||||
```diff
|
||||
-Spi<'static, SPI2, FullDuplexMode>
|
||||
|
@ -67,7 +67,7 @@ crate::peripherals! {
|
||||
TIMG0 <= TIMG0,
|
||||
TIMG1 <= TIMG1,
|
||||
TOUCH <= virtual,
|
||||
TWAI0 <= TWAI0,
|
||||
[Twai0] TWAI0 <= TWAI0,
|
||||
UART0 <= UART0,
|
||||
UART1 <= UART1,
|
||||
UART2 <= UART2,
|
||||
|
@ -53,7 +53,7 @@ crate::peripherals! {
|
||||
SW_INTERRUPT <= virtual,
|
||||
TIMG0 <= TIMG0,
|
||||
TIMG1 <= TIMG1,
|
||||
TWAI0 <= TWAI0,
|
||||
[Twai0] TWAI0 <= TWAI0,
|
||||
UART0 <= UART0,
|
||||
UART1 <= UART1,
|
||||
UHCI0 <= UHCI0,
|
||||
|
@ -81,8 +81,8 @@ crate::peripherals! {
|
||||
TIMG0 <= TIMG0,
|
||||
TIMG1 <= TIMG1,
|
||||
TRACE0 <= TRACE,
|
||||
TWAI0 <= TWAI0,
|
||||
TWAI1 <= TWAI1,
|
||||
[Twai0] TWAI0 <= TWAI0,
|
||||
[Twai1] TWAI1 <= TWAI1,
|
||||
UART0 <= UART0,
|
||||
UART1 <= UART1,
|
||||
UHCI0 <= UHCI0,
|
||||
|
@ -73,7 +73,7 @@ crate::peripherals! {
|
||||
TIMG0 <= TIMG0,
|
||||
TIMG1 <= TIMG1,
|
||||
TRACE0 <= TRACE,
|
||||
TWAI0 <= TWAI0,
|
||||
[Twai0] TWAI0 <= TWAI0,
|
||||
UART0 <= UART0,
|
||||
UART1 <= UART1,
|
||||
UHCI0 <= UHCI0,
|
||||
|
@ -60,7 +60,7 @@ crate::peripherals! {
|
||||
SW_INTERRUPT <= virtual,
|
||||
TIMG0 <= TIMG0,
|
||||
TIMG1 <= TIMG1,
|
||||
TWAI0 <= TWAI0,
|
||||
[Twai0] TWAI0 <= TWAI0,
|
||||
UART0 <= UART0,
|
||||
UART1 <= UART1,
|
||||
UHCI0 <= UHCI0,
|
||||
|
@ -66,7 +66,7 @@ crate::peripherals! {
|
||||
SW_INTERRUPT <= virtual,
|
||||
TIMG0 <= TIMG0,
|
||||
TIMG1 <= TIMG1,
|
||||
TWAI0 <= TWAI0,
|
||||
[Twai0] TWAI0 <= TWAI0,
|
||||
UART0 <= UART0,
|
||||
UART1 <= UART1,
|
||||
UART2 <= UART2,
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -36,8 +36,6 @@ use embedded_can::{Frame, Id};
|
||||
use esp_backtrace as _;
|
||||
use esp_hal::{
|
||||
gpio::Io,
|
||||
interrupt,
|
||||
peripherals::{self, TWAI0},
|
||||
timer::timg::TimerGroup,
|
||||
twai::{self, EspTwaiFrame, StandardId, TwaiMode, TwaiRx, TwaiTx},
|
||||
};
|
||||
@ -47,10 +45,7 @@ use static_cell::StaticCell;
|
||||
type TwaiOutbox = Channel<NoopRawMutex, EspTwaiFrame, 16>;
|
||||
|
||||
#[embassy_executor::task]
|
||||
async fn receiver(
|
||||
mut rx: TwaiRx<'static, TWAI0, esp_hal::Async>,
|
||||
channel: &'static TwaiOutbox,
|
||||
) -> ! {
|
||||
async fn receiver(mut rx: TwaiRx<'static, esp_hal::Async>, channel: &'static TwaiOutbox) -> ! {
|
||||
loop {
|
||||
let frame = rx.receive_async().await;
|
||||
|
||||
@ -72,10 +67,7 @@ async fn receiver(
|
||||
}
|
||||
|
||||
#[embassy_executor::task]
|
||||
async fn transmitter(
|
||||
mut tx: TwaiTx<'static, TWAI0, esp_hal::Async>,
|
||||
channel: &'static TwaiOutbox,
|
||||
) -> ! {
|
||||
async fn transmitter(mut tx: TwaiTx<'static, esp_hal::Async>, channel: &'static TwaiOutbox) -> ! {
|
||||
loop {
|
||||
let frame = channel.receive().await;
|
||||
let result = tx.transmit_async(&frame).await;
|
||||
@ -141,12 +133,6 @@ async fn main(spawner: Spawner) {
|
||||
// Get separate transmit and receive halves of the peripheral.
|
||||
let (rx, tx) = twai.split();
|
||||
|
||||
interrupt::enable(
|
||||
peripherals::Interrupt::TWAI0,
|
||||
interrupt::Priority::Priority1,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
static CHANNEL: StaticCell<TwaiOutbox> = StaticCell::new();
|
||||
let channel = &*CHANNEL.init(Channel::new());
|
||||
|
||||
|
@ -8,7 +8,6 @@
|
||||
use embedded_hal_02::can::Frame;
|
||||
use esp_hal::{
|
||||
gpio::Io,
|
||||
peripherals::TWAI0,
|
||||
prelude::*,
|
||||
twai::{self, filter::SingleStandardFilter, EspTwaiFrame, StandardId, TwaiMode},
|
||||
Blocking,
|
||||
@ -17,7 +16,7 @@ use hil_test as _;
|
||||
use nb::block;
|
||||
|
||||
struct Context {
|
||||
twai: twai::Twai<'static, TWAI0, Blocking>,
|
||||
twai: twai::Twai<'static, Blocking>,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
Loading…
x
Reference in New Issue
Block a user