mirror of https://github.com/FOME-Tech/fome-fw.git
oops, some boards needed spi prescaler func
This commit is contained in:
parent
01674ec324
commit
c0489d8591
|
@ -273,6 +273,13 @@ typedef enum __attribute__ ((__packed__)) {
|
|||
UART_DEVICE_4 = 4,
|
||||
} uart_device_e;
|
||||
|
||||
typedef enum __attribute__ ((__packed__)) {
|
||||
_5MHz,
|
||||
_2_5MHz,
|
||||
_1_25MHz,
|
||||
_150KHz
|
||||
} spi_speed_e;
|
||||
|
||||
typedef enum __attribute__ ((__packed__)) {
|
||||
SPI_NONE = 0,
|
||||
SPI_DEVICE_1 = 1,
|
||||
|
|
|
@ -527,3 +527,25 @@ void initHardware() {
|
|||
|
||||
efiPrintf("initHardware() OK!");
|
||||
}
|
||||
|
||||
#if HAL_USE_SPI
|
||||
// this is F4 implementation but we will keep it here for now for simplicity
|
||||
int getSpiPrescaler(spi_speed_e speed, spi_device_e device) {
|
||||
switch (speed) {
|
||||
case _5MHz:
|
||||
return device == SPI_DEVICE_1 ? SPI_BaudRatePrescaler_16 : SPI_BaudRatePrescaler_8;
|
||||
case _2_5MHz:
|
||||
return device == SPI_DEVICE_1 ? SPI_BaudRatePrescaler_32 : SPI_BaudRatePrescaler_16;
|
||||
case _1_25MHz:
|
||||
return device == SPI_DEVICE_1 ? SPI_BaudRatePrescaler_64 : SPI_BaudRatePrescaler_32;
|
||||
|
||||
case _150KHz:
|
||||
// SPI1 does not support 150KHz, it would be 300KHz for SPI1
|
||||
return SPI_BaudRatePrescaler_256;
|
||||
default:
|
||||
// unexpected
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* HAL_USE_SPI */
|
||||
|
|
|
@ -31,6 +31,8 @@ void stopHardware();
|
|||
// 328.125 KHz 164.06 KHz
|
||||
#define SPI_BaudRatePrescaler_256 ((uint16_t)0x0038)
|
||||
|
||||
int getSpiPrescaler(spi_speed_e speed, spi_device_e device);
|
||||
|
||||
EXTERNC SPIDriver * getSpiDevice(spi_device_e spiDevice);
|
||||
void turnOnSpi(spi_device_e device);
|
||||
void lockSpi(spi_device_e device);
|
||||
|
|
Loading…
Reference in New Issue