From dcd49c38828a0ce3457158905e92e359d0da329f Mon Sep 17 00:00:00 2001 From: Matias N Date: Sat, 5 Sep 2020 23:27:29 -0300 Subject: [PATCH] nrf52_rtc: add missing getcounter() --- arch/arm/src/nrf52/nrf52_rtc.c | 14 ++++++++++++++ arch/arm/src/nrf52/nrf52_rtc.h | 2 ++ 2 files changed, 16 insertions(+) diff --git a/arch/arm/src/nrf52/nrf52_rtc.c b/arch/arm/src/nrf52/nrf52_rtc.c index 1053ee9c36..feaa67b76e 100644 --- a/arch/arm/src/nrf52/nrf52_rtc.c +++ b/arch/arm/src/nrf52/nrf52_rtc.c @@ -77,6 +77,8 @@ static int nrf52_rtc_start(FAR struct nrf52_rtc_dev_s *dev); static int nrf52_rtc_stop(FAR struct nrf52_rtc_dev_s *dev); static int nrf52_rtc_clear(FAR struct nrf52_rtc_dev_s *dev); static int nrf52_rtc_trgovrflw(FAR struct nrf52_rtc_dev_s *dev); +static int nrf52_rtc_getcounter(FAR struct nrf52_rtc_dev_s *dev, + FAR uint32_t *cc); static int nrf52_rtc_setcc(FAR struct nrf52_rtc_dev_s *dev, uint8_t i, uint32_t cc); static int nrf52_rtc_getcc(FAR struct nrf52_rtc_dev_s *dev, uint8_t i, @@ -104,6 +106,7 @@ struct nrf52_rtc_ops_s nrf52_rtc_ops = .stop = nrf52_rtc_stop, .clear = nrf52_rtc_clear, .trgovrflw = nrf52_rtc_trgovrflw, + .getcounter = nrf52_rtc_getcounter, .setcc = nrf52_rtc_setcc, .getcc = nrf52_rtc_getcc, .setpre = nrf52_rtc_setpre, @@ -371,6 +374,17 @@ static int nrf52_rtc_trgovrflw(FAR struct nrf52_rtc_dev_s *dev) return OK; } +static int nrf52_rtc_getcounter(FAR struct nrf52_rtc_dev_s *dev, + FAR uint32_t *ctr) +{ + DEBUGASSERT(dev); + DEBUGASSERT(ctr); + + *ctr = nrf52_rtc_getreg(dev, NRF52_RTC_COUNTER_OFFSET); + + return OK; +} + /**************************************************************************** * Name: nrf52_rtc_setcc ****************************************************************************/ diff --git a/arch/arm/src/nrf52/nrf52_rtc.h b/arch/arm/src/nrf52/nrf52_rtc.h index 17efd282d3..f904e5efb9 100644 --- a/arch/arm/src/nrf52/nrf52_rtc.h +++ b/arch/arm/src/nrf52/nrf52_rtc.h @@ -39,6 +39,7 @@ #define NRF52_RTC_STOP(d) ((d)->ops->stop(d)) #define NRF52_RTC_CLEAR(d) ((d)->ops->clear(d)) #define NRF52_RTC_TRGOVRFLW(d) ((d)->ops->trgovrflw(d)) +#define NRF52_RTC_GETCOUNTER(d, c) ((d)->ops->getcounter(d, c)) #define NRF52_RTC_SETCC(d, i, cc) ((d)->ops->setcc(d, i, cc)) #define NRF52_RTC_GETCC(d, i, cc) ((d)->ops->setcc(d, i, cc)) #define NRF52_RTC_SETPRE(d, pre) ((d)->ops->setpre(d, pre)) @@ -96,6 +97,7 @@ struct nrf52_rtc_ops_s /* RTC operations */ + CODE int (*getcounter)(FAR struct nrf52_rtc_dev_s *dev, FAR uint32_t *cc); CODE int (*setcc)(FAR struct nrf52_rtc_dev_s *dev, uint8_t i, uint32_t cc); CODE int (*getcc)(FAR struct nrf52_rtc_dev_s *dev, uint8_t i, FAR uint32_t *cc);