lr  2.0.0.0
Main Page

LR click

LR Click is a compact add-on board that contains a low-power, long-range transceiver. This board features the RN2483, RF technology-based SRD transceiver, which operates at a frequency of 433/868MHz from Microchip Technology.

click Product page 1

click Product page 2


Click library

  • Author : MikroE Team
  • Date : jul 2020.
  • Type : UART GSM/IOT type

Software Support

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

Standard key functions :

  • Config Object Initialization function.

    void lr_cfg_setup ( lr_cfg_t *cfg );

  • Initialization function.

    LR_RETVAL lr_init ( lr_t *ctx, lr_cfg_t *cfg );

  • Click Default Configuration function.

    void lr_default_cfg ( lr_t *ctx, bool cb_default, void ( *response_p )( char *response ) );

Example key functions :

  • Used by parser to send data inside the software buffer. User can send valid
  • commands with this function but command string and data should be well formated.

    void lr_cmd ( lr_t *ctx, char *cmd, char *response );

  • This function is used for receive message.

    uint8_t lr_rx ( lr_t *ctx, char *window_size, char *response );

  • This function is used for sending message.

    uint8_t lr_tx ( lr_t *ctx, char *buffer );

Examples Description

This example reads and processes data from LR clicks.

The demo application is composed of two sections :

Application Init

Initializes driver init and LR init.

void application_init ( void )
{
log_cfg_t log_cfg;
lr_cfg_t cfg;
// Logger initialization.
LOG_MAP_USB_UART( log_cfg );
log_cfg.level = LOG_LEVEL_DEBUG;
log_cfg.baud = 115200;
log_init( &logger, &log_cfg );
log_info( &logger, "---- Application Init ----" );
// Click initialization.
lr_cfg_setup( &cfg );
LR_MAP_MIKROBUS( cfg, MIKROBUS_1 );
lr_init( &lr, &cfg );
lr_default_cfg( &lr, 0, &lr_cbk );
log_printf( &logger, "mac pause\r\n" );
for ( cnt = 0; cnt < 10; cnt++ )
{
log_printf( &logger, "%c", tmp_txt[ cnt ] );
}
log_printf( &logger, "\r\n" );
log_printf( &logger, "radio set wdt 0\r\n" );
log_printf( &logger, "%s\r\n", &tmp_txt[ 0 ] );
}

Application Task

Transmitter mode - sends one by one byte sequence of the desired message each second and checks if it is sent successfully. Receiver mode - displays all the received characters on USB UART.

void application_task ( void )
{
char *ptr;
lr_process( );
#ifdef DEMO_APP_RECEIVER
rx_state = lr_rx( &lr, LR_ARG_0, &tmp_txt[ 0 ] );
if ( rx_state == 0 )
{
tmp_txt[ 12 ] = 0;
ptr = ( char* )&int_data;
hex_to_int( &tmp_txt[ 10 ], ptr );
log_printf( &logger, "%c", int_data );
}
#endif
#ifdef DEMO_APP_TRANSMITTER
for ( cnt = 0; cnt < 9; cnt++ )
{
int8_to_hex( send_data, send_hex );
tx_state = lr_tx( &lr, &send_hex[ 0 ] );
if ( tx_state == 0 )
{
log_printf( &logger, " Response : %s\r\n", &tmp_txt[ 0 ] );
}
Delay_ms( 1000 );
}
#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.LR

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.


lr_cfg_t
Click configuration structure definition.
Definition: lr.h:248
LR_CMD_SYS_GET_VER
#define LR_CMD_SYS_GET_VER
Definition: lr.h:137
int_data
int8_t int_data
Definition: main.c:48
hex_to_int
void hex_to_int(char *origin, uint8_t *result)
Definition: main.c:102
send_data
uint8_t send_data
Definition: main.c:47
lr_tx
uint8_t lr_tx(lr_t *ctx, char *buffer)
Main tnanceiver function.
LR_MAP_MIKROBUS
#define LR_MAP_MIKROBUS(cfg, mikrobus)
Definition: lr.h:53
application_task
void application_task(void)
Definition: main.c:180
lr_cmd
void lr_cmd(lr_t *ctx, char *cmd, char *response)
Send command function.
tmp_txt
char tmp_txt[50]
Definition: main.c:53
lr_init
LR_RETVAL lr_init(lr_t *ctx, lr_cfg_t *cfg)
Initialization function.
lr_cbk
void lr_cbk(char *response)
Definition: main.c:135
cnt
uint8_t cnt
Definition: main.c:46
send_hex
char send_hex[50]
Definition: main.c:52
lr_rx
uint8_t lr_rx(lr_t *ctx, char *window_size, char *response)
Main receiver function
LR_ARG_0
#define LR_ARG_0
Definition: lr.h:140
tx_state
uint8_t tx_state
Definition: main.c:50
lr_default_cfg
void lr_default_cfg(lr_t *ctx, bool cb_default, void(*response_p)(char *response))
Click Default Configuration function.
LR_CMD_RADIO_SET_WDT
#define LR_CMD_RADIO_SET_WDT
Definition: lr.h:139
application_init
void application_init(void)
Definition: main.c:142
send_message
uint8_t send_message[9]
Definition: main.c:54
rx_state
uint8_t rx_state
Definition: main.c:49
LR_CMD_MAC_PAUSE
#define LR_CMD_MAC_PAUSE
Definition: lr.h:138
lr_cfg_setup
void lr_cfg_setup(lr_cfg_t *cfg)
Config Object Initialization function.