42#ifdef PREINIT_SUPPORTED
46#ifdef MikroCCoreVersion
47 #if MikroCCoreVersion >= 1
52#include "drv_digital_out.h"
53#include "drv_digital_in.h"
66#define LR3_MAP_MIKROBUS( cfg, mikrobus ) \
67 cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
68 cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
69 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
70 cfg.wk = MIKROBUS( mikrobus, MIKROBUS_CS ); \
71 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
78#define LR3_RETVAL uint8_t
81#define LR3_INIT_ERROR 0xFF
88#define FRAME_HEADER 0xAA
89#define RESPONSE_BIT 0x80
96#define LR3_CMD_RESET 0x30
97#define LR3_CMD_FACTORY_RESET 0x31
98#define LR3_CMD_EEPROM_WRITE 0x32
99#define LR3_CMD_EEPROM_READ 0x33
100#define LR3_CMD_GET_FW_VERSION 0x34
101#define LR3_CMD_GET_SERIAL_NO 0x35
102#define LR3_ENABLE_PAIRING 0x40
103#define LR3_GET_NETWORK_TABLE_SIZE 0x42
104#define LR3_GET_NETWORK_TABLE_ROW 0x43
105#define LR3_DEL_NET_TABLE_ROW 0x44
106#define LR3_DEL_ALL_NETWORK_TABLE 0x45
107#define LR3_GET_PAIRING_REQUEST 0x48
108#define LR3_GET_ACTIVATION_STATUS 0x4A
109#define LR3_TX_MESSAGE 0x50
110#define LR3_CHECK_LINK_REQUEST 0x56
111#define LR3_SET_APP_KEY 0x58
113#define LR3_INDICATES_DEVICE_PAIRING 0x41
114#define LR3_INDICATES_PAIRING_CONFIRM 0x49
115#define LR3_INDICATES_TX_MSG_CONFIRMED 0x51
116#define LR3_INDICATES_TX_MSG_UNCONFIRMED 0x52
117#define LR3_INDICATES_RX_MSG 0x53
118#define LR3_INDICATES_LINK_CHECK 0x57
119#define LR3_INDICATES_TX_SESSION_ABORT 0x59
122#define LR3_ERR_ADDR_RANGE 0x01
123#define LR3_ERR_NOT_IDLE 0x02
125#define LR3_ERR_PL_LEN 0xFC
126#define LR3_ERR_CHKSUM 0xFD
127#define LR3_ERR_RESPONSE 0xFE
128#define LR3_ERR_HEADER 0xFF
130#define LR3_UNCONFIRMED_DATA_TX 0x00
131#define LR3_CONFIRMED_DATA_TX 0x01
133#define LR3_BROADCAST_MESSAGE 0xFFFFFFFF
140#define LR3_MODULE_POWER_ON 1
141#define LR3_MODULE_POWER_OFF 0
148#define DRV_RX_BUFFER_SIZE 500
161typedef void ( *
lr3_ind_hdl_t )( uint8_t *cmd, uint8_t* p_load_size, uint8_t *p_load );
217 uint8_t payload[ 255 ];
#define DRV_RX_BUFFER_SIZE
Definition lr3.h:148
#define LR3_RETVAL
Definition lr3.h:78
void lr3_generic_write(lr3_t *ctx, char *data_buf, uint16_t len)
Generic write function.
void lr3_set_ind_handler(lr3_t *ctx, lr3_ind_hdl_t hdl)
Set indication handler function.
void lr3_wake_up(lr3_t *ctx, uint8_t state)
Wake Up function.
uint8_t lr3_command(lr3_t *ctx, lr3_message_t *msg, lr3_message_t *rsp)
Command function.
LR3_RETVAL lr3_delete_network_table_row(lr3_t *ctx, uint8_t *device_id)
Delete Network Table Row function.
void lr3_cfg_setup(lr3_cfg_t *cfg)
Config Object Initialization function.
int32_t lr3_generic_read(lr3_t *ctx, char *data_buf, uint16_t max_len)
Generic read function.
LR3_RETVAL lr3_read_eeprom(lr3_t *ctx, uint8_t address, uint8_t n_bytes, uint8_t *data_out)
EEPROM read function.
uint8_t lr3_chk_sum(lr3_message_t *cmd)
Check sum function.
LR3_RETVAL lr3_get_serial_no(lr3_t *ctx, uint32_t *serial_no)
Get Serial Number 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_soft_reset(lr3_t *ctx)
Software reset function.
LR3_RETVAL lr3_get_pairing_request(lr3_t *ctx)
Get Pairing Request function.
LR3_RETVAL lr3_check_link_request(lr3_t *ctx, uint8_t power, uint8_t message_num, uint8_t message_th)
Radio frame Transmission function.
uint8_t lr3_read_message_process(lr3_t *ctx)
Process function.
LR3_RETVAL lr3_get_activation_status(lr3_t *ctx, uint8_t *data_out)
Get Activation Status function.
LR3_RETVAL lr3_get_fw_version(lr3_t *ctx, uint32_t *fw_version)
Get FW Version function.
LR3_RETVAL lr3_enable_pairing(lr3_t *ctx, uint8_t state)
Enable Pairing function.
LR3_RETVAL lr3_set_app_key(lr3_t *ctx, uint8_t *app_key)
Set App Key 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.
LR3_RETVAL lr3_tx_message(lr3_t *ctx, lr3_tx_msg_t *tx_msg)
Radio frame Transmission function.
LR3_RETVAL lr3_get_network_table_row(lr3_t *ctx, uint8_t index, uint8_t *data_out)
Get Network Table Row function.
LR3_RETVAL lr3_get_network_table_size(lr3_t *ctx)
Get Network Table Size function.
void(* lr3_ind_hdl_t)(uint8_t *cmd, uint8_t *p_load_size, uint8_t *p_load)
LR3_TYPES Types.
Definition lr3.h:161
Click configuration structure definition.
Definition lr3.h:191
uint32_t baud_rate
Definition lr3.h:205
pin_name_t wk
Definition lr3.h:200
bool uart_blocking
Definition lr3.h:206
uart_data_bits_t data_bit
Definition lr3.h:207
pin_name_t tx_pin
Definition lr3.h:195
pin_name_t rx_pin
Definition lr3.h:194
uart_stop_bits_t stop_bit
Definition lr3.h:209
pin_name_t int_pin
Definition lr3.h:201
uart_parity_t parity_bit
Definition lr3.h:208
pin_name_t rst
Definition lr3.h:199
uint8_t command
Definition lr3.h:215
uint8_t payload_size
Definition lr3.h:216
Click ctx object definition.
Definition lr3.h:167
uart_t uart
Definition lr3.h:179
digital_in_t int_pin
Definition lr3.h:175
digital_out_t wk
Definition lr3.h:171
digital_out_t rst
Definition lr3.h:170
lr3_ind_hdl_t ind_handler
Definition lr3.h:184
uint8_t option
Definition lr3.h:226
uint8_t n_bytes
Definition lr3.h:224
uint8_t * data_in
Definition lr3.h:223
uint32_t destination_id
Definition lr3.h:225