void BoardInitMcu( void ) { Gpio_t ioPin; if( McuInitialized == false ) { HAL_Init( ); // LEDs GpioInit( &Led1, LED_1, PIN_OUTPUT, PIN_PUSH_PULL, PIN_NO_PULL, 1 ); GpioInit( &Led2, LED_2, PIN_OUTPUT, PIN_PUSH_PULL, PIN_NO_PULL, 1 ); GpioInit( &Led3, LED_3, PIN_OUTPUT, PIN_PUSH_PULL, PIN_NO_PULL, Led3Status ); SystemClockConfig( ); GpioInit( &ioPin, UART_RX, PIN_INPUT, PIN_PUSH_PULL, PIN_NO_PULL, 0 ); if( GpioRead( &ioPin ) == 1 ) // Debug Mode { UsbIsConnected = true; FifoInit( &Uart1.FifoTx, UartTxBuffer, UART_FIFO_TX_SIZE ); FifoInit( &Uart1.FifoRx, UartRxBuffer, UART_FIFO_RX_SIZE ); // Configure your terminal for 8 Bits data (7 data bit + 1 parity bit), no parity and no flow ctrl UartInit( &Uart1, UART_1, UART_TX, UART_RX ); UartConfig( &Uart1, RX_TX, 115200, UART_8_BIT, UART_1_STOP_BIT, NO_PARITY, NO_FLOW_CTRL ); } else { UsbIsConnected = false; UartDeInit( &Uart1 ); } RtcInit( ); BoardUnusedIoInit( ); } else { SystemClockReConfig( ); } I2cInit( &I2c, I2C_SCL, I2C_SDA ); AdcInit( &Adc, BAT_LEVEL_PIN ); SpiInit( &SX1272.Spi, RADIO_MOSI, RADIO_MISO, RADIO_SCLK, NC ); SX1272IoInit( ); if( McuInitialized == false ) { McuInitialized = true; if( GetBoardPowerSource( ) == BATTERY_POWER ) { CalibrateSystemWakeupTime( ); } } }
void GpsMcuIrqNotify( UartNotifyId_t id ) { uint8_t data; if( id == UART_NOTIFY_RX ) { if( UartGetChar( &Uart1, &data ) == 0 ) { if( ( data == '$' ) || ( NmeaStringSize >= 128 ) ) { NmeaStringSize = 0; } NmeaString[NmeaStringSize++] = ( int8_t )data; if( data == '\n' ) { NmeaString[NmeaStringSize] = '\0'; GpsParseGpsData( ( int8_t* )NmeaString, NmeaStringSize ); UartDeInit( &Uart1 ); BlockLowPowerDuringTask ( false ); } } } }