summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDamien George <damien@micropython.org>2020-09-04 12:40:38 +1000
committerDamien George <damien@micropython.org>2020-09-04 12:40:38 +1000
commit3ff70792770e4591fec22fa6a1b50f492236fcde (patch)
tree27dfcb5661aed7797d0562749c9eadb2d7fe3011 /lib
parent5e69926ea06cc035e831fcb657e756764682e0b5 (diff)
lib/utils/mpirq: Add mp_irq_init func, and clean up unused init method.
mp_irq_init() is useful when the IRQ object is allocated by the caller. The mp_irq_methods_t.init method is not used anywhere so has been removed. Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/utils/mpirq.c6
-rw-r--r--lib/utils/mpirq.h14
2 files changed, 12 insertions, 8 deletions
diff --git a/lib/utils/mpirq.c b/lib/utils/mpirq.c
index 663be1822..02139f24d 100644
--- a/lib/utils/mpirq.c
+++ b/lib/utils/mpirq.c
@@ -53,12 +53,16 @@ const mp_arg_t mp_irq_init_args[] = {
mp_irq_obj_t *mp_irq_new(const mp_irq_methods_t *methods, mp_obj_t parent) {
mp_irq_obj_t *self = m_new0(mp_irq_obj_t, 1);
+ mp_irq_init(self, methods, parent);
+ return self;
+}
+
+void mp_irq_init(mp_irq_obj_t *self, const mp_irq_methods_t *methods, mp_obj_t parent) {
self->base.type = &mp_irq_type;
self->methods = (mp_irq_methods_t *)methods;
self->parent = parent;
self->handler = mp_const_none;
self->ishard = false;
- return self;
}
void mp_irq_handler(mp_irq_obj_t *self) {
diff --git a/lib/utils/mpirq.h b/lib/utils/mpirq.h
index 548185b53..186c9e1b0 100644
--- a/lib/utils/mpirq.h
+++ b/lib/utils/mpirq.h
@@ -26,6 +26,8 @@
#ifndef MICROPY_INCLUDED_LIB_UTILS_MPIRQ_H
#define MICROPY_INCLUDED_LIB_UTILS_MPIRQ_H
+#include "py/obj.h"
+
/******************************************************************************
DEFINE CONSTANTS
******************************************************************************/
@@ -41,20 +43,17 @@ enum {
DEFINE TYPES
******************************************************************************/
-typedef mp_obj_t (*mp_irq_init_t)(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args);
-typedef mp_uint_t (*mp_irq_uint_method_one_uint_para_t)(mp_obj_t self, mp_uint_t trigger);
-typedef mp_uint_t (*mp_irq_int_method_one_para_t)(mp_obj_t self, mp_uint_t info_type);
+typedef mp_uint_t (*mp_irq_trigger_fun_t)(mp_obj_t self, mp_uint_t trigger);
+typedef mp_uint_t (*mp_irq_info_fun_t)(mp_obj_t self, mp_uint_t info_type);
enum {
MP_IRQ_INFO_FLAGS,
MP_IRQ_INFO_TRIGGERS,
- MP_IRQ_INFO_CNT
};
typedef struct _mp_irq_methods_t {
- mp_irq_init_t init;
- mp_irq_uint_method_one_uint_para_t trigger;
- mp_irq_int_method_one_para_t info;
+ mp_irq_trigger_fun_t trigger;
+ mp_irq_info_fun_t info;
} mp_irq_methods_t;
typedef struct _mp_irq_obj_t {
@@ -77,6 +76,7 @@ extern const mp_obj_type_t mp_irq_type;
******************************************************************************/
mp_irq_obj_t *mp_irq_new(const mp_irq_methods_t *methods, mp_obj_t parent);
+void mp_irq_init(mp_irq_obj_t *self, const mp_irq_methods_t *methods, mp_obj_t parent);
void mp_irq_handler(mp_irq_obj_t *self);
#endif // MICROPY_INCLUDED_LIB_UTILS_MPIRQ_H