Skip to content

Commit 58a2009

Browse files
committed
Fix unix build
1 parent 0318a9a commit 58a2009

5 files changed

Lines changed: 26 additions & 20 deletions

File tree

extmod/machine_i2c.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -287,14 +287,14 @@ STATIC void machine_i2c_obj_init_helper(machine_i2c_obj_t *self, size_t n_args,
287287
mp_hal_i2c_init(self, args[ARG_freq].u_int);
288288
}
289289

290-
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) {
290+
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) {
291291
// check the id argument, if given
292292
if (n_args > 0) {
293293
if (args[0] != MP_OBJ_NEW_SMALL_INT(-1)) {
294294
#if defined(MICROPY_PY_MACHINE_I2C_MAKE_NEW)
295295
// dispatch to port-specific constructor
296-
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);
297-
return MICROPY_PY_MACHINE_I2C_MAKE_NEW(type, n_args, n_kw, args);
296+
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);
297+
return MICROPY_PY_MACHINE_I2C_MAKE_NEW(type, n_args, args, kw_args);
298298
#else
299299
mp_raise_ValueError(translate("invalid I2C peripheral"));
300300
#endif
@@ -306,9 +306,7 @@ STATIC mp_obj_t machine_i2c_make_new(const mp_obj_type_t *type, size_t n_args, s
306306
// create new soft I2C object
307307
machine_i2c_obj_t *self = m_new_obj(machine_i2c_obj_t);
308308
self->base.type = &machine_i2c_type;
309-
mp_map_t kw_args;
310-
mp_map_init_fixed_table(&kw_args, n_kw, args + n_args);
311-
machine_i2c_obj_init_helper(self, n_args, args, &kw_args);
309+
machine_i2c_obj_init_helper(self, n_args, args, kw_args);
312310
return (mp_obj_t)self;
313311
}
314312

extmod/machine_pinbase.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ STATIC const mp_pinbase_t pinbase_singleton = {
4545
.base = { &machine_pinbase_type },
4646
};
4747

48-
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) {
48+
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) {
4949
(void)type;
5050
(void)n_args;
51-
(void)n_kw;
5251
(void)args;
52+
(void)kw_args;
5353
return MP_OBJ_FROM_PTR(&pinbase_singleton);
5454
}
5555

extmod/machine_signal.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ typedef struct _machine_signal_t {
4242
bool invert;
4343
} machine_signal_t;
4444

45-
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) {
45+
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) {
4646
mp_obj_t pin = args[0];
4747
bool invert = false;
4848

@@ -96,9 +96,9 @@ STATIC mp_obj_t signal_make_new(const mp_obj_type_t *type, size_t n_args, size_t
9696
// Otherwise there should be 1 or 2 args
9797
{
9898
if (n_args == 1) {
99-
if (n_kw == 0) {
100-
} else if (n_kw == 1 && args[1] == MP_OBJ_NEW_QSTR(MP_QSTR_invert)) {
101-
invert = mp_obj_is_true(args[2]);
99+
if (kw_args == NULL || kw_args->used == 0) {
100+
} else if (kw_args->used == 1 && kw_args->table[0].key == MP_OBJ_NEW_QSTR(MP_QSTR_invert)) {
101+
invert = mp_obj_is_true(kw_args->table[0].value);
102102
} else {
103103
goto error;
104104
}
@@ -133,7 +133,7 @@ STATIC mp_uint_t signal_ioctl(mp_obj_t self_in, mp_uint_t request, uintptr_t arg
133133

134134
// fast method for getting/setting signal value
135135
STATIC mp_obj_t signal_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
136-
mp_arg_check_num(n_args, n_kw, 0, 1, false);
136+
mp_arg_check_num_kw_array(n_args, n_kw, 0, 1, false);
137137
if (n_args == 0) {
138138
// get pin
139139
return MP_OBJ_NEW_SMALL_INT(mp_virtual_pin_read(self_in));

extmod/machine_spi.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,16 @@
4343
/******************************************************************************/
4444
// MicroPython bindings for generic machine.SPI
4545

46-
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);
46+
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);
4747

48-
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) {
48+
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) {
4949
// check the id argument, if given
5050
if (n_args > 0) {
5151
if (args[0] != MP_OBJ_NEW_SMALL_INT(-1)) {
5252
#if defined(MICROPY_PY_MACHINE_SPI_MAKE_NEW)
5353
// dispatch to port-specific constructor
54-
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);
55-
return MICROPY_PY_MACHINE_SPI_MAKE_NEW(type, n_args, n_kw, args);
54+
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);
55+
return MICROPY_PY_MACHINE_SPI_MAKE_NEW(type, n_args, args, kw_args);
5656
#else
5757
mp_raise_ValueError(translate("invalid SPI peripheral"));
5858
#endif
@@ -62,7 +62,7 @@ mp_obj_t mp_machine_spi_make_new(const mp_obj_type_t *type, size_t n_args, size_
6262
}
6363

6464
// software SPI
65-
return mp_machine_soft_spi_make_new(type, n_args, n_kw, args);
65+
return mp_machine_soft_spi_make_new(type, n_args, args, kw_args);
6666
}
6767

6868
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,
180180
mp_hal_pin_name(self->spi.sck), mp_hal_pin_name(self->spi.mosi), mp_hal_pin_name(self->spi.miso));
181181
}
182182

183-
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) {
183+
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) {
184184
enum { ARG_baudrate, ARG_polarity, ARG_phase, ARG_bits, ARG_firstbit, ARG_sck, ARG_mosi, ARG_miso };
185185
static const mp_arg_t allowed_args[] = {
186186
{ 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
193193
{ MP_QSTR_miso, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} },
194194
};
195195
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
196-
mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
196+
mp_arg_parse_all(n_args, all_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
197197

198198
// create new object
199199
mp_machine_soft_spi_obj_t *self = m_new_obj(mp_machine_soft_spi_obj_t);

ports/unix/Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,14 @@ SRC_C = \
154154
supervisor/shared/translate.c \
155155
$(SRC_MOD)
156156

157+
PY_EXTMOD_O_BASENAME += \
158+
extmod/machine_mem.o \
159+
extmod/machine_pinbase.o \
160+
extmod/machine_signal.o \
161+
extmod/machine_pulse.o \
162+
extmod/machine_i2c.o \
163+
extmod/machine_spi.o
164+
157165
LIB_SRC_C = $(addprefix lib/,\
158166
$(LIB_SRC_C_EXTRA) \
159167
timeutils/timeutils.c \

0 commit comments

Comments
 (0)