Skip to content
This repository was archived by the owner on Aug 9, 2022. It is now read-only.

Commit 856de56

Browse files
authored
v0.3.0 - Ecosystem bump (#61)
* Ecosystem bump * Bump xtensa-lx crates * Bump esp32 crate * Update to fix any breaking changes * use `build-std` by default - now that rust-lang/compiler-builtins#411 is merged * v0.3.0
1 parent a19e21b commit 856de56

File tree

10 files changed

+57
-32
lines changed

10 files changed

+57
-32
lines changed

.cargo/config

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,6 @@ rustflags = [
77
"-C", "link-arg=-Wl,-Tlink.x",
88
]
99
target = "xtensa-esp32-none-elf"
10+
11+
[unstable]
12+
build-std=["core", "alloc"]

CHANGELOG.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,16 @@ This project adheres to [Semantic Versioning](http://semver.org/).
55

66
## [Unreleased]
77

8-
## v0.2.0 - 2020-09-23
8+
## [v0.3.0] - 2021-08-12
9+
10+
### Additions
11+
- Basic I2C Support
12+
13+
### Fixed
14+
- Fix compilication errors around the `const_fn` feature.
15+
- Bumped `xtensa-lx`, `xtensa-lx-rt` & `esp32` to support newer compilers.
16+
17+
## [v0.2.0] - 2020-09-23
918

1019
### Changed
1120
- Replace `xtenxa-lx6` with `xtensa-lx`, a silicon agnostic craate for the runtime and peripheral access of xtensa CPU's.
@@ -14,10 +23,11 @@ This project adheres to [Semantic Versioning](http://semver.org/).
1423
- Update alloc to support the new `alloc_ref` nightly changes.
1524
- Clean up examples
1625

17-
## v0.1.0 - 2020-09-15
26+
## [v0.1.0] - 2020-09-15
1827

1928
- Initial release
2029

21-
[Unreleased]: https://github.com/esp-rs/esp32-hal/compare/v0.2.0...HEAD
30+
[Unreleased]: https://github.com/esp-rs/esp32-hal/compare/v0.3.0...HEAD
31+
[v0.3.0]: https://github.com/esp-rs/esp32-hal/compare/v0.2.0...v0.3.0
2232
[v0.2.0]: https://github.com/esp-rs/esp32-hal/compare/v0.1.0...v0.2.0
2333
[v0.1.0]: https://github.com/esp-rs/esp32-hal/tree/v0.1.0

Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "esp32-hal"
3-
version = "0.2.0"
3+
version = "0.3.0"
44
description = "A Hardware abstraction layer for Espressif's ESP32 WiFi microcontroller."
55
authors = ["Scott Mabin <[email protected]>", "Arjan Mels <[email protected]>"]
66
categories = ["embedded", "hardware-support", "no-std"]
@@ -38,9 +38,9 @@ rt = ["esp32/rt", "xtensa-lx-rt"]
3838
[dependencies]
3939
esp32-hal-proc-macros = { version = "=0.2.0", path = "procmacros" }
4040

41-
xtensa-lx-rt = { version = "0.5.0", optional = true, features = ["lx6"] }
42-
xtensa-lx = { version = "0.3.0", features = ["lx6"]}
43-
esp32 = "0.10.0"
41+
xtensa-lx-rt = { version = "0.7.0", optional = true, features = ["lx6"] }
42+
xtensa-lx = { version = "0.4.0", features = ["lx6"] }
43+
esp32 = "0.11.0"
4444
bare-metal = "0.2"
4545
nb = "0.1.2"
4646
embedded-hal = { version = "0.2.3", features = ["unproven"] }

examples/ram.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ fn ram_tests(uart: &mut dyn core::fmt::Write) {
215215
fn external_ram(_uart: &mut dyn core::fmt::Write) {}
216216

217217
#[cfg(feature = "external_ram")]
218-
fn external_ram(uart: &mut core::fmt::Write) {
218+
fn external_ram(uart: &mut dyn core::fmt::Write) {
219219
unsafe {
220220
print_info!(uart, ATTR_RAM_STATIC_EXTERNAL);
221221
print_info!(uart, ATTR_RAM_STATIC_EXTERNAL_BSS);

openocd.cfg

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
adapter_khz 4000
3+
4+
source [find interface/jlink.cfg]
5+
6+
source [find board/esp-wroom-32.cfg]

src/clock_control/mod.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
use crate::prelude::*;
1919
use crate::target;
2020
use crate::target::dport::cpu_per_conf::CPUPERIOD_SEL_A;
21-
use crate::target::generic::Variant::*;
2221
use crate::target::rtccntl::clk_conf::*;
2322
use crate::target::rtccntl::cntl::*;
2423
use crate::target::{APB_CTRL, RTCCNTL, TIMG0};
@@ -1141,9 +1140,9 @@ impl ClockControl {
11411140
/// Get Slow RTC source
11421141
pub fn slow_rtc_source(&self) -> Result<SlowRTCSource, Error> {
11431142
match self.rtc_control.clk_conf.read().ana_clk_rtc_sel().variant() {
1144-
Val(ANA_CLK_RTC_SEL_A::SLOW_CK) => Ok(SlowRTCSource::RTC150k),
1145-
Val(ANA_CLK_RTC_SEL_A::CK_XTAL_32K) => Ok(SlowRTCSource::Xtal32k),
1146-
Val(ANA_CLK_RTC_SEL_A::CK8M_D256_OUT) => Ok(SlowRTCSource::RTC8MD256),
1143+
Some(ANA_CLK_RTC_SEL_A::SLOW_CK) => Ok(SlowRTCSource::RTC150k),
1144+
Some(ANA_CLK_RTC_SEL_A::CK_XTAL_32K) => Ok(SlowRTCSource::Xtal32k),
1145+
Some(ANA_CLK_RTC_SEL_A::CK8M_D256_OUT) => Ok(SlowRTCSource::RTC8MD256),
11471146
_ => Err(Error::UnsupportedFreqConfig),
11481147
}
11491148
}
@@ -1273,9 +1272,9 @@ impl ClockControl {
12731272
.cpuperiod_sel()
12741273
.variant()
12751274
{
1276-
Val(CPUPERIOD_SEL_A::SEL_80) => CPU_FREQ_80M,
1277-
Val(CPUPERIOD_SEL_A::SEL_160) => CPU_FREQ_160M,
1278-
Val(CPUPERIOD_SEL_A::SEL_240) => CPU_FREQ_240M,
1275+
Some(CPUPERIOD_SEL_A::SEL_80) => CPU_FREQ_80M,
1276+
Some(CPUPERIOD_SEL_A::SEL_160) => CPU_FREQ_160M,
1277+
Some(CPUPERIOD_SEL_A::SEL_240) => CPU_FREQ_240M,
12791278
_ => FREQ_OFF,
12801279
},
12811280
CPUSource::RTC8M => self.rtc8m_frequency_measured,

src/clock_control/pll.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
44
use super::Error;
55
use crate::prelude::*;
6-
use crate::target::generic::Variant::Val;
76

87
// Delays (in microseconds) for changing pll settings
98
// TODO according to esp-idf: some of these are excessive, and should be reduced.
@@ -197,9 +196,9 @@ impl super::ClockControl {
197196
.cpuperiod_sel()
198197
.variant()
199198
{
200-
Val(super::CPUPERIOD_SEL_A::SEL_80) => super::PLL_FREQ_320M,
201-
Val(super::CPUPERIOD_SEL_A::SEL_160) => super::PLL_FREQ_320M,
202-
Val(super::CPUPERIOD_SEL_A::SEL_240) => super::PLL_FREQ_480M,
199+
Some(super::CPUPERIOD_SEL_A::SEL_80) => super::PLL_FREQ_320M,
200+
Some(super::CPUPERIOD_SEL_A::SEL_160) => super::PLL_FREQ_320M,
201+
Some(super::CPUPERIOD_SEL_A::SEL_240) => super::PLL_FREQ_480M,
203202
_ => super::FREQ_OFF,
204203
}
205204
}

src/clock_control/watchdog.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
77
use crate::prelude::*;
88
use crate::target;
9-
use crate::target::generic::Variant::Val;
109
use crate::target::rtccntl::wdtconfig0::*;
1110
use crate::target::RTCCNTL;
1211
use embedded_hal::watchdog::{WatchdogDisable, WatchdogEnable};
@@ -105,19 +104,19 @@ impl Watchdog {
105104
let wdtconfig0 = rtc_control.wdtconfig0.read();
106105

107106
let stg0 = match wdtconfig0.wdt_stg0().variant() {
108-
Val(x) => x,
107+
Some(x) => x,
109108
_ => return Err(super::Error::UnsupportedWatchdogConfig),
110109
};
111110
let stg1 = match wdtconfig0.wdt_stg1().variant() {
112-
Val(x) => x,
111+
Some(x) => x,
113112
_ => return Err(super::Error::UnsupportedWatchdogConfig),
114113
};
115114
let stg2 = match wdtconfig0.wdt_stg2().variant() {
116-
Val(x) => x,
115+
Some(x) => x,
117116
_ => return Err(super::Error::UnsupportedWatchdogConfig),
118117
};
119118
let stg3 = match wdtconfig0.wdt_stg3().variant() {
120-
Val(x) => x,
119+
Some(x) => x,
121120
_ => return Err(super::Error::UnsupportedWatchdogConfig),
122121
};
123122

src/interrupt.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ pub use crate::target::{
3636
DPORT,
3737
};
3838
use crate::Core::{self, APP, PRO};
39-
use bare_metal::Nr;
4039
pub use proc_macros::interrupt;
40+
use xtensa_lx::interrupt::InterruptNumber;
4141
pub use xtensa_lx::interrupt::{self, free};
4242

4343
/// Interrupt errors
@@ -257,7 +257,7 @@ unsafe fn level_7_handler(level: u32) {
257257

258258
#[ram]
259259
unsafe fn handle_interrupt(level: u32, interrupt: Interrupt) {
260-
let handler = target::__INTERRUPTS[interrupt.nr() as usize]._handler;
260+
let handler = target::__INTERRUPTS[interrupt.number() as usize]._handler;
261261
if handler as *const _ == DefaultHandler as *const unsafe extern "C" fn() {
262262
DefaultHandler(level, interrupt);
263263
} else {
@@ -296,7 +296,7 @@ unsafe fn handle_interrupts(level: u32) {
296296
let mut interrupt_mask = INTERRUPT_LEVELS[level as usize] & INTERRUPT_EDGE;
297297
loop {
298298
let interrupt_nr = interrupt_mask.trailing_zeros();
299-
if let Ok(interrupt) = target::Interrupt::try_from(interrupt_nr as u8) {
299+
if let Ok(interrupt) = target::Interrupt::try_from(interrupt_nr as u16) {
300300
handle_interrupt(level, interrupt)
301301
} else {
302302
break;
@@ -309,7 +309,7 @@ unsafe fn handle_interrupts(level: u32) {
309309
let interrupt_nr = interrupt_mask.trailing_zeros();
310310

311311
// target::Interrupt::try_from can fail if interrupt already de-asserted: silently ignore
312-
if let Ok(interrupt) = target::Interrupt::try_from(interrupt_nr as u8) {
312+
if let Ok(interrupt) = target::Interrupt::try_from(interrupt_nr as u16) {
313313
handle_interrupt(level, interrupt);
314314
}
315315
}
@@ -351,7 +351,7 @@ fn map_interrupt(
351351
if cpu_interrupt.0 >= 32 {
352352
return Err(Error::InvalidCPUInterrupt);
353353
}
354-
if interrupt.nr() >= Interrupt::INTERNAL_TIMER0_INTR.nr() {
354+
if interrupt.number() >= Interrupt::INTERNAL_TIMER0_INTR.number() {
355355
return Err(Error::InternalInterruptsCannotBeMapped);
356356
}
357357
unsafe {
@@ -360,7 +360,7 @@ fn map_interrupt(
360360
crate::Core::APP => (*DPORT::ptr()).app_mac_intr_map.as_ptr(),
361361
};
362362

363-
let reg = base_reg.add(interrupt.nr() as usize);
363+
let reg = base_reg.add(interrupt.number() as usize);
364364
*reg = cpu_interrupt.0 as u32;
365365
};
366366
Ok(())
@@ -401,9 +401,9 @@ pub fn enable_with_priority(
401401

402402
return (&INTERRUPT_LEVELS_MUTEX).lock(|_| unsafe {
403403
for i in 0..=7 {
404-
INTERRUPT_LEVELS[i] &= !(1 << interrupt.nr());
404+
INTERRUPT_LEVELS[i] &= !(1 << interrupt.number());
405405
}
406-
INTERRUPT_LEVELS[level.0 as usize] |= 1 << interrupt.nr();
406+
INTERRUPT_LEVELS[level.0 as usize] |= 1 << interrupt.number();
407407

408408
interrupt::enable_mask(CPU_INTERRUPT_USED_LEVELS);
409409

src/lib.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#![cfg_attr(feature = "alloc", feature(allocator_api))]
1919
#![cfg_attr(feature = "alloc", feature(alloc_layout_extra))]
2020
#![cfg_attr(feature = "alloc", feature(nonnull_slice_from_raw_parts))]
21+
#![cfg_attr(feature = "alloc", feature(const_fn_trait_bound))]
2122

2223
pub use embedded_hal as hal;
2324
pub use esp32 as target;
@@ -90,6 +91,14 @@ pub unsafe extern "C" fn ESP32Reset() -> ! {
9091
xtensa_lx_rt::Reset();
9192
}
9293

94+
/// The esp32 has a first stage bootloader that handles loading program data into the right place
95+
/// therefore we skip loading it again.
96+
#[no_mangle]
97+
#[rustfmt::skip]
98+
pub extern "Rust" fn __init_data() -> bool {
99+
false
100+
}
101+
93102
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
94103
pub enum Core {
95104
PRO = 0,

0 commit comments

Comments
 (0)