foxBMS - Unit Tests  1.4.0
The foxBMS Unit Tests API Documentation
test_sps.c
Go to the documentation of this file.
1 /**
2  *
3  * @copyright © 2010 - 2022, 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 2022-07-28 (date of last update)
47  * @version v1.4.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 /*========== Definitions and Implementations for Unit Test ==================*/
74 /** SPI data configuration struct for SPS communication */
75 static const spiDAT1_t spi_kSpsDataConfig = {
76  /* struct is implemented in the TI HAL and uses uppercase true and false */
77  .CS_HOLD = FALSE, /*!< The HW chip select signal is deactivated */
78  .WDEL = TRUE, /*!< No delay will be inserted */
79  .DFSEL = SPI_FMT_0, /*!< Data word format select: data format 0 (SPI3) */
80  .CSNR = 0x0, /*!< Chip select (CS) number; 0x01h for CS[0] */
81 };
82 
83 /** SPI interface configuration for SPS communication */
86  .pNode = spiREG3,
87  .pGioPort = &(spiREG3->PC3),
88  .csPin = 2u,
89 };
90 
91 /** channel states */
101 };
102 
112 };
113 
114 /*========== Setup and Teardown =============================================*/
115 void setUp(void) {
116  /* make sure variables are in a known state */
117 
118  for (uint8_t channel = 0u; channel < SPS_NR_OF_AVAILABLE_SPS_CHANNELS; channel++) {
121  sps_channelStatus[channel].current_mA = 0.0f;
122  }
123 }
124 
125 void tearDown(void) {
126 }
127 
128 /*========== Test Cases =====================================================*/
131 }
132 
135 }
136 
138  OS_EnterTaskCritical_Ignore();
139  OS_ExitTaskCritical_Ignore();
140 
141  TEST_ASSERT_EQUAL(SPS_CHANNEL_OFF, sps_channelStatus[0u].channelRequested);
143  TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[0u].channelRequested);
145  TEST_ASSERT_EQUAL(SPS_CHANNEL_OFF, sps_channelStatus[0u].channelRequested);
146 }
147 
150 }
151 
153  OS_EnterTaskCritical_Ignore();
154  OS_ExitTaskCritical_Ignore();
155 
157 
158  TEST_ASSERT_EQUAL(CONT_SWITCH_OFF, SPS_GetChannelCurrentFeedback(0u));
159 }
160 
162  OS_EnterTaskCritical_Ignore();
163  OS_ExitTaskCritical_Ignore();
164 
165  sps_channelStatus[0].current_mA = 600.f;
166 
167  TEST_ASSERT_EQUAL(CONT_SWITCH_ON, SPS_GetChannelCurrentFeedback(0u));
168 }
169 
172 }
173 
175  for (SPS_CHANNEL_INDEX index = 0u; index < SPS_NR_OF_AVAILABLE_SPS_CHANNELS; index++) {
176  TEST_ASSERT_EQUAL(sps_channelStatus[index].affiliation, SPS_GetChannelAffiliation(index));
177  }
178 }
179 
181  /* watch out, the channel here has to have an affiliation that is not SPS_AFF_CONTACTOR */
183 }
184 
186  /* a wrong index should also lead here to an assertion */
188 }
189 
191  OS_EnterTaskCritical_Ignore();
192  OS_ExitTaskCritical_Ignore();
193  /* watch out, the channel here has to have an affiliation that is SPS_AFF_CONTACTOR */
195  TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[0u].channelRequested);
196 }
197 
199  /* watch out, the channel here has to have an affiliation that is not SPS_AFF_GENERAL_IO */
201 }
202 
204  /* a wrong index should also lead here to an assertion */
206 }
207 
209  OS_EnterTaskCritical_Ignore();
210  OS_ExitTaskCritical_Ignore();
211  /* watch out, the channel here has to have an affiliation that is SPS_AFF_GENERAL_IO */
213  TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[7u].channelRequested);
214 }
215 
217  /* default wait time */
218  const uint8_t defaultTimer = 5u;
219 
220  /* check that we init in SPS_START otherwise this test has to be adapted */
221  TEST_ASSERT_EQUAL(SPS_START, TEST_SPS_GetSpsState());
222  TEST_ASSERT_EQUAL(0u, TEST_SPS_GetSpsTimer());
223 
224  /* transition through state-machine: SPS_START */
225  /* interface should become switched to low speed */
226  SPI_SpsInterfaceSwitchToLowSpeed_Expect(&spi_spsInterface);
227  SPS_Ctrl();
228  TEST_ASSERT_EQUAL(SPS_RESET_LOW, TEST_SPS_GetSpsState());
229 
230  /* transition through state-machine: SPS_RESET_LOW */
231  /* check that reset pin is reset
232  (we don't care for the actual address as long as the pin is correct) */
233  IO_PinReset_Expect(0u, SPS_RESET_PIN);
234  IO_PinReset_IgnoreArg_pRegisterAddress();
235  SPS_Ctrl();
236  /* timer should now be set to 5 */
237  TEST_ASSERT_EQUAL(defaultTimer, TEST_SPS_GetSpsTimer());
238  /* state should now be SPS_RESET_HIGH */
239  TEST_ASSERT_EQUAL(SPS_RESET_HIGH, TEST_SPS_GetSpsState());
240  /* test that timer decreases and nothing else happens */
241  SPS_Ctrl();
242  TEST_ASSERT_EQUAL((defaultTimer - 1u), TEST_SPS_GetSpsTimer());
243  TEST_ASSERT_EQUAL(SPS_RESET_HIGH, TEST_SPS_GetSpsState());
244  /* now that we know that it works: overwrite the timer so that
245  the next step can proceed */
247 
248  /* transition through state-machine: SPS_RESET_HIGH */
249  /* check that reset pin is set
250  (we don't care for the actual address as long as the pin is correct) */
251  IO_PinSet_Expect(0u, SPS_RESET_PIN);
252  IO_PinSet_IgnoreArg_pRegisterAddress();
253  SPS_Ctrl();
254  /* timer should now be set to 5 */
255  TEST_ASSERT_EQUAL(defaultTimer, TEST_SPS_GetSpsTimer());
256  /* state should now be SPS_CONFIGURE_CONTROL_REGISTER */
258  /* reset the timer so that we can continue */
260 
261  /* transition through state-machine: SPS_CONFIGURE_CONTROL_REGISTER */
262  /* check that we transmit the first set of commands */
263  SPI_TransmitReceiveData_IgnoreAndReturn(STD_OK);
264  MCU_Delay_us_Ignore();
265  /* Since the transaction is successful, we should switch to high-speed */
266  SPI_SpsInterfaceSwitchToHighSpeed_Expect(&spi_spsInterface);
267  SPS_Ctrl();
268  /* state should be now SPS_TRIGGER_CURRENT_MEASUREMENT */
270 }
271 
273  /* go to state SPS_TRIGGER_CURRENT_MEASUREMENT */
275 
276  /* run state and let first transaction "fail" */
277  MCU_Delay_us_Ignore();
278  SPI_TransmitReceiveData_ExpectAndReturn(NULL_PTR, NULL_PTR, NULL_PTR, 0u, STD_NOT_OK);
279  SPI_TransmitReceiveData_IgnoreArg_pSpiInterface();
280  SPI_TransmitReceiveData_IgnoreArg_pTxBuff();
281  SPI_TransmitReceiveData_IgnoreArg_pRxBuff();
282  SPI_TransmitReceiveData_IgnoreArg_frameLength();
283  SPI_TransmitReceiveData_ExpectAndReturn(NULL_PTR, NULL_PTR, NULL_PTR, 0u, STD_OK);
284  SPI_TransmitReceiveData_IgnoreArg_pSpiInterface();
285  SPI_TransmitReceiveData_IgnoreArg_pTxBuff();
286  SPI_TransmitReceiveData_IgnoreArg_pRxBuff();
287  SPI_TransmitReceiveData_IgnoreArg_frameLength();
288  SPS_Ctrl();
289 }
290 
292  /* go to state SPS_TRIGGER_CURRENT_MEASUREMENT */
294 
295  /* run state and let second transaction "fail" */
296  MCU_Delay_us_Ignore();
297  SPI_TransmitReceiveData_ExpectAndReturn(NULL_PTR, NULL_PTR, NULL_PTR, 0u, STD_OK);
298  SPI_TransmitReceiveData_IgnoreArg_pSpiInterface();
299  SPI_TransmitReceiveData_IgnoreArg_pTxBuff();
300  SPI_TransmitReceiveData_IgnoreArg_pRxBuff();
301  SPI_TransmitReceiveData_IgnoreArg_frameLength();
302  SPI_TransmitReceiveData_ExpectAndReturn(NULL_PTR, NULL_PTR, NULL_PTR, 0u, STD_NOT_OK);
303  SPI_TransmitReceiveData_IgnoreArg_pSpiInterface();
304  SPI_TransmitReceiveData_IgnoreArg_pTxBuff();
305  SPI_TransmitReceiveData_IgnoreArg_pRxBuff();
306  SPI_TransmitReceiveData_IgnoreArg_frameLength();
307  SPS_Ctrl();
308 }
309 
311  /* go to state SPS_TRIGGER_CURRENT_MEASUREMENT */
313 
314  /* run state and let both transaction "fail" */
315  MCU_Delay_us_Ignore();
316  SPI_TransmitReceiveData_IgnoreAndReturn(STD_NOT_OK);
317  SPS_Ctrl();
318 }
319 
321  /* go to state SPS_CONFIGURE_CONTROL_REGISTER */
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  TEST_ASSERT_EQUAL(SPS_START, TEST_SPS_GetSpsState());
329 }
330 
332  /* go to state SPS_TRIGGER_CURRENT_MEASUREMENT */
334 
335  /* run state and let both transaction "fail" */
336  MCU_Delay_us_Ignore();
337  SPI_TransmitReceiveData_IgnoreAndReturn(STD_NOT_OK);
338  SPS_Ctrl();
339  TEST_ASSERT_EQUAL(SPS_START, TEST_SPS_GetSpsState());
340 }
341 
343  /* go to state SPS_READ_EN_IRQ_PIN */
345 
346  /* run state and let both transaction "fail" */
347  MCU_Delay_us_Ignore();
348  SPI_TransmitReceiveData_IgnoreAndReturn(STD_NOT_OK);
349  SPS_Ctrl();
350  TEST_ASSERT_EQUAL(SPS_START, TEST_SPS_GetSpsState());
351 }
352 
354  /* go to state SPS_READ_MEASURED_CURRENT1 */
356 
357  /* run state and let both transaction "fail" */
358  MCU_Delay_us_Ignore();
359  SPI_TransmitReceiveData_IgnoreAndReturn(STD_NOT_OK);
360  SPS_Ctrl();
361  TEST_ASSERT_EQUAL(SPS_START, TEST_SPS_GetSpsState());
362 }
363 
365  /* go to state SPS_READ_MEASURED_CURRENT2 */
367 
368  /* run state and let both transaction "fail" */
369  MCU_Delay_us_Ignore();
370  SPI_TransmitReceiveData_IgnoreAndReturn(STD_NOT_OK);
371  SPS_Ctrl();
372  TEST_ASSERT_EQUAL(SPS_START, TEST_SPS_GetSpsState());
373 }
374 
376  /* go to state SPS_READ_MEASURED_CURRENT3 */
378 
379  /* run state and let both transaction "fail" */
380  MCU_Delay_us_Ignore();
381  SPI_TransmitReceiveData_IgnoreAndReturn(STD_NOT_OK);
382  SPS_Ctrl();
383  TEST_ASSERT_EQUAL(SPS_START, TEST_SPS_GetSpsState());
384 }
385 
387  /* go to state SPS_READ_MEASURED_CURRENT4 */
389 
390  /* run state and let both transaction "fail" */
391  MCU_Delay_us_Ignore();
392  SPI_TransmitReceiveData_IgnoreAndReturn(STD_NOT_OK);
393  SPS_Ctrl();
394  TEST_ASSERT_EQUAL(SPS_START, TEST_SPS_GetSpsState());
395 }
396 
398  /* go to state SPS_TRIGGER_CURRENT_MEASUREMENT */
400 
401  /* let transactions always succeed */
402  MCU_Delay_us_Ignore();
403  SPI_TransmitReceiveData_IgnoreAndReturn(STD_OK);
404 
405  /* run state chain */
406  SPS_Ctrl();
407  TEST_ASSERT_EQUAL(SPS_READ_EN_IRQ_PIN, TEST_SPS_GetSpsState());
408  SPS_Ctrl();
409  TEST_ASSERT_EQUAL(SPS_READ_MEASURED_CURRENT1, TEST_SPS_GetSpsState());
410  SPS_Ctrl();
411  TEST_ASSERT_EQUAL(SPS_READ_MEASURED_CURRENT2, TEST_SPS_GetSpsState());
412  SPS_Ctrl();
413  TEST_ASSERT_EQUAL(SPS_READ_MEASURED_CURRENT3, TEST_SPS_GetSpsState());
414  SPS_Ctrl();
415  TEST_ASSERT_EQUAL(SPS_READ_MEASURED_CURRENT4, TEST_SPS_GetSpsState());
416  SPS_Ctrl();
418 }
419 
421  /* go to illegal state 128 */
422  TEST_SPS_SetSpsState(128u);
423 
425 }
426 
428  OS_EnterTaskCritical_Ignore();
429  OS_ExitTaskCritical_Ignore();
430 
431  /* switch on a first, second, third and fourth channel */
432  TEST_ASSERT_EQUAL(SPS_CHANNEL_OFF, sps_channelStatus[0u].channelRequested);
434  TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[0u].channelRequested);
435  TEST_ASSERT_EQUAL(SPS_CHANNEL_OFF, sps_channelStatus[0u].channel);
436 
437  TEST_ASSERT_EQUAL(SPS_CHANNEL_OFF, sps_channelStatus[1u].channelRequested);
439  TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[1u].channelRequested);
440  TEST_ASSERT_EQUAL(SPS_CHANNEL_OFF, sps_channelStatus[1u].channel);
441 
442  TEST_ASSERT_EQUAL(SPS_CHANNEL_OFF, sps_channelStatus[6u].channelRequested);
444  TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[6u].channelRequested);
445  TEST_ASSERT_EQUAL(SPS_CHANNEL_OFF, sps_channelStatus[6u].channel);
446 
447  TEST_ASSERT_EQUAL(SPS_CHANNEL_OFF, sps_channelStatus[7u].channelRequested);
449  TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[7u].channelRequested);
450  TEST_ASSERT_EQUAL(SPS_CHANNEL_OFF, sps_channelStatus[7u].channel);
451 
452  /* cycle over one state that handles channels */
454  SPI_TransmitReceiveData_IgnoreAndReturn(STD_OK);
455  MCU_Delay_us_Ignore();
456  SPS_Ctrl();
457 
458  /* check that channels have been marked as on */
459  TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[0u].channel);
460  TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[1u].channel);
461  TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[6u].channel);
462  TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[7u].channel);
463 
464  /* switch off a first, second, third and fourth channel */
465  TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[0u].channelRequested);
467  TEST_ASSERT_EQUAL(SPS_CHANNEL_OFF, sps_channelStatus[0u].channelRequested);
468  TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[0u].channel);
469 
470  TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[1u].channelRequested);
472  TEST_ASSERT_EQUAL(SPS_CHANNEL_OFF, sps_channelStatus[1u].channelRequested);
473  TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[1u].channel);
474 
475  TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[6u].channelRequested);
477  TEST_ASSERT_EQUAL(SPS_CHANNEL_OFF, sps_channelStatus[6u].channelRequested);
478  TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[6u].channel);
479 
480  TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[7u].channelRequested);
482  TEST_ASSERT_EQUAL(SPS_CHANNEL_OFF, sps_channelStatus[7u].channelRequested);
483  TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[7u].channel);
484 
485  /* cycle over one state that handles channels */
487  SPI_TransmitReceiveData_IgnoreAndReturn(STD_OK);
488  MCU_Delay_us_Ignore();
489  SPS_Ctrl();
490 
491  /* check that channels have been marked as off */
492  TEST_ASSERT_EQUAL(SPS_CHANNEL_OFF, sps_channelStatus[0u].channel);
493  TEST_ASSERT_EQUAL(SPS_CHANNEL_OFF, sps_channelStatus[1u].channel);
494  TEST_ASSERT_EQUAL(SPS_CHANNEL_OFF, sps_channelStatus[6u].channel);
495  TEST_ASSERT_EQUAL(SPS_CHANNEL_OFF, sps_channelStatus[7u].channel);
496 }
497 
498 /** test the states of PEX feedback function */
500  /* report pin state 0 with normally open --> should report switch off */
501  PEX_GetPin_ExpectAndReturn(PEX_PORT_EXPANDER1, PEX_PIN00, 0u);
502  TEST_ASSERT_EQUAL(CONT_SWITCH_OFF, SPS_GetChannelPexFeedback(0u, true));
503 
504  /* report pin state 1 with normally open --> should report switch on */
505  PEX_GetPin_ExpectAndReturn(PEX_PORT_EXPANDER1, PEX_PIN00, 1u);
506  TEST_ASSERT_EQUAL(CONT_SWITCH_ON, SPS_GetChannelPexFeedback(0u, true));
507 
508  /* report pin state 0 with normally closed --> should report switch on */
509  PEX_GetPin_ExpectAndReturn(PEX_PORT_EXPANDER1, PEX_PIN00, 0u);
510  TEST_ASSERT_EQUAL(CONT_SWITCH_ON, SPS_GetChannelPexFeedback(0u, false));
511 
512  /* report pin state 1 with normally closed --> should report switch off */
513  PEX_GetPin_ExpectAndReturn(PEX_PORT_EXPANDER1, PEX_PIN00, 1u);
514  TEST_ASSERT_EQUAL(CONT_SWITCH_OFF, SPS_GetChannelPexFeedback(0u, false));
515 }
@ CONT_SWITCH_ON
Definition: contactor_cfg.h:73
@ CONT_SWITCH_OFF
Definition: contactor_cfg.h:72
@ STD_NOT_OK
Definition: fstd_types.h:83
@ STD_OK
Definition: fstd_types.h:82
#define NULL_PTR
Null pointer.
Definition: fstd_types.h:76
#define PEX_PIN05
Definition: pex_cfg.h:86
#define PEX_PIN02
Definition: pex_cfg.h:83
#define PEX_PIN00
Definition: pex_cfg.h:81
#define PEX_PIN03
Definition: pex_cfg.h:84
#define PEX_PIN01
Definition: pex_cfg.h:82
#define PEX_PIN07
Definition: pex_cfg.h:88
#define PEX_PIN06
Definition: pex_cfg.h:87
#define PEX_PIN04
Definition: pex_cfg.h:85
#define PEX_PORT_EXPANDER1
Definition: pex_cfg.h:74
CONT_ELECTRICAL_STATE_TYPE_e SPS_GetChannelPexFeedback(const SPS_CHANNEL_INDEX channelIndex, bool normallyOpen)
Get the feedback state of a channel.
Definition: sps.c:625
SPS_CHANNEL_AFFILIATION_e SPS_GetChannelAffiliation(SPS_CHANNEL_INDEX channelIndex)
Returns the channel affiliation.
Definition: sps.c:648
void TEST_SPS_RequestChannelState(SPS_CHANNEL_INDEX channelIndex, SPS_CHANNEL_FUNCTION_e channelFunction)
Definition: sps.c:655
void SPS_Ctrl(void)
Control function for the CONT driver state machine.
Definition: sps.c:476
uint8_t TEST_SPS_GetSpsTimer(void)
Definition: sps.c:664
void TEST_SPS_SetSpsTimer(const uint8_t newTimer)
Definition: sps.c:667
CONT_ELECTRICAL_STATE_TYPE_e SPS_GetChannelCurrentFeedback(const SPS_CHANNEL_INDEX channelIndex)
Get feedback value.
Definition: sps.c:609
void SPS_RequestContactorState(SPS_CHANNEL_INDEX channelIndex, SPS_CHANNEL_FUNCTION_e channelFunction)
Request state of a contactor.
Definition: sps.c:597
SPS_STATE_e TEST_SPS_GetSpsState(void)
Definition: sps.c:658
void TEST_SPS_SetSpsState(const SPS_STATE_e newState)
Definition: sps.c:661
void SPS_RequestGeneralIoState(SPS_CHANNEL_INDEX channelIndex, SPS_CHANNEL_FUNCTION_e channelFunction)
Request state of a general IO.
Definition: sps.c:603
Headers for the driver for the smart power switches.
#define SPS_CHANNEL_ON_DEFAULT_THRESHOLD_mA
Definition: sps_cfg.h:154
#define SPS_NR_OF_AVAILABLE_SPS_CHANNELS
Definition: sps_cfg.h:89
@ SPS_CHANNEL_ON
Definition: sps_cfg.h:175
@ SPS_CHANNEL_OFF
Definition: sps_cfg.h:174
#define SPS_RESET_PIN
Definition: sps_cfg.h:70
@ SPS_TRIGGER_CURRENT_MEASUREMENT
Definition: sps_cfg.h:204
@ SPS_CONFIGURE_CONTROL_REGISTER
Definition: sps_cfg.h:203
@ SPS_READ_MEASURED_CURRENT2
Definition: sps_cfg.h:206
@ SPS_READ_MEASURED_CURRENT1
Definition: sps_cfg.h:205
@ SPS_RESET_LOW
Definition: sps_cfg.h:201
@ SPS_READ_EN_IRQ_PIN
Definition: sps_cfg.h:209
@ SPS_READ_MEASURED_CURRENT3
Definition: sps_cfg.h:207
@ SPS_START
Definition: sps_cfg.h:200
@ SPS_READ_MEASURED_CURRENT4
Definition: sps_cfg.h:208
@ SPS_RESET_HIGH
Definition: sps_cfg.h:202
uint8_t SPS_CHANNEL_INDEX
Definition: sps_types.h:64
@ SPS_AFF_CONTACTOR
Definition: sps_types.h:73
@ SPS_AFF_GENERAL_IO
Definition: sps_types.h:74
spiDAT1_t * pConfig
Definition: spi_cfg.h:124
SPS_CHANNEL_FUNCTION_e channelRequested
Definition: sps_cfg.h:180
SPS_CHANNEL_FUNCTION_e channel
Definition: sps_cfg.h:181
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:137
void testSPS_RequestGeneralIOStateWrongAffiliation(void)
Definition: test_sps.c:198
void testContactorSwitchOnAndOff(void)
Definition: test_sps.c:427
void testSPS_RequestContactorStateCorrectAffiliation(void)
Definition: test_sps.c:190
void testSPS_RequestChannelStateInvalidFunction(void)
Definition: test_sps.c:133
void testSPS_CtrlResetFromStateSPS_TRIGGER_CURRENT_MEASUREMENT(void)
Definition: test_sps.c:331
SPS_CHANNEL_STATE_s sps_channelStatus[SPS_NR_OF_AVAILABLE_SPS_CHANNELS]
Definition: test_sps.c:92
void testSPS_CtrlNormalOperationCycle(void)
Definition: test_sps.c:397
void testSPS_GetChannelFeedbackChannelLow(void)
Definition: test_sps.c:152
void testSPS_CtrlResetFromStateSPS_READ_MEASURED_CURRENT3(void)
Definition: test_sps.c:375
void testSPS_CtrlResetFromStateSPS_READ_MEASURED_CURRENT4(void)
Definition: test_sps.c:386
void testSPS_CtrlResetFromStateSPS_READ_EN_IRQ_PIN(void)
Definition: test_sps.c:342
void testSPS_RequestGIOStateCorrectAffiliation(void)
Definition: test_sps.c:208
void testSPS_CtrlStartupProcedure(void)
Definition: test_sps.c:216
void testSPS_GetChannelAffiliationValidIndex(void)
Definition: test_sps.c:174
void testSPS_CtrlResetFromStateSPS_READ_MEASURED_CURRENT1(void)
Definition: test_sps.c:353
void testSPS_CtrlResetOnFailedSecondTransaction(void)
Definition: test_sps.c:291
void testSPS_CtrlAssertOnIllegalState(void)
Definition: test_sps.c:420
void testSPS_RequestGeneralIOStateWrongIndex(void)
Definition: test_sps.c:203
void setUp(void)
Definition: test_sps.c:115
void tearDown(void)
Definition: test_sps.c:125
void testSPS_RequestContactorStateWrongAffiliation(void)
Definition: test_sps.c:180
void testSPS_GetChannelAffiliationInvalidIndex(void)
Definition: test_sps.c:170
void testSPS_CtrlResetOnFailedBothTransactions(void)
Definition: test_sps.c:310
void testSPS_RequestContactorStateWrongIndex(void)
Definition: test_sps.c:185
void testSPS_GetChannelPexFeedback(void)
Definition: test_sps.c:499
const SPS_CHANNEL_FEEDBACK_MAPPING_s sps_kChannelFeedbackMapping[SPS_NR_OF_AVAILABLE_SPS_CHANNELS]
Definition: test_sps.c:103
static const spiDAT1_t spi_kSpsDataConfig
Definition: test_sps.c:75
void testSPS_CtrlResetFromStateSPS_READ_MEASURED_CURRENT2(void)
Definition: test_sps.c:364
void testSPS_CtrlResetOnFailedFirstTransaction(void)
Definition: test_sps.c:272
void testSPS_GetChannelFeedbackChannelHigh(void)
Definition: test_sps.c:161
SPI_INTERFACE_CONFIG_s spi_spsInterface
Definition: test_sps.c:84
void testSPS_GetChannelFeedbackInvalidChannelIndex(void)
Definition: test_sps.c:148
void testSPS_RequestChannelStateInvalidIndex(void)
Definition: test_sps.c:129
void testSPS_CtrlResetFromStateSPS_CONFIGURE_CONTROL_REGISTER(void)
Definition: test_sps.c:320