Skip to content

Commit 8451583

Browse files
committed
feat: update esp-hal to 1.0.0-beta.0
1 parent 94915a3 commit 8451583

File tree

10 files changed

+222
-167
lines changed

10 files changed

+222
-167
lines changed

Cargo.lock

Lines changed: 117 additions & 103 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,23 @@ authors = ["filipton <filipton12@gmail.com>"]
55
edition = "2021"
66

77
[dependencies]
8-
esp-backtrace = { version = "0.15.0", features = [ "exception-handler", "panic-handler", "println", "custom-pre-backtrace", "custom-halt" ] }
9-
esp-hal = { version = "0.23.1", features = [ ] }
10-
esp-println = { version = "0.13.0", features = ["log"] }
11-
log = { version = "0.4.25" }
12-
esp-wifi = { version = "0.12.0", features = ["coex"] }
13-
esp-hal-embassy = { version = "0.6.0", features = [] }
8+
esp-backtrace = { version = "0.15.1", features = [ "exception-handler", "panic-handler", "println", "custom-pre-backtrace", "custom-halt" ] }
9+
esp-hal = { version = "1.0.0-beta.0", features = [ ] }
10+
esp-println = { version = "0.13.1", features = ["log"] }
11+
log = { version = "0.4.26" }
12+
esp-wifi = { version = "0.13.0", features = ["coex"] }
13+
esp-hal-embassy = { version = "0.7.0", features = [] }
1414
embassy-executor = { version = "0.7.0", features = ["arch-riscv32", "nightly"] }
1515
embassy-net = { version = "0.6.0", features = ["tcp", "udp", "multicast", "dhcpv4", "medium-ethernet", "proto-ipv4", "dns"] }
1616
embassy-time = { version = "0.4.0" }
17-
esp-storage = { version = "0.4.0", features = [] }
17+
esp-storage = { version = "0.5.0", features = [] }
1818
embedded-storage = "0.3.1"
1919
static_cell = { version = "2.1.0", features = ["nightly"] }
2020
heapless = { version = "0.8.0", default-features = false }
21-
esp-alloc = "0.6.0"
21+
esp-alloc = "0.7.0"
2222
esp-hal-wifimanager = { git = "https://github.com/filipton/esp-hal-wifimanager", default-features = false, features = ["ap", "ble"] }
23-
serde = { version = "1.0.217", features = ["alloc", "derive"], default-features = false }
24-
serde_json = { version = "1.0.138", default-features = false, features = ["alloc"] }
23+
serde = { version = "1.0.218", features = ["alloc", "derive"], default-features = false }
24+
serde_json = { version = "1.0.139", default-features = false, features = ["alloc"] }
2525
adv-shift-registers = "0.2.5"
2626
embedded-hal = "1.0.0"
2727
esp-hal-mdns = "0.1.0"
@@ -30,17 +30,17 @@ macros = { path = "./macros" }
3030
nb = "1.1.0"
3131
embassy-futures = "0.1.1"
3232
embassy-sync = "0.6.2"
33-
ws-framer = { version = "0.2.2", features = ["alloc"] }
33+
ws-framer = { version = "=0.2.2", features = ["alloc"] }
3434
embedded-hal-async = "1.0.0"
35-
portable-atomic = { version = "1.10.0", default-features = false }
35+
portable-atomic = { version = "1.11.0", default-features = false }
3636
critical-section = "1.2.0"
3737
getrandom = { version = "0.2.15", features = ["custom"] }
38-
uuid = { version = "1.12.1", default-features = false, features = ["v4"] }
38+
uuid = { version = "=1.12.1", default-features = false, features = ["v4"] }
3939
dyn-smooth = "0.2.0"
40-
esp-hal-ota = { version = "0.3.2", features = [] }
41-
esp32c3 = { version = "0.27.0", optional = true }
42-
esp32 = { version = "0.35.0", optional = true }
43-
anyhow = { version = "1.0.95", default-features = false }
40+
esp-hal-ota = { version = "0.4.0", features = [] }
41+
esp32c3 = { version = "0.28.0", optional = true }
42+
esp32 = { version = "0.36.0", optional = true }
43+
anyhow = { version = "1.0.96", default-features = false }
4444
embedded-hal-bus = { version = "0.3.0", features = ["async"] }
4545
embedded-tls = { version = "0.17.0", default-features = false, features = ["alloc", "embedded-io-adapters", "log"] }
4646
rand_core = { version = "0.6.4", features = ["getrandom"] }

