Plus routine to configure Rx:
// Enable reception on the defined channel - including configuring the receive data input//extern void fnRxOn(QUEUE_HANDLE Channel){ KINETIS_UART_CONTROL *uart_reg = fnSelectChannel(Channel); switch (Channel) { case 0: // configure the UART Rx 0 pin #if defined UART0_A_LOW _CONFIG_PERIPHERAL(A, 1, PA_1_UART0_RX); // UART0_RX on PA1 (alt. function 2) #elif defined UART0_ON_B _CONFIG_PERIPHERAL(B, 16, PB_16_UART0_RX); // UART0_RX on PB16 (alt. function 3) #elif defined UART0_ON_D _CONFIG_PERIPHERAL(D, 6, PD_6_UART0_RX); // UART0_RX on PD6 (alt. function 3) #else _CONFIG_PERIPHERAL(A, 15, PA_15_UART0_RX); // UART0_RX on PA15 (alt. function 3) #endif fnEnterInterrupt(irq_UART0_ID, PRIORITY_UART0, _SCI0_Interrupt); // enter UART0 interrupt handler break; case 1: // configure the UART Rx 1 pin #if defined UART1_ON_C _CONFIG_PERIPHERAL(C, 3, PC_3_UART1_RX); // UART1_RX on PC3 (alt. function 3) #else _CONFIG_PERIPHERAL(E, 1, PE_1_UART1_RX); // UART1_RX on PE1 (alt. function 3) #endif fnEnterInterrupt(irq_UART1_ID, PRIORITY_UART1, _SCI1_Interrupt); // enter UART1 interrupt handler break; case 2: // configure the UART Rx 2 pin #if defined KINETIS_K70 && defined UART2_ON_E // {3} _CONFIG_PERIPHERAL(E, 17, PE_17_UART2_RX); // UART2_RX on PE17 (alt. function 3) #elif defined KINETIS_K70 && defined UART2_ON_F _CONFIG_PERIPHERAL(F, 13, PF_13_UART2_RX); // UART2_RX on PF13 (alt. function 4) #else _CONFIG_PERIPHERAL(D, 2, PD_2_UART2_RX); // UART2_RX on PD2 (alt. function 3) #endif fnEnterInterrupt(irq_UART2_ID, PRIORITY_UART2, _SCI2_Interrupt); // enter UART2 interrupt handler break; #if UARTS_AVAILABLE > 3 case 3: // configure the UART Rx 3 pin #if defined UART3_ON_B _CONFIG_PERIPHERAL(B, 10, PB_10_UART3_RX); // UART3_RX on PB10 (alt. function 3) #elif defined UART3_ON_C _CONFIG_PERIPHERAL(C, 16, PC_16_UART3_RX); // UART3_RX on PC16 (alt. function 3) #else _CONFIG_PERIPHERAL(E, 5, PE_5_UART3_RX); // UART3_RX on PE5 (alt. function 3) #endif fnEnterInterrupt(irq_UART3_ID, PRIORITY_UART3, _SCI3_Interrupt); // enter UART3 interrupt handler break; case 4: // configure the UART Rx 4 pin #if defined UART4_ON_C _CONFIG_PERIPHERAL(C, 14, PC_14_UART4_RX); // UART4_RX on PC14 (alt. function 3) #else _CONFIG_PERIPHERAL(E, 25, PE_25_UART4_RX); // UART4_RX on PE25 (alt. function 3) #endif fnEnterInterrupt(irq_UART4_ID, PRIORITY_UART4, _SCI4_Interrupt); // enter UART4 interrupt handler break; case 5: // configure the UART Rx 5 pin #if defined UART5_ON_D _CONFIG_PERIPHERAL(D, 8, PD_8_UART5_RX); // UART5_RX on PD8 (alt. function 3) #else _CONFIG_PERIPHERAL(E, 9, PE_9_UART5_RX); // UART5_RX on PE9 (alt. function 3) #endif fnEnterInterrupt(irq_UART5_ID, PRIORITY_UART5, _SCI5_Interrupt); // enter UART5 interrupt handler break; #endif } uart_reg->UART_C2 |= (UART_C2_RE | UART_C2_RIE); // enable reception and reception interrupt}
In the case of DMA operation the DMA is initialised using
// The Kinetis buffer has been set up to run continuously in circular buffer mode. This routine therefore doesn't use the buffer pointer and length passed//extern void fnPrepareRxDMA(QUEUE_HANDLE channel, unsigned char *ptrStart, QUEUE_TRANSFER rx_length){ #if defined SERIAL_SUPPORT_DMA_RX KINETIS_UART_CONTROL *uart_reg = fnSelectChannel(channel); if (!(uart_reg->UART_C2 & (UART_C2_RE))) { // if receiver not yet enabled KINETIS_DMA_TDC *ptrDMA_TCD = (KINETIS_DMA_TDC *)eDMA_DESCRIPTORS; ptrDMA_TCD += UART_DMA_RX_CHANNEL[channel]; ptrDMA_TCD->DMA_TCD_DADDR = (unsigned long)ptrStart; // destination is the input tty buffer DMA_ERQ |= (DMA_ERQ_ERQ0 << UART_DMA_RX_CHANNEL[channel]); // enable request source fnRxOn(channel); // configure receiver pin and enable reception and its interrupt/DMA } #endif}
Regards
Mark