Skip to content
Snippets Groups Projects
Select Git revision
  • ccf251974e3c1feeef24e2026fef3e693e43c9ab
  • master default protected
  • rtic6
3 results

rtt_timing.rs

Blame
  • Forked from Per Lindgren / rtic_f4xx_nucleo
    Source project has a limited visibility.
    bare10.rs 2.90 KiB
    //! The RTFM framework
    //!
    //! What it covers:
    //! - Priority based scheduling
    //! - Message passing
    
    #![no_main]
    #![no_std]
    
    extern crate panic_halt;
    
    use cortex_m::{asm, iprintln};
    
    extern crate stm32f4xx_hal as hal;
    use crate::hal::prelude::*;
    use crate::hal::serial::{config::Config, Event, Rx, Serial, Tx};
    use hal::stm32::ITM;
    
    use nb::block;
    use rtfm::app;
    
    // Our error type
    #[derive(Debug)]
    pub enum Error {
        RingBufferOverflow,
        UsartSendOverflow,
        UsartReceiveOverflow,
    }
    
    #[app(device = hal::stm32)]
    const APP: () = {
        // Late resources
        static mut TX: Tx<hal::stm32::USART2> = ();
        static mut RX: Rx<hal::stm32::USART2> = ();
        static mut ITM: ITM = ();
    
        // init runs in an interrupt free section>
        #[init]
        fn init() {
            let stim = &mut core.ITM.stim[0];
            iprintln!(stim, "start");
    
            let rcc = device.RCC.constrain();
    
            // 16 MHz (default, all clocks)
            let clocks = rcc.cfgr.freeze();
    
            let gpioa = device.GPIOA.split();
    
            let tx = gpioa.pa2.into_alternate_af7();
            let rx = gpioa.pa3.into_alternate_af7(); // try comment out
    
            let mut serial = Serial::usart2(
                device.USART2,
                (tx, rx),
                Config::default().baudrate(115_200.bps()),
                clocks,
            )
            .unwrap();
    
            // generate interrupt on Rxne
            serial.listen(Event::Rxne);
            // Separate out the sender and receiver of the serial port
            let (tx, rx) = serial.split();
    
            // Our split serial
            TX = tx;
            RX = rx;
    
            // For debugging