Hai,
I am using UART DMA to write and read from uart i have configured
My code:
void Uart_DMAInit(void)
{
HalUARTInit();
halUARTCfg_t uartConfig;
uartConfig.configured = TRUE;
uartConfig.baudRate = HAL_UART_BR_9600; //HAL_UART_BR_1M;
uartConfig.flowControl = HAL_UART_FLOW_OFF;
uartConfig.flowControlThreshold = 48;
uartConfig.rx.maxBufSize = 128; //max if DMA gets enabled, don't think it is, but just in case
uartConfig.tx.maxBufSize = 128;
uartConfig.idleTimeout = 6;
uartConfig.intEnable = TRUE;
uartConfig.callBackFunc = My_cb; //UartProcessData Callback function to read uart buff
HalUARTOpen (HAL_UART_PORT_1, &uartConfig);
HalUARTWrite(HAL_UART_PORT_1,"UART INIT", 9);
}
void My_cb ( uint8 port, uint8 event )
{
uint8 ch;
uint8 bytesInRxBuffer;
uint8 u8Recv_Buff[MAX_BUFF_SIZE];
UINT8 pu8Buff[MAX_BUFF_SIZE];
uint32 u32count;
uint32 MaxPktLen;
u32count = 0;
MaxPktLen = 0;
memset( u8Recv_Buff, 0 ,sizeof(u8Recv_Buff));
while (Hal_UART_RxBufLen(port))
{
HalUARTRead (port, &u8Recv_Buff[u32count], 1);
if ( u8Recv_Buff[u32count] == TP_RSP_SOF)
{
++u32count;
HalUARTRead (port, &u8Recv_Buff[u32count], 1);
MaxPktLen = u8Recv_Buff[u32count++];
u32count = HalUARTRead (port, &u8Recv_Buff[u32count], MaxPktLen);
}
}
memcpy(pu8Buff, &u8Recv_Buff[0], MaxPktLen);
//*u32Length = u32count;
//return u32count;
}
Configured in hal_board _cfg.h
/* Set to TRUE enable UART usage, FALSE disable it */
#ifndef HAL_UART
#if (defined ZAPP_P1) || (defined ZAPP_P2) || (defined ZTOOL_P1) || (defined ZTOOL_P2)
#define HAL_UART TRUE
#else
#define HAL_UART TRUE
#endif
#endif
But
in _hal_dma_uart.c
static void HalUARTInitDMA(void)
{
halDMADesc_t *ch;
P2DIR &= ~P2DIR_PRIPO;
P2DIR |= HAL_UART_PRIPO; what does it refer to
#if (HAL_UART_DMA == 1)
PERCFG &= ~HAL_UART_PERCFG_BIT; // Set UART0 I/O to Alt. 1 location on P0.
#else
PERCFG |= HAL_UART_PERCFG_BIT; // Set UART1 I/O to Alt. 2 location on P1.
#endif
PxSEL |= HAL_UART_Px_RX_TX;
PxDIR |= 0x40;
// Enable Tx and Rx on P1.
ADCCFG &= ~HAL_UART_Px_RX_TX; // Make sure ADC doesnt use this.
UxCSR = CSR_MODE; // Mode is UART Mode.
UxUCR = UCR_FLUSH; // Flush it.
I want to configure to USART1 Port 1
i went through D112 Doc, configured accordingly, is there any other configurations to do more ..