summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlenn Ruben Bakke <glennbakke@gmail.com>2017-03-06 01:13:19 +0100
committerGlenn Ruben Bakke <glennbakke@gmail.com>2017-03-06 01:13:19 +0100
commit7000e0a2a0dc3ac2ee874a15654d1debd556355d (patch)
tree1dacf97daf2f124e27b93f94f7e4adfc2226aede
parent49b1607bedb7fa473b2cd2ead93e62f8c0f74988 (diff)
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.
-rw-r--r--nrf5/modules/machine/rtc.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/nrf5/modules/machine/rtc.c b/nrf5/modules/machine/rtc.c
index 172cd2ac9..7ccf599b8 100644
--- a/nrf5/modules/machine/rtc.c
+++ b/nrf5/modules/machine/rtc.c
@@ -73,9 +73,19 @@ void rtc_init0(void) {
memset(&RTCHandle0, 0, sizeof(RTC_HandleTypeDef));
RTCHandle0.config.p_instance = RTC0;
RTCHandle0.config.irq_num = RTC0_IRQ_NUM;
+#if (BLUETOOTH_SD == 100)
+ RTCHandle0.config.irq_priority = 3;
+#else
+ RTCHandle0.config.irq_priority = 6;
+#endif
memset(&RTCHandle1, 0, sizeof(RTC_HandleTypeDef));
RTCHandle1.config.p_instance = RTC1;
RTCHandle1.config.irq_num = RTC1_IRQ_NUM;
+#if (BLUETOOTH_SD == 100)
+ RTCHandle1.config.irq_priority = 3;
+#else
+ RTCHandle1.config.irq_priority = 6;
+#endif
}
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)
/******************************************************************************/
/* MicroPython bindings for machine API */
+/*
+from machine import RTC
+def cb():
+ print("Callback")
+r = RTC(0, 8, cb)
+r.start(16)
+*/
+
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) {
static const mp_arg_t allowed_args[] = {
{ 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
self->callback = args[2].u_obj;
}
- // hardcode priority to 3, to make sure it is less than any bluetooth stack.
-
-#if (BLUETOOTH_SD == 100)
- self->rtc->config.irq_priority = 3;
-#else
- self->rtc->config.irq_priority = 6;
-#endif
-
hal_rtc_init(&self->rtc->config);
return MP_OBJ_FROM_PTR(self);