Merge pull request #14025 from fjmolinas/pr_nrf5x_rtt_conf

boards/common/nrf5x: add configurable RTT_FREQUENCY
This commit is contained in:
Alexandre Abadie 2020-05-05 17:46:05 +02:00 committed by GitHub
commit 5773db93f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 9 deletions

View File

@ -29,11 +29,21 @@ extern "C" {
* @name Real time counter configuration * @name Real time counter configuration
* @{ * @{
*/ */
#ifndef RTT_DEV
#define RTT_DEV (1) /* NRF_RTC1 */ #define RTT_DEV (1) /* NRF_RTC1 */
#define RTT_MAX_VALUE (0x00ffffff) #endif
#define RTT_FREQUENCY (1024)
#define RTT_MAX_VALUE (0x00ffffff) /* 24bit */
#define RTT_MAX_FREQUENCY (32768U) /* in Hz */
#define RTT_MIN_FREQUENCY (8U) /* in Hz */
#define RTT_CLOCK_FREQUENCY (32768U) /* in Hz, LFCLK*/
#ifndef RTT_FREQUENCY
#define RTT_FREQUENCY (1024U) /* in Hz */
#endif
/** @} */ /** @} */
#ifdef __cplusplus #ifdef __cplusplus
} /* end extern "C" */ } /* end extern "C" */
#endif #endif

View File

@ -28,9 +28,18 @@ extern "C" {
* @name Real time counter configuration * @name Real time counter configuration
* @{ * @{
*/ */
#ifndef RTT_DEV
#define RTT_DEV (1) /* NRF_RTC1 */ #define RTT_DEV (1) /* NRF_RTC1 */
#define RTT_MAX_VALUE (0x00ffffff) #endif
#define RTT_FREQUENCY (1024)
#define RTT_MAX_VALUE (0x00ffffff) /* 24bit */
#define RTT_MAX_FREQUENCY (32768U) /* in Hz */
#define RTT_MIN_FREQUENCY (8U) /* in Hz */
#define RTT_CLOCK_FREQUENCY (32768U) /* in Hz, LFCLK*/
#ifndef RTT_FREQUENCY
#define RTT_FREQUENCY (1024U) /* in Hz */
#endif
/** @} */ /** @} */
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -38,8 +38,6 @@
#error "RTT configuration: invalid or no RTC device specified (RTT_DEV)" #error "RTT configuration: invalid or no RTC device specified (RTT_DEV)"
#endif #endif
#define LFCLK_FREQ (32768U)
/* allocate memory for callbacks and their args */ /* allocate memory for callbacks and their args */
static rtt_cb_t alarm_cb; static rtt_cb_t alarm_cb;
static void *alarm_arg; static void *alarm_arg;
@ -59,7 +57,7 @@ void rtt_init(void)
/* configure interrupt */ /* configure interrupt */
NVIC_EnableIRQ(IRQn); NVIC_EnableIRQ(IRQn);
/* set prescaler */ /* set prescaler */
DEV->PRESCALER = (LFCLK_FREQ / RTT_FREQUENCY) - 1; DEV->PRESCALER = (RTT_CLOCK_FREQUENCY / RTT_FREQUENCY) - 1;
/* start the actual RTT thing */ /* start the actual RTT thing */
DEV->TASKS_START = 1; DEV->TASKS_START = 1;
} }