foxBMS - Unit Tests
1.2.1
The foxBMS Unit Tests API Documentation
spi_cfg-helper.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-helper.h
44
* @author foxBMS Team
45
* @date 2021-12-08 (date of creation)
46
* @updated 2021-12-08 (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_HELPER_H_
56
#define FOXBMS__SPI_CFG_HELPER_H_
57
58
/*========== Includes =======================================================*/
59
#include "stdint.h"
60
61
/*========== Macros and Definitions =========================================*/
62
/** HW chip select bit position, TMS570LC4357 has maximum of six hardware chip
63
* select pins per SPI node @{ */
64
#define SPI_HARDWARE_CHIP_SELECT_0_BIT_POSITION (0u)
65
#define SPI_HARDWARE_CHIP_SELECT_1_BIT_POSITION (1u)
66
#define SPI_HARDWARE_CHIP_SELECT_2_BIT_POSITION (2u)
67
#define SPI_HARDWARE_CHIP_SELECT_3_BIT_POSITION (3u)
68
#define SPI_HARDWARE_CHIP_SELECT_4_BIT_POSITION (4u)
69
#define SPI_HARDWARE_CHIP_SELECT_5_BIT_POSITION (5u)
70
/**@}*/
71
72
/** Bit mask to activate hardware chip select in the CSNR field of the SPIDAT1 register */
73
#define SPI_HARDWARE_CHIP_SELECT_ACTIVE (0u)
74
75
/** Bit mask to *not* activate hardware chip select in the CSNR field of the SPIDAT1 register */
76
#define SPI_HARDWARE_CHIP_SELECT_NOT_ACTIVE (1u)
77
78
/* clang-format off */
79
/* AXIVION Disable Style MisraC2012-2.2: Redundant expressions are kept to enhance code readability */
80
#define SPI_HARDWARE_CHIP_SELECT_DISABLE_ALL \
81
((uint8_t)( \
82
(SPI_HARDWARE_CHIP_SELECT_NOT_ACTIVE << SPI_HARDWARE_CHIP_SELECT_0_BIT_POSITION) |
/* CS0 */
\
83
(SPI_HARDWARE_CHIP_SELECT_NOT_ACTIVE << SPI_HARDWARE_CHIP_SELECT_1_BIT_POSITION) |
/* CS1 */
\
84
(SPI_HARDWARE_CHIP_SELECT_NOT_ACTIVE << SPI_HARDWARE_CHIP_SELECT_2_BIT_POSITION) |
/* CS2 */
\
85
(SPI_HARDWARE_CHIP_SELECT_NOT_ACTIVE << SPI_HARDWARE_CHIP_SELECT_3_BIT_POSITION) |
/* CS3 */
\
86
(SPI_HARDWARE_CHIP_SELECT_NOT_ACTIVE << SPI_HARDWARE_CHIP_SELECT_4_BIT_POSITION) |
/* CS4 */
\
87
(SPI_HARDWARE_CHIP_SELECT_NOT_ACTIVE << SPI_HARDWARE_CHIP_SELECT_5_BIT_POSITION)
/* CS5 */
\
88
))
89
/* AXIVION Enable Style MisraC2012-2.2: */
90
/* clang-format on */
91
92
/* clang-format off */
93
/* AXIVION Disable Style MisraC2012-2.2: Redundant expressions are kept to enhance code readability */
94
#define SPI_HARDWARE_CHIP_SELECT_0_ACTIVE \
95
((uint8_t)( \
96
(SPI_HARDWARE_CHIP_SELECT_ACTIVE << SPI_HARDWARE_CHIP_SELECT_0_BIT_POSITION) |
/* CS0 */
\
97
(SPI_HARDWARE_CHIP_SELECT_NOT_ACTIVE << SPI_HARDWARE_CHIP_SELECT_1_BIT_POSITION) |
/* CS1 */
\
98
(SPI_HARDWARE_CHIP_SELECT_NOT_ACTIVE << SPI_HARDWARE_CHIP_SELECT_2_BIT_POSITION) |
/* CS2 */
\
99
(SPI_HARDWARE_CHIP_SELECT_NOT_ACTIVE << SPI_HARDWARE_CHIP_SELECT_3_BIT_POSITION) |
/* CS3 */
\
100
(SPI_HARDWARE_CHIP_SELECT_NOT_ACTIVE << SPI_HARDWARE_CHIP_SELECT_4_BIT_POSITION) |
/* CS4 */
\
101
(SPI_HARDWARE_CHIP_SELECT_NOT_ACTIVE << SPI_HARDWARE_CHIP_SELECT_5_BIT_POSITION)
/* CS5 */
\
102
))
103
/* AXIVION Enable Style MisraC2012-2.2: */
104
/* clang-format on */
105
106
/* clang-format off */
107
/* AXIVION Disable Style MisraC2012-2.2: Redundant expressions are kept to enhance code readability */
108
#define SPI_HARDWARE_CHIP_SELECT_1_ACTIVE \
109
((uint8_t)( \
110
(SPI_HARDWARE_CHIP_SELECT_NOT_ACTIVE << SPI_HARDWARE_CHIP_SELECT_0_BIT_POSITION) |
/* CS0 */
\
111
(SPI_HARDWARE_CHIP_SELECT_ACTIVE << SPI_HARDWARE_CHIP_SELECT_1_BIT_POSITION) |
/* CS1 */
\
112
(SPI_HARDWARE_CHIP_SELECT_NOT_ACTIVE << SPI_HARDWARE_CHIP_SELECT_2_BIT_POSITION) |
/* CS2 */
\
113
(SPI_HARDWARE_CHIP_SELECT_NOT_ACTIVE << SPI_HARDWARE_CHIP_SELECT_3_BIT_POSITION) |
/* CS3 */
\
114
(SPI_HARDWARE_CHIP_SELECT_NOT_ACTIVE << SPI_HARDWARE_CHIP_SELECT_4_BIT_POSITION) |
/* CS4 */
\
115
(SPI_HARDWARE_CHIP_SELECT_NOT_ACTIVE << SPI_HARDWARE_CHIP_SELECT_5_BIT_POSITION)
/* CS5 */
\
116
))
117
/* AXIVION Enable Style MisraC2012-2.2: */
118
/* clang-format on */
119
120
/* clang-format off */
121
/* AXIVION Disable Style MisraC2012-2.2: Redundant expressions are kept to enhance code readability */
122
#define SPI_HARDWARE_CHIP_SELECT_2_ACTIVE \
123
((uint8_t)( \
124
(SPI_HARDWARE_CHIP_SELECT_NOT_ACTIVE << SPI_HARDWARE_CHIP_SELECT_0_BIT_POSITION) |
/* CS0 */
\
125
(SPI_HARDWARE_CHIP_SELECT_NOT_ACTIVE << SPI_HARDWARE_CHIP_SELECT_1_BIT_POSITION) |
/* CS1 */
\
126
(SPI_HARDWARE_CHIP_SELECT_ACTIVE << SPI_HARDWARE_CHIP_SELECT_2_BIT_POSITION) |
/* CS2 */
\
127
(SPI_HARDWARE_CHIP_SELECT_NOT_ACTIVE << SPI_HARDWARE_CHIP_SELECT_3_BIT_POSITION) |
/* CS3 */
\
128
(SPI_HARDWARE_CHIP_SELECT_NOT_ACTIVE << SPI_HARDWARE_CHIP_SELECT_4_BIT_POSITION) |
/* CS4 */
\
129
(SPI_HARDWARE_CHIP_SELECT_NOT_ACTIVE << SPI_HARDWARE_CHIP_SELECT_5_BIT_POSITION)
/* CS5 */
\
130
))
131
/* AXIVION Enable Style MisraC2012-2.2: */
132
/* clang-format on */
133
134
/* clang-format off */
135
/* AXIVION Disable Style MisraC2012-2.2: Redundant expressions are kept to enhance code readability */
136
#define SPI_HARDWARE_CHIP_SELECT_3_ACTIVE \
137
((uint8_t)( \
138
(SPI_HARDWARE_CHIP_SELECT_NOT_ACTIVE << SPI_HARDWARE_CHIP_SELECT_0_BIT_POSITION) |
/* CS0 */
\
139
(SPI_HARDWARE_CHIP_SELECT_NOT_ACTIVE << SPI_HARDWARE_CHIP_SELECT_1_BIT_POSITION) |
/* CS1 */
\
140
(SPI_HARDWARE_CHIP_SELECT_NOT_ACTIVE << SPI_HARDWARE_CHIP_SELECT_2_BIT_POSITION) |
/* CS2 */
\
141
(SPI_HARDWARE_CHIP_SELECT_ACTIVE << SPI_HARDWARE_CHIP_SELECT_3_BIT_POSITION) |
/* CS3 */
\
142
(SPI_HARDWARE_CHIP_SELECT_NOT_ACTIVE << SPI_HARDWARE_CHIP_SELECT_4_BIT_POSITION) |
/* CS4 */
\
143
(SPI_HARDWARE_CHIP_SELECT_NOT_ACTIVE << SPI_HARDWARE_CHIP_SELECT_5_BIT_POSITION)
/* CS5 */
\
144
))
145
/* AXIVION Enable Style MisraC2012-2.2: */
146
/* clang-format on */
147
148
/* clang-format off */
149
/* AXIVION Disable Style MisraC2012-2.2: Redundant expressions are kept to enhance code readability */
150
#define SPI_HARDWARE_CHIP_SELECT_4_ACTIVE \
151
((uint8_t)( \
152
(SPI_HARDWARE_CHIP_SELECT_NOT_ACTIVE << SPI_HARDWARE_CHIP_SELECT_0_BIT_POSITION) |
/* CS0 */
\
153
(SPI_HARDWARE_CHIP_SELECT_NOT_ACTIVE << SPI_HARDWARE_CHIP_SELECT_1_BIT_POSITION) |
/* CS1 */
\
154
(SPI_HARDWARE_CHIP_SELECT_NOT_ACTIVE << SPI_HARDWARE_CHIP_SELECT_2_BIT_POSITION) |
/* CS2 */
\
155
(SPI_HARDWARE_CHIP_SELECT_NOT_ACTIVE << SPI_HARDWARE_CHIP_SELECT_3_BIT_POSITION) |
/* CS3 */
\
156
(SPI_HARDWARE_CHIP_SELECT_ACTIVE << SPI_HARDWARE_CHIP_SELECT_4_BIT_POSITION) |
/* CS4 */
\
157
(SPI_HARDWARE_CHIP_SELECT_NOT_ACTIVE << SPI_HARDWARE_CHIP_SELECT_5_BIT_POSITION)
/* CS5 */
\
158
))
159
/* AXIVION Enable Style MisraC2012-2.2: */
160
/* clang-format on */
161
162
/* clang-format off */
163
/* AXIVION Disable Style MisraC2012-2.2: Redundant expressions are kept to enhance code readability */
164
#define SPI_HARDWARE_CHIP_SELECT_5_ACTIVE \
165
((uint8_t)( \
166
(SPI_HARDWARE_CHIP_SELECT_NOT_ACTIVE << SPI_HARDWARE_CHIP_SELECT_0_BIT_POSITION) |
/* CS0 */
\
167
(SPI_HARDWARE_CHIP_SELECT_NOT_ACTIVE << SPI_HARDWARE_CHIP_SELECT_1_BIT_POSITION) |
/* CS1 */
\
168
(SPI_HARDWARE_CHIP_SELECT_NOT_ACTIVE << SPI_HARDWARE_CHIP_SELECT_2_BIT_POSITION) |
/* CS2 */
\
169
(SPI_HARDWARE_CHIP_SELECT_NOT_ACTIVE << SPI_HARDWARE_CHIP_SELECT_3_BIT_POSITION) |
/* CS3 */
\
170
(SPI_HARDWARE_CHIP_SELECT_NOT_ACTIVE << SPI_HARDWARE_CHIP_SELECT_4_BIT_POSITION) |
/* CS4 */
\
171
(SPI_HARDWARE_CHIP_SELECT_ACTIVE << SPI_HARDWARE_CHIP_SELECT_5_BIT_POSITION)
/* CS5 */
\
172
))
173
/* AXIVION Enable Style MisraC2012-2.2: */
174
/* clang-format on */
175
176
/*========== Extern Constant and Variable Declarations ======================*/
177
178
/*========== Extern Function Prototypes =====================================*/
179
180
/*========== Externalized Static Functions Prototypes (Unit Test) ===========*/
181
182
#endif
/* FOXBMS__SPI_CFG_HELPER_H_ */
src
app
driver
spi
spi_cfg-helper.h
Generated by
1.9.1