diff options
author | Damien George <damien.p.george@gmail.com> | 2016-10-04 13:38:11 +1100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2016-10-04 13:38:11 +1100 |
commit | 9f1e395c167648d1b7fef1175290b0047ee6e1f4 (patch) | |
tree | fda3391c92ceea17e4ebaf9fafc310120e9bc84d | |
parent | bd8737520273fc07bec1ec3487c92eb11609f1da (diff) | |
download | micropython-9f1e395c167648d1b7fef1175290b0047ee6e1f4.tar.gz micropython-9f1e395c167648d1b7fef1175290b0047ee6e1f4.zip |
stmhal/spi: Use software SPI if no periph id given, even if pins given.
It's simpler to just default to always using software SPI if no specific
peripheral id/name is given. To use hardware SPI users must specify a
hardware peripheral id as the first parameter to the SPI constructor.
-rw-r--r-- | stmhal/spi.c | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/stmhal/spi.c b/stmhal/spi.c index 1ccc7357d9..46da05facf 100644 --- a/stmhal/spi.c +++ b/stmhal/spi.c @@ -868,7 +868,7 @@ STATIC void machine_hard_spi_deinit(mp_obj_t self); STATIC mp_obj_t machine_spi_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { static const mp_arg_t allowed_args[] = { - { MP_QSTR_id, MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} }, + { MP_QSTR_id, MP_ARG_OBJ, {.u_obj = MP_OBJ_NEW_SMALL_INT(-1)} }, { MP_QSTR_baudrate, MP_ARG_INT, {.u_int = 500000} }, { MP_QSTR_polarity, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} }, { MP_QSTR_phase, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} }, @@ -883,11 +883,7 @@ STATIC mp_obj_t machine_spi_make_new(const mp_obj_type_t *type, size_t n_args, s 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); - if (args[ARG_NEW_id].u_obj == MP_OBJ_NULL) { - // no peripheral id given - // we use software SPI for now but should support hardware if pins allow it - return machine_soft_spi_make_new(args); - } else if (args[ARG_NEW_id].u_obj == MP_OBJ_NEW_SMALL_INT(-1)) { + if (args[ARG_NEW_id].u_obj == MP_OBJ_NEW_SMALL_INT(-1)) { // software SPI return machine_soft_spi_make_new(args); } else { |