diff options
author | Damien George <damien.p.george@gmail.com> | 2014-04-21 01:14:14 +0100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2014-04-21 01:14:14 +0100 |
commit | 3771a097dac8baaf6dc8a9618dc8a1074a43c439 (patch) | |
tree | b0352bf8238bf646ee155d6feae14db04a67c570 /stmhal/spi.c | |
parent | eb8bdf4df3550d1e3d0ef08cf1ce80108b721fda (diff) |
stmhal: Improve USART class, to be more like SPI and I2C.
The three classes I2C, SPI and USART now have a fairly uniform (Python)
API. All are constructed, initialised and deinitialised in the same
way. They can have most of their parameters set, using keyword arguments.
All have send and recv (although slightly different with I2C requiring an
address in master mode). recv can do inplace receiving (ie store the
data in a previously-created bytearray).
It's just polling mode at the moment, but interrupt and DMA would be
nice to add.
Diffstat (limited to 'stmhal/spi.c')
-rw-r--r-- | stmhal/spi.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/stmhal/spi.c b/stmhal/spi.c index fd19bf8b6..352c594c9 100644 --- a/stmhal/spi.c +++ b/stmhal/spi.c @@ -167,7 +167,7 @@ STATIC void pyb_spi_print(void (*print)(void *env, const char *fmt, ...), void * } else { print(env, "SPI(%u, SPI.SLAVE", spi_num); } - print(env, ", polarity=%u, phase=%u, size=%u", self->spi->Init.CLKPolarity == SPI_POLARITY_LOW ? 0 : 1, self->spi->Init.CLKPhase == SPI_PHASE_1EDGE ? 1 : 2, self->spi->Init.DataSize == SPI_DATASIZE_8BIT ? 8 : 16); + print(env, ", polarity=%u, phase=%u, bits=%u", self->spi->Init.CLKPolarity == SPI_POLARITY_LOW ? 0 : 1, self->spi->Init.CLKPhase == SPI_PHASE_1EDGE ? 1 : 2, self->spi->Init.DataSize == SPI_DATASIZE_8BIT ? 8 : 16); if (self->spi->Init.CRCCalculation == SPI_CRCCALCULATION_ENABLED) { print(env, ", crc=0x%x", self->spi->Init.CRCPolynomial); } @@ -181,7 +181,7 @@ STATIC const mp_arg_parse_t pyb_spi_init_accepted_args[] = { { MP_QSTR_polarity, MP_ARG_PARSE_KW_ONLY | MP_ARG_PARSE_INT, {.u_int = 1} }, { MP_QSTR_phase, MP_ARG_PARSE_KW_ONLY | MP_ARG_PARSE_INT, {.u_int = 1} }, { MP_QSTR_dir, MP_ARG_PARSE_KW_ONLY | MP_ARG_PARSE_INT, {.u_int = SPI_DIRECTION_2LINES} }, - { MP_QSTR_size, MP_ARG_PARSE_KW_ONLY | MP_ARG_PARSE_INT, {.u_int = 8} }, + { MP_QSTR_bits, MP_ARG_PARSE_KW_ONLY | MP_ARG_PARSE_INT, {.u_int = 8} }, { MP_QSTR_nss, MP_ARG_PARSE_KW_ONLY | MP_ARG_PARSE_INT, {.u_int = SPI_NSS_SOFT} }, { MP_QSTR_firstbit, MP_ARG_PARSE_KW_ONLY | MP_ARG_PARSE_INT, {.u_int = SPI_FIRSTBIT_MSB} }, { MP_QSTR_ti, MP_ARG_PARSE_KW_ONLY | MP_ARG_PARSE_BOOL, {.u_bool = false} }, |