Skip to content

Commit

Permalink
Fixes after rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
MabezDev committed Dec 12, 2022
1 parent 080f4ae commit fbf8b2c
Show file tree
Hide file tree
Showing 36 changed files with 114 additions and 43 deletions.
4 changes: 2 additions & 2 deletions esp-hal-common/src/prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ pub use crate::{
},
},
macros::*,
serial::{Instance as _esp_hal_serial_Instance, UartPins as _esp_hal_serial_UartPins},
uart::{Instance as _esp_hal_uart_Instance, UartPins as _esp_hal_uart_UartPins},
spi::{
dma::WithDmaSpi2 as _esp_hal_spi_dma_WithDmaSpi2,
Instance as _esp_hal_spi_Instance,
Expand Down Expand Up @@ -132,7 +132,7 @@ pub mod eh1 {
},
},
macros::*,
serial::{Instance as _esp_hal_serial_Instance, UartPins as _esp_hal_serial_UartPins},
uart::{Instance as _esp_hal_serial_Instance, UartPins as _esp_hal_serial_UartPins},
spi::{
dma::WithDmaSpi2 as _esp_hal_spi_dma_WithDmaSpi2,
Instance as _esp_hal_spi_Instance,
Expand Down
2 changes: 1 addition & 1 deletion esp-hal-common/src/pulse_control.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
//!
//! ### Example (for ESP32-C3)
//! ```
//! let mut peripherals = pac::Peripherals::take().unwrap();
//! let mut peripherals = peripherals::Peripherals::take().unwrap();
//!
//! // Configure RMT peripheral globally
//! let pulse = PulseControl::new(
Expand Down
2 changes: 1 addition & 1 deletion esp32-hal/examples/embassy_hello_world.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use esp32_hal::{
clock::ClockControl,
prelude::*,
timer::TimerGroup,
Rtc, embassy, pac::Peripherals,
Rtc, embassy, peripherals::Peripherals,
};
use esp_backtrace as _;
use static_cell::StaticCell;
Expand Down
2 changes: 1 addition & 1 deletion esp32-hal/examples/hello_rgb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

use esp32_hal::{
clock::ClockControl,
pac,
peripherals,
prelude::*,
timer::TimerGroup,
utils::{smartLedAdapter, SmartLedsAdapter},
Expand Down
2 changes: 1 addition & 1 deletion esp32-hal/examples/i2c_bmp180_calibration_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use esp32_hal::{
clock::ClockControl,
gpio::IO,
i2c::I2C,
pac::Peripherals,
peripherals::Peripherals,
prelude::*,
timer::TimerGroup,
Rtc,
Expand Down
2 changes: 1 addition & 1 deletion esp32-hal/examples/i2s_read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use esp32_hal::{
dma::{DmaPriority},
pdma::Dma,
i2s::{DataFormat, I2s, NoMclk, Standard, I2s0New, PinsBclkWsDin, I2sReadDma},
pac::Peripherals,
peripherals::Peripherals,
prelude::*,
timer::TimerGroup,
Rtc,
Expand Down
2 changes: 1 addition & 1 deletion esp32-hal/examples/i2s_sound.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ use esp32_hal::{
dma::DmaPriority,
pdma::Dma,
i2s::{DataFormat, I2s, I2sWriteDma, NoMclk, PinsBclkWsDout, Standard, I2s0New},
pac::Peripherals,
peripherals::Peripherals,
prelude::*,
timer::TimerGroup,
Rtc,
Expand Down
2 changes: 1 addition & 1 deletion esp32-hal/examples/mcpwm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use esp32_hal::{
operator::PwmPinConfig,
timer::PwmWorkingMode,
},
pac::Peripherals,
peripherals::Peripherals,
prelude::*,
timer::TimerGroup,
Rtc,
Expand Down
2 changes: 1 addition & 1 deletion esp32-hal/examples/sha.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use esp32_hal::{
clock::ClockControl,
pac::Peripherals,
peripherals::Peripherals,
prelude::*,
timer::TimerGroup,
Rtc,
Expand Down
2 changes: 1 addition & 1 deletion esp32-hal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub use esp_hal_common::{
Rng,
Rtc,
Rwdt,
sha
sha,
Uart,
};

Expand Down
2 changes: 1 addition & 1 deletion esp32c2-hal/examples/embassy_hello_world.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use embassy_time::{Duration, Timer};
use esp32c2_hal::{
clock::ClockControl,
embassy,
pac::Peripherals,
peripherals::Peripherals,
prelude::*,
timer::TimerGroup,
Rtc,
Expand Down
2 changes: 1 addition & 1 deletion esp32c2-hal/examples/i2c_bmp180_calibration_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use esp32c2_hal::{
clock::ClockControl,
gpio::IO,
i2c::I2C,
pac::Peripherals,
peripherals::Peripherals,
prelude::*,
timer::TimerGroup,
Rtc,
Expand Down
2 changes: 1 addition & 1 deletion esp32c2-hal/examples/sha.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use esp32c2_hal::{
clock::ClockControl,
pac::Peripherals,
peripherals::Peripherals,
prelude::*,
timer::TimerGroup,
Rtc,
Expand Down
2 changes: 1 addition & 1 deletion esp32c3-hal/examples/embassy_hello_world.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use esp32c3_hal::{
clock::ClockControl,
prelude::*,
timer::TimerGroup,
Rtc, embassy, pac::Peripherals,
Rtc, embassy, peripherals::Peripherals,
};
use esp_backtrace as _;
use static_cell::StaticCell;
Expand Down
71 changes: 71 additions & 0 deletions esp32c3-hal/examples/embassy_wait.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#![no_std]
#![no_main]
#![feature(type_alias_impl_trait)]

use embassy_executor::Executor;
use embassy_time::{Duration, Timer};

use esp32c3_hal::{
clock::ClockControl,
prelude::*,
timer::TimerGroup,
Rtc, embassy, peripherals::Peripherals, IO,
};
use esp_backtrace as _;
use esp_hal_common::{PullDown, Bank0GpioRegisterAccess, InputOutputAnalogPinType, Input, GpioPin};
use static_cell::StaticCell;

use embedded_hal_async::digital::Wait;

#[embassy_executor::task]
async fn ping(mut pin: GpioPin<Input<PullDown>, Bank0GpioRegisterAccess, InputOutputAnalogPinType, 5>) {
loop {
esp_println::println!("Waiting...");
pin.wait_for_rising_edge().await.unwrap();
esp_println::println!("Ping!");
Timer::after(Duration::from_millis(100)).await;
}
}

static EXECUTOR: StaticCell<Executor> = StaticCell::new();

#[riscv_rt::entry]
fn main() -> ! {
esp_println::println!("Init!");
let peripherals = Peripherals::take().unwrap();
let system = peripherals.SYSTEM.split();
let clocks = ClockControl::boot_defaults(system.clock_control).freeze();

let mut rtc = Rtc::new(peripherals.RTC_CNTL);
let timer_group0 = TimerGroup::new(peripherals.TIMG0, &clocks);
let mut wdt0 = timer_group0.wdt;
let timer_group1 = TimerGroup::new(peripherals.TIMG1, &clocks);
let mut wdt1 = timer_group1.wdt;

// Disable watchdog timers
rtc.swd.disable();
rtc.rwdt.disable();
wdt0.disable();
wdt1.disable();

#[cfg(feature = "embassy-time-systick")]
embassy::init(&clocks, esp32c3_hal::systimer::SystemTimer::new(peripherals.SYSTIMER));

#[cfg(feature = "embassy-time-timg0")]
embassy::init(&clocks, timer_group0.timer0);

// Set GPIO5 as an output, and set its state high initially.
let io = IO::new(peripherals.GPIO, peripherals.IO_MUX);
let input = io.pins.gpio5.into_pull_down_input();

esp32c3_hal::interrupt::enable(
esp32c3_hal::pac::Interrupt::GPIO,
esp32c3_hal::interrupt::Priority::Priority1,
)
.unwrap();

let executor = EXECUTOR.init(Executor::new());
executor.run(|spawner| {
spawner.spawn(ping(input)).ok();
});
}
2 changes: 1 addition & 1 deletion esp32c3-hal/examples/hello_rgb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

use esp32c3_hal::{
clock::ClockControl,
pac,
peripherals,
prelude::*,
pulse_control::ClockSource,
timer::TimerGroup,
Expand Down
2 changes: 1 addition & 1 deletion esp32c3-hal/examples/i2c_bmp180_calibration_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use esp32c3_hal::{
clock::ClockControl,
gpio::IO,
i2c::I2C,
pac::Peripherals,
peripherals::Peripherals,
prelude::*,
timer::TimerGroup,
Rtc,
Expand Down
2 changes: 1 addition & 1 deletion esp32c3-hal/examples/i2s_read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use esp32c3_hal::{
dma::DmaPriority,
gdma::Gdma,
i2s::{DataFormat, I2s, I2sReadDma, MclkPin, PinsBclkWsDin, Standard, I2s0New},
pac::Peripherals,
peripherals::Peripherals,
prelude::*,
timer::TimerGroup,
Rtc,
Expand Down
2 changes: 1 addition & 1 deletion esp32c3-hal/examples/i2s_sound.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ use esp32c3_hal::{
dma::DmaPriority,
gdma::Gdma,
i2s::{DataFormat, I2s, I2sWriteDma, MclkPin, PinsBclkWsDout, Standard, I2s0New},
pac::Peripherals,
peripherals::Peripherals,
prelude::*,
timer::TimerGroup,
Rtc,
Expand Down
2 changes: 1 addition & 1 deletion esp32c3-hal/examples/sha.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use esp32c3_hal::{
clock::ClockControl,
pac::Peripherals,
peripherals::Peripherals,
prelude::*,
timer::TimerGroup,
Rtc,
Expand Down
4 changes: 2 additions & 2 deletions esp32c3-hal/examples/usb_serial_jtag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use critical_section::Mutex;
use esp32c3_hal::{
clock::ClockControl,
interrupt,
pac::{self, USB_DEVICE},
peripherals::{self, USB_DEVICE},
peripherals::Peripherals,
prelude::*,
timer::TimerGroup,
Expand Down Expand Up @@ -55,7 +55,7 @@ fn main() -> ! {
critical_section::with(|cs| USB_SERIAL.borrow_ref_mut(cs).replace(usb_serial));

interrupt::enable(
pac::Interrupt::USB_SERIAL_JTAG,
peripherals::Interrupt::USB_SERIAL_JTAG,
interrupt::Priority::Priority1,
)
.unwrap();
Expand Down
2 changes: 1 addition & 1 deletion esp32c3-hal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ unsafe fn configure_mmu() {
0,
);

let peripherals = pac::Peripherals::steal();
let peripherals = peripherals::Peripherals::steal();
peripherals.EXTMEM.icache_ctrl1.modify(|_, w| {
w.icache_shut_ibus()
.clear_bit()
Expand Down
2 changes: 1 addition & 1 deletion esp32s2-hal/examples/embassy_hello_world.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use esp32s2_hal::{
clock::ClockControl,
prelude::*,
timer::TimerGroup,
Rtc, embassy, pac::Peripherals,
Rtc, embassy, peripherals::Peripherals,
};
use esp_backtrace as _;
use xtensa_atomic_emulation_trap as _;
Expand Down
2 changes: 1 addition & 1 deletion esp32s2-hal/examples/i2c_bmp180_calibration_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use esp32s2_hal::{
clock::ClockControl,
gpio::IO,
i2c::I2C,
pac::Peripherals,
peripherals::Peripherals,
prelude::*,
timer::TimerGroup,
Rtc,
Expand Down
2 changes: 1 addition & 1 deletion esp32s2-hal/examples/i2s_read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use esp32s2_hal::{
dma::{DmaPriority},
pdma::Dma,
i2s::{DataFormat, I2s, NoMclk, Standard, I2s0New, PinsBclkWsDin, I2sReadDma},
pac::Peripherals,
peripherals::Peripherals,
prelude::*,
timer::TimerGroup,
Rtc,
Expand Down
2 changes: 1 addition & 1 deletion esp32s2-hal/examples/i2s_sound.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ use esp32s2_hal::{
dma::DmaPriority,
pdma::Dma,
i2s::{DataFormat, I2s, I2sWriteDma, MclkPin, PinsBclkWsDout, Standard, I2s0New},
pac::Peripherals,
peripherals::Peripherals,
prelude::*,
timer::TimerGroup,
Rtc,
Expand Down
2 changes: 1 addition & 1 deletion esp32s2-hal/examples/sha.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use esp32s2_hal::{
clock::ClockControl,
pac::Peripherals,
peripherals::Peripherals,
prelude::*,
timer::TimerGroup,
Rtc,
Expand Down
2 changes: 1 addition & 1 deletion esp32s2-hal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub use esp_hal_common::{
Rng,
Rtc,
Rwdt,
sha
sha,
Uart,
};

Expand Down
2 changes: 1 addition & 1 deletion esp32s3-hal/examples/embassy_hello_world.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use esp32s3_hal::{
clock::ClockControl,
prelude::*,
timer::TimerGroup,
Rtc, embassy, pac::Peripherals,
Rtc, embassy, peripherals::Peripherals,
};
use esp_backtrace as _;
use static_cell::StaticCell;
Expand Down
2 changes: 1 addition & 1 deletion esp32s3-hal/examples/i2c_bmp180_calibration_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#![no_main]

use esp32s3_hal::{
clock::ClockControl, gpio::IO, i2c::I2C, pac::Peripherals, prelude::*, timer::TimerGroup, Rtc,
clock::ClockControl, gpio::IO, i2c::I2C, peripherals::Peripherals, prelude::*, timer::TimerGroup, Rtc,
};
use esp_backtrace as _;
use esp_println::println;
Expand Down
2 changes: 1 addition & 1 deletion esp32s3-hal/examples/i2s_read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use esp32s3_hal::{
dma::DmaPriority,
gdma::Gdma,
i2s::{DataFormat, I2s, I2sReadDma, MclkPin, PinsBclkWsDin, Standard, I2s0New},
pac::Peripherals,
peripherals::Peripherals,
prelude::*,
timer::TimerGroup,
Rtc,
Expand Down
2 changes: 1 addition & 1 deletion esp32s3-hal/examples/i2s_sound.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ use esp32s3_hal::{
dma::DmaPriority,
gdma::Gdma,
i2s::{DataFormat, I2s, I2sWriteDma, MclkPin, PinsBclkWsDout, Standard, I2s0New},
pac::Peripherals,
peripherals::Peripherals,
prelude::*,
timer::TimerGroup,
Rtc,
Expand Down
2 changes: 1 addition & 1 deletion esp32s3-hal/examples/mcpwm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use esp32s3_hal::{
operator::PwmPinConfig,
timer::PwmWorkingMode,
},
pac::Peripherals,
peripherals::Peripherals,
prelude::*,
timer::TimerGroup,
Rtc,
Expand Down
2 changes: 1 addition & 1 deletion esp32s3-hal/examples/sha.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use esp32s3_hal::{
clock::ClockControl,
pac::Peripherals,
peripherals::Peripherals,
prelude::*,
timer::TimerGroup,
Rtc,
Expand Down
Loading

0 comments on commit fbf8b2c

Please sign in to comment.