Comments (7)
I checked the serial_interrupts
and embassy_serial
examples on ESP32-C6 and they work fine for me. Which target are you using?
from esp-hal.
I am using an 8684 (C3) currently but should be able to test on a full size C3 soon. I may have missed some interrupt enable something somewhere but the examples don't look particularly complicated, although slightly outdated. I can dig a little more today but will likely just be working on my own manual implementation to keep things rolling on the project. Let me know if there is something I can do to help!
from esp-hal.
but should be able to test on a full size C3 soon
Out of curiosity, have you been able to test on a C3?
from esp-hal.
No, I ended up just setting the fifo buffer size to 1 and just using the interrupt from that and checking each character so I could keep the project developing. I will have to extend the uart parsing later so I will try to remember to try the interrupt on the new boards.
from esp-hal.
Do you mind trying with main
? You can patch esp-hal
by adding in your Cargo.toml
:
[patch.crates-io]
esp-hal ={ git = "https://github.com/esp-rs/esp-hal"}
You would also require some changes when initializing the uart:
let (tx_pin, rx_pin) = (io.pins.gpio3, io.pins.gpio4);
let config = Config {
baudrate: 115200,
data_bits: DataBits::DataBits8,
parity: Parity::ParityNone,
stop_bits: StopBits::STOP1,
clock_source: ClockSource::Apb,
rx_fifo_full_threshold: READ_BUF_SIZE as u16,
rx_timeout: 10,
};
let mut uart0 =
Uart::new_async_with_config(peripherals.UART0, config, &clocks, tx_pin, rx_pin).unwrap();
uart0.set_at_cmd(AtCmdConfig::new(None, None, None, AT_CMD, None));
let (uart0_tx, uart0_rx) = uart0.split();
from esp-hal.
This works
//! connect GPIO 2 -> GPIO 4
#![no_std]
#![no_main]
//% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3
//% FEATURES: async embassy embassy-time-timg0 embassy-generic-timers
use embassy_executor::Spawner;
use embassy_time::Timer;
use esp_backtrace as _;
use esp_hal::{
clock::ClockControl,
gpio::Io,
peripherals::{Peripherals, UART1},
prelude::*,
system::SystemControl,
timer::timg::TimerGroup,
uart::{
config::{AtCmdConfig, Config},
Uart,
UartRx,
UartTx,
},
Async,
};
use esp_println::println;
// rx_fifo_full_threshold
const READ_BUF_SIZE: usize = 64;
// EOT (CTRL-D)
const AT_CMD: u8 = 0x04;
#[embassy_executor::task]
async fn writer(mut tx: UartTx<'static, UART1, Async>) {
loop {
tx.write_async("testing!\x04".as_bytes()).await.ok();
Timer::after_secs(1).await;
}
}
#[embassy_executor::task]
async fn reader(mut rx: UartRx<'static, UART1, Async>) {
const MAX_BUFFER_SIZE: usize = 10 * READ_BUF_SIZE + 16;
let mut rbuf: [u8; MAX_BUFFER_SIZE] = [0u8; MAX_BUFFER_SIZE];
let mut offset = 0;
loop {
println!("reading");
let r = rx.read_async(&mut rbuf[offset..]).await;
match r {
Ok(len) => {
offset += len;
println!("Read: {len}, data: {:?}", &rbuf[..offset]);
offset = 0;
}
Err(e) => println!("RX Error: {:?}", e),
}
}
}
#[main]
async fn main(spawner: Spawner) {
esp_println::logger::init_logger_from_env();
println!("Init!");
let peripherals = Peripherals::take();
let system = SystemControl::new(peripherals.SYSTEM);
let clocks = ClockControl::boot_defaults(system.clock_control).freeze();
let timg0 = TimerGroup::new_async(peripherals.TIMG0, &clocks);
esp_hal_embassy::init(&clocks, timg0);
let io = Io::new(peripherals.GPIO, peripherals.IO_MUX);
let (tx_pin, rx_pin) = (io.pins.gpio2, io.pins.gpio4);
let config = Config::default().rx_fifo_full_threshold(READ_BUF_SIZE as u16);
let mut uart0 =
Uart::new_async_with_config(peripherals.UART1, config, &clocks, tx_pin, rx_pin).unwrap();
uart0.set_at_cmd(AtCmdConfig::new(Some(0), Some(0), None, AT_CMD, None));
let (tx, rx) = uart0.split();
spawner.spawn(reader(rx)).ok();
spawner.spawn(writer(tx)).ok();
}
But it's a bit pointless since currently we cannot disable rx_timeout
- so even without AT-CMD detection the outcome will be the same since the timeout triggers the interrupt. Probably we should change rx_timeout
to be Option in the config struct
from esp-hal.
I believe with #1759 merged this can be closed, however if I am mistaken please feel free to re-open the issue.
from esp-hal.
Related Issues (20)
- DMA Queuing API
- esp-backtrace (0.12.1) - error[E0583]: file not found for module `arc` HOT 1
- When using I2C + shared bus + embassy, if there is no slave device at the accessed address, subsequent I2C operations will send the same signal repeatedly.
- Missing ErasedTimer from imports HOT 5
- Resolve ADC ESP32C6 calibration issues
- Deny warnings in CI
- Bugs in FlashSafeDma<SpiDma> HOT 3
- Question about trait `CreateErasedPin` being `#[doc(hidden)]` HOT 2
- Explore using cargo semver checks HOT 1
- Example wifi_embassy_dhcp not working HOT 5
- release `esp-backtrace` HOT 3
- Flash is not erased when HIL tests fail
- `usb_serial_jtag` example freezes when pressing a key HOT 5
- esp-wifi 0.7 does not compile with embedded-svc feature HOT 7
- Pretty printing panic messages on nightly broken
- ESP32 PSRAM duplicate branch HOT 1
- Expose SPI sio() setting HOT 2
- Expose interrupt state of Pin when wrapped in Input<> HOT 2
- There is currently no way to configure WDT to do anything but a system reset
- I2S write broken HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from esp-hal.