rename routines to be clearer; fix wiznet arg types

This commit is contained in:
Dan Halbert 2020-03-05 16:35:31 -05:00
parent e30b1d3121
commit 817b5be320
31 changed files with 67 additions and 67 deletions

View File

@ -63,7 +63,7 @@ STATIC mp_obj_t analogio_analogin_make_new(const mp_obj_type_t *type,
mp_arg_check_num(n_args, kw_args, 1, 1, false);
// 1st argument is the pin
const mcu_pin_obj_t *pin = validate_is_free_pin(args[0]);
const mcu_pin_obj_t *pin = validate_obj_is_free_pin(args[0]);
analogio_analogin_obj_t *self = m_new_obj(analogio_analogin_obj_t);
self->base.type = &analogio_analogin_type;

View File

@ -62,7 +62,7 @@ STATIC mp_obj_t analogio_analogout_make_new(const mp_obj_type_t *type, mp_uint_t
// check arguments
mp_arg_check_num(n_args, kw_args, 1, 1, false);
const mcu_pin_obj_t *pin = validate_is_free_pin(args[0]);
const mcu_pin_obj_t *pin = validate_obj_is_free_pin(args[0]);
analogio_analogout_obj_t *self = m_new_obj(analogio_analogout_obj_t);
self->base.type = &analogio_analogout_type;

View File

@ -105,9 +105,9 @@ STATIC mp_obj_t audiobusio_i2sout_make_new(const mp_obj_type_t *type, size_t n_a
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
const mcu_pin_obj_t *bit_clock = validate_is_free_pin(args[ARG_bit_clock].u_obj);
const mcu_pin_obj_t *word_select = validate_is_free_pin(args[ARG_word_select].u_obj);
const mcu_pin_obj_t *data = validate_is_free_pin(args[ARG_data].u_obj);
const mcu_pin_obj_t *bit_clock = validate_obj_is_free_pin(args[ARG_bit_clock].u_obj);
const mcu_pin_obj_t *word_select = validate_obj_is_free_pin(args[ARG_word_select].u_obj);
const mcu_pin_obj_t *data = validate_obj_is_free_pin(args[ARG_data].u_obj);
audiobusio_i2sout_obj_t *self = m_new_obj_with_finaliser(audiobusio_i2sout_obj_t);
self->base.type = &audiobusio_i2sout_type;

View File

@ -104,8 +104,8 @@ STATIC mp_obj_t audiobusio_pdmin_make_new(const mp_obj_type_t *type, size_t n_ar
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
const mcu_pin_obj_t *clock_pin = validate_is_free_pin(args[ARG_clock_pin].u_obj);
const mcu_pin_obj_t *data_pin = validate_is_free_pin(args[ARG_data_pin].u_obj);
const mcu_pin_obj_t *clock_pin = validate_obj_is_free_pin(args[ARG_clock_pin].u_obj);
const mcu_pin_obj_t *data_pin = validate_obj_is_free_pin(args[ARG_data_pin].u_obj);
// create PDMIn object from the given pin
audiobusio_pdmin_obj_t *self = m_new_obj(audiobusio_pdmin_obj_t);

View File

@ -104,8 +104,8 @@ STATIC mp_obj_t audioio_audioout_make_new(const mp_obj_type_t *type, size_t n_ar
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
const mcu_pin_obj_t *left_channel_pin = validate_is_free_pin(args[ARG_left_channel].u_obj);
const mcu_pin_obj_t *right_channel_pin = validate_is_free_pin_or_none(args[ARG_right_channel].u_obj);
const mcu_pin_obj_t *left_channel_pin = validate_obj_is_free_pin(args[ARG_left_channel].u_obj);
const mcu_pin_obj_t *right_channel_pin = validate_obj_is_free_pin_or_none(args[ARG_right_channel].u_obj);
// create AudioOut object from the given pin
audioio_audioout_obj_t *self = m_new_obj(audioio_audioout_obj_t);

View File

@ -107,8 +107,8 @@ STATIC mp_obj_t audiopwmio_pwmaudioout_make_new(const mp_obj_type_t *type, size_
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
const mcu_pin_obj_t *left_channel_pin = validate_is_free_pin(args[ARG_left_channel].u_obj);
const mcu_pin_obj_t *right_channel_pin = validate_is_free_pin_or_none(args[ARG_right_channel].u_obj);
const mcu_pin_obj_t *left_channel_pin = validate_obj_is_free_pin(args[ARG_left_channel].u_obj);
const mcu_pin_obj_t *right_channel_pin = validate_obj_is_free_pin_or_none(args[ARG_right_channel].u_obj);
// create AudioOut object from the given pin
audiopwmio_pwmaudioout_obj_t *self = m_new_obj(audiopwmio_pwmaudioout_obj_t);

View File

@ -64,8 +64,8 @@ STATIC mp_obj_t bitbangio_i2c_make_new(const mp_obj_type_t *type, size_t n_args,
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
const mcu_pin_obj_t* scl = validate_is_free_pin(args[ARG_scl].u_obj);
const mcu_pin_obj_t* sda = validate_is_free_pin(args[ARG_sda].u_obj);
const mcu_pin_obj_t* scl = validate_obj_is_free_pin(args[ARG_scl].u_obj);
const mcu_pin_obj_t* sda = validate_obj_is_free_pin(args[ARG_sda].u_obj);
bitbangio_i2c_obj_t *self = m_new_obj(bitbangio_i2c_obj_t);
self->base.type = &bitbangio_i2c_type;

View File

@ -70,7 +70,7 @@ STATIC mp_obj_t bitbangio_onewire_make_new(const mp_obj_type_t *type, size_t n_a
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
const mcu_pin_obj_t* pin = validate_is_free_pin(args[ARG_pin].u_obj);
const mcu_pin_obj_t* pin = validate_obj_is_free_pin(args[ARG_pin].u_obj);
bitbangio_onewire_obj_t *self = m_new_obj(bitbangio_onewire_obj_t);
self->base.type = &bitbangio_onewire_type;

View File

@ -72,9 +72,9 @@ STATIC mp_obj_t bitbangio_spi_make_new(const mp_obj_type_t *type, size_t n_args,
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
const mcu_pin_obj_t* clock = validate_is_free_pin(args[ARG_clock].u_obj);
const mcu_pin_obj_t* mosi = validate_is_free_pin_or_none(args[ARG_MOSI].u_obj);
const mcu_pin_obj_t* miso = validate_is_free_pin_or_none(args[ARG_MISO].u_obj);
const mcu_pin_obj_t* clock = validate_obj_is_free_pin(args[ARG_clock].u_obj);
const mcu_pin_obj_t* mosi = validate_obj_is_free_pin_or_none(args[ARG_MOSI].u_obj);
const mcu_pin_obj_t* miso = validate_obj_is_free_pin_or_none(args[ARG_MISO].u_obj);
bitbangio_spi_obj_t *self = m_new_obj(bitbangio_spi_obj_t);
self->base.type = &bitbangio_spi_type;

View File

@ -77,8 +77,8 @@ STATIC mp_obj_t busio_i2c_make_new(const mp_obj_type_t *type, size_t n_args, con
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
const mcu_pin_obj_t* scl = validate_is_free_pin(args[ARG_scl].u_obj);
const mcu_pin_obj_t* sda = validate_is_free_pin(args[ARG_sda].u_obj);
const mcu_pin_obj_t* scl = validate_obj_is_free_pin(args[ARG_scl].u_obj);
const mcu_pin_obj_t* sda = validate_obj_is_free_pin(args[ARG_sda].u_obj);
common_hal_busio_i2c_construct(self, scl, sda, args[ARG_frequency].u_int, args[ARG_timeout].u_int);
return (mp_obj_t)self;

View File

@ -69,7 +69,7 @@ STATIC mp_obj_t busio_onewire_make_new(const mp_obj_type_t *type, size_t n_args,
};
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
const mcu_pin_obj_t* pin = validate_is_free_pin(args[ARG_pin].u_obj);
const mcu_pin_obj_t* pin = validate_obj_is_free_pin(args[ARG_pin].u_obj);
busio_onewire_obj_t *self = m_new_obj(busio_onewire_obj_t);
self->base.type = &busio_onewire_type;

View File

@ -90,9 +90,9 @@ STATIC mp_obj_t busio_spi_make_new(const mp_obj_type_t *type, size_t n_args, con
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
const mcu_pin_obj_t* clock = validate_is_free_pin(args[ARG_clock].u_obj);
const mcu_pin_obj_t* mosi = validate_is_free_pin_or_none(args[ARG_MOSI].u_obj);
const mcu_pin_obj_t* miso = validate_is_free_pin_or_none(args[ARG_MISO].u_obj);
const mcu_pin_obj_t* clock = validate_obj_is_free_pin(args[ARG_clock].u_obj);
const mcu_pin_obj_t* mosi = validate_obj_is_free_pin_or_none(args[ARG_MOSI].u_obj);
const mcu_pin_obj_t* miso = validate_obj_is_free_pin_or_none(args[ARG_MISO].u_obj);
common_hal_busio_spi_construct(self, clock, mosi, miso);
return MP_OBJ_FROM_PTR(self);

View File

@ -105,8 +105,8 @@ STATIC mp_obj_t busio_uart_make_new(const mp_obj_type_t *type, size_t n_args, co
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
const mcu_pin_obj_t* rx = validate_is_free_pin_or_none(args[ARG_rx].u_obj);
const mcu_pin_obj_t* tx = validate_is_free_pin_or_none(args[ARG_tx].u_obj);
const mcu_pin_obj_t* rx = validate_obj_is_free_pin_or_none(args[ARG_rx].u_obj);
const mcu_pin_obj_t* tx = validate_obj_is_free_pin_or_none(args[ARG_tx].u_obj);
if ( (tx == NULL) && (rx == NULL) ) {
mp_raise_ValueError(translate("tx and rx cannot both be None"));
@ -132,9 +132,9 @@ STATIC mp_obj_t busio_uart_make_new(const mp_obj_type_t *type, size_t n_args, co
mp_float_t timeout = mp_obj_get_float(args[ARG_timeout].u_obj);
validate_timeout(timeout);
const mcu_pin_obj_t* rts = validate_is_free_pin_or_none(args[ARG_rts].u_obj);
const mcu_pin_obj_t* cts = validate_is_free_pin_or_none(args[ARG_cts].u_obj);
const mcu_pin_obj_t* rs485_dir = validate_is_free_pin_or_none(args[ARG_rs485_dir].u_obj);
const mcu_pin_obj_t* rts = validate_obj_is_free_pin_or_none(args[ARG_rts].u_obj);
const mcu_pin_obj_t* cts = validate_obj_is_free_pin_or_none(args[ARG_cts].u_obj);
const mcu_pin_obj_t* rs485_dir = validate_obj_is_free_pin_or_none(args[ARG_rs485_dir].u_obj);
const bool rs485_invert = args[ARG_rs485_invert].u_bool;

View File

@ -68,7 +68,7 @@ STATIC mp_obj_t digitalio_digitalinout_make_new(const mp_obj_type_t *type,
digitalio_digitalinout_obj_t *self = m_new_obj(digitalio_digitalinout_obj_t);
self->base.type = &digitalio_digitalinout_type;
mcu_pin_obj_t *pin = validate_is_free_pin(args[0]);
mcu_pin_obj_t *pin = validate_obj_is_free_pin(args[0]);
common_hal_digitalio_digitalinout_construct(self, pin);
return MP_OBJ_FROM_PTR(self);

View File

@ -141,7 +141,7 @@ STATIC mp_obj_t displayio_display_make_new(const mp_obj_type_t *type, size_t n_a
mp_buffer_info_t bufinfo;
mp_get_buffer_raise(args[ARG_init_sequence].u_obj, &bufinfo, MP_BUFFER_READ);
const mcu_pin_obj_t* backlight_pin = validate_is_free_pin_or_none(args[ARG_backlight_pin].u_obj);
const mcu_pin_obj_t* backlight_pin = validate_obj_is_free_pin_or_none(args[ARG_backlight_pin].u_obj);
mp_float_t brightness = mp_obj_get_float(args[ARG_brightness].u_obj);

View File

@ -129,7 +129,7 @@ STATIC mp_obj_t displayio_epaperdisplay_make_new(const mp_obj_type_t *type, size
mp_get_buffer_raise(args[ARG_stop_sequence].u_obj, &stop_bufinfo, MP_BUFFER_READ);
const mcu_pin_obj_t* busy_pin = validate_is_free_pin_or_none(args[ARG_busy_pin].u_obj);
const mcu_pin_obj_t* busy_pin = validate_obj_is_free_pin_or_none(args[ARG_busy_pin].u_obj);
mp_int_t rotation = args[ARG_rotation].u_int;
if (rotation % 90 != 0) {

View File

@ -73,9 +73,9 @@ STATIC mp_obj_t displayio_fourwire_make_new(const mp_obj_type_t *type, size_t n_
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
mcu_pin_obj_t *command = validate_is_free_pin(args[ARG_command].u_obj);
mcu_pin_obj_t *chip_select = validate_is_free_pin(args[ARG_chip_select].u_obj);
mcu_pin_obj_t *reset = validate_is_free_pin_or_none(args[ARG_reset].u_obj);
mcu_pin_obj_t *command = validate_obj_is_free_pin(args[ARG_command].u_obj);
mcu_pin_obj_t *chip_select = validate_obj_is_free_pin(args[ARG_chip_select].u_obj);
mcu_pin_obj_t *reset = validate_obj_is_free_pin_or_none(args[ARG_reset].u_obj);
displayio_fourwire_obj_t* self = NULL;
mp_obj_t spi = args[ARG_spi_bus].u_obj;

View File

@ -69,7 +69,7 @@ STATIC mp_obj_t displayio_i2cdisplay_make_new(const mp_obj_type_t *type, size_t
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
mcu_pin_obj_t *reset = validate_is_free_pin_or_none(args[ARG_reset].u_obj);
mcu_pin_obj_t *reset = validate_obj_is_free_pin_or_none(args[ARG_reset].u_obj);
displayio_i2cdisplay_obj_t* self = NULL;
mp_obj_t i2c = args[ARG_i2c_bus].u_obj;

View File

@ -76,12 +76,12 @@ STATIC mp_obj_t displayio_parallelbus_make_new(const mp_obj_type_t *type, size_t
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
mcu_pin_obj_t *data0 = validate_is_free_pin(args[ARG_data0].u_obj);
mcu_pin_obj_t *command = validate_is_free_pin(args[ARG_command].u_obj);
mcu_pin_obj_t *chip_select = validate_is_free_pin(args[ARG_chip_select].u_obj);
mcu_pin_obj_t *write = validate_is_free_pin(args[ARG_write].u_obj);
mcu_pin_obj_t *read = validate_is_free_pin(args[ARG_read].u_obj);
mcu_pin_obj_t *reset = validate_is_free_pin(args[ARG_reset].u_obj);
mcu_pin_obj_t *data0 = validate_obj_is_free_pin(args[ARG_data0].u_obj);
mcu_pin_obj_t *command = validate_obj_is_free_pin(args[ARG_command].u_obj);
mcu_pin_obj_t *chip_select = validate_obj_is_free_pin(args[ARG_chip_select].u_obj);
mcu_pin_obj_t *write = validate_obj_is_free_pin(args[ARG_write].u_obj);
mcu_pin_obj_t *read = validate_obj_is_free_pin(args[ARG_read].u_obj);
mcu_pin_obj_t *reset = validate_obj_is_free_pin(args[ARG_reset].u_obj);
displayio_parallelbus_obj_t* self = NULL;
for (uint8_t i = 0; i < CIRCUITPY_DISPLAY_LIMIT; i++) {

View File

@ -87,7 +87,7 @@ STATIC mp_obj_t frequencyio_frequencyin_make_new(const mp_obj_type_t *type, size
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
mcu_pin_obj_t* pin = validate_is_free_pin(args[ARG_pin].u_obj);
mcu_pin_obj_t* pin = validate_obj_is_free_pin(args[ARG_pin].u_obj);
const uint16_t capture_period = args[ARG_capture_period].u_int;

View File

@ -77,8 +77,8 @@ STATIC mp_obj_t i2cslave_i2c_slave_make_new(const mp_obj_type_t *type, size_t n_
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
const mcu_pin_obj_t* scl = validate_is_free_pin(args[ARG_scl].u_obj);
const mcu_pin_obj_t* sda = validate_is_free_pin(args[ARG_sda].u_obj);
const mcu_pin_obj_t* scl = validate_obj_is_free_pin(args[ARG_scl].u_obj);
const mcu_pin_obj_t* sda = validate_obj_is_free_pin(args[ARG_sda].u_obj);
mp_obj_iter_buf_t iter_buf;
mp_obj_t iterable = mp_getiter(args[ARG_addresses].u_obj, &iter_buf);

View File

@ -84,7 +84,7 @@ const mp_obj_type_t mcu_pin_type = {
.print = mcu_pin_print
};
mcu_pin_obj_t *validate_is_pin(mp_obj_t obj) {
mcu_pin_obj_t *validate_obj_is_pin(mp_obj_t obj) {
if (!MP_OBJ_IS_TYPE(obj, &mcu_pin_type)) {
mp_raise_TypeError_varg(translate("Expected a %q"), mcu_pin_type.name);
}
@ -92,25 +92,25 @@ mcu_pin_obj_t *validate_is_pin(mp_obj_t obj) {
}
// Validate that the obj is a pin or None. Return an mcu_pin_obj_t* or NULL, correspondingly.
mcu_pin_obj_t *validate_is_pin_or_none(mp_obj_t obj) {
mcu_pin_obj_t *validate_obj_is_pin_or_none(mp_obj_t obj) {
if (obj == mp_const_none) {
return NULL;
}
return validate_is_pin(obj);
return validate_obj_is_pin(obj);
}
mcu_pin_obj_t *validate_is_free_pin(mp_obj_t obj) {
mcu_pin_obj_t *pin = validate_is_pin(obj);
mcu_pin_obj_t *validate_obj_is_free_pin(mp_obj_t obj) {
mcu_pin_obj_t *pin = validate_obj_is_pin(obj);
assert_pin_free(pin);
return pin;
}
// Validate that the obj is a free pin or None. Return an mcu_pin_obj_t* or NULL, correspondingly.
mcu_pin_obj_t *validate_is_free_pin_or_none(mp_obj_t obj) {
mcu_pin_obj_t *validate_obj_is_free_pin_or_none(mp_obj_t obj) {
if (obj == mp_const_none) {
return NULL;
}
mcu_pin_obj_t *pin = validate_is_pin(obj);
mcu_pin_obj_t *pin = validate_obj_is_pin(obj);
assert_pin_free(pin);
return pin;
}

View File

@ -33,10 +33,10 @@
// Type object used in Python. Should be shared between ports.
extern const mp_obj_type_t mcu_pin_type;
mcu_pin_obj_t *validate_is_pin(mp_obj_t obj);
mcu_pin_obj_t *validate_is_pin_or_none(mp_obj_t obj);
mcu_pin_obj_t *validate_is_free_pin(mp_obj_t obj);
mcu_pin_obj_t *validate_is_free_pin_or_none(mp_obj_t obj);
mcu_pin_obj_t *validate_obj_is_pin(mp_obj_t obj);
mcu_pin_obj_t *validate_obj_is_pin_or_none(mp_obj_t obj);
mcu_pin_obj_t *validate_obj_is_free_pin(mp_obj_t obj);
mcu_pin_obj_t *validate_obj_is_free_pin_or_none(mp_obj_t obj);
void assert_pin_free(const mcu_pin_obj_t* pin);

View File

@ -78,8 +78,8 @@ STATIC mp_obj_t ps2io_ps2_make_new(const mp_obj_type_t *type, size_t n_args, con
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
const mcu_pin_obj_t* clkpin = validate_is_free_pin(args[ARG_clkpin].u_obj);
const mcu_pin_obj_t* datapin = validate_is_free_pin(args[ARG_datapin].u_obj);
const mcu_pin_obj_t* clkpin = validate_obj_is_free_pin(args[ARG_clkpin].u_obj);
const mcu_pin_obj_t* datapin = validate_obj_is_free_pin(args[ARG_datapin].u_obj);
ps2io_ps2_obj_t *self = m_new_obj(ps2io_ps2_obj_t);
self->base.type = &ps2io_ps2_type;

View File

@ -96,7 +96,7 @@ STATIC mp_obj_t pulseio_pwmout_make_new(const mp_obj_type_t *type, size_t n_args
mp_arg_val_t parsed_args[MP_ARRAY_SIZE(allowed_args)];
mp_arg_parse_all(n_args, args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, parsed_args);
const mcu_pin_obj_t *pin = validate_is_free_pin(parsed_args[ARG_pin].u_obj);
const mcu_pin_obj_t *pin = validate_obj_is_free_pin(parsed_args[ARG_pin].u_obj);
uint16_t duty_cycle = parsed_args[ARG_duty_cycle].u_int;
uint32_t frequency = parsed_args[ARG_frequency].u_int;

View File

@ -90,7 +90,7 @@ STATIC mp_obj_t pulseio_pulsein_make_new(const mp_obj_type_t *type, size_t n_arg
};
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
const mcu_pin_obj_t* pin = validate_is_free_pin(args[ARG_pin].u_obj);
const mcu_pin_obj_t* pin = validate_obj_is_free_pin(args[ARG_pin].u_obj);
pulseio_pulsein_obj_t *self = m_new_obj(pulseio_pulsein_obj_t);
self->base.type = &pulseio_pulsein_type;

View File

@ -73,8 +73,8 @@ STATIC mp_obj_t rotaryio_incrementalencoder_make_new(const mp_obj_type_t *type,
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
const mcu_pin_obj_t* pin_a = validate_is_free_pin(args[ARG_pin_a].u_obj);
const mcu_pin_obj_t* pin_b = validate_is_free_pin(args[ARG_pin_b].u_obj);
const mcu_pin_obj_t* pin_a = validate_obj_is_free_pin(args[ARG_pin_a].u_obj);
const mcu_pin_obj_t* pin_b = validate_obj_is_free_pin(args[ARG_pin_b].u_obj);
rotaryio_incrementalencoder_obj_t *self = m_new_obj(rotaryio_incrementalencoder_obj_t);
self->base.type = &rotaryio_incrementalencoder_type;

View File

@ -66,7 +66,7 @@ STATIC mp_obj_t touchio_touchin_make_new(const mp_obj_type_t *type,
mp_arg_check_num(n_args, kw_args, 1, 1, false);
// 1st argument is the pin
const mcu_pin_obj_t *pin = validate_is_free_pin(args[0]);
const mcu_pin_obj_t *pin = validate_obj_is_free_pin(args[0]);
touchio_touchin_obj_t *self = m_new_obj(touchio_touchin_obj_t);
self->base.type = &touchio_touchin_type;

View File

@ -78,8 +78,8 @@ STATIC mp_obj_t wiznet5k_make_new(const mp_obj_type_t *type, size_t n_args, cons
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
// TODO check type of ARG_spi?
const mcu_pin_obj_t *cs = validate_is_free_pin(args[ARG_cs].u_obj);
const mcu_pin_obj_t *rst = validate_is_free_pin_or_none(args[ARG_rst].u_obj);
const mcu_pin_obj_t *cs = validate_obj_is_free_pin(args[ARG_cs].u_obj);
const mcu_pin_obj_t *rst = validate_obj_is_free_pin_or_none(args[ARG_rst].u_obj);
mp_obj_t ret = wiznet5k_create(args[ARG_spi].u_obj, cs, rst);
if (args[ARG_dhcp].u_bool) wiznet5k_start_dhcp();

View File

@ -379,12 +379,12 @@ void wiznet5k_socket_deinit(mod_network_socket_obj_t *socket) {
}
/// Create and return a WIZNET5K object.
mp_obj_t wiznet5k_create(mp_obj_t spi_in, mp_obj_t cs_in, mp_obj_t rst_in) {
mp_obj_t wiznet5k_create(busio_spi_obj_t *spi_in, const mcu_pin_obj_t *cs_in, const mcu_pin_obj_t *rst_in) {
// init the wiznet5k object
wiznet5k_obj.base.type = (mp_obj_type_t*)&mod_network_nic_type_wiznet5k;
wiznet5k_obj.cris_state = 0;
wiznet5k_obj.spi = MP_OBJ_TO_PTR(spi_in);
wiznet5k_obj.spi = spi_in;
wiznet5k_obj.socket_used = 0;
wiznet5k_obj.dhcp_socket = -1;

View File

@ -59,7 +59,7 @@ int wiznet5k_socket_ioctl(mod_network_socket_obj_t *socket, mp_uint_t request, m
void wiznet5k_socket_timer_tick(mod_network_socket_obj_t *socket);
void wiznet5k_socket_deinit(mod_network_socket_obj_t *socket);
mp_obj_t wiznet5k_socket_disconnect(mp_obj_t self_in);
mp_obj_t wiznet5k_create(mp_obj_t spi_in, mp_obj_t cs_in, mp_obj_t rst_in);
mp_obj_t wiznet5k_create(busio_spi_obj_t *spi_in, const mcu_pin_obj_t *cs_in, const mcu_pin_obj_t *rst_in);
int wiznet5k_start_dhcp(void);
int wiznet5k_stop_dhcp(void);