void BoardInitMcu( void ) { if( McuInitialized == false ) { // We use IRQ priority group 4 for the entire project // When setting the IRQ, only the preemption priority is used NVIC_PriorityGroupConfig( NVIC_PriorityGroup_4 ); // Disable Systick SysTick->CTRL &= ~SysTick_CTRL_TICKINT_Msk; // Systick IRQ off SCB->ICSR |= SCB_ICSR_PENDSTCLR_Msk; // Clear SysTick Exception pending flag AdcInit( &Adc, POTI ); SpiInit( &SX1272.Spi, RADIO_MOSI, RADIO_MISO, RADIO_SCLK, NC ); SX1272IoInit( ); #if( LOW_POWER_MODE_ENABLE ) TimerSetLowPowerEnable( true ); #else TimerSetLowPowerEnable( false ); #endif BoardUnusedIoInit( ); if( TimerGetLowPowerEnable( ) == true ) { RtcInit( ); } else { TimerHwInit( ); } McuInitialized = true; } }
void RtcRecoverMcuStatus( void ) { //Disable IRQ while the MCU is not running on HSE __disable_irq( ); SystemClockConfig_STOP(); TimerHwInit(); SPI1_Init(); SX1276IoInit(); SX1276Q1CtrlInit(); __enable_irq( ); }
void HAL_MspSleepInit(void) { /* NOTE : This function is generated automatically by STM32CubeMX and eventually modified by the user */ SystemClock_Config(); SPI1_Init(); SX1276IoInit( ); TimerHwInit( ); }
void BoardInitMcu( void ) { if( McuInitialized == false ) { // We use IRQ priority group 4 for the entire project // When setting the IRQ, only the preemption priority is used NVIC_PriorityGroupConfig( NVIC_PriorityGroup_4 ); // Disable Systick // SysTick->CTRL &= ~SysTick_CTRL_TICKINT_Msk; // Systick IRQ off // SCB->ICSR |= SCB_ICSR_PENDSTCLR_Msk; // Clear SysTick Exception pending flag /* Setup SysTick Timer for 1 ms interrupts (not too often to save power) */ if (SysTick_Config(SystemCoreClock / 1000)) { /* Capture error */ while (1); } I2cInit( &I2c, I2C_SCL, I2C_SDA ); SpiInit( &SX1276.Spi, RADIO_MOSI, RADIO_MISO, RADIO_SCLK, NC ); SX1276IoInit( ); #if defined( USE_DEBUG_PINS ) GpioInit( &DbgPin1, J1_1, PIN_OUTPUT, PIN_PUSH_PULL, PIN_NO_PULL, 0 ); GpioInit( &DbgPin2, J1_2, PIN_OUTPUT, PIN_PUSH_PULL, PIN_NO_PULL, 0 ); GpioInit( &DbgPin3, J1_3, PIN_OUTPUT, PIN_PUSH_PULL, PIN_NO_PULL, 0 ); GpioInit( &DbgPin4, J1_4, PIN_OUTPUT, PIN_PUSH_PULL, PIN_NO_PULL, 0 ); #endif BoardInitPeriph( ); #if( LOW_POWER_MODE_ENABLE ) TimerSetLowPowerEnable( true ); #else TimerSetLowPowerEnable( false ); #endif BoardUnusedIoInit( ); if( TimerGetLowPowerEnable( ) == true ) { RtcInit( ); } else { TimerHwInit( ); } McuInitialized = true; } }
void BoardInitMcu( void ) { if ( McuInitialized == false ) { /* Initialize low level components */ low_level_init(); /*! SPI channel to be used by Semtech SX1276 */ #if defined(SX1276_BOARD_EMBED) SpiInit(&SX1276.Spi, RADIO_MOSI, RADIO_MISO, RADIO_SCLK, NC); SX1276IoInit(); #endif #if defined (USE_USB_CDC) UartInit( &UartUsb, UART_USB_CDC, NC, NC ); UartConfig( &UartUsb, RX_TX, 115200, UART_8_BIT, UART_1_STOP_BIT, NO_PARITY, NO_FLOW_CTRL ); TimerSetLowPowerEnable(false); #elif defined(DEBUG) #if defined(USE_SHELL) Shell_Init(); #else #if !defined(USE_CUSTOM_UART_HAL) FifoInit(&Uart1.FifoRx, DbgRxBuffer, DBG_FIFO_RX_SIZE); FifoInit(&Uart1.FifoTx, DbgTxBuffer, DBG_FIFO_TX_SIZE); #endif UartInit(&Uart1, UART_1, UART1_TX, UART1_RX); UartConfig(&Uart1, RX_TX, 115200, UART_8_BIT, UART_1_STOP_BIT, NO_PARITY, NO_FLOW_CTRL); #endif DbgConsole_Init(&Uart1); TimerSetLowPowerEnable(false); #elif( LOW_POWER_MODE_ENABLE ) TimerSetLowPowerEnable(true); #else TimerSetLowPowerEnable(false); #endif BoardUnusedIoInit(); #if !defined(USE_FREE_RTOS) if ( TimerGetLowPowerEnable() == true ) { RtcInit(); } else { TimerHwInit(); } #endif /* USE_FREE_RTOS */ McuInitialized = true; } }
void BoardInitMcu( void ) { if( McuInitialized == false ) { #if defined( USE_BOOTLOADER ) // Set the Vector Table base location at 0x3000 NVIC_SetVectorTable( NVIC_VectTab_FLASH, 0x3000 ); #endif // We use IRQ priority group 4 for the entire project // When setting the IRQ, only the preemption priority is used NVIC_PriorityGroupConfig( NVIC_PriorityGroup_4 ); // Disable Systick SysTick->CTRL &= ~SysTick_CTRL_TICKINT_Msk; // Systick IRQ off SCB->ICSR |= SCB_ICSR_PENDSTCLR_Msk; // Clear SysTick Exception pending flag I2cInit( &I2c, I2C_SCL, I2C_SDA ); AdcInit( &Adc, BAT_LEVEL ); SpiInit( &SX1272.Spi, RADIO_MOSI, RADIO_MISO, RADIO_SCLK, NC ); SX1272IoInit( ); #if defined( USE_DEBUG_PINS ) GpioInit( &DbgPin1, CON_EXT_1, PIN_OUTPUT, PIN_PUSH_PULL, PIN_NO_PULL, 0 ); GpioInit( &DbgPin2, CON_EXT_3, PIN_OUTPUT, PIN_PUSH_PULL, PIN_NO_PULL, 0 ); GpioInit( &DbgPin3, CON_EXT_7, PIN_OUTPUT, PIN_PUSH_PULL, PIN_NO_PULL, 0 ); GpioInit( &DbgPin4, CON_EXT_9, PIN_OUTPUT, PIN_PUSH_PULL, PIN_NO_PULL, 0 ); #endif BoardUnusedIoInit( ); #if defined( USE_USB_CDC ) UsbMcuInit( ); UartInit( &UartUsb, UART_USB_CDC, NC, NC ); UartConfig( &UartUsb, RX_TX, 115200, UART_8_BIT, UART_1_STOP_BIT, NO_PARITY, NO_FLOW_CTRL ); #endif #ifdef LOW_POWER_MODE_ENABLE RtcInit( ); #else TimerHwInit( ); #endif McuInitialized = true; } }
void BoardInitMcu( void ) { if( McuInitialized == false ) { // We use IRQ priority group 4 for the entire project // When setting the IRQ, only the preemption priority is used NVIC_PriorityGroupConfig( NVIC_PriorityGroup_4 ); // Disable Systick SysTick->CTRL &= ~SysTick_CTRL_TICKINT_Msk; // Systick IRQ off SCB->ICSR |= SCB_ICSR_PENDSTCLR_Msk; // Clear SysTick Exception pending flag I2cInit( &I2c, I2C_SCL, I2C_SDA ); SpiInit( &SX1272.Spi, RADIO_MOSI, RADIO_MISO, RADIO_SCLK, NC ); SX1272IoInit( ); #if defined( USE_DEBUG_PINS ) GpioInit( &DbgPin1, J5_1, PIN_OUTPUT, PIN_PUSH_PULL, PIN_NO_PULL, 0 ); GpioInit( &DbgPin2, J5_2, PIN_OUTPUT, PIN_PUSH_PULL, PIN_NO_PULL, 0 ); GpioInit( &DbgPin3, J5_3, PIN_OUTPUT, PIN_PUSH_PULL, PIN_NO_PULL, 0 ); GpioInit( &DbgPin4, J5_4, PIN_OUTPUT, PIN_PUSH_PULL, PIN_NO_PULL, 0 ); #endif BoardInitPeriph( ); #if( LOW_POWER_MODE_ENABLE ) TimerSetLowPowerEnable( true ); #else TimerSetLowPowerEnable( false ); #endif BoardUnusedIoInit( ); if( TimerGetLowPowerEnable( ) == true ) { RtcInit( ); } else { TimerHwInit( ); } McuInitialized = true; } }
/** * @brief Initializes the Global MSP. * @param None * @retval None */ void HAL_MspInit(void) { /* NOTE : This function is generated automatically by STM32CubeMX and eventually modified by the user */ SystemClock_Config(); //initiate LEDs HalLedInit(); //initiate KEY //KEY_Init(); HalKeyInit( ); //initiate OLED OLED_Init(); //initiate SPI (for sx1276/1279) SPI1_Init(); SX1276IoInit( ); //sx1279 active crystal initiate and power on SX1276Q1CtrlInit(); //initiate 3-wire UART UART_Init(); #if defined( LOW_POWER_MODE_ENABLE ) TimerSetLowPowerEnable( true ); //initiate RTC and stop mode RtcInit( ); #else TimerSetLowPowerEnable( false ); TimerHwInit( ); #endif }
void BoardInitMcu( void ) { if( McuInitialized == false ) { /* Chip errata */ CHIP_Init(); CMU_OscillatorEnable(cmuOsc_HFXO, true, true); CMU_ClockSelectSet(cmuClock_HF,cmuSelect_HFXO); /* Enable clock for HF peripherals */ CMU_ClockEnable(cmuClock_HFPER, true); CMU_ClockEnable(cmuClock_GPIO, true); GpioInit( &Led1, LED_1, PIN_OUTPUT, PIN_PUSH_PULL, PIN_NO_PULL, LED_1_ON_STATE ); GpioInit( &Led2, LED_2, PIN_OUTPUT, PIN_PUSH_PULL, PIN_NO_PULL, LED_2_ON_STATE ); #ifdef USE_I2C I2cInit( &I2c, I2C_SCL, I2C_SDA ); #endif SX1272IoInit( ); SpiInit( &SX1272.Spi, RADIO_MOSI, RADIO_MISO, RADIO_SCLK, NC ); BoardUnusedIoInit( ); #ifdef LOW_POWER_MODE_ENABLE #error LOW_POWER_MODE_ENABLE not supported RtcInit( ); #else TimerHwInit( ); #endif Led_1_Off(); Led_2_Off(); McuInitialized = true; } }