Added new stm32nucleo-spirit1 platform

This commit is contained in:
Marco Grella 2015-07-24 16:30:10 +02:00
parent d87f6f67e2
commit 86f35536a4
254 changed files with 173555 additions and 0 deletions

View file

@ -0,0 +1,649 @@
/**
******************************************************************************
* @file spirit1_appli.c
* @author System Lab - NOIDA
* @version V1.1.0
* @date 14-Aug-2014
* @brief user file to configure Spirit1 transceiver.
*
@verbatim
===============================================================================
##### How to use this driver #####
===============================================================================
[..]
This file is generated automatically by STM32CubeMX and eventually modified
by the user
@endverbatim
******************************************************************************
* @attention
*
* <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of STMicroelectronics nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "stm32l152xe.h"
#include "spirit1_appli.h"
#include "MCU_Interface.h"
#include "SPIRIT1_Util.h"
#include "lib/sensors.h"
extern const struct sensors_sensor button_sensor;
/** @addtogroup USER
* @{
*/
/** @defgroup SPIRIT1_APPLI
* @brief User file to configure spirit1 tranceiver for desired frequency and
* @feature.
* @{
*/
/* Private typedef -----------------------------------------------------------*/
/**
* @brief RadioDriver_t structure fitting
*/
RadioDriver_t spirit_cb =
{
.Init = Spirit1InterfaceInit,
.GpioIrq = Spirit1GpioIrqInit,
.RadioInit = Spirit1RadioInit,
.SetRadioPower = Spirit1SetPower,
.PacketConfig = Spirit1PacketConfig,
.SetPayloadLen = Spirit1SetPayloadlength,
.SetDestinationAddress = Spirit1SetDestinationAddress,
.EnableTxIrq = Spirit1EnableTxIrq,
.EnableRxIrq = Spirit1EnableRxIrq,
.DisableIrq = Spirit1DisableIrq,
.SetRxTimeout = Spirit1SetRxTimeout,
.EnableSQI = Spirit1EnableSQI,
.SetRssiThreshold = Spirit1SetRssiTH,
.ClearIrqStatus = Spirit1ClearIRQ,
.StartRx = Spirit1StartRx,
.StartTx = Spirit1StartTx,
.GetRxPacket = Spirit1GetRxPacket
};
/**
* @brief MCULowPowerMode_t structure fitting
*/
MCULowPowerMode_t MCU_LPM_cb =
{
.McuStopMode = MCU_Enter_StopMode,
.McuStandbyMode = MCU_Enter_StandbyMode,
.McuSleepMode = MCU_Enter_SleepMode
};
/**
* @brief RadioLowPowerMode_t structure fitting
*/
RadioLowPowerMode_t Radio_LPM_cb =
{
.RadioShutDown = RadioPowerOFF,
.RadioStandBy = RadioStandBy,
.RadioSleep = RadioSleep,
.RadioPowerON = RadioPowerON
};
/**
* @brief GPIO structure fitting
*/
SGpioInit xGpioIRQ={
SPIRIT_GPIO_IRQ,
SPIRIT_GPIO_MODE_DIGITAL_OUTPUT_LP,
SPIRIT_GPIO_DIG_OUT_IRQ
};
/**
* @brief Radio structure fitting
*/
SRadioInit xRadioInit = {
XTAL_OFFSET_PPM,
BASE_FREQUENCY,
CHANNEL_SPACE,
CHANNEL_NUMBER,
MODULATION_SELECT,
DATARATE,
FREQ_DEVIATION,
BANDWIDTH
};
#if defined(USE_STack_PROTOCOL)
/**
* @brief Packet Basic structure fitting
*/
PktStackInit xStackInit={
PREAMBLE_LENGTH,
SYNC_LENGTH,
SYNC_WORD,
LENGTH_TYPE,
LENGTH_WIDTH,
CRC_MODE,
CONTROL_LENGTH,
EN_FEC,
EN_WHITENING
};
/* LLP structure fitting */
PktStackLlpInit xStackLLPInit ={
EN_AUTOACK,
EN_PIGGYBACKING,
MAX_RETRANSMISSIONS
};
/**
* @brief Address structure fitting
*/
PktStackAddressesInit xAddressInit={
EN_FILT_MY_ADDRESS,
MY_ADDRESS,
EN_FILT_MULTICAST_ADDRESS,
MULTICAST_ADDRESS,
EN_FILT_BROADCAST_ADDRESS,
BROADCAST_ADDRESS
};
#elif defined(USE_BASIC_PROTOCOL)
/**
* @brief Packet Basic structure fitting
*/
PktBasicInit xBasicInit={
PREAMBLE_LENGTH,
SYNC_LENGTH,
SYNC_WORD,
LENGTH_TYPE,
LENGTH_WIDTH,
CRC_MODE,
CONTROL_LENGTH,
EN_ADDRESS,
EN_FEC,
EN_WHITENING
};
/**
* @brief Address structure fitting
*/
PktBasicAddressesInit xAddressInit={
EN_FILT_MY_ADDRESS,
MY_ADDRESS,
EN_FILT_MULTICAST_ADDRESS,
MULTICAST_ADDRESS,
EN_FILT_BROADCAST_ADDRESS,
BROADCAST_ADDRESS
};
#endif
/* Private define ------------------------------------------------------------*/
#define TIME_UP 0x01
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
RadioDriver_t *pRadioDriver;
MCULowPowerMode_t *pMCU_LPM_Comm;
RadioLowPowerMode_t *pRadio_LPM_Comm;
/*Flags declarations*/
volatile FlagStatus xRxDoneFlag = RESET, xTxDoneFlag=RESET, cmdFlag=RESET;
volatile FlagStatus xStartRx=RESET, rx_timeout=RESET, exitTime=RESET;
volatile FlagStatus datasendFlag=RESET, wakeupFlag=RESET;
volatile FlagStatus PushButtonStatusWakeup=RESET;
volatile FlagStatus PushButtonStatusData=RESET;
/*IRQ status struct declaration*/
SpiritIrqs xIrqStatus;
static __IO uint32_t KEYStatusData = 0x00;
AppliFrame_t xTxFrame, xRxFrame;
uint8_t TxFrameBuff[MAX_BUFFER_LEN] = {0x00};
uint16_t exitCounter = 0;
uint16_t txCounter = 0;
uint16_t wakeupCounter = 0;
uint16_t dataSendCounter = 0x00;
/* Private function prototypes -----------------------------------------------*/
void HAL_Spirit1_Init(void);
void Data_Comm_On(uint8_t *pTxBuff, uint8_t cTxlen, uint8_t* pRxBuff, uint8_t cRxlen);
void Enter_LP_mode(void);
void Exit_LP_mode(void);
void MCU_Enter_StopMode(void);
void MCU_Enter_StandbyMode(void);
void MCU_Enter_SleepMode(void);
void RadioPowerON(void);
void RadioPowerOFF(void);
void RadioStandBy(void);
void RadioSleep(void);
void SPIRIT1_Init(void);
void STackProtocolInit(void);
void BasicProtocolInit(void);
void P2PInterruptHandler(void);
void Set_KeyStatus(FlagStatus val);
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin);
void HAL_SYSTICK_Callback(void);
/* Private functions ---------------------------------------------------------*/
/** @defgroup SPIRIT1_APPLI_Private_Functions
* @{
*/
/**
* @brief Initializes RF Transceiver's HAL.
* @param None
* @retval None.
*/
void HAL_Spirit1_Init(void)
{
pRadioDriver = &spirit_cb;
pRadioDriver->Init( );
}
/**
* @brief This function initializes the protocol for point-to-point
* communication
* @param None
* @retval None
*/
void SPIRIT1_Init(void)
{
pRadioDriver = &spirit_cb;
/* Spirit IRQ config */
pRadioDriver->GpioIrq(&xGpioIRQ);
/* Spirit Radio config */
pRadioDriver->RadioInit(&xRadioInit);
/* Spirit Radio set power */
pRadioDriver->SetRadioPower(POWER_INDEX, POWER_DBM);
/* Spirit Packet config */
pRadioDriver->PacketConfig();
pRadioDriver->EnableSQI();
pRadioDriver->SetRssiThreshold(RSSI_THRESHOLD);
}
/**
* @brief This function initializes the BASIC Packet handler of spirit1
* @param None
* @retval None
*/
void BasicProtocolInit(void)
{
#if defined(USE_BASIC_PROTOCOL)
/* Spirit Packet config */
SpiritPktBasicInit(&xBasicInit);
SpiritPktBasicAddressesInit(&xAddressInit);
#endif
}
/**
* @brief This routine will put the radio and mcu in LPM
* @param None
* @retval None
*/
void Enter_LP_mode(void)
{
pMCU_LPM_Comm = &MCU_LPM_cb;
pRadio_LPM_Comm = &Radio_LPM_cb;
#if defined(MCU_STOP_MODE)&&defined(RF_SHUTDOWN)
{
pRadio_LPM_Comm->RadioShutDown();
pMCU_LPM_Comm->McuStopMode();
}
#elif defined(MCU_STOP_MODE)&&defined(RF_STANDBY)
{
pRadio_LPM_Comm->RadioStandBy();
pMCU_LPM_Comm->McuStopMode();
}
#elif defined(MCU_STOP_MODE)&&defined(RF_SLEEP)
{
pRadio_LPM_Comm->RadioSleep();
pMCU_LPM_Comm->McuStopMode();
}
#elif defined(MCU_STANDBY_MODE)&&defined(RF_SHUTDOWN)
{
pRadio_LPM_Comm->RadioShutDown();
pMCU_LPM_Comm->McuStandbyMode();
}
#elif defined(MCU_STANDBY_MODE)&&defined(RF_STANDBY)
{
pRadio_LPM_Comm->RadioStandBy();
pMCU_LPM_Comm->McuStandbyMode();
}
#elif defined(MCU_STANDBY_MODE)&&defined(RF_SLEEP)
{
pRadio_LPM_Comm->RadioSleep();
pMCU_LPM_Comm->McuStandbyMode();
}
#elif defined(MCU_SLEEP_MODE)&&defined(RF_SHUTDOWN)
{
pRadio_LPM_Comm->RadioShutDown();
pMCU_LPM_Comm->McuSleepMode();
}
#elif defined(MCU_SLEEP_MODE)&&defined(RF_STANDBY)
{
pRadio_LPM_Comm->RadioStandBy();
pMCU_LPM_Comm->McuSleepMode();
}
#elif defined(MCU_SLEEP_MODE)&&defined(RF_SLEEP)
{
pRadio_LPM_Comm->RadioSleep();
pMCU_LPM_Comm->McuSleepMode();
}
#elif defined(MCU_STOP_MODE)
pMCU_LPM_Comm->McuStopMode();
#elif defined(MCU_STANDBY_MODE)
pMCU_LPM_Comm->McuStandbyMode();
#else
pMCU_LPM_Comm->McuSleepMode();
#endif
}
/**
* @brief This routine wake-up the mcu and radio from LPM
* @param None
* @retval None
*/
void Exit_LP_mode(void)
{
pRadio_LPM_Comm = &Radio_LPM_cb;
pRadio_LPM_Comm->RadioPowerON();
}
/**
* @brief This routine puts the MCU in stop mode
* @param None
* @retval None
*/
void MCU_Enter_StopMode(void)
{
HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI); /* Infinite loop */
}
/**
* @brief This routine puts the MCU in standby mode
* @param None
* @retval None
*/
void MCU_Enter_StandbyMode(void)
{
HAL_PWR_EnterSTANDBYMode(); /* Infinite loop */
}
/**
* @brief This routine puts the MCU in sleep mode
* @param None
* @retval None
*/
void MCU_Enter_SleepMode(void)
{
/*Suspend Tick increment to prevent wakeup by Systick interrupt.
Otherwise the Systick interrupt will wake up the device within 1ms (HAL time base)*/
HAL_SuspendTick();
HAL_PWR_EnterSLEEPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI); /* Infinite loop */
}
/**
* @brief This function will turn on the radio and waits till it enters the Ready state.
* @param Param:None.
* @retval None
*
*/
void RadioPowerON(void)
{
SpiritCmdStrobeReady();
do{
/* Delay for state transition */
for(volatile uint8_t i=0; i!=0xFF; i++);
/* Reads the MC_STATUS register */
SpiritRefreshStatus();
}
while(g_xStatus.MC_STATE!=MC_STATE_READY);
}
/**
* @brief This function will Shut Down the radio.
* @param Param:None.
* @retval None
*
*/
void RadioPowerOFF(void)
{
SpiritEnterShutdown();
}
/**
* @brief This function will put the radio in standby state.
* @param None.
* @retval None
*
*/
void RadioStandBy(void)
{
SpiritCmdStrobeStandby();
#if 0
do{
/* Delay for state transition */
for(volatile uint8_t i=0; i!=0xFF; i++);
/* Reads the MC_STATUS register */
SpiritRefreshStatus();
}
while(g_xStatus.MC_STATE!=MC_STATE_STANDBY);
#endif
}
/**
* @brief This function will put the radio in sleep state.
* @param None.
* @retval None
*
*/
void RadioSleep(void)
{
SpiritCmdStrobeSleep();
#if 0
do{
/* Delay for state transition */
for(volatile uint8_t i=0; i!=0xFF; i++);
/* Reads the MC_STATUS register */
SpiritRefreshStatus();
}
while(g_xStatus.MC_STATE!=MC_STATE_SLEEP);
#endif
}
/**
* @brief This routine updates the respective status for key press.
* @param None
* @retval None
*/
void Set_KeyStatus(FlagStatus val)
{
if(val==SET)
{
KEYStatusData = 1;
}
else
KEYStatusData = 0;
}
/**
* @brief SYSTICK callback.
* @param None
* @retval None
*/
void HAL_SYSTICK_Callback(void)
{
if(exitTime)
{
/*Decreament the counter to check when 3 seconds has been elapsed*/
exitCounter--;
/*3 seconds has been elapsed*/
if(exitCounter <= TIME_UP)
{
exitTime = RESET;
}
}
#if defined(RF_STANDBY)
/*Check if Push Button pressed for wakeup or to send data*/
if(PushButtonStatusWakeup)
{
/*Decreament the counter to check when 5 seconds has been elapsed*/
wakeupCounter--;
/*5seconds has been elapsed*/
if(wakeupCounter<=TIME_UP)
{
/*Perform wakeup opeartion*/
wakeupFlag = SET;
Exit_LP_mode();
BSP_LED_Toggle(LED2);
PushButtonStatusWakeup = RESET;
PushButtonStatusData = SET;
}
}
else if(PushButtonStatusData)
{
dataSendCounter--;
if(dataSendCounter<=TIME_UP)
{
datasendFlag = SET;
PushButtonStatusWakeup = RESET;
PushButtonStatusData = RESET;
}
}
#endif
}
/**
* @}
*/
/**
* @brief GPIO EXTI callback
* @param uint16_t GPIO_Pin
* @retval None
*/
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
{
#if defined(MCU_STOP_MODE)/*if MCU is in stop mode*/
/* Clear Wake Up Flag */
__HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU);
/* Configures system clock after wake-up from STOP: enable HSE, PLL and select
PLL as system clock source (HSE and PLL are disabled in STOP mode) */
SystemClockConfig_STOP();
#endif
#if defined(MCU_SLEEP_MODE)
/* Resume Tick interrupt if disabled prior to sleep mode entry*/
HAL_ResumeTick();
#endif
/* Initialize LEDs*/
RadioShieldLedInit(RADIO_SHIELD_LED);
//BSP_LED_Init(LED2);
if (GPIO_Pin == USER_BUTTON_PIN)
{
sensors_changed(&button_sensor);
}
}
/**
* @}
*/
/**
* @brief Configures system clock after wake-up from STOP: enable HSI, PLL
* and select PLL as system clock source.
* @param None
* @retval None
*/
#if defined(MCU_STOP_MODE)/*if MCU is in stop mode*/
static void SystemClockConfig_STOP(void)
{
RCC_ClkInitTypeDef RCC_ClkInitStruct;
RCC_OscInitTypeDef RCC_OscInitStruct;
/* Enable Power Control clock */
__PWR_CLK_ENABLE();
/* The voltage scaling allows optimizing the power consumption when the device is
clocked below the maximum system frequency, to update the voltage scaling value
regarding system frequency refer to product datasheet. */
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
/* Get the Oscillators configuration according to the internal RCC registers */
HAL_RCC_GetOscConfig(&RCC_OscInitStruct);
/* After wake-up from STOP reconfigure the system clock: Enable HSI and PLL */
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
RCC_OscInitStruct.HSEState = RCC_HSE_OFF;
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
RCC_OscInitStruct.PLL.PLLMUL = RCC_PLLMUL_4;
RCC_OscInitStruct.PLL.PLLDIV = RCC_PLLDIV_2;
RCC_OscInitStruct.HSICalibrationValue = 0x10;
HAL_RCC_OscConfig(&RCC_OscInitStruct);
/* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2
clocks dividers */
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_SYSCLK;
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1);
}
#endif
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View file

