1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

cpu/lpc23xx: implement rtc_get_time_ms()

This commit is contained in:
Benjamin Valentin 2021-05-03 00:34:10 +02:00
parent 84bb42ce1f
commit 0991c28849
3 changed files with 19 additions and 0 deletions

View File

@ -14,6 +14,7 @@ config CPU_FAM_LPC23XX
select HAS_PERIPH_GPIO
select HAS_PERIPH_GPIO_IRQ
select HAS_PERIPH_TIMER_PERIODIC
select HAS_PERIPH_RTC_MS
## CPU Models
config CPU_MODEL_LPC2387

View File

@ -3,5 +3,6 @@ FEATURES_PROVIDED += backup_ram
FEATURES_PROVIDED += periph_dac
FEATURES_PROVIDED += periph_gpio periph_gpio_irq
FEATURES_PROVIDED += periph_timer_periodic
FEATURES_PROVIDED += periph_rtc_ms
include $(RIOTCPU)/arm7_common/Makefile.features

View File

@ -28,6 +28,7 @@
#include "periph/rtc.h"
#include "VIC.h"
#include "lpc23xx.h"
#include "timex.h"
#define ENABLE_DEBUG 0
#include "debug.h"
@ -110,6 +111,22 @@ int rtc_get_time(struct tm *localt)
return 0;
}
int rtc_get_time_ms(struct tm *time, uint16_t *ms)
{
uint16_t ccr_before, ccr_after;
/* loop in case of overflow */
do {
ccr_before = RTC_CCR >> 1;
rtc_get_time(time);
ccr_after = RTC_CCR >> 1;
} while (ccr_before > ccr_after);
/* CCR is 15-bit counter, increments second with each overflow */
*ms = (ccr_after * MS_PER_SEC) >> 15;
return 0;
}
int rtc_set_alarm(struct tm *localt, rtc_alarm_cb_t cb, void *arg)
{