39#ifdef PREINIT_SUPPORTED
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
49#include "drv_digital_out.h"
50#include "drv_digital_in.h"
73#define LR2_CMD_SYS_GET_VER "sys get ver"
74#define LR2_CMD_MAC_PAUSE "mac pause"
75#define LR2_CMD_RADIO_SET_WDT "radio set wdt 0"
82#define LR2_JM_OTAA "otaa"
83#define LR2_JM_ABP "abp"
89#define LR2_PL_CNF "cnf "
90#define LR2_PL_UNCNF "uncnf "
96#define LR2_INVALID_PARAM 1
97#define LR2_NOT_JOINED 2
98#define LR2_NO_FREE_CH 3
100#define LR2_ERR_REJOIN_NEEDED 5
102#define LR2_MAC_PAUSED 7
103#define LR2_INVALID_PAR_DATA_LEN 8
104#define LR2_KEYS_NOT_INIT 9
105#define LR2_MAC_ERR 10
107#define LR2_INVALID_REPAR_DATA_LEN 13
108#define LR2_RADIO_ERR 14
115#define LR2_MAX_DATA_SIZE 256
116#define LR2_MAX_TRANSFER_SIZE 384
118#define LR2_MAX_CMD_SIZE 64
124#define LR2_MAX_RSP_SIZE 20
130#define LR2_RESP_COUNT 100
136#define LR2_TIMER_EXPIRED 50000
142#define LR2_MAC_TX "mac tx "
143#define LR2_JOIN "mac join "
144#define LR2_RADIO_TX "radio tx "
145#define LR2_RADIO_RX "radio rx "
152#define LR2_DRV_RX_BUFFER_SIZE 300
153#define LR2_DRV_TX_BUFFER_SIZE 100
171#define LR2_MAP_MIKROBUS( cfg, mikrobus ) \
172 cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
173 cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
174 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
175 cfg.rts = MIKROBUS( mikrobus, MIKROBUS_CS ); \
176 cfg.cts = MIKROBUS( mikrobus, MIKROBUS_INT )
227 void ( *callback_resp )(
char *response );
#define LR2_DRV_TX_BUFFER_SIZE
Definition lr2.h:153
#define LR2_DRV_RX_BUFFER_SIZE
LR 2 driver buffer size.
Definition lr2.h:152
#define LR2_MAX_TRANSFER_SIZE
Definition lr2.h:116
uint8_t lr2_join(lr2_t *ctx, char *join_mode, char *response)
Function for setting join mode.
int32_t lr2_generic_read(lr2_t *ctx, char *data_buf, uint16_t max_len)
LR 2 data reading function.
void lr2_generic_write(lr2_t *ctx, char *data_buf, uint16_t len)
LR 2 data writing function.
uint8_t lr2_rx(lr2_t *ctx, char *window_size, char *response)
Main receiver function
err_t lr2_init(lr2_t *ctx, lr2_cfg_t *cfg)
LR 2 initialization function.
void lr2_cfg_setup(lr2_cfg_t *cfg)
LR 2 configuration object setup function.
void lr2_tick_conf(lr2_t *ctx, uint32_t timer_limit)
Timer Configuration.
void lr2_put_char(lr2_t *ctx, char data_in)
Function for write char.
void lr2_default_cfg(lr2_t *ctx, bool cb_default, void(*response_p)(char *response))
LR 2 default configuration function.
void lr2_tick_isr(lr2_t *ctx)
Timer.
void lr2_isr_process(lr2_t *ctx)
Main Process.
uint8_t lr2_tx(lr2_t *ctx, char *buffer)
Main tnanceiver function.
void lr2_cmd(lr2_t *ctx, char *cmd, char *response)
Send command function.
void lr2_rx_isr(lr2_t *ctx, char rx_input)
Receiver.
uint8_t lr2_mac_tx(lr2_t *ctx, lr2_mac_t *mac)
Function for writing mac parameters.
lr2_return_value_t
LR 2 Click return value data.
Definition lr2.h:301
@ LR2_ERROR
Definition lr2.h:303
@ LR2_OK
Definition lr2.h:302
Click buffers object definition.
Definition lr2.h:186
uint16_t rx_buffer_len
Definition lr2.h:189
LR 2 Click configuration object.
Definition lr2.h:277
pin_name_t rts
Definition lr2.h:284
uint32_t baud_rate
Definition lr2.h:288
pin_name_t cts
Definition lr2.h:285
bool uart_blocking
Definition lr2.h:289
uart_data_bits_t data_bit
Definition lr2.h:290
pin_name_t tx_pin
Definition lr2.h:280
pin_name_t rx_pin
Definition lr2.h:279
uart_stop_bits_t stop_bit
Definition lr2.h:292
uart_parity_t parity_bit
Definition lr2.h:291
pin_name_t rst
Definition lr2.h:283
Mac object definition.
Definition lr2.h:236
char * response
Definition lr2.h:240
char * payload
Definition lr2.h:237
char * port_no
Definition lr2.h:238
char * buffer
Definition lr2.h:239
Process Flags object definition.
Definition lr2.h:212
bool rsp_rdy_f
Definition lr2.h:213
bool lr2_rdy_f
Definition lr2.h:214
Response object definition.
Definition lr2.h:223
bool callback_default
Definition lr2.h:226
bool rsp_f
Definition lr2.h:224
char * rsp_buffer
Definition lr2.h:225
LR 2 Click context object.
Definition lr2.h:249
char data_in
Definition lr2.h:268
lr2_procces_flags_t flags
Definition lr2.h:266
lr2_timer_t tm
Definition lr2.h:265
digital_out_t rts
Definition lr2.h:252
uart_t uart
Definition lr2.h:258
lr2_buffers_t buff
Definition lr2.h:264
digital_in_t cts
Definition lr2.h:255
digital_out_t rst
Definition lr2.h:251
lr2_response_t rsp
Definition lr2.h:267
Timer Flags and Counter object definition.
Definition lr2.h:198
bool timeout_f
Definition lr2.h:200
bool timer_f
Definition lr2.h:199
uint32_t ticker
Definition lr2.h:202
bool timer_use_f
Definition lr2.h:201
uint32_t timer_max
Definition lr2.h:203