Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions boards/stm32f3discovery/src/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ impl Write for Writer {

impl IoWrite for Writer {
fn write(&mut self, buf: &[u8]) {
let uart = unsafe { &mut stm32f303xc::usart::USART1 };
let rcc = stm32f303xc::rcc::Rcc::new();
let uart = stm32f303xc::usart::Usart::new_usart1(&rcc);

if !self.initialized {
self.initialized = true;
Expand All @@ -63,7 +64,14 @@ impl IoWrite for Writer {
#[panic_handler]
pub unsafe extern "C" fn panic_fmt(info: &PanicInfo) -> ! {
// User LD3 is connected to PE09
let led = &mut led::LedHigh::new(PinId::PE09.get_pin_mut().as_mut().unwrap());
// Have to reinitialize several peripherals because otherwise can't access them here.
let rcc = stm32f303xc::rcc::Rcc::new();
let syscfg = stm32f303xc::syscfg::Syscfg::new(&rcc);
let exti = stm32f303xc::exti::Exti::new(&syscfg);
let mut pin = stm32f303xc::gpio::Pin::new(PinId::PE09, &exti);
let gpio_ports = stm32f303xc::gpio::GpioPorts::new(&rcc, &exti);
pin.set_ports_ref(&gpio_ports);
let led = &mut led::LedHigh::new(&mut pin);
let writer = &mut WRITER;

debug::panic(
Expand Down
Loading