Fix style and warnings using timer0
This commit is contained in:
parent
228cc36f38
commit
0bafaa0473
|
@ -65,7 +65,7 @@ OSAL_IRQ_HANDLER(Vector6C) {
|
||||||
OSAL_IRQ_PROLOGUE();
|
OSAL_IRQ_PROLOGUE();
|
||||||
|
|
||||||
NRF_RTC0->EVENTS_TICK = 0;
|
NRF_RTC0->EVENTS_TICK = 0;
|
||||||
|
|
||||||
osalSysLockFromISR();
|
osalSysLockFromISR();
|
||||||
osalOsTimerHandlerI();
|
osalOsTimerHandlerI();
|
||||||
osalSysUnlockFromISR();
|
osalSysUnlockFromISR();
|
||||||
|
@ -87,7 +87,7 @@ OSAL_IRQ_HANDLER(Vector84) {
|
||||||
OSAL_IRQ_PROLOGUE();
|
OSAL_IRQ_PROLOGUE();
|
||||||
|
|
||||||
NRF_RTC1->EVENTS_TICK = 0;
|
NRF_RTC1->EVENTS_TICK = 0;
|
||||||
|
|
||||||
osalSysLockFromISR();
|
osalSysLockFromISR();
|
||||||
osalOsTimerHandlerI();
|
osalOsTimerHandlerI();
|
||||||
osalSysUnlockFromISR();
|
osalSysUnlockFromISR();
|
||||||
|
@ -135,20 +135,20 @@ OSAL_IRQ_HANDLER(Vector6C) {
|
||||||
OSAL_IRQ_PROLOGUE();
|
OSAL_IRQ_PROLOGUE();
|
||||||
|
|
||||||
if (NRF_RTC0->EVENTS_COMPARE[0]) {
|
if (NRF_RTC0->EVENTS_COMPARE[0]) {
|
||||||
NRF_RTC0->EVENTS_COMPARE[0] = 0;
|
NRF_RTC0->EVENTS_COMPARE[0] = 0;
|
||||||
|
|
||||||
osalSysLockFromISR();
|
osalSysLockFromISR();
|
||||||
osalOsTimerHandlerI();
|
osalOsTimerHandlerI();
|
||||||
osalSysUnlockFromISR();
|
osalSysUnlockFromISR();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if OSAL_ST_RESOLUTION == 16
|
#if OSAL_ST_RESOLUTION == 16
|
||||||
if (NRF_RTC0->EVENTS_COMPARE[1]) {
|
if (NRF_RTC0->EVENTS_COMPARE[1]) {
|
||||||
NRF_RTC0->EVENTS_COMPARE[1] = 0;
|
NRF_RTC0->EVENTS_COMPARE[1] = 0;
|
||||||
NRF_RTC0->TASKS_CLEAR = 1;
|
NRF_RTC0->TASKS_CLEAR = 1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
OSAL_IRQ_EPILOGUE();
|
OSAL_IRQ_EPILOGUE();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -166,20 +166,20 @@ OSAL_IRQ_HANDLER(Vector84) {
|
||||||
OSAL_IRQ_PROLOGUE();
|
OSAL_IRQ_PROLOGUE();
|
||||||
|
|
||||||
if (NRF_RTC1->EVENTS_COMPARE[0]) {
|
if (NRF_RTC1->EVENTS_COMPARE[0]) {
|
||||||
NRF_RTC1->EVENTS_COMPARE[0] = 0;
|
NRF_RTC1->EVENTS_COMPARE[0] = 0;
|
||||||
|
|
||||||
osalSysLockFromISR();
|
osalSysLockFromISR();
|
||||||
osalOsTimerHandlerI();
|
osalOsTimerHandlerI();
|
||||||
osalSysUnlockFromISR();
|
osalSysUnlockFromISR();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if OSAL_ST_RESOLUTION == 16
|
#if OSAL_ST_RESOLUTION == 16
|
||||||
if (NRF_RTC1->EVENTS_COMPARE[1]) {
|
if (NRF_RTC1->EVENTS_COMPARE[1]) {
|
||||||
NRF_RTC1->EVENTS_COMPARE[1] = 0;
|
NRF_RTC1->EVENTS_COMPARE[1] = 0;
|
||||||
NRF_RTC1->TASKS_CLEAR = 1;
|
NRF_RTC1->TASKS_CLEAR = 1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
OSAL_IRQ_EPILOGUE();
|
OSAL_IRQ_EPILOGUE();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -211,7 +211,7 @@ void st_lld_init(void) {
|
||||||
NRF_RTC0->INTENSET = RTC_INTENSET_COMPARE1_Msk;
|
NRF_RTC0->INTENSET = RTC_INTENSET_COMPARE1_Msk;
|
||||||
#endif
|
#endif
|
||||||
NRF_RTC0->TASKS_CLEAR = 1;
|
NRF_RTC0->TASKS_CLEAR = 1;
|
||||||
|
|
||||||
/* Start timer */
|
/* Start timer */
|
||||||
nvicEnableVector(RTC0_IRQn, NRF51_ST_PRIORITY);
|
nvicEnableVector(RTC0_IRQn, NRF51_ST_PRIORITY);
|
||||||
NRF_RTC0->TASKS_START = 1;
|
NRF_RTC0->TASKS_START = 1;
|
||||||
|
@ -231,8 +231,8 @@ void st_lld_init(void) {
|
||||||
NRF_RTC1->INTENSET = RTC_INTENSET_COMPARE1_Msk;
|
NRF_RTC1->INTENSET = RTC_INTENSET_COMPARE1_Msk;
|
||||||
#endif
|
#endif
|
||||||
NRF_RTC1->TASKS_CLEAR = 1;
|
NRF_RTC1->TASKS_CLEAR = 1;
|
||||||
|
|
||||||
/* Start timer */
|
/* Start timer */
|
||||||
nvicEnableVector(RTC1_IRQn, NRF51_ST_PRIORITY);
|
nvicEnableVector(RTC1_IRQn, NRF51_ST_PRIORITY);
|
||||||
NRF_RTC1->TASKS_START = 1;
|
NRF_RTC1->TASKS_START = 1;
|
||||||
#endif /* NRF51_ST_USE_RTC1 == TRUE */
|
#endif /* NRF51_ST_USE_RTC1 == TRUE */
|
||||||
|
@ -285,7 +285,7 @@ void st_lld_init(void) {
|
||||||
nvicEnableVector(TIMER0_IRQn, NRF51_ST_PRIORITY);
|
nvicEnableVector(TIMER0_IRQn, NRF51_ST_PRIORITY);
|
||||||
NRF_TIMER0->TASKS_START = 1;
|
NRF_TIMER0->TASKS_START = 1;
|
||||||
#endif /* NRF51_ST_USE_TIMER0 == TRUE */
|
#endif /* NRF51_ST_USE_TIMER0 == TRUE */
|
||||||
|
|
||||||
#endif /* OSAL_ST_MODE == OSAL_ST_MODE_PERIODIC */
|
#endif /* OSAL_ST_MODE == OSAL_ST_MODE_PERIODIC */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,9 +42,9 @@
|
||||||
*/
|
*/
|
||||||
#if !defined(NRF51_ST_USE_RTC0) || defined(__DOXYGEN__)
|
#if !defined(NRF51_ST_USE_RTC0) || defined(__DOXYGEN__)
|
||||||
#if !defined(SOFTDEVICE_PRESENT)
|
#if !defined(SOFTDEVICE_PRESENT)
|
||||||
#define NRF51_ST_USE_RTC0 TRUE
|
#define NRF51_ST_USE_RTC0 TRUE
|
||||||
#else
|
#else
|
||||||
#define NRF51_ST_USE_RTC0 FALSE
|
#define NRF51_ST_USE_RTC0 FALSE
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -53,9 +53,9 @@
|
||||||
*/
|
*/
|
||||||
#if !defined(NRF51_ST_USE_RTC1) || defined(__DOXYGEN__)
|
#if !defined(NRF51_ST_USE_RTC1) || defined(__DOXYGEN__)
|
||||||
#if !defined(SOFTDEVICE_PRESENT)
|
#if !defined(SOFTDEVICE_PRESENT)
|
||||||
#define NRF51_ST_USE_RTC1 FALSE
|
#define NRF51_ST_USE_RTC1 FALSE
|
||||||
#else
|
#else
|
||||||
#define NRF51_ST_USE_RTC1 TRUE
|
#define NRF51_ST_USE_RTC1 TRUE
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@
|
||||||
* @brief Use TIMER0 to generates system ticks
|
* @brief Use TIMER0 to generates system ticks
|
||||||
*/
|
*/
|
||||||
#if !defined(NRF51_ST_USE_TIMER0) || defined(__DOXYGEN__)
|
#if !defined(NRF51_ST_USE_TIMER0) || defined(__DOXYGEN__)
|
||||||
#define NRF51_ST_USE_TIMER0 FALSE
|
#define NRF51_ST_USE_TIMER0 FALSE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -92,8 +92,8 @@
|
||||||
#error "One clock source is needed, enable one (RTC0, RTC1, or TIMER0)"
|
#error "One clock source is needed, enable one (RTC0, RTC1, or TIMER0)"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if ((NRF51_ST_USE_RTC0 == TRUE ? 1 : 0) + \
|
#if ((NRF51_ST_USE_RTC0 == TRUE ? 1 : 0) + \
|
||||||
(NRF51_ST_USE_RTC1 == TRUE ? 1 : 0) + \
|
(NRF51_ST_USE_RTC1 == TRUE ? 1 : 0) + \
|
||||||
(NRF51_ST_USE_TIMER0 == TRUE ? 1 : 0)) > 1
|
(NRF51_ST_USE_TIMER0 == TRUE ? 1 : 0)) > 1
|
||||||
#error "Only one clock source can be used (RTC0, RTC1, or TIMER0)"
|
#error "Only one clock source can be used (RTC0, RTC1, or TIMER0)"
|
||||||
#endif
|
#endif
|
||||||
|
@ -156,10 +156,13 @@ extern "C" {
|
||||||
*/
|
*/
|
||||||
static inline systime_t st_lld_get_counter(void) {
|
static inline systime_t st_lld_get_counter(void) {
|
||||||
#if NRF51_ST_USE_RTC0 == TRUE
|
#if NRF51_ST_USE_RTC0 == TRUE
|
||||||
return (systime_t)NRF_RTC0->COUNTER;
|
return (systime_t)NRF_RTC0->COUNTER;
|
||||||
#endif
|
#endif
|
||||||
#if NRF51_ST_USE_RTC1 == TRUE
|
#if NRF51_ST_USE_RTC1 == TRUE
|
||||||
return (systime_t)NRF_RTC1->COUNTER;
|
return (systime_t)NRF_RTC1->COUNTER;
|
||||||
|
#endif
|
||||||
|
#if NRF51_ST_USE_TIMER0 == TRUE
|
||||||
|
return (systime_t)0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,6 +186,9 @@ static inline void st_lld_start_alarm(systime_t abstime) {
|
||||||
NRF_RTC1->EVENTS_COMPARE[0] = 0;
|
NRF_RTC1->EVENTS_COMPARE[0] = 0;
|
||||||
NRF_RTC1->EVTENSET = RTC_EVTENSET_COMPARE0_Msk;
|
NRF_RTC1->EVTENSET = RTC_EVTENSET_COMPARE0_Msk;
|
||||||
#endif
|
#endif
|
||||||
|
#if NRF51_ST_USE_TIMER0 == TRUE
|
||||||
|
(void)abstime;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -215,6 +221,9 @@ static inline void st_lld_set_alarm(systime_t abstime) {
|
||||||
#if NRF51_ST_USE_RTC1 == TRUE
|
#if NRF51_ST_USE_RTC1 == TRUE
|
||||||
NRF_RTC1->CC[0] = abstime;
|
NRF_RTC1->CC[0] = abstime;
|
||||||
#endif
|
#endif
|
||||||
|
#if NRF51_ST_USE_TIMER0 == TRUE
|
||||||
|
(void)abstime;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -231,6 +240,9 @@ static inline systime_t st_lld_get_alarm(void) {
|
||||||
#if NRF51_ST_USE_RTC1 == TRUE
|
#if NRF51_ST_USE_RTC1 == TRUE
|
||||||
return (systime_t)NRF_RTC1->CC[0];
|
return (systime_t)NRF_RTC1->CC[0];
|
||||||
#endif
|
#endif
|
||||||
|
#if NRF51_ST_USE_TIMER0 == TRUE
|
||||||
|
return (systime_t)0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -249,6 +261,9 @@ static inline bool st_lld_is_alarm_active(void) {
|
||||||
#if NRF51_ST_USE_RTC1 == TRUE
|
#if NRF51_ST_USE_RTC1 == TRUE
|
||||||
return NRF_RTC1->EVTEN & RTC_EVTEN_COMPARE0_Msk;
|
return NRF_RTC1->EVTEN & RTC_EVTEN_COMPARE0_Msk;
|
||||||
#endif
|
#endif
|
||||||
|
#if NRF51_ST_USE_TIMER0 == TRUE
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* _ST_LLD_H_ */
|
#endif /* _ST_LLD_H_ */
|
||||||
|
|
Loading…
Reference in New Issue