microwave2 2.0.0.0
microwave2.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 MICROWAVE2_H
36#define MICROWAVE2_H
37
38#include "drv_digital_out.h"
39#include "drv_digital_in.h"
40#include "drv_uart.h"
41
42
43// -------------------------------------------------------------- PUBLIC MACROS
53#define MICROWAVE2_MAP_MIKROBUS( cfg, mikrobus ) \
54 cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
55 cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
56 cfg.da = MIKROBUS( mikrobus, MIKROBUS_AN ); \
57 cfg.dl = MIKROBUS( mikrobus, MIKROBUS_INT )
64#define MICROWAVE2_RETVAL uint8_t
65
66#define MICROWAVE2_OK 0x00
67#define MICROWAVE2_INIT_ERROR 0xFF
74#define DRV_RX_BUFFER_SIZE 500
81#define MICROWAVE2_MOVING_AWAY 1
82#define MICROWAVE2_MOVING_CLOSER 2
83#define MICROWAVE2_STOPPED_MOVING 4 // End group macro
87// --------------------------------------------------------------- PUBLIC TYPES
97typedef struct
98{
99 // Input pins
100
101 digital_in_t da;
102 digital_in_t dl;
103
104 // Modules
105
106 uart_t uart;
107
108 char uart_rx_buffer[ DRV_RX_BUFFER_SIZE ];
109 char uart_tx_buffer[ DRV_RX_BUFFER_SIZE ];
110
112
116typedef struct
117{
118 // Communication gpio pins
119
120 pin_name_t rx_pin;
121 pin_name_t tx_pin;
122
123 // Additional gpio pins
124
125 pin_name_t da;
126 pin_name_t dl;
127
128 // static variable
129
130 uint32_t baud_rate; // Clock speed.
132 uart_data_bits_t data_bit; // Data bits.
133 uart_parity_t parity_bit; // Parity bit.
134 uart_stop_bits_t stop_bit; // Stop bits.
135
137 // End types group
139// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
140
146#ifdef __cplusplus
147extern "C"{
148#endif
149
159
168
178void microwave2_generic_multi_write ( microwave2_t *ctx, char *data_buf, uint8_t len );
179
180
188int32_t microwave2_generic_read ( microwave2_t *ctx, char *data_buf, uint16_t max_len );
189
190
200
210
219
228
229#ifdef __cplusplus
230}
231#endif
232#endif // _MICROWAVE2_H_
233 // End public_function group
236
237// ------------------------------------------------------------------------- END
#define DRV_RX_BUFFER_SIZE
Definition: microwave2.h:74
#define MICROWAVE2_RETVAL
Definition: microwave2.h:64
uint8_t microwave2_da_state(microwave2_t *ctx)
Set pin DA.
uint8_t microwave2_dl_state(microwave2_t *ctx)
Set pin DL.
void microwave2_cfg_setup(microwave2_cfg_t *cfg)
Config Object Initialization function.
MICROWAVE2_RETVAL microwave2_init(microwave2_t *ctx, microwave2_cfg_t *cfg)
Initialization function.
void microwave2_generic_single_write(microwave2_t *ctx, char tx_data)
Generic single write function.
int32_t microwave2_generic_read(microwave2_t *ctx, char *data_buf, uint16_t max_len)
Generic read function.
char microwave2_generic_single_read(microwave2_t *ctx)
Generic single read function.
void microwave2_generic_multi_write(microwave2_t *ctx, char *data_buf, uint8_t len)
Generic multi write function.
Click configuration structure definition.
Definition: microwave2.h:117
uint32_t baud_rate
Definition: microwave2.h:130
pin_name_t da
Definition: microwave2.h:125
bool uart_blocking
Definition: microwave2.h:131
uart_data_bits_t data_bit
Definition: microwave2.h:132
pin_name_t tx_pin
Definition: microwave2.h:121
pin_name_t rx_pin
Definition: microwave2.h:120
uart_stop_bits_t stop_bit
Definition: microwave2.h:134
uart_parity_t parity_bit
Definition: microwave2.h:133
pin_name_t dl
Definition: microwave2.h:126
Click ctx object definition.
Definition: microwave2.h:98
digital_in_t dl
Definition: microwave2.h:102
digital_in_t da
Definition: microwave2.h:101
uart_t uart
Definition: microwave2.h:106