42#ifdef PREINIT_SUPPORTED
46#ifdef MikroCCoreVersion
47 #if MikroCCoreVersion >= 1
52#include "drv_digital_out.h"
53#include "drv_digital_in.h"
67#define MBUSRF4_MAP_MIKROBUS( cfg, mikrobus ) \
68 cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
69 cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
70 cfg.ind = MIKROBUS( mikrobus, MIKROBUS_AN ); \
71 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
72 cfg.sel = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
73 cfg.rts = MIKROBUS( mikrobus, MIKROBUS_INT )
80#define MBUSRF4_RETVAL uint8_t
82#define MBUSRF4_OK 0x00
83#define MBUSRF4_INIT_ERROR 0xFF
90#define MBUSRF4_ERROR_COMMAND_OR_ELEMENT 0xFF
91#define MBUSRF4_ERROR_START_OR_END_COMMAND 0x8F
92#define MBUSRF4_ERROR_NEXT_ELEMENT 0x4F
93#define MBUSRF4_ERROR_CURRENT_ELEMENT 0x2F
94#define MBUSRF4_NO_ERROR 0x00
101#define DRV_RX_BUFFER_SIZE 256
108#define MBUSRF4_CMD_RESET 0x30
109#define MBUSRF4_CMD_FACTORY_RESET 0x31
110#define MBUSRF4_CMD_SET_MODE 0x32
111#define MBUSRF4_CMD_EEPROM_WRITE 0x33
112#define MBUSRF4_CMD_EEPROM_READ 0x34
113#define MBUSRF4_CMD_TX_MSG 0x35
114#define MBUSRF4_CMD_RX_MSG_IND 0x36
115#define MBUSRF4_CMD_GET_FW_VERSION 0x37
116#define MBUSRF4_CMD_GET_SERIALNO 0x38
117#define MBUSRF4_CMD_GET_RSSI 0x39
118#define MBUSRF4_CMD_SET_C_FIELD 0x40
125#define MBUSRF4_EEADDR_WM_BUS_MODE 0x00
126#define MBUSRF4_EEADDR_RF_CHANNEL 0x01
127#define MBUSRF4_EEADDR_RF_POWER 0x02
128#define MBUSRF4_EEADDR_RF_AUTOSLEEP 0x03
129#define MBUSRF4_EEADDR_RX_WINDOW 0x04
131#define MBUSRF4_EEADDR_WMBUS_C_FIELD 0x10
132#define MBUSRF4_EEADDR_WMBUS_MANUFACTER_ID0 0x11
133#define MBUSRF4_EEADDR_WMBUS_MANUFACTER_ID1 0x12
134#define MBUSRF4_EEADDR_WMBUS_DEVICE_ID0 0x13
135#define MBUSRF4_EEADDR_WMBUS_DEVICE_ID1 0x14
136#define MBUSRF4_EEADDR_WMBUS_DEVICE_ID2 0x15
137#define MBUSRF4_EEADDR_WMBUS_DEVICE_ID3 0x16
138#define MBUSRF4_EEADDR_WMBUS_VERSION 0x17
139#define MBUSRF4_EEADDR_WMBUS_DEVICE_TYPE 0x18
141#define MBUSRF4_EEADDR_WMBUS_BLOCK1_FROM_MODULE_ENABLE 0x20
142#define MBUSRF4_EEADDR_WMBUS_RSSI_ENABLE 0x21
143#define MBUSRF4_EEADDR_WMBUS_INDICATE_TIMEOUT_LSB 0x22
144#define MBUSRF4_EEADDR_WMBUS_INDICATE_TIMEOUT_MSB 0x23
145#define MBUSRF4_EEADDR_WMBUS_UART_BAUDREATE 0x24
152#define MBUSRF4_EEPARAM_WMBUS_MODE_S2_SHORT_PREAMBLE 0x00
153#define MBUSRF4_EEPARAM_WMBUS_MODE_S2_LONG_PREAMBLE 0x01
154#define MBUSRF4_EEPARAM_WMBUS_MODE_S1 0x02
155#define MBUSRF4_EEPARAM_WMBUS_MODE_S1_M 0x03
156#define MBUSRF4_EEPARAM_WMBUS_MODE_T1_METER 0x04
157#define MBUSRF4_EEPARAM_WMBUS_MODE_T2_METER 0x05
158#define MBUSRF4_EEPARAM_WMBUS_MODE_T2_OTHER 0x06
159#define MBUSRF4_EEPARAM_WMBUS_MODE_R2_METER 0x07
160#define MBUSRF4_EEPARAM_WMBUS_MODE_R2_OTHER 0x08
161#define MBUSRF4_EEPARAM_WMBUS_MODE_C1_METER_FRAME_A 0x09
162#define MBUSRF4_EEPARAM_WMBUS_MODE_C1_METER_FRAME_B 0x0A
163#define MBUSRF4_EEPARAM_WMBUS_MODE_C2_METER_FRAME_A 0x0B
164#define MBUSRF4_EEPARAM_WMBUS_MODE_C2_METER_FRAME_B 0x0C
165#define MBUSRF4_EEPARAM_WMBUS_MODE_C2_OTHER_FRAME_A 0x0D
166#define MBUSRF4_EEPARAM_WMBUS_MODE_C2_OTHER_FRAME_B 0x0E
167#define MBUSRF4_EEPARAM_WMBUS_MODE_T2_C2_OTHER 0x0F
174#define MBUSRF4_EEPARAM_RFGH_868p03MHz 0x00
175#define MBUSRF4_EEPARAM_RFGH_868p09MHz 0x01
176#define MBUSRF4_EEPARAM_RFGH_868p15MHz 0x02
177#define MBUSRF4_EEPARAM_RFGH_868p21MHz 0x03
178#define MBUSRF4_EEPARAM_RFGH_868p27MHz 0x04
179#define MBUSRF4_EEPARAM_RFGH_868p33MHz 0x05
180#define MBUSRF4_EEPARAM_RFGH_868p39MHz 0x06
181#define MBUSRF4_EEPARAM_RFGH_868p45MHz 0x07
182#define MBUSRF4_EEPARAM_RFGH_868p51MHz 0x08
183#define MBUSRF4_EEPARAM_RFGH_868p57MHz 0x09
190#define MBUSRF4_EEPARAM_RFPWR_0dBm 0x00
191#define MBUSRF4_EEPARAM_RFPWR_5dBm 0x01
192#define MBUSRF4_EEPARAM_RFPWR_7dBm 0x02
193#define MBUSRF4_EEPARAM_RFPWR_10dBm 0x03
194#define MBUSRF4_EEPARAM_RFPWR_12dBm 0x04
201#define MBUSRF4_EEPARAM_RFAS_SLEEP_DISABLE 0x00
202#define MBUSRF4_EEPARAM_RFAS_SLEEP_ENABLE 0x01
209#define MBUSRF4_WM_BUS_C_FIELD 0x44
210#define MBUSRF4_HEADER 0xAA
217#define MBUSRF4_EEPARAM_BLOCK1_FROM_MODULE_ENABLE 0x01
218#define MBUSRF4_EEPARAM_BLOCK1_FROM_MODULE_DISABLE 0x00
225#define MBUSRF4_EEPARAM_RSSI_ENABLE 0x01
226#define MBUSRF4_EEPARAM_RSSI_DISABLE 0x00
233#define MBUSRF4_EEPARAM_UART_BAUDRATE_9600 0x00
234#define MBUSRF4_EEPARAM_UART_BAUDRATE_19200 0x01
235#define MBUSRF4_EEPARAM_UART_BAUDRATE_38400 0x02
236#define MBUSRF4_EEPARAM_UART_BAUDRATE_57600 0x03
237#define MBUSRF4_EEPARAM_UART_BAUDRATE_115200 0x04
244#define MBUSRF4_SET_VALUE_IN_RAM_MEMORY 0x00
245#define MBUSRF4_SET_VALUE_IN_EEPROM_MEMORY 0xFF
252#define MBUSRF4_USER_APP_RX_MODE 0x00
253#define MBUSRF4_USER_APP_TX_MODE 0x01
260#define MBUSRF4_COMMUNICATION_UART_MODE 0x01
261#define MBUSRF4_COMMUNICATION_SPI_MODE 0x00
#define DRV_RX_BUFFER_SIZE
Definition mbusrf4.h:101
#define MBUSRF4_RETVAL
Definition mbusrf4.h:80
void mbusrf4_send_command(mbusrf4_t *ctx, uint8_t command, uint8_t length, uint8_t *payload_buff)
Send command - UART communication.
void mbusrf4_cfg_setup(mbusrf4_cfg_t *cfg)
Config Object Initialization function.
MBUSRF4_RETVAL mbusrf4_init(mbusrf4_t *ctx, mbusrf4_cfg_t *cfg)
Initialization function.
int32_t mbusrf4_generic_read(mbusrf4_t *ctx, char *data_buf, uint16_t max_len)
Generic read function.
uint8_t mbusrf4_get_state_rts(mbusrf4_t *ctx)
Get Interrupt state of the RTS(INT) pin.
void mbusrf4_set_communication_mode(mbusrf4_t *ctx, uint8_t mode)
Set communication SPI/UART.
void mbusrf4_transmit_data(mbusrf4_t *ctx, uint8_t *tx_buf, uint8_t tx_len)
void mbusrf4_generic_write(mbusrf4_t *ctx, char *data_buf, uint16_t len)
Generic write function.
uint8_t mbusrf4_get_state_ind(mbusrf4_t *ctx)
Get Interrupt state of the IND(AN) pin.
uint8_t mbusrf4_error_t
Error type.
Definition mbusrf4.h:323
Click configuration structure definition.
Definition mbusrf4.h:297
pin_name_t rts
Definition mbusrf4.h:308
uint32_t baud_rate
Definition mbusrf4.h:312
bool uart_blocking
Definition mbusrf4.h:313
uart_data_bits_t data_bit
Definition mbusrf4.h:314
pin_name_t tx_pin
Definition mbusrf4.h:301
pin_name_t rx_pin
Definition mbusrf4.h:300
pin_name_t sel
Definition mbusrf4.h:307
uart_stop_bits_t stop_bit
Definition mbusrf4.h:316
uart_parity_t parity_bit
Definition mbusrf4.h:315
pin_name_t ind
Definition mbusrf4.h:305
pin_name_t cs
Definition mbusrf4.h:306
Click ctx object definition.
Definition mbusrf4.h:273
digital_out_t cs
Definition mbusrf4.h:276
digital_out_t sel
Definition mbusrf4.h:277
uart_t uart
Definition mbusrf4.h:286
digital_in_t rts
Definition mbusrf4.h:282
digital_in_t ind
Definition mbusrf4.h:281