foxBMS  1.6.0
The foxBMS Battery Management System API Documentation
spi_cfg.h File Reference

Headers for the configuration for the SPI module. More...

#include "battery_system_cfg.h"
#include "HL_het.h"
#include "HL_spi.h"
#include <stdint.h>
Include dependency graph for spi_cfg.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  SPI_INTERFACE_CONFIG_s
 

Macros

#define SPI_NR_SPI_INTERFACES   (5u)
 
#define SPI_CSHOLD_BIT   (0x10000000u)
 
#define SPI_WDEL_BIT   (0x04000000u)
 
#define SPI_HARDWARE_CHIP_SELECT_FIELD_POSITION   (16u)
 
#define SPI_DATA_FORMAT_FIELD_POSITION   (24u)
 
#define SPI_TX_BUFFER_EMPTY_FLAG_POSITION   (9u)
 
#define SPI_PC0_CLEAR_HW_CS_MASK   (0xFFFFFF00u)
 
#define SPI_TX_EMPTY_TIMEOUT_ITERATIONS   (6000u)
 
#define SPI_MAX_NUMBER_HW_CS   (6u)
 
#define SPI_SBC_MCU_CHIP_SELECT_PIN   (0u)
 
#define SPI_ADI_CHIP_SELECT_PIN   (1u)
 
#define SPI_LTC_CHIP_SELECT_PIN   (1u)
 
#define SPI_MAXIM_CHIP_SELECT_PIN   (0u)
 
#define SPI_FRAM_CHIP_SELECT_PIN   (1u)
 
#define SPI_SPI1_INDEX   (0u)
 
#define SPI_SPI2_INDEX   (1u)
 
#define SPI_SPI3_INDEX   (2u)
 
#define SPI_SPI4_INDEX   (3u)
 
#define SPI_SPI5_INDEX   (4u)
 
#define SPI_NXP_TX_CHIP_SELECT_PIN   (1u)
 
#define SPI_NXP_RX_CHIP_SELECT_PIN   (0u)
 
#define SPI_SPS_CS_GIOPORT   (hetREG2->DOUT)
 
#define SPI_SPS_CS_GIOPORT_DIR   (hetREG2->DIR)
 
#define SPI_SPS_CS_PIN   (1u) /* Connected to pin 1 of HET register */
 

Enumerations

enum  SPI_BUSY_STATE_e { SPI_IDLE , SPI_BUSY }
 
enum  SPI_CHIP_SELECT_TYPE_e { SPI_CHIP_SELECT_HARDWARE , SPI_CHIP_SELECT_SOFTWARE , SPI_CHIP_SELECT_MAX }
 

Functions

void SPI_SpsInterfaceSwitchToHighSpeed (SPI_INTERFACE_CONFIG_s *pSpiSpsInterface)
 Switch the SPS spi handle to high speed. More...
 
void SPI_SpsInterfaceSwitchToLowSpeed (SPI_INTERFACE_CONFIG_s *pSpiSpsInterface)
 Switch the SPS spi handle to low speed. More...
 

Variables

SPI_INTERFACE_CONFIG_s spi_adiInterface [BS_NR_OF_STRINGS]
 
SPI_INTERFACE_CONFIG_s spi_ltcInterface [BS_NR_OF_STRINGS]
 
SPI_INTERFACE_CONFIG_s spi_mxmInterface
 
SPI_INTERFACE_CONFIG_s spi_nxp775InterfaceTx [BS_NR_OF_STRINGS]
 
SPI_INTERFACE_CONFIG_s spi_nxp775InterfaceRx [BS_NR_OF_STRINGS]
 
SPI_INTERFACE_CONFIG_s spi_framInterface
 
SPI_INTERFACE_CONFIG_s spi_spsInterface
 
SPI_INTERFACE_CONFIG_s spi_sbcMcuInterface
 
SPI_BUSY_STATE_e spi_busyFlags []
 
const uint8_t spi_nrBusyFlags
 

Detailed Description

Headers for the configuration 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:

  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
2020-03-05 (date of creation)
Updated
2023-10-12 (date of last update)
Version
v1.6.0
Prefix
SPI

Definition in file spi_cfg.h.

Macro Definition Documentation

◆ SPI_ADI_CHIP_SELECT_PIN

#define SPI_ADI_CHIP_SELECT_PIN   (1u)

ADI chip select pin

