foxBMS  1.1.0
The foxBMS Battery Management System API Documentation
spi_cfg.c File Reference

Configuration for the SPI module. More...

#include "spi_cfg.h"
Include dependency graph for spi_cfg.c:

Go to the source code of this file.

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

static const spiDAT1_t spi_kLtcDataConfig
 
SPI_INTERFACE_CONFIG_s spi_ltcInterface [BS_NR_OF_STRINGS]
 
static const spiDAT1_t spi_kMxmDataConfig
 
SPI_INTERFACE_CONFIG_s spi_MxmInterface
 
const spiDAT1_t spi_kNxp775DataConfig
 
SPI_INTERFACE_CONFIG_s spi_nxp775Interface
 
static const spiDAT1_t spi_kFramDataConfig
 
SPI_INTERFACE_CONFIG_s spi_framInterface
 
static const spiDAT1_t spi_kSpsDataConfigLowSpeed
 
static const spiDAT1_t spi_kSpsDataConfigHighSpeed
 
SPI_INTERFACE_CONFIG_s spi_spsInterface
 
static const spiDAT1_t spi_kAdcDataConfig
 
SPI_INTERFACE_CONFIG_s spi_adc0Interface
 
SPI_INTERFACE_CONFIG_s spi_adc1Interface
 
static const spiDAT1_t spi_kSbcDataConfig
 
SPI_INTERFACE_CONFIG_s spi_kSbcMcuInterface
 
SPI_INTERFACE_CONFIG_s spi_dmaTransmission []
 Variable used for SPI over DMA transmission. Retains the CS pin to deactivate in DMA callback. More...
 
uint32_t spi_saveFmt0 []
 
SPI_BUSY_STATE_e spi_busyFlags []
 
const uint8_t spi_nrBusyFlags = sizeof(spi_busyFlags) / sizeof(SPI_BUSY_STATE_e)
 

Detailed Description

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
2021-06-16 (date of last update)
Prefix
SPI

Definition in file spi_cfg.c.

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 297 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 302 of file spi_cfg.c.

Variable Documentation

◆ spi_adc0Interface

SPI_INTERFACE_CONFIG_s spi_adc0Interface
Initial value:
= {
.channel = SPI_Interface3,
.pConfig = &spi_kAdcDataConfig,
.pNode = spiREG3,
.pGioPort = &(spiREG3->PC3),
.csPin = 4u,
}
static const spiDAT1_t spi_kAdcDataConfig
Definition: spi_cfg.c:181
@ SPI_Interface3
Definition: spi_cfg.h:101

SPI interface configuration for ADC communication

Definition at line 190 of file spi_cfg.c.

◆ spi_adc1Interface

SPI_INTERFACE_CONFIG_s spi_adc1Interface
Initial value:
= {
.channel = SPI_Interface3,
.pConfig = &spi_kAdcDataConfig,
.pNode = spiREG3,
.pGioPort = &(spiREG3->PC3),
.csPin = 5u,
}

SPI interface configuration for ADC communication

Definition at line 199 of file spi_cfg.c.

◆ spi_busyFlags

SPI_BUSY_STATE_e spi_busyFlags[]
Initial value:

struct containing the lock state of the SPI interfaces

Definition at line 281 of file spi_cfg.c.

◆ spi_dmaTransmission

SPI_INTERFACE_CONFIG_s spi_dmaTransmission[]

Variable used for SPI over DMA transmission. Retains the CS pin to deactivate in DMA callback.

Definition at line 229 of file spi_cfg.c.

◆ spi_framInterface

SPI_INTERFACE_CONFIG_s spi_framInterface
Initial value:
= {
.channel = SPI_Interface3,
.pConfig = &spi_kFramDataConfig,
.pNode = spiREG3,
.pGioPort = &(spiREG3->PC3),
.csPin = 0u,
}
static const spiDAT1_t spi_kFramDataConfig
Definition: spi_cfg.c:136

SPI interface configuration for FRAM communication

Definition at line 145 of file spi_cfg.c.

◆ spi_kAdcDataConfig

const spiDAT1_t spi_kAdcDataConfig
static
Initial value:
= {
.CS_HOLD = FALSE,
.WDEL = TRUE,
.DFSEL = SPI_FMT_2,
.CSNR = 0x0,
}

SPI data configuration struct for ADC communication

Definition at line 181 of file spi_cfg.c.

◆ spi_kFramDataConfig

const spiDAT1_t spi_kFramDataConfig
static
Initial value:
= {
.CS_HOLD = FALSE,
.WDEL = TRUE,
.DFSEL = SPI_FMT_1,
.CSNR = 0x0,
}

SPI data configuration struct for FRAM communication

Definition at line 136 of file spi_cfg.c.

◆ spi_kLtcDataConfig

const spiDAT1_t spi_kLtcDataConfig
static
Initial value:
= {
.CS_HOLD = FALSE,
.WDEL = TRUE,
.DFSEL = SPI_FMT_0,
.CSNR = 0x0,
}

SPI data configuration struct for LTC communication

Definition at line 64 of file spi_cfg.c.

◆ spi_kMxmDataConfig

const spiDAT1_t spi_kMxmDataConfig
static
Initial value:
= {
.CS_HOLD = FALSE,
.WDEL = TRUE,
.DFSEL = SPI_FMT_1,
.CSNR = 0x00,
}

SPI data configuration struct for MXM communication

Definition at line 102 of file spi_cfg.c.

