Clean up imports/exports, normalize/update examples

This commit is contained in:
Jesse Braham 2022-01-10 10:21:40 -08:00
parent 8081977fcf
commit a9cf53a001
9 changed files with 26 additions and 49 deletions

View File

@ -1,23 +1,23 @@
#![no_std]
#![no_main]
use esp32_hal::{gpio::IO, pac, prelude::*, Timer};
use esp32_hal::{gpio::IO, pac::Peripherals, prelude::*, Timer};
use nb::block;
use panic_halt as _;
use xtensa_lx_rt::entry;
#[entry]
fn main() -> ! {
let peripherals = pac::Peripherals::take().unwrap();
let peripherals = Peripherals::take().unwrap();
let io = IO::new(peripherals.GPIO, peripherals.IO_MUX);
let mut led = io.pins.gpio15.into_push_pull_output();
let mut timer0 = Timer::new(peripherals.TIMG0);
// Disable watchdog timer
timer0.disable();
let mut led = io.pins.gpio15.into_push_pull_output();
led.set_high().unwrap();
timer0.start(10_000_000u64);
loop {

View File

@ -3,19 +3,21 @@
use core::fmt::Write;
use esp32_hal::{pac, prelude::*, Serial, Timer};
use esp32_hal::{pac::Peripherals, prelude::*, Serial, Timer};
use nb::block;
use panic_halt as _;
use xtensa_lx_rt::entry;
#[entry]
fn main() -> ! {
let peripherals = pac::Peripherals::take().unwrap();
let peripherals = Peripherals::take().unwrap();
let mut timer0 = Timer::new(peripherals.TIMG0);
let mut serial0 = Serial::new(peripherals.UART0).unwrap();
// Disable watchdog timer
timer0.disable();
timer0.start(10_000_000u64);
loop {

View File

@ -1,6 +1,4 @@
use esp_hal_common::gpio::gpio;
use crate::hal_gpio::*;
use esp_hal_common::gpio::*;
type OutputSignalType = u16;
const OUTPUT_SIGNAL_MAX: u16 = 548;

View File

@ -1,7 +1,9 @@
#![no_std]
pub use embedded_hal as ehal;
pub use esp_hal_common::{gpio as hal_gpio, pac, prelude, Serial, Timer};
pub use esp_hal_common::{pac, prelude, Serial, Timer};
pub use self::gpio::IO;
pub mod gpio;

View File

@ -1,28 +1,28 @@
#![no_std]
#![no_main]
use esp32c3_hal::{gpio::IO, pac, prelude::*, RtcCntl, Timer};
use esp32c3_hal::{gpio::IO, pac::Peripherals, prelude::*, RtcCntl, Timer};
use nb::block;
use panic_halt as _;
use riscv_rt::entry;
#[entry]
fn main() -> ! {
let peripherals = pac::Peripherals::take().unwrap();
let peripherals = Peripherals::take().unwrap();
let io = IO::new(peripherals.GPIO, peripherals.IO_MUX);
let mut led = io.pins.gpio5.into_push_pull_output();
let rtc_cntl = RtcCntl::new(peripherals.RTC_CNTL);
let mut timer0 = Timer::new(peripherals.TIMG0);
let mut timer1 = Timer::new(peripherals.TIMG1);
// Disable watchdog timers
rtc_cntl.set_super_wdt_enable(false);
rtc_cntl.set_wdt_enable(false);
timer0.disable();
timer1.disable();
let mut led = io.pins.gpio5.into_push_pull_output();
led.set_high().unwrap();
timer0.start(10_000_000u64);
loop {

View File

@ -3,22 +3,25 @@
use core::fmt::Write;
use esp32c3_hal::{pac, prelude::*, RtcCntl, Serial, Timer};
use esp32c3_hal::{pac::Peripherals, prelude::*, RtcCntl, Serial, Timer};
use nb::block;
use panic_halt as _;
use riscv_rt::entry;
#[entry]
fn main() -> ! {
let peripherals = pac::Peripherals::take().unwrap();
let peripherals = Peripherals::take().unwrap();
let rtc_cntl = RtcCntl::new(peripherals.RTC_CNTL);
let mut timer0 = Timer::new(peripherals.TIMG0);
let mut serial0 = Serial::new(peripherals.UART0).unwrap();
let mut timer0 = Timer::new(peripherals.TIMG0);
let mut timer1 = Timer::new(peripherals.TIMG1);
// Disable watchdog timers
rtc_cntl.set_super_wdt_enable(false);
rtc_cntl.set_wdt_enable(false);
timer0.disable();
timer1.disable();
timer0.start(10_000_000u64);

View File

@ -1,25 +0,0 @@
#![no_std]
#![no_main]
use esp32c3_hal::{pac, prelude::*, RtcCntl, Serial, Timer};
use nb::block;
use panic_halt as _;
use riscv_rt::entry;
#[entry]
fn main() -> ! {
let peripherals = pac::Peripherals::take().unwrap();
let rtccntl = RtcCntl::new(peripherals.RTC_CNTL);
let mut serial0 = Serial::new(peripherals.UART0).unwrap();
let mut timer0 = Timer::new(peripherals.TIMG0);
rtccntl.set_super_wdt_enable(false);
rtccntl.set_wdt_enable(false);
timer0.disable();
loop {
let byte = block!(serial0.read()).unwrap();
block!(serial0.write(byte)).unwrap();
}
}

View File

@ -1,6 +1,4 @@
use esp_hal_common::gpio::gpio;
use crate::hal_gpio::*;
use esp_hal_common::gpio::*;
type OutputSignalType = u8;
const OUTPUT_SIGNAL_MAX: u8 = 128;

View File

@ -1,10 +1,9 @@
#![no_std]
pub use embedded_hal as ehal;
pub use esp_hal_common::{gpio as hal_gpio, pac, prelude, Serial, Timer};
pub mod rtc_cntl;
pub use esp_hal_common::{pac, prelude, Serial, Timer};
pub mod gpio;
pub mod rtc_cntl;
pub use rtc_cntl::RtcCntl;
pub use self::{gpio::IO, rtc_cntl::RtcCntl};