Definition at line 136 of file spi_cfg.h.

◆ SPI_CSHOLD_BIT

#define SPI_CSHOLD_BIT   (0x10000000u)

Bit in SPIDAT1 register that activates hardware Chip Select hold

Definition at line 82 of file spi_cfg.h.

◆ SPI_DATA_FORMAT_FIELD_POSITION

#define SPI_DATA_FORMAT_FIELD_POSITION   (24u)

Position of DFSEL field in SPIDAT1 register

Definition at line 91 of file spi_cfg.h.

◆ SPI_FRAM_CHIP_SELECT_PIN

#define SPI_FRAM_CHIP_SELECT_PIN   (1u)

FRAM chip select pin

Definition at line 150 of file spi_cfg.h.

◆ SPI_HARDWARE_CHIP_SELECT_FIELD_POSITION

#define SPI_HARDWARE_CHIP_SELECT_FIELD_POSITION   (16u)

Position of CSNR field in SPIDAT1 register

Definition at line 88 of file spi_cfg.h.

◆ SPI_LTC_CHIP_SELECT_PIN

#define SPI_LTC_CHIP_SELECT_PIN   (1u)

LTC chip select pin

Definition at line 139 of file spi_cfg.h.

◆ SPI_MAX_NUMBER_HW_CS

#define SPI_MAX_NUMBER_HW_CS   (6u)

Max number of hardware chip select pins

Definition at line 103 of file spi_cfg.h.

◆ SPI_MAXIM_CHIP_SELECT_PIN

#define SPI_MAXIM_CHIP_SELECT_PIN   (0u)

Maxim chip select pin

Definition at line 142 of file spi_cfg.h.

◆ SPI_NR_SPI_INTERFACES

#define SPI_NR_SPI_INTERFACES   (5u)

Definition at line 79 of file spi_cfg.h.

◆ SPI_NXP_RX_CHIP_SELECT_PIN

#define SPI_NXP_RX_CHIP_SELECT_PIN   (0u)

NXP chip select pin

Definition at line 146 of file spi_cfg.h.

◆ SPI_NXP_TX_CHIP_SELECT_PIN

#define SPI_NXP_TX_CHIP_SELECT_PIN   (1u)

NXP chip select pin

Definition at line 145 of file spi_cfg.h.

◆ SPI_PC0_CLEAR_HW_CS_MASK

#define SPI_PC0_CLEAR_HW_CS_MASK   (0xFFFFFF00u)

Mask used to clear all HW CS bits

Definition at line 97 of file spi_cfg.h.

◆ SPI_SBC_MCU_CHIP_SELECT_PIN

#define SPI_SBC_MCU_CHIP_SELECT_PIN   (0u)

SBC MCU chip select pin

Definition at line 106 of file spi_cfg.h.

◆ SPI_SPI1_INDEX

#define SPI_SPI1_INDEX   (0u)

Index for the SPI nodes

Definition at line 71 of file spi_cfg.h.

◆ SPI_SPI2_INDEX

#define SPI_SPI2_INDEX   (1u)

Index for the SPI nodes

Definition at line 72 of file spi_cfg.h.

◆ SPI_SPI3_INDEX

#define SPI_SPI3_INDEX   (2u)

Index for the SPI nodes

Definition at line 73 of file spi_cfg.h.

◆ SPI_SPI4_INDEX

#define SPI_SPI4_INDEX   (3u)

Index for the SPI nodes

Definition at line 74 of file spi_cfg.h.

◆ SPI_SPI5_INDEX

#define SPI_SPI5_INDEX   (4u)

Index for the SPI nodes

Definition at line 75 of file spi_cfg.h.

◆ SPI_SPS_CS_GIOPORT

#define SPI_SPS_CS_GIOPORT   (hetREG2->DOUT)

GIO defines for SPI for Smart Power Switches

Definition at line 153 of file spi_cfg.h.

◆ SPI_SPS_CS_GIOPORT_DIR

#define SPI_SPS_CS_GIOPORT_DIR   (hetREG2->DIR)

GIO defines for SPI for Smart Power Switches

Definition at line 154 of file spi_cfg.h.

◆ SPI_SPS_CS_PIN

#define SPI_SPS_CS_PIN   (1u) /* Connected to pin 1 of HET register */

GIO defines for SPI for Smart Power Switches

Definition at line 155 of file spi_cfg.h.

