8000 mimxrt: Implement the review comments. · micropython/micropython@a77a47a · GitHub
[go: up one dir, main page]

Skip to content

Commit a77a47a

Browse files
committed
mimxrt: Implement the review comments.
1 parent 6730c39 commit a77a47a

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

docs/mimxrt/quickref.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,13 +303,16 @@ rates (up to 30Mhz). Hardware SPI is accessed via the
303303

304304
from machine import SPI, Pin
305305

306+
spi = SPI(0, 10000000)
306307
cs_pin = Pin(6, Pin.OUT, value=1)
308+
cs_pin(0)
307309
spi.write('Hello World')
310+
cs_pin(1)
308311

309312
For the assignment of Pins to SPI signals, refer to
310313
:ref:`Hardware SPI pinout <mimxrt_spi_pinout>`.
311314
The keyword option cs=n can be used to enable the cs pin 0 or 1 for an automatic cs signal. The
312-
default is cs=0. Using cs=-1 the automatic cs signal is not created.
315+
default is cs=-1. Using cs=-1 the automatic cs signal is not created.
313316
In that case, cs has to be set by the script. Clearing that assignment requires a power cycle.
314317

315318
Notes:

ports/mimxrt/machine_spi.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ mp_obj_t machine_spi_make_new(const mp_obj_type_t *type, size_t n_args, size_t n
131131
{ MP_QSTR_firstbit, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = DEFAULT_SPI_FIRSTBIT} },
132132
{ MP_QSTR_gap_ns, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = -1} },
133133
{ MP_QSTR_drive, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = DEFAULT_SPI_DRIVE} },
134-
{ MP_QSTR_cs, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} },
134+
{ MP_QSTR_cs, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = -1} },
135135
};
136136

137137
// Parse the arguments.
@@ -174,7 +174,9 @@ mp_obj_t machine_spi_make_new(const mp_obj_type_t *type, size_t n_args, size_t n
174174
self->master_config->lastSckToPcsDelayInNanoSec = self->master_config->betweenTransferDelayInNanoSec;
175175
self->master_config->pcsToSckDelayInNanoSec = self->master_config->betweenTransferDelayInNanoSec;
176176
int8_t cs = args[ARG_cs].u_int;
177-
// The default value 0 is set already, so only cs=1 has to be set.
177+
// In the SPI master_config for automatic CS the value cs=0 is set already,
178+
// so only cs=1 has to be addressed here. The case cs == -1 for manual CS is handled
179+
// in the function spi_set_iomux() and the value in the master_config can stay at 0.
178180
if (cs == 1) {
179181
self->master_config->whichPcs = cs;
180182
}

0 commit comments

Comments
 (0)
0