mbed library sources
Dependents: frdm_kl05z_gpio_test
Fork of mbed-src by
Diff: targets/hal/TARGET_STM/TARGET_NUCLEO_F103RB/spi_api.c
- Revision:
- 88:81f18c97d490
- Parent:
- 70:c1fbde68b492
- Child:
- 139:e3413eddde57
--- a/targets/hal/TARGET_STM/TARGET_NUCLEO_F103RB/spi_api.c Sat Feb 08 19:45:06 2014 +0000 +++ b/targets/hal/TARGET_STM/TARGET_NUCLEO_F103RB/spi_api.c Mon Feb 10 19:00:06 2014 +0000 @@ -57,8 +57,6 @@ // Only used in Slave mode static const PinMap PinMap_SPI_SSEL[] = { {PB_6, SPI_1, STM_PIN_DATA(GPIO_Mode_IN_FLOATING, 0)}, // Generic IO, not real H/W NSS pin - //{PA_4, SPI_1, STM_PIN_DATA(GPIO_Mode_IN_FLOATING, 0)}, - //{PA_15, SPI_1, STM_PIN_DATA(GPIO_Mode_IN_FLOATING, 1)}, // Remap {NC, NC, 0} }; @@ -102,9 +100,6 @@ if (obj->spi == SPI_1) { RCC_APB2PeriphClockCmd(RCC_APB2Periph_SPI1, ENABLE); } - if (obj->spi == SPI_2) { - RCC_APB1PeriphClockCmd(RCC_APB1Periph_SPI2, ENABLE); - } // Configure the SPI pins pinmap_pinout(mosi, PinMap_SPI_MOSI); @@ -115,7 +110,7 @@ obj->bits = SPI_DataSize_8b; obj->cpol = SPI_CPOL_Low; obj->cpha = SPI_CPHA_1Edge; - obj->br_presc = SPI_BaudRatePrescaler_64; // Closest to 1MHz (72MHz/64 = 1.125MHz) + obj->br_presc = SPI_BaudRatePrescaler_256; // 1MHz if (ssel == NC) { // Master obj->mode = SPI_Mode_Master; @@ -176,11 +171,8 @@ } void spi_frequency(spi_t *obj, int hz) { - // Get SPI clock frequency - uint32_t PCLK = SystemCoreClock >> 1; - // Choose the baud rate divisor (between 2 and 256) - uint32_t divisor = PCLK / hz; + uint32_t divisor = SystemCoreClock / hz; // Find the nearest power-of-2 divisor = (divisor > 0 ? divisor-1 : 0);