foxBMS - Unit Tests  1.6.0
The foxBMS Unit Tests API Documentation
nxpfs85xx.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 nxpfs85xx.c
44  * @author foxBMS Team
45  * @date 2020-03-18 (date of creation)
46  * @updated 2023-10-12 (date of last update)
47  * @version v1.6.0
48  * @ingroup DRIVERS
49  * @prefix FS85
50  *
51  * @brief Driver for the FS85xx module
52  *
53  * @details It must always be used when creating new c source files.
54  *
55  */
56 
57 /*========== Includes =======================================================*/
58 #include "nxpfs85xx.h"
59 
60 #include "HL_gio.h"
61 #include "HL_system.h"
62 
63 #include "diag.h"
64 #include "fram.h"
65 #include "fstd_types.h"
66 #include "fsystem.h"
67 #include "io.h"
68 #include "master_info.h"
69 #include "mcu.h"
70 #include "sbc_fs8x_communication.h"
71 #include "spi.h"
72 
73 #include <stdint.h>
74 
75 /*========== Macros and Definitions =========================================*/
76 
77 /*========== Static Constant and Variable Definitions =======================*/
78 /** Initialization phases during startup of FS85xx IC*/
79 typedef enum {
85 
86 /*========== Extern Constant and Variable Definitions =======================*/
89  .configValues.watchdogSeed = FS8x_WD_SEED_DEFAULT,
90  .configValues.communicationMode = fs8xSPI,
91  .configValues.i2cAddressOtp = 0, /* Not used as SPI is selected */
92  .fin.finUsed = false,
93  .fin.finState = STD_NOT_OK,
94  .fin.pGIOport = &(systemREG1->SYSPC4), /* FIN connected to ECLK1 (ball A12): PRIVILEGE MODE REQUIRED! */
95  .fin.pin = 0,
96  .mainRegister = {0},
97  .fsRegister = {0},
98  .nvram.entry = FRAM_BLOCK_ID_SBC_INIT_STATE,
99  .nvram.pData = &fram_sbcInit,
100  .mode = FS85_NORMAL_MODE, /* default value */
101 };
102 
103 /*========== Static Function Prototypes =====================================*/
104 /**
105  * @brief Checks register value against expected value
106  * @details If actual register value equals expected value #STD_OK is
107  * returned if this is not the case this indicates an error and
108  * #STD_NOT_OK is returned.
109  * @param registerValue actual register value of interest
110  * @param expectedRegisterValue expected register value
111  * @return #STD_OK if register value equals expected, else #STD_NOT_OK
112  */
113 static STD_RETURN_TYPE_e FS85_CheckRegisterValues(uint32_t registerValue, uint32_t expectedRegisterValue);
114 
115 /**
116  * @brief Updates fail safe register values
117  * @details Updates fail safe register value of passed SBC instance
118  * with new values
119  * @param[in,out] pFsRegister pointer to fail-safe registers
120  * @param registerAddress address of register that is updated
121  * @param registerValue register value
122  */
123 static void FS85_UpdateFailSafeRegister(
124  FS85_FS_REGISTER_s *pFsRegister,
125  uint32_t registerAddress,
126  uint32_t registerValue);
127 
128 /**
129  * @brief Updates main register values
130  * @details Updates main register value of passed SBC instance with new
131  * values
132  * @param[in,out] pMainRegister pointer to main registers
133  * @param registerAddress address of register that is updated
134  * @param registerValue register value
135  */
136 static void FS85_UpdateMainRegister(
137  FS85_MAIN_REGISTERS_s *pMainRegister,
138  uint32_t registerAddress,
139  uint32_t registerValue);
140 
141 /**
142  * @brief Updates register values
143  * @details Updates register value of passed SBC instance with new
144  * values
145  * @param[in,out] pInstance SBC instance that is updated
146  * @param isFailSafe true if fail-safe register, false if main register
147  * @param registerAddress address of register that is updated
148  * @param registerValue register value
149  */
150 static void FS85_UpdateRegister(
151  FS85_STATE_s *pInstance,
152  bool isFailSafe,
153  uint32_t registerAddress,
154  uint32_t registerValue);
155 
156 /**
157  * @brief Reads SBC register value
158  * @details Reads SBC register value from registerAddress and updates
159  * register in SBC state variable if reading was successful
160  * @param[in,out] pInstance SBC instance that is updated
161  * @param isFailSafe true if fail-safe register, false if main
162  * register
163  * @param registerAddress address of register that is read from
164  * @return #STD_OK if reading was successful, otherwise #STD_NOT_OK
165  */
166 static STD_RETURN_TYPE_e FS85_ReadBackRegister(FS85_STATE_s *pInstance, bool isFailSafe, uint8_t registerAddress);
167 
168 /**
169  * @brief Write to fail-safe register
170  * @details Writes to fail-safe register (can be done during FS_INIT phase
171  * only)
172  * @param[in] pInstance SBC instance that is updated
173  * @param registerAddress address of register
174  * @param registerValue value that is written into register
175  * @return #STD_OK if writing was successful, other #STD_NOT_OK
176  */
178  FS85_STATE_s *pInstance,
179  uint8_t registerAddress,
180  uint16_t registerValue);
181 
182 /**
183  * @brief Write to fail-safe register
184  * @details Writes to fail-safe register (can be done during FS_INIT
185  * phase only), reads back if write process was successful and
186  * afterwards updates register value of passed SBC instance
187  * @param[in,out] pInstance SBC instance that is updated
188  * @param registerAddress address of register
189  * @param registerValue value that is written into register
190  * @return #STD_OK if writing was successful, other #STD_NOT_OK
191  */
193  FS85_STATE_s *pInstance,
194  uint8_t registerAddress,
195  uint16_t registerValue);
196 
197 /**
198  * @brief Clears flags in register
199  * @details Writes to register, reads back if clear process was
200  * successful and afterwards updates register value of passed
201  * SBC instance
202  * @param[in,out] pInstance SBC instance that is updated
203  * @param registerAddress address of register
204  * @param isFailSafe true if fail-safe register, false if main register
205  * @param registerValue value that is written into register
206  * @return #STD_OK if writing was successful, other #STD_NOT_OK
207  */
209  FS85_STATE_s *pInstance,
210  uint8_t registerAddress,
211  bool isFailSafe,
212  uint16_t registerValue);
213 
214 /**
215  * @brief Clears flags in register
216  * @details Reads all registers updates the register values of passed
217  * SBC instance
218  * @param[in,out] pInstance SBC instance that is updated
219  * @return #STD_OK if readout was successful, otherwise #STD_NOT_OK
220  */
222 
223 /**
224  * @brief Perform RSTB safety path check
225  * @details This functions performs a safety path check to make sure
226  * external components connected to RSTB are available to
227  * bring the safety critical outputs to known levels during
228  * operation.
229  * @param[in,out] pInstance SBC instance for which the RSTB path is checked
230  * @return #STD_OK if path check was successful, other #STD_NOT_OK
231  */
233 
234 /**
235  * @brief Perform FS0B safety path check
236  * @details This functions performs a safety path check to make sure
237  * external components connected to FS0B are available to
238  * bring the safety critical outputs to known levels during
239  * operation.
240  * @param[in,out] pInstance SBC instance for which the FS0B path is checked
241  */
243 
244 /**
245  * @brief Sends SBC to Standby Mode
246  * @details Sets GOTOSTBY Bit on SBC via SPI.
247  * @param pInstance SBC Instance to send to Standby
248 */
250 
251 /*========== Static Function Implementations ================================*/
252 static STD_RETURN_TYPE_e FS85_CheckRegisterValues(uint32_t registerValue, uint32_t expectedRegisterValue) {
253  /* AXIVION Routine Generic-MissingParameterAssert: registerValue: parameter accepts whole range */
254  /* AXIVION Routine Generic-MissingParameterAssert: expectedRegisterValue: parameter accepts whole range */
255  STD_RETURN_TYPE_e retval = STD_OK;
256  if (registerValue != expectedRegisterValue) {
257  retval = STD_NOT_OK;
258  }
259  return retval;
260 }
261 
263  FS85_FS_REGISTER_s *pFsRegister,
264  uint32_t registerAddress,
265  uint32_t registerValue) {
266  FAS_ASSERT(pFsRegister != NULL_PTR);
267  FAS_ASSERT(registerAddress <= FS8X_M_DEVICEID_ADDR);
268  /* AXIVION Routine Generic-MissingParameterAssert: registerValue: parameter accepts whole range */
269  switch (registerAddress) {
271  pFsRegister->grl_flags = registerValue;
272  break;
274  pFsRegister->iOvervoltageUndervoltageSafeReaction1 = registerValue;
275  break;
277  pFsRegister->iOvervoltageUndervoltageSafeReaction2 = registerValue;
278  break;
280  pFsRegister->iWatchdogConfiguration = registerValue;
281  break;
283  pFsRegister->i_safe_inputs = registerValue;
284  break;
285  case FS8X_FS_I_FSSM_ADDR:
286  pFsRegister->iFailSafeSateMachine = registerValue;
287  break;
288  case FS8X_FS_I_SVS_ADDR:
289  pFsRegister->i_svs = registerValue;
290  break;
292  pFsRegister->watchdogWindow = registerValue;
293  break;
295  pFsRegister->watchdogSeed = registerValue;
296  break;
298  pFsRegister->watchdogAnswer = registerValue;
299  break;
301  pFsRegister->overvoltageUndervoltageRegisterStatus = registerValue;
302  break;
304  pFsRegister->releaseFs0bPin = registerValue;
305  break;
307  pFsRegister->safeIos = registerValue;
308  break;
310  pFsRegister->diag_safety = registerValue;
311  break;
313  pFsRegister->intb_mask = registerValue;
314  break;
315  case FS8X_FS_STATES_ADDR:
316  pFsRegister->states = registerValue;
317  break;
318  default:
319  FAS_ASSERT(FAS_TRAP); /* This case should never be reached */
320  break; /* LCOV_EXCL_LINE */
321  }
322 }
323 
325  FS85_MAIN_REGISTERS_s *pMainRegister,
326  uint32_t registerAddress,
327  uint32_t registerValue) {
328  FAS_ASSERT(pMainRegister != NULL_PTR);
329  FAS_ASSERT(registerAddress <= FS8X_M_DEVICEID_ADDR);
330  /* AXIVION Routine Generic-MissingParameterAssert: registerValue: parameter accepts whole range */
331  switch (registerAddress) {
332  case FS8X_M_FLAG_ADDR:
333  pMainRegister->flag = registerValue;
334  break;
335  case FS8X_M_MODE_ADDR:
336  pMainRegister->mode = registerValue;
337  break;
339  pMainRegister->registerControl1 = registerValue;
340  break;
342  pMainRegister->registerControl2 = registerValue;
343  break;
344  case FS8X_M_AMUX_ADDR:
345  pMainRegister->analogMultiplexer = registerValue;
346  break;
347  case FS8X_M_CLOCK_ADDR:
348  pMainRegister->clock = registerValue;
349  break;
351  pMainRegister->int_mask1 = registerValue;
352  break;
354  pMainRegister->int_mask2 = registerValue;
355  break;
356  case FS8X_M_FLAG1_ADDR:
357  pMainRegister->flag1 = registerValue;
358  break;
359  case FS8X_M_FLAG2_ADDR:
360  pMainRegister->flag2 = registerValue;
361  break;
363  pMainRegister->vmon_regx = registerValue;
364  break;
366  pMainRegister->lvb1_svs = registerValue;
367  break;
368  case FS8X_M_MEMORY0_ADDR:
369  pMainRegister->memory0 = registerValue;
370  break;
371  case FS8X_M_MEMORY1_ADDR:
372  pMainRegister->memory1 = registerValue;
373  break;
375  pMainRegister->deviceId = registerValue;
376  break;
377  default:
378  FAS_ASSERT(FAS_TRAP); /* This case should never be reached */
379  break; /* LCOV_EXCL_LINE */
380  }
381 }
382 
384  FS85_STATE_s *pInstance,
385  bool isFailSafe,
386  uint32_t registerAddress,
387  uint32_t registerValue) {
388  FAS_ASSERT(pInstance != NULL_PTR);
389  FAS_ASSERT((isFailSafe == true) || (isFailSafe == false));
390  FAS_ASSERT(registerAddress <= FS8X_M_DEVICEID_ADDR);
391  /* AXIVION Routine Generic-MissingParameterAssert: registerValue: parameter accepts whole range */
392 
393  /* Check if fail-safe or main register needs to be updated */
394  if (isFailSafe == true) { /* Update fail-safe register */
395  FS85_UpdateFailSafeRegister(&(pInstance->fsRegister), registerAddress, registerValue);
396  } else { /* Update main register */
397  FS85_UpdateMainRegister(&(pInstance->mainRegister), registerAddress, registerValue);
398  }
399 }
400 
401 static STD_RETURN_TYPE_e FS85_ReadBackRegister(FS85_STATE_s *pInstance, bool isFailSafe, uint8_t registerAddress) {
402  FAS_ASSERT(pInstance != NULL_PTR);
403  FAS_ASSERT((isFailSafe == true) || (isFailSafe == false));
404  /* AXIVION Routine Generic-MissingParameterAssert: registerAddress: parameter accepts whole range */
405 
406  STD_RETURN_TYPE_e retval = STD_NOT_OK;
407  fs8x_rx_frame_t rxTemp = {0};
408 
409  FAS_ASSERT(pInstance != NULL_PTR);
410 
411  if (fs8xStatusOk !=
412  FS8x_ReadRegister(pInstance->pSpiInterface, &(pInstance->configValues), isFailSafe, registerAddress, &rxTemp)) {
413  retval = STD_NOT_OK;
414  } else {
415  FS85_UpdateRegister(pInstance, isFailSafe, registerAddress, rxTemp.readData);
416  retval = STD_OK;
417  }
418  return retval;
419 }
420 
422  FS85_STATE_s *pInstance,
423  uint8_t registerAddress,
424  uint16_t registerValue) {
425  FAS_ASSERT(pInstance != NULL_PTR);
426  /* AXIVION Routine Generic-MissingParameterAssert: registerAddress: parameter accepts whole range */
427  /* AXIVION Routine Generic-MissingParameterAssert: registerValue: parameter accepts whole range */
428 
429  STD_RETURN_TYPE_e retval = STD_OK;
430 
431  FAS_ASSERT(pInstance != NULL_PTR);
432 
433  /* Write to register */
434  if (fs8xStatusOk !=
435  FS8x_WriteRegisterInit(pInstance->pSpiInterface, &(pInstance->configValues), registerAddress, registerValue)) {
436  retval = STD_NOT_OK;
437  } else {
438  retval = STD_OK;
439  }
440  return retval;
441 }
442 
444  FS85_STATE_s *pInstance,
445  uint8_t registerAddress,
446  uint16_t registerValue) {
447  FAS_ASSERT(pInstance != NULL_PTR);
448  /* AXIVION Routine Generic-MissingParameterAssert: registerAddress: parameter accepts whole range */
449  /* AXIVION Routine Generic-MissingParameterAssert: registerValue: parameter accepts whole range */
450 
451  STD_RETURN_TYPE_e retval = STD_OK;
452  fs8x_rx_frame_t rxTemp = {0};
453 
454  FAS_ASSERT(pInstance != NULL_PTR);
455 
456  /* Write to register */
457  if (fs8xStatusOk !=
458  FS8x_WriteRegisterInit(pInstance->pSpiInterface, &(pInstance->configValues), registerAddress, registerValue)) {
459  retval |= STD_NOT_OK;
460  } else {
461  /* Read back register value and check if write process was successful */
462  if (fs8xStatusOk !=
463  FS8x_ReadRegister(pInstance->pSpiInterface, &(pInstance->configValues), true, registerAddress, &rxTemp)) {
464  retval |= STD_NOT_OK;
465  } else {
466  if (rxTemp.readData == registerValue) {
467  /* Written register value equals read value */
468  FS85_UpdateRegister(pInstance, true, registerAddress, rxTemp.readData);
469  } else {
470  retval |= STD_NOT_OK;
471  }
472  }
473  }
474  return retval;
475 }
476 
478  FS85_STATE_s *pInstance,
479  uint8_t registerAddress,
480  bool isFailSafe,
481  uint16_t registerValue) {
482  FAS_ASSERT(pInstance != NULL_PTR);
483  /* AXIVION Routine Generic-MissingParameterAssert: registerAddress: parameter accepts whole range */
484  /* AXIVION Routine Generic-MissingParameterAssert: isFailSafe: parameter accepts whole range */
485  /* AXIVION Routine Generic-MissingParameterAssert: registerValue: parameter accepts whole range */
486 
487  STD_RETURN_TYPE_e retval = STD_OK;
488  fs8x_rx_frame_t rxTemp = {0};
489 
490  FAS_ASSERT(pInstance != NULL_PTR);
491 
492  /* Write to register */
493  if (fs8xStatusOk !=
495  pInstance->pSpiInterface, &(pInstance->configValues), isFailSafe, registerAddress, registerValue)) {
496  retval |= STD_NOT_OK;
497  } else {
498  /* Read back register value and check if write process was successful */
499  if (fs8xStatusOk !=
501  pInstance->pSpiInterface, &(pInstance->configValues), isFailSafe, registerAddress, &rxTemp)) {
502  retval |= STD_NOT_OK;
503  } else {
504  /* Check if all flags have been cleared: '1' is written to registers to clear respective flags */
505  if ((rxTemp.readData & registerValue) == 0u) {
506  /* Written register value equals read value */
507  FS85_UpdateRegister(pInstance, isFailSafe, registerAddress, rxTemp.readData);
508  } else {
509  retval |= STD_NOT_OK;
510  }
511  }
512  }
513  return retval;
514 }
515 
517  FAS_ASSERT(pInstance != NULL_PTR);
518 
519  STD_RETURN_TYPE_e retVal = STD_NOT_OK;
520 
521  if (fs8xStatusOk ==
523  pInstance->pSpiInterface, &(pInstance->configValues), false, FS8X_M_MODE_ADDR, FS8X_M_GOTOSTBY_MASK)) {
524  retVal = STD_OK;
525  }
526 
527  return retVal;
528 }
529 
530 /*========== Extern Function Implementations ================================*/
532  FAS_ASSERT(pInstance != NULL_PTR);
533 
534  STD_RETURN_TYPE_e retval = STD_OK;
535  uint16_t registerMask = 0u;
536  uint16_t expRegisterValue = 0u;
537  uint16_t registerValue = 0u;
538 
539  FAS_ASSERT(pInstance != NULL_PTR);
540  /* Default init value: #STD_NOT_OK, will be set to #STD_OK later in init if
541  no short-circuit between FIN and RSTB detected. Do not apply external
542  clock on this pin until finState == #STD_OK */
543  FAS_ASSERT(pInstance->fin.finState == STD_NOT_OK);
544 
545  /** First: Verify following conditions:
546  1. Verify LBIST (logical-built-in-self-test) and ABIST1 (analog-built-in-self-test1) are pass
547  2. Verify Debug mode is not activated
548  3. Verify there is no OTP CRC error
549  4. Verify PGOOD was released: PGOOD is connected to power-on-reset of the MCU
550 
551  Second: Configure FS_I and FS_I_NOT registers
552 
553  - Write the desired data in the FS_I_Register_A (DATA)
554  - Write the opposite in the FS_I_NOT_Register_A (DATA_NOT)
555  - Only the utility bits must be inverted in the DATA_NOT content. The RESERVED bits are not considered and can be
556  written at '0'. If the comparison result is correct, then the REG_CORRUPT is set to '0'. If the comparison result
557  is wrong, then the REG_CORRUPT bit is set to '1'. The REG_CORRUPT monitoring is active as soon as the INIT_FS is
558  closed by the first good watchdog refresh. INIT_FS must be closed by the first good watchdog refresh before 256ms
559  timeout.
560 
561  1. Configure VCOREMON_OV_UV impact on RSTB and FS0B
562  2. Configure VDDIO_OV_UV impact on RSTB and FS0B
563  3. Configure VMONx_OV_UV impact on RSTB and FS0B
564  4. Configure ABIST2 assignment
565  5. Configure the WD window period, the WD window duty cycle, the WD counters limits,
566  and its impact on RSTB and FS0B. Ensure that the configuration does not violate the
567  FTTI requirement at system level.
568  6. Configure the Fault Error Counter limit and its impact on RSTB and FS0B at
569  intermediate value
570  7. Configure the RSTB pulse duration
571  8. Configure MCU FCCU error monitoring and its impact on RSTB and FS0B
572  9. Configure Ext. IC error monitoring and its impact on RSTB and FS0B
573  10.Configure FS0B short to high impact on RSTB
574 
575  Third: Execute
576 
577  1. Close INIT_FS by sending the first good WD refresh
578  2. Execute ABIST2 and verify it is pass
579  3. Clear all the flags by writing in FS_DIAG_SAFETY, FS_OVUVREG_STATUS
580  4. Clear the fault error counter to 0 with consecutive good WD refresh
581  5. Perform RSTB path check (repeat steps 1 to 4 after RSTB is released)
582  6. Release FS0B pin
583  7. Perform FS0B safety path check
584  8. Refresh the WD according to its configuration
585  9. Check FS_GRL_FLAGS register after each WD refresh
586 
587  The FS85 is now ready. If everything is OK for the MCU, it can release its own
588  safety path and the ECU starts.
589  */
590 
591  /* --------------------- First: Verify --------------------------------- */
592 
593  /** 1.: Verify LBIST and ABIST1 */
594  if (STD_OK != FS85_ReadBackRegister(pInstance, true, FS8X_FS_DIAG_SAFETY_ADDR)) {
595  retval = STD_NOT_OK;
596  }
598  expRegisterValue = (FS8X_FS_LBIST_OK_PASS | FS8X_FS_ABIST1_OK_PASS);
599  if (STD_OK != FS85_CheckRegisterValues((pInstance->fsRegister.diag_safety & registerMask), expRegisterValue)) {
600  retval = STD_NOT_OK;
601  }
602 
603  /** Read FS STATES register */
604  if (STD_OK != FS85_ReadBackRegister(pInstance, true, FS8X_FS_STATES_ADDR)) {
605  retval = STD_NOT_OK;
606  }
607 
608  /** 2.: Check if debug mode is active */
609  registerMask = FS8X_FS_DBG_MODE_MASK;
610  expRegisterValue = FS8X_FS_DBG_MODE_NO_DEBUG;
611  if (STD_OK != FS85_CheckRegisterValues((pInstance->fsRegister.states & registerMask), expRegisterValue)) {
612  /* Debug mode active: this can only be the case if debugger connected */
614  pInstance->mode = FS85_DEBUG_MODE;
615  } else {
616  /* Debug mode not active: no debugger connected */
618  pInstance->mode = FS85_NORMAL_MODE;
619  }
620 
621  /** 3.: Verify that no OPT CRC error */
622  registerMask = FS8X_FS_OTP_CORRUPT_MASK;
623  expRegisterValue = FS8X_FS_OTP_CORRUPT_NO_ERROR;
624  if (STD_OK != FS85_CheckRegisterValues((pInstance->fsRegister.states & registerMask), expRegisterValue)) {
625  retval = STD_NOT_OK;
626  }
627 
628  /** -------- Second: Configure fail-safe init registers ------------------*/
629  /** Check if SBC is in FS_INIT state, if not switch SBC in FS_INIT state.
630  * Specific configurations can only be done in FS_INIT state */
631  registerMask = FS8X_FS_FSM_STATE_MASK;
632  expRegisterValue = FS8X_FS_FSM_STATE_INIT_FS;
633  if (STD_OK != FS85_CheckRegisterValues((pInstance->fsRegister.states & registerMask), expRegisterValue)) {
634  /* SBC not in FS_INIT state -> request FS_INIT state */
635  /* Write FS_STATE request */
637  if (STD_OK != FS85_WriteRegisterFsInit(pInstance, FS8X_FS_SAFE_IOS_ADDR, registerValue)) {
638  retval = STD_NOT_OK;
639  } else {
640  /* Check if SBC now in FS_STATE */
641  if (STD_OK != FS85_ReadBackRegister(pInstance, true, FS8X_FS_STATES_ADDR)) {
642  retval = STD_NOT_OK;
643  } else {
644  /* Read register now check if SBC in FS_INIT state */
645  if (STD_OK !=
646  FS85_CheckRegisterValues((pInstance->fsRegister.states & registerMask), expRegisterValue)) {
647  /* SBC not in FS_INIT state -> error */
648  retval = STD_NOT_OK;
649  }
650  }
651  }
652  }
653 
654  /** 1.: Configure VCOREMON_OV_UV impact on RSTB and FS0B */
655  /** 2.: Configure VDDIO_OV_UV impact on RSTB and FS0B */
656  /** 4.: Configure ABIST2 assignment */
657  registerValue = 0;
658 
659  /** Select VCOREMON_OV options:
660  * - FS8X_FS_I_VCOREMON_OV_FS_IMPACT_NO_EFFECT
661  * - FS8X_FS_I_VCOREMON_OV_FS_IMPACT_FS0B
662  * - FS8X_FS_I_VCOREMON_OV_FS_IMPACT_FS0B_RSTB */
664 
665  /** Select VCOREMON_UV options:
666  * - FS8X_FS_I_VCOREMON_UV_FS_IMPACT_NO_EFFECT
667  * - FS8X_FS_I_VCOREMON_UV_FS_IMPACT_FS0B
668  * - FS8X_FS_I_VCOREMON_UV_FS_IMPACT_FS0B_RSTB */
670 
671  /** Select VDDIO_OV options:
672  * - FS8X_FS_I_VDDIO_OV_FS_IMPACT_NO_EFFECT
673  * - FS8X_FS_I_VDDIO_OV_FS_IMPACT_FS0B
674  * - FS8X_FS_I_VDDIO_OV_FS_IMPACT_FS0B_RSTB */
676 
677  /** Select VDDIO_UV options:
678  * - FS8X_FS_I_VDDIO_UV_FS_IMPACT_NO_EFFECT
679  * - FS8X_FS_I_VDDIO_UV_FS_IMPACT_FS0B
680  * - FS8X_FS_I_VDDIO_UV_FS_IMPACT_FS0B_RSTB */
682 
683  /** Select ABIST2 options:
684  * + VCOREMON
685  * - FS8X_FS_I_VCOREMON_ABIST2_NO_ABIST
686  * - FS8X_FS_I_VCOREMON_ABIST2_VCOREMON_BIST
687  * + VDDIO
688  * - FS8X_FS_I_VDDIO_ABIST2_NO_ABIST
689  * - FS8X_FS_I_VDDIO_ABIST2_VDDIO_BIST
690  * + VMONx (VMON1 - VMON4)
691  * - FS8X_FS_I_VMONx_ABIST2_NO_ABIST
692  * - FS8X_FS_I_VMONx_ABIST2_VMONx_BIST */
694  registerValue |= FS8X_FS_I_VDDIO_ABIST2_VDDIO_BIST;
695  registerValue |= FS8X_FS_I_VMON1_ABIST2_VMON1_BIST;
696  registerValue |= FS8X_FS_I_VMON2_ABIST2_VMON2_BIST;
697  registerValue |= FS8X_FS_I_VMON3_ABIST2_VMON3_BIST;
698  registerValue |= FS8X_FS_I_VMON4_ABIST2_VMON4_BIST;
699 
700  /* Write register */
701  if (STD_OK != FS85_WriteBackRegisterFsInit(pInstance, FS8X_FS_I_OVUV_SAFE_REACTION1_ADDR, registerValue)) {
702  retval = STD_NOT_OK;
703  }
704 
705  /** 3.: Configure VMONx_OV_UV impact on RSTB and FS0B */
706  registerValue = 0;
707  /** Select VMONx_OV options:
708  * - FS8X_FS_I_VMONx_OV_FS_IMPACT_NO_EFFECT
709  * - FS8X_FS_I_VMONx_OV_FS_IMPACT_FS0B
710  * - FS8X_FS_I_VMONx_OV_FS_IMPACT_FS0B_RSTB */
715 
716  /** Select VMONx_UV options:
717  * - FS8X_FS_I_VMONx_UV_FS_IMPACT_NO_EFFECT
718  * - FS8X_FS_I_VMONx_UV_FS_IMPACT_FS0B
719  * - FS8X_FS_I_VMONx_UV_FS_IMPACT_FS0B_RSTB */
724 
725  /* Write register */
726  if (STD_OK != FS85_WriteBackRegisterFsInit(pInstance, FS8X_FS_I_OVUV_SAFE_REACTION2_ADDR, registerValue)) {
727  retval = STD_NOT_OK;
728  }
729 
730  /** 5.: Configure the WD window period, the WD window duty cycle, the WD counters limits, and its impact on RSTB and
731  FS0B. Ensure that the configuration does not violate the FTTI requirement at system level. */
732  registerValue = 0;
733 
734  /** WD window period options:
735  * - FS8X_FS_WD_WINDOW_DISABLE
736  * - FS8X_FS_WD_WINDOW_xxxxMS */
737  registerValue |= FS8X_FS_WD_WINDOW_128MS;
738 
739  /** WD window duty cycle options:
740  * - FS8X_FS_WDW_DC_31_25
741  * - FS8X_FS_WDW_DC_37_5
742  * - FS8X_FS_WDW_DC_50
743  * - FS8X_FS_WDW_DC_62_5
744  * - FS8X_FS_WDW_DC_68_75 */
745  registerValue |= FS8X_FS_WDW_DC_50;
746 
747  /** WD fault recovery strategy
748  * - FS8X_FS_WDW_RECOVERY_DISABLE
749  * - FS8X_FS_WDW_RECOVERY_xxxxMS */
750  registerValue |= FS8X_FS_WDW_RECOVERY_128MS;
751 
752  /* Write register */
753  if (STD_OK != FS85_WriteBackRegisterFsInit(pInstance, FS8X_FS_WD_WINDOW_ADDR, registerValue)) {
754  retval = STD_NOT_OK;
755  }
756 
757  /** 6.: Configure the Fault Error Counter limit and its impact on RSTB and FS0B at intermediate value */
758  /** Configure the RSTB pulse duration */
759  /** Configure FS0B short to high impact on RSTB */
760  registerValue = 0;
761 
762  /** Fault Error Counter limit options:
763  * - FS8X_FS_I_FLT_ERR_CNT_LIMIT_2
764  * - FS8X_FS_I_FLT_ERR_CNT_LIMIT_4
765  * - FS8X_FS_I_FLT_ERR_CNT_LIMIT_6
766  * - FS8X_FS_I_FLT_ERR_CNT_LIMIT_8 */
767  registerValue |= FS8X_FS_I_FLT_ERR_CNT_LIMIT_8;
768 
769  /** Fault Error Counter impact options:
770  * - FS8X_FS_I_FLT_ERR_IMPACT_NO_EFFECT
771  * - FS8X_FS_I_FLT_ERR_IMPACT_FS0B
772  * - FS8X_FS_I_FLT_ERR_IMPACT_FS0B_RSTB */
773  registerValue |= FS8X_FS_I_FLT_ERR_IMPACT_FS0B_RSTB;
774 
775  /** 7.: RSTB pulse duration options:
776  * - FS8X_FS_I_RSTB_DUR_1MS
777  * - FS8X_FS_I_RSTB_DUR_10MS */
778  registerValue |= FS8X_FS_I_RSTB_DUR_10MS;
779 
780  /** 10.: FS0B short to high impact on RSTB options:
781  * - FS8X_FS_I_FS0B_SC_HIGH_CFG_NO_ASSERTION
782  * - FS8X_FS_I_FS0B_SC_HIGH_CFG_RESET_ASSERTED */
784 
785  /** After POR fault-error counter is set to 1 on default, it is reset after two consecutive good WD refreshes. This
786  part of the register is read-only so a write access has no influence. Set this bit for a successful comparison
787  between written and read register value */
788  registerValue |= FS8X_FS_I_FLT_ERR_CNT_1;
789 
790  /* Write register */
791  if (STD_OK != FS85_WriteRegisterFsInit(pInstance, FS8X_FS_I_FSSM_ADDR, registerValue)) {
792  retval = STD_NOT_OK;
793  }
794 
795  /** 8.: Configure MCU FCCU error monitoring and its impact on RSTB and FS0B */
796  /** 9.: Configure Ext. IC error monitoring and its impact on RSTB and FS0B */
797  registerValue = 0;
798 
799  /** MCU FCCU error monitoring options:
800  * + Input option:
801  * - FS8X_FS_I_FCCU_CFG_NO_MONITORING
802  * - FS8X_FS_I_FCCU_CFG_FCCU1_INPUT
803  * - FS8X_FS_I_FCCU_CFG_FCCU1_FCCU2_INPUT
804  * - FS8X_FS_I_FCCU_CFG_FCCU1_FCCU2_PAIR (bi-stable protocol)
805  * + Polarity option (independent):
806  * - FS8X_FS_I_FCCUx_FLT_POL_FCCUx_L
807  * - FS8X_FS_I_FCCUx_FLT_POL_FCCUx_H
808  * + Polarity option (bi-stable)
809  * - FS8X_FS_I_FCCU12_FLT_POL_FCCU1_L_FCCU2_H
810  * - FS8X_FS_I_FCCU12_FLT_POL_FCCU1_H_FCCU2_L
811  * + Impact option (independent)
812  * - FS8X_FS_I_FCCUx_FS_REACT_FS0B
813  * - FS8X_FS_I_FCCUx_FS_REACT_FS0B_RSTB
814  * + Impact option (bi-stable)
815  * - FS8X_FS_I_FCCU12_FS_IMPACT_FS0B
816  * - FS8X_FS_I_FCCU12_FS_IMPACT_FS0B_RSTB
817  */
818  registerValue |= FS8X_FS_I_FCCU_CFG_NO_MONITORING;
819  registerValue |= FS8X_FS_I_FCCU1_FLT_POL_FCCU1_L;
820  registerValue |= FS8X_FS_I_FCCU1_FS_REACT_FS0B;
821 
822  /** Ext. IC error monitoring options:
823  * + Polarity options:
824  * - FS8X_FS_I_ERRMON_FLT_POLARITY_NEGATIVE_EDGE
825  * - FS8X_FS_I_ERRMON_FLT_POLARITY_POSITIVE_EDGE
826  * + Error acknowledgment time options:
827  * - FS8X_FS_I_ERRMON_ACK_TIME_1MS
828  * - FS8X_FS_I_ERRMON_ACK_TIME_8MS
829  * - FS8X_FS_I_ERRMON_ACK_TIME_16MS
830  * - FS8X_FS_I_ERRMON_ACK_TIME_32MS
831  * + Error monitoring impact options:
832  * - FS8X_FS_I_ERRMON_FS_IMPACT_FS0B
833  * - FS8X_FS_I_ERRMON_FS_IMPACT_FS0B_RSTB */
835  registerValue |= FS8X_FS_I_ERRMON_ACK_TIME_32MS;
836  registerValue |= FS8X_FS_I_ERRMON_FS_IMPACT_FS0B;
837 
838  /* Write register */
839  if (STD_OK != FS85_WriteRegisterFsInit(pInstance, FS8X_FS_I_SAFE_INPUTS_ADDR, registerValue)) {
840  retval = STD_NOT_OK;
841  }
842 
843  /* -------------------- Third: Execute --------------------------------- */
844 
845  /** 1.: Close INIT_FS by sending the first good WD refresh */
846  if (STD_OK != FS85_TriggerWatchdog(pInstance)) {
847  retval = STD_NOT_OK;
848  }
849  /** 2.: Execute ABIST2 and verify it is pass */
850  /** ABIST2 is executed automatically after closing of INIT_FS, duration: 1.2ms max */
851  MCU_Delay_us(1200u);
852 
853  if (STD_OK != FS85_ReadBackRegister(pInstance, true, FS8X_FS_DIAG_SAFETY_ADDR)) {
854  retval = STD_NOT_OK;
855  }
856  registerMask = FS8X_FS_ABIST2_OK_MASK;
857  expRegisterValue = FS8X_FS_ABIST2_OK_MASK;
858  if (STD_OK != FS85_CheckRegisterValues((pInstance->fsRegister.diag_safety & registerMask), expRegisterValue)) {
859  retval = STD_NOT_OK;
860  }
861 
862  /** 3.: Clear all the flags by writing in FS_DIAG_SAFETY */
863  registerValue = 0;
864  /** Flags are cleared by writing '1' to register */
866  registerValue |= FS8X_FS_ERRMON_ERROR_DETECTED;
868  registerValue |=
872  if (STD_OK != FS85_ClearRegisterFlags(pInstance, FS8X_FS_DIAG_SAFETY_ADDR, true, registerValue)) {
873  retval = STD_NOT_OK;
874  }
875 
876  /** Clear all the flags by writing in FS_OVUVREG_STATUS */
877  registerValue = 0;
878  /** Flags are cleared by writing '1' to register */
881  registerValue |=
887  registerValue |= FS8X_FS_FS_OSC_DRIFT_OSCILLATOR_DRIFT;
888  if (STD_OK != FS85_ClearRegisterFlags(pInstance, FS8X_FS_OVUVREG_STATUS_ADDR, true, registerValue)) {
889  retval = STD_NOT_OK;
890  }
891 
892  /** Clear flags FLAG1 register */
893  registerValue = FS8X_M_VBOSUVH_EVENT_OCCURRED;
894  registerValue |= FS8X_M_VBOOSTUVH_EVENT_OCCURRED;
895  if (STD_OK != FS85_ClearRegisterFlags(pInstance, FS8X_M_FLAG1_ADDR, false, registerValue)) {
896  retval = STD_NOT_OK;
897  }
898 
899  /** Clear flags FLAG2 register */
900  registerValue = FS8X_M_VSUPUV7_EVENT_OCCURRED;
901  registerValue |=
904  if (STD_OK != FS85_ClearRegisterFlags(pInstance, FS8X_M_FLAG2_ADDR, false, registerValue)) {
905  retval = STD_NOT_OK;
906  }
907 
908  /** Read out all registers for debug purpose */
909  if (STD_OK != FS85_ReadBackAllRegisters(pInstance)) {
910  retval = STD_OK;
911  }
912 
913  return retval;
914 }
915 
916 extern bool FS85_CheckIgnitionSignal(FS85_STATE_s *pInstance) {
917  FAS_ASSERT(pInstance != NULL_PTR);
918 
919  /* Default state */
920  bool ignitionSignalDetected = true;
921  /* variables for storing current and previous wake1 signal levels */
922  static uint16_t wake1Level = 0u;
923  static uint16_t oldWake1Level = 0u;
924 
925  /* Read wake1 signal level */
926  fs8x_rx_frame_t rxTemp = {.deviceStatus = 0u, .readData = 0u};
927  if (fs8xStatusOk ==
928  FS8x_ReadRegister(pInstance->pSpiInterface, &(pInstance->configValues), false, FS8X_M_FLAG2_ADDR, &rxTemp)) {
929  wake1Level = rxTemp.readData & FS8X_M_WK1RT_WAKE1_HIGH;
930  }
931 
932  /* Check for falling edge in wake1 signal */
933  if ((oldWake1Level != wake1Level) && (wake1Level == 0u)) {
934  if (STD_OK != FS85_GoToStandby(pInstance)) {
935  /* error in switch to standby mode, reset ole level to try again */
936  wake1Level = oldWake1Level;
937  } else {
938  ignitionSignalDetected = false;
939  }
940  }
941  /* update old level for edge detection */
942  oldWake1Level = wake1Level;
943  return ignitionSignalDetected;
944 }
945 
947  FS85_STATE_s *pInstance,
948  uint8_t *pRequiredWatchdogRefreshes) {
949  FAS_ASSERT(pInstance != NULL_PTR);
950  FAS_ASSERT(pRequiredWatchdogRefreshes != NULL_PTR);
951 
952  STD_RETURN_TYPE_e retval = STD_OK;
953 
954  /** Clear the fault error counter to 0 with consecutive good WD refreshes.
955  * The watchdog refresh counter is used to decrement the fault error counter. Each time the watchdog is properly
956  * refreshed, the watchdog refresh counter is incremented by '1'. Each time the watchdog refresh counter reaches
957  * its maximum value ('6' by default) and if next WD refresh is also good, the fault error counter is decremented
958  * by '1'. Whatever the position the watchdog refresh counter is in, each time there is a wrong refresh watchdog,
959  * the watchdog refresh counter is reset to '0'. */
960 
961  /** Read out FS_I_WD_CFG register to get watchdog refresh counter limit and value */
962  if (STD_OK != FS85_ReadBackRegister(pInstance, true, FS8X_FS_I_WD_CFG_ADDR)) {
963  retval = STD_NOT_OK;
964  }
965 
966  /** Get refresh counter value */
967  uint8_t watchdogRefreshLimit = 0u;
968  uint16_t watchdogRefreshCounter = FS8x_BO_GET_REG_VALUE(
970 
971  /** Get refresh counter limit register value */
975  watchdogRefreshLimit = 6u;
976  } else if (
980  watchdogRefreshLimit = 4u;
981  } else if (
985  watchdogRefreshLimit = 2u;
986  } else {
987  watchdogRefreshLimit = 1u;
988  }
989 
990  /** Get fault error counter */
991  uint8_t faultCounter = 0u;
992  if (fs8xStatusOk !=
993  FS8x_GetFaultErrorCounterValue(pInstance->pSpiInterface, &(pInstance->configValues), &faultCounter)) {
994  retval = STD_NOT_OK;
995  }
996 
997  /** Get number of required watchdog refreshes to clear fault error counter to 0 */
998  *pRequiredWatchdogRefreshes = faultCounter + (watchdogRefreshLimit - watchdogRefreshCounter);
999 
1000  return retval;
1001 }
1002 
1004  FAS_ASSERT(pInstance != NULL_PTR);
1005  /* AXIVION Routine Generic-MissingParameterAssert: parameters without assertion accept whole range of data type */
1006 
1007  STD_RETURN_TYPE_e retval = STD_OK;
1008 
1009  /* Check fault error counter */
1010  uint8_t faultCounter = 0u;
1011  retval |= FS8x_GetFaultErrorCounterValue(pInstance->pSpiInterface, &(pInstance->configValues), &faultCounter);
1012  if (faultCounter != 0u) {
1013  retval = STD_NOT_OK;
1014  }
1015  return retval;
1016 }
1017 
1019  FAS_ASSERT(pInstance != NULL_PTR);
1020 
1021  STD_RETURN_TYPE_e retval = STD_OK;
1022 
1023  /* Perform RSTB path check (repeat steps 1 to 4 after RSTB is released) */
1024  if (STD_OK != FS85_PerformPathCheckRstb(pInstance)) {
1025  retval = STD_NOT_OK;
1026  }
1027 
1028  /* FS0B pin can not be released in debug mode */
1029  if (pInstance->mode != FS85_DEBUG_MODE) {
1030  /* Release FS0B pin */
1031  if (fs8xStatusOk != FS8x_FS0B_Release(pInstance->pSpiInterface, &(pInstance->configValues))) {
1032  retval = STD_NOT_OK;
1033  }
1034  }
1035 
1036  /* Perform FS0B safety path check */
1037  if (STD_OK != FS85_PerformPathCheckFs0b(pInstance)) {
1038  retval = STD_NOT_OK;
1039  }
1040 
1041  /* Init finished successfully if retval still okay */
1042  if (retval == STD_OK) {
1043  pInstance->nvram.pData->phase = (uint8_t)FS85_INITIALIZED;
1044  (void)FRAM_WriteData(pInstance->nvram.entry);
1045  }
1046  return retval;
1047 }
1048 
1049 /* AXIVION Next Codeline Style CodingStyle-Naming.Function: The name is pre-defined by the driver provided by NXP. */
1050 /* AXIVION Next Construct Style CodingStyle-Naming.Parameter: The name is pre-defined by the driver provided by NXP. */
1051 /* AXIVION Next Construct Style MisraC2012-2.7: The API is pre-defined by the driver provided by NXP. */
1053  SPI_INTERFACE_CONFIG_s *pSpiInterface,
1054  uint8_t *txFrame,
1055  uint16_t frameLengthBytes,
1056  uint8_t *rxFrame) {
1057  FAS_ASSERT(pSpiInterface != NULL_PTR);
1058  FAS_ASSERT(txFrame != NULL_PTR);
1059  FAS_ASSERT(rxFrame != NULL_PTR);
1060  /* AXIVION Routine Generic-MissingParameterAssert: frameLengthBytes: parameter accepts whole range */
1061 
1062  uint16_t fs85_txBuffer[FS8x_COMM_FRAME_SIZE] = {0u, 0u, 0u, 0u};
1063  uint16_t fs85_rxBuffer[FS8x_COMM_FRAME_SIZE] = {0u, 0u, 0u, 0u};
1064  fs8x_status_t spiCommunicationState = fs8xStatusError;
1065 
1066  /* Copy TX data in TX array, reset RX array */
1067  for (uint8_t i = 0u; i < FS8x_COMM_FRAME_SIZE; i++) {
1068  fs85_txBuffer[FS8x_COMM_FRAME_SIZE - 1u - i] = (uint16_t)txFrame[i]; /* txFrame[0] will be sent last */
1069  fs85_rxBuffer[i] = 0;
1070  }
1071 
1072  STD_RETURN_TYPE_e spiRetval =
1073  SPI_TransmitReceiveData(pSpiInterface, fs85_txBuffer, fs85_rxBuffer, FS8x_COMM_FRAME_SIZE);
1074 
1075  if (spiRetval == STD_OK) {
1076  /* No error flag set - copy RX data in RX array */
1077  for (uint8_t i = 0u; i < FS8x_COMM_FRAME_SIZE; i++) {
1078  rxFrame[i] = (uint8_t)fs85_rxBuffer[FS8x_COMM_FRAME_SIZE - 1u - i];
1079  }
1080  spiCommunicationState = fs8xStatusOk;
1081  }
1082 
1083  return spiCommunicationState;
1084 }
1085 
1087  FAS_ASSERT(pInstance != NULL_PTR);
1088 
1089  STD_RETURN_TYPE_e retval = STD_NOT_OK;
1090  if (fs8xStatusOk == FS8x_WD_Refresh(pInstance->pSpiInterface, &(pInstance->configValues))) {
1091  /* Check GRL_FLAGS register if watchdog refresh was valid */
1092  if (STD_OK == FS85_ReadBackRegister(pInstance, true, FS8X_FS_GRL_FLAGS_ADDR)) {
1093  uint16_t registerMask = FS8X_FS_FS_WD_G_MASK;
1094  uint16_t expRegisterValue = FS8X_FS_FS_WD_G_GOOD_WD_REFRESH;
1095  if (STD_OK ==
1096  FS85_CheckRegisterValues((pInstance->fsRegister.grl_flags & registerMask), expRegisterValue)) {
1097  /* GOOD watchdog refresh */
1098  retval = STD_OK;
1099  } else {
1100  /* BAD watchdog refresh: get reason */
1101  if (STD_OK == FS85_ReadBackRegister(pInstance, true, FS8X_FS_DIAG_SAFETY_ADDR)) {
1102  registerMask = FS8X_FS_BAD_WD_TIMING_MASK;
1103  expRegisterValue = FS8X_FS_BAD_WD_TIMING_BAD_WD_REFRESH;
1105  (pInstance->fsRegister.diag_safety & registerMask), expRegisterValue)) {
1106  /* TODO: Notify someone: bad watchdog refresh was caused by wrong window or in timeout */
1107  }
1108  registerMask = FS8X_FS_BAD_WD_DATA_MASK;
1109  expRegisterValue = FS8X_FS_BAD_WD_DATA_BAD_WD_REFRESH;
1111  (pInstance->fsRegister.diag_safety & registerMask), expRegisterValue)) {
1112  /* TODO: Notify someone: bad watchdog refresh was caused by error in data */
1113  }
1114  }
1115  }
1116  }
1117  }
1118  return retval;
1119 }
1120 
1122  FAS_ASSERT(pInstance != NULL_PTR);
1123 
1124  STD_RETURN_TYPE_e retval = STD_OK;
1125 
1126  /* Read all fail-safe registers */
1127  (void)FS85_ReadBackRegister(pInstance, true, FS8X_FS_GRL_FLAGS_ADDR);
1130  (void)FS85_ReadBackRegister(pInstance, true, FS8X_FS_I_WD_CFG_ADDR);
1131  (void)FS85_ReadBackRegister(pInstance, true, FS8X_FS_I_SAFE_INPUTS_ADDR);
1132  (void)FS85_ReadBackRegister(pInstance, true, FS8X_FS_I_FSSM_ADDR);
1133  (void)FS85_ReadBackRegister(pInstance, true, FS8X_FS_I_SVS_ADDR);
1134  (void)FS85_ReadBackRegister(pInstance, true, FS8X_FS_WD_WINDOW_ADDR);
1135  (void)FS85_ReadBackRegister(pInstance, true, FS8X_FS_WD_SEED_ADDR);
1136  (void)FS85_ReadBackRegister(pInstance, true, FS8X_FS_WD_ANSWER_ADDR);
1137  (void)FS85_ReadBackRegister(pInstance, true, FS8X_FS_OVUVREG_STATUS_ADDR);
1138  (void)FS85_ReadBackRegister(pInstance, true, FS8X_FS_RELEASE_FS0B_ADDR);
1139  (void)FS85_ReadBackRegister(pInstance, true, FS8X_FS_SAFE_IOS_ADDR);
1140  (void)FS85_ReadBackRegister(pInstance, true, FS8X_FS_DIAG_SAFETY_ADDR);
1141  (void)FS85_ReadBackRegister(pInstance, true, FS8X_FS_INTB_MASK_ADDR);
1142  (void)FS85_ReadBackRegister(pInstance, true, FS8X_FS_STATES_ADDR);
1143 
1144  /* Read main registers */
1145  (void)FS85_ReadBackRegister(pInstance, FALSE, FS8X_M_FLAG_ADDR);
1146  (void)FS85_ReadBackRegister(pInstance, FALSE, FS8X_M_MODE_ADDR);
1147  (void)FS85_ReadBackRegister(pInstance, FALSE, FS8X_M_REG_CTRL1_ADDR);
1148  (void)FS85_ReadBackRegister(pInstance, FALSE, FS8X_M_REG_CTRL2_ADDR);
1149  (void)FS85_ReadBackRegister(pInstance, FALSE, FS8X_M_AMUX_ADDR);
1150  (void)FS85_ReadBackRegister(pInstance, FALSE, FS8X_M_CLOCK_ADDR);
1151  (void)FS85_ReadBackRegister(pInstance, FALSE, FS8X_M_INT_MASK1_ADDR);
1152  (void)FS85_ReadBackRegister(pInstance, FALSE, FS8X_M_INT_MASK2_ADDR);
1153  (void)FS85_ReadBackRegister(pInstance, FALSE, FS8X_M_FLAG1_ADDR);
1154  (void)FS85_ReadBackRegister(pInstance, FALSE, FS8X_M_FLAG2_ADDR);
1155  (void)FS85_ReadBackRegister(pInstance, FALSE, FS8X_M_VMON_REGX_ADDR);
1156  (void)FS85_ReadBackRegister(pInstance, FALSE, FS8X_M_LVB1_SVS_ADDR);
1157  (void)FS85_ReadBackRegister(pInstance, FALSE, FS8X_M_MEMORY0_ADDR);
1158  (void)FS85_ReadBackRegister(pInstance, FALSE, FS8X_M_MEMORY1_ADDR);
1159  (void)FS85_ReadBackRegister(pInstance, FALSE, FS8X_M_DEVICEID_ADDR);
1160  return retval;
1161 }
1162 
1164  FAS_ASSERT(pInstance != NULL_PTR);
1165 
1166  STD_RETURN_TYPE_e retval = STD_OK;
1167  resetSource_t rstReason = MINFO_GetResetSource();
1168  bool test_assertionRSTB = false; /* Do not test RSTB assertion on default */
1169 
1170  /** Assertion of RSTB pin will trigger reset, check if reset reason was power-cycle.
1171  If so, check if short circuit between FIN and RSTB pin exists */
1172  if (rstReason == POWERON_RESET) {
1173  /** First check if FIN is used */
1174  if (pInstance->fin.finUsed == true) {
1175  /** Write to NVRAM to determine after reset and if short-circuit
1176  * between RSTB and FIN present what exactly caused the reset. */
1177  pInstance->nvram.pData->phase = (uint8_t)FS85_FIN_TEST;
1178  FRAM_WriteData(pInstance->nvram.entry);
1179 
1180  /** MCU SBC is connected to ECLK1 -> privilege mode is required to access register */
1182 
1183  /** Last reset was caused by power-cycle */
1184  /** Set level of FIN pin low and check if this generates reset */
1185  IO_PinReset(pInstance->fin.pGIOport, pInstance->fin.pin);
1186 
1187  /** Pulses longer than 2000ns trigger reset -> wait 10us to check if
1188  reset is triggered by short between RSTB and FIN */
1189  MCU_Delay_us(10u);
1190 
1191  /** If we reach this line of code, no reset has taken place.
1192  Everything okay. Set level of FIN pin back to high */
1193  IO_PinSet(pInstance->fin.pGIOport, pInstance->fin.pin);
1194 
1195  /** No further register access required -> leave privilege mode */
1197 
1198  /** FIN state okay, no short circuit. Update also in nvram struct */
1200  pInstance->fin.finState = STD_OK;
1201  pInstance->nvram.pData->finState = STD_OK;
1202 
1203  /** Continue with RSTB assertion test */
1204  test_assertionRSTB = false;
1205  } else {
1206  /** Power-cycle but no FIN pin used -> continue with RSTB check */
1207  test_assertionRSTB = false;
1208  }
1209  } else if (rstReason == EXT_RESET) {
1210  /** Last reset reason was external reset via nRST pin (EXT_RESET)
1211  Readout FRAM to determine in which state the SBC was prior to reset */
1212  FRAM_ReadData(pInstance->nvram.entry);
1213  if ((FS85_INIT_PHASE_e)pInstance->nvram.pData->phase == FS85_FIN_TEST) {
1214  /** Short-circuit between FIN and RSTB: Do not apply CLK on FIN */
1215  /** Update nvram FIN state */
1216  pInstance->nvram.pData->finState = STD_NOT_OK;
1217  /** FIN state not okay, but still in SBC init phase after power-cycle
1218  * continue now with RSTB assertion */
1219  test_assertionRSTB = false;
1220  } else if ((FS85_INIT_PHASE_e)pInstance->nvram.pData->phase == FS85_RSTB_ASSERTION_TEST) {
1221  /** Reset was triggered by SPI RSTB assertion test -> continue with SBC init phase */
1222  test_assertionRSTB = false;
1223 
1224  /** Diagnosis of the RSTB pin/event is available by reading the FS_SAFE_IOs register:
1225  * RSTB_EVENT bit reports an activation of RSTB pin. */
1226  FS85_ReadBackRegister(pInstance, true, FS8X_FS_SAFE_IOS_ADDR);
1227 
1228  /** Check RSTB_EVENT if RSTB has been activated */
1229  if (STD_OK ==
1232  /** RSTB pin should be sensed high and no RSTB short to high */
1234  uint16_t expRegisterValue =
1237  if (STD_OK != FS85_CheckRegisterValues((pInstance->fsRegister.safeIos & mask), expRegisterValue)) {
1238  retval = STD_NOT_OK;
1239  }
1240  /** Reset RSTB_EVENT flag */
1242  /** Update diag flag */
1244  } else {
1245  /** RSTB has not been activated but this should have been the case */
1246  retval = STD_NOT_OK;
1248  }
1249  } else {
1250  /** Reset was not caused by SBC initialization or power-cycle.
1251  * Continue with SBC init phase as RSTB assertion is only tested
1252  * after power-cycle occurred */
1253  test_assertionRSTB = false;
1254  }
1255  /** Copy FIN state info from nvram variable into local state variable. This restores lost data from rest or
1256  updates local FIN state if short-circuit between FIN and RSTB has been detected */
1257  pInstance->fin.finState = pInstance->nvram.pData->finState;
1258  if (pInstance->fin.finState == STD_OK) {
1260  } else {
1262  }
1263  } else {
1264  /** Reset was not caused by power-cycle or SBC. SBC has already been initialized successfully after detected
1265  * power-cycle. Everything okay. Read FIN state from NVRAM and continue with normal operation */
1266  FRAM_ReadData(pInstance->nvram.entry);
1267  test_assertionRSTB = false;
1268  pInstance->fin.finState = pInstance->nvram.pData->finState;
1269  if (pInstance->fin.finState == STD_OK) {
1271  } else {
1273  }
1274  }
1275 
1276  /** Verify the hardware connection between the MCU reset pin and the FS85 reset pin */
1277  if (test_assertionRSTB == true) {
1278  /** Write to NVRAM to determine after reset and if RSTB was asserted correctly */
1279  pInstance->nvram.pData->phase = (uint8_t)FS85_RSTB_ASSERTION_TEST;
1280  FRAM_WriteData(pInstance->nvram.entry);
1281 
1282  FS85_ReadBackRegister(pInstance, true, FS8X_FS_STATES_ADDR);
1283 
1284  uint16_t registerValue = FS8X_FS_RSTB_REQ_RSTB_ASSERTION;
1285  FS85_WriteRegisterFsInit(pInstance, FS8X_FS_SAFE_IOS_ADDR, registerValue);
1286 
1287  while (true) {
1288  ;
1289  }
1290 
1291  /* Controller should never reach this point as reset via RSTB is requested */
1292  }
1293  return retval;
1294 }
1295 
1297  FAS_ASSERT(pInstance != NULL_PTR);
1298 
1299  STD_RETURN_TYPE_e retval = STD_OK;
1300  /* TBD */
1301  return retval;
1302 }
1303 
1304 /*========== Externalized Static Function Implementations (Unit Test) =======*/
1305 #ifdef UNITY_UNIT_TEST
1306 extern STD_RETURN_TYPE_e TEST_FS85_CheckRegisterValues(uint32_t registerValue, uint32_t expectedRegisterValue) {
1307  return FS85_CheckRegisterValues(registerValue, expectedRegisterValue);
1308 }
1310  FS85_STATE_s *pInstance,
1311  bool isFailSafe,
1312  uint32_t registerAddress,
1313  uint32_t registerValue) {
1314  FS85_UpdateRegister(pInstance, isFailSafe, registerAddress, registerValue);
1315 }
1317  FS85_FS_REGISTER_s *pFsRegister,
1318  uint32_t registerAddress,
1319  uint32_t registerValue) {
1320  FS85_UpdateFailSafeRegister(pFsRegister, registerAddress, registerValue);
1321 }
1322 
1324  FS85_MAIN_REGISTERS_s *pMainRegister,
1325  uint32_t registerAddress,
1326  uint32_t registerValue) {
1327  FS85_UpdateMainRegister(pMainRegister, registerAddress, registerValue);
1328 }
1329 extern STD_RETURN_TYPE_e TEST_FS85_ReadBackRegister(FS85_STATE_s *pInstance, bool isFailSafe, uint8_t registerAddress) {
1330  return FS85_ReadBackRegister(pInstance, isFailSafe, registerAddress);
1331 }
1333  FS85_STATE_s *pInstance,
1334  uint8_t registerAddress,
1335  uint16_t registerValue) {
1336  return FS85_WriteRegisterFsInit(pInstance, registerAddress, registerValue);
1337 }
1339  FS85_STATE_s *pInstance,
1340  uint8_t registerAddress,
1341  uint16_t registerValue) {
1342  return FS85_WriteBackRegisterFsInit(pInstance, registerAddress, registerValue);
1343 }
1345  FS85_STATE_s *pInstance,
1346  uint8_t registerAddress,
1347  bool isFailSafe,
1348  uint16_t registerValue) {
1349  return FS85_ClearRegisterFlags(pInstance, registerAddress, isFailSafe, registerValue);
1350 }
1352  return FS85_ReadBackAllRegisters(pInstance);
1353 }
1355  return FS85_PerformPathCheckRstb(pInstance);
1356 }
1358  return FS85_PerformPathCheckFs0b(pInstance);
1359 }
1361  return FS85_GoToStandby(pInstance);
1362 }
1363 
1364 #endif
DIAG_RETURNTYPE_e DIAG_Handler(DIAG_ID_e diagId, DIAG_EVENT_e event, DIAG_IMPACT_LEVEL_e impact, uint32_t data)
DIAG_Handler provides generic error handling, based on diagnosis group.
Definition: diag.c:246
Diagnosis driver header.
@ DIAG_EVENT_NOT_OK
Definition: diag_cfg.h:268
@ DIAG_EVENT_OK
Definition: diag_cfg.h:267
@ DIAG_SYSTEM
Definition: diag_cfg.h:280
@ DIAG_ID_SBC_RSTB_STATE
Definition: diag_cfg.h:237
@ DIAG_ID_SBC_FIN_STATE
Definition: diag_cfg.h:236
#define FAS_ASSERT(x)
Assertion macro that asserts that x is true.
Definition: fassert.h:251
#define FAS_TRAP
Define that evaluates to essential boolean false thus tripping an assert.
Definition: fassert.h:129
FRAM_RETURN_TYPE_e FRAM_ReadData(FRAM_BLOCK_ID_e blockId)
Reads a variable from the FRAM.
Definition: fram.c:211
FRAM_RETURN_TYPE_e FRAM_WriteData(FRAM_BLOCK_ID_e blockId)
Writes a variable to the FRAM.
Definition: fram.c:133
Header for the driver for the FRAM module.
FRAM_SBC_INIT_s fram_sbcInit
Definition: fram_cfg.c:73
@ FRAM_BLOCK_ID_SBC_INIT_STATE
Definition: fram_cfg.h:107
Definition of foxBMS standard types.
STD_RETURN_TYPE_e
Definition: fstd_types.h:82
@ 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
Function to switch between user mode and privilege mode.
#define FSYS_SwitchToUserMode()
Switch back to user mode.
Definition: fsystem.h:135
long FSYS_RaisePrivilege(void)
Raise privilege.
Definition: test_htsensor.c:71
#define UNIT_TEST_WEAK_IMPL
Definition: general.h:95
fs8x_status_t FS8x_GetFaultErrorCounterValue(SPI_INTERFACE_CONFIG_s *spiInterface, fs8x_drv_data_t *drvData, uint8_t *faultErrorCounterValue)
Reads actual Fault Error Counter value.
Definition: sbc_fs8x.c:270
fs8x_status_t FS8x_WD_Refresh(SPI_INTERFACE_CONFIG_s *spiInterface, fs8x_drv_data_t *drvData)
Performs the watchdog refresh.
Definition: sbc_fs8x.c:160
fs8x_status_t FS8x_WriteRegisterInit(SPI_INTERFACE_CONFIG_s *pSpiInterface, fs8x_drv_data_t *drvData, uint8_t address, uint16_t writeData)
Performs a write to a single FS8x FS init register (during the INIT_FS phase only).
fs8x_status_t FS8x_WriteRegister(SPI_INTERFACE_CONFIG_s *pSpiInterface, fs8x_drv_data_t *drvData, bool isFailSafe, uint8_t address, uint16_t writeData)
Sends write command to the FS8x.
fs8x_status_t FS8x_FS0B_Release(SPI_INTERFACE_CONFIG_s *spiInterface, fs8x_drv_data_t *drvData)
FS0B release routine.
Definition: sbc_fs8x.c:184
fs8x_status_t FS8x_ReadRegister(SPI_INTERFACE_CONFIG_s *pSpiInterface, fs8x_drv_data_t *drvData, bool isFailSafe, uint8_t address, fs8x_rx_frame_t *rxData)
Performs a read from a single FS8x register.
fs8x_status_t
Status return codes.
@ fs8xSPI
@ fs8xStatusOk
@ fs8xStatusError
UNIT_TEST_WEAK_IMPL fs8x_status_t MCU_SPI_TransferData(SPI_INTERFACE_CONFIG_s *pSpiInterface, uint8_t *txFrame, uint16_t frameLengthBytes, uint8_t *rxFrame)
This function transfers single frame through blocking SPI communication in both directions....
Definition: nxpfs85xx.c:1052
void IO_PinSet(volatile uint32_t *pRegisterAddress, uint32_t pin)
Set pin by writing in pin output register.
Definition: io.c:91
void IO_PinReset(volatile uint32_t *pRegisterAddress, uint32_t pin)
Reset pin by writing in pin output register.
Definition: io.c:98
Header for the driver for the IO module.
resetSource_t MINFO_GetResetSource(void)
Get reason for last reset.
Definition: master_info.c:86
void MINFO_SetDebugProbeConnectionState(MINFO_DEBUG_PROBE_CONNECTION_STATE_e state)
Check if debug probe is connected.
Definition: master_info.c:90
General foxBMS-master system information.
@ MINFO_DEBUG_PROBE_CONNECTED
Definition: master_info.h:70
@ MINFO_DEBUG_PROBE_NOT_CONNECTED
Definition: master_info.h:69
void MCU_Delay_us(uint32_t delay_us)
Wait blocking a certain time in microseconds.
Definition: mcu.c:89
Headers for the driver for the MCU module.
STD_RETURN_TYPE_e TEST_FS85_ReadBackRegister(FS85_STATE_s *pInstance, bool isFailSafe, uint8_t registerAddress)
Definition: nxpfs85xx.c:1329
STD_RETURN_TYPE_e FS85_TriggerWatchdog(FS85_STATE_s *pInstance)
Trigger watchdog.
Definition: nxpfs85xx.c:1086
STD_RETURN_TYPE_e TEST_FS85_PerformPathCheckRstb(FS85_STATE_s *pInstance)
Definition: nxpfs85xx.c:1354
static STD_RETURN_TYPE_e FS85_ReadBackRegister(FS85_STATE_s *pInstance, bool isFailSafe, uint8_t registerAddress)
Reads SBC register value.
Definition: nxpfs85xx.c:401
void TEST_FS85_UpdateRegister(FS85_STATE_s *pInstance, bool isFailSafe, uint32_t registerAddress, uint32_t registerValue)
Definition: nxpfs85xx.c:1309
STD_RETURN_TYPE_e FS85_InitializeNumberOfRequiredWatchdogRefreshes(FS85_STATE_s *pInstance, uint8_t *pRequiredWatchdogRefreshes)
Calculates the number of required watchdog refresh to reset fault error counter.
Definition: nxpfs85xx.c:946
FS85_STATE_s fs85xx_mcuSupervisor
Definition: nxpfs85xx.c:87
static STD_RETURN_TYPE_e FS85_PerformPathCheckRstb(FS85_STATE_s *pInstance)
Perform RSTB safety path check.
Definition: nxpfs85xx.c:1163
STD_RETURN_TYPE_e FS85_InitializeFsPhase(FS85_STATE_s *pInstance)
Configures SBC during INIT_FS phase.
Definition: nxpfs85xx.c:531
FS85_INIT_PHASE_e
Definition: nxpfs85xx.c:79
@ FS85_RSTB_ASSERTION_TEST
Definition: nxpfs85xx.c:82
@ FS85_FIN_TEST
Definition: nxpfs85xx.c:81
@ FS85_UNINITIALIZED
Definition: nxpfs85xx.c:80
@ FS85_INITIALIZED
Definition: nxpfs85xx.c:83
static STD_RETURN_TYPE_e FS85_PerformPathCheckFs0b(FS85_STATE_s *pInstance)
Perform FS0B safety path check.
Definition: nxpfs85xx.c:1296
STD_RETURN_TYPE_e TEST_FS85_GoToStandby(FS85_STATE_s *pInstance)
Definition: nxpfs85xx.c:1360
static void FS85_UpdateRegister(FS85_STATE_s *pInstance, bool isFailSafe, uint32_t registerAddress, uint32_t registerValue)
Updates register values.
Definition: nxpfs85xx.c:383
STD_RETURN_TYPE_e TEST_FS85_PerformPathCheckFs0b(FS85_STATE_s *pInstance)
Definition: nxpfs85xx.c:1357
static STD_RETURN_TYPE_e FS85_GoToStandby(FS85_STATE_s *pInstance)
Sends SBC to Standby Mode.
Definition: nxpfs85xx.c:516
static void FS85_UpdateFailSafeRegister(FS85_FS_REGISTER_s *pFsRegister, uint32_t registerAddress, uint32_t registerValue)
Updates fail safe register values.
Definition: nxpfs85xx.c:262
bool FS85_CheckIgnitionSignal(FS85_STATE_s *pInstance)
Check WAKE1 Signal at SBC.
Definition: nxpfs85xx.c:916
void TEST_FS85_UpdateFailSafeRegister(FS85_FS_REGISTER_s *pFsRegister, uint32_t registerAddress, uint32_t registerValue)
Definition: nxpfs85xx.c:1316
static STD_RETURN_TYPE_e FS85_CheckRegisterValues(uint32_t registerValue, uint32_t expectedRegisterValue)
Checks register value against expected value.
Definition: nxpfs85xx.c:252
STD_RETURN_TYPE_e TEST_FS85_CheckRegisterValues(uint32_t registerValue, uint32_t expectedRegisterValue)
Definition: nxpfs85xx.c:1306
STD_RETURN_TYPE_e TEST_FS85_WriteBackRegisterFsInit(FS85_STATE_s *pInstance, uint8_t registerAddress, uint16_t registerValue)
Definition: nxpfs85xx.c:1338
static void FS85_UpdateMainRegister(FS85_MAIN_REGISTERS_s *pMainRegister, uint32_t registerAddress, uint32_t registerValue)
Updates main register values.
Definition: nxpfs85xx.c:324
static STD_RETURN_TYPE_e FS85_ReadBackAllRegisters(FS85_STATE_s *pInstance)
Clears flags in register.
Definition: nxpfs85xx.c:1121
static STD_RETURN_TYPE_e FS85_WriteRegisterFsInit(FS85_STATE_s *pInstance, uint8_t registerAddress, uint16_t registerValue)
Write to fail-safe register.
Definition: nxpfs85xx.c:421
static STD_RETURN_TYPE_e FS85_ClearRegisterFlags(FS85_STATE_s *pInstance, uint8_t registerAddress, bool isFailSafe, uint16_t registerValue)
Clears flags in register.
Definition: nxpfs85xx.c:477
void TEST_FS85_UpdateMainRegister(FS85_MAIN_REGISTERS_s *pMainRegister, uint32_t registerAddress, uint32_t registerValue)
Definition: nxpfs85xx.c:1323
STD_RETURN_TYPE_e TEST_FS85_ReadBackAllRegisters(FS85_STATE_s *pInstance)
Definition: nxpfs85xx.c:1351
STD_RETURN_TYPE_e TEST_FS85_ClearRegisterFlags(FS85_STATE_s *pInstance, uint8_t registerAddress, bool isFailSafe, uint16_t registerValue)
Definition: nxpfs85xx.c:1344
STD_RETURN_TYPE_e FS85_SafetyPathChecks(FS85_STATE_s *pInstance)
Performs SBC safety path checks.
Definition: nxpfs85xx.c:1018
STD_RETURN_TYPE_e TEST_FS85_WriteRegisterFsInit(FS85_STATE_s *pInstance, uint8_t registerAddress, uint16_t registerValue)
Definition: nxpfs85xx.c:1332
static STD_RETURN_TYPE_e FS85_WriteBackRegisterFsInit(FS85_STATE_s *pInstance, uint8_t registerAddress, uint16_t registerValue)
Write to fail-safe register.
Definition: nxpfs85xx.c:443
STD_RETURN_TYPE_e FS85_CheckFaultErrorCounter(FS85_STATE_s *pInstance)
Checks if fault error counter is zero.
Definition: nxpfs85xx.c:1003
Header for the driver for the FRAM module.
@ FS85_DEBUG_MODE
Definition: nxpfs85xx.h:111
@ FS85_NORMAL_MODE
Definition: nxpfs85xx.h:110
#define FS8x_WD_SEED_DEFAULT
Watchdog seed default value.
Definition: sbc_fs8x.h:59
#define FS8x_BO_GET_REG_VALUE(value, mask, shift)
Macro for getting value from register.
This file contains functions for SPI/I2C communication.
#define FS8x_COMM_FRAME_SIZE
#define FS8X_FS_I_FLT_ERR_IMPACT_FS0B_RSTB
#define FS8X_FS_VDDIO_UV_UNDERVOLTAGE_REPORTED
#define FS8X_FS_I_WD_RFR_CNT_MASK
#define FS8X_FS_BAD_WD_TIMING_MASK
#define FS8X_FS_VMON2_OV_OVERVOLTAGE_REPORTED
#define FS8X_M_VBOOSTUVH_EVENT_OCCURRED
#define FS8X_FS_I_ERRMON_FS_IMPACT_FS0B
#define FS8X_FS_VCOREMON_OV_OVERVOLTAGE_REPORTED
#define FS8X_FS_FCCU1_ERROR_DETECTED
#define FS8X_FS_RSTB_DIAG_MASK
#define FS8X_FS_I_FCCU_CFG_NO_MONITORING
#define FS8X_FS_RSTB_REQ_RSTB_ASSERTION
#define FS8X_M_WK2FLG_EVENT_OCCURRED
#define FS8X_FS_I_ERRMON_FLT_POLARITY_POSITIVE_EDGE
#define FS8X_M_INT_MASK2_ADDR
#define FS8X_FS_I_VMON2_UV_FS_IMPACT_NO_EFFECT
#define FS8X_FS_I_ERRMON_ACK_TIME_32MS
#define FS8X_FS_WDW_DC_50
#define FS8X_FS_FSM_STATE_INIT_FS
#define FS8X_FS_I_FCCU1_FLT_POL_FCCU1_L
#define FS8X_FS_ABIST1_OK_PASS
#define FS8X_FS_I_VMON2_ABIST2_VMON2_BIST
#define FS8X_FS_I_VMON4_OV_FS_IMPACT_NO_EFFECT
#define FS8X_FS_DBG_MODE_MASK
#define FS8X_M_MEMORY1_ADDR
#define FS8X_FS_ABIST2_OK_MASK
#define FS8X_FS_I_VMON3_ABIST2_VMON3_BIST
#define FS8X_FS_RSTB_EVENT_MASK
#define FS8X_FS_SPI_FS_CRC_ERROR_DETECTED
#define FS8X_FS_I_WD_RFR_LIMIT_2
#define FS8X_FS_SPI_FS_CLK_WRONG_NUMBER_OF_CLOCK_CYCLES
#define FS8X_FS_LBIST_OK_MASK
#define FS8X_FS_BAD_WD_DATA_BAD_WD_REFRESH
#define FS8X_FS_I2C_FS_CRC_ERROR_DETECTED
#define FS8X_FS_WD_ANSWER_ADDR
#define FS8X_FS_VMON3_UV_UNDERVOLTAGE_REPORTED
#define FS8X_FS_FSM_STATE_MASK
#define FS8X_M_REG_CTRL2_ADDR
Definition: sbc_fs8x_map.h:696
#define FS8X_M_VBOSUVH_EVENT_OCCURRED
#define FS8X_FS_I_VDDIO_OV_FS_IMPACT_NO_EFFECT
#define FS8X_FS_RSTB_DIAG_NO_FAILURE
#define FS8X_FS_RSTB_EVENT_RESET_OCCURRED
#define FS8X_FS_RELEASE_FS0B_ADDR
#define FS8X_FS_WD_WINDOW_ADDR
#define FS8X_FS_VCOREMON_UV_UNDERVOLTAGE_REPORTED
#define FS8X_FS_I_VDDIO_UV_FS_IMPACT_NO_EFFECT
#define FS8X_M_DEVICEID_ADDR
#define FS8X_M_FLAG1_ADDR
#define FS8X_FS_BAD_WD_TIMING_BAD_WD_REFRESH
#define FS8X_FS_I_VMON2_OV_FS_IMPACT_NO_EFFECT
#define FS8X_FS_I2C_FS_REQ_I2C_VIOLATION
#define FS8X_M_VMON_REGX_ADDR
#define FS8X_FS_I_RSTB_DUR_10MS
#define FS8X_FS_I_WD_RFR_LIMIT_SHIFT
#define FS8X_FS_I_VDDIO_ABIST2_VDDIO_BIST
#define FS8X_M_VSUPUVL_EVENT_OCCURRED
#define FS8X_FS_I_VMON4_ABIST2_VMON4_BIST
#define FS8X_FS_ERRMON_ERROR_DETECTED
#define FS8X_M_REG_CTRL1_ADDR
Definition: sbc_fs8x_map.h:432
#define FS8X_FS_I_VCOREMON_OV_FS_IMPACT_NO_EFFECT
#define FS8X_FS_RSTB_SNS_PAD_SENSED_HIGH
#define FS8X_M_WK1RT_WAKE1_HIGH
#define FS8X_FS_VMON4_UV_UNDERVOLTAGE_REPORTED
#define FS8X_FS_I_VCOREMON_UV_FS_IMPACT_NO_EFFECT
#define FS8X_FS_I_FLT_ERR_CNT_1
#define FS8X_M_FLAG_ADDR
Definition: sbc_fs8x_map.h:57
#define FS8X_FS_WD_SEED_ADDR
#define FS8X_FS_I_VMON3_OV_FS_IMPACT_NO_EFFECT
#define FS8X_FS_I_WD_RFR_LIMIT_6
#define FS8X_M_MODE_ADDR
Definition: sbc_fs8x_map.h:304
#define FS8X_FS_VMON4_OV_OVERVOLTAGE_REPORTED
#define FS8X_FS_RSTB_DRV_COMMAND_SENSED_HIGH
#define FS8X_FS_I_WD_RFR_LIMIT_MASK
#define FS8X_FS_DBG_MODE_NO_DEBUG
#define FS8X_FS_I_VMON3_UV_FS_IMPACT_NO_EFFECT
#define FS8X_FS_OTP_CORRUPT_MASK
#define FS8X_FS_I_FS0B_SC_HIGH_CFG_NO_ASSERTION
#define FS8X_FS_I_VMON1_ABIST2_VMON1_BIST
#define FS8X_FS_WD_WINDOW_128MS
#define FS8X_FS_I_SAFE_INPUTS_ADDR
#define FS8X_M_GOTOSTBY_MASK
Definition: sbc_fs8x_map.h:310
#define FS8X_FS_INTB_MASK_ADDR
#define FS8X_FS_SAFE_IOS_ADDR
#define FS8X_M_CLOCK_ADDR
#define FS8X_FS_I_OVUV_SAFE_REACTION1_ADDR
#define FS8X_M_VSUPUVH_EVENT_OCCURRED
#define FS8X_FS_OVUVREG_STATUS_ADDR
#define FS8X_FS_I_FSSM_ADDR
#define FS8X_FS_FS_OSC_DRIFT_OSCILLATOR_DRIFT
#define FS8X_FS_I_WD_CFG_ADDR
#define FS8X_FS_VMON2_UV_UNDERVOLTAGE_REPORTED
#define FS8X_FS_FS_DIG_REF_OV_OVERVOLTAGE_REPORTED
#define FS8X_FS_FS_WD_G_MASK
#define FS8X_FS_DIAG_SAFETY_ADDR
#define FS8X_FS_I_VMON1_UV_FS_IMPACT_NO_EFFECT
#define FS8X_FS_FCCU12_ERROR_DETECTED
#define FS8X_FS_VMON1_OV_OVERVOLTAGE_REPORTED
#define FS8X_FS_RSTB_DRV_MASK
#define FS8X_M_VPREUVH_EVENT_OCCURRED
#define FS8X_FS_VMON1_UV_UNDERVOLTAGE_REPORTED
#define FS8X_M_VSUPUV7_EVENT_OCCURRED
#define FS8X_M_INT_MASK1_ADDR
#define FS8X_FS_I_VMON1_OV_FS_IMPACT_NO_EFFECT
#define FS8X_FS_VMON3_OV_OVERVOLTAGE_REPORTED
#define FS8X_FS_WDW_RECOVERY_128MS
#define FS8X_FS_RSTB_SNS_MASK
#define FS8X_FS_I_SVS_ADDR
#define FS8X_FS_VDDIO_OV_OVERVOLTAGE_REPORTED
#define FS8X_M_LVB1_SVS_ADDR
#define FS8X_FS_I_FCCU1_FS_REACT_FS0B
#define FS8X_FS_SPI_FS_REQ_SPI_VIOLATION
#define FS8X_M_FLAG2_ADDR
#define FS8X_FS_I_WD_RFR_CNT_SHIFT
#define FS8X_FS_FS_WD_G_GOOD_WD_REFRESH
#define FS8X_FS_I_FLT_ERR_CNT_LIMIT_8
#define FS8X_FS_GO_TO_INITFS_GO_BACK_TO_INIT_FS
#define FS8X_FS_I_OVUV_SAFE_REACTION2_ADDR
#define FS8X_FS_I_VMON4_UV_FS_IMPACT_NO_EFFECT
#define FS8X_M_VPREUVL_EVENT_OCCURRED
#define FS8X_FS_OTP_CORRUPT_NO_ERROR
#define FS8X_FS_ABIST1_OK_MASK
#define FS8X_FS_LBIST_OK_PASS
#define FS8X_FS_BAD_WD_DATA_MASK
#define FS8X_FS_I_WD_RFR_LIMIT_4
#define FS8X_M_AMUX_ADDR
Definition: sbc_fs8x_map.h:882
#define FS8X_FS_STATES_ADDR
#define FS8X_M_MEMORY0_ADDR
#define FS8X_FS_I_VCOREMON_ABIST2_VCOREMON_BIST
#define FS8X_FS_GRL_FLAGS_ADDR
#define FS8X_FS_FCCU2_ERROR_DETECTED
STD_RETURN_TYPE_e SPI_TransmitReceiveData(SPI_INTERFACE_CONFIG_s *pSpiInterface, uint16 *pTxBuff, uint16 *pRxBuff, uint32 frameLength)
Transmits and receives data on SPI without DMA.
Definition: spi.c:221
Headers for the driver for the SPI module.
SPI_INTERFACE_CONFIG_s spi_sbcMcuInterface
Definition: spi_cfg.c:255
uint8_t phase
Definition: fram_cfg.h:131
STD_RETURN_TYPE_e finState
Definition: fram_cfg.h:132
volatile uint32_t * pGIOport
Definition: nxpfs85xx.h:118
STD_RETURN_TYPE_e finState
Definition: nxpfs85xx.h:117
uint16_t diag_safety
Definition: nxpfs85xx.h:84
uint16_t releaseFs0bPin
Definition: nxpfs85xx.h:82
uint16_t i_svs
Definition: nxpfs85xx.h:77
uint16_t iWatchdogConfiguration
Definition: nxpfs85xx.h:74
uint16_t watchdogAnswer
Definition: nxpfs85xx.h:80
uint16_t overvoltageUndervoltageRegisterStatus
Definition: nxpfs85xx.h:81
uint16_t i_safe_inputs
Definition: nxpfs85xx.h:75
uint16_t iOvervoltageUndervoltageSafeReaction2
Definition: nxpfs85xx.h:73
uint16_t safeIos
Definition: nxpfs85xx.h:83
uint16_t watchdogSeed
Definition: nxpfs85xx.h:79
uint16_t iFailSafeSateMachine
Definition: nxpfs85xx.h:76
uint16_t grl_flags
Definition: nxpfs85xx.h:71
uint16_t watchdogWindow
Definition: nxpfs85xx.h:78
uint16_t states
Definition: nxpfs85xx.h:86
uint16_t intb_mask
Definition: nxpfs85xx.h:85
uint16_t iOvervoltageUndervoltageSafeReaction1
Definition: nxpfs85xx.h:72
uint16_t registerControl1
Definition: nxpfs85xx.h:94
uint16_t registerControl2
Definition: nxpfs85xx.h:95
uint16_t analogMultiplexer
Definition: nxpfs85xx.h:96
FRAM_SBC_INIT_s * pData
Definition: nxpfs85xx.h:125
FRAM_BLOCK_ID_e entry
Definition: nxpfs85xx.h:124
FS85_MAIN_REGISTERS_s mainRegister
Definition: nxpfs85xx.h:133
FS85_OPERATION_MODE_e mode
Definition: nxpfs85xx.h:136
FS85_FS_REGISTER_s fsRegister
Definition: nxpfs85xx.h:134
FS85_NVRAM_INFO_s nvram
Definition: nxpfs85xx.h:135
FS85_FIN_CONFIGURATION_s fin
Definition: nxpfs85xx.h:132
fs8x_drv_data_t configValues
Definition: nxpfs85xx.h:131
SPI_INTERFACE_CONFIG_s * pSpiInterface
Definition: nxpfs85xx.h:130
Structure representing received data frame.
uint16_t readData
Content of a read register.
uint8_t deviceStatus
A device status is returned into this byte after a successful transfer.