foxBMS-UnitTests  1.0.0
The foxBMS Unit Tests API Documentation
spi_cfg.h
Go to the documentation of this file.
1 /**
2  *
3  * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der
4  * angewandten Forschung e.V. All rights reserved.
5  *
6  * BSD 3-Clause License
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions are met:
9  * 1. Redistributions of source code must retain the above copyright notice,
10  * this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the distribution.
14  * 3. Neither the name of the copyright holder nor the names of its
15  * contributors may be used to endorse or promote products derived from
16  * this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28  * POSSIBILITY OF SUCH DAMAGE.
29  *
30  * We kindly request you to use one or more of the following phrases to refer
31  * to foxBMS in your hardware, software, documentation or advertising
32  * materials:
33  *
34  * ″This product uses parts of foxBMS®″
35  *
36  * ″This product includes parts of foxBMS®″
37  *
38  * ″This product is derived from foxBMS®″
39  *
40  */
41 
42 /**
43  * @file spi_cfg.h
44  * @author foxBMS Team
45  * @date 2020-03-05 (date of creation)
46  * @updated 2020-03-05 (date of last update)
47  * @ingroup DRIVERS_CONFIGURATION
48  * @prefix SPI
49  *
50  * @brief Headers for the configuration for the SPI module
51  *
52  *
53  */
54 
55 #ifndef FOXBMS__SPI_CFG_H_
56 #define FOXBMS__SPI_CFG_H_
57 
58 /*========== Includes =======================================================*/
59 #include "general.h"
60 
61 #include "battery_system_cfg.h"
62 
63 #include "HL_het.h"
64 #include "HL_spi.h"
65 
66 /*========== Macros and Definitions =========================================*/
67 
68 /* TODO: check definition of SPI nodes depending on target hardware */
69 /** SPI defines for LTC */
70 #define LTC_SPI_NODE (spiREG1)
71 
72 /** GIO defines for SPI for Smart Power Switches @{ */
73 #define SPS_SPI_CS_GIOPORT (hetREG2->DOUT)
74 #define SPS_SPI_CS_GIOPORT_DIR (hetREG2->DIR)
75 #define SPS_SPI_CS_PIN (1u)
76 /**@}*/
77 
78 /**
79  * SPI defines for NXP MC33775A
80  * @{
81  */
82 #define N775_SPI_TX_NODE (spiREG1)
83 #define N775_SPI_TX_GIOPORT (N775_SPI_TX_NODE->PC3)
84 #define N775_SPI_TX_CS_PIN (2U)
85 
86 #define N775_SPI_RX_NODE (spiREG5)
87 #define N775_SPI_RX_GIOPORT (N775_SPI_TX_NODE->PC3)
88 #define N775_SPI_RX_CS_PIN (2U)
89 /**@}*/
90 
91 /** enum for spi interface state */
92 typedef enum SPI_BUSY_STATE {
96 
97 /** spi block identification numbers */
98 typedef enum SPI_INTERFACE {
105 
106 /** configuration of the SPI interface */
107 typedef struct SPI_INTERFACE_CONFIG {
109  const spiDAT1_t *pConfig;
110  spiBASE_t *pNode;
111  volatile uint32_t *pGioPort;
112  uint32_t csPin;
114 
115 /*========== Extern Constant and Variable Declarations ======================*/
116 extern const spiDAT1_t spi_kNxp775DataConfig;
117 
127 
128 extern uint32_t spi_saveFmt0[];
129 
131 
132 extern const uint8_t spi_nrBusyFlags;
133 
134 /*========== Extern Function Prototypes =====================================*/
135 /**
136  * @brief Switch the SPS spi handle to high speed
137  * @param[out] pSpiSpsInterface handle of the SPS spi config
138  */
139 extern void SPI_SpsInterfaceSwitchToHighSpeed(SPI_INTERFACE_CONFIG_s *pSpiSpsInterface);
140 
141 /**
142  * @brief Switch the SPS spi handle to low speed
143  * @param[out] pSpiSpsInterface handle of the SPS spi config
144  */
145 extern void SPI_SpsInterfaceSwitchToLowSpeed(SPI_INTERFACE_CONFIG_s *pSpiSpsInterface);
146 
147 /*========== Externalized Static Functions Prototypes (Unit Test) ===========*/
148 
149 #endif /* FOXBMS__SPI_CFG_H_ */
spi_kSbcMcuInterface
SPI_INTERFACE_CONFIG_s spi_kSbcMcuInterface
Definition: spi_cfg.c:217
general.h
TODO.
SPI_BUSY
@ SPI_BUSY
Definition: spi_cfg.h:94
SPI_INTERFACE_CONFIG::pGioPort
volatile uint32_t * pGioPort
Definition: spi_cfg.h:111
spi_MxmInterface
SPI_INTERFACE_CONFIG_s spi_MxmInterface
Definition: spi_cfg.c:110
SPI_IDLE
@ SPI_IDLE
Definition: spi_cfg.h:93
SPI_INTERFACE_CONFIG::channel
SPI_INTERFACE_e channel
Definition: spi_cfg.h:108
spi_framInterface
SPI_INTERFACE_CONFIG_s spi_framInterface
Definition: spi_cfg.c:145
SPI_SpsInterfaceSwitchToHighSpeed
void SPI_SpsInterfaceSwitchToHighSpeed(SPI_INTERFACE_CONFIG_s *pSpiSpsInterface)
Switch the SPS spi handle to high speed.
Definition: spi_cfg.c:297
battery_system_cfg.h
Configuration of the battery system (e.g., number of battery modules, battery cells,...
SPI_Interface2
@ SPI_Interface2
Definition: spi_cfg.h:100
spi_adc1Interface
SPI_INTERFACE_CONFIG_s spi_adc1Interface
Definition: spi_cfg.c:199
SPI_Interface3
@ SPI_Interface3
Definition: spi_cfg.h:101
SPI_INTERFACE_CONFIG::pNode
spiBASE_t * pNode
Definition: spi_cfg.h:110
spi_adc0Interface
SPI_INTERFACE_CONFIG_s spi_adc0Interface
Definition: spi_cfg.c:190
SPI_Interface5
@ SPI_Interface5
Definition: spi_cfg.h:103
spi_saveFmt0
uint32_t spi_saveFmt0[]
Definition: spi_cfg.c:272
SPI_Interface1
@ SPI_Interface1
Definition: spi_cfg.h:99
spi_spsInterface
SPI_INTERFACE_CONFIG_s spi_spsInterface
Definition: spi_cfg.c:172
SPI_INTERFACE_CONFIG
Definition: spi_cfg.h:107
spi_nrBusyFlags
const uint8_t spi_nrBusyFlags
Definition: spi_cfg.c:290
SPI_INTERFACE
SPI_INTERFACE
Definition: spi_cfg.h:98
spi_ltcInterface
SPI_INTERFACE_CONFIG_s spi_ltcInterface[BS_NR_OF_STRINGS]
Definition: spi_cfg.c:77
SPI_INTERFACE_CONFIG::pConfig
const spiDAT1_t * pConfig
Definition: spi_cfg.h:109
SPI_BUSY_STATE_e
enum SPI_BUSY_STATE SPI_BUSY_STATE_e
SPI_Interface4
@ SPI_Interface4
Definition: spi_cfg.h:102
SPI_INTERFACE_CONFIG::csPin
uint32_t csPin
Definition: spi_cfg.h:112
SPI_SpsInterfaceSwitchToLowSpeed
void SPI_SpsInterfaceSwitchToLowSpeed(SPI_INTERFACE_CONFIG_s *pSpiSpsInterface)
Switch the SPS spi handle to low speed.
Definition: spi_cfg.c:302
SPI_INTERFACE_CONFIG_s
struct SPI_INTERFACE_CONFIG SPI_INTERFACE_CONFIG_s
SPI_BUSY_STATE
SPI_BUSY_STATE
Definition: spi_cfg.h:92
spi_kNxp775DataConfig
const spiDAT1_t spi_kNxp775DataConfig
Definition: spi_cfg.c:119
SPI_INTERFACE_e
enum SPI_INTERFACE SPI_INTERFACE_e
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: spi_cfg.c:229
spi_busyFlags
SPI_BUSY_STATE_e spi_busyFlags[]
Definition: spi_cfg.c:281
BS_NR_OF_STRINGS
#define BS_NR_OF_STRINGS
Definition: battery_system_cfg.h:89
spi_nxp775Interface
SPI_INTERFACE_CONFIG_s spi_nxp775Interface
Definition: spi_cfg.c:127