/*---------------------------------------------------------------------------------------------------------*/ void LIN_FunctionTestUsingLinCtlReg(void) { uint32_t u32Item; /* LIN Max Speed is 20K */ UART1->BAUD = UART_BAUD_MODE2 | UART_BAUD_MODE2_DIVIDER(__HXT, 9600); /* === CASE 1==== The sample code will send a LIN header with a 12-bit break field, 0x55 sync field and ID field is 0x30. Measurement the UART1 Tx pin to check it. */ /* === CASE 2==== The sample code will send a LIN header with ID is 0x35 and response field. The response field with 8 data bytes and checksum without including ID. Measurement the UART1 Tx pin to check it. */ /* === CASE 3==== The sample code will send a LIN header with ID is 0x12 and response field. The response field with 8 data bytes and checksum with including ID. Measurement the UART1 Tx pin to check it. */ do { LIN_TestItem(); u32Item = getchar(); printf("%c\n", u32Item); switch(u32Item) { case '1': LIN_SendHeaderUsingLinCtlReg(0x30, UART_LIN_CTL_LIN_HEAD_SEL_BREAK_SYNC_ID); break; case '2': LIN_MasterTestUsingLinCtlReg(0x35, MODE_CLASSIC); break; case '3': LIN_MasterTestUsingLinCtlReg(0x12, MODE_ENHANCED); break; default: break; } } while(u32Item != 27); /* Clear header select setting */ UART1->LIN_CTL &= ~UART_LIN_CTL_LIN_HEAD_SEL_Msk; /* Select UART function mode */ UART1->FUN_SEL = UART_FUNC_SEL_UART; printf("\nLIN Sample Code End.\n"); }
/*---------------------------------------------------------------------------------------------------------*/ void LIN_FunctionTestUsingLinCtlReg(void) { uint32_t u32Item; /* Set UART Configuration, LIN Max Speed is 20K */ UART_SetLine_Config(UART1, 9600, UART_WORD_LEN_8, UART_PARITY_NONE, UART_STOP_BIT_1); /* === CASE 1==== The sample code will send a LIN header with a 12-bit break field, 0x55 sync field and ID field is 0x30. Measurement the UART1 Tx pin to check it. */ /* === CASE 2==== The sample code will send a LIN header with ID is 0x35 and response field. The response field with 8 data bytes and checksum without including ID. Measurement the UART1 Tx pin to check it. */ /* === CASE 3==== The sample code will send a LIN header with ID is 0x12 and response field. The response field with 8 data bytes and checksum with including ID. Measurement the UART1 Tx pin to check it. */ do { LIN_TestItem(); u32Item = getchar(); printf("%c\n", u32Item); switch(u32Item) { case '1': LIN_SendHeaderUsingLinCtlReg(0x30, UART_LIN_CTL_LIN_HEAD_SEL_BREAK_SYNC_ID); break; case '2': LIN_MasterTestUsingLinCtlReg(0x35, MODE_CLASSIC); break; case '3': LIN_MasterTestUsingLinCtlReg(0x12, MODE_ENHANCED); break; default: break; } } while(u32Item != 27); /* Clear header select setting */ UART1->LIN_CTL &= ~UART_LIN_CTL_LIN_HEAD_SEL_Msk; UART_Close(UART1); printf("\nLINSample Code End.\n"); }
/*---------------------------------------------------------------------------------------------------------*/ void LIN_FunctionTest() { uint32_t u32Item; /* LIN Max Speeed is 20K */ UART1->BAUD = UART_BAUD_MODE2 | UART_BAUD_DIV_MODE2(48000000,20000); /* Switch back to LIN Function */ _UART_SEL_FUNC(UART1,UART_FUNC_SEL_LIN); /* === CASE 1==== The sample code will send a LIN header with a 12-bit break field, 0x55 sync field and ID field is 0x30. Measurement the UART1 tx pin to check it. */ /* === CASE 2==== The sample code will send a LIN header with ID is 0x35 and response field. The response field with 8 data bytes and checksum without including ID. Measurement the UART1 tx pin to check it. */ /* === CASE 3==== The sample code will send a LIN header with ID is 0x12 and response field. The response field with 8 data bytes and checksum with including ID. Measurement the UART1 tx pin to check it. */ do{ LIN_TestItem(); u32Item = getchar(); printf("%c\n",u32Item); switch(u32Item) { case '1': LIN_SendHeader(0x30); break; case '2': LIN_MasterTest(0x35,MODE_CLASSIC); break; case '3': LIN_MasterTest(0x12,MODE_ENHANCED); break; default: break; } }while(u32Item != 27); _UART_SEL_FUNC(UART1,UART_FUNC_SEL_UART); printf("\nLINSample Code End.\n"); }