ltecat1eu 2.0.0.0
ltecat1eu.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 LTECAT1EU_H
29#define LTECAT1EU_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
74#define LTECAT1EU_CMD_AT "AT"
75#define LTECAT1EU_CMD_ATI "ATI"
76#define LTECAT1EU_CMD_CGMR "AT+CGMR"
77
78#define LTECAT1EU_CMD_CFUN "AT+CFUN"
79#define LTECAT1EU_CMD_CREG "AT+CREG"
80#define LTECAT1EU_CMD_CEREG "AT+CEREG"
81#define LTECAT1EU_CMD_CGDCONT "AT+CGDCONT"
82#define LTECAT1EU_CMD_CIMI "AT+CIMI"
83#define LTECAT1EU_CMD_CGATT "AT+CGATT"
84#define LTECAT1EU_CMD_CSQ "AT+CSQ"
85#define LTECAT1EU_CMD_CESQ "AT+CESQ"
86#define LTECAT1EU_CMD_COPS "AT+COPS"
87
88
94#define DRV_RX_BUFFER_SIZE 500
95#define DRV_TX_BUFFER_SIZE 100
96
97 // ltecat1eu_set
98
113#define LTECAT1EU_MAP_MIKROBUS( cfg, mikrobus ) \
114 cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
115 cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
116 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
117 cfg.cts = MIKROBUS( mikrobus, MIKROBUS_CS ); \
118 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
119 cfg.rts = MIKROBUS( mikrobus, MIKROBUS_INT )
120
121 // ltecat1eu_map
122 // ltecat1eu
123
128typedef struct
129{
130 // Output pins
131 digital_out_t rst;
132 digital_out_t cs;
133 digital_out_t rts;
134
135 // Input pins
136 digital_in_t cts;
137
138 // Modules
139 uart_t uart;
141 // Buffers
142 char uart_rx_buffer[ DRV_RX_BUFFER_SIZE ];
143 char uart_tx_buffer[ DRV_TX_BUFFER_SIZE ];
146
151typedef struct
152{
153 // Communication gpio pins
154 pin_name_t rx_pin;
155 pin_name_t tx_pin;
157 // Additional gpio pins
158 //pin_name_t an;
159 pin_name_t rst;
160 pin_name_t cts;
161 pin_name_t cs;
162 pin_name_t rts;
163
164 // Static variable
165 uint32_t baud_rate;
167 uart_data_bits_t data_bit;
168 uart_parity_t parity_bit;
169 uart_stop_bits_t stop_bit;
172
183
200
216
228void ltecat1eu_generic_write ( ltecat1eu_t *ctx, char *data_buf, uint16_t len );
229
243err_t ltecat1eu_generic_read ( ltecat1eu_t *ctx, char *data_buf, uint16_t max_len );
244
245
254
263void ltecat1eu_set_rst ( ltecat1eu_t *ctx, uint8_t state );
264
273void ltecat1eu_set_rts ( ltecat1eu_t *ctx, uint8_t state );
274
284
294void ltecat1eu_send_cmd ( ltecat1eu_t *ctx, char *cmd );
295
306void ltecat1eu_send_cmd_with_parameter ( ltecat1eu_t *ctx, char *at_cmd_buf, char *param_buf );
307
317void ltecat1eu_send_cmd_check ( ltecat1eu_t *ctx, char *at_cmd_buf );
318
328void ltecat1eu_send_cmd_parameter_check ( ltecat1eu_t *ctx, char *at_cmd_buf );
329
339void ltecat1eu_set_sim_apn ( ltecat1eu_t *ctx, char *sim_apn );
340
351void ltecat1eu_send_text_message ( ltecat1eu_t *ctx, char *phone_number, char *message_context );
352
353#ifdef __cplusplus
354}
355#endif
356#endif // LTECAT1EU_H
357
358 // ltecat1eu
359
360// ------------------------------------------------------------------------ END
#define DRV_RX_BUFFER_SIZE
LTE Cat.1-EU driver buffer size.
Definition ltecat1eu.h:94
#define DRV_TX_BUFFER_SIZE
Definition ltecat1eu.h:95
void ltecat1eu_send_cmd_check(ltecat1eu_t *ctx, char *at_cmd_buf)
Check the sent command.
void ltecat1eu_send_cmd_parameter_check(ltecat1eu_t *ctx, char *at_cmd_buf)
Check the command parameters.
uint8_t ltecat1eu_get_cts(ltecat1eu_t *ctx)
CTS Pin Get function.
void ltecat1eu_set_sim_apn(ltecat1eu_t *ctx, char *sim_apn)
Set sim card APN.
void ltecat1eu_cfg_setup(ltecat1eu_cfg_t *cfg)
LTE Cat.1-EU configuration object setup function.
void ltecat1eu_set_rst(ltecat1eu_t *ctx, uint8_t state)
Sets state of the RST pin.
void ltecat1eu_power_on(ltecat1eu_t *ctx)
LTE Cat.1-EU module power on.
err_t ltecat1eu_generic_read(ltecat1eu_t *ctx, char *data_buf, uint16_t max_len)
LTE Cat.1-EU data reading function.
void ltecat1eu_set_rts(ltecat1eu_t *ctx, uint8_t state)
Sets state of the RTS pin.
err_t ltecat1eu_init(ltecat1eu_t *ctx, ltecat1eu_cfg_t *cfg)
LTE Cat.1-EU initialization function.
void ltecat1eu_generic_write(ltecat1eu_t *ctx, char *data_buf, uint16_t len)
LTE Cat.1-EU data writing function.
void ltecat1eu_send_text_message(ltecat1eu_t *ctx, char *phone_number, char *message_context)
LTE Cat.1-EU send text message.
void ltecat1eu_send_cmd(ltecat1eu_t *ctx, char *cmd)
Send command function.
void ltecat1eu_send_cmd_with_parameter(ltecat1eu_t *ctx, char *at_cmd_buf, char *param_buf)
Send command function with parameter.
ltecat1eu_return_value_t
LTE Cat.1-EU Click return value data.
Definition ltecat1eu.h:178
@ LTECAT1EU_OK
Definition ltecat1eu.h:179
@ LTECAT1EU_ERROR
Definition ltecat1eu.h:180
LTE Cat.1-EU Click configuration object.
Definition ltecat1eu.h:152
pin_name_t rts
Definition ltecat1eu.h:162
uint32_t baud_rate
Definition ltecat1eu.h:165
pin_name_t cts
Definition ltecat1eu.h:160
bool uart_blocking
Definition ltecat1eu.h:166
uart_data_bits_t data_bit
Definition ltecat1eu.h:167
pin_name_t tx_pin
Definition ltecat1eu.h:155
pin_name_t rx_pin
Definition ltecat1eu.h:154
uart_stop_bits_t stop_bit
Definition ltecat1eu.h:169
uart_parity_t parity_bit
Definition ltecat1eu.h:168
pin_name_t rst
Definition ltecat1eu.h:159
pin_name_t cs
Definition ltecat1eu.h:161
LTE Cat.1-EU Click context object.
Definition ltecat1eu.h:129
digital_out_t cs
Definition ltecat1eu.h:132
digital_out_t rts
Definition ltecat1eu.h:133
uart_t uart
Definition ltecat1eu.h:139
digital_in_t cts
Definition ltecat1eu.h:136
digital_out_t rst
Definition ltecat1eu.h:131