src/buttons.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ async fn wakeup_button(
8686
if sleep_state() {
8787
state.state.signal();
8888
if deeper_sleep_state() {
89-
esp_hal::reset::software_reset();
89+
esp_hal::system::software_reset();
9090
}
9191

9292
return Ok(true);
@@ -337,9 +337,7 @@ async fn submit_reset_wifi(
337337
}
338338

339339
Timer::after_millis(500).await;
340-
esp_hal::reset::software_reset();
341-
342-
Ok(false)
340+
esp_hal::system::software_reset();
343341
}
344342

345343
#[macros::button_handler]

src/main.rs

Lines changed: 61 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@ use structs::ConnSettings;
2323
use utils::{logger::FkmLogger, set_brownout_detection};
2424
use ws_framer::{WsUrl, WsUrlOwned};
2525

26-
#[cfg(feature = "esp32")]
27-
use esp_hal::time::RateExtU32;
28-
2926
mod battery;
3027
mod buttons;
3128
mod consts;
@@ -62,12 +59,12 @@ async fn main(spawner: Spawner) {
6259

6360
#[cfg(feature = "esp32")]
6461
{
65-
config.cpu_clock = esp_hal::clock::CpuClock::_80MHz;
62+
config = config.with_cpu_clock(esp_hal::clock::CpuClock::_80MHz);
6663
}
6764

6865
#[cfg(feature = "esp32c3")]
6966
{
70-
config.cpu_clock = esp_hal::clock::CpuClock::_80MHz;
67+
config = config.with_cpu_clock(esp_hal::clock::CpuClock::_80MHz);
7168
}
7269

7370
config
@@ -79,7 +76,7 @@ async fn main(spawner: Spawner) {
7976

8077
#[cfg(not(feature = "esp32"))]
8178
{
82-
esp_alloc::heap_allocator!(120 * 1024);
79+
esp_alloc::heap_allocator!(size: 120 * 1024);
8380
}
8481

8582
{
@@ -123,11 +120,23 @@ async fn main(spawner: Spawner) {
123120
#[cfg(feature = "esp32")]
124121
let stackmat_rx = peripherals.GPIO4.degrade();
125122
#[cfg(feature = "esp32")]
126-
let shifter_data_pin = Output::new(peripherals.GPIO16, esp_hal::gpio::Level::Low);
123+
let shifter_data_pin = Output::new(
124+
peripherals.GPIO16,
125+
esp_hal::gpio::Level::Low,
126+
Default::default(),
127+
);
127128
#[cfg(feature = "esp32")]
128-
let shifter_clk_pin = Output::new(peripherals.GPIO12, esp_hal::gpio::Level::Low);
129+
let shifter_clk_pin = Output::new(
130+
peripherals.GPIO12,
131+
esp_hal::gpio::Level::Low,
132+
Default::default(),
133+
);
129134
#[cfg(feature = "esp32")]
130-
let shifter_latch_pin = Output::new(peripherals.GPIO17, esp_hal::gpio::Level::Low);
135+
let shifter_latch_pin = Output::new(
136+
peripherals.GPIO17,
137+
esp_hal::gpio::Level::Low,
138+
Default::default(),
139+
);
131140

132141
#[cfg(feature = "esp32c3")]
133142
let sck = peripherals.GPIO4.degrade();
@@ -140,11 +149,23 @@ async fn main(spawner: Spawner) {
140149
#[cfg(feature = "esp32c3")]
141150
let stackmat_rx = peripherals.GPIO20.degrade();
142151
#[cfg(feature = "esp32c3")]
143-
let shifter_data_pin = Output::new(peripherals.GPIO10, esp_hal::gpio::Level::Low);
152+
let shifter_data_pin = Output::new(
153+
peripherals.GPIO10,
154+
esp_hal::gpio::Level::Low,
155+
Default::default(),
156+
);
144157
#[cfg(feature = "esp32c3")]
145-
let shifter_latch_pin = Output::new(peripherals.GPIO1, esp_hal::gpio::Level::Low);
158+
let shifter_latch_pin = Output::new(
159+
peripherals.GPIO1,
160+
esp_hal::gpio::Level::Low,
161+
Default::default(),
162+
);
146163
#[cfg(feature = "esp32c3")]
147-
let shifter_clk_pin = Output::new(peripherals.GPIO21, esp_hal::gpio::Level::Low);
164+
let shifter_clk_pin = Output::new(
165+
peripherals.GPIO21,
166+
esp_hal::gpio::Level::Low,
167+
Default::default(),
168+
);
148169

149170
let mut adv_shift_reg = adv_shift_registers::AdvancedShiftRegister::<8, _>::new(
150171
shifter_data_pin,
@@ -164,16 +185,31 @@ async fn main(spawner: Spawner) {
164185
.set_data(&[!crate::utils::stackmat::DEC_DIGITS[8] ^ crate::utils::stackmat::DOT_MOD; 6]);
165186

166187
#[cfg(feature = "esp32")]
167-
let button_1 = Input::new(peripherals.GPIO27, esp_hal::gpio::Pull::Up);
188+
let button_1 = Input::new(
189+
peripherals.GPIO27,
190+
esp_hal::gpio::InputConfig::default().with_pull(esp_hal::gpio::Pull::Down),
191+
);
168192
#[cfg(feature = "esp32")]
169-
let button_2 = Input::new(peripherals.GPIO26, esp_hal::gpio::Pull::Up);
193+
let button_2 = Input::new(
194+
peripherals.GPIO26,
195+
esp_hal::gpio::InputConfig::default().with_pull(esp_hal::gpio::Pull::Down),
196+
);
170197
#[cfg(feature = "esp32")]
171-
let button_3 = Input::new(peripherals.GPIO33, esp_hal::gpio::Pull::Up);
198+
let button_3 = Input::new(
199+
peripherals.GPIO33,
200+
esp_hal::gpio::InputConfig::default().with_pull(esp_hal::gpio::Pull::Down),
201+
);
172202
#[cfg(feature = "esp32")]
173-
let button_4 = Input::new(peripherals.GPIO32, esp_hal::gpio::Pull::Up);
203+
let button_4 = Input::new(
204+
peripherals.GPIO32,
205+
esp_hal::gpio::InputConfig::default().with_pull(esp_hal::gpio::Pull::Down),
206+
);
174207

175208
#[cfg(feature = "esp32c3")]
176-
let button_input = Input::new(peripherals.GPIO3, esp_hal::gpio::Pull::Down);
209+
let button_input = Input::new(
210+
peripherals.GPIO3,
211+
esp_hal::gpio::InputConfig::default().with_pull(esp_hal::gpio::Pull::Down),
212+
);
177213

178214
#[cfg(feature = "esp32c3")]
179215
let buttons_shifter = adv_shift_reg.get_shifter_mut(0);
@@ -191,7 +227,11 @@ async fn main(spawner: Spawner) {
191227
};
192228

193229
#[cfg(feature = "esp32")]
194-
let cs_pin = Output::new(peripherals.GPIO5, esp_hal::gpio::Level::High);
230+
let cs_pin = Output::new(
231+
peripherals.GPIO5,
232+
esp_hal::gpio::Level::High,
233+
Default::default(),
234+
);
195235

196236
let global_state = Rc::new(GlobalStateInner::new(&nvs));
197237
let wifi_setup_sig = Rc::new(Signal::new());
@@ -200,7 +240,7 @@ async fn main(spawner: Spawner) {
200240
let i2c = esp_hal::i2c::master::I2c::new(
201241
peripherals.I2C0,
202242
esp_hal::i2c::master::Config::default()
203-
.with_frequency(100.kHz())
243+
.with_frequency(esp_hal::time::Rate::from_khz(100))
204244
.with_timeout(esp_hal::i2c::master::BusTimeout::Maximum),
205245
)
206246
.expect("I2C new failed")
@@ -289,8 +329,7 @@ async fn main(spawner: Spawner) {
289329
let Ok(mut wifi_res) = wifi_res else {
290330
log::error!("WifiManager failed!!! Restarting in 1s!");
291331
Timer::after_millis(1000).await;
292-
esp_hal::reset::software_reset();
293-
return;
332+
esp_hal::system::software_reset();
294333
};
295334

296335
let conn_settings: ConnSettings = wifi_res
@@ -324,7 +363,7 @@ async fn main(spawner: Spawner) {
324363
_ = nvs.invalidate_key(WIFI_NVS_KEY).await;
325364
Timer::after_millis(1000).await;
326365

327-
esp_hal::reset::software_reset();
366+
esp_hal::system::software_reset();
328367
}
329368

330369
continue;

src/mdns.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ pub async fn mdns_query(stack: Stack<'static>) -> heapless::String<255> {
2626
_ = stack.join_multicast_group(ip_addr);
2727

2828
let mut mdns = MdnsQuery::new("_stackmat._tcp.local", MDNS_RESEND_INTERVAL, || {
29-
esp_hal::time::now().duration_since_epoch().to_millis()
29+
esp_hal::time::Instant::now()
30+
.duration_since_epoch()
31+
.as_millis()
3032
});
3133
let mut data_buf = [0; 1024];
3234

src/rfid.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ use crate::translations::{get_translation, TranslationKey};
55
use alloc::string::ToString;
66
use anyhow::{anyhow, Result};
77
use embassy_time::{Duration, Timer};
8+
use esp_hal::time::Rate;
89
use esp_hal::{
910
dma::{DmaRxBuf, DmaTxBuf},
1011
dma_buffers,
1112
gpio::AnyPin,
1213
spi::{master::Spi, Mode},
13-
time::RateExtU32,
1414
};
1515

1616
#[cfg(feature = "esp32")]
@@ -40,7 +40,7 @@ pub async fn rfid_task(
4040
let spi = Spi::new(
4141
spi,
4242
esp_hal::spi::master::Config::default()
43-
.with_frequency(400.kHz())
43+
.with_frequency(Rate::from_khz(400))
4444
.with_mode(Mode::_0),
4545
)
4646
.expect("Spi init failed")

src/stackmat.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ pub async fn stackmat_task(
2323
.with_rx(uart_pin);
2424

2525
#[cfg(feature = "e2e")]
26-
let mut e2e_data = (StackmatTimerState::Reset, 0, esp_hal::time::now());
26+
let mut e2e_data = (StackmatTimerState::Reset, 0, esp_hal::time::Instant::now());
2727

2828
let mut buf = [0; 8];
2929
let mut read_buf = [0; 8];
30-
let mut last_read = esp_hal::time::now();
30+
let mut last_read = esp_hal::time::Instant::now();
3131
let mut last_state = None;
3232
let mut last_stackmat_state = StackmatTimerState::Unknown;
3333
loop {
@@ -36,7 +36,9 @@ pub async fn stackmat_task(
3636
continue;
3737
}
3838

39-
if (esp_hal::time::now() - last_read).to_millis() > 500 && last_state != Some(false) {
39+
if (esp_hal::time::Instant::now() - last_read).as_millis() > 500
40+
&& last_state != Some(false)
41+
{
4042
global_state.state.lock().await.stackmat_connected = Some(false);
4143
last_state = Some(false);
4244
display.set_data(&[255; 6]);
@@ -53,14 +55,14 @@ pub async fn stackmat_task(
5355
let data = global_state.e2e.stackmat_sig.wait().await;
5456
e2e_data.0 = data.0;
5557
e2e_data.1 = data.1;
56-
e2e_data.2 = esp_hal::time::now();
58+
e2e_data.2 = esp_hal::time::Instant::now();
5759
}
5860

5961
let timer_ms = match e2e_data.0 {
6062
StackmatTimerState::Unknown => 0,
6163
StackmatTimerState::Reset => 0,
6264
StackmatTimerState::Running => {
63-
let mut time = (esp_hal::time::now() - e2e_data.2).to_millis();
65+
let mut time = (esp_hal::time::Instant::now() - e2e_data.2).as_millis();
6466
if time >= e2e_data.1 {
6567
time = e2e_data.1;
6668
e2e_data.0 = StackmatTimerState::Stopped;
@@ -82,7 +84,7 @@ pub async fn stackmat_task(
8284

8385
#[cfg(not(feature = "e2e"))]
8486
let n = {
85-
let n = uart.read_buffered_bytes(&mut read_buf);
87+
let n = uart.read_buffered(&mut read_buf);
8688
let Ok(n) = n else {
8789
log::error!("uart: read_bytes err");
8890
continue;
@@ -211,6 +213,6 @@ pub async fn stackmat_task(
211213
}
212214
}
213215

214-
last_read = esp_hal::time::now();
216+
last_read = esp_hal::time::Instant::now();
215217
}
216218
}

src/utils/backtrace_store.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,5 +224,5 @@ pub extern "Rust" fn custom_pre_backtrace() {
224224

225225
#[no_mangle]
226226
pub extern "Rust" fn custom_halt() {
227-
esp_hal::reset::software_reset();
227+
esp_hal::system::software_reset();
228228
}

src/utils/buttons.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,12 @@ impl ButtonsHandler {
7373

7474
#[cfg(feature = "esp32")] buttons: &[Input<'static>],
7575
) {
76-
let mut debounce_time = esp_hal::time::now();
76+
let mut debounce_time = esp_hal::time::Instant::now();
7777
let mut old_debounced = i32::MAX;
7878
let mut old_val = 0;
7979

8080
#[cfg(feature = "e2e")]
81-
let mut e2e_data = (esp_hal::time::now(), 0, 0);
81+
let mut e2e_data = (esp_hal::time::Instant::now(), 0, 0);
8282

8383
#[cfg(feature = "e2e")]
8484
let mut send_ack = false;
@@ -92,13 +92,13 @@ impl ButtonsHandler {
9292
let (btn_idx, press_ms) = state.e2e.buttons_sig.wait().await;
9393
out_val |= 1 << btn_idx;
9494

95-
e2e_data.0 = esp_hal::time::now();
95+
e2e_data.0 = esp_hal::time::Instant::now();
9696
e2e_data.1 = press_ms;
9797
e2e_data.2 = btn_idx;
9898
send_ack = true;
9999

100100
log::debug!("[E2E] Button pressed: {btn_idx} for {press_ms}ms");
101-
} else if (esp_hal::time::now() - e2e_data.0).to_millis() <= e2e_data.1 {
101+
} else if (esp_hal::time::Instant::now() - e2e_data.0).as_millis() <= e2e_data.1 {
102102
out_val |= 1 << e2e_data.2;
103103
}
104104
}
@@ -127,10 +127,10 @@ impl ButtonsHandler {
127127

128128
if old_val != out_val {
129129
old_val = out_val;
130-
debounce_time = esp_hal::time::now();
130+
debounce_time = esp_hal::time::Instant::now();
131131
} else if old_debounced != out_val {
132-
let duration = esp_hal::time::now() - debounce_time;
133-
if duration.to_millis() > 50 || sleep_state() {
132+
let duration = esp_hal::time::Instant::now() - debounce_time;
133+
if duration.as_millis() > 50 || sleep_state() {
134134
if old_debounced == 0 {
135135
self.button_down((out_val as u8).into(), state).await;
136136
} else {
@@ -146,7 +146,7 @@ impl ButtonsHandler {
146146
old_debounced = out_val;
147147
}
148148
} else {
149-
debounce_time = esp_hal::time::now();
149+
debounce_time = esp_hal::time::Instant::now();
150150
}
151151

152152
if old_debounced != 0 {

0 commit comments

Comments
 (0)