ltecat43 2.1.0.0
ltecat43.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 LTECAT43_H
29#define LTECAT43_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 LTECAT43_CMD_AT "AT"
74#define LTECAT43_CMD_ATI "ATI"
75#define LTECAT43_CMD_CGMR "AT+CGMR"
76#define LTECAT43_CMD_CFUN "AT+CFUN"
77#define LTECAT43_CMD_CREG "AT+CREG"
78#define LTECAT43_CMD_CGREG "AT+CGREG"
79#define LTECAT43_CMD_CGDCONT "AT+CGDCONT"
80#define LTECAT43_CMD_CIMI "AT+CIMI"
81#define LTECAT43_CMD_CMEE "AT+CMEE"
82#define LTECAT43_CMD_CGATT "AT+CGATT"
83#define LTECAT43_CMD_CSQ "AT+CSQ"
84#define LTECAT43_CMD_COPS "AT+COPS"
85#define LTECAT43_CMD_CMGS "AT+CMGS"
86#define LTECAT43_CMD_CMGF "AT+CMGF"
87#define LTECAT43_CMD_CGACT "AT+CGACT"
88#define LTECAT43_CMD_USOCR "AT+USOCR"
89#define LTECAT43_CMD_USOCO "AT+USOCO"
90#define LTECAT43_CMD_USOWR "AT+USOWR"
91#define LTECAT43_CMD_USOST "AT+USOST"
92#define LTECAT43_CMD_USORD "AT+USORD"
93#define LTECAT43_CMD_USORF "AT+USORF"
94#define LTECAT43_CMD_USOCL "AT+USOCL"
95#define LTECAT43_CMD_UGPS "AT+UGPS"
96#define LTECAT43_CMD_UGGGA "AT+UGGGA"
97
102#define LTECAT43_RSP_OK "OK"
103#define LTECAT43_RSP_ERROR "ERROR"
104
109#define LTECAT43_POWER_STATE_OFF 0
110#define LTECAT43_POWER_STATE_ON 1
111
117#define LTECAT43_TX_DRV_BUFFER_SIZE 256
118#define LTECAT43_RX_DRV_BUFFER_SIZE 256
119
120 // ltecat43_cmd
121
136#define LTECAT43_MAP_MIKROBUS( cfg, mikrobus ) \
137 cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
138 cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
139 cfg.sts = MIKROBUS( mikrobus, MIKROBUS_AN ); \
140 cfg.pwr = MIKROBUS( mikrobus, MIKROBUS_RST ); \
141 cfg.rts = MIKROBUS( mikrobus, MIKROBUS_CS ); \
142 cfg.ri = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
143 cfg.cts = MIKROBUS( mikrobus, MIKROBUS_INT );
144
145 // ltecat43_map
146 // ltecat43
147
152typedef struct
153{
154 // Output pins
155 digital_out_t sts;
156 digital_out_t pwr;
157 digital_out_t rts;
159 // Input pins
160 digital_in_t ri;
161 digital_in_t cts;
163 // Modules
164 uart_t uart;
166 // Buffers
167 uint8_t uart_rx_buffer[ LTECAT43_TX_DRV_BUFFER_SIZE ];
168 uint8_t uart_tx_buffer[ LTECAT43_RX_DRV_BUFFER_SIZE ];
170} ltecat43_t;
171
176typedef struct
177{
178 // Communication gpio pins
179 pin_name_t rx_pin;
180 pin_name_t tx_pin;
182 // Additional gpio pins
183 pin_name_t sts;
184 pin_name_t pwr;
185 pin_name_t rts;
186 pin_name_t ri;
187 pin_name_t cts;
189 // Static variable
190 uint32_t baud_rate;
192 uart_data_bits_t data_bit;
193 uart_parity_t parity_bit;
194 uart_stop_bits_t stop_bit;
197
211
228
243
256err_t ltecat43_generic_write ( ltecat43_t *ctx, uint8_t *data_in, uint16_t len );
257
270err_t ltecat43_generic_read ( ltecat43_t *ctx, uint8_t *data_out, uint16_t len );
271
281void ltecat43_set_pwr_pin ( ltecat43_t *ctx, uint8_t state );
282
292void ltecat43_set_sts_pin ( ltecat43_t *ctx, uint8_t state );
293
303void ltecat43_set_rts_pin ( ltecat43_t *ctx, uint8_t state );
304
314
324
335void ltecat43_set_power_state ( ltecat43_t *ctx, uint8_t state );
336
346void ltecat43_send_cmd ( ltecat43_t *ctx, uint8_t *cmd );
347
358void ltecat43_send_cmd_par ( ltecat43_t *ctx, uint8_t *at_cmd_buf, uint8_t *param_buf );
359
369void ltecat43_send_cmd_check ( ltecat43_t *ctx, uint8_t *at_cmd_buf );
370
380void ltecat43_set_sim_apn ( ltecat43_t *ctx, uint8_t *sim_apn );
381
392void ltecat43_send_sms_text ( ltecat43_t *ctx, uint8_t *phone_number, uint8_t *sms_text );
393
407err_t ltecat43_send_sms_pdu ( ltecat43_t *ctx, uint8_t *service_center_number, uint8_t *phone_number, uint8_t *sms_text );
408
409#ifdef __cplusplus
410}
411#endif
412#endif // LTECAT43_H
413
414 // ltecat43
415
416// ------------------------------------------------------------------------ END
#define LTECAT43_RX_DRV_BUFFER_SIZE
Definition ltecat43.h:118
#define LTECAT43_TX_DRV_BUFFER_SIZE
LTE Cat.4 3 driver buffer size.
Definition ltecat43.h:117
void ltecat43_send_cmd_check(ltecat43_t *ctx, uint8_t *at_cmd_buf)
Check the sent command.
err_t ltecat43_send_sms_pdu(ltecat43_t *ctx, uint8_t *service_center_number, uint8_t *phone_number, uint8_t *sms_text)
LTE Cat.4 3 send SMS in PDU mode.
uint8_t ltecat43_get_cts_pin(ltecat43_t *ctx)
LTE Cat.4 3 get CTS pin function.
void ltecat43_set_sts_pin(ltecat43_t *ctx, uint8_t state)
LTE Cat.4 3 set STS pin function.
void ltecat43_send_cmd(ltecat43_t *ctx, uint8_t *cmd)
Send command function.
void ltecat43_send_sms_text(ltecat43_t *ctx, uint8_t *phone_number, uint8_t *sms_text)
LTE Cat.4 3 send SMS in text mode.
void ltecat43_set_pwr_pin(ltecat43_t *ctx, uint8_t state)
LTE Cat.4 3 set PWR pin function.
uint8_t ltecat43_get_ri_pin(ltecat43_t *ctx)
LTE Cat.4 3 get RI pin function.
err_t ltecat43_init(ltecat43_t *ctx, ltecat43_cfg_t *cfg)
LTE Cat.4 3 initialization function.
void ltecat43_set_power_state(ltecat43_t *ctx, uint8_t state)
LTE Cat.4 3 set power state function.
err_t ltecat43_generic_write(ltecat43_t *ctx, uint8_t *data_in, uint16_t len)
LTE Cat.4 3 data writing function.
void ltecat43_cfg_setup(ltecat43_cfg_t *cfg)
LTE Cat.4 3 configuration object setup function.
void ltecat43_set_rts_pin(ltecat43_t *ctx, uint8_t state)
LTE Cat.4 3 set RTS pin function.
err_t ltecat43_generic_read(ltecat43_t *ctx, uint8_t *data_out, uint16_t len)
LTE Cat.4 3 data reading function.
void ltecat43_send_cmd_par(ltecat43_t *ctx, uint8_t *at_cmd_buf, uint8_t *param_buf)
Send command function with parameter.
void ltecat43_set_sim_apn(ltecat43_t *ctx, uint8_t *sim_apn)
Set sim card APN.
ltecat43_return_value_t
LTE Cat.4 3 Click return value data.
Definition ltecat43.h:203
@ LTECAT43_ERROR_TIMEOUT
Definition ltecat43.h:206
@ LTECAT43_ERROR_UNKNOWN
Definition ltecat43.h:208
@ LTECAT43_OK
Definition ltecat43.h:204
@ LTECAT43_ERROR_CMD
Definition ltecat43.h:207
@ LTECAT43_ERROR
Definition ltecat43.h:205
LTE Cat.4 3 Click configuration object.
Definition ltecat43.h:177
pin_name_t rts
Definition ltecat43.h:185
uint32_t baud_rate
Definition ltecat43.h:190
pin_name_t sts
Definition ltecat43.h:183
pin_name_t cts
Definition ltecat43.h:187
bool uart_blocking
Definition ltecat43.h:191
pin_name_t ri
Definition ltecat43.h:186
uart_data_bits_t data_bit
Definition ltecat43.h:192
pin_name_t tx_pin
Definition ltecat43.h:180
pin_name_t pwr
Definition ltecat43.h:184
pin_name_t rx_pin
Definition ltecat43.h:179
uart_stop_bits_t stop_bit
Definition ltecat43.h:194
uart_parity_t parity_bit
Definition ltecat43.h:193
LTE Cat.4 3 Click context object.
Definition ltecat43.h:153
digital_out_t pwr
Definition ltecat43.h:156
digital_out_t rts
Definition ltecat43.h:157
digital_in_t ri
Definition ltecat43.h:160
uart_t uart
Definition ltecat43.h:164
digital_out_t sts
Definition ltecat43.h:155
digital_in_t cts
Definition ltecat43.h:161