mirror of https://github.com/ARMmbed/mbed-os.git
Run astyle
parent
8627204d36
commit
4e83b88257
|
@ -55,8 +55,8 @@ uint32_t lp_ticker_read(void)
|
||||||
lp_ticker_init();
|
lp_ticker_init();
|
||||||
|
|
||||||
do {
|
do {
|
||||||
time = rtc_read();
|
time = rtc_read();
|
||||||
usecs = rtc_read_subseconds();
|
usecs = rtc_read_subseconds();
|
||||||
} while (time != rtc_read());
|
} while (time != rtc_read());
|
||||||
|
|
||||||
return (time * 1000000) + usecs;
|
return (time * 1000000) + usecs;
|
||||||
|
|
|
@ -36,22 +36,22 @@
|
||||||
static RTC_HandleTypeDef RtcHandle;
|
static RTC_HandleTypeDef RtcHandle;
|
||||||
|
|
||||||
#if RTC_LSI
|
#if RTC_LSI
|
||||||
#define RTC_CLOCK LSI_VALUE
|
#define RTC_CLOCK LSI_VALUE
|
||||||
#else
|
#else
|
||||||
#define RTC_CLOCK LSE_VALUE
|
#define RTC_CLOCK LSE_VALUE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if DEVICE_LOWPOWERTIMER
|
#if DEVICE_LOWPOWERTIMER
|
||||||
#define RTC_ASYNCH_PREDIV ((RTC_CLOCK - 1) / 0x8000)
|
#define RTC_ASYNCH_PREDIV ((RTC_CLOCK - 1) / 0x8000)
|
||||||
#define RTC_SYNCH_PREDIV (RTC_CLOCK / (RTC_ASYNCH_PREDIV + 1) - 1)
|
#define RTC_SYNCH_PREDIV (RTC_CLOCK / (RTC_ASYNCH_PREDIV + 1) - 1)
|
||||||
#else
|
#else
|
||||||
#define RTC_ASYNCH_PREDIV (0x007F)
|
#define RTC_ASYNCH_PREDIV (0x007F)
|
||||||
#define RTC_SYNCH_PREDIV (RTC_CLOCK / (RTC_ASYNCH_PREDIV + 1) - 1)
|
#define RTC_SYNCH_PREDIV (RTC_CLOCK / (RTC_ASYNCH_PREDIV + 1) - 1)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if DEVICE_LOWPOWERTIMER
|
#if DEVICE_LOWPOWERTIMER
|
||||||
static void (*irq_handler)(void);
|
static void (*irq_handler)(void);
|
||||||
static void RTC_IRQHandler(void);
|
static void RTC_IRQHandler(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void rtc_init(void)
|
void rtc_init(void)
|
||||||
|
@ -70,20 +70,16 @@ void rtc_init(void)
|
||||||
RCC_OscInitStruct.LSEState = RCC_LSE_ON;
|
RCC_OscInitStruct.LSEState = RCC_LSE_ON;
|
||||||
RCC_OscInitStruct.LSIState = RCC_LSI_OFF;
|
RCC_OscInitStruct.LSIState = RCC_LSI_OFF;
|
||||||
|
|
||||||
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) == HAL_OK)
|
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) == HAL_OK) {
|
||||||
{
|
|
||||||
__HAL_RCC_RTC_CLKPRESCALER(RCC_RTCCLKSOURCE_LSE);
|
__HAL_RCC_RTC_CLKPRESCALER(RCC_RTCCLKSOURCE_LSE);
|
||||||
__HAL_RCC_RTC_CONFIG(RCC_RTCCLKSOURCE_LSE);
|
__HAL_RCC_RTC_CONFIG(RCC_RTCCLKSOURCE_LSE);
|
||||||
}
|
} else {
|
||||||
else
|
error("Cannot initialize RTC with LSE\n");
|
||||||
{
|
|
||||||
error("Cannot initialize RTC with LSE\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_RTC;
|
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_RTC;
|
||||||
PeriphClkInitStruct.RTCClockSelection = RCC_RTCCLKSOURCE_LSE;
|
PeriphClkInitStruct.RTCClockSelection = RCC_RTCCLKSOURCE_LSE;
|
||||||
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK)
|
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) {
|
||||||
{
|
|
||||||
error("PeriphClkInitStruct RTC failed with LSE\n");
|
error("PeriphClkInitStruct RTC failed with LSE\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,8 +96,7 @@ void rtc_init(void)
|
||||||
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE; // Mandatory, otherwise the PLL is reconfigured!
|
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE; // Mandatory, otherwise the PLL is reconfigured!
|
||||||
RCC_OscInitStruct.LSEState = RCC_LSE_OFF;
|
RCC_OscInitStruct.LSEState = RCC_LSE_OFF;
|
||||||
RCC_OscInitStruct.LSIState = RCC_LSI_ON;
|
RCC_OscInitStruct.LSIState = RCC_LSI_ON;
|
||||||
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
|
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) {
|
||||||
{
|
|
||||||
error("Cannot initialize RTC with LSI\n");
|
error("Cannot initialize RTC with LSI\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,8 +105,7 @@ void rtc_init(void)
|
||||||
|
|
||||||
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_RTC;
|
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_RTC;
|
||||||
PeriphClkInitStruct.RTCClockSelection = RCC_RTCCLKSOURCE_LSI;
|
PeriphClkInitStruct.RTCClockSelection = RCC_RTCCLKSOURCE_LSI;
|
||||||
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK)
|
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) {
|
||||||
{
|
|
||||||
error("PeriphClkInitStruct RTC failed with LSI\n");
|
error("PeriphClkInitStruct RTC failed with LSI\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -258,16 +252,13 @@ void rtc_write(time_t t)
|
||||||
int rtc_isenabled(void)
|
int rtc_isenabled(void)
|
||||||
{
|
{
|
||||||
#if DEVICE_LOWPOWERTIMER
|
#if DEVICE_LOWPOWERTIMER
|
||||||
if ((RTC->ISR & RTC_ISR_INITS) == RTC_ISR_INITS)
|
if ((RTC->ISR & RTC_ISR_INITS) == RTC_ISR_INITS) {
|
||||||
{
|
return 1;
|
||||||
return 1;
|
} else {
|
||||||
}
|
return 0;
|
||||||
else
|
}
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#else /* DEVICE_LOWPOWERTIMER */
|
#else /* DEVICE_LOWPOWERTIMER */
|
||||||
return 1;
|
return 1;
|
||||||
#endif /* DEVICE_LOWPOWERTIMER */
|
#endif /* DEVICE_LOWPOWERTIMER */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue