Document API IEC60730 Library
|
Go to the documentation of this file.
27 #include "em_device.h"
30 #include SL_IEC60730_BOARD_HEADER
32 #define IE60730_LIBRARY_VERSION { 2, 0, 0 }
35 #define SL_IEC60730_BOARD_HEADER
44 #define IEC60370_CM4 0
45 #define IEC60370_CM33 1
46 #if defined(__CM4_REV)
47 #define IEC60370_CPU IEC60370_CM4
48 #elif defined(__CM33_REV)
49 #define IEC60370_CPU IEC60370_CM33
51 #error "Unknown Core type!"
113 #define UNUSED_VAR(x) (void) (x)
118 #define __CONCAT(x, y) x##y
121 #define CONCAT(x, y) __CONCAT(x, y)
125 #define XSTR(x) STR(x)
130 #define LABEL_DEF(NAME) LB_ASM volatile(LB_XSTR(NAME))
145 #define DEC_CLASSB_VARS(vartype, name) \
146 __no_init vartype name __CLASSB_RAM; \
147 __no_init vartype CONCAT(name, _inv) __CLASSB_RAM
151 #define EXTERN_DEC_CLASSB_VARS(vartype, name) \
152 extern __no_init vartype name __CLASSB_RAM; \
153 extern __no_init vartype CONCAT(name, _inv) __CLASSB_RAM
157 #define sl_static_dec_classb_vars(vartype, name) \
158 static __no_init vartype name __CLASSB_RAM; \
159 static __no_init vartype CONCAT(name, _inv) __CLASSB_RAM
163 #define INV_CLASSB_VAR(vartype, name) \
164 CONCAT(name, _inv) = (vartype) (~(vartype) name)
168 #define INV_CLASSB_PVAR(vartype, name) \
169 CONCAT(name, _inv) = (vartype *) (~(vartype) name)
171 #if ((defined UNIT_TEST_IEC60730_VARIABLE_MEMORY_ENABLE) || defined (UNIT_TEST_IEC60730_INVARIABLE_MEMORY_ENABLE))
172 #define CHECK_INTEGRITY(vartype, x) unit_test_mock_check_integrity()
174 #define CHECK_INTEGRITY(vartype, x) \
177 ((vartype) - 1 == ((vartype) x ^ (vartype) CONCAT(x, _inv)))
178 #endif // (UNIT_TEST_IEC60730_VARIABLE_MEMORY_ENABLE || UNIT_TEST_IEC60730_INVARIABLE_MEMORY_ENABLE)
188 #define sl_iec60730_crc_t
196 #define SL_IEC60730_INVAR_BLOCKS_PER_BIST
200 #if (SL_IEC60730_USE_CRC_32_ENABLE == 1)
217 #define SL_IEC60730_ROM_SIZE ((uint32_t) SL_IEC60730_ROM_END - (uint32_t) SL_IEC60730_ROM_START)
221 #define STEPS_NUMBER ((uint32_t) SL_IEC60730_ROM_SIZE / SL_IEC60730_FLASH_BLOCK)
225 #define SL_IEC60730_ROM_SIZE_INWORDS ((uint32_t) SL_IEC60730_ROM_SIZE / 4U)
229 #define SL_IEC60730_FLASH_BLOCK_WORDS ((uint32_t) (SL_IEC60730_ROM_SIZE_INWORDS / STEPS_NUMBER))
234 #define SL_IEC60730_ROM_SIZE_TEST(start, end) \
235 ((uint32_t) end - (uint32_t) start)
239 #define STEPS_NUMBER_TEST(start, end) \
240 ((uint32_t) SL_IEC60730_ROM_SIZE_TEST(start, end) / SL_IEC60730_FLASH_BLOCK)
244 #define SL_IEC60730_ROM_SIZE_INWORDS_TEST(start, end) ((uint32_t) SL_IEC60730_ROM_SIZE_TEST(start, end) / 4U)
248 #define SL_IEC60730_FLASH_BLOCK_WORDS_TEST(start, end) ((uint32_t) (SL_IEC60730_ROM_SIZE_INWORDS_TEST(start, end) / STEPS_NUMBER_TEST(start, end)))
253 #ifndef SL_IEC60730_REF_CRC
254 #define SL_IEC60730_REF_CRC (check_sum)
264 #define BLOCKSIZE (4)
272 #define RT_BLOCK_OVERLAP (1)
276 #define RT_BLOCKSIZE (BLOCKSIZE + (RT_BLOCK_OVERLAP << 1))
284 #define BACKGROUND ((uint32_t) 0x00000000uL)
332 #define IEC60730_VMC_COMPLETE (1 << 0)
333 #define IEC60730_IMC_COMPLETE (1 << 1)
335 #define IEC60730_CPU_CLOCKS_COMPLETE (1 << 2)
337 #define IEC60730_CPU_REGS_COMPLETE (1 << 3)
339 #define IEC60730_INTERRUPT_COMPLETE (1 << 4)
341 #define IEC60730_GPIO_COMPLETE (1 << 5)
343 #define IEC60730_ANALOG_COMPLETE (1 << 6)
345 #define IEC60730_COMMS_COMPLETE (1 << 7)
347 #define IEC60730_OEM0_COMPLETE (1 << 8)
349 #define IEC60730_OEM1_COMPLETE (1 << 9)
351 #define IEC60730_OEM2_COMPLETE (1 << 10)
353 #define IEC60730_OEM3_COMPLETE (1 << 11)
355 #define IEC60730_OEM4_COMPLETE (1 << 12)
357 #define IEC60730_OEM5_COMPLETE (1 << 13)
359 #define IEC60730_OEM6_COMPLETE (1 << 14)
361 #define IEC60730_OEM7_COMPLETE (1 << 15)
363 #define IEC60730_ALL_COMPLETE_BITS \
365 (IEC60730_VMC_COMPLETE | IEC60730_IMC_COMPLETE \
366 | IEC60730_CPU_CLOCKS_COMPLETE | IEC60730_CPU_REGS_COMPLETE \
367 | IEC60730_INTERRUPT_COMPLETE | IEC60730_GPIO_COMPLETE \
368 | IEC60730_ANALOG_COMPLETE | IEC60730_COMMS_COMPLETE \
369 | IEC60730_OEM0_COMPLETE | IEC60730_OEM1_COMPLETE | IEC60730_OEM2_COMPLETE \
370 | IEC60730_OEM3_COMPLETE | IEC60730_OEM4_COMPLETE | IEC60730_OEM5_COMPLETE \
371 | IEC60730_OEM6_COMPLETE | IEC60730_OEM7_COMPLETE)
427 uint8_t number_error;
573 #define IEC60730_MAX_IRQ_CHECK 32
592 uint8_t num_irq_fail;
623 #define SL_IEC60370_ENTER_ATOMIC() CORE_ENTER_ATOMIC()
625 #define SL_IEC60370_EXIT_ATOMIC() CORE_EXIT_ATOMIC()
627 #define SL_IEC60370_DECLARE_IRQ_STATE CORE_DECLARE_IRQ_STATE;
631 #define SL_IEC60730_IMC_POST_ENTER_ATOMIC() \
632 CORE_DECLARE_IRQ_STATE; \
636 #define SL_IEC60730_IMC_POST_EXIT_ATOMIC() CORE_EXIT_ATOMIC()
639 #define SL_IEC60730_IMC_BIST_ENTER_ATOMIC() \
640 CORE_DECLARE_IRQ_STATE; \
644 #define SL_IEC60730_IMC_BIST_EXIT_ATOMIC() CORE_EXIT_ATOMIC()
647 #define SL_IEC60730_CRC_INIT(crc, init) GPCRC_Init(crc, init)
648 #define SL_IEC60730_CRC_RESET(crc) GPCRC_Reset(crc)
650 #define SL_IEC60730_CRC_START(crc) GPCRC_Start(crc)
652 #define SL_IEC60730_CRC_INPUTU32(crc, d) GPCRC_InputU32(crc, d)
654 #define SL_IEC60730_CRC_INPUTU16(crc, d) GPCRC_InputU16(crc, d)
656 #define SL_IEC60730_CRC_INPUTU8(crc, d) GPCRC_InputU8(crc, d)
658 #define SL_IEC60730_CRC_DATA_READ(crc) GPCRC_DataRead(crc)
660 #define SL_IEC60730_CRC_DATA_READ_BIT_REVERSED(crc) GPCRC_DataReadBitReversed(crc)
662 #define SL_IEC60730_CRC_DATA_READ_BYTE_REVERSED(crc) GPCRC_DataReadByteReversed(crc)
691 #if (SL_IEC60730_CRC_USE_SW_ENABLE == 0)
714 #define SL_IEC60730_DEFAULT_GPRC
719 #ifndef SL_IEC60730_DEFAULT_GPRC
720 #if (_SILICON_LABS_32B_SERIES == 2)
721 #if ((defined SL_IEC60730_NON_SECURE_ENABLE) || (!defined(SL_TRUSTZONE_SECURE)))
722 #define SL_IEC60730_DEFAULT_GPRC GPCRC_NS
725 #define SL_IEC60730_DEFAULT_GPRC GPCRC
728 #else // (_SILICON_LABS_32B_SERIES == 2)
729 #define SL_IEC60730_DEFAULT_GPRC GPCRC
731 #endif // (_SILICON_LABS_32B_SERIES == 2)
732 #endif // !SL_IEC60730_DEFAULT_GPRC
737 #define SL_IEC60730_IMC_CRC_BUFFER_SAMPLE_TEST "123456789"
740 #define SL_IEC60730_IMC_CRC_BUFFER_INIT_VALUE
750 #define SL_IEC60730_IMC_CRC_BUFFER_XOR_OUTPUT
756 #define SL_IEC60730_IMC_CRC_BUFFER_SAMPLE_RESULT
760 #define SL_IEC60730_IMC_CRC_BUFFER_UPDATE_DEFAULT
764 #if (SL_IEC60730_CRC_USE_SW_ENABLE == 1)
765 #if (SL_IEC60730_USE_CRC_32_ENABLE == 1)
766 #define SL_IEC60730_IMC_CRC_BUFFER_INIT_VALUE SL_IEC60730_IMC_INIT_VALUE
767 #define SL_IEC60730_IMC_CRC_BUFFER_XOR_OUTPUT (0xFFFFFFFFuL)
768 #define SL_IEC60730_IMC_CRC_BUFFER_SAMPLE_RESULT (0xCBF43926)
769 #define SL_IEC60730_IMC_CRC_BUFFER_UPDATE_DEFAULT { SL_IEC60730_IMC_CRC_BUFFER_XOR_OUTPUT }
771 #define SL_IEC60730_IMC_CRC_BUFFER_INIT_VALUE SL_IEC60730_IMC_INIT_VALUE
772 #define SL_IEC60730_IMC_CRC_BUFFER_XOR_OUTPUT (0x0000)
773 #define SL_IEC60730_IMC_CRC_BUFFER_SAMPLE_RESULT (0x31C3)
774 #define SL_IEC60730_IMC_CRC_BUFFER_UPDATE_DEFAULT { SL_IEC60730_IMC_CRC_BUFFER_XOR_OUTPUT }
777 #if (SL_IEC60730_USE_CRC_32_ENABLE == 1)
778 #define SL_IEC60730_IMC_CRC_BUFFER_INIT_VALUE SL_IEC60730_IMC_INIT_VALUE
779 #define SL_IEC60730_IMC_CRC_BUFFER_XOR_OUTPUT (0xFFFFFFFFuL)
780 #define SL_IEC60730_IMC_CRC_BUFFER_SAMPLE_RESULT (0xCBF43926)
781 #define SL_IEC60730_IMC_CRC_BUFFER_INIT_DEFAULT \
784 SL_IEC60730_IMC_CRC_BUFFER_INIT_VALUE, \
792 #define SL_IEC60730_IMC_CRC_BUFFER_UPDATE_DEFAULT \
793 { { SL_IEC60730_DEFAULT_GPRC }, \
794 SL_IEC60730_IMC_CRC_BUFFER_INIT_DEFAULT, \
795 SL_IEC60730_IMC_DATA_READ, \
796 SL_IEC60730_IMC_CRC_BUFFER_XOR_OUTPUT }
798 #define SL_IEC60730_IMC_CRC_BUFFER_INIT_VALUE SL_IEC60730_IMC_INIT_VALUE
799 #define SL_IEC60730_IMC_CRC_BUFFER_XOR_OUTPUT (0x0000)
800 #define SL_IEC60730_IMC_CRC_BUFFER_SAMPLE_RESULT (0x31C3)
801 #define SL_IEC60730_IMC_CRC_BUFFER_INIT_DEFAULT \
804 SL_IEC60730_IMC_CRC_BUFFER_INIT_VALUE, \
811 #define SL_IEC60730_IMC_CRC_BUFFER_UPDATE_DEFAULT \
812 { { SL_IEC60730_DEFAULT_GPRC }, \
813 SL_IEC60730_IMC_CRC_BUFFER_INIT_DEFAULT, \
814 SL_IEC60730_IMC_DATA_READ_BIT_REVERSED, \
815 SL_IEC60730_IMC_CRC_BUFFER_XOR_OUTPUT }
864 #define SL_IEC60730_VMC_POST_ENTER_CRITICAL() \
866 CORE_DECLARE_IRQ_STATE; \
867 CORE_ENTER_CRITICAL()
870 #define SL_IEC60730_VMC_POST_EXIT_CRITICAL() CORE_EXIT_CRITICAL()
873 #define SL_IEC60730_VMC_BIST_ENTER_CRITICAL() \
874 CORE_DECLARE_IRQ_STATE; \
875 CORE_ENTER_CRITICAL()
878 #define SL_IEC60730_VMC_BIST_EXIT_CRITICAL() CORE_EXIT_CRITICAL()
906 #if (_SILICON_LABS_32B_SERIES == 2)
911 #define SL_IEC60730_BURAM_WRITE(buram_inst, idx, val) \
913 buram_inst->RET[idx].REG = val; \
919 #define SL_IEC60730_BURAM_READ(buram_inst, idx) (buram_inst->RET[idx].REG)
@ SL_IEC60730_NO_FAILURE
No failure detected.
Definition: sl_iec60730.h:80
@ SL_IEC60730_OEM_FAIL_2
OEM defined failure.
Definition: sl_iec60730.h:104
sl_iec60730_crc_typedef * gpcrc
GPCRC Register.
Definition: sl_iec60730.h:684
@ SL_IEC60730_INTERRUPT_FAIL
Interrupt Plausibility Check detected a failure.
Definition: sl_iec60730.h:87
sl_iec60730_test_failure_t
Cause of failure passed to Safe State function.
Definition: sl_iec60730.h:79
void sl_iec60730_restart_watchdogs(void)
sl_iec60730_read_type_t readType
The way to read calculated CRC value.
Definition: sl_iec60730.h:694
sl_iec60730_crc_t check_sum
Definition: sl_iec60730.h:708
This structure is used as configuration for IMC testing. The variable contains information about the ...
Definition: sl_iec60730.h:700
@ SL_IEC60730_USART3_FAIL
USART3 comms channel detected a failure.
Definition: sl_iec60730.h:99
uint16_t sl_iec60730_program_counter_check
@ SL_IEC60730_RADIO_FAIL
Radio comms detected a failure.
Definition: sl_iec60730.h:93
SL_IEC60730_IRQ_TYPE_VARIABLE max
Maximum executed executions of ISR. Can be 0-255, must be greater than or equal to min.
Definition: sl_iec60730.h:584
@ SL_IEC60730_EUART0_FAIL
EUART comms channel detected a failure.
Definition: sl_iec60730.h:101
sl_iec60730_crc_init_typedef init
CRC initialization structure.
Definition: sl_iec60730.h:693
Definition: sl_iec60730.h:425
@ SL_IEC60730_LESENSE0_FAIL
LESENSE0 detected a failure.
Definition: sl_iec60730.h:92
sl_iec60730_timer_test_control_t
Enable/disable switch for system timer test.
Definition: sl_iec60730.h:502
uint8_t minor
Minor version.
Definition: sl_iec60730.h:64
@ SL_IEC60730_TIMER_TEST_ENABLE
timer tests will execute
Definition: sl_iec60730.h:504
@ SL_IEC60730_OEM_FAIL_3
OEM defined failure.
Definition: sl_iec60730.h:105
@ SL_IEC60730_CS0_FAIL
CSEN0 detected a failureLESENSE.
Definition: sl_iec60730.h:91
@ SL_IEC60730_CLOCK_FAIL
System Clock Check detected a failure.
Definition: sl_iec60730.h:86
@ SL_IEC60730_USART0_FAIL
USART0 comms channel detected a failure.
Definition: sl_iec60730.h:96
GPCRC_Init_TypeDef sl_iec60730_crc_init_typedef
CRC initialization structure.
Definition: sl_iec60730.h:669
uint8_t number_of_test_regions
Number of test regions.
Definition: sl_iec60730.h:710
sl_iec60730_safety_check_t * sl_iec60730_safety_check_get_error(void)
This structure is used as multiple test regions for VMC testing.
Definition: sl_iec60730.h:887
@ SL_IEC60730_TEST_IN_PROGRESS
test is still in progress
Definition: sl_iec60730.h:75
void sl_iec60730_sys_clock_count_reset(void)
Definition: sl_iec60730.h:690
GPCRC_TypeDef sl_iec60730_crc_typedef
the General Purpose Cyclic Redundancy Check (GPCRC) module
Definition: sl_iec60730.h:667
Definition: sl_iec60730.h:62
void sl_iec60730_vmc_init(sl_iec60730_vmc_test_multiple_regions_t *test_config)
uint8_t sl_iec60730_read_type_t
The way to read CRC value when using function sl_iec60730_update_crc_with_data_buffer.
Definition: sl_iec60730.h:672
uint32_t * start
Start address of RAM to check.
Definition: sl_iec60730.h:882
uint32_t * end
End address of RAM to check.
Definition: sl_iec60730.h:883
@ SL_IEC60730_PDM0_FAIL
PDM comms channel detected a failure.
Definition: sl_iec60730.h:102
#define sl_iec60730_crc_t
Definition: sl_iec60730.h:191
uint8_t major
Major version.
Definition: sl_iec60730.h:63
@ SL_IEC60730_I2C1_FAIL
I2C1 comms channel detected a failure.
Definition: sl_iec60730.h:95
void sl_iec60730_test_clock_tick(void)
@ SL_IEC60730_IMC_DATA_READ
use function GPCRC_DataRead to read CRC
Definition: sl_iec60730.h:675
Definition: sl_iec60730.h:580
void sl_iec60730_sys_clock_count_tick(void)
@ SL_IEC60730_WATCHDOG_POST_FAIL
Watchdog POST test failed.
Definition: sl_iec60730.h:82
uint8_t revision
Revision.
Definition: sl_iec60730.h:65
@ SL_IEC60730_USART1_FAIL
USART1 comms channel detected a failure.
Definition: sl_iec60730.h:97
void sl_iec60730_bist(void)
@ SL_IEC60730_VMC_FAIL
Variable Memory Check detected a failure.
Definition: sl_iec60730.h:83
@ SL_IEC60730_OEM_FAIL_1
OEM defined failure.
Definition: sl_iec60730.h:103
@ SL_IEC60730_IMC_DATA_READ_BIT_REVERSED
use function GPCRC_DataReadBitReversed to read CRC
Definition: sl_iec60730.h:676
@ SL_IEC60730_TEST_VERIFY
Special case used for automated verification testing.
Definition: sl_iec60730.h:81
SL_IEC60730_IRQ_TYPE_VARIABLE min
Minimum expected executions of ISR. Can be 0-255, must be less than or equal to max.
Definition: sl_iec60730.h:582
#define SL_IEC60730_IRQ_TYPE_VARIABLE
Data type for iec60730_IRQExecCount variables.
Definition: sl_iec60730_config.h:38
@ SL_IEC60730_TIMER_TEST_DISABLE
timer tests will not execute
Definition: sl_iec60730.h:503
@ SL_IEC60730_TEST_FAILED
test result failed
Definition: sl_iec60730.h:73
This structure is used as configuration for VMC testing.
Definition: sl_iec60730.h:881
Definition: sl_iec60730.h:590
Definition: sl_iec60730.h:611
void sl_iec60730_post(void)
uint8_t number_of_test_regions
Number of test regions.
Definition: sl_iec60730.h:889
sl_iec60730_test_result_t
The result of a test.
Definition: sl_iec60730.h:72
@ SL_IEC60730_OEM_FAIL_4
OEM defined failure.
Definition: sl_iec60730.h:106
void sl_iec60730_safety_check_error_occur(sl_iec60730_test_failure_t failure)
@ SL_IEC60730_IMC_FAIL
Invariable Memory Check detected a failure.
Definition: sl_iec60730.h:84
@ SL_IEC60730_CPU_REGISTERS_FAIL
CPU Registers Check detected a failure.
Definition: sl_iec60730.h:85
sl_iec60730_imc_params_t hal
struct sl_iec60730_imc_params_t that contain GPCRC Register
Definition: sl_iec60730.h:692
sl_iec60730_crc_t xorOut
XOR with calculated CRC value.
Definition: sl_iec60730.h:696
const sl_iec60730_library_version_t SL_IEC60730_LIBRARY_VERSION
Global variable which holds the IEC60370 library version.
@ SL_IEC60730_LEUART0_FAIL
LEUART comms channel detected a failure.
Definition: sl_iec60730.h:100
void sl_iec60730_safe_state(sl_iec60730_test_failure_t failure)
@ SL_IEC60730_TEST_PASSED
test result passed
Definition: sl_iec60730.h:74
@ SL_IEC60730_GPIO_FAIL
GPIO Plausibility Check detected a failure.
Definition: sl_iec60730.h:89
uint32_t * start
Start address of FLASH to check.
Definition: sl_iec60730.h:701
@ SL_IEC60730_SAFETY_CHECK_FAIL
iec60730_safety_check detected some failure
Definition: sl_iec60730.h:107
@ SL_IEC60730_IMC_DATA_READ_BYTE_REVERSED
use function GPCRC_DataReadByteReversed to read CRC
Definition: sl_iec60730.h:678
uint32_t * end
End address of FLASH to check.
Definition: sl_iec60730.h:702
This structure is used as configuration for IMC testing, that holds GPCRC Register.
Definition: sl_iec60730.h:683
void sl_iec60730_imc_init(sl_iec60730_imc_params_t *params, sl_iec60730_imc_test_multiple_regions_t *test_config)
sl_iec60730_test_result_t sl_iec60730_update_crc_with_data_buffer(sl_iec60730_update_crc_params_t *params, sl_iec60730_crc_t *crc, uint8_t *buffer, uint32_t size)
@ SL_IEC60730_ANALOG_FAIL
Analog Plausibility Check detected a failure.
Definition: sl_iec60730.h:90
@ SL_IEC60730_USART2_FAIL
USART2 comms channel detected a failure.
Definition: sl_iec60730.h:98
@ SL_IEC60730_PROGRAM_COUNTER_FAIL
Program Counter Check detected a failure.
Definition: sl_iec60730.h:88
void sl_iec60730_safety_check_reset_error(void)
@ SL_IEC60730_I2C0_FAIL
I2C0 comms channel detected a failure.
Definition: sl_iec60730.h:94