39#ifdef PREINIT_SUPPORTED
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
49#include "drv_digital_out.h"
50#include "drv_digital_in.h"
63#define SPIRIT2_MAP_MIKROBUS( cfg, mikrobus ) \
64 cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
65 cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
66 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
67 cfg.cmd = MIKROBUS( mikrobus, MIKROBUS_CS ); \
68 cfg.shd = MIKROBUS( mikrobus, MIKROBUS_PWM )
75#define SPIRIT2_MODULE_POWER_ON 1
76#define SPIRIT2_MODULE_POWER_OFF 0
83#define DRV_RX_BUFFER_SIZE 500
84#define DRV_TX_BUFFER_SIZE 200
91#define SPIRIT2_OPERATING_MODE 0x01
92#define SPIRIT2_COMMAND_MODE 0x00
94#define SPIRIT2_MODULE_WAKE_UP 0x01
95#define SPIRIT2_MODULE_SHUTDOWN 0x00
102#define SPIRIT2_CMD_ENTER_COMMAND_MODE "+++"
103#define SPIRIT2_CMD_ENTER_OPERATING_MODE "ATO"
104#define SPIRIT2_CMD_READ_MODULE_VERSION "AT/V"
105#define SPIRIT2_CMD_READ_ALL_CONFIG_REG "AT/S"
106#define SPIRIT2_CMD_STORE_CURRENT_CONFIG "AT/C"
107#define SPIRIT2_CMD_RESET_CONFIG "ATR"
108#define SPIRIT2_CMD_RESET_MODULE "ATZ"
115#define SPIRIT2_CMD_READ_INFO_PER "ATI0"
116#define SPIRIT2_CMD_READ_INFO_PSSI "ATI1"
117#define SPIRIT2_CMD_READ_INFO_LQI "ATI2"
118#define SPIRIT2_CMD_READ_INFO_PQI "ATI3"
119#define SPIRIT2_CMD_READ_INFO_SQI "ATI4"
120#define SPIRIT2_CMD_READ_INFO_PACKET_COUNT "ATI5"
121#define SPIRIT2_CMD_READ_INFO_PACKETS_LOST "ATI6"
128#define SPIRIT2_CMD_CFG_BAUD_RATE "ATS00"
129#define SPIRIT2_CMD_CFG_FREQUENCY "ATS01"
130#define SPIRIT2_CMD_CFG_DATA_RATE "ATS02"
131#define SPIRIT2_CMD_CFG_MODULATION "ATS03"
132#define SPIRIT2_CMD_CFG_OUTPUT_POWER "ATS04"
133#define SPIRIT2_CMD_CFG_FREQ_DEVIATION "ATS05"
134#define SPIRIT2_CMD_CFG_RX_FILTER "ATS06"
135#define SPIRIT2_CMD_CFG_CS_MODE "ATS07"
136#define SPIRIT2_CMD_CFG_RSSI_THRESHOLD "ATS08"
137#define SPIRIT2_CMD_CFG_PREAMBLE_LEN "ATS09"
138#define SPIRIT2_CMD_CFG_SYNC_LENGTH "ATS10"
139#define SPIRIT2_CMD_CFG_SYNC_VALUE "ATS11"
140#define SPIRIT2_CMD_CFG_CRC_MODE "ATS12"
141#define SPIRIT2_CMD_CFG_WHITENING "ATS13"
142#define SPIRIT2_CMD_CFG_FEC "ATS14"
143#define SPIRIT2_CMD_CFG_SOURCE_ADDR "ATS15"
144#define SPIRIT2_CMD_CFG_DESTINATION_ADDR "ATS16"
145#define SPIRIT2_CMD_CFG_MULTICAST_ADDR "ATS17"
146#define SPIRIT2_CMD_CFG_BROADCAST_ADDR "ATS18"
147#define SPIRIT2_CMD_CFG_FILTER_CRC "ATS19"
148#define SPIRIT2_CMD_CFG_FILTER_SOURCE "ATS20"
149#define SPIRIT2_CMD_CFG_FILTER_DESTINATION "ATS21"
150#define SPIRIT2_CMD_CFG_FILTER_MULTICAST "ATS22"
151#define SPIRIT2_CMD_CFG_FILTER_BROADCAST "ATS23"
152#define SPIRIT2_CMD_CFG_TXRX_LED "ATS24"
153#define SPIRIT2_CMD_CFG_ESCAPE_SEQ "ATS26"
154#define SPIRIT2_CMD_CFG_SOURCE_FILT_MASK "ATS27"
155#define SPIRIT2_CMD_CFG_PAYLOAD_SIZE "ATS28"
162#define SPIRIT2_PCFG_ENABLE "1"
163#define SPIRIT2_PCFG_DISABLE "0"
170#define SPIRIT2_PCFG_BAUD_RATE_9600 "9600"
171#define SPIRIT2_PCFG_BAUD_RATE_19200 "19200"
172#define SPIRIT2_PCFG_BAUD_RATE_38400 "38400"
173#define SPIRIT2_PCFG_BAUD_RATE_56000 "56000"
174#define SPIRIT2_PCFG_BAUD_RATE_57600 "57600"
175#define SPIRIT2_PCFG_BAUD_RATE_115200 "115200"
176#define SPIRIT2_PCFG_BAUD_RATE_128000 "128000"
177#define SPIRIT2_PCFG_BAUD_RATE_256000 "256000"
184#define SPIRIT2_PCFG_CSMODE_STATIC_SENSING "0"
185#define SPIRIT2_PCFG_CSMODE_DYNAMIC_SENSING_6dB "1"
186#define SPIRIT2_PCFG_CSMODE_DYNAMIC_SENSING_12dB "2"
187#define SPIRIT2_PCFG_CSMODE_DYNAMIC_SENSING_18dB "3"
194#define SPIRIT2_PCFG_CRCMODE_POLY_0x07 "1"
195#define SPIRIT2_PCFG_CRCMODE_POLY_0x8005 "2"
196#define SPIRIT2_PCFG_CRCMODE_POLY_0x1021 "3"
197#define SPIRIT2_PCFG_CRCMODE_POLY_0x864CFB "4"
204#define SPIRIT2_PCFG_TXRXLED_DISABLED "0"
205#define SPIRIT2_PCFG_TXRXLED_OPEN_DRAIN "1"
206#define SPIRIT2_PCFG_TXRXLED_PUSH_PULL "2"
213#define SPIRIT2_PCFG_MODULATION_2_FSK "0"
214#define SPIRIT2_PCFG_MODULATION_GFSK05 "1"
215#define SPIRIT2_PCFG_MODULATION_GFSK1 "2"
216#define SPIRIT2_PCFG_MODULATION_GMSK "3"
217#define SPIRIT2_PCFG_MODULATION_OOK "4"
218#define SPIRIT2_PCFG_MODULATION_ASK "5"
225#define SPIRIT2_CMD_SET_RF_TEST_MODE_DISABLE "AT/T0"
226#define SPIRIT2_CMD_SET_RF_TEST_MODE_PN9 "AT/T1"
227#define SPIRIT2_CMD_SET_RF_TEST_MODE_CW "AT/T2"
#define DRV_RX_BUFFER_SIZE
Definition spirit2.h:83
#define DRV_TX_BUFFER_SIZE
Definition spirit2.h:84
uint32_t baud_rate
Definition spirit2.h:269
digital_out_t cmd
Definition spirit2.h:238
spirit2_return_value_t
SPIRIT 2 Click return value data.
Definition spirit2.h:282
bool uart_blocking
Definition spirit2.h:270
pin_name_t cmd
Definition spirit2.h:264
uart_data_bits_t data_bit
Definition spirit2.h:271
uart_t uart
Definition spirit2.h:242
pin_name_t tx_pin
Definition spirit2.h:259
pin_name_t rx_pin
Definition spirit2.h:258
pin_name_t shd
Definition spirit2.h:265
digital_out_t rst
Definition spirit2.h:237
uart_stop_bits_t stop_bit
Definition spirit2.h:273
uart_parity_t parity_bit
Definition spirit2.h:272
pin_name_t rst
Definition spirit2.h:263
digital_out_t shd
Definition spirit2.h:239
@ SPIRIT2_OK
Definition spirit2.h:283
@ SPIRIT2_ERROR
Definition spirit2.h:284
void spirit2_send_cmd_parameter_check(spirit2_t *ctx, char *at_cmd_buf)
Check the command parameters.
void spirit2_send_cmd_with_parameter(spirit2_t *ctx, char *at_cmd_buf, char *param_buf)
Send command function with parameter.
void spirit2_cfg_setup(spirit2_cfg_t *cfg)
SPIRIT 2 configuration object setup function.
void spirit2_generic_write(spirit2_t *ctx, char *data_buf, uint16_t len)
SPIRIT 2 data writing function.
void spirit2_reset(spirit2_t *ctx)
Software reset function.
int32_t spirit2_generic_read(spirit2_t *ctx, char *data_buf, uint16_t max_len)
SPIRIT 2 data reading function.
void spirit2_send_cmd(spirit2_t *ctx, char *cmd)
Send command function.
err_t spirit2_init(spirit2_t *ctx, spirit2_cfg_t *cfg)
SPIRIT 2 initialization function.
void spirit2_power_module(spirit2_t *ctx, uint8_t power_state)
Power module function.
void spirit2_set_mode(spirit2_t *ctx, uint8_t mode)
Set mode function.
void spirit2_send_cmd_check(spirit2_t *ctx, char *at_cmd_buf)
Check the sent command.
SPIRIT 2 Click configuration object.
Definition spirit2.h:255
SPIRIT 2 Click context object.
Definition spirit2.h:235