Skip to content

Commit

Permalink
STM32L1 - Rename RTC_LSI
Browse files Browse the repository at this point in the history
  • Loading branch information
svastm committed Sep 29, 2016
1 parent da44e99 commit f361a43
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions hal/targets.json
Original file line number Diff line number Diff line change
Expand Up @@ -1192,7 +1192,7 @@
"core": "Cortex-M3",
"default_toolchain": "uARM",
"extra_labels": ["STM", "STM32L1", "STM32L152RC"],
"macros": ["DEVICE_RTC_LSI=1"],
"macros": ["RTC_LSI=1"],
"supported_toolchains": ["ARM", "uARM", "IAR", "GCC_ARM"],
"progen": {"target": "stm32l151rc"},
"detect_code": ["4100"],
Expand Down Expand Up @@ -1227,7 +1227,7 @@
"default_toolchain": "uARM",
"program_cycle_s": 1.5,
"extra_labels": ["STM", "STM32L1", "STM32L151RC"],
"macros": ["DEVICE_RTC_LSI=1"],
"macros": ["RTC_LSI=1"],
"supported_toolchains": ["ARM", "uARM", "GCC_ARM"],
"progen": {"target": "stm32l151rc"},
"device_has": ["ANALOGIN", "ANALOGOUT", "I2C", "I2CSLAVE", "INTERRUPTIN", "PORTIN", "PORTINOUT", "PORTOUT", "PWMOUT", "RTC", "SERIAL", "SLEEP", "SPI", "SPISLAVE", "STDIO_MESSAGES"],
Expand Down
16 changes: 8 additions & 8 deletions hal/targets/hal/TARGET_STM/TARGET_STM32L1/rtc_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@

#include "mbed_error.h"

#if DEVICE_RTC_LSI
#if RTC_LSI
static int rtc_inited = 0;
#endif

static RTC_HandleTypeDef RtcHandle;

#if DEVICE_RTC_LSI
#if RTC_LSI
#define RTC_CLOCK LSI_VALUE
#else
#define RTC_CLOCK LSE_VALUE
Expand All @@ -63,14 +63,14 @@ void rtc_init(void)
{
RCC_OscInitTypeDef RCC_OscInitStruct;

#if DEVICE_RTC_LSI
#if RTC_LSI
if (rtc_inited) return;
rtc_inited = 1;
#endif

RtcHandle.Instance = RTC;

#if !DEVICE_RTC_LSI
#if !RTC_LSI
// Enable LSE Oscillator
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI | RCC_OSCILLATORTYPE_LSE;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE; // Mandatory, otherwise the PLL is reconfigured!
Expand Down Expand Up @@ -128,7 +128,7 @@ void rtc_init(void)
}

#if DEVICE_LOWPOWERTIMER
#if DEVICE_RTC_LSI
#if RTC_LSI
rtc_write(0);
#else
if (!rtc_isenabled()) {
Expand All @@ -144,7 +144,7 @@ void rtc_init(void)

void rtc_free(void)
{
#if DEVICE_RTC_LSI
#if RTC_LSI
// Enable Power clock
__PWR_CLK_ENABLE();

Expand All @@ -167,14 +167,14 @@ void rtc_free(void)
RCC_OscInitStruct.LSEState = RCC_LSE_OFF;
HAL_RCC_OscConfig(&RCC_OscInitStruct);

#if DEVICE_RTC_LSI
#if RTC_LSI
rtc_inited = 0;
#endif
}

int rtc_isenabled(void)
{
#if DEVICE_RTC_LSI
#if RTC_LSI
return rtc_inited;
#else
if ((RTC->ISR & RTC_ISR_INITS) == RTC_ISR_INITS) {
Expand Down

0 comments on commit f361a43

Please sign in to comment.