Skip to content

Commit

Permalink
Merge pull request #2154 from particle-iot/fix/gen2-rtc-thread-safety
Browse files Browse the repository at this point in the history
[gen2] rtc: hal_rtc_get_time() is not thread-safe
  • Loading branch information
avtolstoy committed Jul 20, 2020
2 parents e9e4758 + 1cf34bd commit ee82be9
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions hal/src/stm32f2xx/rtc_hal.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,11 @@ int hal_rtc_get_time(struct timeval* tv, void* reserved) {
RTC_TimeTypeDef RTC_TimeStructure;
RTC_DateTypeDef RTC_DateStructure;

int32_t state = HAL_disable_irq();
/* Get the current Time and Date */
RTC_GetTime(RTC_Format_BIN, &RTC_TimeStructure);
RTC_GetDate(RTC_Format_BIN, &RTC_DateStructure);
HAL_enable_irq(state);

struct tm calendar_time = {0};

Expand Down

0 comments on commit ee82be9

Please sign in to comment.