extmod/machine_spi: Use delay_half, not baudrate, for internal timing.

The delay_half parameter must be specified by the port to set up the
timing of the software SPI.  This allows the port to adjust the timing
value to better suit its timing characteristics, as well as provide a
more accurate printing of the baudrate.
This commit is contained in:
Damien George
2016-10-04 13:43:02 +11:00
parent 9f1e395c16
commit b932b2dd1f
4 changed files with 37 additions and 8 deletions

View File

@@ -34,8 +34,10 @@
void mp_machine_soft_spi_transfer(mp_obj_base_t *self_in, size_t len, const uint8_t *src, uint8_t *dest) {
mp_machine_soft_spi_obj_t *self = (mp_machine_soft_spi_obj_t*)self_in;
uint32_t delay_half = self->delay_half;
// only MSB transfer is implemented
uint32_t delay_half = 500000 / self->baudrate + 1;
for (size_t i = 0; i < len; ++i) {
uint8_t data_out = src[i];
uint8_t data_in = 0;