/* POST CPU Register Test */
IEC60730_CPU_Reg_Test();
if(!CPUTestPass) {
while(1);
}
/* POST RAM Test */
if(IEC60730_RAM_MarchX_Test(0x20000000, 600, NULL) == FAIL)
while(1);
/* Init System, IP clock and multi-function I/O */
SYS_Init();
/* Configure UART0: 115200, 8-bit word, no parity bit, 1 stop bit. */
UART_Open(UART0, 115200);
printf("+-------------------------------------------------+\n");
printf("| Nuvoton MCU IEC60730 Test Suite |\n");
printf("+-------------------------------------------------+\n");
/* CPU Registers Test */
CPUTestPass = 0;
printf("CPU Register Test (BIST)...");
IEC60730_CPU_Reg_Test();
if(CPUTestPass) printf("Pass !!\n");
else printf("Fail !!\n");
/* Program Counter Test */
printf("Program Counter Test ...");
bResult = IEC60730_CPU_PC_Test();
if(bResult) printf("Pass !!\n");
else printf("Fail !!\n");
/* POST CPU Register Test */
IEC60730_CPU_Reg_Test();
if(!CPUTestPass) {
while(1);
}
/* POST RAM Test */
if(IEC60730_RAM_MarchX_Test(0x20000000, 600, NULL) == FAIL)
while(1);
/* Init System, IP clock and multi-function I/O */
SYS_Init();
/* Configure UART0: 115200, 8-bit word, no parity bit, 1 stop bit. */
UART_Open(UART0, 115200);
printf("+-------------------------------------------------+\n");
printf("| Nuvoton MCU IEC60730 Test Suite |\n");
printf("+-------------------------------------------------+\n");
/* CPU Registers Test */
CPUTestPass = 0;
printf("CPU Register Test (BIST)...");
IEC60730_CPU_Reg_Test();
if(CPUTestPass) printf("Pass !!\n");
else printf("Fail !!\n");
/* Program Counter Test */
printf("Program Counter Test ...");
bResult = IEC60730_CPU_PC_Test();
if(bResult) printf("Pass !!\n");
else printf("Fail !!\n");
void GenerateCRCTable(void)
{
uint32_t i, j;
uint8_t u8CRCPoly = 0x89; // the value of our CRC-7 polynomial
// generate a table value for all 256 possible byte values
for (i = 0; i < 256; i++) {
aCRCTable[i] = (i & 0x80) ? i ^ u8CRCPoly : i;
for (j = 1; j < 8; j++) {
aCRCTable[i] <<= 1;
if (aCRCTable[i] & 0x80)
aCRCTable[i] ^= u8CRCPoly;
}
}
}
// adds a message byte to the current CRC-7 to get a the new CRC-7
uint8_t CRCAdd(uint8_t u8CRC, uint8_t u8MessageByte)
{
return aCRCTable[(u8CRC << 1) ^ u8MessageByte];
}
// returns the CRC-7 for a message of "length" bytes
uint8_t getCRC(uint8_t *u8pMessage, uint32_t u32Length)
{
uint32_t i;
uint8_t u8CRC = 0;
for (i = 0; i < u32Length; i++)
u8CRC = CRCAdd(u8CRC, u8pMessage[i]);
return u8CRC;
}