@ -0,0 +1,334 @@
/**
******************************************************************************
* @file stm32cube_hal_init.c
* @author System LAB
* @version V1.0.0
* @date 17-June-2015
* @brief STM32 Cube HAL Init Source file
******************************************************************************
* @attention
*
* <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of STMicroelectronics nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "stdio.h"
#include "string.h"
#include "stdlib.h"
#include "stm32cube_hal_init.h"
#include "stm32l1xx_nucleo.h"
#include "radio_shield_config.h"
#include "spirit1_appli.h"
extern UART_HandleTypeDef UartHandle;
FlagStatus TamperStatus = RESET;
volatile uint8_t scheduler_started=0;
RTC_HandleTypeDef RtcHandle;
int dec_precision = 2;
volatile float UVI_Value;
static void RTC_Config(void);
static void RTC_TimeStampConfig(void);
static void SystemClock_Config(void);
static void MX_GPIO_Init(void);
void BSP_PB_Init(Button_TypeDef Button, ButtonMode_TypeDef Button_Mode);
void BSP_LED_Init(Led_TypeDef Led);
void BSP_LED_Off(Led_TypeDef Led);
void BSP_LED_On(Led_TypeDef Led);
void BSP_LED_Toggle(Led_TypeDef Led);
void USARTConfig(void);
void Stack_6LoWPAN_Init(void);
static void Error_Handler();
I2C_HandleTypeDef I2cHandle;
#define I2C_ADDRESS 0x30F
/* I2C SPEEDCLOCK define to max value: 400 KHz on STM32L1xx*/
#define I2C_SPEEDCLOCK 400000
#define I2C_DUTYCYCLE I2C_DUTYCYCLE_2
/**
* @brief stm32cube_hal_init()
* @param None
* @retval None
*/
void stm32cube_hal_init()
{
HAL_Init();
/* Configure the system clock */
SystemClock_Config();
HAL_EnableDBGStopMode();
MX_GPIO_Init();
HAL_Spirit1_Init();
SPIRIT1_Init();
USARTConfig();
/* Initialize RTC */
RTC_Config();
RTC_TimeStampConfig();
}
/**
* @brief Configure the RTC peripheral by selecting the clock source.
* @param None
* @retval None
*/
void RTC_Config(void)
{
/*##-1- Configure the RTC peripheral #######################################*/
RtcHandle.Instance = RTC;
/* Configure RTC prescaler and RTC data registers */
/* RTC configured as follow:
- Hour Format = Format 12
- Asynch Prediv = Value according to source clock
- Synch Prediv = Value according to source clock
- OutPut = Output Disable
- OutPutPolarity = High Polarity
- OutPutType = Open Drain */
RtcHandle.Init.HourFormat = RTC_HOURFORMAT_12;
RtcHandle.Init.AsynchPrediv = RTC_ASYNCH_PREDIV;
RtcHandle.Init.SynchPrediv = RTC_SYNCH_PREDIV;
RtcHandle.Init.OutPut = RTC_OUTPUT_DISABLE;
RtcHandle.Init.OutPutPolarity = RTC_OUTPUT_POLARITY_HIGH;
RtcHandle.Init.OutPutType = RTC_OUTPUT_TYPE_OPENDRAIN;
if(HAL_RTC_Init(&RtcHandle) != HAL_OK)
{
/* Initialization Error */
Error_Handler();
}
}
/**
* @brief Configures the current time and date.
* @param None
* @retval None
*/
static void RTC_TimeStampConfig(void)
{
RTC_DateTypeDef sdatestructure;
RTC_TimeTypeDef stimestructure;
/*##-3- Configure the Date #################################################*/
/* Set Date: Tuesday February 18th 2014 */
sdatestructure.Year = 0x14;
sdatestructure.Month = RTC_MONTH_FEBRUARY;
sdatestructure.Date = 0x18;
sdatestructure.WeekDay = RTC_WEEKDAY_TUESDAY;
if(HAL_RTC_SetDate(&RtcHandle,&sdatestructure,FORMAT_BCD) != HAL_OK)
{
/* Initialization Error */
Error_Handler();
}
/*##-4- Configure the Time #################################################*/
/* Set Time: 08:10:00 */
stimestructure.Hours = 0x08;
stimestructure.Minutes = 0x10;
stimestructure.Seconds = 0x00;
stimestructure.TimeFormat = RTC_HOURFORMAT12_AM;
stimestructure.DayLightSaving = RTC_DAYLIGHTSAVING_NONE ;
stimestructure.StoreOperation = RTC_STOREOPERATION_RESET;
if(HAL_RTC_SetTime(&RtcHandle,&stimestructure,FORMAT_BCD) != HAL_OK)
{
/* Initialization Error */
Error_Handler();
}
}
/**
* @brief System Clock Configuration
* The system Clock is configured as follow :
* System Clock source = PLL (HSI)
* SYSCLK(Hz) = 32000000
* HCLK(Hz) = 32000000
* AHB Prescaler = 1
* APB1 Prescaler = 1
* APB2 Prescaler = 1
* HSI Frequency(Hz) = 16000000
* PLL_MUL = 4
* PLL_DIV = 2
* Flash Latency(WS) = 1
* Main regulator output voltage = Scale1 mode
* @param None
* @retval None
*/
void SystemClock_Config(void)
{
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
/* Enable HSE Oscillator and Activate PLL with HSE as source */
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
RCC_OscInitStruct.HSEState = RCC_HSE_OFF;
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL6;
RCC_OscInitStruct.PLL.PLLDIV = RCC_PLL_DIV3;
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
Error_Handler();
}
/* Set Voltage scale1 as MCU will run at 32MHz */
__PWR_CLK_ENABLE();
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
/* Poll VOSF bit of in PWR_CSR. Wait until it is reset to 0 */
while (__HAL_PWR_GET_FLAG(PWR_FLAG_VOS) != RESET) {};
/* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2
clocks dividers */
RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2);
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK)
{
Error_Handler();
}
}
/**
* @brief This function is executed in case of error occurrence.
* @param None
* @retval None
*/
static void Error_Handler(void)
{
/* User may add here some code to deal with this error */
while(1)
{
}
}
/**
* @brief RTC MSP Initialization
* This function configures the hardware resources used in this example
* @param hrtc: RTC handle pointer
*
* @note Care must be taken when HAL_RCCEx_PeriphCLKConfig() is used to select
* the RTC clock source; in this case the Backup domain will be reset in
* order to modify the RTC Clock source, as consequence RTC registers (including
* the backup registers) and RCC_BDCR register are set to their reset values.
*
* @retval None
*/
void HAL_RTC_MspInit(RTC_HandleTypeDef *hrtc)
{
RCC_OscInitTypeDef RCC_OscInitStruct;
RCC_PeriphCLKInitTypeDef PeriphClkInitStruct;
/*##-1- Configue LSE as RTC clock soucre ###################################*/
#ifdef RTC_CLOCK_SOURCE_LSE
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI | RCC_OSCILLATORTYPE_LSE;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
RCC_OscInitStruct.LSEState = RCC_LSE_ON;
RCC_OscInitStruct.LSIState = RCC_LSI_OFF;
if(HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
/* Initialization Error */
Error_Handler();
}
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_RTC;
PeriphClkInitStruct.RTCClockSelection = RCC_RTCCLKSOURCE_LSE;
if(HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK)
{
/* Initialization Error */
Error_Handler();
}
#elif defined (RTC_CLOCK_SOURCE_LSI)
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI | RCC_OSCILLATORTYPE_LSE;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
RCC_OscInitStruct.LSIState = RCC_LSI_ON;
RCC_OscInitStruct.LSEState = RCC_LSE_OFF;
if(HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
/* Initialization Error */
Error_Handler();
}
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_RTC;
PeriphClkInitStruct.RTCClockSelection = RCC_RTCCLKSOURCE_LSI;
if(HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK)
{
/* Initialization Error */
Error_Handler();
}
#else
#error Please select the RTC Clock source inside the stm32cube_hal_init.h file
#endif /*RTC_CLOCK_SOURCE_LSE*/
/*##-2- Enable RTC peripheral Clocks #######################################*/
/* Enable RTC Clock */
__HAL_RCC_RTC_ENABLE();
/*##-3- Configure the NVIC for RTC TimeStamp ###################################*/
HAL_NVIC_SetPriority(/*TAMP_STAMP_IRQn*/2, 0x0F, 0);
HAL_NVIC_EnableIRQ(/*TAMP_STAMP_IRQn*/2);
}
/** Configure pins as
* Analog
* Input
* Output
* EVENT_OUT
* EXTI
*/
void MX_GPIO_Init(void)
{
/* GPIO Ports Clock Enable */
__GPIOA_CLK_ENABLE();
__GPIOC_CLK_ENABLE();
__GPIOD_CLK_ENABLE();
}
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View file

