7474//| MOSI: Optional[microcontroller.Pin] = None,
7575//| MISO: Optional[microcontroller.Pin] = None,
7676//| half_duplex: bool = False,
77+ //| slave_mode: bool = False
7778//| ) -> None:
7879//| """Construct an SPI object on the given pins.
7980//|
9697//| :param ~microcontroller.Pin MOSI: the Main Out Selected In pin.
9798//| :param ~microcontroller.Pin MISO: the Main In Selected Out pin.
9899//| :param bool half_duplex: True when MOSI is used for bidirectional data. False when SPI is full-duplex or simplex.
100+ //| :param-bool slave_mode: True when the chip is operating as a slave. False when the chip is operating as a master.
99101//|
100102//| **Limitations:** ``half_duplex`` is available only on STM; other chips do not have the hardware support.
103+ //| **Limitations:** ``slave_mode`` is available only on SAMD51; other chips do not have the firmware support.
101104//| """
102105//| ...
103106
106109STATIC mp_obj_t busio_spi_make_new (const mp_obj_type_t * type , size_t n_args , size_t n_kw , const mp_obj_t * all_args ) {
107110 #if CIRCUITPY_BUSIO_SPI
108111 busio_spi_obj_t * self = mp_obj_malloc (busio_spi_obj_t , & busio_spi_type );
109- enum { ARG_clock , ARG_MOSI , ARG_MISO , ARG_half_duplex };
112+ enum { ARG_clock , ARG_MOSI , ARG_MISO , ARG_half_duplex , ARG_slave_mode };
110113 static const mp_arg_t allowed_args [] = {
111114 { MP_QSTR_clock , MP_ARG_REQUIRED | MP_ARG_OBJ },
112115 { MP_QSTR_MOSI , MP_ARG_OBJ , {.u_obj = mp_const_none } },
113116 { MP_QSTR_MISO , MP_ARG_OBJ , {.u_obj = mp_const_none } },
114117 { MP_QSTR_half_duplex , MP_ARG_OBJ | MP_ARG_KW_ONLY , {.u_bool = false} },
118+ { MP_QSTR_slave_mode , MP_ARG_OBJ | MP_ARG_KW_ONLY , {.u_bool = false} },
115119 };
116120 mp_arg_val_t args [MP_ARRAY_SIZE (allowed_args )];
117121 mp_arg_parse_all_kw_array (n_args , n_kw , all_args , MP_ARRAY_SIZE (allowed_args ), allowed_args , args );
@@ -124,7 +128,7 @@ STATIC mp_obj_t busio_spi_make_new(const mp_obj_type_t *type, size_t n_args, siz
124128 mp_raise_ValueError (MP_ERROR_TEXT ("Must provide MISO or MOSI pin" ));
125129 }
126130
127- common_hal_busio_spi_construct (self , clock , mosi , miso , args [ARG_half_duplex ].u_bool );
131+ common_hal_busio_spi_construct (self , clock , mosi , miso , args [ARG_half_duplex ].u_bool , args [ ARG_slave_mode ]. u_bool );
128132 return MP_OBJ_FROM_PTR (self );
129133 #else
130134 raise_ValueError_invalid_pins ();
0 commit comments