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 LR4_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 LR4_RETVAL uint8_t
81#define LR4_INIT_ERROR 0xFF
88#define LR4_FRAME_HEADER 0xAA
89#define LR4_RESPONSE_BIT 0x80
96#define LR4_CMD_RESET 0x30
97#define LR4_CMD_FACTORY_RESET 0x31
98#define LR4_CMD_EEPROM_WRITE 0x32
99#define LR4_CMD_EEPROM_READ 0x33
100#define LR4_CMD_GET_FW_VERSION 0x34
101#define LR4_CMD_GET_SERIAL_NO 0x35
102#define LR4_CMD_GET_DEV_EUI 0x36
103#define LR4_CMD_JOIN 0x40
104#define LR4_CMD_GET_ACTIVATION_STATUS 0x42
105#define LR4_CMD_SET_APP_KEY 0x43
106#define LR4_CMD_SET_APP_SESSION_KEY 0x44
107#define LR4_CMD_SET_NWK_SESSION_KEY 0x45
108#define LR4_CMD_TX_MSG 0x46
109#define LR4_CMD_GET_SESSION_STATUS 0x4A
110#define LR4_CMD_SET_NEXT_DR 0x4B
111#define LR4_CMD_SET_BATTERY_LVL 0x50
112#define LR4_CMD_GET_BATTERY_LVL 0x51
113#define LR4_CMD_SET_UPLINK_CNT 0x52
114#define LR4_CMD_GET_UPLINK_CNT 0x53
115#define LR4_CMD_SET_DOWNLINK_CNT 0x54
116#define LR4_CMD_GET_DOWNLINK_CNT 0x55
117#define LR4_CMD_SET_CH_PARAMETERS 0x57
118#define LR4_CMD_GET_CH_PARAMETERS 0x58
120#define LR4_INDICATES_JOIN 0x41
121#define LR4_INDICATES_TX_MSG_CONFIRMED 0x47
122#define LR4_INDICATES_TX_MSG_UNCONFIRMED 0x48
123#define LR4_INDICATES_RX_MSG 0x49
126#define LR4_ERR_ADDR_RANGE 0x01
127#define LR4_ERR_NOT_IDLE 0x02
129#define LR4_ERR_PL_LEN 0xFC
130#define LR4_ERR_CHKSUM 0xFD
131#define LR4_ERR_RESPONSE 0xFE
132#define LR4_ERR_HEADER 0xFF
135#define LR4_JOIN_ACTIVATION_BY_PERSONALIZATION_MODE 0x00
136#define LR4_JOIN_OVER_THE_AIR_ACTIVATION_MODE 0x01
137#define LR4_GET_ACTIVATION_MODE 0x00
138#define LR4_GET_SESSION_STATUS_MODE 0x01
139#define LR4_SET_APP_KEY_MODE 0x00
140#define LR4_SET_NWK_SESSION_KEY_MODE 0x01
141#define LR4_UPLINK_CNT 0x00
142#define LR4_DOWNLINK_CNT 0x01
143#define LR4_CHANNEL_DISABLED 0x00
144#define LR4_CHANNEL_ENABLED 0x01
145#define LR4_UNCONFIRMED_TRANSMISSION 0x00
146#define LR4_CONFIRMED_TRANSMISSION 0x01
149#define LR4_STATUS_IDLE 0x00
150#define LR4_STATUS_BUSY 0x01
151#define LR4_STATUS_DEV_NOT_ACTIVATED 0x02
152#define LR4_STATUS_DELAYED 0x03
154#define LR4_STATUS_NOT_ACTIVATED 0x00
155#define LR4_STATUS_JOINING 0x01
156#define LR4_STATUS_JOINED 0x02
157#define LR4_STATUS_MAC_ERROR 0x03
164#define LR4_MODULE_POWER_ON 1
165#define LR4_MODULE_POWER_OFF 0
172#define DRV_RX_BUFFER_SIZE 500
185typedef void ( *
lr4_ind_hdl_t )( uint8_t *cmd, uint8_t* p_load_size, uint8_t *p_load );
241 uint8_t payload[ 255 ];
#define DRV_RX_BUFFER_SIZE
Definition lr4.h:172
#define LR4_RETVAL
Definition lr4.h:78
LR4_RETVAL lr4_write_eeprom(lr4_t *ctx, uint8_t address, uint8_t n_bytes, uint8_t *data_in)
EEPROM write function.
LR4_RETVAL lr4_get_counter(lr4_t *ctx, uint32_t *cnt, uint8_t cnt_mode)
Get Counter function.
void lr4_generic_write(lr4_t *ctx, char *data_buf, uint16_t len)
Generic write function.
LR4_RETVAL lr4_get_serial_no(lr4_t *ctx, uint32_t *serial_no)
Get Serial Number function.
LR4_RETVAL lr4_get_status(lr4_t *ctx, uint8_t status_mode)
Get Status function.
void lr4_set_ind_handler(lr4_t *ctx, lr4_ind_hdl_t hdl)
Set indication handler function.
LR4_RETVAL lr4_get_dev_eui(lr4_t *ctx, uint8_t *dev_eui)
Get DevEUI function.
LR4_RETVAL lr4_set_next_tx_data_rate(lr4_t *ctx, uint8_t data_rate)
Set Next Data Rate function.
LR4_RETVAL lr4_tx_message(lr4_t *ctx, lr4_tx_msg_t *tx_msg)
Radio frame Transmission function.
LR4_RETVAL lr4_get_fw_version(lr4_t *ctx, uint32_t *fw_version)
Get FW Version function.
LR4_RETVAL lr4_set_channel(lr4_t *ctx, uint8_t index, uint32_t freq, uint8_t data_rate_range, uint8_t status)
Set Channel function.
LR4_RETVAL lr4_soft_reset(lr4_t *ctx)
Software reset function.
LR4_RETVAL lr4_set_battery_level(lr4_t *ctx, uint8_t battery_level)
Set Battery Level function.
void lr4_cfg_setup(lr4_cfg_t *cfg)
Config Object Initialization function.
LR4_RETVAL lr4_init(lr4_t *ctx, lr4_cfg_t *cfg)
Initialization function.
LR4_RETVAL lr4_factory_reset(lr4_t *ctx)
Factory reset function.
LR4_RETVAL lr4_join_network(lr4_t *ctx, uint8_t mode)
Join Network function.
LR4_RETVAL lr4_set_key(lr4_t *ctx, uint8_t *key_data, uint8_t key_mode)
Set Key function.
LR4_RETVAL lr4_read_eeprom(lr4_t *ctx, uint8_t address, uint8_t n_bytes, uint8_t *data_out)
EEPROM read function.
uint8_t lr4_command(lr4_t *ctx, lr4_message_t *msg, lr4_message_t *rsp)
Command function.
LR4_RETVAL lr4_set_counter(lr4_t *ctx, uint32_t cnt, uint8_t cnt_mode)
Set Counter function.
uint8_t lr4_chk_sum(lr4_message_t *cmd)
Check sum function.
int32_t lr4_generic_read(lr4_t *ctx, char *data_buf, uint16_t max_len)
Generic read function.
uint8_t lr4_read_message_process(lr4_t *ctx)
Process function.
void lr4_hard_reset(lr4_t *ctx)
Hardware reset function.
void lr4_wake_up(lr4_t *ctx, uint8_t state)
Wake Up function.
LR4_RETVAL lr4_get_battery_level(lr4_t *ctx)
Get Battery Level function.
void(* lr4_ind_hdl_t)(uint8_t *cmd, uint8_t *p_load_size, uint8_t *p_load)
LR4_TYPES Types.
Definition lr4.h:185
Click configuration structure definition.
Definition lr4.h:215
uint32_t baud_rate
Definition lr4.h:229
pin_name_t wk
Definition lr4.h:224
bool uart_blocking
Definition lr4.h:230
uart_data_bits_t data_bit
Definition lr4.h:231
pin_name_t tx_pin
Definition lr4.h:219
pin_name_t rx_pin
Definition lr4.h:218
uart_stop_bits_t stop_bit
Definition lr4.h:233
pin_name_t int_pin
Definition lr4.h:225
uart_parity_t parity_bit
Definition lr4.h:232
pin_name_t rst
Definition lr4.h:223
uint8_t command
Definition lr4.h:239
uint8_t payload_size
Definition lr4.h:240
Click ctx object definition.
Definition lr4.h:191
lr4_ind_hdl_t ind_handler
Definition lr4.h:208
uart_t uart
Definition lr4.h:203
digital_in_t int_pin
Definition lr4.h:199
digital_out_t wk
Definition lr4.h:195
digital_out_t rst
Definition lr4.h:194
uint8_t option
Definition lr4.h:250
uint8_t port
Definition lr4.h:249
uint8_t n_bytes
Definition lr4.h:248
uint8_t * data_in
Definition lr4.h:247