LR 2 click
LR 2 Click is a compact add-on board that contains a low-power, long-range transceiver. This board features the RN2903, RF technology-based SRD transceiver, which operates at a frequency of 915MHz from Microchip Technology. This Click boardâ„¢ features an embedded LoRaWAN Class A compliant stack, providing a long-range spread spectrum communication with high interference immunity. The RN2903 module is fully compliant with the United States (FCC) and Canada (IC) regulations combined with the advanced and straightforward command interface allowing easy integration into the final application.
click Product page
Click library
- Author : Stefan Ilic
- Date : Jun 2021.
- Type : UART type
Software Support
We provide a library for the LR2 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 LR2 Click driver.
Standard key functions :
lr2_cfg_setup
Config Object Initialization function.
void lr2_cfg_setup(lr2_cfg_t *cfg)
LR 2 configuration object setup function.
LR 2 Click configuration object.
Definition lr2.h:277
lr2_init
Initialization function.
err_t lr2_init(lr2_t *ctx, lr2_cfg_t *cfg)
LR 2 initialization function.
LR 2 Click context object.
Definition lr2.h:249
lr2_default_cfg
Click Default Configuration function.
void lr2_default_cfg(lr2_t *ctx, bool cb_default, void(*response_p)(char *response))
LR 2 default configuration function.
Example key functions :
lr2_mac_tx
Function for writing mac parameters
uint8_t lr2_mac_tx(lr2_t *ctx, lr2_mac_t *mac)
Function for writing mac parameters.
Mac object definition.
Definition lr2.h:236
lr2_join
Function for setting join mode uint8_t
lr2_join (
lr2_t *ctx,
char *join_mode,
char *response );
uint8_t lr2_join(lr2_t *ctx, char *join_mode, char *response)
Function for setting join mode.
lr2_tick_conf
Timer Configuration
void lr2_tick_conf(lr2_t *ctx, uint32_t timer_limit)
Timer Configuration.
Example Description
This example shows the usage of the LR 2 Click board by transmitting and receiving data.
The demo application is composed of two sections :
Application Init
Initializes the driver and performs default configuration and reads System version.
{
log_cfg_t log_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
if ( UART_ERROR ==
lr2_init( &lr2, &lr2_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
lr2_process( );
log_printf( &logger,
" System VER: %s \r\n",
resp_buf );
log_printf( &logger,
" MAC PAUSE: %s \r\n",
resp_buf );
log_printf( &logger,
" RADIO SET WDT 0: %s \r\n",
resp_buf );
#ifdef DEMO_APP_TRANSMITTER
log_printf( &logger, " Application Mode: Transmitter\r\n" );
#else
log_printf( &logger, " Application Mode: Receiver\r\n" );
#endif
log_info( &logger, " Application Task " );
}
#define LR2_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition lr2.h:171
#define LR2_CMD_RADIO_SET_WDT
Definition lr2.h:75
#define LR2_CMD_SYS_GET_VER
LR 2 Click Commands.
Definition lr2.h:73
#define LR2_CMD_MAC_PAUSE
Definition lr2.h:74
void lr2_cmd(lr2_t *ctx, char *cmd, char *response)
Send command function.
void application_init(void)
Definition main.c:48
uint8_t resp_buf[50]
Definition main.c:37
Application Task
Transmitter mode - sends a desired message each second and checks if it is sent successfully.
Receiver mode - displays all the received characters on USB UART.
{
lr2_process( );
#ifdef DEMO_APP_TRANSMITTER
uint8_t hex_buf[ 50 ] = { 0 };
uint8_t cnt = 0;
{
}
{
log_printf( &logger,
" Response : %s\r\n",
resp_buf );
}
Delay_ms ( 1000 );
#else
{
uint8_t text_buf[ 20 ] = { 0 };
uint8_t hex_buf[ 3 ] = { 0 };
uint8_t cnt = 0;
for ( cnt = 0; cnt < ( strlen(
resp_buf ) - 10 ); cnt += 2 )
{
text_buf[ cnt / 2 ] = hex_to_uint8( hex_buf );
}
log_printf( &logger, "Received message: %s\r\n", text_buf );
}
#endif
}
#define LR2_ARG_0
Definition lr2.h:76
uint8_t lr2_rx(lr2_t *ctx, char *window_size, char *response)
Main receiver function
uint8_t lr2_tx(lr2_t *ctx, char *buffer)
Main tnanceiver function.
@ LR2_OK
Definition lr2.h:302
uint8_t send_message[9]
Definition main.c:38
void application_task(void)
Definition main.c:95
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.LR2
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.