Commit 7f99d9de authored by Mahmoud Rushdi's avatar Mahmoud Rushdi Committed by Oliver Horst
Browse files

[fix] Apply review comments.

parent 9af215bc
......@@ -59,12 +59,11 @@ int hal_uart_init_channel(hal_io_handle_t handle, uint32_t baudrate)
uartInstance_t *uartInstPtr;
XUartPs *xilUartPtr;
XUartPs_Config *cfgPtr;
int status, i;
uint32_t status;
if (handle >= MAX_NUM_UART_CONTROLLERS )
if ( MAX_NUM_UART_CONTROLLERS <= handle )
{
// Unsupported handle
// xil_printf( "UART: hal_uart_init_channel: handle should be less than %d. \n", MAX_NUM_UART_CONTROLLERS);
/* Unsupported handle */
return pdFAIL;
}
else
......@@ -75,7 +74,6 @@ int hal_uart_init_channel(hal_io_handle_t handle, uint32_t baudrate)
cfgPtr = XUartPs_LookupConfig( handle );
if ( !cfgPtr )
{
// xil_printf( "UART: hal_uart_init_channel: handle can't be resolved. \n");
return pdFAIL;
}
else
......@@ -90,30 +88,23 @@ int hal_uart_init_channel(hal_io_handle_t handle, uint32_t baudrate)
);
if ( XST_SUCCESS != status )
{
// xil_printf( "UART: hal_uart_init_channel: Xilinx driver initialization failed. \n");
return pdFAIL;
}
else
{
/*
* Run self-test on the UART controller.
*/
/* Run self-test on the UART controller. */
status = XUartPs_SelfTest( xilUartPtr );
if ( XST_SUCCESS != status )
{
// xil_printf( "UART: hal_uart_init_channel: Xilinx driver self-test failed. \n");
return pdFAIL;
}
else
{
/*
* Set the baudrate.
*/
/* Set the baudrate. */
status = XUartPs_SetBaudRate( xilUartPtr, baudrate);
if ( XST_SUCCESS != status )
{
// xil_printf( "UART: hal_uart_init_channel: Xilinx driver Set Baudrate failed. \n");
return pdFAIL;
}
......@@ -121,10 +112,7 @@ int hal_uart_init_channel(hal_io_handle_t handle, uint32_t baudrate)
* of bus-off state. */
uartInstPtr->baudrate = baudrate;
/*
* Enter Normal Mode.
*/
/* Enter Normal Mode. */
XUartPs_SetOperMode(xilUartPtr, XUARTPS_OPER_MODE_NORMAL);
while( XUARTPS_OPER_MODE_NORMAL != XUartPs_GetOperMode(xilUartPtr) );
......@@ -133,15 +121,13 @@ int hal_uart_init_channel(hal_io_handle_t handle, uint32_t baudrate)
}
}
}
}
int hal_uart_getchar(hal_io_handle_t handle, uint8_t *ch)
{
if (handle >= MAX_NUM_UART_CONTROLLERS )
if ( MAX_NUM_UART_CONTROLLERS <= handle )
{
// Unsupported handle
// xil_printf( "UART: hal_uart_getchar: handle should be less than %d. \n", MAX_NUM_UART_CONTROLLERS);
/* Unsupported handle */
return pdFAIL;
}
else
......@@ -157,14 +143,18 @@ int hal_uart_getchar(hal_io_handle_t handle, uint8_t *ch)
int hal_uart_getchar_timeout(hal_io_handle_t handle, uint8_t *ch, TickType_t timeout)
{
(void) handle;
(void) *ch;
(void) timeout;
return pdFAIL;
}
int hal_uart_putchar(hal_io_handle_t handle, uint8_t ch)
{
if (handle >= MAX_NUM_UART_CONTROLLERS )
if ( MAX_NUM_UART_CONTROLLERS <= handle )
{
// Unsupported handle
// xil_printf( "UART: hal_uart_putchar: handle should be less than %d. \n", MAX_NUM_UART_CONTROLLERS);
/* Unsupported handle */
return pdFAIL;
}
else
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment