usbuart  2.0.0.0
Main Page

USB UART click

USB UART 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.


Click library

  • Author : MikroE Team
  • Date : Apr 2020.
  • Type : UART GPS/GNSS type

Software Support

We provide a library for the UsbUart 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 form compilers IDE(recommended way), or downloaded from our LibStock, or found on mikroE github account.

Library Description

This library contains API for UsbUart Click driver.

Standard key functions :

  • Config Object Initialization function.

    void usbuart_cfg_setup ( usbuart_cfg_t *cfg );

  • Initialization function.

    USBUART_RETVAL usbuart_init ( usbuart_t *ctx, usbuart_cfg_t *cfg );

Example key functions :

  • Power control.

    void usbuart_pwr_ctrl ( usbuart_t *ctx, uint8_t state );

  • Set device mode

    void usbuart_set_mode ( usbuart_t *ctx, uint8_t mode );

  • Function for send command

    void usbuart_send_command ( usbuart_t *ctx, char *command );

Examples Description

This example reads and processes data from USB UART 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;
// Logger initialization.
LOG_MAP_USB_UART( log_cfg );
log_cfg.level = LOG_LEVEL_DEBUG;
log_cfg.baud = 9600;
log_init( &logger, &log_cfg );
log_info( &logger, "---- Application Init ----" );
// Click initialization.
USBUART_MAP_MIKROBUS( cfg, MIKROBUS_1 );
usbuart_init( &usbuart, &cfg );
}

Application Task

Reads the received data.

void application_task ( void )
{
#ifdef DEMO_APP_RECEIVER
usbuart_process( );
#endif
#ifdef DEMO_APP_TRANSMITER
usbuart_process( );
#endif
}

The full application code, and ready to use projects can be installed directly form compilers IDE(recommneded) or found on LibStock page or mikroE GitHub accaunt.

Other mikroE Libraries used in the example:

  • MikroSDK.Board
  • MikroSDK.Log
  • Click.UsbUart

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. The terminal available in all Mikroelektronika compilers, or any other terminal application of your choice, can be used to read the message.


usbuart_send_command
void usbuart_send_command(usbuart_t *ctx, char *command)
Function for send command.
usbuart_set_cts
void usbuart_set_cts(usbuart_t *ctx, uint8_t state)
Set CTS (Clear to send)
usbuart_cfg_t
Click configuration structure definition.
Definition: usbuart.h:136
usbuart_set_mode
void usbuart_set_mode(usbuart_t *ctx, uint8_t mode)
Set device mode.
USBUART_MODE_NORMAL
#define USBUART_MODE_NORMAL
Definition: usbuart.h:100
application_task
void application_task(void)
Definition: main.c:108
MESSAGE_TO_SENT
#define MESSAGE_TO_SENT
Definition: main.c:33
USBUART_MAP_MIKROBUS
#define USBUART_MAP_MIKROBUS(cfg, mikrobus)
Definition: usbuart.h:53
usbuart_init
USBUART_RETVAL usbuart_init(usbuart_t *ctx, usbuart_cfg_t *cfg)
Initialization function.
usbuart_pwr_ctrl
void usbuart_pwr_ctrl(usbuart_t *ctx, uint8_t state)
Power control.
application_init
void application_init(void)
Definition: main.c:84
USBUART_POWER_ON
#define USBUART_POWER_ON
Definition: usbuart.h:83
usbuart_cfg_setup
void usbuart_cfg_setup(usbuart_cfg_t *cfg)
Config Object Initialization function.
USBUART_CTS_NO_ACTIVE
#define USBUART_CTS_NO_ACTIVE
Definition: usbuart.h:92