The foxBMS secondary mcu API documentation
spi.c File Reference

Driver for the serial peripheral interface module (encapsulation of some HAL functions) More...

#include "spi.h"
#include "mcu.h"
Include dependency graph for spi.c:

Functions

void SPI_Wait (void)
 
STD_RETURN_TYPE_e SPI_SendDummyByte (uint8_t busID, SPI_HandleType_s *hspi)
 
void SPI_Init (SPI_HandleType_s *hspi)
 initializes the SPI module. More...
 
void HAL_SPI_TxRxCpltCallback (SPI_HandleType_s *hspi)
 callback SPI transmit and receive complete from SPI-Interrupt More...
 
void HAL_SPI_TxCpltCallback (SPI_HandleType_s *hspi)
 callback SPI transmit complete from SPI-Interrupt More...
 
void SPI_SetCS (uint8_t busID)
 sets Chip Select low to start SPI transmission. More...
 
void SPI_UnsetCS (uint8_t busID)
 sets Chip Select high to end SPI transmission. More...
 
STD_RETURN_TYPE_e SPI_Transmit (SPI_HandleType_s *hspi, uint8_t *pData, uint16_t Size)
 transmits through SPI without receiving data. More...
 
STD_RETURN_TYPE_e SPI_TransmitReceive (SPI_HandleType_s *hspi, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size)
 transmits and receives data through SPI. More...
 
STD_RETURN_TYPE_e SPI_IsTransmitOngoing (void)
 gets the SPI transmit status. More...
 
void SPI_SetTransmitOngoing (void)
 sets the SPI transmit status. More...
 

Variables

static SPI_STATE_s spi_state
 
const uint8_t spi_cmdDummy [1] ={0x00}
 

Detailed Description

Driver for the serial peripheral interface module (encapsulation of some HAL functions)

BSD 3-Clause License Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

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:

″This product uses parts of foxBMS®″

″This product includes parts of foxBMS®″

″This product is derived from foxBMS®″

Author
foxBMS Team
Date
02.10.2015 (date of creation)
Module-prefix SPI

Function Documentation

◆ HAL_SPI_TxCpltCallback()

void HAL_SPI_TxCpltCallback ( SPI_HandleType_s hspi)

callback SPI transmit complete from SPI-Interrupt

Parameters
hspipointer to SPI hardware handle
Here is the call graph for this function:

◆ HAL_SPI_TxRxCpltCallback()

void HAL_SPI_TxRxCpltCallback ( SPI_HandleType_s hspi)

callback SPI transmit and receive complete from SPI-Interrupt

Parameters
hspipointer to SPI hardware handle
Here is the call graph for this function:

◆ SPI_Init()

void SPI_Init ( SPI_HandleType_s hspi)

initializes the SPI module.

This function initializes the SPI channels according to the configuration given as parameter.

Parameters
*hspipointer to the spi configuration

◆ SPI_IsTransmitOngoing()

STD_RETURN_TYPE_e SPI_IsTransmitOngoing ( void  )

gets the SPI transmit status.

Returns
retval TRUE if transmission still ongoing, FALSE otherwise

◆ SPI_SendDummyByte()

STD_RETURN_TYPE_e SPI_SendDummyByte ( uint8_t  busID,
SPI_HandleType_s hspi 
)

sends a dummy byte on SPI.

Parameters
busIDselects which CS pin has to be set high
*hspipointer to SPI hardware handle
Returns
E_OK if SPI transmission is OK, E_NOT_OK otherwise

◆ SPI_SetCS()

void SPI_SetCS ( uint8_t  busID)

sets Chip Select low to start SPI transmission.

This function sets CS low in case CS is driven by software.

Parameters
busIDselects which CS pin has to be set low
Here is the call graph for this function:

◆ SPI_SetTransmitOngoing()

void SPI_SetTransmitOngoing ( void  )

sets the SPI transmit status.

◆ SPI_Transmit()

STD_RETURN_TYPE_e SPI_Transmit ( SPI_HandleType_s hspi,
uint8_t *  pData,
uint16_t  Size 
)

transmits through SPI without receiving data.

Parameters
*hspipointer to SPI hardware handle
*pDatadata to be sent
Sizesize of the data to be sent
Returns
E_OK if SPI transmission is OK, E_NOT_OK otherwise
Here is the call graph for this function:

◆ SPI_TransmitReceive()

STD_RETURN_TYPE_e SPI_TransmitReceive ( SPI_HandleType_s hspi,
uint8_t *  pTxData,
uint8_t *  pRxData,
uint16_t  Size 
)

transmits and receives data through SPI.

Parameters
*hspipointer to SPI hardware handle
*pTxDatadata to be sent
*pRxDatadata to be received
Sizesize of the data to be sent/received
Returns
E_OK if SPI transmission is OK, E_NOT_OK otherwise
Here is the call graph for this function:

◆ SPI_UnsetCS()

void SPI_UnsetCS ( uint8_t  busID)

sets Chip Select high to end SPI transmission.

This function sets CS high in case CS is driven by software. It is typically called in the callback routine of SPI transmission.

Parameters
busIDselects which CS pin has to be set high
Here is the call graph for this function:

◆ SPI_Wait()

void SPI_Wait ( void  )

waits a defined time.

Here is the call graph for this function:

Variable Documentation

◆ spi_cmdDummy

const uint8_t spi_cmdDummy[1] ={0x00}

◆ spi_state

SPI_STATE_s spi_state
static
Initial value:
= {
.transmit_ongoing = FALSE,
.dummyByte_ongoing = FALSE,
.counter = 0,
}
#define FALSE
Definition: std_types.h:65

contains variables used by the SPI driver