usbuart5  2.1.0.0
Main Page

USB UART 5 click

PRVIH_PAR_RECENICA_SA_PRODUCT_PAGE_DA_ISPRATE_CELINU

[click Product page](CLICK_PRODUCT_PAGE_LINK)


Click library

  • Author : Nenad Filipovic
  • Date : Jan 2023.
  • Type : UART type

Software Support

We provide a library for the USB UART 5 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 USB UART 5 Click driver.

Standard key functions :

Example key functions :

Example Description

This example reads and processes data from USB UART 5 Click boardâ„¢. The library initializes and defines the UART bus drivers to transmit or receive data.

The demo application is composed of two sections :

Application Init

Initializes driver, wake-up module, and performs the default configuration.

void application_init ( void )
{
log_cfg_t log_cfg;
usbuart5_cfg_t usbuart5_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
usbuart5_cfg_setup( &usbuart5_cfg );
USBUART5_MAP_MIKROBUS( usbuart5_cfg, MIKROBUS_1 );
if ( UART_ERROR == usbuart5_init( &usbuart5, &usbuart5_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
if ( USBUART5_ERROR == usbuart5_default_cfg ( &usbuart5 ) )
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
app_buf_len = 0;
app_buf_cnt = 0;
#ifdef DEMO_APP_RECEIVER
log_info( &logger, " RECEIVER " );
#endif
#ifdef DEMO_APP_TRANSMITTER
log_info( &logger, " TRANSMITTER " );
#endif
}

Application Task

Transmitter/Receiver task depends on uncommented code. The receiver logs each received byte to the UART for data logging, while transmitted sends messages every 2 seconds. Results are being sent to the UART Terminal, where you can track their changes.

void application_task ( void )
{
#ifdef DEMO_APP_RECEIVER
usbuart5_process();
if ( app_buf_len > 0 )
{
log_printf( &logger, "%s", app_buf );
usbuart5_clear_app_buf( );
}
#endif
#ifdef DEMO_APP_TRANSMITTER
if ( USBUART5_ERROR != usbuart5_send_data( &usbuart5, &message_data[ 0 ] ) )
{
log_printf( &logger, "MESSAGE SENT\r\n" );
}
Delay_ms( 2000 );
#endif
}

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.USBUART5

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.


usbuart5_cfg_t
USB UART 5 Click configuration object.
Definition: usbuart5.h:126
usbuart5_suspend_mode
void usbuart5_suspend_mode(usbuart5_t *ctx, uint8_t mode)
USB UART 5 suspend mode function.
application_task
void application_task(void)
Definition: main.c:109
usbuart5_t
USB UART 5 Click context object.
Definition: usbuart5.h:103
usbuart5_cfg_setup
void usbuart5_cfg_setup(usbuart5_cfg_t *cfg)
USB UART 5 configuration object setup function.
USBUART5_ERROR
@ USBUART5_ERROR
Definition: usbuart5.h:153
usbuart5_default_cfg
err_t usbuart5_default_cfg(usbuart5_t *ctx)
USB UART 5 default configuration function.
usbuart5_init
err_t usbuart5_init(usbuart5_t *ctx, usbuart5_cfg_t *cfg)
USB UART 5 initialization function.
USBUART5_MAP_MIKROBUS
#define USBUART5_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition: usbuart5.h:87
application_init
void application_init(void)
Definition: main.c:64
usbuart5_send_data
err_t usbuart5_send_data(usbuart5_t *ctx, uint8_t *data_out)
USB UART 5 send data function.
usbuart5_reset_device
void usbuart5_reset_device(usbuart5_t *ctx)
USB UART 5 reset the device function.