uartmux4  2.1.0.0
Main Page

UART MUX 4 click

PRVIH_PAR_RECENICA_SA_PRODUCT_PAGE_DA_ISPRATE_CELINU

[click Product page](CLICK_PRODUCT_PAGE_LINK)


Click library

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

Software Support

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

Standard key functions :

Example key functions :

Example Description

This example demonstrates the use of UART MUX 4 click board by processing the incoming data and displaying them on the USB UART.

The demo application is composed of two sections :

Application Init

Initializes the driver and switches the multiplexer position to enable UART1.

void application_init ( void )
{
log_cfg_t log_cfg;
uartmux4_cfg_t uartmux4_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
uartmux4_cfg_setup( &uartmux4_cfg );
UARTMUX4_MAP_MIKROBUS( uartmux4_cfg, MIKROBUS_1 );
if ( UART_ERROR == uartmux4_init( &uartmux4, &uartmux4_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
uartmux4_enable_uart1( &uartmux4 );
Delay_ms( 100 );
log_info( &logger, " Application Task " );
log_printf( &logger, " ---------------- \r\n" );
Delay_ms( 100 );
}

Application Task

Writes demo message, echos it back, processes all incoming data and displays them on the USB UART.

void application_task ( void )
{
if ( uartmux4_generic_write ( &uartmux4, DEMO_MESSAGE, sizeof( DEMO_MESSAGE ) ) )
{
if ( UARTMUX4_OK == uartmux4_process( &uartmux4 ) )
{
log_printf( &logger, "%s", app_buf );
uartmux4_clear_app_buf( );
}
}
Delay_ms( 2000 );
}

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

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.


uartmux4_init
err_t uartmux4_init(uartmux4_t *ctx, uartmux4_cfg_t *cfg)
UART MUX 4 initialization function.
uartmux4_enable_uart1
void uartmux4_enable_uart1(uartmux4_t *ctx)
UART MUX 4 enable the UART 1 function.
application_task
void application_task(void)
Definition: main.c:93
uartmux4_t
UART MUX 4 Click context object.
Definition: uartmux4.h:92
UARTMUX4_MAP_MIKROBUS
#define UARTMUX4_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition: uartmux4.h:79
uartmux4_enable_uart2
void uartmux4_enable_uart2(uartmux4_t *ctx)
UART MUX 4 enable the UART 2 function.
UARTMUX4_OK
@ UARTMUX4_OK
Definition: uartmux4.h:133
uartmux4_cfg_t
UART MUX 4 Click configuration object.
Definition: uartmux4.h:110
DEMO_MESSAGE
#define DEMO_MESSAGE
Definition: main.c:31
uartmux4_generic_write
err_t uartmux4_generic_write(uartmux4_t *ctx, uint8_t *data_in, uint16_t len)
UART MUX 4 data writing function.
uartmux4_cfg_setup
void uartmux4_cfg_setup(uartmux4_cfg_t *cfg)
UART MUX 4 configuration object setup function.
application_init
void application_init(void)
Definition: main.c:58