39#ifdef PREINIT_SUPPORTED
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
49#include "drv_digital_out.h"
50#include "drv_digital_in.h"
51#include "drv_i2c_master.h"
52#include "drv_spi_master.h"
76#define LBANDRTK_CLASS_ID_UBX_ACK 0x05
77#define LBANDRTK_CLASS_ID_UBX_CFG 0x06
78#define LBANDRTK_CLASS_ID_UBX_INF 0x04
79#define LBANDRTK_CLASS_ID_UBX_MON 0x0A
80#define LBANDRTK_CLASS_ID_UBX_RXM 0x02
81#define LBANDRTK_MSG_ID_UBX_ACK_ACK 0x01
82#define LBANDRTK_MSG_ID_UBX_ACK_NAK 0x00
83#define LBANDRTK_MSG_ID_UBX_CFG_RST 0x04
84#define LBANDRTK_MSG_ID_UBX_CFG_VALDEL 0x8C
85#define LBANDRTK_MSG_ID_UBX_CFG_VALGET 0x8B
86#define LBANDRTK_MSG_ID_UBX_CFG_VALSET 0x8A
87#define LBANDRTK_MSG_ID_UBX_INF_ERROR 0x00
88#define LBANDRTK_MSG_ID_UBX_INF_NOTICE 0x02
89#define LBANDRTK_MSG_ID_UBX_INF_WARNING 0x01
90#define LBANDRTK_MSG_ID_UBX_MON_HW2 0x0B
91#define LBANDRTK_MSG_ID_UBX_MON_VER 0x04
92#define LBANDRTK_MSG_ID_UBX_RXM_PMP 0x72
93#define LBANDRTK_MSG_ID_UBX_RXM_PMREQ 0x41
99#define LBANDRTK_VER_CFG_POLL_REQUEST 0x00
100#define LBANDRTK_VER_CFG_POLLED 0x01
101#define LBANDRTK_LAYER_RAM 0x01
102#define LBANDRTK_LAYER_BBR 0x02
103#define LBANDRTK_LAYER_FLASH 0x04
104#define LBANDRTK_LAYER_ALL 0x07
105#define LBANDRTK_KEY_ID_SIZE_1_BIT 0x10000000ul
106#define LBANDRTK_KEY_ID_SIZE_1_BYTE 0x20000000ul
107#define LBANDRTK_KEY_ID_SIZE_2_BYTES 0x30000000ul
108#define LBANDRTK_KEY_ID_SIZE_4_BYTES 0x40000000ul
109#define LBANDRTK_KEY_ID_SIZE_8_BYTES 0x50000000ul
110#define LBANDRTK_KEY_ID_SIZE_MASK 0x70000000ul
111#define LBANDRTK_KEY_ID_GROUP_MASK 0x00FF0000ul
112#define LBANDRTK_KEY_ID_ITEM_MASK 0x00000FFFul
113#define LBANDRTK_CFG_PMP_CENTER_FREQUENCY 0x40B10011ul
114#define LBANDRTK_CFG_PMP_SEARCH_WINDOW 0x30B10012ul
115#define LBANDRTK_CFG_PMP_USE_SERVICE_ID 0x10B10016ul
116#define LBANDRTK_CFG_PMP_SERVICE_ID 0x30B10017ul
117#define LBANDRTK_CFG_PMP_DATA_RATE 0x30B10013ul
118#define LBANDRTK_CFG_PMP_USE_DESCRAMBLER 0x10B10014ul
119#define LBANDRTK_CFG_PMP_DESCRAMBLER_INIT 0x30B10015ul
120#define LBANDRTK_CFG_PMP_USE_PRESCRAMBLING 0x10B10019ul
121#define LBANDRTK_CFG_PMP_UNIQUE_WORD 0x50B1001Aul
127#define LBANDRTK_PREAMBLE_SYNC_CHAR_1 0xB5
128#define LBANDRTK_PREAMBLE_SYNC_CHAR_2 0x62
134#define LBANDRTK_MAX_PAYLOAD_LEN 528u
140#define LBANDRTK_DUMMY 0xFF
146#define LBANDRTK_TIMEOUT 3000u
147#define LBANDRTK_NUM_OF_RETRIES 5
153#define LBANDRTK_PMP_CENTER_FREQ_EU 1545260000ul
154#define LBANDRTK_PMP_CENTER_FREQ_US 1556290000ul
155#define LBANDRTK_PMP_CENTER_FREQ LBANDRTK_PMP_CENTER_FREQ_EU
156#define LBANDRTK_PMP_SEARCH_WINDOW 2200u
157#define LBANDRTK_PMP_USE_SERVICE_ID 0
158#define LBANDRTK_PMP_SERVICE_ID 21845u
159#define LBANDRTK_PMP_DATA_RATE 2400u
160#define LBANDRTK_PMP_USE_DESCRAMBLER 1
161#define LBANDRTK_PMP_DESCRAMBLER_INIT 26969u
162#define LBANDRTK_PMP_USE_PRESCRAMBLING 0
163#define LBANDRTK_PMP_UNIQUE_WORD_HIGH 0xE15AE893ul
164#define LBANDRTK_PMP_UNIQUE_WORD_LOW 0xE15AE893ul
170#define LBANDRTK_UBX_RXM_PMP_MAX_USER_DATA 504u
171#define LBANDRTK_UBX_RXM_PMP_EBN0_SCALE 0.125f
178#define LBANDRTK_SET_DEV_ADDR 0x43
185#define LBANDRTK_DRV_TX_BUFFER_SIZE ( LBANDRTK_MAX_PAYLOAD_LEN + 8 )
186#define LBANDRTK_DRV_RX_BUFFER_SIZE ( LBANDRTK_MAX_PAYLOAD_LEN + 8 )
196#define LBANDRTK_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
197#define LBANDRTK_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
215#define LBANDRTK_MAP_MIKROBUS( cfg, mikrobus ) \
216 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
217 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
218 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
219 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
220 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
221 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
222 cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
223 cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
224 cfg.ein = MIKROBUS( mikrobus, MIKROBUS_AN ); \
225 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_PWM );
#define LBANDRTK_MAX_PAYLOAD_LEN
LBAND RTK UBX max payload size.
Definition lbandrtk.h:134
#define LBANDRTK_DRV_RX_BUFFER_SIZE
Definition lbandrtk.h:186
#define LBANDRTK_DRV_TX_BUFFER_SIZE
LBAND RTK driver buffer size.
Definition lbandrtk.h:185
void lbandrtk_reset_device(lbandrtk_t *ctx)
LBAND RTK reset device function.
err_t lbandrtk_init(lbandrtk_t *ctx, lbandrtk_cfg_t *cfg)
LBAND RTK initialization function.
err_t lbandrtk_set_val_8(lbandrtk_t *ctx, uint32_t key_id, uint8_t layer, uint8_t value)
LBAND RTK set val 8 function.
void lbandrtk_set_rst_pin(lbandrtk_t *ctx, uint8_t state)
LBAND RTK set rst pin function.
err_t lbandrtk_generic_write(lbandrtk_t *ctx, uint8_t *data_in, uint16_t len)
LBAND RTK data writing function.
err_t lbandrtk_set_default_pmp_cfg(lbandrtk_t *ctx)
LBAND RTK set default pmp cfg function.
err_t lbandrtk_set_val_64(lbandrtk_t *ctx, uint32_t key_id, uint8_t layer, uint32_t value_high, uint32_t value_low)
LBAND RTK set val 64 function.
err_t lbandrtk_get_pmp_cfg(lbandrtk_t *ctx, lbandrtk_pmp_cfg_t *pmp_cfg)
LBAND RTK get pmp cfg function.
void lbandrtk_cfg_setup(lbandrtk_cfg_t *cfg)
LBAND RTK configuration object setup function.
err_t lbandrtk_generic_read(lbandrtk_t *ctx, uint8_t *data_out, uint16_t len)
LBAND RTK data reading function.
err_t lbandrtk_get_val_32(lbandrtk_t *ctx, uint32_t key_id, uint8_t layer, uint32_t *value)
LBAND RTK get val 32 function.
err_t lbandrtk_get_val_8(lbandrtk_t *ctx, uint32_t key_id, uint8_t layer, uint8_t *value)
LBAND RTK get val 8 function.
void lbandrtk_drv_interface_selection(lbandrtk_cfg_t *cfg, lbandrtk_drv_t drv_sel)
LBAND RTK driver interface setup function.
err_t lbandrtk_get_val_16(lbandrtk_t *ctx, uint32_t key_id, uint8_t layer, uint16_t *value)
LBAND RTK get val 16 function.
err_t lbandrtk_set_val_32(lbandrtk_t *ctx, uint32_t key_id, uint8_t layer, uint32_t value)
LBAND RTK set val 32 function.
err_t lbandrtk_check_ack(lbandrtk_t *ctx, uint8_t class_id, uint8_t msg_id)
LBAND RTK check ack function.
err_t lbandrtk_set_pmp_cfg(lbandrtk_t *ctx, lbandrtk_pmp_cfg_t pmp_cfg)
LBAND RTK set pmp cfg function.
err_t lbandrtk_get_val_64(lbandrtk_t *ctx, uint32_t key_id, uint8_t layer, uint32_t *value_high, uint32_t *value_low)
LBAND RTK get val 64 function.
err_t lbandrtk_write_ubx_frame(lbandrtk_t *ctx, lbandrtk_ubx_frame_t *frame)
LBAND RTK write ubx frame function.
err_t lbandrtk_set_val_16(lbandrtk_t *ctx, uint32_t key_id, uint8_t layer, uint16_t value)
LBAND RTK set val 16 function.
void lbandrtk_set_ein_pin(lbandrtk_t *ctx, uint8_t state)
LBAND RTK set ein pin function.
err_t lbandrtk_read_ubx_frame(lbandrtk_t *ctx, lbandrtk_ubx_frame_t *frame)
LBAND RTK read ubx frame function.
err_t(* lbandrtk_master_io_t)(struct lbandrtk_s *, uint8_t *, uint16_t)
LBAND RTK Click driver interface.
Definition lbandrtk.h:246
lbandrtk_drv_t
LBAND RTK Click driver selector.
Definition lbandrtk.h:235
@ LBANDRTK_DRV_SEL_UART
Definition lbandrtk.h:236
@ LBANDRTK_DRV_SEL_I2C
Definition lbandrtk.h:238
@ LBANDRTK_DRV_SEL_SPI
Definition lbandrtk.h:237
lbandrtk_return_value_t
LBAND RTK Click return value data.
Definition lbandrtk.h:355
@ LBANDRTK_ERROR
Definition lbandrtk.h:357
@ LBANDRTK_OK
Definition lbandrtk.h:356
struct lbandrtk_s lbandrtk_t
LBAND RTK Click context object.
This file contains SPI specific macros, functions, etc.
LBAND RTK Click configuration object.
Definition lbandrtk.h:320
uint32_t baud_rate
Definition lbandrtk.h:340
pin_name_t ein
Definition lbandrtk.h:331
lbandrtk_drv_t drv_sel
Definition lbandrtk.h:346
uint32_t i2c_speed
Definition lbandrtk.h:333
spi_master_chip_select_polarity_t cs_polarity
Definition lbandrtk.h:338
bool uart_blocking
Definition lbandrtk.h:341
pin_name_t sck
Definition lbandrtk.h:325
uart_data_bits_t data_bit
Definition lbandrtk.h:342
spi_master_mode_t spi_mode
Definition lbandrtk.h:337
pin_name_t tx_pin
Definition lbandrtk.h:328
pin_name_t mosi
Definition lbandrtk.h:324
uint32_t spi_speed
Definition lbandrtk.h:336
pin_name_t rx_pin
Definition lbandrtk.h:327
uart_stop_bits_t stop_bit
Definition lbandrtk.h:344
pin_name_t scl
Definition lbandrtk.h:321
pin_name_t miso
Definition lbandrtk.h:323
uart_parity_t parity_bit
Definition lbandrtk.h:343
pin_name_t sda
Definition lbandrtk.h:322
pin_name_t rst
Definition lbandrtk.h:330
pin_name_t cs
Definition lbandrtk.h:326
uint8_t i2c_address
Definition lbandrtk.h:334
LBAND RTK Click CFG-PMP: Point to multipoint (PMP) configuration object.
Definition lbandrtk.h:273
uint8_t use_prescrambling
Definition lbandrtk.h:282
uint32_t unique_word_low
Definition lbandrtk.h:284
uint8_t use_service_id
Definition lbandrtk.h:277
uint8_t use_descrambler
Definition lbandrtk.h:280
uint16_t descrambler_init
Definition lbandrtk.h:281
uint16_t search_window
Definition lbandrtk.h:275
uint16_t service_id
Definition lbandrtk.h:278
uint32_t center_freq
Definition lbandrtk.h:274
uint16_t data_rate
Definition lbandrtk.h:279
uint32_t unique_word_high
Definition lbandrtk.h:283
LBAND RTK Click context object.
Definition lbandrtk.h:293
spi_master_t spi
Definition lbandrtk.h:298
lbandrtk_master_io_t write_f
Definition lbandrtk.h:309
lbandrtk_drv_t drv_sel
Definition lbandrtk.h:307
char uart_tx_buffer[LBANDRTK_DRV_TX_BUFFER_SIZE]
Definition lbandrtk.h:303
uart_t uart
Definition lbandrtk.h:299
i2c_master_t i2c
Definition lbandrtk.h:297
lbandrtk_master_io_t read_f
Definition lbandrtk.h:310
digital_out_t ein
Definition lbandrtk.h:295
lbandrtk_ubx_frame_t frame
Definition lbandrtk.h:311
char uart_rx_buffer[LBANDRTK_DRV_RX_BUFFER_SIZE]
Definition lbandrtk.h:302
digital_out_t rst
Definition lbandrtk.h:294
uint8_t slave_address
Definition lbandrtk.h:305
pin_name_t chip_select
Definition lbandrtk.h:306
LBAND RTK Click UBX frame union object.
Definition lbandrtk.h:253
uint16_t header
Definition lbandrtk.h:257
uint16_t payload_len
Definition lbandrtk.h:261
uint8_t msg_id
Definition lbandrtk.h:260
uint8_t class_id
Definition lbandrtk.h:259