binhonova  2.1.0.0
binhonova.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 BINHONOVA_H
29 #define BINHONOVA_H
30 
31 #ifdef __cplusplus
32 extern "C"{
33 #endif
34 
35 #include "drv_digital_out.h"
36 #include "drv_digital_in.h"
37 #include "drv_uart.h"
38 
60 #define BINHONOVA_TX_DRV_BUFFER_SIZE 100
61 #define BINHONOVA_RX_DRV_BUFFER_SIZE 300
62  // binhonova_cmd
64 
79 #define BINHONOVA_MAP_MIKROBUS( cfg, mikrobus ) \
80  cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
81  cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX );
82  // binhonova_map // binhonova
85 
90 typedef struct
91 {
92  // Modules
93  uart_t uart;
95  // Buffers
96  uint8_t uart_rx_buffer[ BINHONOVA_RX_DRV_BUFFER_SIZE ];
97  uint8_t uart_tx_buffer[ BINHONOVA_TX_DRV_BUFFER_SIZE ];
99 } binhonova_t;
100 
105 typedef struct
106 {
107  // Communication gpio pins
108  pin_name_t rx_pin;
109  pin_name_t tx_pin;
111  // Static variable
112  uint32_t baud_rate;
114  uart_data_bits_t data_bit;
115  uart_parity_t parity_bit;
116  uart_stop_bits_t stop_bit;
119 
124 typedef enum
125 {
127  BINHONOVA_ERROR = -1
128 
130 
147 
162 
175 err_t binhonova_generic_write ( binhonova_t *ctx, uint8_t *data_in, uint16_t len );
176 
189 err_t binhonova_generic_read ( binhonova_t *ctx, uint8_t *data_out, uint16_t len );
190 
191 #ifdef __cplusplus
192 }
193 #endif
194 #endif // BINHONOVA_H
195  // binhonova
197 
198 // ------------------------------------------------------------------------ END
binhonova_return_value_t
binhonova_return_value_t
Binho Nova Click return value data.
Definition: binhonova.h:125
binhonova_cfg_t::uart_blocking
bool uart_blocking
Definition: binhonova.h:113
binhonova_t::uart
uart_t uart
Definition: binhonova.h:93
BINHONOVA_TX_DRV_BUFFER_SIZE
#define BINHONOVA_TX_DRV_BUFFER_SIZE
Binho Nova driver buffer size.
Definition: binhonova.h:60
binhonova_cfg_t::data_bit
uart_data_bits_t data_bit
Definition: binhonova.h:114
binhonova_cfg_t::parity_bit
uart_parity_t parity_bit
Definition: binhonova.h:115
binhonova_cfg_t
Binho Nova Click configuration object.
Definition: binhonova.h:106
binhonova_generic_read
err_t binhonova_generic_read(binhonova_t *ctx, uint8_t *data_out, uint16_t len)
Binho Nova data reading function.
binhonova_t
Binho Nova Click context object.
Definition: binhonova.h:91
binhonova_cfg_setup
void binhonova_cfg_setup(binhonova_cfg_t *cfg)
Binho Nova configuration object setup function.
binhonova_cfg_t::tx_pin
pin_name_t tx_pin
Definition: binhonova.h:109
BINHONOVA_OK
@ BINHONOVA_OK
Definition: binhonova.h:126
binhonova_init
err_t binhonova_init(binhonova_t *ctx, binhonova_cfg_t *cfg)
Binho Nova initialization function.
binhonova_cfg_t::stop_bit
uart_stop_bits_t stop_bit
Definition: binhonova.h:116
BINHONOVA_RX_DRV_BUFFER_SIZE
#define BINHONOVA_RX_DRV_BUFFER_SIZE
Definition: binhonova.h:61
BINHONOVA_ERROR
@ BINHONOVA_ERROR
Definition: binhonova.h:127
binhonova_cfg_t::baud_rate
uint32_t baud_rate
Definition: binhonova.h:112
binhonova_cfg_t::rx_pin
pin_name_t rx_pin
Definition: binhonova.h:108
binhonova_generic_write
err_t binhonova_generic_write(binhonova_t *ctx, uint8_t *data_in, uint16_t len)
Binho Nova data writing function.