void UART0_Init(void) { /*---------------------------------------------------------------------------------------------------------*/ /* Init UART */ /*---------------------------------------------------------------------------------------------------------*/ UART0->BAUD = UART_BAUD_MODE2 | UART_BAUD_DIV_MODE2(PLL_CLOCK, 115200); _UART_SET_DATA_FORMAT(UART0, UART_WORD_LEN_8 | UART_PARITY_NONE | UART_STOP_BIT_1); }
void UART0_Init(void) { /*---------------------------------------------------------------------------------------------------------*/ /* Init UART */ /*---------------------------------------------------------------------------------------------------------*/ /* Configure UART0 and set UART0 Baudrate */ UART0->BAUD = UART_BAUD_MODE2 | UART_BAUD_DIV_MODE2(__XTAL, 115200); _UART_SET_DATA_FORMAT(UART0, UART_WORD_LEN_8 | UART_PARITY_NONE | UART_STOP_BIT_1); }
void UART1_Init() { /*---------------------------------------------------------------------------------------------------------*/ /* Init UART */ /*---------------------------------------------------------------------------------------------------------*/ UART1->BAUD = UART_BAUD_MODE2 | UART_BAUD_DIV_MODE2(__XTAL, 115200); _UART_SET_DATA_FORMAT(UART1, UART_WORD_LEN_8 | UART_PARITY_NONE | UART_STOP_BIT_1); }
void UART0_Init(void) { /*---------------------------------------------------------------------------------------------------------*/ /* Init UART */ /*---------------------------------------------------------------------------------------------------------*/ /* Reset IP */ SYS->IPRSTC2 |= SYS_IPRSTC2_UART0_RST_Msk; SYS->IPRSTC2 &= ~SYS_IPRSTC2_UART0_RST_Msk; /* Configure UART0 and set UART0 Baudrate */ UART0->BAUD = UART_BAUD_MODE2 | UART_BAUD_DIV_MODE2(PLL_CLOCK, 115200); _UART_SET_DATA_FORMAT(UART0, UART_WORD_LEN_8 | UART_PARITY_NONE | UART_STOP_BIT_1); }
/*---------------------------------------------------------------------------------------------------------*/ 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"); }