Skip to content

Commit

Permalink
Update examples as needed to get things building again
Browse files Browse the repository at this point in the history
  • Loading branch information
jessebraham committed Sep 25, 2023
1 parent 767066b commit e35868b
Show file tree
Hide file tree
Showing 269 changed files with 495 additions and 1,463 deletions.
10 changes: 2 additions & 8 deletions esp32-hal/examples/advanced_serial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use nb::block;
#[entry]
fn main() -> ! {
let peripherals = Peripherals::take();
let mut system = peripherals.DPORT.split();
let system = peripherals.DPORT.split();
let clocks = ClockControl::boot_defaults(system.clock_control).freeze();

let config = Config {
Expand All @@ -45,13 +45,7 @@ fn main() -> ! {
io.pins.gpio17.into_floating_input(),
);

let mut serial1 = Uart::new_with_config(
peripherals.UART1,
config,
Some(pins),
&clocks,
&mut system.peripheral_clock_control,
);
let mut serial1 = Uart::new_with_config(peripherals.UART1, config, Some(pins), &clocks);

let mut delay = Delay::new(&clocks);

Expand Down
4 changes: 2 additions & 2 deletions esp32-hal/examples/aes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ use esp_println::println;
#[entry]
fn main() -> ! {
let peripherals = Peripherals::take();
let mut system = peripherals.DPORT.split();
let system = peripherals.DPORT.split();
let _clocks = ClockControl::boot_defaults(system.clock_control).freeze();

let mut aes = Aes::new(peripherals.AES, &mut system.peripheral_clock_control);
let mut aes = Aes::new(peripherals.AES);

let keytext = "SUp4SeCp@sSw0rd".as_bytes();
let plaintext = "message".as_bytes();
Expand Down
14 changes: 3 additions & 11 deletions esp32-hal/examples/crc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,12 @@ use nb::block;
#[entry]
fn main() -> ! {
let peripherals = Peripherals::take();
let mut system = peripherals.DPORT.split();
let system = peripherals.DPORT.split();
let clocks = ClockControl::boot_defaults(system.clock_control).freeze();

let timer_group0 = TimerGroup::new(
peripherals.TIMG0,
&clocks,
&mut system.peripheral_clock_control,
);
let timer_group0 = TimerGroup::new(peripherals.TIMG0, &clocks);
let mut timer0 = timer_group0.timer0;
let mut uart0 = Uart::new(
peripherals.UART0,
&clocks,
&mut system.peripheral_clock_control,
);
let mut uart0 = Uart::new(peripherals.UART0, &clocks);

timer0.start(1u64.secs());

Expand Down
8 changes: 2 additions & 6 deletions esp32-hal/examples/embassy_hello_world.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,10 @@ async fn run2() {
fn main() -> ! {
esp_println::println!("Init!");
let peripherals = Peripherals::take();
let mut system = peripherals.DPORT.split();
let system = peripherals.DPORT.split();
let clocks = ClockControl::boot_defaults(system.clock_control).freeze();

let timer_group0 = TimerGroup::new(
peripherals.TIMG0,
&clocks,
&mut system.peripheral_clock_control,
);
let timer_group0 = TimerGroup::new(peripherals.TIMG0, &clocks);
embassy::init(&clocks, timer_group0.timer0);

let executor = make_static!(Executor::new());
Expand Down
7 changes: 1 addition & 6 deletions esp32-hal/examples/embassy_i2c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,7 @@ fn main() -> ! {
let mut system = peripherals.DPORT.split();
let clocks = ClockControl::boot_defaults(system.clock_control).freeze();

let timer_group0 = TimerGroup::new(
peripherals.TIMG0,
&clocks,
&mut system.peripheral_clock_control,
);
let timer_group0 = TimerGroup::new(peripherals.TIMG0, &clocks);
embassy::init(&clocks, timer_group0.timer0);

let io = IO::new(peripherals.GPIO, peripherals.IO_MUX);
Expand All @@ -62,7 +58,6 @@ fn main() -> ! {
io.pins.gpio32,
io.pins.gpio33,
400u32.kHz(),
&mut system.peripheral_clock_control,
&clocks,
);

Expand Down
9 changes: 2 additions & 7 deletions esp32-hal/examples/embassy_i2s_read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,12 @@ fn main() -> ! {
let mut system = peripherals.DPORT.split();
let clocks = ClockControl::boot_defaults(system.clock_control).freeze();

let timer_group0 = TimerGroup::new(
peripherals.TIMG0,
&clocks,
&mut system.peripheral_clock_control,
);
let timer_group0 = TimerGroup::new(peripherals.TIMG0, &clocks);
embassy::init(&clocks, timer_group0.timer0);

let io = IO::new(peripherals.GPIO, peripherals.IO_MUX);

let dma = Dma::new(system.dma, &mut system.peripheral_clock_control);
let dma = Dma::new(system.dma);
let dma_channel = dma.i2s0channel;

let tx_descriptors = make_static!([0u32; 20 * 3]);
Expand All @@ -98,7 +94,6 @@ fn main() -> ! {
rx_descriptors,
DmaPriority::Priority0,
),
&mut system.peripheral_clock_control,
&clocks,
);

Expand Down
9 changes: 2 additions & 7 deletions esp32-hal/examples/embassy_i2s_sound.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,16 +109,12 @@ fn main() -> ! {
let mut system = peripherals.DPORT.split();
let clocks = ClockControl::boot_defaults(system.clock_control).freeze();

let timer_group0 = TimerGroup::new(
peripherals.TIMG0,
&clocks,
&mut system.peripheral_clock_control,
);
let timer_group0 = TimerGroup::new(peripherals.TIMG0, &clocks);
embassy::init(&clocks, timer_group0.timer0);

let io = IO::new(peripherals.GPIO, peripherals.IO_MUX);

let dma = Dma::new(system.dma, &mut system.peripheral_clock_control);
let dma = Dma::new(system.dma);
let dma_channel = dma.i2s0channel;

let tx_descriptors = make_static!([0u32; 20 * 3]);
Expand All @@ -136,7 +132,6 @@ fn main() -> ! {
rx_descriptors,
DmaPriority::Priority0,
),
&mut system.peripheral_clock_control,
&clocks,
);

Expand Down
8 changes: 2 additions & 6 deletions esp32-hal/examples/embassy_multicore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,10 @@ async fn enable_disable_led(control: &'static Signal<CriticalSectionRawMutex, bo
#[entry]
fn main() -> ! {
let peripherals = Peripherals::take();
let mut system = peripherals.DPORT.split();
let system = peripherals.DPORT.split();
let clocks = ClockControl::boot_defaults(system.clock_control).freeze();

let timer_group0 = TimerGroup::new(
peripherals.TIMG0,
&clocks,
&mut system.peripheral_clock_control,
);
let timer_group0 = TimerGroup::new(peripherals.TIMG0, &clocks);
embassy::init(&clocks, timer_group0.timer0);

// Set GPIO2 as an output, and set its state high initially.
Expand Down
8 changes: 2 additions & 6 deletions esp32-hal/examples/embassy_multicore_interrupt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,10 @@ async fn enable_disable_led(control: &'static Signal<CriticalSectionRawMutex, bo
#[entry]
fn main() -> ! {
let peripherals = Peripherals::take();
let mut system = peripherals.DPORT.split();
let system = peripherals.DPORT.split();
let clocks = ClockControl::boot_defaults(system.clock_control).freeze();

let timer_group0 = TimerGroup::new(
peripherals.TIMG0,
&clocks,
&mut system.peripheral_clock_control,
);
let timer_group0 = TimerGroup::new(peripherals.TIMG0, &clocks);
embassy::init(&clocks, timer_group0.timer0);

// Set GPIO2 as an output, and set its state high initially.
Expand Down
8 changes: 2 additions & 6 deletions esp32-hal/examples/embassy_multiprio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,10 @@ async fn low_prio_async() {
#[entry]
fn main() -> ! {
let peripherals = Peripherals::take();
let mut system = peripherals.DPORT.split();
let system = peripherals.DPORT.split();
let clocks = ClockControl::boot_defaults(system.clock_control).freeze();

let timer_group0 = TimerGroup::new(
peripherals.TIMG0,
&clocks,
&mut system.peripheral_clock_control,
);
let timer_group0 = TimerGroup::new(peripherals.TIMG0, &clocks);
embassy::init(&clocks, timer_group0.timer0);

// Set GPIO2 as an output, and set its state high initially.
Expand Down
12 changes: 2 additions & 10 deletions esp32-hal/examples/embassy_serial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,18 +68,10 @@ fn main() -> ! {
let mut system = peripherals.DPORT.split();
let clocks = ClockControl::boot_defaults(system.clock_control).freeze();

let timer_group0 = TimerGroup::new(
peripherals.TIMG0,
&clocks,
&mut system.peripheral_clock_control,
);
let timer_group0 = TimerGroup::new(peripherals.TIMG0, &clocks);
embassy::init(&clocks, timer_group0.timer0);

let mut uart0 = Uart::new(
peripherals.UART0,
&clocks,
&mut system.peripheral_clock_control,
);
let mut uart0 = Uart::new(peripherals.UART0, &clocks);
uart0.set_at_cmd(AtCmdConfig::new(None, None, None, AT_CMD, None));
uart0
.set_rx_fifo_full_threshold(READ_BUF_SIZE as u16)
Expand Down
9 changes: 2 additions & 7 deletions esp32-hal/examples/embassy_spi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,7 @@ fn main() -> ! {
let mut system = peripherals.DPORT.split();
let clocks = ClockControl::boot_defaults(system.clock_control).freeze();

let timer_group0 = TimerGroup::new(
peripherals.TIMG0,
&clocks,
&mut system.peripheral_clock_control,
);
let timer_group0 = TimerGroup::new(peripherals.TIMG0, &clocks);
embassy::init(&clocks, timer_group0.timer0);

esp32_hal::interrupt::enable(
Expand All @@ -75,7 +71,7 @@ fn main() -> ! {
let mosi = io.pins.gpio23;
let cs = io.pins.gpio22;

let dma = Dma::new(system.dma, &mut system.peripheral_clock_control);
let dma = Dma::new(system.dma);
let dma_channel = dma.spi2channel;

let descriptors = make_static!([0u32; 8 * 3]);
Expand All @@ -89,7 +85,6 @@ fn main() -> ! {
cs,
100u32.kHz(),
SpiMode::Mode0,
&mut system.peripheral_clock_control,
&clocks,
)
.with_dma(dma_channel.configure(
Expand Down
6 changes: 1 addition & 5 deletions esp32-hal/examples/embassy_wait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,7 @@ fn main() -> ! {
let mut system = peripherals.DPORT.split();
let clocks = ClockControl::boot_defaults(system.clock_control).freeze();

let timer_group0 = TimerGroup::new(
peripherals.TIMG0,
&clocks,
&mut system.peripheral_clock_control,
);
let timer_group0 = TimerGroup::new(peripherals.TIMG0, &clocks);
embassy::init(&clocks, timer_group0.timer0);

let io = IO::new(peripherals.GPIO, peripherals.IO_MUX);
Expand Down
10 changes: 2 additions & 8 deletions esp32-hal/examples/hello_rgb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,13 @@ use smart_leds::{
#[entry]
fn main() -> ! {
let peripherals = peripherals::Peripherals::take();
let mut system = peripherals.DPORT.split();
let system = peripherals.DPORT.split();
let clocks = ClockControl::boot_defaults(system.clock_control).freeze();

let io = IO::new(peripherals.GPIO, peripherals.IO_MUX);

// Configure RMT peripheral globally
let rmt = Rmt::new(
peripherals.RMT,
80u32.MHz(),
&mut system.peripheral_clock_control,
&clocks,
)
.unwrap();
let rmt = Rmt::new(peripherals.RMT, 80u32.MHz(), &clocks).unwrap();

// We use one of the RMT channels to instantiate a `SmartLedsAdapter` which can
// be used directly with all `smart_led` implementations
Expand Down
14 changes: 3 additions & 11 deletions esp32-hal/examples/hello_world.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,12 @@ use nb::block;
#[entry]
fn main() -> ! {
let peripherals = Peripherals::take();
let mut system = peripherals.DPORT.split();
let system = peripherals.DPORT.split();
let clocks = ClockControl::boot_defaults(system.clock_control).freeze();

let timer_group0 = TimerGroup::new(
peripherals.TIMG0,
&clocks,
&mut system.peripheral_clock_control,
);
let timer_group0 = TimerGroup::new(peripherals.TIMG0, &clocks);
let mut timer0 = timer_group0.timer0;
let mut uart0 = Uart::new(
peripherals.UART0,
&clocks,
&mut system.peripheral_clock_control,
);
let mut uart0 = Uart::new(peripherals.UART0, &clocks);

timer0.start(1u64.secs());

Expand Down
3 changes: 1 addition & 2 deletions esp32-hal/examples/i2c_bmp180_calibration_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use esp_println::println;
#[entry]
fn main() -> ! {
let peripherals = Peripherals::take();
let mut system = peripherals.DPORT.split();
let system = peripherals.DPORT.split();
let clocks = ClockControl::boot_defaults(system.clock_control).freeze();

let io = IO::new(peripherals.GPIO, peripherals.IO_MUX);
Expand All @@ -28,7 +28,6 @@ fn main() -> ! {
io.pins.gpio32,
io.pins.gpio33,
100u32.kHz(),
&mut system.peripheral_clock_control,
&clocks,
);

Expand Down
9 changes: 2 additions & 7 deletions esp32-hal/examples/i2c_display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,10 @@ use ssd1306::{prelude::*, I2CDisplayInterface, Ssd1306};
#[entry]
fn main() -> ! {
let peripherals = Peripherals::take();
let mut system = peripherals.DPORT.split();
let system = peripherals.DPORT.split();
let clocks = ClockControl::boot_defaults(system.clock_control).freeze();

let timer_group0 = TimerGroup::new(
peripherals.TIMG0,
&clocks,
&mut system.peripheral_clock_control,
);
let timer_group0 = TimerGroup::new(peripherals.TIMG0, &clocks);
let mut timer0 = timer_group0.timer0;

let io = IO::new(peripherals.GPIO, peripherals.IO_MUX);
Expand All @@ -53,7 +49,6 @@ fn main() -> ! {
io.pins.gpio32,
io.pins.gpio33,
100u32.kHz(),
&mut system.peripheral_clock_control,
&clocks,
);

Expand Down
5 changes: 2 additions & 3 deletions esp32-hal/examples/i2s_read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ use esp_println::println;
#[entry]
fn main() -> ! {
let peripherals = Peripherals::take();
let mut system = peripherals.DPORT.split();
let system = peripherals.DPORT.split();
let clocks = ClockControl::boot_defaults(system.clock_control).freeze();

let io = IO::new(peripherals.GPIO, peripherals.IO_MUX);

let dma = Dma::new(system.dma, &mut system.peripheral_clock_control);
let dma = Dma::new(system.dma);
let dma_channel = dma.i2s0channel;

let mut tx_descriptors = [0u32; 8 * 3];
Expand All @@ -51,7 +51,6 @@ fn main() -> ! {
&mut rx_descriptors,
DmaPriority::Priority0,
),
&mut system.peripheral_clock_control,
&clocks,
);

Expand Down
Loading

0 comments on commit e35868b

Please sign in to comment.