mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-12-26 12:43:08 +00:00
69 lines
2 KiB
C
69 lines
2 KiB
C
|
#include "main.h"
|
||
|
#include "api-hal-spi-config.h"
|
||
|
|
||
|
extern SPI_HandleTypeDef SPI_R;
|
||
|
extern SPI_HandleTypeDef SPI_D;
|
||
|
|
||
|
/**
|
||
|
* SD Card in fast mode (after init)
|
||
|
*/
|
||
|
const SPIDevice sd_fast_spi = {
|
||
|
.spi = &SPI_D,
|
||
|
.config = {
|
||
|
.Mode = SPI_MODE_MASTER,
|
||
|
.Direction = SPI_DIRECTION_2LINES,
|
||
|
.DataSize = SPI_DATASIZE_8BIT,
|
||
|
.CLKPolarity = SPI_POLARITY_LOW,
|
||
|
.CLKPhase = SPI_PHASE_1EDGE,
|
||
|
.NSS = SPI_NSS_SOFT,
|
||
|
.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_2,
|
||
|
.FirstBit = SPI_FIRSTBIT_MSB,
|
||
|
.TIMode = SPI_TIMODE_DISABLE,
|
||
|
.CRCCalculation = SPI_CRCCALCULATION_DISABLE,
|
||
|
.CRCPolynomial = 7,
|
||
|
.CRCLength = SPI_CRC_LENGTH_DATASIZE,
|
||
|
.NSSPMode = SPI_NSS_PULSE_ENABLE,
|
||
|
}};
|
||
|
|
||
|
/**
|
||
|
* SD Card in slow mode (before init)
|
||
|
*/
|
||
|
const SPIDevice sd_slow_spi = {
|
||
|
.spi = &SPI_D,
|
||
|
.config = {
|
||
|
.Mode = SPI_MODE_MASTER,
|
||
|
.Direction = SPI_DIRECTION_2LINES,
|
||
|
.DataSize = SPI_DATASIZE_8BIT,
|
||
|
.CLKPolarity = SPI_POLARITY_LOW,
|
||
|
.CLKPhase = SPI_PHASE_1EDGE,
|
||
|
.NSS = SPI_NSS_SOFT,
|
||
|
.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_32,
|
||
|
.FirstBit = SPI_FIRSTBIT_MSB,
|
||
|
.TIMode = SPI_TIMODE_DISABLE,
|
||
|
.CRCCalculation = SPI_CRCCALCULATION_DISABLE,
|
||
|
.CRCPolynomial = 7,
|
||
|
.CRCLength = SPI_CRC_LENGTH_DATASIZE,
|
||
|
.NSSPMode = SPI_NSS_PULSE_ENABLE,
|
||
|
}};
|
||
|
|
||
|
/**
|
||
|
* Display
|
||
|
*/
|
||
|
const SPIDevice display_spi = {
|
||
|
.spi = &SPI_D,
|
||
|
.config = {
|
||
|
.Mode = SPI_MODE_MASTER,
|
||
|
.Direction = SPI_DIRECTION_2LINES,
|
||
|
.DataSize = SPI_DATASIZE_8BIT,
|
||
|
.CLKPolarity = SPI_POLARITY_LOW,
|
||
|
.CLKPhase = SPI_PHASE_1EDGE,
|
||
|
.NSS = SPI_NSS_SOFT,
|
||
|
.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_16,
|
||
|
.FirstBit = SPI_FIRSTBIT_MSB,
|
||
|
.TIMode = SPI_TIMODE_DISABLE,
|
||
|
.CRCCalculation = SPI_CRCCALCULATION_DISABLE,
|
||
|
.CRCPolynomial = 7,
|
||
|
.CRCLength = SPI_CRC_LENGTH_DATASIZE,
|
||
|
.NSSPMode = SPI_NSS_PULSE_ENABLE,
|
||
|
}};
|