8000 nrf5/modules: Moving irq priority settings in RTC object to rtc_init0… · boneskull/circuitpython@7000e0a · GitHub
[go: up one dir, main page]

Skip to content

Commit 7000e0a

Browse files
committed
nrf5/modules: Moving irq priority settings in RTC object to rtc_init0 when initializing the hardware instances. Also modifying comments a bit. Adding simple example in comment above make_new function on how the object is intended to work.
1 parent 49b1607 commit 7000e0a

File tree

1 file changed

+18
-8
lines changed
  • nrf5/modules/machine

1 file changed

+18
-8
lines changed

nrf5/modules/machine/rtc.c

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,19 @@ void rtc_init0(void) {
7373
memset(&RTCHandle0, 0, sizeof(RTC_HandleTypeDef));
7474
RTCHandle0.config.p_instance = RTC0;
7575
RTCHandle0.config.irq_num = RTC0_IRQ_NUM;
76+
#if (BLUETOOTH_SD == 100)
77+
RTCHandle0.config.irq_priority = 3;
78+
#else
79+
RTCHandle0.config.irq_priority = 6;
80+
#endif
7681
memset(&RTCHandle1, 0, sizeof(RTC_HandleTypeDef));
7782
RTCHandle1.config.p_instance = RTC1;
7883
RTCHandle1.config.irq_num = RTC1_IRQ_NUM;
84+
#if (BLUETOOTH_SD == 100)
85+
RTCHandle1.config.irq_priority = 3;
86+
#else
87+
RTCHandle1.config.irq_priority = 6;
88+
#endif
7989
}
8090

8191
STATIC int rtc_find(mp_obj_t id) {
@@ -97,6 +107,14 @@ STATIC void rtc_print(const mp_print_t *print, mp_obj_t o, mp_print_kind_t kind)
97107
/******************************************************************************/
98108
/* MicroPython bindings for machine API */
99109

110+
/*
111+
from machine import RTC
112+
def cb():
113+
print("Callback")
114+
r = RTC(0, 8, cb)
115+
r.start(16)
116+
*/
117+
100118
STATIC mp_obj_t machine_rtc_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) {
101119
static const mp_arg_t allowed_args[] = {
102120
{ MP_QSTR_id, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = mp_const_none} },
@@ -132,14 +150,6 @@ STATIC mp_obj_t machine_rtc_make_new(const mp_obj_type_t *type, size_t n_args, s
132150
self->callback = args[2].u_obj;
133151
}
134152

135-
// hardcode priority to 3, to make sure it is less than any bluetooth stack.
136-
137-
#if (BLUETOOTH_SD == 100)
138-
self->rtc->config.irq_priority = 3;
139-
#else
140-
self->rtc->config.irq_priority = 6;
141-
#endif
142-
143153
hal_rtc_init(&self->rtc->config);
144154

145155
return MP_OBJ_FROM_PTR(self);

0 commit comments

Comments
 (0)
0