Move missing pin warning to shared-bindings

This commit is contained in:
Lucian Copeland 2020-09-23 11:39:39 -04:00
parent 22d9a94f2b
commit 00517b2600
3 changed files with 4 additions and 18 deletions

View File

@ -116,15 +116,6 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self,
const mcu_pin_obj_t * clock, const mcu_pin_obj_t * mosi,
const mcu_pin_obj_t * miso) {
//SCK is not optional. MOSI and MISO are
if (!clock) {
mp_raise_ValueError(translate("Must provide SCK pin"));
}
if (!miso && !mosi) {
mp_raise_ValueError(translate("Must provide MISO or MOSI pin"));
}
spi_bus_config_t bus_config;
bus_config.mosi_io_num = mosi != NULL ? mosi->number : -1;
bus_config.miso_io_num = miso != NULL ? miso->number : -1;

View File

@ -127,15 +127,6 @@ STATIC int check_pins(busio_spi_obj_t *self,
uint8_t mosi_len = MP_ARRAY_SIZE(mcu_spi_mosi_list);
uint8_t miso_len = MP_ARRAY_SIZE(mcu_spi_miso_list);
//SCK is not optional. MOSI and MISO are
if (!sck) {
mp_raise_ValueError(translate("Must provide SCK pin"));
}
if (!miso && !mosi) {
mp_raise_ValueError(translate("Must provide MISO or MOSI pin"));
}
// Loop over each possibility for SCK. Check whether MISO and/or MOSI can be used on the same peripheral
for (uint i = 0; i < sck_len; i++) {
const mcu_periph_obj_t *mcu_spi_sck = &mcu_spi_sck_list[i];

View File

@ -96,6 +96,10 @@ STATIC mp_obj_t busio_spi_make_new(const mp_obj_type_t *type, size_t n_args, con
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);
if (!miso && !mosi) {
mp_raise_ValueError(translate("Must provide MISO or MOSI pin"));
}
common_hal_busio_spi_construct(self, clock, mosi, miso);
return MP_OBJ_FROM_PTR(self);
}