foxBMS - Unit Tests  1.6.0
The foxBMS Unit Tests API Documentation
test_sps.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_sps.c
44  * @author foxBMS Team
45  * @date 2020-10-28 (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 SPS driver
52  *
53  */
54 
55 /*========== Includes =======================================================*/
56 #include "unity.h"
57 #include "Mockcontactor.h"
58 #include "Mockcontactor_cfg.h"
59 #include "Mockdatabase.h"
60 #include "Mockio.h"
61 #include "Mockmcu.h"
62 #include "Mockos.h"
63 #include "Mockpex.h"
64 #include "Mockpex_cfg.h"
65 #include "Mockspi.h"
66 #include "Mockspi_cfg.h"
67 #include "Mocksps_cfg.h"
68 #include "Mocksps_types.h"
69 
70 #include "sps.h"
71 #include "test_assert_helper.h"
72 
73 #include <stdbool.h>
74 
75 /*========== Unit Testing Framework Directives ==============================*/
76 TEST_INCLUDE_PATH("../../src/app/driver/config")
77 TEST_INCLUDE_PATH("../../src/app/driver/contactor")
78 TEST_INCLUDE_PATH("../../src/app/driver/io")
79 TEST_INCLUDE_PATH("../../src/app/driver/pex")
80 TEST_INCLUDE_PATH("../../src/app/driver/spi")
81 TEST_INCLUDE_PATH("../../src/app/driver/sps")
82 
83 /*========== Definitions and Implementations for Unit Test ==================*/
84 /** SPI data configuration struct for SPS communication */
85 static spiDAT1_t spi_kSpsDataConfig = {
86  /* struct is implemented in the TI HAL and uses uppercase true and false */
87  .CS_HOLD = FALSE, /*!< The HW chip select signal is deactivated */
88  .WDEL = TRUE, /*!< No delay will be inserted */
89  .DFSEL = SPI_FMT_0, /*!< Data word format select: data format 0 (SPI3) */
90  .CSNR = 0x0, /*!< Chip select (CS) number; 0x01h for CS[0] */
91 };
92 
93 /** SPI interface configuration for SPS communication */
96  .pNode = spiREG3,
97  .pGioPort = &(spiREG3->PC3),
98  .csPin = 2u,
99 };
100 
101 /** channel states */
111 };
112 
122 };
123 
124 /*========== Setup and Teardown =============================================*/
125 void setUp(void) {
126  /* make sure variables are in a known state */
127 
128  for (uint8_t channel = 0u; channel < SPS_NR_OF_AVAILABLE_SPS_CHANNELS; channel++) {
131  sps_channelStatus[channel].current_mA = 0.0f;
132  }
133 }
134 
135 void tearDown(void) {
136 }
137 
138 /*========== Test Cases =====================================================*/
141 }
142 
145 }
146 
148  OS_EnterTaskCritical_Ignore();
149  OS_ExitTaskCritical_Ignore();
150 
151  TEST_ASSERT_EQUAL(SPS_CHANNEL_OFF, sps_channelStatus[0u].channelRequested);
153  TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[0u].channelRequested);
155  TEST_ASSERT_EQUAL(SPS_CHANNEL_OFF, sps_channelStatus[0u].channelRequested);
156 }
157 
160 }
161 
163  OS_EnterTaskCritical_Ignore();
164  OS_ExitTaskCritical_Ignore();
165 
167 
168  TEST_ASSERT_EQUAL(CONT_SWITCH_OFF, SPS_GetChannelCurrentFeedback(0u));
169 }
170 
172  OS_EnterTaskCritical_Ignore();
173  OS_ExitTaskCritical_Ignore();
174 
175  sps_channelStatus[0].current_mA = 600.f;
176 
177  TEST_ASSERT_EQUAL(CONT_SWITCH_ON, SPS_GetChannelCurrentFeedback(0u));
178 }
179 
182 }
183 
185  for (SPS_CHANNEL_INDEX index = 0u; index < SPS_NR_OF_AVAILABLE_SPS_CHANNELS; index++) {
186  TEST_ASSERT_EQUAL(sps_channelStatus[index].affiliation, SPS_GetChannelAffiliation(index));
187  }
188 }
189 
191  /* watch out, the channel here has to have an affiliation that is not SPS_AFF_CONTACTOR */
193 }
194 
196  /* a wrong index should also lead here to an assertion */
198 }
199 
201  OS_EnterTaskCritical_Ignore();
202  OS_ExitTaskCritical_Ignore();
203  /* watch out, the channel here has to have an affiliation that is SPS_AFF_CONTACTOR */
205  TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[0u].channelRequested);
206 }
207 
209  /* watch out, the channel here has to have an affiliation that is not SPS_AFF_GENERAL_IO */
211 }
212 
214  /* a wrong index should also lead here to an assertion */
216 }
217 
219  OS_EnterTaskCritical_Ignore();
220  OS_ExitTaskCritical_Ignore();
221  /* watch out, the channel here has to have an affiliation that is SPS_AFF_GENERAL_IO */
223  TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[7u].channelRequested);
224 }
225 
227  /* default wait time */
228  const uint8_t defaultTimer = 5u;
229 
230  /* check that we init in SPS_START otherwise this test has to be adapted */
231  TEST_ASSERT_EQUAL(SPS_START, TEST_SPS_GetSpsState());
232  TEST_ASSERT_EQUAL(0u, TEST_SPS_GetSpsTimer());
233 
234  /* transition through state-machine: SPS_START */
235  /* interface should become switched to low speed */
236  SPI_SpsInterfaceSwitchToLowSpeed_Expect(&spi_spsInterface);
237  SPS_Ctrl();
238  TEST_ASSERT_EQUAL(SPS_RESET_LOW, TEST_SPS_GetSpsState());
239 
240  /* transition through state-machine: SPS_RESET_LOW */
241  /* check that reset pin is reset
242  (we don't care for the actual address as long as the pin is correct) */
243  IO_PinReset_Expect(0u, SPS_RESET_PIN);
244  IO_PinReset_IgnoreArg_pRegisterAddress();
245  SPS_Ctrl();
246  /* timer should now be set to 5 */
247  TEST_ASSERT_EQUAL(defaultTimer, TEST_SPS_GetSpsTimer());
248  /* state should now be SPS_RESET_HIGH */
249  TEST_ASSERT_EQUAL(SPS_RESET_HIGH, TEST_SPS_GetSpsState());
250  /* test that timer decreases and nothing else happens */
251  SPS_Ctrl();
252  TEST_ASSERT_EQUAL((defaultTimer - 1u), TEST_SPS_GetSpsTimer());
253  TEST_ASSERT_EQUAL(SPS_RESET_HIGH, TEST_SPS_GetSpsState());
254  /* now that we know that it works: overwrite the timer so that
255  the next step can proceed */
257 
258  /* transition through state-machine: SPS_RESET_HIGH */
259  /* check that reset pin is set
260  (we don't care for the actual address as long as the pin is correct) */
261  IO_PinSet_Expect(0u, SPS_RESET_PIN);
262  IO_PinSet_IgnoreArg_pRegisterAddress();
263  SPS_Ctrl();
264  /* timer should now be set to 5 */
265  TEST_ASSERT_EQUAL(defaultTimer, TEST_SPS_GetSpsTimer());
266  /* state should now be SPS_CONFIGURE_CONTROL_REGISTER */
268  /* reset the timer so that we can continue */
270 
271  /* transition through state-machine: SPS_CONFIGURE_CONTROL_REGISTER */
272  /* check that we transmit the first set of commands */
273  SPI_TransmitReceiveData_IgnoreAndReturn(STD_OK);
274  MCU_Delay_us_Ignore();
275  /* Since the transaction is successful, we should switch to high-speed */
276  SPI_SpsInterfaceSwitchToHighSpeed_Expect(&spi_spsInterface);
277  SPS_Ctrl();
278  /* state should be now SPS_TRIGGER_CURRENT_MEASUREMENT */
280 }
281 
283  /* go to state SPS_TRIGGER_CURRENT_MEASUREMENT */
285 
286  /* run state and let first transaction "fail" */
287  MCU_Delay_us_Ignore();
288  SPI_TransmitReceiveData_ExpectAndReturn(NULL_PTR, NULL_PTR, NULL_PTR, 0u, STD_NOT_OK);
289  SPI_TransmitReceiveData_IgnoreArg_pSpiInterface();
290  SPI_TransmitReceiveData_IgnoreArg_pTxBuff();
291  SPI_TransmitReceiveData_IgnoreArg_pRxBuff();
292  SPI_TransmitReceiveData_IgnoreArg_frameLength();
293  SPI_TransmitReceiveData_ExpectAndReturn(NULL_PTR, NULL_PTR, NULL_PTR, 0u, STD_OK);
294  SPI_TransmitReceiveData_IgnoreArg_pSpiInterface();
295  SPI_TransmitReceiveData_IgnoreArg_pTxBuff();
296  SPI_TransmitReceiveData_IgnoreArg_pRxBuff();
297  SPI_TransmitReceiveData_IgnoreArg_frameLength();
298  SPS_Ctrl();
299 }
300 
302  /* go to state SPS_TRIGGER_CURRENT_MEASUREMENT */
304 
305  /* run state and let second transaction "fail" */
306  MCU_Delay_us_Ignore();
307  SPI_TransmitReceiveData_ExpectAndReturn(NULL_PTR, NULL_PTR, NULL_PTR, 0u, STD_OK);
308  SPI_TransmitReceiveData_IgnoreArg_pSpiInterface();
309  SPI_TransmitReceiveData_IgnoreArg_pTxBuff();
310  SPI_TransmitReceiveData_IgnoreArg_pRxBuff();
311  SPI_TransmitReceiveData_IgnoreArg_frameLength();
312  SPI_TransmitReceiveData_ExpectAndReturn(NULL_PTR, NULL_PTR, NULL_PTR, 0u, STD_NOT_OK);
313  SPI_TransmitReceiveData_IgnoreArg_pSpiInterface();
314  SPI_TransmitReceiveData_IgnoreArg_pTxBuff();
315  SPI_TransmitReceiveData_IgnoreArg_pRxBuff();
316  SPI_TransmitReceiveData_IgnoreArg_frameLength();
317  SPS_Ctrl();
318 }
319 
321  /* go to state SPS_TRIGGER_CURRENT_MEASUREMENT */
323 
324  /* run state and let both transaction "fail" */
325  MCU_Delay_us_Ignore();
326  SPI_TransmitReceiveData_IgnoreAndReturn(STD_NOT_OK);
327  SPS_Ctrl();
328 }
329 
331  /* go to state SPS_CONFIGURE_CONTROL_REGISTER */
333 
334  /* run state and let both transaction "fail" */
335  MCU_Delay_us_Ignore();
336  SPI_TransmitReceiveData_IgnoreAndReturn(STD_NOT_OK);
337  SPS_Ctrl();
338  TEST_ASSERT_EQUAL(SPS_START, TEST_SPS_GetSpsState());
339 }
340 
342  /* go to state SPS_TRIGGER_CURRENT_MEASUREMENT */
344 
345  /* run state and let both transaction "fail" */
346  MCU_Delay_us_Ignore();
347  SPI_TransmitReceiveData_IgnoreAndReturn(STD_NOT_OK);
348  SPS_Ctrl();
349  TEST_ASSERT_EQUAL(SPS_START, TEST_SPS_GetSpsState());
350 }
351 
353  /* go to state SPS_READ_EN_IRQ_PIN */
355 
356  /* run state and let both transaction "fail" */
357  MCU_Delay_us_Ignore();
358  SPI_TransmitReceiveData_IgnoreAndReturn(STD_NOT_OK);
359  SPS_Ctrl();
360  TEST_ASSERT_EQUAL(SPS_START, TEST_SPS_GetSpsState());
361 }
362 
364  /* go to state SPS_READ_MEASURED_CURRENT1 */
366 
367  /* run state and let both transaction "fail" */
368  MCU_Delay_us_Ignore();
369  SPI_TransmitReceiveData_IgnoreAndReturn(STD_NOT_OK);
370  SPS_Ctrl();
371  TEST_ASSERT_EQUAL(SPS_START, TEST_SPS_GetSpsState());
372 }
373 
375  /* go to state SPS_READ_MEASURED_CURRENT2 */
377 
378  /* run state and let both transaction "fail" */
379  MCU_Delay_us_Ignore();
380  SPI_TransmitReceiveData_IgnoreAndReturn(STD_NOT_OK);
381  SPS_Ctrl();
382  TEST_ASSERT_EQUAL(SPS_START, TEST_SPS_GetSpsState());
383 }
384 
386  /* go to state SPS_READ_MEASURED_CURRENT3 */
388 
389  /* run state and let both transaction "fail" */
390  MCU_Delay_us_Ignore();
391  SPI_TransmitReceiveData_IgnoreAndReturn(STD_NOT_OK);
392  SPS_Ctrl();
393  TEST_ASSERT_EQUAL(SPS_START, TEST_SPS_GetSpsState());
394 }
395 
397  /* go to state SPS_READ_MEASURED_CURRENT4 */
399 
400  /* run state and let both transaction "fail" */
401  MCU_Delay_us_Ignore();
402  SPI_TransmitReceiveData_IgnoreAndReturn(STD_NOT_OK);
403  SPS_Ctrl();
404  TEST_ASSERT_EQUAL(SPS_START, TEST_SPS_GetSpsState());
405 }
406 
408  /* go to state SPS_TRIGGER_CURRENT_MEASUREMENT */
410 
411  /* let transactions always succeed */
412  MCU_Delay_us_Ignore();
413  SPI_TransmitReceiveData_IgnoreAndReturn(STD_OK);
414 
415  /* run state chain */
416  SPS_Ctrl();
417  TEST_ASSERT_EQUAL(SPS_READ_EN_IRQ_PIN, TEST_SPS_GetSpsState());
418  SPS_Ctrl();
419  TEST_ASSERT_EQUAL(SPS_READ_MEASURED_CURRENT1, TEST_SPS_GetSpsState());
420  SPS_Ctrl();
421  TEST_ASSERT_EQUAL(SPS_READ_MEASURED_CURRENT2, TEST_SPS_GetSpsState());
422  SPS_Ctrl();
423  TEST_ASSERT_EQUAL(SPS_READ_MEASURED_CURRENT3, TEST_SPS_GetSpsState());
424  SPS_Ctrl();
425  TEST_ASSERT_EQUAL(SPS_READ_MEASURED_CURRENT4, TEST_SPS_GetSpsState());
426  SPS_Ctrl();
428 }
429 
431  /* go to illegal state 128 */
432  TEST_SPS_SetSpsState(128u);
433 
435 }
436 
438  OS_EnterTaskCritical_Ignore();
439  OS_ExitTaskCritical_Ignore();
440 
441  /* switch on a first, second, third and fourth channel */
442  TEST_ASSERT_EQUAL(SPS_CHANNEL_OFF, sps_channelStatus[0u].channelRequested);
444  TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[0u].channelRequested);
445  TEST_ASSERT_EQUAL(SPS_CHANNEL_OFF, sps_channelStatus[0u].channel);
446 
447  TEST_ASSERT_EQUAL(SPS_CHANNEL_OFF, sps_channelStatus[1u].channelRequested);
449  TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[1u].channelRequested);
450  TEST_ASSERT_EQUAL(SPS_CHANNEL_OFF, sps_channelStatus[1u].channel);
451 
452  TEST_ASSERT_EQUAL(SPS_CHANNEL_OFF, sps_channelStatus[6u].channelRequested);
454  TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[6u].channelRequested);
455  TEST_ASSERT_EQUAL(SPS_CHANNEL_OFF, sps_channelStatus[6u].channel);
456 
457  TEST_ASSERT_EQUAL(SPS_CHANNEL_OFF, sps_channelStatus[7u].channelRequested);
459  TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[7u].channelRequested);
460  TEST_ASSERT_EQUAL(SPS_CHANNEL_OFF, sps_channelStatus[7u].channel);
461 
462  /* cycle over one state that handles channels */
464  SPI_TransmitReceiveData_IgnoreAndReturn(STD_OK);
465  MCU_Delay_us_Ignore();
466  SPS_Ctrl();
467 
468  /* check that channels have been marked as on */
469  TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[0u].channel);
470  TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[1u].channel);
471  TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[6u].channel);
472  TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[7u].channel);
473 
474  /* switch off a first, second, third and fourth channel */
475  TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[0u].channelRequested);
477  TEST_ASSERT_EQUAL(SPS_CHANNEL_OFF, sps_channelStatus[0u].channelRequested);
478  TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[0u].channel);
479 
480  TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[1u].channelRequested);
482  TEST_ASSERT_EQUAL(SPS_CHANNEL_OFF, sps_channelStatus[1u].channelRequested);
483  TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[1u].channel);
484 
485  TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[6u].channelRequested);
487  TEST_ASSERT_EQUAL(SPS_CHANNEL_OFF, sps_channelStatus[6u].channelRequested);
488  TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[6u].channel);
489 
490  TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[7u].channelRequested);
492  TEST_ASSERT_EQUAL(SPS_CHANNEL_OFF, sps_channelStatus[7u].channelRequested);
493  TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[7u].channel);
494 
495  /* cycle over one state that handles channels */
497  SPI_TransmitReceiveData_IgnoreAndReturn(STD_OK);
498  MCU_Delay_us_Ignore();
499  SPS_Ctrl();
500 
501  /* check that channels have been marked as off */
502  TEST_ASSERT_EQUAL(SPS_CHANNEL_OFF, sps_channelStatus[0u].channel);
503  TEST_ASSERT_EQUAL(SPS_CHANNEL_OFF, sps_channelStatus[1u].channel);
504  TEST_ASSERT_EQUAL(SPS_CHANNEL_OFF, sps_channelStatus[6u].channel);
505  TEST_ASSERT_EQUAL(SPS_CHANNEL_OFF, sps_channelStatus[7u].channel);
506 }
507 
508 /** test the states of PEX feedback function */
510  /* report pin state 0 with normally open --> should report switch off */
511  PEX_GetPin_ExpectAndReturn(PEX_PORT_EXPANDER1, PEX_PIN00, 0u);
512  TEST_ASSERT_EQUAL(CONT_SWITCH_OFF, SPS_GetChannelPexFeedback(0u, true));
513 
514  /* report pin state 1 with normally open --> should report switch on */
515  PEX_GetPin_ExpectAndReturn(PEX_PORT_EXPANDER1, PEX_PIN00, 1u);
516  TEST_ASSERT_EQUAL(CONT_SWITCH_ON, SPS_GetChannelPexFeedback(0u, true));
517 
518  /* report pin state 0 with normally closed --> should report switch on */
519  PEX_GetPin_ExpectAndReturn(PEX_PORT_EXPANDER1, PEX_PIN00, 0u);
520  TEST_ASSERT_EQUAL(CONT_SWITCH_ON, SPS_GetChannelPexFeedback(0u, false));
521 
522  /* report pin state 1 with normally closed --> should report switch off */
523  PEX_GetPin_ExpectAndReturn(PEX_PORT_EXPANDER1, PEX_PIN00, 1u);
524  TEST_ASSERT_EQUAL(CONT_SWITCH_OFF, SPS_GetChannelPexFeedback(0u, false));
525 }
@ CONT_SWITCH_ON
Definition: contactor_cfg.h:72
@ CONT_SWITCH_OFF
Definition: contactor_cfg.h:71
@ 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 PEX_PIN05
Definition: pex_cfg.h:87
#define PEX_PIN02
Definition: pex_cfg.h:84
#define PEX_PIN00
Definition: pex_cfg.h:82
#define PEX_PIN03
Definition: pex_cfg.h:85
#define PEX_PIN01
Definition: pex_cfg.h:83
#define PEX_PIN07
Definition: pex_cfg.h:89
#define PEX_PIN06
Definition: pex_cfg.h:88
#define PEX_PIN04
Definition: pex_cfg.h:86
#define PEX_PORT_EXPANDER1
Definition: pex_cfg.h:75
CONT_ELECTRICAL_STATE_TYPE_e SPS_GetChannelPexFeedback(const SPS_CHANNEL_INDEX channelIndex, bool normallyOpen)
Get the feedback state of a channel.
Definition: sps.c:636
SPS_CHANNEL_AFFILIATION_e SPS_GetChannelAffiliation(SPS_CHANNEL_INDEX channelIndex)
Returns the channel affiliation.
Definition: sps.c:659
void TEST_SPS_RequestChannelState(SPS_CHANNEL_INDEX channelIndex, SPS_CHANNEL_FUNCTION_e channelFunction)
Definition: sps.c:666
void SPS_Ctrl(void)
Control function for the CONT driver state machine.
Definition: sps.c:481
uint8_t TEST_SPS_GetSpsTimer(void)
Definition: sps.c:675
void TEST_SPS_SetSpsTimer(const uint8_t newTimer)
Definition: sps.c:678
CONT_ELECTRICAL_STATE_TYPE_e SPS_GetChannelCurrentFeedback(const SPS_CHANNEL_INDEX channelIndex)
Get feedback value.
Definition: sps.c:620
void SPS_RequestContactorState(SPS_CHANNEL_INDEX channelIndex, SPS_CHANNEL_FUNCTION_e channelFunction)
Request state of a contactor.
Definition: sps.c:602
SPS_STATE_e TEST_SPS_GetSpsState(void)
Definition: sps.c:669
void TEST_SPS_SetSpsState(const SPS_STATE_e newState)
Definition: sps.c:672
void SPS_RequestGeneralIoState(SPS_CHANNEL_INDEX channelIndex, SPS_CHANNEL_FUNCTION_e channelFunction)
Request state of a general IO.
Definition: sps.c:611
Headers for the driver for the smart power switches.
#define SPS_CHANNEL_ON_DEFAULT_THRESHOLD_mA
Definition: sps_cfg.h:167
#define SPS_NR_OF_AVAILABLE_SPS_CHANNELS
Definition: sps_cfg.h:102
@ SPS_CHANNEL_ON
Definition: sps_cfg.h:188
@ SPS_CHANNEL_OFF
Definition: sps_cfg.h:187
#define SPS_RESET_PIN
Definition: sps_cfg.h:72
@ SPS_TRIGGER_CURRENT_MEASUREMENT
Definition: sps_cfg.h:217
@ SPS_CONFIGURE_CONTROL_REGISTER
Definition: sps_cfg.h:216
@ SPS_READ_MEASURED_CURRENT2
Definition: sps_cfg.h:219
@ SPS_READ_MEASURED_CURRENT1
Definition: sps_cfg.h:218
@ SPS_RESET_LOW
Definition: sps_cfg.h:214
@ SPS_READ_EN_IRQ_PIN
Definition: sps_cfg.h:222
@ SPS_READ_MEASURED_CURRENT3
Definition: sps_cfg.h:220
@ SPS_START
Definition: sps_cfg.h:213
@ SPS_READ_MEASURED_CURRENT4
Definition: sps_cfg.h:221
@ SPS_RESET_HIGH
Definition: sps_cfg.h:215
uint8_t SPS_CHANNEL_INDEX
Definition: sps_types.h:65
@ SPS_AFF_CONTACTOR
Definition: sps_types.h:74
@ SPS_AFF_GENERAL_IO
Definition: sps_types.h:75
spiDAT1_t * pConfig
Definition: spi_cfg.h:126
SPS_CHANNEL_FUNCTION_e channelRequested
Definition: sps_cfg.h:193
float_t current_mA
Definition: sps_cfg.h:195
SPS_CHANNEL_FUNCTION_e channel
Definition: sps_cfg.h:194
Helper for unit tests.
#define TEST_ASSERT_PASS_ASSERT(_code_under_test)
assert whether assert macro has passed
#define TEST_ASSERT_FAIL_ASSERT(_code_under_test)
assert whether assert macro has failed
void testSPS_RequestChannelStateSwitchOn(void)
Definition: test_sps.c:147
static spiDAT1_t spi_kSpsDataConfig
Definition: test_sps.c:85
void testSPS_RequestGeneralIOStateWrongAffiliation(void)
Definition: test_sps.c:208
void testContactorSwitchOnAndOff(void)
Definition: test_sps.c:437
void testSPS_RequestContactorStateCorrectAffiliation(void)
Definition: test_sps.c:200
void testSPS_RequestChannelStateInvalidFunction(void)
Definition: test_sps.c:143
void testSPS_CtrlResetFromStateSPS_TRIGGER_CURRENT_MEASUREMENT(void)
Definition: test_sps.c:341
SPS_CHANNEL_STATE_s sps_channelStatus[SPS_NR_OF_AVAILABLE_SPS_CHANNELS]
Definition: test_sps.c:102
void testSPS_CtrlNormalOperationCycle(void)
Definition: test_sps.c:407
void testSPS_GetChannelFeedbackChannelLow(void)
Definition: test_sps.c:162
void testSPS_CtrlResetFromStateSPS_READ_MEASURED_CURRENT3(void)
Definition: test_sps.c:385
void testSPS_CtrlResetFromStateSPS_READ_MEASURED_CURRENT4(void)
Definition: test_sps.c:396
void testSPS_CtrlResetFromStateSPS_READ_EN_IRQ_PIN(void)
Definition: test_sps.c:352
void testSPS_RequestGIOStateCorrectAffiliation(void)
Definition: test_sps.c:218
void testSPS_CtrlStartupProcedure(void)
Definition: test_sps.c:226
void testSPS_GetChannelAffiliationValidIndex(void)
Definition: test_sps.c:184
void testSPS_CtrlResetFromStateSPS_READ_MEASURED_CURRENT1(void)
Definition: test_sps.c:363
void testSPS_CtrlResetOnFailedSecondTransaction(void)
Definition: test_sps.c:301
void testSPS_CtrlAssertOnIllegalState(void)
Definition: test_sps.c:430
void testSPS_RequestGeneralIOStateWrongIndex(void)
Definition: test_sps.c:213
void setUp(void)
Definition: test_sps.c:125
void tearDown(void)
Definition: test_sps.c:135
void testSPS_RequestContactorStateWrongAffiliation(void)
Definition: test_sps.c:190
void testSPS_GetChannelAffiliationInvalidIndex(void)
Definition: test_sps.c:180
void testSPS_CtrlResetOnFailedBothTransactions(void)
Definition: test_sps.c:320
void testSPS_RequestContactorStateWrongIndex(void)
Definition: test_sps.c:195
void testSPS_GetChannelPexFeedback(void)
Definition: test_sps.c:509
const SPS_CHANNEL_FEEDBACK_MAPPING_s sps_kChannelFeedbackMapping[SPS_NR_OF_AVAILABLE_SPS_CHANNELS]
Definition: test_sps.c:113
void testSPS_CtrlResetFromStateSPS_READ_MEASURED_CURRENT2(void)
Definition: test_sps.c:374
void testSPS_CtrlResetOnFailedFirstTransaction(void)
Definition: test_sps.c:282
void testSPS_GetChannelFeedbackChannelHigh(void)
Definition: test_sps.c:171
SPI_INTERFACE_CONFIG_s spi_spsInterface
Definition: test_sps.c:94
void testSPS_GetChannelFeedbackInvalidChannelIndex(void)
Definition: test_sps.c:158
void testSPS_RequestChannelStateInvalidIndex(void)
Definition: test_sps.c:139
void testSPS_CtrlResetFromStateSPS_CONFIGURE_CONTROL_REGISTER(void)
Definition: test_sps.c:330