@@ -57,8 +57,6 @@ static const PinMap PinMap_SPI_SCLK[] = {
57
57
// Only used in Slave mode
58
58
static const PinMap PinMap_SPI_SSEL [] = {
59
59
{PB_6 , SPI_1 , STM_PIN_DATA (GPIO_Mode_IN_FLOATING , 0 )}, // Generic IO, not real H/W NSS pin
60
- //{PA_4, SPI_1, STM_PIN_DATA(GPIO_Mode_IN_FLOATING, 0)},
61
- //{PA_15, SPI_1, STM_PIN_DATA(GPIO_Mode_IN_FLOATING, 1)}, // Remap
62
60
{NC , NC , 0 }
63
61
};
64
62
@@ -102,9 +100,6 @@ void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel
102
100
if (obj -> spi == SPI_1 ) {
103
101
RCC_APB2PeriphClockCmd (RCC_APB2Periph_SPI1 , ENABLE );
104
102
}
105
- if (obj -> spi == SPI_2 ) {
106
- RCC_APB1PeriphClockCmd (RCC_APB1Periph_SPI2 , ENABLE );
107
- }
108
103
109
104
// Configure the SPI pins
110
105
pinmap_pinout (mosi , PinMap_SPI_MOSI );
@@ -115,7 +110,7 @@ void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel
115
110
obj -> bits = SPI_DataSize_8b ;
116
111
obj -> cpol = SPI_CPOL_Low ;
117
112
obj -> cpha = SPI_CPHA_1Edge ;
118
- obj -> br_presc = SPI_BaudRatePrescaler_64 ; // Closest to 1MHz (72MHz/64 = 1.125MHz)
113
+ obj -> br_presc = SPI_BaudRatePrescaler_256 ; // 1MHz
119
114
120
115
if (ssel == NC ) { // Master
121
116
obj -> mode = SPI_Mode_Master ;
@@ -176,11 +171,8 @@ void spi_format(spi_t *obj, int bits, int mode, int slave) {
176
171
}
177
172
178
173
void spi_frequency (spi_t * obj , int hz ) {
179
- // Get SPI clock frequency
180
- uint32_t PCLK = SystemCoreClock >> 1 ;
181
-
182
174
// Choose the baud rate divisor (between 2 and 256)
183
- uint32_t divisor = PCLK / hz ;
175
+ uint32_t divisor = SystemCoreClock / hz ;
184
176
185
177
// Find the nearest power-of-2
186
178
divisor = (divisor > 0 ? divisor - 1 : 0 );
0 commit comments