Skip to content

Commit

Permalink
fix: compile error
Browse files Browse the repository at this point in the history
  • Loading branch information
andelf committed Jan 1, 2024
1 parent 0d81753 commit c6f1e1a
Show file tree
Hide file tree
Showing 16 changed files with 18 additions and 61 deletions.
7 changes: 3 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@ ble = []
#] }
ch58x = { version = "0.2.0", features = ["ch58x"] }

riscv = "0.10.1"
qingke = "0.1.2"
critical-section = "1.1.2"
qingke = { version = "0.1.6", features = ["critical-section-impl"] }
# ch32v-rt = { version = "0.0.2", path = "../ch32v-rt" }
ch32v-rt = "0.0.2"
critical-section = { version = "1.1.2", features = ["restore-state-u8"] }

fugit = "0.3.7"
nb = "1.1.0"
Expand All @@ -49,7 +48,7 @@ display-interface = "0.4.1"
display-interface-spi = "0.4.1"
embedded-graphics = "0.8.1"
panic-halt = "0.2.0"
ssd1306 = "0.8.3"
ssd1306 = "0.8.4"

embassy-futures = "0.1.1"
embassy-executor = { version = "0.4.0", features = [
Expand Down
18 changes: 2 additions & 16 deletions examples/adc_pin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use core::arch::{asm, global_asm};
use core::fmt::Write;
use core::writeln;

use embedded_hal_1::delay::DelayUs;
use embedded_hal_1::delay::DelayNs;
use hal::adc::{adc_to_temperature_celsius, Adc};
use hal::dma::NoDma;
use hal::gpio::{AnyPin, Input, Level, Output, OutputDrive, Pull};
Expand All @@ -31,23 +31,12 @@ fn main() -> ! {

let mut download_button = Input::new(p.PB22, Pull::Up);
let mut reset_button = Input::new(p.PB23, Pull::Up);
let mut rtc = Rtc {};

serial.blocking_flush();
// rtc.set_datatime(DateTime {
// year: 2023,
// month: 10,
// day: 16,
// hour: 15,
// minute: 42,
// second: 10,
// });

writeln!(serial, "\n\n\nHello World!").unwrap();
writeln!(serial, "Clocks: {}", hal::sysctl::clocks().hclk).unwrap();
writeln!(serial, "ChipID: {:02x}", hal::signature::get_chip_id());
let now = rtc.now();
writeln!(serial, "Boot time: {} weekday={}", now, now.isoweekday()).unwrap();

// ADC part
let mut adc = Adc::new(p.ADC, hal::adc::Config::default());
Expand All @@ -60,17 +49,14 @@ fn main() -> ! {
loop {
blue_led.toggle();

let now = rtc.now();

let data = adc.read(&mut pin);
writeln!(serial, "adc raw data: {}", data).unwrap();
let vi = adc.read_as_millivolts(&mut pin);
writeln!(serial, "Vbat voltage: {}mV", vi).unwrap();

writeln!(
serial,
"{}: download={} reset={}",
now,
"BUTTON state: download={} reset={}",
// now.isoweekday(),
download_button.is_low(),
reset_button.is_low()
Expand Down
9 changes: 1 addition & 8 deletions examples/adc_temp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use core::arch::{asm, global_asm};
use core::fmt::Write;
use core::writeln;

use embedded_hal_1::delay::DelayUs;
use embedded_hal_1::delay::DelayNs;
use hal::adc::{adc_to_temperature_celsius, Adc};
use hal::dma::NoDma;
use hal::gpio::{AnyPin, Input, Level, Output, OutputDrive, Pull};
Expand All @@ -21,7 +21,6 @@ use {ch58x_hal as hal, panic_halt as _};
fn main() -> ! {
let mut config = hal::Config::default();
config.clock.use_pll_60mhz().enable_lse();

let p = hal::init(config);

// LED PA8
Expand Down Expand Up @@ -49,12 +48,6 @@ fn main() -> ! {
let now = rtc.now();
writeln!(serial, "Boot time: {} weekday={}", now, now.isoweekday()).unwrap();

// requires machine mode
// let marchid = riscv::register::marchid::read().unwrap();
// writeln!(serial, "marchid: 0x{:08x?}", marchid.bits());
// let mias = riscv::register::misa::read().unwrap();
// writeln!(serial, "mias: 0x{:08x?}", mias.bits());

// ADC part
let adc_config = hal::adc::Config::for_temperature();
let mut adc = Adc::new(p.ADC, adc_config);
Expand Down
2 changes: 1 addition & 1 deletion examples/blinky.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use core::arch::{asm, global_asm};
use core::fmt::Write;
use core::writeln;

use embedded_hal_1::delay::DelayUs;
use embedded_hal_1::delay::DelayNs;
use hal::gpio::{AnyPin, Input, Level, Output, OutputDrive, Pull};
use hal::interrupt::Interrupt;
use hal::isp::EEPROM_BLOCK_SIZE;
Expand Down
2 changes: 1 addition & 1 deletion examples/empty.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#![no_std]
#![no_main]

use embedded_hal_1::delay::DelayUs;
use embedded_hal_1::delay::DelayNs;
use hal::gpio::{Input, Level, Output, OutputDrive, Pull};
use hal::peripherals;
use hal::uart::UartTx;
Expand Down
2 changes: 1 addition & 1 deletion examples/flashisp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#![no_main]

use ch32v_rt::highcode;
use embedded_hal_1::delay::DelayUs;
use embedded_hal_1::delay::DelayNs;
use hal::gpio::{Input, Level, Output, OutputDrive, Pull};
// use hal::interrupt::Interrupt;
use hal::rtc::{DateTime, Rtc};
Expand Down
2 changes: 1 addition & 1 deletion examples/hardfault.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use core::arch::{asm, global_asm};
use core::fmt::Write;
use core::writeln;

use embedded_hal_1::delay::DelayUs;
use embedded_hal_1::delay::DelayNs;
use hal::gpio::{AnyPin, Input, Level, Output, OutputDrive, Pull};
use hal::isp::EEPROM_BLOCK_SIZE;
use hal::rtc::{DateTime, Rtc};
Expand Down
2 changes: 1 addition & 1 deletion examples/i2c-mpu6050.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#![no_std]
#![no_main]

use embedded_hal_1::delay::DelayUs;
use embedded_hal_1::delay::DelayNs;
use hal::gpio::{Input, Level, Output, OutputDrive, Pull};
use hal::i2c::{self, I2c};
use hal::peripherals;
Expand Down
2 changes: 1 addition & 1 deletion examples/serial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use core::arch::{asm, global_asm};
use core::fmt::Write;
use core::writeln;

use embedded_hal_1::delay::DelayUs;
use embedded_hal_1::delay::DelayNs;
use hal::dma::NoDma;
use hal::gpio::{AnyPin, Input, Level, Output, OutputDrive, Pull};
use hal::interrupt::Interrupt;
Expand Down
2 changes: 1 addition & 1 deletion examples/spi-ssd1306.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use embedded_graphics::prelude::*;
use embedded_graphics::primitives::Line;
use embedded_graphics::text::{Baseline, Text};
use embedded_hal_02::spi::Polarity;
use embedded_hal_1::delay::DelayUs;
use embedded_hal_1::delay::DelayNs;
use hal::adc::Adc;
use hal::gpio::{Input, Level, Output, OutputDrive, Pull};
use hal::prelude::*;
Expand Down
2 changes: 1 addition & 1 deletion examples/yd-ch582m.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

use ch32v_rt::highcode;
use ch58x_hal as hal;
use embedded_hal_1::delay::DelayUs;
use embedded_hal_1::delay::DelayNs;
use hal::gpio::{Input, Level, Output, OutputDrive, Pull};
use hal::peripherals;
use hal::rtc::{DateTime, Rtc};
Expand Down
2 changes: 1 addition & 1 deletion src/adc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ where
.clk_div()
.variant(config.clk as u8)
.buf_en()
.bit(!config.buf_en)
.bit(config.buf_en)
.pga_gain()
.variant(config.pga_gain as u8)
});
Expand Down
21 changes: 0 additions & 21 deletions src/critical_section.rs

This file was deleted.

3 changes: 1 addition & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use core::ptr;

pub use ch58x::ch58x as pac;
use qingke::riscv;

pub use self::peripheral::{Peripheral, PeripheralRef};
pub use self::peripherals::Peripherals;
Expand Down Expand Up @@ -32,8 +33,6 @@ pub mod peripherals;
mod peripheral;
pub mod prelude;

mod critical_section;

#[cfg(feature = "embassy")]
pub mod embassy;

Expand Down
1 change: 1 addition & 0 deletions src/sysctl.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use fugit::HertzU32 as Hertz;
use qingke::riscv;

use crate::pac::SYS;
use crate::with_safe_access;
Expand Down
2 changes: 1 addition & 1 deletion src/systick.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ impl<'d> SysTick<'d> {
}
}

impl<'d> embedded_hal_1::delay::DelayUs for SysTick<'d> {
impl<'d> embedded_hal_1::delay::DelayNs for SysTick<'d> {
fn delay_us(&mut self, us: u32) {
let us = self.ticks_per_second * (us as u64) / 1_000_000;

Expand Down

0 comments on commit c6f1e1a

Please sign in to comment.