btez 2.0.0.0
btez.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 BTEZ_H
36#define BTEZ_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// -------------------------------------------------------------- PUBLIC MACROS
66#define BTEZ_MAP_MIKROBUS( cfg, mikrobus ) \
67 cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
68 cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
69 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
70 cfg.cts = MIKROBUS( mikrobus, MIKROBUS_CS ); \
71 cfg.rts = MIKROBUS( mikrobus, MIKROBUS_INT )
78#define BTEZ_RETVAL uint8_t
79
80#define BTEZ_OK 0x00
81#define BTEZ_INIT_ERROR 0xFF
88#define DRV_RX_BUFFER_SIZE 500
89#define DRV_TX_BUFFER_SIZE 200
92 // End group macro
93// --------------------------------------------------------------- PUBLIC TYPES
101typedef struct
102{
103 // Output pins
104
105 digital_out_t rst;
106 digital_out_t cts;
107
108 // Input pins
109
110 digital_in_t rts;
111
112 // Modules
113
114 uart_t uart;
115
116 char uart_rx_buffer[ DRV_RX_BUFFER_SIZE ];
117 char uart_tx_buffer[ DRV_TX_BUFFER_SIZE ];
118
119} btez_t;
120
124typedef struct
125{
126 // Communication gpio pins
127
128 pin_name_t rx_pin;
129 pin_name_t tx_pin;
130
131 // Additional gpio pins
132
133 pin_name_t rst;
134 pin_name_t cts;
135 pin_name_t rts;
136
137 // static variable
138
139 uint32_t baud_rate; // Clock speed.
141 uart_data_bits_t data_bit; // Data bits.
142 uart_parity_t parity_bit; // Parity bit.
143 uart_stop_bits_t stop_bit; // Stop bits.
144
145} btez_cfg_t;
146
150typedef uint8_t btez_error_t;
151
152 // End types group
153// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
154
160#ifdef __cplusplus
161extern "C"{
162#endif
163
173
183
190
198void btez_generic_write ( btez_t *ctx, char *data_buf, uint16_t len );
199
208int32_t btez_generic_read ( btez_t *ctx, char *data_buf, uint16_t max_len );
209
216void btez_send_command ( btez_t *ctx, char *command );
217
218#ifdef __cplusplus
219}
220#endif
221#endif // _BTEZ_H_
222
223 // End public_function group
225
226// ------------------------------------------------------------------------- END
#define DRV_RX_BUFFER_SIZE
Definition btez.h:88
#define DRV_TX_BUFFER_SIZE
Definition btez.h:89
#define BTEZ_RETVAL
Definition btez.h:78
void btez_send_command(btez_t *ctx, char *command)
Send command function.
void btez_module_reset(btez_t *ctx)
Reset module.
void btez_cfg_setup(btez_cfg_t *cfg)
Config Object Initialization function.
int32_t btez_generic_read(btez_t *ctx, char *data_buf, uint16_t max_len)
Generic read function.
BTEZ_RETVAL btez_init(btez_t *ctx, btez_cfg_t *cfg)
Initialization function.
void btez_generic_write(btez_t *ctx, char *data_buf, uint16_t len)
Generic write function.
uint8_t btez_error_t
Error type.
Definition btez.h:150
Click configuration structure definition.
Definition btez.h:125
pin_name_t rts
Definition btez.h:135
uint32_t baud_rate
Definition btez.h:139
pin_name_t cts
Definition btez.h:134
bool uart_blocking
Definition btez.h:140
uart_data_bits_t data_bit
Definition btez.h:141
pin_name_t tx_pin
Definition btez.h:129
pin_name_t rx_pin
Definition btez.h:128
uart_stop_bits_t stop_bit
Definition btez.h:143
uart_parity_t parity_bit
Definition btez.h:142
pin_name_t rst
Definition btez.h:133
Click ctx object definition.
Definition btez.h:102
uart_t uart
Definition btez.h:114
digital_in_t rts
Definition btez.h:110
digital_out_t rst
Definition btez.h:105
digital_out_t cts
Definition btez.h:106