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 " );
}

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 );
}
}

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.


usbuart4_cfg_t
USB UART 4 Click configuration object.
Definition: usbuart4.h:132
application_task
void application_task(void)
Definition: main.c:73
PROCESS_BUFFER_SIZE
#define PROCESS_BUFFER_SIZE
Definition: main.c:25
usbuart4_init
err_t usbuart4_init(usbuart4_t *ctx, usbuart4_cfg_t *cfg)
USB UART 4 initialization function.
usbuart4_cfg_setup
void usbuart4_cfg_setup(usbuart4_cfg_t *cfg)
USB UART 4 configuration object setup function.
usbuart4_t
USB UART 4 Click context object.
Definition: usbuart4.h:108
USBUART4_CTS_NO_ACTIVE
#define USBUART4_CTS_NO_ACTIVE
Definition: usbuart4.h:64
usbuart4_generic_read
uint32_t usbuart4_generic_read(usbuart4_t *ctx, char *data_buf, uint16_t max_len)
USB UART 4 data reading function.
usbuart4_set_mode
void usbuart4_set_mode(usbuart4_t *ctx, uint8_t mode)
Set device mode.
USBUART4_MAP_MIKROBUS
#define USBUART4_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition: usbuart4.h:92
usbuart4_pwr_ctrl
void usbuart4_pwr_ctrl(usbuart4_t *ctx, uint8_t state)
Power control.
usbuart4_set_cts
void usbuart4_set_cts(usbuart4_t *ctx, uint8_t state)
Set CTS (Clear to send)
application_init
void application_init(void)
Definition: main.c:33
USBUART4_MODE_NORMAL
#define USBUART4_MODE_NORMAL
Definition: usbuart4.h:61
USBUART4_POWER_ON
#define USBUART4_POWER_ON
Definition: usbuart4.h:66
usbuart4_send_command
void usbuart4_send_command(usbuart4_t *ctx, char *command)
Function for send command.