usbuart4 2.0.0.0
Main Page

USB UART 4 click

USB UART 4 click offers a USB to asynchronous serial data (UART) interface, allowing the microcontroller based designs to communicate with the personal computer, in a very simple way. It is equipped with the FT232RL, a very popular USB to UART interface IC, used on many MikroElektronika devices - both for its reliability and simplicity. USB UART click is used for whenever there is a need to seamlessly and effortlessly interface the UART lines to a personal computer

click Product page


Click library

  • Author : Stefan Ilic
  • Date : Jun 2021.
  • Type : UART type

Software Support

We provide a library for the USBUART4 Click as well as a demo application (example), developed using MikroElektronika compilers. The demo can run on all the main MikroElektronika development boards.

Package can be downloaded/installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on Mikroe github account.

Library Description

‍This library contains API for USBUART4 Click driver.

Standard key functions :

Example key functions :

Example Description

‍This example reads and processes data from USB UART 4 clicks.

The demo application is composed of two sections :

Application Init

‍Initializes driver and power module.

void application_init ( void ) {
log_cfg_t log_cfg;
usbuart4_cfg_t usbuart4_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
Delay_ms ( 100 );
// Click initialization.
usbuart4_cfg_setup( &usbuart4_cfg );
USBUART4_MAP_MIKROBUS( usbuart4_cfg, MIKROBUS_1 );
err_t init_flag = usbuart4_init( &usbuart4, &usbuart4_cfg );
if ( UART_ERROR == init_flag ) {
log_error( &logger, " Application Init Error. " );
log_info( &logger, " Please, run program again... " );
for ( ; ; );
}
app_buf_len = 0;
log_info( &logger, " Application Task " );
}
#define USBUART4_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition usbuart4.h:106
#define USBUART4_CTS_NO_ACTIVE
Definition usbuart4.h:78
#define USBUART4_MODE_NORMAL
Definition usbuart4.h:75
#define USBUART4_POWER_ON
Definition usbuart4.h:80
void usbuart4_set_mode(usbuart4_t *ctx, uint8_t mode)
Set device mode.
void application_init(void)
Definition main.c:33

Application Task

‍Reads data and echos it back to device and logs it to board.

void application_task ( void ) {
app_buf_len = usbuart4_generic_read( &usbuart4, app_buf, PROCESS_BUFFER_SIZE );
if ( app_buf_len > 0 ) {
log_printf( &logger, "%s", app_buf );
memset( app_buf, 0, PROCESS_BUFFER_SIZE );
}
}
uint32_t usbuart4_generic_read(usbuart4_t *ctx, char *data_buf, uint16_t max_len)
USB UART 4 data reading function.
void application_task(void)
Definition main.c:73
#define PROCESS_BUFFER_SIZE
Definition main.c:25

The full application code, and ready to use projects can be installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on Mikroe github account.

Other Mikroe Libraries used in the example:

  • MikroSDK.Board
  • MikroSDK.Log
  • Click.USBUART4

Additional notes and informations

Depending on the development board you are using, you may need USB UART click, USB UART 2 Click or RS232 Click to connect to your PC, for development systems with no UART to USB interface available on the board. UART terminal is available in all MikroElektronika compilers.