foxBMS - Unit Tests  1.6.0
The foxBMS Unit Tests API Documentation
test_spi.c
Go to the documentation of this file.
1 /**
2  *
3  * @copyright © 2010 - 2023, 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 test_spi.c
44  * @author foxBMS Team
45  * @date 2020-04-01 (date of creation)
46  * @updated 2023-10-12 (date of last update)
47  * @version v1.6.0
48  * @ingroup UNIT_TEST_IMPLEMENTATION
49  * @prefix TEST
50  *
51  * @brief Tests for the spi module
52  *
53  */
54 
55 /*========== Includes =======================================================*/
56 #include "unity.h"
57 #include "MockHL_spi.h"
58 #include "MockHL_sys_dma.h"
59 #include "Mockdma_cfg.h"
60 #include "Mockio.h"
61 #include "Mockmcu.h"
62 #include "Mockos.h"
63 #include "Mockspi_cfg.h"
64 
65 #include "spi.h"
66 #include "spi_cfg-helper.h"
67 #include "test_assert_helper.h"
68 
69 #include <stdbool.h>
70 
71 /*========== Unit Testing Framework Directives ==============================*/
72 TEST_SOURCE_FILE("spi.c")
73 
74 TEST_INCLUDE_PATH("../../src/app/driver/config")
75 TEST_INCLUDE_PATH("../../src/app/driver/dma")
76 TEST_INCLUDE_PATH("../../src/app/driver/io")
77 TEST_INCLUDE_PATH("../../src/app/driver/spi")
78 
79 /*========== Definitions and Implementations for Unit Test ==================*/
80 
81 long FSYS_RaisePrivilege(void) {
82  return 0;
83 }
84 
85 /** SPI enumeration for DMA */
87  spiREG1, /*!< SPI1 */
88  spiREG2, /*!< SPI2 */
89  spiREG3, /*!< SPI3 */
90  spiREG4, /*!< SPI4 */
91  spiREG5, /*!< SPI5 */
92 };
93 
94 /** DMA channel configuration for SPI communication */
96  {DMA_CH0, DMA_CH1}, /*!< SPI1 */
97  {DMA_CH2, DMA_CH3}, /*!< SPI2 */
98  {DMA_CH4, DMA_CH5}, /*!< SPI3 */
99  {DMA_CH6, DMA_CH7}, /*!< SPI4 */
100  {DMA_CH8, DMA_CH9}, /*!< SPI5 */
101 };
102 
103 /** SPI data configuration struct for ADI communication */
105  { /* struct is implemented in the TI HAL and uses uppercase true and false */
106  .CS_HOLD = TRUE, /* If true, HW chip select kept active between words */
107  .WDEL = FALSE, /* Activation of delay between words */
108  .DFSEL = SPI_FMT_0, /* Data word format selection */
109  /* Hardware chip select is configured automatically depending on configuration in #SPI_INTERFACE_CONFIG_s */
111 };
112 
113 /** SPI data configuration struct for LTC communication */
115  { /* struct is implemented in the TI HAL and uses uppercase true and false */
116  .CS_HOLD = TRUE, /* If true, HW chip select kept active between words */
117  .WDEL = FALSE, /* Activation of delay between words */
118  .DFSEL = SPI_FMT_0, /* Data word format selection */
119  /* Hardware chip select is configured automatically depending on configuration in #SPI_INTERFACE_CONFIG_s */
121 };
122 
123 /** SPI data configuration struct for MXM communication */
124 static spiDAT1_t spi_kMxmDataConfig = {
125  .CS_HOLD = TRUE, /* If true, HW chip select kept active */
126  .WDEL = TRUE, /* Activation of delay between words */
127  .DFSEL = SPI_FMT_1, /* Data word format selection */
128  /* Hardware chip select is configured automatically depending on configuration in #SPI_INTERFACE_CONFIG_s */
130 };
131 
132 /** SPI data configuration struct for NXP MC33775A communication, Tx part */
134  {.CS_HOLD = TRUE, /* If true, HW chip select kept active */
135  .WDEL = TRUE, /* Activation of delay between words */
136  .DFSEL = SPI_FMT_2, /* Data word format selection */
137  /* Hardware chip select is configured automatically depending on configuration in #SPI_INTERFACE_CONFIG_s */
139 };
140 
141 /** SPI data configuration struct for NXP MC33775A communication, Rx part */
143  {.CS_HOLD = TRUE, /* If true, HW chip select kept active */
144  .WDEL = TRUE, /* Activation of delay between words */
145  .DFSEL = SPI_FMT_2, /* Data word format selection */
146  /* Hardware chip select is configured automatically depending on configuration in #SPI_INTERFACE_CONFIG_s */
148 };
149 
150 /** SPI data configuration struct for FRAM communication */
151 static spiDAT1_t spi_kFramDataConfig = {
152  /* struct is implemented in the TI HAL and uses uppercase true and false */
153  .CS_HOLD = TRUE, /* If true, HW chip select kept active */
154  .WDEL = TRUE, /* Activation of delay between words */
155  .DFSEL = SPI_FMT_1, /* Data word format selection */
156  /* Hardware chip select is configured automatically depending on configuration in #SPI_INTERFACE_CONFIG_s */
158 };
159 
160 /** SPI data configuration struct for SPS communication in low speed (4MHz) */
161 static spiDAT1_t spi_kSpsDataConfigLowSpeed = {
162  /* struct is implemented in the TI HAL and uses uppercase true and false */
163  .CS_HOLD = TRUE, /* If true, HW chip select kept active */
164  .WDEL = TRUE, /* Activation of delay between words */
165  .DFSEL = SPI_FMT_1, /* Data word format selection */
166  /* Hardware chip select is configured automatically depending on configuration in #SPI_INTERFACE_CONFIG_s */
168 };
169 
170 /** SPI configuration struct for SBC communication */
171 static spiDAT1_t spi_kSbcDataConfig = {
172  /* struct is implemented in the TI HAL and uses uppercase true and false */
173  .CS_HOLD = TRUE, /* If true, HW chip select kept active */
174  .WDEL = TRUE, /* Activation of delay between words */
175  .DFSEL = SPI_FMT_0, /* Data word format selection */
176  /* Hardware chip select is configured automatically depending on configuration in #SPI_INTERFACE_CONFIG_s */
178 };
179 
180 /**
181  * SPI interface configuration for ADI communication
182  * This is a list of structs because of multi string
183  */
185  {
186  .pConfig = &spi_kAdiDataConfig[0u],
187  .pNode = spiREG1,
188  .pGioPort = &(spiREG1->PC3),
189  .csPin = 1u,
190  .csType = SPI_CHIP_SELECT_HARDWARE,
191  },
192 };
193 
194 /**
195  * SPI interface configuration for LTC communication
196  * This is a list of structs because of multi string
197  */
199  {
200  .pConfig = &spi_kLtcDataConfig[0u],
201  .pNode = spiREG1,
202  .pGioPort = &(spiREG1->PC3),
203  .csPin = 1u,
204  .csType = SPI_CHIP_SELECT_HARDWARE,
205  },
206 };
207 
208 /** SPI interface configuration for MXM communication */
211  .pNode = spiREG4,
212  .pGioPort = &(spiREG4->PC3),
213  .csPin = 0u,
214  .csType = SPI_CHIP_SELECT_HARDWARE,
215 };
216 
217 /** SPI interface configuration for N775 communication Tx part */
219  {
221  .pNode = spiREG1,
222  .pGioPort = &(spiREG1->PC3),
223  .csPin = 1u,
224  .csType = SPI_CHIP_SELECT_HARDWARE,
225  },
226 };
227 
228 /** SPI interface configuration for N775 communication, Rx part */
230  {
232  .pNode = spiREG4,
233  .pGioPort = &(spiREG4->PC3),
234  .csPin = 0u,
235  .csType = SPI_CHIP_SELECT_HARDWARE,
236  },
237 };
238 
239 /** SPI interface configuration for FRAM communication */
242  .pNode = spiREG3,
243  .pGioPort = &(spiREG3->PC3),
244  .csPin = 1u,
245  .csType = SPI_CHIP_SELECT_SOFTWARE,
246 };
247 
248 /** SPI interface configuration for SPS communication */
251  .pNode = spiREG2,
252  .pGioPort = &SPI_SPS_CS_GIOPORT,
253  .csPin = SPI_SPS_CS_PIN,
254  .csType = SPI_CHIP_SELECT_SOFTWARE,
255 };
256 
257 /** SPI interface configuration for SBC communication */
260  .pNode = spiREG2,
261  .pGioPort = &(spiREG2->PC3),
262  .csPin = 0u,
263  .csType = SPI_CHIP_SELECT_HARDWARE,
264 };
265 
266 /** struct containing the lock state of the SPI interfaces */
268  SPI_IDLE,
269  SPI_IDLE,
270  SPI_IDLE,
271  SPI_IDLE,
272  SPI_IDLE,
273 };
274 
275 const uint8_t spi_nrBusyFlags = sizeof(spi_busyFlags) / sizeof(SPI_BUSY_STATE_e);
276 
277 /** mock for testing with an SPI handle */
278 spiBASE_t spiMockHandle = {0};
279 
280 spi_config_reg_t spiMockConfigRegister = {0};
281 
282 /*========== Setup and Teardown =============================================*/
283 void setUp(void) {
284  /* make sure PC0 of config register is clean */
285  spiMockConfigRegister.CONFIG_PC0 = 0;
286 }
287 
288 void tearDown(void) {
289 }
290 
291 /*========== Test Cases =====================================================*/
292 /**
293  * @brief Testing static function #SPI_InitializeChipSelects
294  * @details The following cases need to be tested:
295  * - Argument validation:
296  * - none (void function)
297  * - Routine validation:
298  * - RT1/1: software chip select pin in the valid range is verbatim
299  * piped through the function
300  */
302  /* ======= Assertion tests ============================================= */
303  /* none */
304 
305  /* ======= Routine tests =============================================== */
306  /* ======= RT1/1: Test implementation */
307  const uint8_t currentString = 0u;
308 
309  /* ======= RT1/1: call function under test */
311 
312  /* ======= RT1/1: test output verification */
313  TEST_ASSERT_EQUAL(SPI_HARDWARE_CHIP_SELECT_1_ACTIVE, spi_adiInterface[currentString].pConfig->CSNR);
314  TEST_ASSERT_EQUAL(SPI_HARDWARE_CHIP_SELECT_1_ACTIVE, spi_ltcInterface[currentString].pConfig->CSNR);
315  TEST_ASSERT_EQUAL(SPI_HARDWARE_CHIP_SELECT_1_ACTIVE, spi_nxp775InterfaceTx[currentString].pConfig->CSNR);
316  TEST_ASSERT_EQUAL(SPI_HARDWARE_CHIP_SELECT_0_ACTIVE, spi_nxp775InterfaceRx[currentString].pConfig->CSNR);
318  TEST_ASSERT_EQUAL(1u, spi_framInterface.pConfig->CSNR);
319  TEST_ASSERT_EQUAL(1u, spi_spsInterface.pConfig->CSNR);
321 }
322 
323 /**
324  * @brief Testing static function #SPI_GetChipSelectPin
325  * @details The following cases need to be tested:
326  * - Argument validation:
327  * - AT1/2: invalid chip select type -> assert
328  * - AT2/2: invalid chip select pin number -> assert
329  * - Routine validation:
330  * - RT1/2: software chip select pin in the valid range is verbatim
331  * piped through the function
332  * - RT1/2: hardware chip select pin in the valid range is mapped to
333  * the correct value
334  */
336  /* ======= Assertion tests ============================================= */
337  /* ======= AT1/2 ======= */
338  const SPI_CHIP_SELECT_TYPE_e invalidChipSelectType = SPI_CHIP_SELECT_MAX;
339  const uint32_t validCsPin = 0u;
340  TEST_ASSERT_FAIL_ASSERT(TEST_SPI_GetChipSelectPin(invalidChipSelectType, validCsPin));
341  /* ======= AT2/2 ======= */
342  const SPI_CHIP_SELECT_TYPE_e validChipSelectType = SPI_CHIP_SELECT_SOFTWARE;
343  const uint32_t invalidCsPin = MCU_LARGEST_PIN_NUMBER + 1u;
344  TEST_ASSERT_FAIL_ASSERT(TEST_SPI_GetChipSelectPin(validChipSelectType, invalidCsPin));
345 
346  /* ======= Routine tests =============================================== */
347  /* ======= RT1/2: Test implementation */
348  const uint32_t validSoftwareChipSelectPin = MCU_LARGEST_PIN_NUMBER / 2u;
349  /* ======= RT1/2: call function under test */
350  const uint8_t softwareChipSelectPin =
351  TEST_SPI_GetChipSelectPin(SPI_CHIP_SELECT_SOFTWARE, validSoftwareChipSelectPin);
352  /* ======= RT1/2: test output verification */
353  TEST_ASSERT_EQUAL(validSoftwareChipSelectPin, softwareChipSelectPin);
354 
355  /* ======= RT2/2: Test implementation */
356  const uint32_t validHardwareChipSelectPin = 2u;
357  /* ======= RT2/2: call function under test */
358  const uint8_t hardwareChipSelectPin =
359  TEST_SPI_GetChipSelectPin(SPI_CHIP_SELECT_HARDWARE, validHardwareChipSelectPin);
360  /* ======= RT2/2: test output verification */
361  TEST_ASSERT_EQUAL(SPI_HARDWARE_CHIP_SELECT_2_ACTIVE, hardwareChipSelectPin);
362 }
363 
364 /**
365  * @brief Testing static function #SPI_GetHardwareChipSelectPin
366  * @details The following cases need to be tested:
367  * - Argument validation:
368  * - AT1/1: invalid pin number -> assert
369  * - Routine validation:
370  * - RT1/1: check that only valid hardware chip select
371  * configurations are returned
372  */
374  /* ======= Assertion tests ============================================= */
375  /* ======= AT1/1 ======= */
376  const uint32_t invalidHwCsPin = 7u;
378 
379  /* ======= Routine tests =============================================== */
380  const uint8_t csPin0 = 0u;
381  const uint8_t csPin1 = 1u;
382  const uint8_t csPin2 = 2u;
383  const uint8_t csPin3 = 3u;
384  const uint8_t csPin4 = 4u;
385  const uint8_t csPin5 = 5u;
386  /* ======= RT1/1: Test implementation */
387  /* ======= RT1/1: call function under test */
388  const uint8_t mappedHardwareChipSelectPin0 = TEST_SPI_GetHardwareChipSelectPin(csPin0);
389  const uint8_t mappedHardwareChipSelectPin1 = TEST_SPI_GetHardwareChipSelectPin(csPin1);
390  const uint8_t mappedHardwareChipSelectPin2 = TEST_SPI_GetHardwareChipSelectPin(csPin2);
391  const uint8_t mappedHardwareChipSelectPin3 = TEST_SPI_GetHardwareChipSelectPin(csPin3);
392  const uint8_t mappedHardwareChipSelectPin4 = TEST_SPI_GetHardwareChipSelectPin(csPin4);
393  const uint8_t mappedHardwareChipSelectPin5 = TEST_SPI_GetHardwareChipSelectPin(csPin5);
394  /* ======= RT1/1: test output verification */
395  TEST_ASSERT_EQUAL(SPI_HARDWARE_CHIP_SELECT_0_ACTIVE, mappedHardwareChipSelectPin0);
396  TEST_ASSERT_EQUAL(SPI_HARDWARE_CHIP_SELECT_1_ACTIVE, mappedHardwareChipSelectPin1);
397  TEST_ASSERT_EQUAL(SPI_HARDWARE_CHIP_SELECT_2_ACTIVE, mappedHardwareChipSelectPin2);
398  TEST_ASSERT_EQUAL(SPI_HARDWARE_CHIP_SELECT_3_ACTIVE, mappedHardwareChipSelectPin3);
399  TEST_ASSERT_EQUAL(SPI_HARDWARE_CHIP_SELECT_4_ACTIVE, mappedHardwareChipSelectPin4);
400  TEST_ASSERT_EQUAL(SPI_HARDWARE_CHIP_SELECT_5_ACTIVE, mappedHardwareChipSelectPin5);
401 }
402 
403 /** simple API test that function guards against null pointer */
406 }
407 
408 /** test intended function of SPI_SetFunctional() for setting a bit */
410  /** fake a config register that is null and inject into function */
411  spiMockConfigRegister.CONFIG_PC0 = 0;
412  spi1GetConfigValue_Expect(NULL_PTR, CurrentValue);
413  spi1GetConfigValue_IgnoreArg_config_reg();
414  spi1GetConfigValue_ReturnThruPtr_config_reg(&spiMockConfigRegister);
415 
416  /* the function should call spiSetFunctional with a 1 at bit 10 */
417  spiSetFunctional_Expect(spiREG1, ((uint32_t)1u << 10u));
418 
419  SPI_SetFunctional(spiREG1, 10, true);
420 }
421 
422 /** test intended function of SPI_SetFunctional() for clearing a bit */
424  /** fake a config register that is UINT32_MAX and inject into function */
425  spiMockConfigRegister.CONFIG_PC0 = UINT32_MAX;
426  spi1GetConfigValue_Expect(NULL_PTR, CurrentValue);
427  spi1GetConfigValue_IgnoreArg_config_reg();
428  spi1GetConfigValue_ReturnThruPtr_config_reg(&spiMockConfigRegister);
429 
430  /* the function should call spiSetFunctional with a 0 at bit 10 */
431  spiSetFunctional_Expect(spiREG1, ~((uint32_t)1u << 10u));
432 
433  SPI_SetFunctional(spiREG1, 10, false);
434 }
435 
436 /** test usage of right API functions for SPI1 */
438  /* this test will fail if another function than the intended function is
439  called */
440  spi1GetConfigValue_Ignore();
441  spiSetFunctional_Ignore();
442  SPI_SetFunctional(spiREG1, 0, false);
443 }
444 
445 /** test usage of right API functions for SPI2 */
447  /* this test will fail if another function than the intended function is
448  called */
449  spi2GetConfigValue_Ignore();
450  spiSetFunctional_Ignore();
451  SPI_SetFunctional(spiREG2, 0, false);
452 }
453 
454 /** test usage of right API functions for SPI3 */
456  /* this test will fail if another function than the intended function is
457  called */
458  spi3GetConfigValue_Ignore();
459  spiSetFunctional_Ignore();
460  SPI_SetFunctional(spiREG3, 0, false);
461 }
462 
463 /** test usage of right API functions for SPI4 */
465  /* this test will fail if another function than the intended function is
466  called */
467  spi4GetConfigValue_Ignore();
468  spiSetFunctional_Ignore();
469  SPI_SetFunctional(spiREG4, 0, false);
470 }
471 
472 /** test usage of right API functions for SPI5 */
474  /* this test will fail if another function than the intended function is
475  called */
476  spi5GetConfigValue_Ignore();
477  spiSetFunctional_Ignore();
478  SPI_SetFunctional(spiREG5, 0, false);
479 }
480 
481 /** test invalid input to SPI_CheckInterfaceAvailable */
484 }
485 
486 /** test all return codes from HAL with SPI_CheckInterfaceAvailable */
488  SpiTxStatus_ExpectAndReturn(spiREG1, SPI_READY);
489  TEST_ASSERT_EQUAL(STD_OK, SPI_CheckInterfaceAvailable(spiREG1));
490 
491  SpiTxStatus_ExpectAndReturn(spiREG1, SPI_PENDING);
492  TEST_ASSERT_EQUAL(STD_NOT_OK, SPI_CheckInterfaceAvailable(spiREG1));
493 
494  SpiTxStatus_ExpectAndReturn(spiREG1, SPI_COMPLETED);
495  TEST_ASSERT_EQUAL(STD_OK, SPI_CheckInterfaceAvailable(spiREG1));
496 }
497 
498 /**
499  * @brief Testing extern function #SPI_GetSpiIndex
500  * @details The following cases need to be tested:
501  * - Argument validation:
502  * - AT1/1: NULL_PTR for pNode -> assert
503  * - Routine validation:
504  * - RT1/2: check that the correct SPI index is returned
505  * - RT2/2: provide an invalid SPI register -> assert
506  */
508  /* ======= Assertion tests ============================================= */
509  /* ======= AT1/1 ======= */
511 
512  /* ======= Routine tests =============================================== */
513  /* ======= RT1/2: Test implementation */
514 
515  /* ======= RT1/2: call function under test */
516  const uint8_t spiIndex1 = SPI_GetSpiIndex(spiREG1);
517  const uint8_t spiIndex2 = SPI_GetSpiIndex(spiREG2);
518  const uint8_t spiIndex3 = SPI_GetSpiIndex(spiREG3);
519  const uint8_t spiIndex4 = SPI_GetSpiIndex(spiREG4);
520  const uint8_t spiIndex5 = SPI_GetSpiIndex(spiREG5);
521 
522  /* ======= RT1/2: test output verification */
523  TEST_ASSERT_EQUAL(0u, spiIndex1);
524  TEST_ASSERT_EQUAL(1u, spiIndex2);
525  TEST_ASSERT_EQUAL(2u, spiIndex3);
526  TEST_ASSERT_EQUAL(3u, spiIndex4);
527  TEST_ASSERT_EQUAL(4u, spiIndex5);
528 
529  /* ======= RT2/2: Test implementation */
530  spiBASE_t *invalidSpiRegister = (spiBASE_t *)0xFFF7FBE8u;
531 
532  /* ======= RT2/2: call function under test */
533  TEST_ASSERT_FAIL_ASSERT(SPI_GetSpiIndex(invalidSpiRegister));
534 
535  /* ======= RT2/2: test output verification */
536  /* nothing to be verified */
537 }
#define BS_NR_OF_STRINGS
Number of parallel strings in the battery pack.
#define DMA_NUMBER_SPI_INTERFACES
Definition: dma_cfg.h:115
@ STD_NOT_OK
Definition: fstd_types.h:84
@ STD_OK
Definition: fstd_types.h:83
#define NULL_PTR
Null pointer.
Definition: fstd_types.h:77
#define MCU_LARGEST_PIN_NUMBER
largest pin number that exists in TMS570LC4357
Definition: mcu.h:69
uint8_t TEST_SPI_GetHardwareChipSelectPin(uint8_t csPin)
Definition: spi.c:586
void SPI_SetFunctional(spiBASE_t *pNode, enum spiPinSelect bit, bool hardwareControlled)
Sets the functional of a SPI pin.
Definition: spi.c:429
STD_RETURN_TYPE_e SPI_CheckInterfaceAvailable(spiBASE_t *pNode)
Returns STD_OK if the SPI interface can be used again.
Definition: spi.c:546
void TEST_SPI_InitializeChipSelects(void)
Definition: spi.c:580
uint8_t SPI_GetSpiIndex(spiBASE_t *pNode)
Returns index of SPI node.
Definition: spi.c:556
uint8_t TEST_SPI_GetChipSelectPin(SPI_CHIP_SELECT_TYPE_e csType, uint32_t csPin)
Definition: spi.c:583
Headers for the driver for the SPI module.
Headers for the configuration for the SPI module.
#define SPI_HARDWARE_CHIP_SELECT_3_ACTIVE
#define SPI_HARDWARE_CHIP_SELECT_0_ACTIVE
#define SPI_HARDWARE_CHIP_SELECT_1_ACTIVE
#define SPI_HARDWARE_CHIP_SELECT_4_ACTIVE
#define SPI_HARDWARE_CHIP_SELECT_5_ACTIVE
#define SPI_HARDWARE_CHIP_SELECT_2_ACTIVE
#define SPI_HARDWARE_CHIP_SELECT_DISABLE_ALL
SPI_BUSY_STATE_e
Definition: spi_cfg.h:109
@ SPI_IDLE
Definition: spi_cfg.h:110
#define SPI_SPS_CS_GIOPORT
Definition: spi_cfg.h:153
SPI_CHIP_SELECT_TYPE_e
Definition: spi_cfg.h:116
@ SPI_CHIP_SELECT_SOFTWARE
Definition: spi_cfg.h:118
@ SPI_CHIP_SELECT_MAX
Definition: spi_cfg.h:119
@ SPI_CHIP_SELECT_HARDWARE
Definition: spi_cfg.h:117
#define SPI_SPS_CS_PIN
Definition: spi_cfg.h:155
spiDAT1_t * pConfig
Definition: spi_cfg.h:126
Helper for unit tests.
#define TEST_ASSERT_FAIL_ASSERT(_code_under_test)
assert whether assert macro has failed
spiBASE_t spiMockHandle
Definition: test_spi.c:278
void testSPI_CheckInterfaceAvailableInvalidInput(void)
Definition: test_spi.c:482
static spiDAT1_t spi_kNxp775DataConfigRx[BS_NR_OF_STRINGS]
Definition: test_spi.c:142
static spiDAT1_t spi_kAdiDataConfig[BS_NR_OF_STRINGS]
Definition: test_spi.c:104
SPI_INTERFACE_CONFIG_s spi_mxmInterface
Definition: test_spi.c:209
static spiDAT1_t spi_kSbcDataConfig
Definition: test_spi.c:171
SPI_INTERFACE_CONFIG_s spi_adiInterface[BS_NR_OF_STRINGS]
Definition: test_spi.c:184
void testSPI_SetFunctionalRightApiSpi5(void)
Definition: test_spi.c:473
SPI_INTERFACE_CONFIG_s spi_sbcMcuInterface
Definition: test_spi.c:258
SPI_INTERFACE_CONFIG_s spi_nxp775InterfaceTx[BS_NR_OF_STRINGS]
Definition: test_spi.c:218
spiBASE_t * dma_spiInterfaces[DMA_NUMBER_SPI_INTERFACES]
Definition: test_spi.c:86
static spiDAT1_t spi_kNxp775DataConfigTx[BS_NR_OF_STRINGS]
Definition: test_spi.c:133
void testSPI_CheckInterfaceAvailable(void)
Definition: test_spi.c:487
SPI_BUSY_STATE_e spi_busyFlags[]
Definition: test_spi.c:267
void testSPI_SetFunctionalRightApiSpi2(void)
Definition: test_spi.c:446
void testSPI_GetHardwareChipSelectPin(void)
Testing static function SPI_GetHardwareChipSelectPin.
Definition: test_spi.c:373
void testSPI_SetFunctionalTestIntendedFunctionClear(void)
Definition: test_spi.c:423
void testSPI_SetFunctionalTestIntendedFunctionSet(void)
Definition: test_spi.c:409
void testSPI_SetFunctionalRightApiSpi4(void)
Definition: test_spi.c:464
void testSPI_SetFunctionalNullPointer(void)
Definition: test_spi.c:404
void setUp(void)
Definition: test_spi.c:283
void tearDown(void)
Definition: test_spi.c:288
SPI_INTERFACE_CONFIG_s spi_framInterface
Definition: test_spi.c:240
static spiDAT1_t spi_kFramDataConfig
Definition: test_spi.c:151
static spiDAT1_t spi_kLtcDataConfig[BS_NR_OF_STRINGS]
Definition: test_spi.c:114
void testSPI_SetFunctionalRightApiSpi3(void)
Definition: test_spi.c:455
spi_config_reg_t spiMockConfigRegister
Definition: test_spi.c:280
void testSPI_GetSpiIndex(void)
Testing extern function SPI_GetSpiIndex.
Definition: test_spi.c:507
long FSYS_RaisePrivilege(void)
Raise privilege.
Definition: test_spi.c:81
static spiDAT1_t spi_kMxmDataConfig
Definition: test_spi.c:124
SPI_INTERFACE_CONFIG_s spi_nxp775InterfaceRx[BS_NR_OF_STRINGS]
Definition: test_spi.c:229
DMA_CHANNEL_CONFIG_s dma_spiDmaChannels[DMA_NUMBER_SPI_INTERFACES]
Definition: test_spi.c:95
void testSPI_GetChipSelectPin(void)
Testing static function SPI_GetChipSelectPin.
Definition: test_spi.c:335
void testSPI_SetFunctionalRightApiSpi1(void)
Definition: test_spi.c:437
void testSPI_InitializeChipSelects(void)
Testing static function SPI_InitializeChipSelects.
Definition: test_spi.c:301
SPI_INTERFACE_CONFIG_s spi_ltcInterface[BS_NR_OF_STRINGS]
Definition: test_spi.c:198
const uint8_t spi_nrBusyFlags
Definition: test_spi.c:275
SPI_INTERFACE_CONFIG_s spi_spsInterface
Definition: test_spi.c:249
static spiDAT1_t spi_kSpsDataConfigLowSpeed
Definition: test_spi.c:161