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

Commit a413ce9

Browse files
committed
Merge from master
2 parents 8943b1d + e8dd426 commit a413ce9

36 files changed

+2503
-338
lines changed

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"rust-analyzer.cargo.target": "x86_64-unknown-linux-gnu"
3+
}

CHANGELOG.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Change Log
2+
3+
All notable changes to this project will be documented in this file.
4+
This project adheres to [Semantic Versioning](http://semver.org/).
5+
6+
## [Unreleased]
7+
8+
## v0.2.0 - 2020-09-23
9+
10+
### Changed
11+
- Replace `xtenxa-lx6` with `xtensa-lx`, a silicon agnostic craate for the runtime and peripheral access of xtensa CPU's.
12+
13+
### Fixed
14+
- Update alloc to support the new `alloc_ref` nightly changes.
15+
- Clean up examples
16+
17+
## v0.1.0 - 2020-09-15
18+
19+
- Initial release
20+
21+
[Unreleased]: https://github.com/esp-rs/esp32-hal/compare/v0.2.0...HEAD
22+
[v0.2.0]: https://github.com/esp-rs/esp32-hal/compare/v0.1.0...v0.2.0
23+
[v0.1.0]: https://github.com/esp-rs/esp32-hal/tree/v0.1.0

Cargo.toml

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
[package]
22
name = "esp32-hal"
3-
version = "0.1.0"
3+
version = "0.2.0"
4+
description = "A Hardware abstraction layer for Espressif's ESP32 WiFi microcontroller."
45
authors = ["Scott Mabin <[email protected]>", "Arjan Mels <[email protected]>"]
6+
categories = ["embedded", "hardware-support", "no-std"]
7+
keywords = ["xtensa", "esp32", "hal", "esp"]
8+
license = "MIT OR Apache-2.0"
9+
readme = "README.md"
10+
repository = "https://github.com/esp-rs/esp32-hal"
511
edition = "2018"
612

713

@@ -26,23 +32,24 @@ alloc = ["linked_list_allocator"]
2632
mem = []
2733

2834
# Enable the `rt` feature of the `esp32` crate.
29-
rt = ["esp32/rt", "xtensa-lx6-rt"]
35+
rt = ["esp32/rt", "xtensa-lx-rt"]
3036

3137

3238
[dependencies]
33-
esp32-hal-proc-macros = { path = "procmacros" }
39+
esp32-hal-proc-macros = { version = "=0.2.0", path = "procmacros" }
3440

35-
xtensa-lx6-rt = { version = "0.3.0", optional = true }
36-
xtensa-lx6 = "0.2.0"
37-
esp32 = { version = "0.6.0", default-features = false }
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"
3844
bare-metal = "0.2"
3945
nb = "0.1.2"
4046
embedded-hal = { version = "0.2.3", features = ["unproven"] }
41-
linked_list_allocator = { version = "0.8.4", optional = true, default-features = false, features = ["alloc_ref"] }
47+
linked_list_allocator = { version = "=0.8.11", optional = true, default-features = false, features = ["alloc_ref"] }
4248
void = { version = "1.0.2", default-features = false }
4349

4450
[dev-dependencies]
4551
panic-halt = "0.2.0"
52+
ili9341 = { version = "0.3.0", features = ["graphics"] }
4653
ssd1306 = "0.3.1"
4754
embedded-graphics = "0.6.2"
4855
mpu6050 = "0.1.3"

README.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,28 @@
11
# esp32-hal
22

3-
A experimental hardware abstraction layer for the [esp32](https://en.wikipedia.org/wiki/ESP32) written in Rust.
3+
A hardware abstraction layer for the [esp32](https://en.wikipedia.org/wiki/ESP32) written in Rust.
44

55
Contributions are welcome :)
66

77
Join in on the discussion: https://matrix.to/#/#esp-rs:matrix.org!
88

9+
## Running examples
10+
11+
There are currently two ways to flash the esp32:
12+
13+
* The `flash` script using `esptool`
14+
- If you are familiar with the esp ecosystem, there is a `flash` script in this repo which utilizes the espressif esptool to flash the esp32 over usb.
15+
Example usage:
16+
```rust
17+
./flash -p /dev/ttyUSB0 -e blinky --release
18+
```
19+
20+
* The [`espflash`](https://github.com/icewind1991/espflash) cargo subcommand
21+
- A Rust rewrite of the esptool, with a cargo subcommand. Example usage:
22+
```rust
23+
cargo espflash --example blinky --release /dev/ttyUSB0
24+
```
25+
926
## License
1027

1128
Licensed under either of

examples/adc.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ fn main() -> ! {
2020
let mut timg0 = dp.TIMG0;
2121
let mut timg1 = dp.TIMG1;
2222

23-
let (mut dport, dport_clock_control) = dp.DPORT.split();
23+
let (_, dport_clock_control) = dp.DPORT.split();
2424

2525
// (https://github.com/espressif/openocd-esp32/blob/97ba3a6bb9eaa898d91df923bbedddfeaaaf28c9/src/target/esp32.c#L431)
2626
// openocd disables the watchdog timer on halt
@@ -50,7 +50,6 @@ fn main() -> ! {
5050
},
5151
Config::default(),
5252
clkcntrl_config,
53-
&mut dport,
5453
)
5554
.unwrap();
5655

examples/alloc.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use esp32_hal::alloc::{
1818
use esp32_hal::clock_control::{sleep, ClockControl};
1919
use esp32_hal::dport::Split;
2020
use esp32_hal::dprintln;
21-
use esp32_hal::serial::{config::Config, NoRx, NoTx, Serial};
21+
use esp32_hal::serial::{config::Config, Serial};
2222
use esp32_hal::target;
2323

2424
#[macro_use]
@@ -59,7 +59,7 @@ fn main() -> ! {
5959
// we will do it manually on startup
6060
disable_timg_wdts(&mut timg0, &mut timg1);
6161

62-
let (mut dport, dport_clock_control) = dp.DPORT.split();
62+
let (_, dport_clock_control) = dp.DPORT.split();
6363

6464
// setup clocks & watchdog
6565
let clock_control = ClockControl::new(
@@ -74,13 +74,19 @@ fn main() -> ! {
7474

7575
watchdog.start(15.s());
7676

77+
let gpios = dp.GPIO.split();
78+
7779
// setup serial controller
78-
let mut uart0 = Serial::uart0(
80+
let mut uart0: Serial<_, _, _> = Serial::new(
7981
dp.UART0,
80-
(NoTx, NoRx),
82+
esp32_hal::serial::Pins {
83+
tx: gpios.gpio1,
84+
rx: gpios.gpio3,
85+
cts: None,
86+
rts: None,
87+
},
8188
Config::default(),
8289
clock_control_config,
83-
&mut dport,
8490
)
8591
.unwrap();
8692

examples/blinky.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
11
#![no_std]
22
#![no_main]
33

4-
extern crate esp32_hal as hal;
5-
extern crate panic_halt;
6-
extern crate xtensa_lx6_rt;
7-
84
use esp32_hal::target;
95
use hal::prelude::*;
10-
use xtensa_lx6::timer::get_cycle_count;
6+
use xtensa_lx::timer::get_cycle_count;
7+
use panic_halt as _;
8+
use esp32_hal as hal;
119

1210
/// The default clock source is the onboard crystal
1311
/// In most cases 40mhz (but can be as low as 2mhz depending on the board)
1412
const CORE_HZ: u32 = 40_000_000;
1513

1614
const WDT_WKEY_VALUE: u32 = 0x50D83AA1;
1715

18-
#[no_mangle]
16+
#[entry]
1917
fn main() -> ! {
2018
let dp = target::Peripherals::take().expect("Failed to obtain Peripherals");
2119

@@ -30,7 +28,7 @@ fn main() -> ! {
3028
disable_rtc_wdt(&mut rtccntl);
3129

3230
let pins = dp.GPIO.split();
33-
let mut led = pins.gpio2.into_open_drain_output();
31+
let mut led = pins.gpio2.into_push_pull_output();
3432

3533
loop {
3634
led.set_high().unwrap();

examples/exception.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ use esp32_hal::Core::PRO;
1919
// !!! Cannot use CriticalSectionSpinLockMutex here, because an NMI is fires from within a locked
2020
// section which leads to a deadlock in the NMI interrupt handler. This is not a problem in this
2121
// case as this is a single threaded example. !!!
22-
static TX: xtensa_lx6::mutex::CriticalSectionMutex<Option<esp32_hal::serial::Tx<esp32::UART0>>> =
23-
xtensa_lx6::mutex::CriticalSectionMutex::new(None);
22+
static TX: xtensa_lx::mutex::CriticalSectionMutex<Option<esp32_hal::serial::Tx<esp32::UART0>>> =
23+
xtensa_lx::mutex::CriticalSectionMutex::new(None);
2424

2525
fn locked_print(str: &str) {
2626
(&TX).lock(|tx| {
@@ -30,7 +30,7 @@ fn locked_print(str: &str) {
3030
tx,
3131
" {}, Level: {}",
3232
str,
33-
xtensa_lx6::interrupt::get_level()
33+
xtensa_lx::interrupt::get_level()
3434
)
3535
.unwrap();
3636
});
@@ -78,8 +78,8 @@ fn random_name() {
7878
#[exception]
7979
#[ram]
8080
fn other_exception(
81-
cause: xtensa_lx6_rt::exception::ExceptionCause,
82-
frame: xtensa_lx6_rt::exception::Context,
81+
cause: xtensa_lx_rt::exception::ExceptionCause,
82+
frame: xtensa_lx_rt::exception::Context,
8383
) {
8484
(&TX).lock(|tx| {
8585
let tx = tx.as_mut().unwrap();
@@ -100,7 +100,7 @@ fn main() -> ! {
100100
// we will do it manually on startup
101101
disable_timg_wdts(&mut timg0, &mut timg1);
102102

103-
let (mut dport, dport_clock_control) = dp.DPORT.split();
103+
let (_, dport_clock_control) = dp.DPORT.split();
104104

105105
// setup clocks & watchdog
106106
let mut clock_control = ClockControl::new(
@@ -132,7 +132,6 @@ fn main() -> ! {
132132
},
133133
Config::default(),
134134
clock_control_config,
135-
&mut dport,
136135
)
137136
.unwrap();
138137

0 commit comments

Comments
 (0)