feat(firmware): initialize peripherals
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Luca 2024-01-09 01:46:20 +01:00
parent 112bcf7d61
commit 5e2fe898f1
1 changed files with 37 additions and 0 deletions

View File

@ -3,9 +3,46 @@
use ch32v00x_hal as hal; use ch32v00x_hal as hal;
use hal::debug::SDIPrint;
use hal::gpio::PinState;
use hal::i2c::{I2c, I2cConfig};
use hal::pac::Peripherals;
use hal::prelude::*;
use hal::serial::Config as SerialConfig;
use panic_halt as _; use panic_halt as _;
#[qingke_rt::entry] #[qingke_rt::entry]
fn main() -> ! { fn main() -> ! {
SDIPrint::enable();
let p = Peripherals::take().unwrap();
let mut rcc = p.RCC.constrain();
let clocks = rcc.config.freeze();
let gpioa = p.GPIOA.split(&mut rcc);
let mut _fan = gpioa.pa2.into_push_pull_output_in_state(PinState::High);
let gpioc = p.GPIOC.split(&mut rcc);
let _i2c = I2c::i2c1(
p.I2C1,
gpioc.pc2.into_alternate_open_drain(),
gpioc.pc1.into_alternate_open_drain(),
I2cConfig::fast_mode(),
&mut rcc,
&clocks,
);
let mut _tec = gpioc.pc4.into_push_pull_output();
let gpiod = p.GPIOD.split(&mut rcc);
let mut _usart = p.USART1.usart(
gpiod.pd5.into_alternate(),
gpiod.pd6.into_floating_input(),
SerialConfig::default(),
&mut rcc,
&clocks,
);
loop {} loop {}
} }