38void SPI_InitCS(SPI_TypeDef *SPIx,
bool isMaster, GPIO_TypeDef *GPIOx,
uint16_t GPIO_PIN);
uint16_t SPI_TransmitReceive(SPI_TypeDef *SPIx, uint16_t data)
Transmits and recieves data over the SPI.
Definition ACDC_SPI.c:87
void SPI_EnableRemap(const SPI_TypeDef *SPIx, bool enable)
Enables pin remapping on SPIx depending on the value of enable (Only SPI1 can be remapped)
Definition ACDC_SPI.c:49
void SPI_Transmit(SPI_TypeDef *SPIx, uint16_t data)
Transmits data over the given SPI.
Definition ACDC_SPI.c:62
uint16_t SPI_TransmitReceiveCS(SPI_TypeDef *SPIx, uint16_t data, GPIO_TypeDef *GPIOx, uint16_t GPIO_PIN)
Transmits and recieves data over the SPI, also takes care of the software chip select.
Definition ACDC_SPI.c:92
SPI_BitMode
Definition ACDC_SPI.h:28
@ SPI_MODE_8Bit
Definition ACDC_SPI.h:29
@ SPI_MODE_16Bit
Definition ACDC_SPI.h:30
void SPI_SetBitMode(SPI_TypeDef *SPIx, SPI_BitMode SPI_MODE_x)
Changes the SPIx peripheral between 8-bit and 16-bit mode.
Definition ACDC_SPI.c:131
void SPI_SetClockPhaseAndPolarity(SPI_TypeDef *SPIx, bool ClkPhase, bool ClkPolarity)
Sets the clock phase and polarity for SPIx.
Definition ACDC_SPI.c:155
uint16_t SPI_Receive(const SPI_TypeDef *SPIx)
Recieves data from a SPI.
Definition ACDC_SPI.c:79
bool SPI_HasDataToRecieve(SPI_TypeDef *SPIx)
Checks if there is data available in the SPIx recieve buffer.
Definition ACDC_SPI.c:174
SPI_BaudDivider
Definition ACDC_SPI.h:17
@ SPI_BAUD_DIV_128
Definition ACDC_SPI.h:24
@ SPI_BAUD_DIV_256
Definition ACDC_SPI.h:25
@ SPI_BAUD_DIV_64
Definition ACDC_SPI.h:23
@ SPI_BAUD_DIV_2
Definition ACDC_SPI.h:18
@ SPI_BAUD_DIV_8
Definition ACDC_SPI.h:20
@ SPI_BAUD_DIV_32
Definition ACDC_SPI.h:22
@ SPI_BAUD_DIV_16
Definition ACDC_SPI.h:21
@ SPI_BAUD_DIV_4
Definition ACDC_SPI.h:19
void SPI_SetBaudDivider(SPI_TypeDef *SPIx, SPI_BaudDivider SPI_BAUD_DIV_x)
Changes the Baud rate divider of the SPIx peripheral.
Definition ACDC_SPI.c:100
void SPI_SetToMaster(SPI_TypeDef *SPIx, bool isMaster)
Configures SPIx peripheral as master or slave mode.
Definition ACDC_SPI.c:167
void SPI_InitCS(SPI_TypeDef *SPIx, bool isMaster, GPIO_TypeDef *GPIOx, uint16_t GPIO_PIN)
Initializes the SPIx peripheral to master or slave, using the chip select pin of your choosing....
Definition ACDC_SPI.c:29
void SPI_TransmitCS(SPI_TypeDef *SPIx, uint16_t data, GPIO_TypeDef *GPIOx, uint16_t GPIO_PIN)
Transmits data over the given SPI, and toggles the CS pins accordingly.
Definition ACDC_SPI.c:72
void SPI_EnableSoftwareCS(SPI_TypeDef *SPIx, GPIO_TypeDef *GPIOx, uint16_t GPIO_PIN)
Enables the software CS for SPIx. (Disables Hardware CS)
Definition ACDC_SPI.c:44
void SPI_CalculateAndSetBaudDivider(SPI_TypeDef *SPIx, uint32_t maxPeripheralClockSpeed)
Calculates and sets the SPI baud divider to accompany the current peripherals maximum clock speed.
Definition ACDC_SPI.c:106
void SPI_SetLsbFirst(SPI_TypeDef *SPIx, bool LsbFirst)
Sets SPIx into either MsbFirst or LsbFirst mode.
Definition ACDC_SPI.c:146
Header file for the type bool.
unsigned short uint16_t
Definition ACDC_stdint.h:15
unsigned long int uint32_t
Definition ACDC_stdint.h:16