mbed library sources
Dependents: frdm_kl05z_gpio_test
Fork of mbed-src by
Diff: targets/hal/TARGET_STM/TARGET_DISCO_F407VG/spi_api.c
- Revision:
- 227:7bd0639b8911
- Parent:
- 133:d4dda5c437f0
- Child:
- 242:7074e42da0b2
diff -r b062af740e40 -r 7bd0639b8911 targets/hal/TARGET_STM/TARGET_DISCO_F407VG/spi_api.c --- a/targets/hal/TARGET_STM/TARGET_DISCO_F407VG/spi_api.c Wed Jun 11 09:45:09 2014 +0100 +++ b/targets/hal/TARGET_STM/TARGET_DISCO_F407VG/spi_api.c Wed Jun 11 16:00:09 2014 +0100 @@ -34,7 +34,6 @@ #include <math.h> #include "cmsis.h" #include "pinmap.h" -#include "error.h" #include "stm32f4xx_hal.h" static const PinMap PinMap_SPI_MOSI[] = { @@ -112,10 +111,7 @@ SPIName spi_cntl = (SPIName)pinmap_merge(spi_sclk, spi_ssel); obj->spi = (SPIName)pinmap_merge(spi_data, spi_cntl); - - if (obj->spi == (SPIName)NC) { - error("SPI error: pinout mapping failed."); - } + MBED_ASSERT(obj->spi != (SPIName)NC); // Enable SPI clock if (obj->spi == SPI_1) { @@ -157,7 +153,7 @@ HAL_SPI_DeInit(&SpiHandle); } -void spi_format(spi_t *obj, int bits, int mode, int slave) { +void spi_format(spi_t *obj, int bits, int mode, int slave) { // Save new values if (bits == 8) { obj->bits = SPI_DATASIZE_8BIT; @@ -177,11 +173,11 @@ break; case 2: obj->cpol = SPI_POLARITY_HIGH; - obj->cpha = SPI_PHASE_1EDGE; + obj->cpha = SPI_PHASE_1EDGE; break; default: obj->cpol = SPI_POLARITY_HIGH; - obj->cpha = SPI_PHASE_2EDGE; + obj->cpha = SPI_PHASE_2EDGE; break; } @@ -191,7 +187,7 @@ } else { obj->mode = SPI_MODE_SLAVE; - obj->nss = SPI_NSS_HARD_INPUT; + obj->nss = SPI_NSS_HARD_INPUT; } init_spi(obj); @@ -231,7 +227,7 @@ SpiHandle.Instance = (SPI_TypeDef *)(obj->spi); // Check if data is received status = ((__HAL_SPI_GET_FLAG(&SpiHandle, SPI_FLAG_RXNE) != RESET) ? 1 : 0); - return status; + return status; } static inline int ssp_writeable(spi_t *obj) {