5454/// parameters to init the SPI bus:
5555///
5656/// from pyb import SPI
57- /// spi = SPI(1, SPI.MASTER, baudrate=2000000, bits=8, polarity=0, phase=0, nss =SPI.ACTIVE_LOW)
57+ /// spi = SPI(1, SPI.MASTER, baudrate=2000000, bits=8, polarity=0, phase=0, cs_polarity =SPI.ACTIVE_LOW)
5858///
5959/// Only required parameter is the baudrate, in Hz. polarity and phase may be 0 or 1.
6060/// Bit accepts 8, 16, 32. Chip select values are ACTIVE_LOW and ACTIVE_HIGH
@@ -168,15 +168,15 @@ STATIC void pyb_spi_print(const mp_print_t *print, mp_obj_t self_in, mp_print_ki
168168 pyb_spi_obj_t * self = self_in ;
169169
170170 if (self -> baudrate > 0 ) {
171- mp_printf (print , "<SPI1, SPI.MASTER, baudrate=%u, bits=%u, polarity=%u, phase=%u, nss =%q>" ,
171+ mp_printf (print , "<SPI1, SPI.MASTER, baudrate=%u, bits=%u, polarity=%u, phase=%u, cs_polarity =%q>" ,
172172 self -> baudrate , (self -> wlen * 8 ), self -> polarity , self -> phase ,
173173 (self -> config & SPI_CS_ACTIVELOW ) ? MP_QSTR_ACTIVE_LOW : MP_QSTR_ACTIVE_HIGH );
174174 } else {
175175 mp_print_str (print , "<SPI1>" );
176176 }
177177}
178178
179- /// \method init(mode, *, baudrate=1000000, bits=8, polarity=0, phase=0, nss =SPI.ACTIVE_LOW)
179+ /// \method init(mode, *, baudrate=1000000, bits=8, polarity=0, phase=0, cs_polarity =SPI.ACTIVE_LOW)
180180///
181181/// Initialise the SPI bus with the given parameters:
182182///
@@ -185,14 +185,14 @@ STATIC void pyb_spi_print(const mp_print_t *print, mp_obj_t self_in, mp_print_ki
185185/// - `bits` is the transfer width size (8, 16, 32).
186186/// - `polarity` (0, 1).
187187/// - `phase` (0, 1).
188- /// - `nss ` can be ACTIVE_LOW or ACTIVE_HIGH.
188+ /// - `cs_polarity ` can be ACTIVE_LOW or ACTIVE_HIGH.
189189static const mp_arg_t pybspi_init_args [] = {
190190 { MP_QSTR_mode , MP_ARG_REQUIRED | MP_ARG_INT , },
191191 { MP_QSTR_baudrate , MP_ARG_KW_ONLY | MP_ARG_INT , {.u_int = PYBSPI_DEF_BAUDRATE } },
192192 { MP_QSTR_bits , MP_ARG_KW_ONLY | MP_ARG_INT , {.u_int = 8 } },
193193 { MP_QSTR_polarity , MP_ARG_KW_ONLY | MP_ARG_INT , {.u_int = 0 } },
194194 { MP_QSTR_phase , MP_ARG_KW_ONLY | MP_ARG_INT , {.u_int = 0 } },
195- { MP_QSTR_nss , MP_ARG_KW_ONLY | MP_ARG_INT , {.u_int = SPI_CS_ACTIVELOW } },
195+ { MP_QSTR_cs_polarity , MP_ARG_KW_ONLY | MP_ARG_INT , {.u_int = SPI_CS_ACTIVELOW } },
196196};
197197
198198STATIC mp_obj_t pyb_spi_init_helper (pyb_spi_obj_t * self , mp_uint_t n_args , const mp_obj_t * pos_args , mp_map_t * kw_args ) {
@@ -227,15 +227,15 @@ STATIC mp_obj_t pyb_spi_init_helper(pyb_spi_obj_t *self, mp_uint_t n_args, const
227227 goto invalid_args ;
228228 }
229229
230- uint nss = args [5 ].u_int ;
231- if (nss != SPI_CS_ACTIVELOW && nss != SPI_CS_ACTIVEHIGH ) {
230+ uint cs = args [5 ].u_int ;
231+ if (cs != SPI_CS_ACTIVELOW && cs != SPI_CS_ACTIVEHIGH ) {
232232 goto invalid_args ;
233233 }
234234
235235 // build the configuration
236236 self -> baudrate = args [1 ].u_int ;
237237 self -> wlen = args [2 ].u_int >> 3 ;
238- self -> config = bits | nss | SPI_SW_CTRL_CS | SPI_4PIN_MODE | SPI_TURBO_OFF ;
238+ self -> config = bits | cs | SPI_SW_CTRL_CS | SPI_4PIN_MODE | SPI_TURBO_OFF ;
239239 self -> polarity = polarity ;
240240 self -> phase = phase ;
241241 self -> submode = (polarity << 1 ) | phase ;
0 commit comments