foxBMS - Unit Tests  1.5.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-02-03 (date of last update)
47  * @version v1.5.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 /*========== Definitions and Implementations for Unit Test ==================*/
76 /** SPI data configuration struct for SPS communication */
77 static const spiDAT1_t spi_kSpsDataConfig = {
78  /* struct is implemented in the TI HAL and uses uppercase true and false */
79  .CS_HOLD = FALSE, /*!< The HW chip select signal is deactivated */
80  .WDEL = TRUE, /*!< No delay will be inserted */
81  .DFSEL = SPI_FMT_0, /*!< Data word format select: data format 0 (SPI3) */
82  .CSNR = 0x0, /*!< Chip select (CS) number; 0x01h for CS[0] */
83 };
84 
85 /** SPI interface configuration for SPS communication */
88  .pNode = spiREG3,
89  .pGioPort = &(spiREG3->PC3),
90  .csPin = 2u,
91 };
92 
93 /** channel states */
103 };
104 
114 };
115 
116 /*========== Setup and Teardown =============================================*/
117 void setUp(void) {
118  /* make sure variables are in a known state */
119 
120  for (uint8_t channel = 0u; channel < SPS_NR_OF_AVAILABLE_SPS_CHANNELS; channel++) {
123  sps_channelStatus[channel].current_mA = 0.0f;
124  }
125 }
126 
127 void tearDown(void) {
128 }
129 
130 /*========== Test Cases =====================================================*/
133 }
134 
137 }
138 
140  OS_EnterTaskCritical_Ignore();
141  OS_ExitTaskCritical_Ignore();
142 
143  TEST_ASSERT_EQUAL(SPS_CHANNEL_OFF, sps_channelStatus[0u].channelRequested);
145  TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[0u].channelRequested);
147  TEST_ASSERT_EQUAL(SPS_CHANNEL_OFF, sps_channelStatus[0u].channelRequested);
148 }
149 
152 }
153 
155  OS_EnterTaskCritical_Ignore();
156  OS_ExitTaskCritical_Ignore();
157 
159 
160  TEST_ASSERT_EQUAL(CONT_SWITCH_OFF, SPS_GetChannelCurrentFeedback(0u));
161 }
162 
164  OS_EnterTaskCritical_Ignore();
165  OS_ExitTaskCritical_Ignore();
166 
167  sps_channelStatus[0].current_mA = 600.f;
168 
169  TEST_ASSERT_EQUAL(CONT_SWITCH_ON, SPS_GetChannelCurrentFeedback(0u));
170 }
171 
174 }
175 
177  for (SPS_CHANNEL_INDEX index = 0u; index < SPS_NR_OF_AVAILABLE_SPS_CHANNELS; index++) {
178  TEST_ASSERT_EQUAL(sps_channelStatus[index].affiliation, SPS_GetChannelAffiliation(index));
179  }
180 }
181 
183  /* watch out, the channel here has to have an affiliation that is not SPS_AFF_CONTACTOR */
185 }
186 
188  /* a wrong index should also lead here to an assertion */
190 }
191 
193  OS_EnterTaskCritical_Ignore();
194  OS_ExitTaskCritical_Ignore();
195  /* watch out, the channel here has to have an affiliation that is SPS_AFF_CONTACTOR */
197  TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[0u].channelRequested);
198 }
199 
201  /* watch out, the channel here has to have an affiliation that is not SPS_AFF_GENERAL_IO */
203 }
204 
206  /* a wrong index should also lead here to an assertion */
208 }
209 
211  OS_EnterTaskCritical_Ignore();
212  OS_ExitTaskCritical_Ignore();
213  /* watch out, the channel here has to have an affiliation that is SPS_AFF_GENERAL_IO */
215  TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[7u].channelRequested);
216 }
217 
219  /* default wait time */
220  const uint8_t defaultTimer = 5u;
221 
222  /* check that we init in SPS_START otherwise this test has to be adapted */
223  TEST_ASSERT_EQUAL(SPS_START, TEST_SPS_GetSpsState());
224  TEST_ASSERT_EQUAL(0u, TEST_SPS_GetSpsTimer());
225 
226  /* transition through state-machine: SPS_START */
227  /* interface should become switched to low speed */
228  SPI_SpsInterfaceSwitchToLowSpeed_Expect(&spi_spsInterface);
229  SPS_Ctrl();
230  TEST_ASSERT_EQUAL(SPS_RESET_LOW, TEST_SPS_GetSpsState());
231 
232  /* transition through state-machine: SPS_RESET_LOW */
233  /* check that reset pin is reset
234  (we don't care for the actual address as long as the pin is correct) */
235  IO_PinReset_Expect(0u, SPS_RESET_PIN);
236  IO_PinReset_IgnoreArg_pRegisterAddress();
237  SPS_Ctrl();
238  /* timer should now be set to 5 */
239  TEST_ASSERT_EQUAL(defaultTimer, TEST_SPS_GetSpsTimer());
240  /* state should now be SPS_RESET_HIGH */
241  TEST_ASSERT_EQUAL(SPS_RESET_HIGH, TEST_SPS_GetSpsState());
242  /* test that timer decreases and nothing else happens */
243  SPS_Ctrl();
244  TEST_ASSERT_EQUAL((defaultTimer - 1u), TEST_SPS_GetSpsTimer());
245  TEST_ASSERT_EQUAL(SPS_RESET_HIGH, TEST_SPS_GetSpsState());
246  /* now that we know that it works: overwrite the timer so that
247  the next step can proceed */
249 
250  /* transition through state-machine: SPS_RESET_HIGH */
251  /* check that reset pin is set
252  (we don't care for the actual address as long as the pin is correct) */
253  IO_PinSet_Expect(0u, SPS_RESET_PIN);
254  IO_PinSet_IgnoreArg_pRegisterAddress();
255  SPS_Ctrl();
256  /* timer should now be set to 5 */
257  TEST_ASSERT_EQUAL(defaultTimer, TEST_SPS_GetSpsTimer());
258  /* state should now be SPS_CONFIGURE_CONTROL_REGISTER */
260  /* reset the timer so that we can continue */
262 
263  /* transition through state-machine: SPS_CONFIGURE_CONTROL_REGISTER */
264  /* check that we transmit the first set of commands */
265  SPI_TransmitReceiveData_IgnoreAndReturn(STD_OK);
266  MCU_Delay_us_Ignore();
267  /* Since the transaction is successful, we should switch to high-speed */
268  SPI_SpsInterfaceSwitchToHighSpeed_Expect(&spi_spsInterface);
269  SPS_Ctrl();
270  /* state should be now SPS_TRIGGER_CURRENT_MEASUREMENT */
272 }
273 
275  /* go to state SPS_TRIGGER_CURRENT_MEASUREMENT */
277 
278  /* run state and let first transaction "fail" */
279  MCU_Delay_us_Ignore();
280  SPI_TransmitReceiveData_ExpectAndReturn(NULL_PTR, NULL_PTR, NULL_PTR, 0u, STD_NOT_OK);
281  SPI_TransmitReceiveData_IgnoreArg_pSpiInterface();
282  SPI_TransmitReceiveData_IgnoreArg_pTxBuff();
283  SPI_TransmitReceiveData_IgnoreArg_pRxBuff();
284  SPI_TransmitReceiveData_IgnoreArg_frameLength();
285  SPI_TransmitReceiveData_ExpectAndReturn(NULL_PTR, NULL_PTR, NULL_PTR, 0u, STD_OK);
286  SPI_TransmitReceiveData_IgnoreArg_pSpiInterface();
287  SPI_TransmitReceiveData_IgnoreArg_pTxBuff();
288  SPI_TransmitReceiveData_IgnoreArg_pRxBuff();
289  SPI_TransmitReceiveData_IgnoreArg_frameLength();
290  SPS_Ctrl();
291 }
292 
294  /* go to state SPS_TRIGGER_CURRENT_MEASUREMENT */
296 
297  /* run state and let second transaction "fail" */
298  MCU_Delay_us_Ignore();
299  SPI_TransmitReceiveData_ExpectAndReturn(NULL_PTR, NULL_PTR, NULL_PTR, 0u, STD_OK);
300  SPI_TransmitReceiveData_IgnoreArg_pSpiInterface();
301  SPI_TransmitReceiveData_IgnoreArg_pTxBuff();
302  SPI_TransmitReceiveData_IgnoreArg_pRxBuff();
303  SPI_TransmitReceiveData_IgnoreArg_frameLength();
304  SPI_TransmitReceiveData_ExpectAndReturn(NULL_PTR, NULL_PTR, NULL_PTR, 0u, STD_NOT_OK);
305  SPI_TransmitReceiveData_IgnoreArg_pSpiInterface();
306  SPI_TransmitReceiveData_IgnoreArg_pTxBuff();
307  SPI_TransmitReceiveData_IgnoreArg_pRxBuff();
308  SPI_TransmitReceiveData_IgnoreArg_frameLength();
309  SPS_Ctrl();
310 }
311 
313  /* go to state SPS_TRIGGER_CURRENT_MEASUREMENT */
315 
316  /* run state and let both transaction "fail" */
317  MCU_Delay_us_Ignore();
318  SPI_TransmitReceiveData_IgnoreAndReturn(STD_NOT_OK);
319  SPS_Ctrl();
320 }
321 
323  /* go to state SPS_CONFIGURE_CONTROL_REGISTER */
325 
326  /* run state and let both transaction "fail" */
327  MCU_Delay_us_Ignore();
328  SPI_TransmitReceiveData_IgnoreAndReturn(STD_NOT_OK);
329  SPS_Ctrl();
330  TEST_ASSERT_EQUAL(SPS_START, TEST_SPS_GetSpsState());
331 }
332 
334  /* go to state SPS_TRIGGER_CURRENT_MEASUREMENT */
336 
337  /* run state and let both transaction "fail" */
338  MCU_Delay_us_Ignore();
339  SPI_TransmitReceiveData_IgnoreAndReturn(STD_NOT_OK);
340  SPS_Ctrl();
341  TEST_ASSERT_EQUAL(SPS_START, TEST_SPS_GetSpsState());
342 }
343 
345  /* go to state SPS_READ_EN_IRQ_PIN */
347 
348  /* run state and let both transaction "fail" */
349  MCU_Delay_us_Ignore();
350  SPI_TransmitReceiveData_IgnoreAndReturn(STD_NOT_OK);
351  SPS_Ctrl();
352  TEST_ASSERT_EQUAL(SPS_START, TEST_SPS_GetSpsState());
353 }
354 
356  /* go to state SPS_READ_MEASURED_CURRENT1 */
358 
359  /* run state and let both transaction "fail" */
360  MCU_Delay_us_Ignore();
361  SPI_TransmitReceiveData_IgnoreAndReturn(STD_NOT_OK);
362  SPS_Ctrl();
363  TEST_ASSERT_EQUAL(SPS_START, TEST_SPS_GetSpsState());
364 }
365 
367  /* go to state SPS_READ_MEASURED_CURRENT2 */
369 
370  /* run state and let both transaction "fail" */
371  MCU_Delay_us_Ignore();
372  SPI_TransmitReceiveData_IgnoreAndReturn(STD_NOT_OK);
373  SPS_Ctrl();
374  TEST_ASSERT_EQUAL(SPS_START, TEST_SPS_GetSpsState());
375 }
376 
378  /* go to state SPS_READ_MEASURED_CURRENT3 */
380 
381  /* run state and let both transaction "fail" */
382  MCU_Delay_us_Ignore();
383  SPI_TransmitReceiveData_IgnoreAndReturn(STD_NOT_OK);
384  SPS_Ctrl();
385  TEST_ASSERT_EQUAL(SPS_START, TEST_SPS_GetSpsState());
386 }
387 
389  /* go to state SPS_READ_MEASURED_CURRENT4 */
391 
392  /* run state and let both transaction "fail" */
393  MCU_Delay_us_Ignore();
394  SPI_TransmitReceiveData_IgnoreAndReturn(STD_NOT_OK);
395  SPS_Ctrl();
396  TEST_ASSERT_EQUAL(SPS_START, TEST_SPS_GetSpsState());
397 }
398 
400  /* go to state SPS_TRIGGER_CURRENT_MEASUREMENT */
402 
403  /* let transactions always succeed */
404  MCU_Delay_us_Ignore();
405  SPI_TransmitReceiveData_IgnoreAndReturn(STD_OK);
406 
407  /* run state chain */
408  SPS_Ctrl();
409  TEST_ASSERT_EQUAL(SPS_READ_EN_IRQ_PIN, TEST_SPS_GetSpsState());
410  SPS_Ctrl();
411  TEST_ASSERT_EQUAL(SPS_READ_MEASURED_CURRENT1, TEST_SPS_GetSpsState());
412  SPS_Ctrl();
413  TEST_ASSERT_EQUAL(SPS_READ_MEASURED_CURRENT2, TEST_SPS_GetSpsState());
414  SPS_Ctrl();
415  TEST_ASSERT_EQUAL(SPS_READ_MEASURED_CURRENT3, TEST_SPS_GetSpsState());
416  SPS_Ctrl();
417  TEST_ASSERT_EQUAL(SPS_READ_MEASURED_CURRENT4, TEST_SPS_GetSpsState());
418  SPS_Ctrl();
420 }
421 
423  /* go to illegal state 128 */
424  TEST_SPS_SetSpsState(128u);
425 
427 }
428 
430  OS_EnterTaskCritical_Ignore();
431  OS_ExitTaskCritical_Ignore();
432 
433  /* switch on a first, second, third and fourth channel */
434  TEST_ASSERT_EQUAL(SPS_CHANNEL_OFF, sps_channelStatus[0u].channelRequested);
436  TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[0u].channelRequested);
437  TEST_ASSERT_EQUAL(SPS_CHANNEL_OFF, sps_channelStatus[0u].channel);
438 
439  TEST_ASSERT_EQUAL(SPS_CHANNEL_OFF, sps_channelStatus[1u].channelRequested);
441  TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[1u].channelRequested);
442  TEST_ASSERT_EQUAL(SPS_CHANNEL_OFF, sps_channelStatus[1u].channel);
443 
444  TEST_ASSERT_EQUAL(SPS_CHANNEL_OFF, sps_channelStatus[6u].channelRequested);
446  TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[6u].channelRequested);
447  TEST_ASSERT_EQUAL(SPS_CHANNEL_OFF, sps_channelStatus[6u].channel);
448 
449  TEST_ASSERT_EQUAL(SPS_CHANNEL_OFF, sps_channelStatus[7u].channelRequested);
451  TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[7u].channelRequested);
452  TEST_ASSERT_EQUAL(SPS_CHANNEL_OFF, sps_channelStatus[7u].channel);
453 
454  /* cycle over one state that handles channels */
456  SPI_TransmitReceiveData_IgnoreAndReturn(STD_OK);
457  MCU_Delay_us_Ignore();
458  SPS_Ctrl();
459 
460  /* check that channels have been marked as on */
461  TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[0u].channel);
462  TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[1u].channel);
463  TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[6u].channel);
464  TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[7u].channel);
465 
466  /* switch off a first, second, third and fourth channel */
467  TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[0u].channelRequested);
469  TEST_ASSERT_EQUAL(SPS_CHANNEL_OFF, sps_channelStatus[0u].channelRequested);
470  TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[0u].channel);
471 
472  TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[1u].channelRequested);
474  TEST_ASSERT_EQUAL(SPS_CHANNEL_OFF, sps_channelStatus[1u].channelRequested);
475  TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[1u].channel);
476 
477  TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[6u].channelRequested);
479  TEST_ASSERT_EQUAL(SPS_CHANNEL_OFF, sps_channelStatus[6u].channelRequested);
480  TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[6u].channel);
481 
482  TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[7u].channelRequested);
484  TEST_ASSERT_EQUAL(SPS_CHANNEL_OFF, sps_channelStatus[7u].channelRequested);
485  TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[7u].channel);
486 
487  /* cycle over one state that handles channels */
489  SPI_TransmitReceiveData_IgnoreAndReturn(STD_OK);
490  MCU_Delay_us_Ignore();
491  SPS_Ctrl();
492 
493  /* check that channels have been marked as off */
494  TEST_ASSERT_EQUAL(SPS_CHANNEL_OFF, sps_channelStatus[0u].channel);
495  TEST_ASSERT_EQUAL(SPS_CHANNEL_OFF, sps_channelStatus[1u].channel);
496  TEST_ASSERT_EQUAL(SPS_CHANNEL_OFF, sps_channelStatus[6u].channel);
497  TEST_ASSERT_EQUAL(SPS_CHANNEL_OFF, sps_channelStatus[7u].channel);
498 }
499 
500 /** test the states of PEX feedback function */
502  /* report pin state 0 with normally open --> should report switch off */
503  PEX_GetPin_ExpectAndReturn(PEX_PORT_EXPANDER1, PEX_PIN00, 0u);
504  TEST_ASSERT_EQUAL(CONT_SWITCH_OFF, SPS_GetChannelPexFeedback(0u, true));
505 
506  /* report pin state 1 with normally open --> should report switch on */
507  PEX_GetPin_ExpectAndReturn(PEX_PORT_EXPANDER1, PEX_PIN00, 1u);
508  TEST_ASSERT_EQUAL(CONT_SWITCH_ON, SPS_GetChannelPexFeedback(0u, true));
509 
510  /* report pin state 0 with normally closed --> should report switch on */
511  PEX_GetPin_ExpectAndReturn(PEX_PORT_EXPANDER1, PEX_PIN00, 0u);
512  TEST_ASSERT_EQUAL(CONT_SWITCH_ON, SPS_GetChannelPexFeedback(0u, false));
513 
514  /* report pin state 1 with normally closed --> should report switch off */
515  PEX_GetPin_ExpectAndReturn(PEX_PORT_EXPANDER1, PEX_PIN00, 1u);
516  TEST_ASSERT_EQUAL(CONT_SWITCH_OFF, SPS_GetChannelPexFeedback(0u, false));
517 }
@ 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:139
void testSPS_RequestGeneralIOStateWrongAffiliation(void)
Definition: test_sps.c:200
void testContactorSwitchOnAndOff(void)
Definition: test_sps.c:429
void testSPS_RequestContactorStateCorrectAffiliation(void)
Definition: test_sps.c:192
void testSPS_RequestChannelStateInvalidFunction(void)
Definition: test_sps.c:135
void testSPS_CtrlResetFromStateSPS_TRIGGER_CURRENT_MEASUREMENT(void)
Definition: test_sps.c:333
SPS_CHANNEL_STATE_s sps_channelStatus[SPS_NR_OF_AVAILABLE_SPS_CHANNELS]
Definition: test_sps.c:94
void testSPS_CtrlNormalOperationCycle(void)
Definition: test_sps.c:399
void testSPS_GetChannelFeedbackChannelLow(void)
Definition: test_sps.c:154
void testSPS_CtrlResetFromStateSPS_READ_MEASURED_CURRENT3(void)
Definition: test_sps.c:377
void testSPS_CtrlResetFromStateSPS_READ_MEASURED_CURRENT4(void)
Definition: test_sps.c:388
void testSPS_CtrlResetFromStateSPS_READ_EN_IRQ_PIN(void)
Definition: test_sps.c:344
void testSPS_RequestGIOStateCorrectAffiliation(void)
Definition: test_sps.c:210
void testSPS_CtrlStartupProcedure(void)
Definition: test_sps.c:218
void testSPS_GetChannelAffiliationValidIndex(void)
Definition: test_sps.c:176
void testSPS_CtrlResetFromStateSPS_READ_MEASURED_CURRENT1(void)
Definition: test_sps.c:355
void testSPS_CtrlResetOnFailedSecondTransaction(void)
Definition: test_sps.c:293
void testSPS_CtrlAssertOnIllegalState(void)
Definition: test_sps.c:422
void testSPS_RequestGeneralIOStateWrongIndex(void)
Definition: test_sps.c:205
void setUp(void)
Definition: test_sps.c:117
void tearDown(void)
Definition: test_sps.c:127
void testSPS_RequestContactorStateWrongAffiliation(void)
Definition: test_sps.c:182
void testSPS_GetChannelAffiliationInvalidIndex(void)
Definition: test_sps.c:172
void testSPS_CtrlResetOnFailedBothTransactions(void)
Definition: test_sps.c:312
void testSPS_RequestContactorStateWrongIndex(void)
Definition: test_sps.c:187
void testSPS_GetChannelPexFeedback(void)
Definition: test_sps.c:501
const SPS_CHANNEL_FEEDBACK_MAPPING_s sps_kChannelFeedbackMapping[SPS_NR_OF_AVAILABLE_SPS_CHANNELS]
Definition: test_sps.c:105
static const spiDAT1_t spi_kSpsDataConfig
Definition: test_sps.c:77
void testSPS_CtrlResetFromStateSPS_READ_MEASURED_CURRENT2(void)
Definition: test_sps.c:366
void testSPS_CtrlResetOnFailedFirstTransaction(void)
Definition: test_sps.c:274
void testSPS_GetChannelFeedbackChannelHigh(void)
Definition: test_sps.c:163
SPI_INTERFACE_CONFIG_s spi_spsInterface
Definition: test_sps.c:86
void testSPS_GetChannelFeedbackInvalidChannelIndex(void)
Definition: test_sps.c:150
void testSPS_RequestChannelStateInvalidIndex(void)
Definition: test_sps.c:131
void testSPS_CtrlResetFromStateSPS_CONFIGURE_CONTROL_REGISTER(void)
Definition: test_sps.c:322