Skip to content

Commit

Permalink
chore: minor demo fix
Browse files Browse the repository at this point in the history
  • Loading branch information
andelf committed Oct 2, 2024
1 parent a03e270 commit f5f3aa2
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 14 deletions.
12 changes: 9 additions & 3 deletions examples/hpm5300evk/src/bin/adc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,17 @@ async fn main(spawner: Spawner) -> ! {
loop {
Timer::after_millis(200).await;

// defmt::info!("tick {}", MCHTMR.mtime().read());
// let n = adc.blocking_read(&mut adc_ch7_pin, Default::default());
let mut sum = 0;
for _ in 0..1000 {
let n = adc.blocking_read(&mut adc_ch7_pin, Default::default());
sum += n as u32;
}
let n = sum / 1000;

let n = adc.blocking_read(&mut adc_ch7_pin, Default::default());
let voltage = (n as u32) * 3300 / 65536;

println!("ADC0_CH7: {}", n);
println!("ADC0_CH7: {} {}mV", n, voltage);
}
}

Expand Down
2 changes: 1 addition & 1 deletion examples/hpm5300evk/src/bin/blinky.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use embedded_hal::delay::DelayNs;
use hal::gpio::{Level, Output, Speed};
use riscv::delay::McycleDelay;
use {defmt_rtt as _, hpm_hal as hal, riscv_rt as _};
use {defmt_rtt as _, hpm_hal as hal};

#[hal::entry]
fn main() -> ! {
Expand Down
2 changes: 1 addition & 1 deletion examples/hpm5300evk/src/bin/blocking_uart_tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use embedded_io::Write as _; // `writeln!` provider
use hpm_hal::gpio::{Level, Output, Speed};
use hpm_hal::uart::UartTx;
use riscv::delay::McycleDelay;
use {defmt_rtt as _, hpm_hal as hal, panic_halt as _, riscv_rt as _};
use {defmt_rtt as _, hpm_hal as hal, panic_halt as _};

const BANNER: &str = include_str!("../../../assets/BANNER");

Expand Down
4 changes: 2 additions & 2 deletions examples/hpm5300evk/src/bin/button.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
use embedded_hal::delay::DelayNs;
use hpm_hal::gpio::{Input, Pull};
use riscv::delay::McycleDelay;
use {defmt_rtt as _, hpm_hal as hal, panic_halt as _, riscv_rt as _};
use {defmt_rtt as _, hpm_hal as hal, panic_halt as _};

#[riscv_rt::entry]
#[hal::entry]
fn main() -> ! {
let p = hal::init(Default::default());

Expand Down
2 changes: 1 addition & 1 deletion examples/hpm5300evk/src/bin/i2c_oled.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use hal::gpio::{Level, Output, Speed};
use hal::i2c::I2c;
use hal::mode::Blocking;
use riscv::delay::McycleDelay;
use {defmt_rtt as _, hpm_hal as hal, riscv_rt as _};
use {defmt_rtt as _, hpm_hal as hal};

const BANNER: &str = include_str!("../../../assets/BANNER");

Expand Down
2 changes: 1 addition & 1 deletion examples/hpm5300evk/src/bin/pll_setting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use hal::pac;
use hal::uart::UartTx;
use hpm_hal::time::Hertz;
use riscv::delay::McycleDelay;
use {defmt_rtt as _, hpm_hal as hal, panic_halt as _, riscv_rt as _};
use {defmt_rtt as _, hpm_hal as hal, panic_halt as _};

const BANNER: &str = include_str!("../../../assets/BANNER");

Expand Down
2 changes: 1 addition & 1 deletion examples/hpm5300evk/src/bin/qspi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use hpm_hal::spi::{
};
use hpm_hal::time::Hertz;
use riscv::delay::McycleDelay;
use {defmt_rtt as _, hpm_hal as hal, riscv_rt as _};
use {defmt_rtt as _, hpm_hal as hal};

#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)]
pub enum Orientation {
Expand Down
2 changes: 1 addition & 1 deletion examples/hpm5300evk/src/bin/spi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use hpm_hal::mode::Blocking;
use hpm_hal::spi::{Config, Spi};
use hpm_hal::time::Hertz;
use riscv::delay::McycleDelay;
use {defmt_rtt as _, hpm_hal as hal, panic_halt as _, riscv_rt as _};
use {defmt_rtt as _, hpm_hal as hal, panic_halt as _};

pub struct ST7789<
Spi: SpiDevice,
Expand Down
2 changes: 1 addition & 1 deletion examples/hpm5300evk/src/bin/tsns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use hal::gpio::{Level, Output, Speed};
use hal::pac;
use hpm_hal::time::Hertz;
use riscv::delay::McycleDelay;
use {defmt_rtt as _, hpm_hal as hal, riscv_rt as _};
use {defmt_rtt as _, hpm_hal as hal};

const BANNER: &str = include_str!("../../../assets/BANNER");

Expand Down
2 changes: 1 addition & 1 deletion examples/hpm5300evk/src/bin/usb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use embassy_usb::Builder;
use futures_util::future::join;
use hal::usb::{Instance, UsbDriver};
use hpm_hal::{bind_interrupts, peripherals};
use {defmt_rtt as _, hpm_hal as hal, riscv_rt as _};
use {defmt_rtt as _, hpm_hal as hal};

bind_interrupts!(struct Irqs {
USB0 => hal::usb::InterruptHandler<peripherals::USB0>;
Expand Down
2 changes: 1 addition & 1 deletion examples/hpm5300evk/src/bin/usb_hid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use hpm_hal::gpio::{Input, Pull};
use hpm_hal::{bind_interrupts, peripherals};
use static_cell::StaticCell;
use usbd_hid::descriptor::{KeyboardReport, SerializedDescriptor};
use {defmt_rtt as _, hpm_hal as hal, riscv_rt as _};
use {defmt_rtt as _, hpm_hal as hal};

bind_interrupts!(struct Irqs {
USB0 => hal::usb::InterruptHandler<peripherals::USB0>;
Expand Down

0 comments on commit f5f3aa2

Please sign in to comment.