48
48
//|
49
49
//| :param ~busio.SPI spi: The SPI bus the device is on
50
50
//| :param ~digitalio.DigitalInOut chip_select: The chip select pin object that implements the DigitalInOut API.
51
+ //| :param bool cs_active_value: Set to true if your device requires CS to be active high. Defaults to false.
51
52
//| :param int extra_clocks: The minimum number of clock cycles to cycle the bus after CS is high. (Used for SD cards.)
52
53
//|
53
54
//| Example::
73
74
STATIC mp_obj_t adafruit_bus_device_spidevice_make_new (const mp_obj_type_t * type , size_t n_args , const mp_obj_t * pos_args , mp_map_t * kw_args ) {
74
75
adafruit_bus_device_spidevice_obj_t * self = m_new_obj (adafruit_bus_device_spidevice_obj_t );
75
76
self -> base .type = & adafruit_bus_device_spidevice_type ;
76
- enum { ARG_spi , ARG_chip_select , ARG_baudrate , ARG_polarity , ARG_phase , ARG_extra_clocks };
77
+ enum { ARG_spi , ARG_chip_select , ARG_cs_active_value , ARG_baudrate , ARG_polarity , ARG_phase , ARG_extra_clocks };
77
78
static const mp_arg_t allowed_args [] = {
78
79
{ MP_QSTR_spi , MP_ARG_REQUIRED | MP_ARG_OBJ },
79
80
{ MP_QSTR_chip_select , MP_ARG_OBJ , {.u_obj = MP_OBJ_NULL } },
81
+ { MP_QSTR_cs_active_value , MP_ARG_KW_ONLY | MP_ARG_BOOL , {.u_bool = false} },
80
82
{ MP_QSTR_baudrate , MP_ARG_KW_ONLY | MP_ARG_INT , {.u_int = 100000 } },
81
83
{ MP_QSTR_polarity , MP_ARG_KW_ONLY | MP_ARG_INT , {.u_int = 0 } },
82
84
{ MP_QSTR_phase , MP_ARG_KW_ONLY | MP_ARG_INT , {.u_int = 0 } },
@@ -87,7 +89,7 @@ STATIC mp_obj_t adafruit_bus_device_spidevice_make_new(const mp_obj_type_t *type
87
89
88
90
busio_spi_obj_t * spi = args [ARG_spi ].u_obj ;
89
91
90
- common_hal_adafruit_bus_device_spidevice_construct (MP_OBJ_TO_PTR (self ), spi , args [ARG_chip_select ].u_obj , args [ARG_baudrate ].u_int , args [ARG_polarity ].u_int ,
92
+ common_hal_adafruit_bus_device_spidevice_construct (MP_OBJ_TO_PTR (self ), spi , args [ARG_chip_select ].u_obj , args [ARG_cs_active_value ]. u_bool , args [ ARG_baudrate ].u_int , args [ARG_polarity ].u_int ,
91
93
args [ARG_phase ].u_int , args [ARG_extra_clocks ].u_int );
92
94
93
95
if (args [ARG_chip_select ].u_obj != MP_OBJ_NULL ) {
0 commit comments