diff options
author | Damien George <damien.p.george@gmail.com> | 2014-09-30 22:26:59 +0100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2014-09-30 22:36:47 +0100 |
commit | bfa7b480a7a537fc5496c8d9ffbf560f3a02314d (patch) | |
tree | 2b43899291c8b95c69fac45aed09f6fccbcc511f /stmhal/spi.c | |
parent | 8b03d944e2ae64f7987116ff342fbd1cc3b97b71 (diff) | |
download | micropython-bfa7b480a7a537fc5496c8d9ffbf560f3a02314d.tar.gz micropython-bfa7b480a7a537fc5496c8d9ffbf560f3a02314d.zip |
stmhal: For spi_init, add argument to select if NSS pin is enabled.
Most of the time you don't use the NSS pin of the SPI bus, and so it
shouldn't be enabled by default (this gave some bugs in the past).
Diffstat (limited to 'stmhal/spi.c')
-rw-r--r-- | stmhal/spi.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/stmhal/spi.c b/stmhal/spi.c index 0b825ce1df..007f22daf8 100644 --- a/stmhal/spi.c +++ b/stmhal/spi.c @@ -86,7 +86,7 @@ void spi_init0(void) { } // TODO allow to take a list of pins to use -void spi_init(SPI_HandleTypeDef *spi) { +void spi_init(SPI_HandleTypeDef *spi, bool enable_nss_pin) { // init the GPIO lines GPIO_InitTypeDef GPIO_InitStructure; GPIO_InitStructure.Mode = GPIO_MODE_AF_PP; @@ -130,7 +130,7 @@ void spi_init(SPI_HandleTypeDef *spi) { return; } - for (uint i = 0; i < 4; i++) { + for (uint i = (enable_nss_pin ? 0 : 1); i < 4; i++) { GPIO_InitStructure.Pin = pins[i]->pin_mask; HAL_GPIO_Init(pins[i]->gpio, &GPIO_InitStructure); } @@ -297,7 +297,7 @@ STATIC mp_obj_t pyb_spi_init_helper(const pyb_spi_obj_t *self, mp_uint_t n_args, } // init the SPI bus - spi_init(self->spi); + spi_init(self->spi, init->NSS != SPI_NSS_SOFT); return mp_const_none; } |