Skip to content

Commit

Permalink
simplify the BSP to keep are timer_f and include the RTC library
Browse files Browse the repository at this point in the history
Include the STM32RTC library to all the BSP as only few functions
remain in the BSP as the RTC is instantiated by the STM32RTC library

Signed-off-by: Francois Ramu <francois.ramu@st.com>
  • Loading branch information
FRASTM committed Jun 15, 2023
1 parent 37238b7 commit 0368da7
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 202 deletions.
145 changes: 0 additions & 145 deletions src/BSP/rtc.c

This file was deleted.

53 changes: 0 additions & 53 deletions src/BSP/rtc.h

This file was deleted.

52 changes: 48 additions & 4 deletions src/BSP/timer_if.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,56 @@
// #include "stm32_lpm.h"
// #include "utilities_def.h"
#include "stm32wlxx_ll_rtc.h"
#include "rtc.h"

/* USER CODE BEGIN Includes */

/* USER CODE END Includes */

/* External variables ---------------------------------------------------------*/
/**
* @brief RTC handle
*/

extern RTC_HandleTypeDef RtcHandle;

/* HAL MSP function used for RTC_Init */
void HAL_RTC_MspInit(RTC_HandleTypeDef* rtcHandle)
{

if(rtcHandle->Instance==RTC)
{
if (HAL_RTCEx_SetSSRU_IT(rtcHandle) != HAL_OK)
{
Error_Handler();
}

/* RTC interrupt Init */
HAL_NVIC_SetPriority(TAMP_STAMP_LSECSS_SSRU_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(TAMP_STAMP_LSECSS_SSRU_IRQn);

HAL_NVIC_SetPriority(RTC_Alarm_IRQn, RTC_IRQ_PRIO, RTC_IRQ_SUBPRIO);
HAL_NVIC_EnableIRQ(RTC_Alarm_IRQn);
}
}

void HAL_RTC_MspDeInit(RTC_HandleTypeDef* rtcHandle)
{

if(rtcHandle->Instance==RTC)
{
/* USER CODE BEGIN RTC_MspDeInit 0 */

/* USER CODE END RTC_MspDeInit 0 */
/* Peripheral clock disable */
__HAL_RCC_RTC_DISABLE();
__HAL_RCC_RTCAPB_CLK_DISABLE();

/* RTC interrupt Deinit */
HAL_NVIC_DisableIRQ(TAMP_STAMP_LSECSS_SSRU_IRQn);
HAL_NVIC_DisableIRQ(RTC_Alarm_IRQn);
/* USER CODE BEGIN RTC_MspDeInit 1 */

/* USER CODE END RTC_MspDeInit 1 */
}
}

/**
* @brief Timer driver callbacks handler
*/
Expand Down Expand Up @@ -187,6 +225,12 @@ UTIL_TIMER_Status_t TIMER_IF_Init(void)
if (RTC_Initialized == false)
{
/* RTC is already Initialized by the LoRaWan::begin */
RtcHandle.IsEnabled.RtcFeatures = UINT32_MAX;

/** Enable the Alarm B just after the HAL_RTC_Init */
RTC_StartAlarm(RTC_ALARM_B, 0, 0, 0, 0, 0, RTC_HOURFORMAT12_PM, 32UL);

/*Stop Timer */
TIMER_IF_StopTimer();

/*overload RTC feature enable*/
Expand Down
1 change: 1 addition & 0 deletions src/BSP/timer_if.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ void UTIL_TIMER_IRQ_MAP_PROCESS(void *data);
/* Exported types ------------------------------------------------------------*/
/* USER CODE BEGIN ET */


/* USER CODE END ET */

/* Exported constants --------------------------------------------------------*/
Expand Down

0 comments on commit 0368da7

Please sign in to comment.