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 NANOBEACON_OPCODE_READY 0x01
74#define NANOBEACON_OPCODE_READY_ACK 0x80
75#define NANOBEACON_OPCODE_READY_NACK 0x81
76#define NANOBEACON_OPCODE_RATE 0x02
77#define NANOBEACON_OPCODE_READ_REG 0x03
78#define NANOBEACON_OPCODE_READ_REG_RESP 0x83
79#define NANOBEACON_OPCODE_WRITE_REG 0x04
80#define NANOBEACON_OPCODE_WRITE_REG_RESP 0x84
81#define NANOBEACON_OPCODE_READ_MEM 0x05
82#define NANOBEACON_OPCODE_READ_MEM_RESP 0x85
83#define NANOBEACON_OPCODE_WRITE_MEM 0x06
84#define NANOBEACON_OPCODE_WRITE_MEM_RESP 0x86
85#define NANOBEACON_OPCODE_READ_EFUSE 0x07
86#define NANOBEACON_OPCODE_READ_EFUSE_RESP 0x87
87#define NANOBEACON_OPCODE_WRITE_EFUSE 0x08
88#define NANOBEACON_OPCODE_WRITE_EFUSE_RESP 0x88
94#define NANOBEACON_PACKET_HEADER 0xAE
95#define NANOBEACON_PACKET_TAIL 0xEA
96#define NANOBEACON_PAYLOAD_READY 0xAA
97#define NANOBEACON_PACKET_PAYLOAD_SIZE 128
98#define NANOBEACON_TIMEOUT_MS 3000
99#define NANOBEACON_CHECK_COMM_NUM_TRIES 5
106#define NANOBEACON_TX_DRV_BUFFER_SIZE ( NANOBEACON_PACKET_PAYLOAD_SIZE + 4 )
107#define NANOBEACON_RX_DRV_BUFFER_SIZE ( NANOBEACON_PACKET_PAYLOAD_SIZE + 4 )
125#define NANOBEACON_MAP_MIKROBUS( cfg, mikrobus ) \
126 cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
127 cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
128 cfg.an = MIKROBUS( mikrobus, MIKROBUS_AN ); \
129 cfg.en = MIKROBUS( mikrobus, MIKROBUS_RST ); \
130 cfg.dq = MIKROBUS( mikrobus, MIKROBUS_PWM );
#define NANOBEACON_PACKET_PAYLOAD_SIZE
Definition nanobeacon.h:97
#define NANOBEACON_RX_DRV_BUFFER_SIZE
Definition nanobeacon.h:107
#define NANOBEACON_TX_DRV_BUFFER_SIZE
NanoBeacon driver buffer size.
Definition nanobeacon.h:106
uint8_t nanobeacon_get_an_pin(nanobeacon_t *ctx)
NanoBeacon get an pin function.
err_t nanobeacon_read_efuse(nanobeacon_t *ctx, uint8_t aid, uint16_t *data_out)
NanoBeacon read efuse function.
err_t nanobeacon_set_advertising(uint8_t *mac_address, uint16_t interval, uint8_t *adv_raw_data, uint8_t len)
NanoBeacon set advertising function.
err_t nanobeacon_write_efuse(nanobeacon_t *ctx, uint8_t aid, uint16_t data_in)
NanoBeacon write efuse function.
err_t nanobeacon_read_packet(nanobeacon_t *ctx, nanobeacon_packet_t *pkt_out)
NanoBeacon read packet function.
err_t nanobeacon_send_packet(nanobeacon_t *ctx, nanobeacon_packet_t pkt_in)
NanoBeacon send packet function.
err_t nanobeacon_start_advertising(nanobeacon_t *ctx)
NanoBeacon start advertising function.
err_t nanobeacon_generic_read(nanobeacon_t *ctx, uint8_t *data_out, uint16_t len)
NanoBeacon data reading function.
err_t nanobeacon_init(nanobeacon_t *ctx, nanobeacon_cfg_t *cfg)
NanoBeacon initialization function.
err_t nanobeacon_read_reg(nanobeacon_t *ctx, uint16_t address, uint32_t *data_out)
NanoBeacon read reg function.
void nanobeacon_set_en_pin(nanobeacon_t *ctx, uint8_t state)
NanoBeacon set EN pin function.
void nanobeacon_cfg_setup(nanobeacon_cfg_t *cfg)
NanoBeacon configuration object setup function.
void nanobeacon_restart_device(nanobeacon_t *ctx)
NanoBeacon restart device function.
err_t nanobeacon_generic_write(nanobeacon_t *ctx, uint8_t *data_in, uint16_t len)
NanoBeacon data writing function.
err_t nanobeacon_load_adv_to_ram(nanobeacon_t *ctx)
NanoBeacon load adv to ram function.
void nanobeacon_set_dq_pin(nanobeacon_t *ctx, uint8_t state)
NanoBeacon set DQ pin function.
err_t nanobeacon_write_mem(nanobeacon_t *ctx, uint16_t address, uint32_t data_in)
NanoBeacon write mem function.
err_t nanobeacon_write_reg(nanobeacon_t *ctx, uint16_t address, uint32_t data_in)
NanoBeacon write reg function.
err_t nanobeacon_read_mem(nanobeacon_t *ctx, uint16_t address, uint32_t *data_out)
NanoBeacon read mem function.
err_t nanobeacon_check_communication(nanobeacon_t *ctx)
NanoBeacon check communication function.
nanobeacon_return_value_t
NanoBeacon Click return value data.
Definition nanobeacon.h:198
@ NANOBEACON_OK
Definition nanobeacon.h:199
@ NANOBEACON_ERROR
Definition nanobeacon.h:200
NanoBeacon Click configuration object.
Definition nanobeacon.h:174
uint32_t baud_rate
Definition nanobeacon.h:185
bool uart_blocking
Definition nanobeacon.h:186
uart_data_bits_t data_bit
Definition nanobeacon.h:187
pin_name_t tx_pin
Definition nanobeacon.h:177
pin_name_t rx_pin
Definition nanobeacon.h:176
uart_stop_bits_t stop_bit
Definition nanobeacon.h:189
pin_name_t en
Definition nanobeacon.h:181
uart_parity_t parity_bit
Definition nanobeacon.h:188
pin_name_t dq
Definition nanobeacon.h:182
pin_name_t an
Definition nanobeacon.h:180
NanoBeacon Click packet object.
Definition nanobeacon.h:140
uint8_t opcode
Definition nanobeacon.h:141
uint8_t payload_len
Definition nanobeacon.h:142
NanoBeacon Click context object.
Definition nanobeacon.h:152
uart_t uart
Definition nanobeacon.h:161
digital_out_t dq
Definition nanobeacon.h:155
digital_in_t an
Definition nanobeacon.h:158
digital_out_t en
Definition nanobeacon.h:154