foxBMS - Unit Tests  1.2.1
The foxBMS Unit Tests API Documentation
test_sps.c
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 test_sps.c
44  * @author foxBMS Team
45  * @date 2020-10-28 (date of creation)
46  * @updated 2021-12-08 (date of last update)
47  * @ingroup UNIT_TEST_IMPLEMENTATION
48  * @prefix TEST
49  *
50  * @brief Tests for the SPS driver
51  *
52  */
53 
54 /*========== Includes =======================================================*/
55 #include "unity.h"
56 #include "Mockcontactor.h"
57 #include "Mockcontactor_cfg.h"
58 #include "Mockdatabase.h"
59 #include "Mockio.h"
60 #include "Mockmcu.h"
61 #include "Mockos.h"
62 #include "Mockpex.h"
63 #include "Mockpex_cfg.h"
64 #include "Mockspi.h"
65 #include "Mockspi_cfg.h"
66 #include "Mocksps_cfg.h"
67 #include "Mocksps_types.h"
68 
69 #include "sps.h"
70 #include "test_assert_helper.h"
71 
72 /*========== Definitions and Implementations for Unit Test ==================*/
73 /** SPI data configuration struct for SPS communication */
74 static const spiDAT1_t spi_kSpsDataConfig = {
75  /* struct is implemented in the TI HAL and uses uppercase true and false */
76  .CS_HOLD = FALSE, /*!< The HW chip select signal is deactivated */
77  .WDEL = TRUE, /*!< No delay will be inserted */
78  .DFSEL = SPI_FMT_0, /*!< Data word format select: data format 0 (SPI3) */
79  .CSNR = 0x0, /*!< Chip select (CS) number; 0x01h for CS[0] */
80 };
81 
82 /** SPI interface configuration for SPS communication */
85  .pNode = spiREG3,
86  .pGioPort = &(spiREG3->PC3),
87  .csPin = 2u,
88 };
89 
90 /** channel states */
100 };
101 
111 };
112 
113 /*========== Setup and Teardown =============================================*/
114 void setUp(void) {
115  /* make sure variables are in a known state */
116 
117  for (uint8_t channel = 0u; channel < SPS_NR_OF_AVAILABLE_SPS_CHANNELS; channel++) {
120  sps_channelStatus[channel].current_mA = 0.0f;
121  }
122 }
123 
124 void tearDown(void) {
125 }
126 
127 /*========== Test Cases =====================================================*/
130 }
131 
134 }
135 
137  OS_EnterTaskCritical_Ignore();
138  OS_ExitTaskCritical_Ignore();
139 
140  TEST_ASSERT_EQUAL(SPS_CHANNEL_OFF, sps_channelStatus[0u].channelRequested);
142  TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[0u].channelRequested);
144  TEST_ASSERT_EQUAL(SPS_CHANNEL_OFF, sps_channelStatus[0u].channelRequested);
145 }
146 
149 }
150 
152  OS_EnterTaskCritical_Ignore();
153  OS_ExitTaskCritical_Ignore();
154 
156 
157  TEST_ASSERT_EQUAL(CONT_SWITCH_OFF, SPS_GetChannelCurrentFeedback(0u));
158 }
159 
161  OS_EnterTaskCritical_Ignore();
162  OS_ExitTaskCritical_Ignore();
163 
164  sps_channelStatus[0].current_mA = 600.f;
165 
166  TEST_ASSERT_EQUAL(CONT_SWITCH_ON, SPS_GetChannelCurrentFeedback(0u));
167 }
168 
171 }
172 
174  for (SPS_CHANNEL_INDEX index = 0u; index < SPS_NR_OF_AVAILABLE_SPS_CHANNELS; index++) {
175  TEST_ASSERT_EQUAL(sps_channelStatus[index].affiliation, SPS_GetChannelAffiliation(index));
176  }
177 }
178 
180  /* watch out, the channel here has to have an affiliation that is not SPS_AFF_CONTACTOR */
182 }
183 
185  /* a wrong index should also lead here to an assertion */
187 }
188 
190  OS_EnterTaskCritical_Ignore();
191  OS_ExitTaskCritical_Ignore();
192  /* watch out, the channel here has to have an affiliation that is SPS_AFF_CONTACTOR */
194  TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[0u].channelRequested);
195 }
196 
198  /* watch out, the channel here has to have an affiliation that is not SPS_AFF_GENERAL_IO */
200 }
201 
203  /* a wrong index should also lead here to an assertion */
205 }
206 
208  OS_EnterTaskCritical_Ignore();
209  OS_ExitTaskCritical_Ignore();
210  /* watch out, the channel here has to have an affiliation that is SPS_AFF_GENERAL_IO */
212  TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[7u].channelRequested);
213 }
214 
216  /* default wait time */
217  const uint8_t defaultTimer = 5u;
218 
219  /* check that we init in SPS_START otherwise this test has to be adapted */
220  TEST_ASSERT_EQUAL(SPS_START, TEST_SPS_GetSpsState());
221  TEST_ASSERT_EQUAL(0u, TEST_SPS_GetSpsTimer());
222 
223  /* transition through state-machine: SPS_START */
224  /* interface should become switched to low speed */
225  SPI_SpsInterfaceSwitchToLowSpeed_Expect(&spi_spsInterface);
226  SPS_Ctrl();
227  TEST_ASSERT_EQUAL(SPS_RESET_LOW, TEST_SPS_GetSpsState());
228 
229  /* transition through state-machine: SPS_RESET_LOW */
230  /* check that reset pin is reset
231  (we don't care for the actual address as long as the pin is correct) */
232  IO_PinReset_Expect(0u, SPS_RESET_PIN);
233  IO_PinReset_IgnoreArg_pRegisterAddress();
234  SPS_Ctrl();
235  /* timer should now be set to 5 */
236  TEST_ASSERT_EQUAL(defaultTimer, TEST_SPS_GetSpsTimer());
237  /* state should now be SPS_RESET_HIGH */
238  TEST_ASSERT_EQUAL(SPS_RESET_HIGH, TEST_SPS_GetSpsState());
239  /* test that timer decreases and nothing else happens */
240  SPS_Ctrl();
241  TEST_ASSERT_EQUAL((defaultTimer - 1u), TEST_SPS_GetSpsTimer());
242  TEST_ASSERT_EQUAL(SPS_RESET_HIGH, TEST_SPS_GetSpsState());
243  /* now that we know that it works: overwrite the timer so that
244  the next step can proceed */
246 
247  /* transition through state-machine: SPS_RESET_HIGH */
248  /* check that reset pin is set
249  (we don't care for the actual address as long as the pin is correct) */
250  IO_PinSet_Expect(0u, SPS_RESET_PIN);
251  IO_PinSet_IgnoreArg_pRegisterAddress();
252  SPS_Ctrl();
253  /* timer should now be set to 5 */
254  TEST_ASSERT_EQUAL(defaultTimer, TEST_SPS_GetSpsTimer());
255  /* state should now be SPS_CONFIGURE_CONTROL_REGISTER */
257  /* reset the timer so that we can continue */
259 
260  /* transition through state-machine: SPS_CONFIGURE_CONTROL_REGISTER */
261  /* check that we transmit the first set of commands */
262  SPI_TransmitReceiveData_IgnoreAndReturn(STD_OK);
263  MCU_delay_us_Ignore();
264  /* Since the transaction is successful, we should switch to high-speed */
265  SPI_SpsInterfaceSwitchToHighSpeed_Expect(&spi_spsInterface);
266  SPS_Ctrl();
267  /* state should be now SPS_TRIGGER_CURRENT_MEASUREMENT */
269 }
270 
272  /* go to state SPS_TRIGGER_CURRENT_MEASUREMENT */
274 
275  /* run state and let first transaction "fail" */
276  MCU_delay_us_Ignore();
277  SPI_TransmitReceiveData_ExpectAndReturn(NULL_PTR, NULL_PTR, NULL_PTR, 0u, STD_NOT_OK);
278  SPI_TransmitReceiveData_IgnoreArg_pSpiInterface();
279  SPI_TransmitReceiveData_IgnoreArg_pTxBuff();
280  SPI_TransmitReceiveData_IgnoreArg_pRxBuff();
281  SPI_TransmitReceiveData_IgnoreArg_frameLength();
282  SPI_TransmitReceiveData_ExpectAndReturn(NULL_PTR, NULL_PTR, NULL_PTR, 0u, STD_OK);
283  SPI_TransmitReceiveData_IgnoreArg_pSpiInterface();
284  SPI_TransmitReceiveData_IgnoreArg_pTxBuff();
285  SPI_TransmitReceiveData_IgnoreArg_pRxBuff();
286  SPI_TransmitReceiveData_IgnoreArg_frameLength();
287  SPS_Ctrl();
288 }
289 
291  /* go to state SPS_TRIGGER_CURRENT_MEASUREMENT */
293 
294  /* run state and let second transaction "fail" */
295  MCU_delay_us_Ignore();
296  SPI_TransmitReceiveData_ExpectAndReturn(NULL_PTR, NULL_PTR, NULL_PTR, 0u, STD_OK);
297  SPI_TransmitReceiveData_IgnoreArg_pSpiInterface();
298  SPI_TransmitReceiveData_IgnoreArg_pTxBuff();
299  SPI_TransmitReceiveData_IgnoreArg_pRxBuff();
300  SPI_TransmitReceiveData_IgnoreArg_frameLength();
301  SPI_TransmitReceiveData_ExpectAndReturn(NULL_PTR, NULL_PTR, NULL_PTR, 0u, STD_NOT_OK);
302  SPI_TransmitReceiveData_IgnoreArg_pSpiInterface();
303  SPI_TransmitReceiveData_IgnoreArg_pTxBuff();
304  SPI_TransmitReceiveData_IgnoreArg_pRxBuff();
305  SPI_TransmitReceiveData_IgnoreArg_frameLength();
306  SPS_Ctrl();
307 }
308 
310  /* go to state SPS_TRIGGER_CURRENT_MEASUREMENT */
312 
313  /* run state and let both transaction "fail" */
314  MCU_delay_us_Ignore();
315  SPI_TransmitReceiveData_IgnoreAndReturn(STD_NOT_OK);
316  SPS_Ctrl();
317 }
318 
320  /* go to state SPS_CONFIGURE_CONTROL_REGISTER */
322 
323  /* run state and let both transaction "fail" */
324  MCU_delay_us_Ignore();
325  SPI_TransmitReceiveData_IgnoreAndReturn(STD_NOT_OK);
326  SPS_Ctrl();
327  TEST_ASSERT_EQUAL(SPS_START, TEST_SPS_GetSpsState());
328 }
329 
331  /* go to state SPS_TRIGGER_CURRENT_MEASUREMENT */
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_READ_EN_IRQ_PIN */
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_MEASURED_CURRENT1 */
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_CURRENT2 */
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_CURRENT3 */
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_CURRENT4 */
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_TRIGGER_CURRENT_MEASUREMENT */
399 
400  /* let transactions always succeed */
401  MCU_delay_us_Ignore();
402  SPI_TransmitReceiveData_IgnoreAndReturn(STD_OK);
403 
404  /* run state chain */
405  SPS_Ctrl();
406  TEST_ASSERT_EQUAL(SPS_READ_EN_IRQ_PIN, TEST_SPS_GetSpsState());
407  SPS_Ctrl();
408  TEST_ASSERT_EQUAL(SPS_READ_MEASURED_CURRENT1, TEST_SPS_GetSpsState());
409  SPS_Ctrl();
410  TEST_ASSERT_EQUAL(SPS_READ_MEASURED_CURRENT2, TEST_SPS_GetSpsState());
411  SPS_Ctrl();
412  TEST_ASSERT_EQUAL(SPS_READ_MEASURED_CURRENT3, TEST_SPS_GetSpsState());
413  SPS_Ctrl();
414  TEST_ASSERT_EQUAL(SPS_READ_MEASURED_CURRENT4, TEST_SPS_GetSpsState());
415  SPS_Ctrl();
417 }
418 
420  /* go to illegal state 128 */
421  TEST_SPS_SetSpsState(128u);
422 
424 }
425 
427  OS_EnterTaskCritical_Ignore();
428  OS_ExitTaskCritical_Ignore();
429 
430  /* switch on a first, second, third and fourth channel */
431  TEST_ASSERT_EQUAL(SPS_CHANNEL_OFF, sps_channelStatus[0u].channelRequested);
433  TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[0u].channelRequested);
434  TEST_ASSERT_EQUAL(SPS_CHANNEL_OFF, sps_channelStatus[0u].channel);
435 
436  TEST_ASSERT_EQUAL(SPS_CHANNEL_OFF, sps_channelStatus[1u].channelRequested);
438  TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[1u].channelRequested);
439  TEST_ASSERT_EQUAL(SPS_CHANNEL_OFF, sps_channelStatus[1u].channel);
440 
441  TEST_ASSERT_EQUAL(SPS_CHANNEL_OFF, sps_channelStatus[6u].channelRequested);
443  TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[6u].channelRequested);
444  TEST_ASSERT_EQUAL(SPS_CHANNEL_OFF, sps_channelStatus[6u].channel);
445 
446  TEST_ASSERT_EQUAL(SPS_CHANNEL_OFF, sps_channelStatus[7u].channelRequested);
448  TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[7u].channelRequested);
449  TEST_ASSERT_EQUAL(SPS_CHANNEL_OFF, sps_channelStatus[7u].channel);
450 
451  /* cycle over one state that handles channels */
453  SPI_TransmitReceiveData_IgnoreAndReturn(STD_OK);
454  MCU_delay_us_Ignore();
455  SPS_Ctrl();
456 
457  /* check that channels have been marked as on */
458  TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[0u].channel);
459  TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[1u].channel);
460  TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[6u].channel);
461  TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[7u].channel);
462 
463  /* switch off a first, second, third and fourth channel */
464  TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[0u].channelRequested);
466  TEST_ASSERT_EQUAL(SPS_CHANNEL_OFF, sps_channelStatus[0u].channelRequested);
467  TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[0u].channel);
468 
469  TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[1u].channelRequested);
471  TEST_ASSERT_EQUAL(SPS_CHANNEL_OFF, sps_channelStatus[1u].channelRequested);
472  TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[1u].channel);
473 
474  TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[6u].channelRequested);
476  TEST_ASSERT_EQUAL(SPS_CHANNEL_OFF, sps_channelStatus[6u].channelRequested);
477  TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[6u].channel);
478 
479  TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[7u].channelRequested);
481  TEST_ASSERT_EQUAL(SPS_CHANNEL_OFF, sps_channelStatus[7u].channelRequested);
482  TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[7u].channel);
483 
484  /* cycle over one state that handles channels */
486  SPI_TransmitReceiveData_IgnoreAndReturn(STD_OK);
487  MCU_delay_us_Ignore();
488  SPS_Ctrl();
489 
490  /* check that channels have been marked as off */
491  TEST_ASSERT_EQUAL(SPS_CHANNEL_OFF, sps_channelStatus[0u].channel);
492  TEST_ASSERT_EQUAL(SPS_CHANNEL_OFF, sps_channelStatus[1u].channel);
493  TEST_ASSERT_EQUAL(SPS_CHANNEL_OFF, sps_channelStatus[6u].channel);
494  TEST_ASSERT_EQUAL(SPS_CHANNEL_OFF, sps_channelStatus[7u].channel);
495 }
496 
497 /** test the states of PEX feedback function */
499  /* report pin state 0 with normally open --> should report switch off */
500  PEX_GetPin_ExpectAndReturn(PEX_PORT_EXPANDER1, PEX_PIN00, 0u);
501  TEST_ASSERT_EQUAL(CONT_SWITCH_OFF, SPS_GetChannelPexFeedback(0u, true));
502 
503  /* report pin state 1 with normally open --> should report switch on */
504  PEX_GetPin_ExpectAndReturn(PEX_PORT_EXPANDER1, PEX_PIN00, 1u);
505  TEST_ASSERT_EQUAL(CONT_SWITCH_ON, SPS_GetChannelPexFeedback(0u, true));
506 
507  /* report pin state 0 with normally closed --> should report switch on */
508  PEX_GetPin_ExpectAndReturn(PEX_PORT_EXPANDER1, PEX_PIN00, 0u);
509  TEST_ASSERT_EQUAL(CONT_SWITCH_ON, SPS_GetChannelPexFeedback(0u, false));
510 
511  /* report pin state 1 with normally closed --> should report switch off */
512  PEX_GetPin_ExpectAndReturn(PEX_PORT_EXPANDER1, PEX_PIN00, 1u);
513  TEST_ASSERT_EQUAL(CONT_SWITCH_OFF, SPS_GetChannelPexFeedback(0u, false));
514 }
@ CONT_SWITCH_ON
Definition: contactor_cfg.h:72
@ CONT_SWITCH_OFF
Definition: contactor_cfg.h:71
@ STD_NOT_OK
Definition: fstd_types.h:82
@ STD_OK
Definition: fstd_types.h:81
#define NULL_PTR
Null pointer.
Definition: fstd_types.h:75
#define PEX_PIN05
Definition: pex_cfg.h:85
#define PEX_PIN02
Definition: pex_cfg.h:82
#define PEX_PIN00
Definition: pex_cfg.h:80
#define PEX_PIN03
Definition: pex_cfg.h:83
#define PEX_PIN01
Definition: pex_cfg.h:81
#define PEX_PIN07
Definition: pex_cfg.h:87
#define PEX_PIN06
Definition: pex_cfg.h:86
#define PEX_PIN04
Definition: pex_cfg.h:84
#define PEX_PORT_EXPANDER1
Definition: pex_cfg.h:73
CONT_ELECTRICAL_STATE_TYPE_e SPS_GetChannelPexFeedback(const SPS_CHANNEL_INDEX channelIndex, bool normallyOpen)
Get the feedback state of a channel.
Definition: sps.c:622
SPS_CHANNEL_AFFILIATION_e SPS_GetChannelAffiliation(SPS_CHANNEL_INDEX channelIndex)
Returns the channel affiliation.
Definition: sps.c:645
void TEST_SPS_RequestChannelState(SPS_CHANNEL_INDEX channelIndex, SPS_CHANNEL_FUNCTION_e channelFunction)
Definition: sps.c:652
void SPS_Ctrl(void)
Control function for the CONT driver state machine.
Definition: sps.c:475
uint8_t TEST_SPS_GetSpsTimer(void)
Definition: sps.c:661
void TEST_SPS_SetSpsTimer(const uint8_t newTimer)
Definition: sps.c:664
void SPS_RequestGeneralIOState(SPS_CHANNEL_INDEX channelIndex, SPS_CHANNEL_FUNCTION_e channelFunction)
Request state of a general IO.
Definition: sps.c:601
CONT_ELECTRICAL_STATE_TYPE_e SPS_GetChannelCurrentFeedback(const SPS_CHANNEL_INDEX channelIndex)
Get feedback value.
Definition: sps.c:606
void SPS_RequestContactorState(SPS_CHANNEL_INDEX channelIndex, SPS_CHANNEL_FUNCTION_e channelFunction)
Request state of a contactor.
Definition: sps.c:596
SPS_STATE_e TEST_SPS_GetSpsState(void)
Definition: sps.c:655
void TEST_SPS_SetSpsState(const SPS_STATE_e newState)
Definition: sps.c:658
Headers for the driver for the smart power switches.
#define SPS_CHANNEL_ON_DEFAULT_THRESHOLD_mA
Definition: sps_cfg.h:153
#define SPS_NR_OF_AVAILABLE_SPS_CHANNELS
Definition: sps_cfg.h:88
@ SPS_CHANNEL_ON
Definition: sps_cfg.h:174
@ SPS_CHANNEL_OFF
Definition: sps_cfg.h:173
@ SPS_TRIGGER_CURRENT_MEASUREMENT
Definition: sps_cfg.h:203
@ SPS_CONFIGURE_CONTROL_REGISTER
Definition: sps_cfg.h:202
@ SPS_READ_MEASURED_CURRENT2
Definition: sps_cfg.h:205
@ SPS_READ_MEASURED_CURRENT1
Definition: sps_cfg.h:204
@ SPS_RESET_LOW
Definition: sps_cfg.h:200
@ SPS_READ_EN_IRQ_PIN
Definition: sps_cfg.h:208
@ SPS_READ_MEASURED_CURRENT3
Definition: sps_cfg.h:206
@ SPS_START
Definition: sps_cfg.h:199
@ SPS_READ_MEASURED_CURRENT4
Definition: sps_cfg.h:207
@ SPS_RESET_HIGH
Definition: sps_cfg.h:201
#define SPS_RESET_PIN
Definition: sps_cfg.h:69
uint8_t SPS_CHANNEL_INDEX
Definition: sps_types.h:63
@ SPS_AFF_CONTACTOR
Definition: sps_types.h:72
@ SPS_AFF_GENERAL_IO
Definition: sps_types.h:73
spiDAT1_t * pConfig
Definition: spi_cfg.h:140
SPS_CHANNEL_FUNCTION_e channelRequested
Definition: sps_cfg.h:179
float current_mA
Definition: sps_cfg.h:181
SPS_CHANNEL_FUNCTION_e channel
Definition: sps_cfg.h:180
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:136
void testSPS_RequestGeneralIOStateWrongAffiliation(void)
Definition: test_sps.c:197
void testContactorSwitchOnAndOff(void)
Definition: test_sps.c:426
void testSPS_RequestContactorStateCorrectAffiliation(void)
Definition: test_sps.c:189
void testSPS_RequestChannelStateInvalidFunction(void)
Definition: test_sps.c:132
void testSPS_CtrlResetFromStateSPS_TRIGGER_CURRENT_MEASUREMENT(void)
Definition: test_sps.c:330
SPS_CHANNEL_STATE_s sps_channelStatus[SPS_NR_OF_AVAILABLE_SPS_CHANNELS]
Definition: test_sps.c:91
void testSPS_CtrlNormalOperationCycle(void)
Definition: test_sps.c:396
void testSPS_GetChannelFeedbackChannelLow(void)
Definition: test_sps.c:151
void testSPS_CtrlResetFromStateSPS_READ_MEASURED_CURRENT3(void)
Definition: test_sps.c:374
void testSPS_CtrlResetFromStateSPS_READ_MEASURED_CURRENT4(void)
Definition: test_sps.c:385
void testSPS_CtrlResetFromStateSPS_READ_EN_IRQ_PIN(void)
Definition: test_sps.c:341
void testSPS_RequestGIOStateCorrectAffiliation(void)
Definition: test_sps.c:207
void testSPS_CtrlStartupProcedure(void)
Definition: test_sps.c:215
void testSPS_GetChannelAffiliationValidIndex(void)
Definition: test_sps.c:173
void testSPS_CtrlResetFromStateSPS_READ_MEASURED_CURRENT1(void)
Definition: test_sps.c:352
void testSPS_CtrlResetOnFailedSecondTransaction(void)
Definition: test_sps.c:290
void testSPS_CtrlAssertOnIllegalState(void)
Definition: test_sps.c:419
void testSPS_RequestGeneralIOStateWrongIndex(void)
Definition: test_sps.c:202
void setUp(void)
Definition: test_sps.c:114
void tearDown(void)
Definition: test_sps.c:124
void testSPS_RequestContactorStateWrongAffiliation(void)
Definition: test_sps.c:179
void testSPS_GetChannelAffiliationInvalidIndex(void)
Definition: test_sps.c:169
void testSPS_CtrlResetOnFailedBothTransactions(void)
Definition: test_sps.c:309
void testSPS_RequestContactorStateWrongIndex(void)
Definition: test_sps.c:184
void testSPS_GetChannelPexFeedback(void)
Definition: test_sps.c:498
const SPS_CHANNEL_FEEDBACK_MAPPING_s sps_kChannelFeedbackMapping[SPS_NR_OF_AVAILABLE_SPS_CHANNELS]
Definition: test_sps.c:102
static const spiDAT1_t spi_kSpsDataConfig
Definition: test_sps.c:74
void testSPS_CtrlResetFromStateSPS_READ_MEASURED_CURRENT2(void)
Definition: test_sps.c:363
void testSPS_CtrlResetOnFailedFirstTransaction(void)
Definition: test_sps.c:271
void testSPS_GetChannelFeedbackChannelHigh(void)
Definition: test_sps.c:160
SPI_INTERFACE_CONFIG_s spi_spsInterface
Definition: test_sps.c:83
void testSPS_GetChannelFeedbackInvalidChannelIndex(void)
Definition: test_sps.c:147
void testSPS_RequestChannelStateInvalidIndex(void)
Definition: test_sps.c:128
void testSPS_CtrlResetFromStateSPS_CONFIGURE_CONTROL_REGISTER(void)
Definition: test_sps.c:319