diff --git a/firmware/src/main.rs b/firmware/src/main.rs index d03a242..617a03f 100644 --- a/firmware/src/main.rs +++ b/firmware/src/main.rs @@ -3,9 +3,46 @@ 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 _; #[qingke_rt::entry] 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 {} }