aiwb212f 2.1.0.0
aiwb212f.h
Go to the documentation of this file.
1/****************************************************************************
2** Copyright (C) 2020 MikroElektronika d.o.o.
3** Contact: https://www.mikroe.com/contact
4**
5** Permission is hereby granted, free of charge, to any person obtaining a copy
6** of this software and associated documentation files (the "Software"), to deal
7** in the Software without restriction, including without limitation the rights
8** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9** copies of the Software, and to permit persons to whom the Software is
10** furnished to do so, subject to the following conditions:
11** The above copyright notice and this permission notice shall be
12** included in all copies or substantial portions of the Software.
13**
14** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
16** OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
19** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20** USE OR OTHER DEALINGS IN THE SOFTWARE.
21****************************************************************************/
22
28#ifndef AIWB212F_H
29#define AIWB212F_H
30
31#ifdef __cplusplus
32extern "C"{
33#endif
34
39#ifdef PREINIT_SUPPORTED
40#include "preinit.h"
41#endif
42
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
45 #include "delays.h"
46 #endif
47#endif
48
49#include "drv_digital_out.h"
50#include "drv_digital_in.h"
51#include "drv_uart.h"
52
73#define AIWB212F_CMD_AT "AT"
74#define AIWB212F_CMD_AT_HELP "AT+HELP"
75#define AIWB212F_CMD_AT_SW_RESET "AT+RST"
76#define AIWB212F_CMD_AT_GMR "AT+GMR"
77#define AIWB212F_CMD_AT_SLEEP "AT+SLEEP"
78#define AIWB212F_CMD_AT_SYSIOMAP "AT+SYSIOMAP"
79#define AIWB212F_CMD_AT_SYSGPIOWRITE "AT+SYSGPIOWRITE"
80#define AIWB212F_CMD_AT_SYSGPIOREAD "AT+SYSGPIOREAD"
81#define AIWB212F_CMD_AT_PWMCFG "AT+PWMCFG"
82#define AIWB212F_CMD_AT_PWMCFGS "AT+PWMCFGS"
83#define AIWB212F_CMD_AT_PWMSTOP "AT+PWMSTOP"
84#define AIWB212F_CMD_AT_PWMDUTYSET "AT+PWMDUTYSET"
85#define AIWB212F_CMD_AT_PWMDUTYSETS "AT+PWMDUTYSETS"
86#define AIWB212F_CMD_AT_WMODE "AT+WMODE"
87#define AIWB212F_CMD_AT_WSCAN "AT+WSCAN"
88#define AIWB212F_CMD_AT_WSDHCP "AT+WSDHCP"
89#define AIWB212F_CMD_AT_WJAP "AT+WJAP"
90#define AIWB212F_CMD_AT_WAUTOCONN "AT+WAUTOCONN"
91#define AIWB212F_CMD_AT_WAPDHCP "AT+WAPDHCP"
92#define AIWB212F_CMD_AT_WAP "AT+WAP"
93#define AIWB212F_CMD_AT_PING "AT+PING"
94#define AIWB212F_CMD_AT_CIPSTAMAC_DEF "AT+CIPSTAMAC_DEF"
95#define AIWB212F_CMD_AT_WCOUNTRY "AT+WCOUNTRY"
96#define AIWB212F_CMD_AT_WCONFIG "AT+WCONFIG"
97#define AIWB212F_CMD_AT_SOCKET "AT+SOCKET"
98#define AIWB212F_CMD_AT_SOCKETSEND "AT+SOCKETSEND"
99#define AIWB212F_CMD_AT_SOCKETSENDLINE "AT+SOCKETSENDLINE"
100#define AIWB212F_CMD_AT_SOCKETREAD "AT+SOCKETREAD"
101#define AIWB212F_CMD_AT_SOCKETDEL "AT+SOCKETDEL"
102#define AIWB212F_CMD_AT_SOCKETRECVCFG "AT+SOCKETRECVCFG"
103#define AIWB212F_CMD_AT_SOCKETTT "AT+SOCKETTT"
104#define AIWB212F_CMD_AT_MQTT "AT+MQTT"
105#define AIWB212F_CMD_AT_MQTTPUB "AT+MQTTPUB"
106#define AIWB212F_CMD_AT_MQTTPUBRAW "AT+MQTTPUBRAW"
107#define AIWB212F_CMD_AT_MQTTSUB "AT+MQTTSUB"
108#define AIWB212F_CMD_AT_BLEMAC "AT+BLEMAC"
109#define AIWB212F_CMD_AT_BLEMODE "AT+BLEMODE"
110#define AIWB212F_CMD_AT_BLERFPWR "AT+BLERFPWR"
111#define AIWB212F_CMD_AT_BLENAME "AT+BLENAME"
112
117#define AIWB212F_RSP_OK "OK"
118#define AIWB212F_RSP_ERROR "ERROR"
119#define AIWB212F_RSP_READY "ready"
120
126#define AIWB212F_TX_DRV_BUFFER_SIZE 100
127#define AIWB212F_RX_DRV_BUFFER_SIZE 300
128
129 // aiwb212f_cmd
130
145#define AIWB212F_MAP_MIKROBUS( cfg, mikrobus ) \
146 cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
147 cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
148 cfg.en = MIKROBUS( mikrobus, MIKROBUS_RST )
149
150 // aiwb212f_map
151 // aiwb212f
152
157typedef struct
158{
159 // Output pins
160 digital_out_t en;
162 // Modules
163 uart_t uart;
165 // Buffers
166 uint8_t uart_rx_buffer[ AIWB212F_RX_DRV_BUFFER_SIZE ];
167 uint8_t uart_tx_buffer[ AIWB212F_TX_DRV_BUFFER_SIZE ];
169} aiwb212f_t;
170
175typedef struct
176{
177 // Communication gpio pins
178 pin_name_t rx_pin;
179 pin_name_t tx_pin;
181 // Additional gpio pins
182 pin_name_t en;
184 // Static variable
185 uint32_t baud_rate;
187 uart_data_bits_t data_bit;
188 uart_parity_t parity_bit;
189 uart_stop_bits_t stop_bit;
192
206
223
238
252
265err_t aiwb212f_generic_write ( aiwb212f_t *ctx, uint8_t *data_in, uint16_t len );
266
279err_t aiwb212f_generic_read ( aiwb212f_t *ctx, uint8_t *data_out, uint16_t len );
280
290
300void aiwb212f_send_cmd ( aiwb212f_t *ctx, uint8_t *at_cmd_buf );
301
312void aiwb212f_send_cmd_with_par ( aiwb212f_t *ctx, uint8_t *at_cmd_buf, uint8_t *param_buf );
313
323void aiwb212f_send_cmd_check ( aiwb212f_t *ctx, uint8_t *at_cmd_buf );
324
335void aiwb212f_set_gpio ( aiwb212f_t *ctx, uint8_t *pin, uint8_t *state );
336
337#ifdef __cplusplus
338}
339#endif
340#endif // AIWB212F_H
341
342 // aiwb212f
343
344// ------------------------------------------------------------------------ END
aiwb212f_return_value_t
Ai-WB2-12F Click return value data.
Definition aiwb212f.h:198
@ AIWB212F_ERROR_CMD
Definition aiwb212f.h:202
@ AIWB212F_ERROR_TIMEOUT
Definition aiwb212f.h:201
@ AIWB212F_ERROR_UNKNOWN
Definition aiwb212f.h:203
@ AIWB212F_OK
Definition aiwb212f.h:199
@ AIWB212F_ERROR
Definition aiwb212f.h:200
#define AIWB212F_RX_DRV_BUFFER_SIZE
Definition aiwb212f.h:127
#define AIWB212F_TX_DRV_BUFFER_SIZE
Ai-WB2-12F driver buffer size.
Definition aiwb212f.h:126
void aiwb212f_send_cmd(aiwb212f_t *ctx, uint8_t *at_cmd_buf)
Ai-WB2-12F send command function.
void aiwb212f_send_cmd_with_par(aiwb212f_t *ctx, uint8_t *at_cmd_buf, uint8_t *param_buf)
Ai-WB2-12F send command with parameter function.
void aiwb212f_hw_reset(aiwb212f_t *ctx)
Ai-WB2-12F hardware reset function.
void aiwb212f_cfg_setup(aiwb212f_cfg_t *cfg)
Ai-WB2-12F configuration object setup function.
err_t aiwb212f_generic_write(aiwb212f_t *ctx, uint8_t *data_in, uint16_t len)
Ai-WB2-12F data writing function.
err_t aiwb212f_generic_read(aiwb212f_t *ctx, uint8_t *data_out, uint16_t len)
Ai-WB2-12F data reading function.
void aiwb212f_send_cmd_check(aiwb212f_t *ctx, uint8_t *at_cmd_buf)
Ai-WB2-12F send command check function.
void aiwb212f_set_gpio(aiwb212f_t *ctx, uint8_t *pin, uint8_t *state)
Ai-WB2-12F set gpio pin state function.
err_t aiwb212f_default_cfg(aiwb212f_t *ctx)
Ai-WB2-12F default configuration function.
err_t aiwb212f_init(aiwb212f_t *ctx, aiwb212f_cfg_t *cfg)
Ai-WB2-12F initialization function.
Ai-WB2-12F Click configuration object.
Definition aiwb212f.h:176
uint32_t baud_rate
Definition aiwb212f.h:185
bool uart_blocking
Definition aiwb212f.h:186
uart_data_bits_t data_bit
Definition aiwb212f.h:187
pin_name_t tx_pin
Definition aiwb212f.h:179
pin_name_t rx_pin
Definition aiwb212f.h:178
uart_stop_bits_t stop_bit
Definition aiwb212f.h:189
pin_name_t en
Definition aiwb212f.h:182
uart_parity_t parity_bit
Definition aiwb212f.h:188
Ai-WB2-12F Click context object.
Definition aiwb212f.h:158
uart_t uart
Definition aiwb212f.h:163
digital_out_t en
Definition aiwb212f.h:160