foxBMS - Unit Tests  1.1.2
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 angewandten Forschung e.V.
4  * All rights reserved.
5  *
6  * SPDX-License-Identifier: BSD-3-Clause
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions are met:
10  *
11  * 1. Redistributions of source code must retain the above copyright notice, this
12  * list of conditions and the following disclaimer.
13  *
14  * 2. Redistributions in binary form must reproduce the above copyright notice,
15  * this list of conditions and the following disclaimer in the documentation
16  * and/or other materials provided with the distribution.
17  *
18  * 3. Neither the name of the copyright holder nor the names of its
19  * contributors may be used to endorse or promote products derived from
20  * this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
26  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  *
33  * We kindly request you to use one or more of the following phrases to refer to
34  * foxBMS in your hardware, software, documentation or advertising materials:
35  *
36  * - ″This product uses parts of foxBMS®″
37  * - ″This product includes parts of foxBMS®″
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_ */
Configuration of the battery system (e.g., number of battery modules, battery cells,...
#define BS_NR_OF_STRINGS
General macros and definitions for the whole platform.
void SPI_SpsInterfaceSwitchToLowSpeed(SPI_INTERFACE_CONFIG_s *pSpiSpsInterface)
Switch the SPS spi handle to low speed.
Definition: spi_cfg.c:302
SPI_BUSY_STATE
Definition: spi_cfg.h:92
@ SPI_IDLE
Definition: spi_cfg.h:93
@ SPI_BUSY
Definition: spi_cfg.h:94
SPI_INTERFACE_CONFIG_s spi_MxmInterface
Definition: spi_cfg.c:110
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_INTERFACE_CONFIG_s spi_adc0Interface
Definition: spi_cfg.c:190
SPI_INTERFACE_CONFIG_s spi_kSbcMcuInterface
Definition: spi_cfg.c:217
const spiDAT1_t spi_kNxp775DataConfig
Definition: spi_cfg.c:119
SPI_BUSY_STATE_e spi_busyFlags[]
Definition: spi_cfg.c:281
SPI_INTERFACE_CONFIG_s spi_nxp775Interface
Definition: spi_cfg.c:127
enum SPI_BUSY_STATE SPI_BUSY_STATE_e
SPI_INTERFACE_CONFIG_s spi_framInterface
Definition: spi_cfg.c:145
uint32_t spi_saveFmt0[]
Definition: spi_cfg.c:272
SPI_INTERFACE_CONFIG_s spi_adc1Interface
Definition: spi_cfg.c:199
void SPI_SpsInterfaceSwitchToHighSpeed(SPI_INTERFACE_CONFIG_s *pSpiSpsInterface)
Switch the SPS spi handle to high speed.
Definition: spi_cfg.c:297
struct SPI_INTERFACE_CONFIG SPI_INTERFACE_CONFIG_s
SPI_INTERFACE
Definition: spi_cfg.h:98
@ SPI_Interface3
Definition: spi_cfg.h:101
@ SPI_Interface5
Definition: spi_cfg.h:103
@ SPI_Interface2
Definition: spi_cfg.h:100
@ SPI_Interface4
Definition: spi_cfg.h:102
@ SPI_Interface1
Definition: spi_cfg.h:99
SPI_INTERFACE_CONFIG_s spi_ltcInterface[BS_NR_OF_STRINGS]
Definition: spi_cfg.c:77
const uint8_t spi_nrBusyFlags
Definition: spi_cfg.c:290
SPI_INTERFACE_CONFIG_s spi_spsInterface
Definition: spi_cfg.c:172
enum SPI_INTERFACE SPI_INTERFACE_e
const spiDAT1_t * pConfig
Definition: spi_cfg.h:109
SPI_INTERFACE_e channel
Definition: spi_cfg.h:108
spiBASE_t * pNode
Definition: spi_cfg.h:110
volatile uint32_t * pGioPort
Definition: spi_cfg.h:111