ble7 2.0.0.0
ble7.h
Go to the documentation of this file.
1/*
2 * MikroSDK - MikroE Software Development Kit
3 * Copyright© 2020 MikroElektronika d.o.o.
4 *
5 * Permission is hereby granted, free of charge, to any person
6 * obtaining a copy of this software and associated documentation
7 * files (the "Software"), to deal in the Software without restriction,
8 * including without limitation the rights to use, copy, modify, merge,
9 * publish, distribute, sublicense, and/or sell copies of the Software,
10 * and to permit persons to whom the Software is furnished to do so,
11 * subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be
14 * included in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
20 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
22 * OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
33// ----------------------------------------------------------------------------
34
35#ifndef BLE7_H
36#define BLE7_H
37
42#ifdef PREINIT_SUPPORTED
43#include "preinit.h"
44#endif
45
46#ifdef MikroCCoreVersion
47 #if MikroCCoreVersion >= 1
48 #include "delays.h"
49 #endif
50#endif
51
52#include "drv_digital_out.h"
53#include "drv_digital_in.h"
54#include "drv_uart.h"
55
56
57// -------------------------------------------------------------- PUBLIC MACROS
67#define BLE7_MAP_MIKROBUS( cfg, mikrobus ) \
68 cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
69 cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
70 cfg.gp0 = MIKROBUS( mikrobus, MIKROBUS_AN ); \
71 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
72 cfg.rts = MIKROBUS( mikrobus, MIKROBUS_CS ); \
73 cfg.gp1 = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
74 cfg.cts = MIKROBUS( mikrobus, MIKROBUS_INT );
81#define BLE7_RETVAL uint8_t
82
83#define BLE7_OK 0x00
84#define BLE7_INIT_ERROR 0xFF
85
86#define BLE7_END_BUFF 0
93#define DRV_RX_BUFFER_SIZE 200
94#define DRV_TX_BUFFER_SIZE 100
97 // End group macro
98// --------------------------------------------------------------- PUBLIC TYPES
106typedef struct
107{
108 // Output pins
109
110 digital_out_t rst;
111 digital_out_t gp1;
112 digital_out_t cts;
113
114 // Input pins
115
116 digital_in_t gp0;
117 digital_in_t rts;
118
119 // Modules
120
121 uart_t uart;
122
123 char uart_rx_buffer[ DRV_RX_BUFFER_SIZE ];
124 char uart_tx_buffer[ DRV_TX_BUFFER_SIZE ];
125
126} ble7_t;
127
131typedef struct
132{
133 // Communication gpio pins
134
135 pin_name_t rx_pin;
136 pin_name_t tx_pin;
137
138 // Additional gpio pins
139
140 pin_name_t gp0;
141 pin_name_t rst;
142 pin_name_t rts;
143 pin_name_t gp1;
144 pin_name_t cts;
145
146 // static variable
147
148 uint32_t baud_rate; // Clock speed.
150 uart_data_bits_t data_bit; // Data bits.
151 uart_parity_t parity_bit; // Parity bit.
152 uart_stop_bits_t stop_bit; // Stop bits.
153
154} ble7_cfg_t;
155
159typedef uint8_t ble7_error_t;
160
161 // End types group
162// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
163
169#ifdef __cplusplus
170extern "C"{
171#endif
172
182
192
198void ble7_reset ( ble7_t *ctx );
199
209void ble7_generic_write ( ble7_t *ctx, char *data_buf, uint16_t len );
210
222int32_t ble7_generic_read ( ble7_t *ctx, char *data_buf, uint16_t max_len );
223
235void ble7_send_command ( ble7_t *ctx, char *command );
236
246uint8_t ble7_get_gp0 ( ble7_t *ctx );
247
257uint8_t ble7_get_rts ( ble7_t *ctx );
258
267void ble7_set_gp1 ( ble7_t *ctx, uint8_t state );
268
277void ble7_set_cts ( ble7_t *ctx, uint8_t state );
278
279#ifdef __cplusplus
280}
281#endif
282#endif // _BLE7_H_
283
284 // End public_function group
286
287// ------------------------------------------------------------------------- END
#define DRV_RX_BUFFER_SIZE
Definition ble7.h:93
#define DRV_TX_BUFFER_SIZE
Definition ble7.h:94
#define BLE7_RETVAL
Definition ble7.h:81
void ble7_generic_write(ble7_t *ctx, char *data_buf, uint16_t len)
Generic write function.
uint8_t ble7_get_rts(ble7_t *ctx)
RTS Pin Getting function.
void ble7_reset(ble7_t *ctx)
Reset function.
void ble7_set_gp1(ble7_t *ctx, uint8_t state)
GP1 Pin Setting function.
void ble7_cfg_setup(ble7_cfg_t *cfg)
Config Object Initialization function.
void ble7_send_command(ble7_t *ctx, char *command)
Transmit function.
int32_t ble7_generic_read(ble7_t *ctx, char *data_buf, uint16_t max_len)
Generic read function.
void ble7_set_cts(ble7_t *ctx, uint8_t state)
CTS Pin Setting function.
uint8_t ble7_get_gp0(ble7_t *ctx)
GP0 Pin Getting function.
BLE7_RETVAL ble7_init(ble7_t *ctx, ble7_cfg_t *cfg)
Initialization function.
uint8_t ble7_error_t
Error type.
Definition ble7.h:159
Click configuration structure definition.
Definition ble7.h:132
pin_name_t rts
Definition ble7.h:142
uint32_t baud_rate
Definition ble7.h:148
pin_name_t gp0
Definition ble7.h:140
pin_name_t cts
Definition ble7.h:144
bool uart_blocking
Definition ble7.h:149
uart_data_bits_t data_bit
Definition ble7.h:150
pin_name_t tx_pin
Definition ble7.h:136
pin_name_t rx_pin
Definition ble7.h:135
uart_stop_bits_t stop_bit
Definition ble7.h:152
pin_name_t gp1
Definition ble7.h:143
uart_parity_t parity_bit
Definition ble7.h:151
pin_name_t rst
Definition ble7.h:141
Click ctx object definition.
Definition ble7.h:107
uart_t uart
Definition ble7.h:121
digital_in_t gp0
Definition ble7.h:116
digital_in_t rts
Definition ble7.h:117
digital_out_t gp1
Definition ble7.h:111
digital_out_t rst
Definition ble7.h:110
digital_out_t cts
Definition ble7.h:112