mbed library sources
Dependents: frdm_kl05z_gpio_test
Fork of mbed-src by
Diff: targets/hal/TARGET_STM/TARGET_DISCO_F303VC/spi_api.c
- Revision:
- 241:ffe41b0c8126
- Parent:
- 227:7bd0639b8911
diff -r 9a7c54113eaf -r ffe41b0c8126 targets/hal/TARGET_STM/TARGET_DISCO_F303VC/spi_api.c --- a/targets/hal/TARGET_STM/TARGET_DISCO_F303VC/spi_api.c Thu Jun 26 09:45:08 2014 +0100 +++ b/targets/hal/TARGET_STM/TARGET_DISCO_F303VC/spi_api.c Thu Jun 26 10:30:09 2014 +0100 @@ -122,13 +122,18 @@ obj->cpha = SPI_CPHA_1Edge; obj->br_presc = SPI_BaudRatePrescaler_256; + obj->pin_miso = miso; + obj->pin_mosi = mosi; + obj->pin_sclk = sclk; + obj->pin_ssel = ssel; + if (ssel == NC) { // Master obj->mode = SPI_Mode_Master; obj->nss = SPI_NSS_Soft; } else { // Slave pinmap_pinout(ssel, PinMap_SPI_SSEL); obj->mode = SPI_Mode_Slave; - obj->nss = SPI_NSS_Soft; + obj->nss = SPI_NSS_Hard; } init_spi(obj); @@ -141,10 +146,10 @@ void spi_format(spi_t *obj, int bits, int mode, int slave) { // Save new values - if (bits == 8) { + if (bits == 16) { + obj->bits = SPI_DataSize_16b; + } else { obj->bits = SPI_DataSize_8b; - } else { - obj->bits = SPI_DataSize_16b; } switch (mode) { @@ -248,7 +253,7 @@ } int spi_slave_receive(spi_t *obj) { - return (ssp_readable(obj) && !ssp_busy(obj)) ? (1) : (0); + return ((ssp_readable(obj) && !ssp_busy(obj)) ? 1 : 0); }; int spi_slave_read(spi_t *obj) {