◆ spi_kNxp775DataConfig

const spiDAT1_t spi_kNxp775DataConfig
Initial value:
= {
.CS_HOLD = FALSE,
.WDEL = TRUE,
.DFSEL = SPI_FMT_0,
.CSNR = 0x0,
}

SPI data configuration struct for NXP MC33775A communication

Definition at line 119 of file spi_cfg.c.

◆ spi_kSbcDataConfig

const spiDAT1_t spi_kSbcDataConfig
static
Initial value:
= {
.CS_HOLD = FALSE,
.WDEL = TRUE,
.DFSEL = SPI_FMT_0,
.CSNR = 0x0,
}

SPI configuration struct for SBC communication

Definition at line 208 of file spi_cfg.c.

◆ spi_kSbcMcuInterface

SPI_INTERFACE_CONFIG_s spi_kSbcMcuInterface
Initial value:
= {
.channel = SPI_Interface2,
.pConfig = &spi_kSbcDataConfig,
.pNode = spiREG2,
.pGioPort = &(spiREG2->PC3),
.csPin = 0u,
}
static const spiDAT1_t spi_kSbcDataConfig
Definition: spi_cfg.c:208
@ SPI_Interface2
Definition: spi_cfg.h:100

SPI interface configuration for SBC communication

Definition at line 217 of file spi_cfg.c.

◆ spi_kSpsDataConfigHighSpeed

const spiDAT1_t spi_kSpsDataConfigHighSpeed
static
Initial value:
= {
.CS_HOLD = FALSE,
.WDEL = TRUE,
.DFSEL = SPI_FMT_2,
.CSNR = 0x0,
}

SPI data configuration struct for SPS communication in high speed (10MHz)

Definition at line 163 of file spi_cfg.c.

◆ spi_kSpsDataConfigLowSpeed

const spiDAT1_t spi_kSpsDataConfigLowSpeed
static
Initial value:
= {
.CS_HOLD = FALSE,
.WDEL = TRUE,
.DFSEL = SPI_FMT_1,
.CSNR = 0x0,
}

SPI data configuration struct for SPS communication in low speed (4MHz)

Definition at line 154 of file spi_cfg.c.

◆ spi_ltcInterface

Initial value:
= {
{
.channel = SPI_Interface1,
.pConfig = &spi_kLtcDataConfig,
.pNode = spiREG1,
.pGioPort = &(spiREG1->PC3),
.csPin = 2u,
},
{
.channel = SPI_Interface1,
.pConfig = &spi_kLtcDataConfig,
.pNode = spiREG1,
.pGioPort = &(spiREG1->PC3),
.csPin = 2u,
},
{
.channel = SPI_Interface1,
.pConfig = &spi_kLtcDataConfig,
.pNode = spiREG1,
.pGioPort = &(spiREG1->PC3),
.csPin = 2u,
},
}
static const spiDAT1_t spi_kLtcDataConfig
Definition: spi_cfg.c:64
@ SPI_Interface1
Definition: spi_cfg.h:99

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

Definition at line 77 of file spi_cfg.c.

◆ spi_MxmInterface

SPI_INTERFACE_CONFIG_s spi_MxmInterface
Initial value:
= {
.channel = SPI_Interface4,
.pConfig = &spi_kMxmDataConfig,
.pNode = spiREG4,
.pGioPort = &(spiREG4->PC3),
.csPin = 0u,
}
static const spiDAT1_t spi_kMxmDataConfig
Definition: spi_cfg.c:102
@ SPI_Interface4
Definition: spi_cfg.h:102

SPI interface configuration for MXM communication

Definition at line 110 of file spi_cfg.c.

◆ spi_nrBusyFlags

const uint8_t spi_nrBusyFlags = sizeof(spi_busyFlags) / sizeof(SPI_BUSY_STATE_e)

size of spi_busyFlags

Definition at line 290 of file spi_cfg.c.

◆ spi_nxp775Interface

SPI_INTERFACE_CONFIG_s spi_nxp775Interface
Initial value:
= {
.channel = SPI_Interface1,
.pConfig = &spi_kNxp775DataConfig,
.pNode = spiREG1,
.pGioPort = &(spiREG1->PC3),
.csPin = 2u,
}
const spiDAT1_t spi_kNxp775DataConfig
Definition: spi_cfg.c:119

SPI interface configuration for N775 communication

Definition at line 127 of file spi_cfg.c.

◆ spi_saveFmt0

uint32_t spi_saveFmt0[]
Initial value:
= {
0U,
0U,
0U,
0U,
0U,
}

With DMA, only FMT0 can be used. This table stores the existing FMT0. The wanted FMT is then copied in FMT0. In the DMA callback, the existing FMT0 is restored with this table.

Definition at line 272 of file spi_cfg.c.

◆ spi_spsInterface

SPI_INTERFACE_CONFIG_s spi_spsInterface
Initial value:
= {
.channel = SPI_Interface2,
.pNode = spiREG2,
.pGioPort = &SPS_SPI_CS_GIOPORT,
.csPin = SPS_SPI_CS_PIN,
}
static const spiDAT1_t spi_kSpsDataConfigLowSpeed
Definition: spi_cfg.c:154
#define SPS_SPI_CS_PIN
Definition: spi_cfg.h:75
#define SPS_SPI_CS_GIOPORT
Definition: spi_cfg.h:73

SPI interface configuration for SPS communication

Definition at line 172 of file spi_cfg.c.