@ -0,0 +1,319 @@
/**
******************************************************************************
* @file stm32l1xx_hal_msp.c
* @author System LAB
* @version V1.0.0
* @date 17-June-2015
* @brief HAL MSP file
******************************************************************************
* @attention
*
* <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of STMicroelectronics nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "stm32cube_hal_init.h"
#include "stm32l1xx_hal.h"
#include "hw-config.h"
/** @addtogroup STM32L1xx_HAL_Examples
* @{
*/
/** @addtogroup Templates
* @{
*/
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
volatile uint8_t UART_RxBuffer[UART_RxBufferSize];
volatile uint32_t Usart_BaudRate = 115200;
UART_HandleTypeDef UartHandle;
/* Private function prototypes -----------------------------------------------*/
/* Private functions ---------------------------------------------------------*/
/** @defgroup HAL_MSP_Private_Functions
* @{
*/
/**
* @brief Initializes the Global MSP.
* @param None
* @retval None
*/
void HAL_MspInit(void)
{
/* NOTE : This function is generated automatically by MicroXplorer and eventually
modified by the user
*/
GPIO_InitTypeDef GPIO_InitStruct;
/*##-2- Enable peripherals and GPIO Clocks #################################*/
/* Enable GPIO TX/RX clock */
/* GPIO Ports Clock Enable */
__GPIOA_CLK_ENABLE();
__GPIOC_CLK_ENABLE();
__GPIOD_CLK_ENABLE();
I2Cx_SCL_GPIO_CLK_ENABLE();
I2Cx_SDA_GPIO_CLK_ENABLE();
/* Enable I2Cx clock */
I2Cx_CLK_ENABLE();
/*##-3- Configure peripheral GPIO ##########################################*/
/* I2C TX GPIO pin configuration */
GPIO_InitStruct.Pin = I2Cx_SCL_PIN;
GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
GPIO_InitStruct.Pull = GPIO_PULLUP;
GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
GPIO_InitStruct.Alternate = I2Cx_SCL_SDA_AF;
HAL_GPIO_Init(I2Cx_SCL_GPIO_PORT, &GPIO_InitStruct);
/* I2C RX GPIO pin configuration */
GPIO_InitStruct.Pin = I2Cx_SDA_PIN;
GPIO_InitStruct.Alternate = I2Cx_SCL_SDA_AF;
HAL_GPIO_Init(I2Cx_SDA_GPIO_PORT, &GPIO_InitStruct);
/*##-4- Configure the NVIC for I2C ########################################*/
/* NVIC for I2Cx */
HAL_NVIC_SetPriority(I2Cx_ER_IRQn, 0, 1);
HAL_NVIC_EnableIRQ(I2Cx_ER_IRQn);
HAL_NVIC_SetPriority(I2Cx_EV_IRQn, 0, 2);
HAL_NVIC_EnableIRQ(I2Cx_EV_IRQn);
}
/**
* @brief DeInitializes the Global MSP.
* @param None
* @retval None
*/
void HAL_MspDeInit(void)
{
/* NOTE : This function is generated automatically by MicroXplorer and eventually
modified by the user
*/
/*##-1- Reset peripherals ##################################################*/
I2Cx_FORCE_RESET();
I2Cx_RELEASE_RESET();
/*##-2- Disable peripherals and GPIO Clocks #################################*/
/* Configure I2C Tx as alternate function */
HAL_GPIO_DeInit(I2Cx_SCL_GPIO_PORT, I2Cx_SCL_PIN);
/* Configure I2C Rx as alternate function */
HAL_GPIO_DeInit(I2Cx_SDA_GPIO_PORT, I2Cx_SDA_PIN);
/*##-3- Disable the NVIC for I2C ##########################################*/
HAL_NVIC_DisableIRQ(I2Cx_ER_IRQn);
HAL_NVIC_DisableIRQ(I2Cx_EV_IRQn);
}
void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base)
{
if(htim_base->Instance==TIM2)
{
/* Peripheral clock enable */
__TIM2_CLK_ENABLE();
/**TIM2 GPIO Configuration
PA0-WKUP ------> TIM2_CH1
*/
/* Peripheral interrupt init*/
HAL_NVIC_SetPriority(TIM2_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(TIM2_IRQn);
}
}
void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* htim_base)
{
if(htim_base->Instance==TIM2)
{
/* Peripheral clock disable */
__TIM2_CLK_DISABLE();
/**TIM2 GPIO Configuration
PA0-WKUP ------> TIM2_CH1
*/
/* Peripheral interrupt Deinit*/
HAL_NVIC_DisableIRQ(TIM2_IRQn);
}
}
/**
* @brief UART MSP Initialization
* This function configures the hardware resources used in this example:
* - Peripheral's clock enable
* - Peripheral's GPIO Configuration
* - NVIC configuration for UART interrupt request enable
* @param huart: UART handle pointer
* @retval None
*/
void HAL_UART_MspInit(UART_HandleTypeDef *huart)
{
GPIO_InitTypeDef GPIO_InitStruct;
/*##-1- Enable peripherals and GPIO Clocks #################################*/
/* Enable GPIO TX/RX clock */
USARTx_TX_GPIO_CLK_ENABLE();
USARTx_RX_GPIO_CLK_ENABLE();
/* Enable USARTx clock */
USARTx_CLK_ENABLE();
/*##-2- Configure peripheral GPIO ##########################################*/
/* UART TX GPIO pin configuration */
GPIO_InitStruct.Pin = USARTx_TX_PIN;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
GPIO_InitStruct.Alternate = USARTx_TX_AF;
HAL_GPIO_Init(USARTx_TX_GPIO_PORT, &GPIO_InitStruct);
/* UART RX GPIO pin configuration */
GPIO_InitStruct.Pin = USARTx_RX_PIN;
GPIO_InitStruct.Alternate = USARTx_RX_AF;
HAL_GPIO_Init(USARTx_RX_GPIO_PORT, &GPIO_InitStruct);
/*##-3- Configure the NVIC for UART ########################################*/
/* NVIC for USART */
HAL_NVIC_SetPriority(USARTx_IRQn, 0, 1);
HAL_NVIC_EnableIRQ(USARTx_IRQn);
}
/**
* @brief UART MSP De-Initialization
* This function frees the hardware resources used in this example:
* - Disable the Peripheral's clock
* - Revert GPIO and NVIC configuration to their default state
* @param huart: UART handle pointer
* @retval None
*/
void HAL_UART_MspDeInit(UART_HandleTypeDef *huart)
{
/*##-1- Reset peripherals ##################################################*/
USARTx_FORCE_RESET();
USARTx_RELEASE_RESET();
/*##-2- Disable peripherals and GPIO Clocks #################################*/
/* Configure UART Tx as alternate function */
HAL_GPIO_DeInit(USARTx_TX_GPIO_PORT, USARTx_TX_PIN);
/* Configure UART Rx as alternate function */
HAL_GPIO_DeInit(USARTx_RX_GPIO_PORT, USARTx_RX_PIN);
/*##-3- Disable the NVIC for UART ##########################################*/
HAL_NVIC_DisableIRQ(USARTx_IRQn);
}
/**
* @brief Configure the USART
* @param None
* @retval None
*/
void USARTConfig(void)
{
GPIO_InitTypeDef GPIO_InitStruct;
/*##-1- Enable peripherals and GPIO Clocks #################################*/
/* Enable GPIO TX/RX clock */
USARTx_TX_GPIO_CLK_ENABLE();
USARTx_RX_GPIO_CLK_ENABLE();
/* Enable USART2 clock */
USARTx_CLK_ENABLE();
/* Enable DMA1 clock */
DMAx_CLK_ENABLE();
/*##-2- Configure peripheral GPIO ##########################################*/
/* UART TX GPIO pin configuration */
GPIO_InitStruct.Pin = USARTx_TX_PIN;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
GPIO_InitStruct.Alternate = USARTx_TX_AF;
HAL_GPIO_Init(USARTx_TX_GPIO_PORT, &GPIO_InitStruct);
/* UART RX GPIO pin configuration */
GPIO_InitStruct.Pin = USARTx_RX_PIN;
GPIO_InitStruct.Alternate = USARTx_RX_AF;
HAL_GPIO_Init(USARTx_RX_GPIO_PORT, &GPIO_InitStruct);
/*##-1- Configure the UART peripheral ######################################*/
/* Put the USART peripheral in the Asynchronous mode (UART Mode) */
UartHandle.Instance = USARTx;
UartHandle.Init.BaudRate = Usart_BaudRate;
UartHandle.Init.WordLength = UART_WORDLENGTH_8B;
UartHandle.Init.StopBits = UART_STOPBITS_1;
UartHandle.Init.Parity = UART_PARITY_NONE;
UartHandle.Init.HwFlowCtl = UART_HWCONTROL_NONE;
UartHandle.Init.Mode = UART_MODE_TX_RX;
if(HAL_UART_Init(&UartHandle) != HAL_OK)
{
// Error_Handler();
while(1);
}
UartHandle.pRxBuffPtr = (uint8_t*)UART_RxBuffer;
UartHandle.RxXferSize = UART_RxBufferSize;
UartHandle.ErrorCode = HAL_UART_ERROR_NONE;
//HAL_UART_Receive_IT(&UartHandle, (uint8_t*)UART_RxBuffer, UART_RxBufferSize);
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View file

@ -0,0 +1,363 @@
/**
******************************************************************************
* @file stm32l1xx_it.c
* @author System LAB
* @version V1.0.0
* @date 17-June-2015
* @brief Main Interrupt Service Routines
******************************************************************************
* @attention
*
* <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of STMicroelectronics nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "stm32cube_hal_init.h"
#include "stm32l1xx_it.h"
#include "stm32l1xx_nucleo.h"
#include "radio_gpio.h"
#include "spirit1.h"
extern UART_HandleTypeDef UartHandle;
/** @addtogroup STM32L1xx_HAL_Examples
* @{
*/
/** @addtogroup Templates
* @{
*/
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
/* Private functions ---------------------------------------------------------*/
/******************************************************************************/
/* Cortex-M3 Processor Exceptions Handlers */
/******************************************************************************/
extern I2C_HandleTypeDef I2cHandle;
/**
* @brief This function handles NMI exception.
* @param None
* @retval None
*/
void NMI_Handler(void)
{
}
void WWDG_IRQHandler(void)
{
while(1);
}
/**
* @brief This function handles Hard Fault exception.
* @param None
* @retval None
*/
void HardFault_Handler(void)
{
/* Go to infinite loop when Hard Fault exception occurs */
while (1)
{
}
}
/**
* @brief This function handles Memory Manage exception.
* @param None
* @retval None
*/
void MemManage_Handler(void)
{
/* Go to infinite loop when Memory Manage exception occurs */
while (1)
{
}
}
/**
* @brief This function handles Bus Fault exception.
* @param None
* @retval None
*/
void BusFault_Handler(void)
{
/* Go to infinite loop when Bus Fault exception occurs */
while (1)
{
}
}
/**
* @brief This function handles Usage Fault exception.
* @param None
* @retval None
*/
void UsageFault_Handler(void)
{
/* Go to infinite loop when Usage Fault exception occurs */
while (1)
{
}
}
/**
* @brief This function handles SVCall exception.
* @param None
* @retval None
*/
void SVC_Handler(void)
{
}
/**
* @brief This function handles Debug Monitor exception.
* @param None
* @retval None
*/
void DebugMon_Handler(void)
{
}
/**
* @brief This function handles PendSVC exception.
* @param None
* @retval None
*/
void PendSV_Handler(void)
{
}
/******************************************************************************/
/* STM32L1xx Peripherals Interrupt Handlers */
/* Add here the Interrupt Handler for the used peripheral(s) (PPP), for the */
/* available peripheral interrupt handler's name please refer to the startup */
/* file (startup_stm32l1xx.s). */
/******************************************************************************/
/**
* @brief This function handles I2C event interrupt request.
* @param None
* @retval None
* @Note This function is redefined in "stm32cube_hal_init.h" and related to I2C data transmission
*/
void I2Cx_EV_IRQHandler(void)
{
HAL_I2C_EV_IRQHandler(& I2cHandle);
}
/**
* @brief This function handles I2C error interrupt request.
* @param None
* @retval None
* @Note This function is redefined in "stm32cube_hal_init.h" and related to I2C error
*/
void I2Cx_ER_IRQHandler(void)
{
HAL_I2C_ER_IRQHandler(& I2cHandle);
}
/**
* @brief This function handles External lines 15 to 4 interrupt request.
* @param None
* @retval None
*/
void EXTI0_IRQHandler(void)
{
/* EXTI line interrupt detected */
if(__HAL_GPIO_EXTI_GET_IT(GPIO_PIN_0) != RESET)
{
__HAL_GPIO_EXTI_CLEAR_IT(GPIO_PIN_0);
}
while(1);
}
void EXTI1_IRQHandler(void)
{
/* EXTI line interrupt detected */
if(__HAL_GPIO_EXTI_GET_IT(GPIO_PIN_1) != RESET)
{
__HAL_GPIO_EXTI_CLEAR_IT(GPIO_PIN_1);
}
while(1);
}
void EXTI2_IRQHandler(void)
{
/* EXTI line interrupt detected */
if(__HAL_GPIO_EXTI_GET_IT(GPIO_PIN_2) != RESET)
{
__HAL_GPIO_EXTI_CLEAR_IT(GPIO_PIN_2);
}
while(1);
}
void EXTI3_IRQHandler(void)
{
/* EXTI line interrupt detected */
if(__HAL_GPIO_EXTI_GET_IT(GPIO_PIN_3) != RESET)
{
__HAL_GPIO_EXTI_CLEAR_IT(GPIO_PIN_3);
}
while(1);
}
/**
* @brief This function handles External lines 15 to 4 interrupt request.
* @param None
* @retval None
*/
void EXTI9_5_IRQHandler(void)
{
/* EXTI line 7 interrupt detected */
if(__HAL_GPIO_EXTI_GET_IT(RADIO_GPIO_3_EXTI_LINE))
{
__HAL_GPIO_EXTI_CLEAR_IT(RADIO_GPIO_3_EXTI_LINE);
HAL_GPIO_EXTI_Callback(RADIO_GPIO_3_EXTI_LINE);
spirit1_interrupt_callback();
}
__HAL_GPIO_EXTI_CLEAR_IT(GPIO_PIN_9);
__HAL_GPIO_EXTI_CLEAR_IT(GPIO_PIN_8);
__HAL_GPIO_EXTI_CLEAR_IT(GPIO_PIN_7);
__HAL_GPIO_EXTI_CLEAR_IT(GPIO_PIN_6);
__HAL_GPIO_EXTI_CLEAR_IT(GPIO_PIN_5);
#ifndef LPM_ENABLE
// if(__HAL_GPIO_EXTI_GET_IT(KEY_BUTTON_EXTI_LINE) != RESET)
// {
// __HAL_GPIO_EXTI_CLEAR_IT(KEY_BUTTON_EXTI_LINE);
//
// Set_KeyStatus(SET);
// }
//
#else /*Low Power mode enabled*/
#if defined(RF_STANDBY)/*if spirit1 is in standby*/
if(EXTI->PR & KEY_BUTTON_EXTI_LINE)
{
HAL_GPIO_EXTI_Callback(KEY_BUTTON_EXTI_LINE);
/* EXTI line 13 interrupt detected */
if(HAL_GPIO_ReadPin(KEY_BUTTON_GPIO_PORT, KEY_BUTTON_PIN) == 0x01) //0x00
{
HAL_GPIO_EXTI_Callback(KEY_BUTTON_EXTI_LINE);
PushButtonStatusWakeup = SET;
PushButtonStatusData = RESET;
wakeupCounter = LPM_WAKEUP_TIME;
dataSendCounter = DATA_SEND_TIME;
dataSendCounter++;
}
__HAL_GPIO_EXTI_CLEAR_IT(KEY_BUTTON_EXTI_LINE);
}
#else /*if spirit1 is not in standby or sleep mode but MCU is in LPM*/
if(__HAL_GPIO_EXTI_GET_IT(KEY_BUTTON_EXTI_LINE) != RESET)
{
__HAL_GPIO_EXTI_CLEAR_IT(KEY_BUTTON_EXTI_LINE);
HAL_GPIO_EXTI_Callback(KEY_BUTTON_EXTI_LINE);
Set_KeyStatus(SET);
}
#endif
#endif
}
/**
* @brief This function handles EXTI15_10_IRQHandler
* @param None
* @retval None
*/
void EXTI15_10_IRQHandler(void)
{
HAL_GPIO_EXTI_IRQHandler(USER_BUTTON_PIN);
}
/**
* @brief This function handles UART interrupt request.
* @param None
* @retval None
* @Note This function is redefined in "stm32cube_hal_init.h" and related to DMA
* used for USART data transmission
*/
void USART2_IRQHandler()
{
slip_input_byte(UartHandle.Instance->DR);
return;
//HAL_UART_IRQHandler(&UartHandle);
}
/**
* @brief UART error callbacks
* @param UartHandle: UART handle
* @note This example shows a simple way to report transfer error, and you can
* add your own implementation.
* @retval None
*/
void HAL_UART_ErrorCallback(UART_HandleTypeDef *UartHandle)
{
// Error_Handler();
}
/**
* @brief Tx Transfer completed callback
* @param UartHandle: UART handle.
* @note This example shows a simple way to report end of IT Tx transfer, and
* you can add your own implementation.
* @retval None
*/
void HAL_UART_TxCpltCallback(UART_HandleTypeDef *UartHandle)
{
}
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/