◆ SPI_TX_BUFFER_EMPTY_FLAG_POSITION

#define SPI_TX_BUFFER_EMPTY_FLAG_POSITION   (9u)

Position of TX buffer empty flag in SPIFLG register

Definition at line 94 of file spi_cfg.h.

◆ SPI_TX_EMPTY_TIMEOUT_ITERATIONS

#define SPI_TX_EMPTY_TIMEOUT_ITERATIONS   (6000u)

Time to avoid infinite loop when waiting for Tx empty flag in a while loop

Definition at line 100 of file spi_cfg.h.

◆ SPI_WDEL_BIT

#define SPI_WDEL_BIT   (0x04000000u)

Bit in SPIDAT1 register that activates delay between words

Definition at line 85 of file spi_cfg.h.

Enumeration Type Documentation

◆ SPI_BUSY_STATE_e

enum for spi interface state

Enumerator
SPI_IDLE 
SPI_BUSY 

Definition at line 109 of file spi_cfg.h.

◆ SPI_CHIP_SELECT_TYPE_e

type of chip select for spi

Enumerator
SPI_CHIP_SELECT_HARDWARE 
SPI_CHIP_SELECT_SOFTWARE 
SPI_CHIP_SELECT_MAX 

Definition at line 116 of file spi_cfg.h.

Function Documentation

◆ SPI_SpsInterfaceSwitchToHighSpeed()

void SPI_SpsInterfaceSwitchToHighSpeed ( SPI_INTERFACE_CONFIG_s pSpiSpsInterface)

Switch the SPS spi handle to high speed.

Parameters
[out]pSpiSpsInterfacehandle of the SPS spi config

Definition at line 280 of file spi_cfg.c.

◆ SPI_SpsInterfaceSwitchToLowSpeed()

void SPI_SpsInterfaceSwitchToLowSpeed ( SPI_INTERFACE_CONFIG_s pSpiSpsInterface)

Switch the SPS spi handle to low speed.

Parameters
[out]pSpiSpsInterfacehandle of the SPS spi config

Definition at line 285 of file spi_cfg.c.

Variable Documentation

◆ spi_adiInterface

SPI_INTERFACE_CONFIG_s spi_adiInterface[BS_NR_OF_STRINGS]
extern

SPI interface configuration for ADI communication This is a list of structs because of multistring

Definition at line 181 of file spi_cfg.c.

◆ spi_busyFlags

SPI_BUSY_STATE_e spi_busyFlags[]
extern

struct containing the lock state of the SPI interfaces

Definition at line 264 of file spi_cfg.c.

◆ spi_framInterface

SPI_INTERFACE_CONFIG_s spi_framInterface
extern

SPI interface configuration for FRAM communication

Definition at line 237 of file spi_cfg.c.

◆ spi_ltcInterface

SPI_INTERFACE_CONFIG_s spi_ltcInterface[BS_NR_OF_STRINGS]
extern

SPI interface configuration for LTC communication This is a list of structs because of multistring

Definition at line 195 of file spi_cfg.c.

◆ spi_mxmInterface

SPI_INTERFACE_CONFIG_s spi_mxmInterface
extern

SPI interface configuration for MXM communication

Definition at line 206 of file spi_cfg.c.

◆ spi_nrBusyFlags

const uint8_t spi_nrBusyFlags
extern

size of spi_busyFlags

Definition at line 273 of file spi_cfg.c.

◆ spi_nxp775InterfaceRx

SPI_INTERFACE_CONFIG_s spi_nxp775InterfaceRx[BS_NR_OF_STRINGS]
extern

SPI interface configuration for N775 communication, Rx part

Definition at line 226 of file spi_cfg.c.

◆ spi_nxp775InterfaceTx

SPI_INTERFACE_CONFIG_s spi_nxp775InterfaceTx[BS_NR_OF_STRINGS]
extern

SPI interface configuration for N775 communication Tx part

Definition at line 215 of file spi_cfg.c.

◆ spi_sbcMcuInterface

SPI_INTERFACE_CONFIG_s spi_sbcMcuInterface
extern

SPI interface configuration for SBC communication

Definition at line 255 of file spi_cfg.c.

◆ spi_spsInterface

SPI_INTERFACE_CONFIG_s spi_spsInterface
extern

SPI interface configuration for SPS communication

Definition at line 246 of file spi_cfg.c.