123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- /*******************************************************************************
- Class B Implementation Test File
- Summary:
- This file contains the test program for the
- the Class B Safety Software on PIC18 MCUs.
- ********************************************************************************
- File: SSL_Demo2.c
- Processor: PIC18
- Compiler: Microchip MPLAB® C18 v3.41 or higher
- Author: Reiling
-
- Created on 11. Juli 2012, 10:58
- ******************************************************************************/
- #include "SSL_Class_B_Tests.h"
- #pragma romdata CRCID=0x2000
- rom const uint16_t crc_Result_CONST = 0x97B9; /* FLASH CRC result constant */
- #pragma romdata
- /*******************************************************************************
- * Main SSL Demo
- ******************************************************************************/
- uint16_t SSL_Class_B_Tests( void )
- {
- uint16_t testFlags = 0;
- uint16_t crc_Result = 0; // CRC values FLASH
- /************************ CPU REGISTER TEST ***********************************/
- if(SSL_CPU_RegisterTest() == CPU_REGISTER_TEST_PASS)
- {
- // the CPU registers don't have stuck bits
- testFlags |= CPURegister_TestResult;
- }
- else
- {
- testFlags &= ~CPURegister_TestResult;
- }
- /*********************** PROGRAM COUNTER TEST *********************************/
- if (SSL_PCtest() == PROGRAM_COUNTER_TEST_PASS)
- {
- // the PC register does not have stuck bits
- testFlags |= ProgramCounter_TestResult;
- }
- else
- {
- testFlags &= ~ProgramCounter_TestResult;
- }
- /**************************** RAM TESTS ***************************************/
- /********************** Checker Board RAM test ********************************/
- // Note that this test is not destructive. It has to NOT overlap the stack space!
- if (SSL_RAMtest_CheckerBoard( ) == CB_TEST_PASS)
- {
- // the test succeeded and we are confident that the RAM area can be used
- testFlags |= CheckerboardRam_TestResult;
- }
- else
- {
- testFlags &= ~CheckerboardRam_TestResult;
- }
- /********************** Checker Board Stack test ********************************/
- // Note that this test is not destructive. It test Stack and Heap RAM!
- if (SSL_STACKtest_CheckerBoard( ) == CB_TEST_PASS)
- {
- // the test succeeded and we are confident that the RAM area can be used
- testFlags |= CheckerboardRam_TestResult;
- }
- else
- {
- testFlags &= ~CheckerboardRam_TestResult;
- }
- /************************ March B RAM Test ************************************/
- if (SSL_RAMtest_MarchB() == MARCHB_RAM_TEST_PASS)
- {
- // the test succeeded and we can go ahead and use the allocated memory
- testFlags |= MarchBRam_TestResult;
- }
- else
- {
- testFlags &= ~MarchBRam_TestResult;
- }
- /************************ March C RAM Test ************************************/
- if (SSL_RAMtest_MarchC() == MARCHC_RAM_TEST_PASS)
- {
- testFlags |= MarchCRam_TestResult;
- }
- else
- {
- testFlags &= ~MarchCRam_TestResult;
- }
- /************************ MarchC Minus RAM test *******************************/
- if (SSL_RAMtest_MarchCMinus() == MARCHCminus_RAM_TEST_PASS)
- {
- // if both tests succeeded we can go ahead and use the allocated memory
- testFlags |= MarchCMinusRam_TestResult;
- }
- else
- {
- testFlags &= ~MarchCMinusRam_TestResult;
- }
- /*************************** FLASH CRC TEST ***********************************/
- // This function can be called periodically and the generated checksum can be
- // compared with the reference checksum. Reference must be generated after
- // compile and written into "crc_Result_CONST". See above.
- crc_Result = SSL_FLASHtest_CRC( );
- // make sure that the periodic check is equal to the reference one
- if ( crc_Result == crc_Result_CONST)
- {
- testFlags |= Flash_TestResult;
- // we are confident that the data programmed in Flash
- // has not been altered in any way
- }
- else
- {
- testFlags &= ~Flash_TestResult;
- }
- return testFlags;
- }
|