int main()
{
SysCtlClockSet(SYSCTL_SYSDIV_2_5|SYSCTL_USE_PLL|SYSCTL_OSC_MAIN|SYSCTL_XTAL_8MHZ);
/*UART2 INIT*/
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
SysCtlPeripheralEnable(SYSCTL_PERIPH_UART2);
HWREG(GPIO_PORTD_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY;
HWREG(GPIO_PORTD_BASE + GPIO_O_CR) = 0xFF;
GPIOPinConfigure(GPIO_PD7_U2TX);
GPIOPinConfigure(GPIO_PD6_U2RX);
GPIOPinTypeUART(GPIO_PORTD_BASE,GPIO_PIN_7|GPIO_PIN_6);
UARTConfigSetExpClk(UART2_BASE,SysCtlClockGet(),115200,UART_CONFIG_WLEN_8|UART_CONFIG_STOP_ONE|UART_CONFIG_PAR_NONE);
UARTEnable(UART2_BASE);
/*UART4 INIT*/
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);
SysCtlPeripheralEnable(SYSCTL_PERIPH_UART4);
GPIOPinConfigure(GPIO_PC4_U4RX);
GPIOPinTypeUART(GPIO_PORTC_BASE,GPIO_PIN_4);
UARTFIFOLevelSet(UART4_BASE,UART_FIFO_TX4_8,UART_FIFO_RX4_8);
UARTConfigSetExpClk(UART4_BASE,SysCtlClockGet(),100000,
UART_CONFIG_WLEN_8|UART_CONFIG_STOP_TWO|UART_CONFIG_PAR_EVEN);
/* DMA */
SysCtlPeripheralEnable(SYSCTL_PERIPH_UDMA);
uDMAEnable();
uDMAControlBaseSet(DMAControlTable);
uDMAChannelAssign(UDMA_CH18_UART4RX);
uDMAChannelAttributeDisable(UDMA_CH18_UART4RX,
UDMA_ATTR_USEBURST|
UDMA_ATTR_HIGH_PRIORITY|
UDMA_ATTR_ALTSELECT|
UDMA_ATTR_REQMASK);
uDMAChannelAttributeEnable(UDMA_CH18_UART4RX,UDMA_ATTR_ALTSELECT);
uDMAChannelControlSet(UDMA_CH18_UART4RX|UDMA_PRI_SELECT,
UDMA_SIZE_8|
UDMA_SRC_INC_NONE|
UDMA_DST_INC_NONE|
UDMA_ARB_8);
uDMAChannelControlSet(UDMA_CH18_UART4RX|UDMA_PRI_SELECT,
UDMA_SIZE_8|UDMA_SRC_INC_NONE|
UDMA_DST_INC_NONE|UDMA_ARB_8);
uDMAChannelTransferSet(UDMA_CH18_UART4RX|UDMA_PRI_SELECT,
UDMA_MODE_PINGPONG,
(void*)(UART4_BASE+UART_O_DR),
remote_dataA,13);
uDMAChannelTransferSet(UDMA_CH18_UART4RX|UDMA_PRI_SELECT,
UDMA_MODE_PINGPONG,
(void*)(UART4_BASE+UART_O_DR),
remote_dataB,12);
uDMAChannelEnable(UDMA_CH18_UART4RX);
IntMasterEnable();
UARTDMAEnable(UART4_BASE,UART_DMA_RX);
UARTEnable(UART4_BASE);
IntEnable(INT_UART4);
UARTIntEnable(UART4_BASE,UART_INT_RX);
while(1)
{
data_send(remote_dataA,13);
data_send(remote_dataB,12);
data_send(remote_data,25);
}
}
/* UART IRQ */
void UART4_Handler(void)
{
uint32_t status,mode;
status=UARTIntStatus(UART4_BASE,true);
UARTIntClear(UART4_BASE,status);
mode=uDMAChannelModeGet(UDMA_CH18_UART4RX|UDMA_PRI_SELECT);
if(mode==UDMA_MODE_STOP)
{
uDMAChannelTransferSet(UDMA_CH18_UART4RX|UDMA_PRI_SELECT,
UDMA_MODE_PINGPONG,
(void*)(UART4_BASE+UART_O_DR),
remote_dataA,13);
}
mode=uDMAChannelModeGet(UDMA_CH18_UART4RX|UDMA_ALT_SELECT);
if(mode==UDMA_MODE_STOP)
{
uDMAChannelTransferSet(UDMA_CH18_UART4RX|UDMA_PRI_SELECT,
UDMA_MODE_PINGPONG,
(void*)(UART4_BASE+UART_O_DR),
remote_dataB,12);
}
uDMAChannelEnable(UDMA_CH18_UART4RX);
for(uint8_t j=0;j