/* Setup the CLI module of the application. Allocate memory for the driver handler and initialize the physical layer.  */
int32_t cli_setup(struct cli_desc **device, struct cli_init_param *init_param)
/* Setup the CLI module of the application. Allocate memory for the driver handler and initialize the physical layer.  */
int32_t cli_setup(struct cli_desc **device, struct cli_init_param *init_param)
{
	int32_t ret;
	int8_t i;
	*device = (struct cli_desc *)calloc(1, sizeof(**device));
	if (!(*device))
		return -1;
	ret = uart_init(&((*device)->uart_device), &(init_param->uart_init));
	if (ret != SUCCESS)
		goto error_dev;
	for (i = 0; i < CLI_WIDTH; i++)
		uart_current_line[i] = 0;
	uart_cmd = 0;
	uart_tab = 0;
	ret = uart_read_nonblocking((*device)->uart_device, &uart_buff, 1);
	if (ret != SUCCESS)
		goto error_uart;
	return SUCCESS;
error_uart:
	uart_remove((*device)->uart_device);
error_dev:
	free(*device);
	return FAILURE;
}