summaryrefslogtreecommitdiff
path: root/extmod
diff options
context:
space:
mode:
authorScott Shawcroft <scott@tannewt.org>2019-01-18 12:52:27 -0800
committerScott Shawcroft <scott@tannewt.org>2019-01-18 12:52:27 -0800
commit58a2009cc11ac6b080d182854d0f669a6f65647a (patch)
tree80a0c64544fc4b3a15826f6a790123bc2599888d /extmod
parent0318a9a9bcbceab308323788cb9e579da166710e (diff)
Fix unix build
Diffstat (limited to 'extmod')
-rw-r--r--extmod/machine_i2c.c10
-rw-r--r--extmod/machine_pinbase.c4
-rw-r--r--extmod/machine_signal.c10
-rw-r--r--extmod/machine_spi.c14
4 files changed, 18 insertions, 20 deletions
diff --git a/extmod/machine_i2c.c b/extmod/machine_i2c.c
index b91f1a1eb..85b46a9f6 100644
--- a/extmod/machine_i2c.c
+++ b/extmod/machine_i2c.c
@@ -287,14 +287,14 @@ STATIC void machine_i2c_obj_init_helper(machine_i2c_obj_t *self, size_t n_args,
mp_hal_i2c_init(self, args[ARG_freq].u_int);
}
-STATIC mp_obj_t machine_i2c_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
+STATIC mp_obj_t machine_i2c_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
// check the id argument, if given
if (n_args > 0) {
if (args[0] != MP_OBJ_NEW_SMALL_INT(-1)) {
#if defined(MICROPY_PY_MACHINE_I2C_MAKE_NEW)
// dispatch to port-specific constructor
- extern mp_obj_t MICROPY_PY_MACHINE_I2C_MAKE_NEW(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args);
- return MICROPY_PY_MACHINE_I2C_MAKE_NEW(type, n_args, n_kw, args);
+ extern mp_obj_t MICROPY_PY_MACHINE_I2C_MAKE_NEW(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *all_args, mp_map_t *kw_args);
+ return MICROPY_PY_MACHINE_I2C_MAKE_NEW(type, n_args, args, kw_args);
#else
mp_raise_ValueError(translate("invalid I2C peripheral"));
#endif
@@ -306,9 +306,7 @@ STATIC mp_obj_t machine_i2c_make_new(const mp_obj_type_t *type, size_t n_args, s
// create new soft I2C object
machine_i2c_obj_t *self = m_new_obj(machine_i2c_obj_t);
self->base.type = &machine_i2c_type;
- mp_map_t kw_args;
- mp_map_init_fixed_table(&kw_args, n_kw, args + n_args);
- machine_i2c_obj_init_helper(self, n_args, args, &kw_args);
+ machine_i2c_obj_init_helper(self, n_args, args, kw_args);
return (mp_obj_t)self;
}
diff --git a/extmod/machine_pinbase.c b/extmod/machine_pinbase.c
index 070c5cde9..997a6fd99 100644
--- a/extmod/machine_pinbase.c
+++ b/extmod/machine_pinbase.c
@@ -45,11 +45,11 @@ STATIC const mp_pinbase_t pinbase_singleton = {
.base = { &machine_pinbase_type },
};
-STATIC mp_obj_t pinbase_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
+STATIC mp_obj_t pinbase_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
(void)type;
(void)n_args;
- (void)n_kw;
(void)args;
+ (void)kw_args;
return MP_OBJ_FROM_PTR(&pinbase_singleton);
}
diff --git a/extmod/machine_signal.c b/extmod/machine_signal.c
index 3f9f5af94..62658cbb1 100644
--- a/extmod/machine_signal.c
+++ b/extmod/machine_signal.c
@@ -42,7 +42,7 @@ typedef struct _machine_signal_t {
bool invert;
} machine_signal_t;
-STATIC mp_obj_t signal_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
+STATIC mp_obj_t signal_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
mp_obj_t pin = args[0];
bool invert = false;
@@ -96,9 +96,9 @@ STATIC mp_obj_t signal_make_new(const mp_obj_type_t *type, size_t n_args, size_t
// Otherwise there should be 1 or 2 args
{
if (n_args == 1) {
- if (n_kw == 0) {
- } else if (n_kw == 1 && args[1] == MP_OBJ_NEW_QSTR(MP_QSTR_invert)) {
- invert = mp_obj_is_true(args[2]);
+ if (kw_args == NULL || kw_args->used == 0) {
+ } else if (kw_args->used == 1 && kw_args->table[0].key == MP_OBJ_NEW_QSTR(MP_QSTR_invert)) {
+ invert = mp_obj_is_true(kw_args->table[0].value);
} else {
goto error;
}
@@ -133,7 +133,7 @@ STATIC mp_uint_t signal_ioctl(mp_obj_t self_in, mp_uint_t request, uintptr_t arg
// fast method for getting/setting signal value
STATIC mp_obj_t signal_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
- mp_arg_check_num(n_args, n_kw, 0, 1, false);
+ mp_arg_check_num_kw_array(n_args, n_kw, 0, 1, false);
if (n_args == 0) {
// get pin
return MP_OBJ_NEW_SMALL_INT(mp_virtual_pin_read(self_in));
diff --git a/extmod/machine_spi.c b/extmod/machine_spi.c
index 3bbab2824..c5707a3d0 100644
--- a/extmod/machine_spi.c
+++ b/extmod/machine_spi.c
@@ -43,16 +43,16 @@
/******************************************************************************/
// MicroPython bindings for generic machine.SPI
-STATIC mp_obj_t mp_machine_soft_spi_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args);
+STATIC mp_obj_t mp_machine_soft_spi_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args);
-mp_obj_t mp_machine_spi_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
+mp_obj_t mp_machine_spi_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
// check the id argument, if given
if (n_args > 0) {
if (args[0] != MP_OBJ_NEW_SMALL_INT(-1)) {
#if defined(MICROPY_PY_MACHINE_SPI_MAKE_NEW)
// dispatch to port-specific constructor
- extern mp_obj_t MICROPY_PY_MACHINE_SPI_MAKE_NEW(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args);
- return MICROPY_PY_MACHINE_SPI_MAKE_NEW(type, n_args, n_kw, args);
+ extern mp_obj_t MICROPY_PY_MACHINE_SPI_MAKE_NEW(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args);
+ return MICROPY_PY_MACHINE_SPI_MAKE_NEW(type, n_args, args, kw_args);
#else
mp_raise_ValueError(translate("invalid SPI peripheral"));
#endif
@@ -62,7 +62,7 @@ mp_obj_t mp_machine_spi_make_new(const mp_obj_type_t *type, size_t n_args, size_
}
// software SPI
- return mp_machine_soft_spi_make_new(type, n_args, n_kw, args);
+ return mp_machine_soft_spi_make_new(type, n_args, args, kw_args);
}
STATIC mp_obj_t machine_spi_init(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
@@ -180,7 +180,7 @@ STATIC void mp_machine_soft_spi_print(const mp_print_t *print, mp_obj_t self_in,
mp_hal_pin_name(self->spi.sck), mp_hal_pin_name(self->spi.mosi), mp_hal_pin_name(self->spi.miso));
}
-STATIC mp_obj_t mp_machine_soft_spi_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) {
+STATIC mp_obj_t mp_machine_soft_spi_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *all_args, mp_map_t *kw_args) {
enum { ARG_baudrate, ARG_polarity, ARG_phase, ARG_bits, ARG_firstbit, ARG_sck, ARG_mosi, ARG_miso };
static const mp_arg_t allowed_args[] = {
{ MP_QSTR_baudrate, MP_ARG_INT, {.u_int = 500000} },
@@ -193,7 +193,7 @@ STATIC mp_obj_t mp_machine_soft_spi_make_new(const mp_obj_type_t *type, size_t n
{ MP_QSTR_miso, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} },
};
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
- mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
+ mp_arg_parse_all(n_args, all_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
// create new object
mp_machine_soft_spi_obj_t *self = m_new_obj(mp_machine_soft_spi_obj_t);