foxBMS
1.1.0
The foxBMS Battery Management System API Documentation
|
Driver for the SPI module. More...
#include "spi.h"
#include "HL_reg_spi.h"
#include "HL_spi.h"
#include "HL_sys_common.h"
#include "dma.h"
#include "fsystem.h"
#include "io.h"
#include "mcu.h"
#include "os.h"
Go to the source code of this file.
Macros | |
#define | SPI_FLAG_REGISTER_TRANSMISSION_ERRORS (0x5Fu) |
Functions | |
STD_RETURN_TYPE_e | SPI_TransmitDummyByte (SPI_INTERFACE_CONFIG_s *pSpiInterface, uint32_t delay) |
Sends a dummy byte to wake up the SPI interface. More... | |
STD_RETURN_TYPE_e | SPI_TransmitData (SPI_INTERFACE_CONFIG_s *pSpiInterface, uint16_t *pTxBuff, uint32_t frameLength) |
Sends data on SPI without DMA. More... | |
STD_RETURN_TYPE_e | SPI_TransmitDataWithDummy (SPI_INTERFACE_CONFIG_s *pSpiInterface, uint32_t delay, uint16_t *pTxBuff, uint32_t frameLength) |
Sends data on SPI without DMA, with wake-up byte. More... | |
STD_RETURN_TYPE_e | SPI_TransmitReceiveData (SPI_INTERFACE_CONFIG_s *pSpiInterface, uint16 *pTxBuff, uint16 *pRxBuff, uint32 frameLength) |
Transmits and receives data on SPI without DMA. More... | |
STD_RETURN_TYPE_e | SPI_DirectlyTransmitReceiveData (SPI_INTERFACE_CONFIG_s *pSpiInterface, uint16 *pTxBuff, uint16 *pRxBuff, uint32 frameLength) |
Transmits and receives data on SPI without DMA. More... | |
STD_RETURN_TYPE_e | SPI_TransmitReceiveDataDma (SPI_INTERFACE_CONFIG_s *pSpiInterface, uint16_t *pTxBuff, uint16_t *pRxBuff, uint32_t frameLength) |
Transmits and receives data on SPI with DMA. More... | |
STD_RETURN_TYPE_e | SPI_TransmitReceiveDataWithDummyDma (SPI_INTERFACE_CONFIG_s *pSpiInterface, uint32_t delay, uint16_t *pTxBuff, uint16_t *pRxBuff, uint32_t frameLength) |
Transmits and receives data on SPI with DMA. More... | |
STD_RETURN_TYPE_e | SPI_Lock (uint8_t spi) |
Locks SPI interfaces. More... | |
void | SPI_Unlock (uint8_t spi) |
Unlocks SPI interfaces. More... | |
void | SPI_SetFunctional (spiBASE_t *pNode, enum spiPinSelect bit, bool hardwareControlled) |
Sets the functional of a SPI pin. More... | |
Driver for the SPI module.
SPDX-License-Identifier: BSD-3-Clause
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
We kindly request you to use one or more of the following phrases to refer to foxBMS in your hardware, software, documentation or advertising materials:
Definition in file spi.c.
#define SPI_FLAG_REGISTER_TRANSMISSION_ERRORS (0x5Fu) |
STD_RETURN_TYPE_e SPI_DirectlyTransmitReceiveData | ( | SPI_INTERFACE_CONFIG_s * | pSpiInterface, |
uint16 * | pTxBuff, | ||
uint16 * | pRxBuff, | ||
uint32 | frameLength | ||
) |
Transmits and receives data on SPI without DMA.
This function can be used to send and receive data via SPI. SPI communication is performed in blocking mode but setting/resetting chip select and locking of the peripheral is not handled by this function. This must be ensured by the caller.
pSpiInterface | pointer to SPI interface configuration |
pTxBuff | pointer to data that is transmitted by the SPI interface |
pRxBuff | pointer to data that is received by the SPI interface |
frameLength | number of bytes to be transmitted by the SPI interface |
STD_RETURN_TYPE_e SPI_Lock | ( | uint8_t | spi | ) |
Locks SPI interfaces.
This function is used to change the state of the SPI_busy_flags variable to "locked".
spi | SPI interface to be locked (0-4 on the TMS570LC4357) |
Definition at line 407 of file spi.c.
void SPI_SetFunctional | ( | spiBASE_t * | pNode, |
enum spiPinSelect | bit, | ||
bool | hardwareControlled | ||
) |
Sets the functional of a SPI pin.
SPI pins in this HAL can have functional state SPI (for when it is controlled by the SPI hardware) and functional state GIO (for when it is controlled as a GIO pin).
[in,out] | pNode | handle of the SPI node that should be configured |
[in] | bit | bit that should be manipulated, other pins remain unchanged |
[in] | hardwareControlled | Whether the bit should be hardware controlled (true) or not (false) |
STD_RETURN_TYPE_e SPI_TransmitData | ( | SPI_INTERFACE_CONFIG_s * | pSpiInterface, |
uint16_t * | pTxBuff, | ||
uint32_t | frameLength | ||
) |
Sends data on SPI without DMA.
pSpiInterface | pointer to SPI interface configuration |
pTxBuff | pointer to data that is transmitted by the SPI interface |
frameLength | number of bytes to be transmitted by the SPI interface |
Definition at line 104 of file spi.c.
STD_RETURN_TYPE_e SPI_TransmitDataWithDummy | ( | SPI_INTERFACE_CONFIG_s * | pSpiInterface, |
uint32_t | delay, | ||
uint16_t * | pTxBuff, | ||
uint32_t | frameLength | ||
) |
Sends data on SPI without DMA, with wake-up byte.
It calls SPI_SendDummyByte() to wake-up the SPI interface.
pSpiInterface | pointer to SPI interface configuration |
delay | delay to wait after dummy byte transfer |
pTxBuff | pointer to data that is transmitted by the SPI interface |
frameLength | number of bytes to be transmitted by the SPI interface |
Definition at line 125 of file spi.c.
STD_RETURN_TYPE_e SPI_TransmitDummyByte | ( | SPI_INTERFACE_CONFIG_s * | pSpiInterface, |
uint32_t | delay | ||
) |
STD_RETURN_TYPE_e SPI_TransmitReceiveData | ( | SPI_INTERFACE_CONFIG_s * | pSpiInterface, |
uint16 * | pTxBuff, | ||
uint16 * | pRxBuff, | ||
uint32 | frameLength | ||
) |
Transmits and receives data on SPI without DMA.
This function can be used to send and receive data via SPI. SPI communication is performed in blocking mode and chip select is set/reset automatically.
pSpiInterface | pointer to SPI interface configuration |
pTxBuff | pointer to data that is transmitted by the SPI interface |
pRxBuff | pointer to data that is received by the SPI interface |
frameLength | number of bytes to be transmitted by the SPI interface |
Definition at line 142 of file spi.c.
STD_RETURN_TYPE_e SPI_TransmitReceiveDataDma | ( | SPI_INTERFACE_CONFIG_s * | pSpiInterface, |
uint16_t * | pTxBuff, | ||
uint16_t * | pRxBuff, | ||
uint32_t | frameLength | ||
) |
Transmits and receives data on SPI with DMA.
This function can be used to send and receive data via SPI. SPI communication is performed in blocking mode and chip select is set/reset automatically..
pSpiInterface | pointer to SPI interface configuration |
pTxBuff | pointer to data that is transmitted by the SPI interface |
pRxBuff | pointer to data that is received by the SPI interface |
frameLength | number of bytes to be transmitted by the SPI interface |
Definition at line 183 of file spi.c.
STD_RETURN_TYPE_e SPI_TransmitReceiveDataWithDummyDma | ( | SPI_INTERFACE_CONFIG_s * | pSpiInterface, |
uint32_t | delay, | ||
uint16_t * | pTxBuff, | ||
uint16_t * | pRxBuff, | ||
uint32_t | frameLength | ||
) |
Transmits and receives data on SPI with DMA.
This function can be used to send and receive data via SPI. SPI communication is performed in blocking mode and chip select is set/reset automatically. A dummy is sent first.
pSpiInterface | pointer to SPI interface configuration |
delay | delay to wait after dummy byte transfer |
pTxBuff | pointer to data that is transmitted by the SPI interface |
pRxBuff | pointer to data that is received by the SPI interface |
frameLength | number of bytes to be transmitted by the SPI interface |
Definition at line 291 of file spi.c.