LR 3 click
LR 3 Click is a compact add-on board that contains a long-range transceiver. This board features the 32001345, RF technology-based SRD transceiver, which operates at a frequency of 868MHz from Mipot.
click Product page
Click library
- Author : MikroE Team
- Date : jun 2020.
- Type : UART type
Software Support
We provide a library for the LR3 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 LR3 Click driver.
Standard key functions :
- Config Object Initialization function.
void lr3_cfg_setup ( lr3_cfg_t *cfg );
- Initialization function.
LR3_RETVAL lr3_init ( lr3_t *ctx, lr3_cfg_t *cfg );
Example key functions :
- Function performs the recovery of EEPROM default values.
LR3_RETVAL lr3_factory_reset ( lr3_t *ctx );
- Function writes data to EEPROM.
LR3_RETVAL lr3_write_eeprom ( lr3_t *ctx, uint8_t address, uint8_t n_bytes, uint8_t *data_in );
- Function performs the transmission of radio frames.
LR3_RETVAL lr3_tx_message ( lr3_t *ctx, lr3_tx_msg_t *tx_msg );
Examples Description
This example reads and processes data from LR 3 clicks.
The demo application is composed of two sections :
Application Init
Initializes the driver, enables the click board and configures it for the selected mode.
{
log_cfg_t log_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, "---- Application Init ----" );
Delay_ms ( 100 );
Delay_ms ( 1000 );
#ifdef MASTER
tmp_msg.payload[ 0 ] = 0;
{
log_error( &logger, "Setting device as MASTER!\r\n" );
for( ; ; );
}
log_printf( &logger, "Device configured as MASTER!\r\n" );
Delay_ms ( 1000 );
{
log_error( &logger, "Deleting all paired devices!\r\n" );
for( ; ; );
}
log_printf( &logger, "All paired devices deleted!\r\n" );
Delay_ms ( 1000 );
{
log_error( &logger, "Pairing not enabled!\r\n" );
for( ; ; );
}
log_printf( &logger, "Pairing enabled!\r\n" );
Delay_ms ( 1000 );
#endif
#ifdef END_NODE
tmp_msg.payload[ 0 ] = 1;
{
log_error( &logger, "Setting device as END_NODE!\r\n" );
for( ; ; );
}
log_printf( &logger, "Device configured as END_NODE!\r\n" );
Delay_ms ( 1000 );
uint8_t master_id[ 4 ] = { 0 };
do
{
Delay_ms ( 1000 );
}
log_printf( &logger, "Paired to a network!\r\n" );
log_printf( &logger, "Master ID: 0x%.2X%.2X%.2X%.2X\r\n", ( uint16_t ) master_id[ 3 ],
( uint16_t ) master_id[ 2 ],
( uint16_t ) master_id[ 1 ],
( uint16_t ) master_id[ 0 ] );
#endif
}
#define LR3_MAP_MIKROBUS(cfg, mikrobus)
Definition lr3.h:66
void lr3_set_ind_handler(lr3_t *ctx, lr3_ind_hdl_t hdl)
Set indication handler function.
void lr3_cfg_setup(lr3_cfg_t *cfg)
Config Object Initialization function.
LR3_RETVAL lr3_factory_reset(lr3_t *ctx)
Factory reset function.
LR3_RETVAL lr3_init(lr3_t *ctx, lr3_cfg_t *cfg)
Initialization function.
LR3_RETVAL lr3_write_eeprom(lr3_t *ctx, uint8_t address, uint8_t n_bytes, uint8_t *data_in)
EEPROM write function.
LR3_RETVAL lr3_get_pairing_request(lr3_t *ctx)
Get Pairing Request function.
LR3_RETVAL lr3_get_activation_status(lr3_t *ctx, uint8_t *data_out)
Get Activation Status function.
LR3_RETVAL lr3_enable_pairing(lr3_t *ctx, uint8_t state)
Enable Pairing function.
LR3_RETVAL lr3_delete_all_network_table(lr3_t *ctx)
Delete All Network Table function.
void lr3_hard_reset(lr3_t *ctx)
Hardware reset function.
void application_init(void)
Definition main.c:88
Click configuration structure definition.
Definition lr3.h:191
Application Task
Depending on the selected mode, it reads all the received data or sends a desired message every 3 seconds. All data is being displayed on the USB UART.
{
#ifdef END_NODE
lr3_tx_msg.data_in = &tmp_msg.payload[ 0 ];
{
log_printf( &logger,
"Message: \"%s\" sent to MASTER...\r\n", ( uint8_t * )
TEXT_TO_SEND );
log_printf( &logger, "------------------------\r\n" );
}
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
#endif
#ifdef MASTER
#endif
}
#define LR3_BROADCAST_MESSAGE
Definition lr3.h:133
#define LR3_UNCONFIRMED_DATA_TX
Definition lr3.h:130
uint8_t lr3_read_message_process(lr3_t *ctx)
Process function.
LR3_RETVAL lr3_tx_message(lr3_t *ctx, lr3_tx_msg_t *tx_msg)
Radio frame Transmission function.
void application_task(void)
Definition main.c:180
#define TEXT_TO_SEND
Definition main.c:35
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.LR3
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.