canisolator 2.0.0.0
canisolator.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 CANISOLATOR_H
36#define CANISOLATOR_H
37
38#include "drv_digital_out.h"
39#include "drv_uart.h"
40
41// -------------------------------------------------------------- PUBLIC MACROS
51#define CANISOLATOR_MAP_MIKROBUS( cfg, mikrobus ) \
52 cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
53 cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX )
60#define CANISOLATOR_RETVAL uint8_t
61
62#define CANISOLATOR_OK 0x00
63#define CANISOLATOR_INIT_ERROR 0xFF
70#define DRV_RX_BUFFER_SIZE 500 // End group macro
74// --------------------------------------------------------------- PUBLIC TYPES
84typedef struct
85{
86 // Modules
87
88 uart_t uart;
89
90 char uart_rx_buffer[ DRV_RX_BUFFER_SIZE ];
91 char uart_tx_buffer[ DRV_RX_BUFFER_SIZE ];
92
94
98typedef struct
99{
100 // Communication gpio pins
101
102 pin_name_t rx_pin;
103 pin_name_t tx_pin;
104
105 // static variable
106
107 uint32_t baud_rate; // Clock speed.
109 uart_data_bits_t data_bit; // Data bits.
110 uart_parity_t parity_bit; // Parity bit.
111 uart_stop_bits_t stop_bit; // Stop bits.
112
114 // End types group
116// ------------------------------------------------------------------ CONSTANTS // End constants group
125// ------------------------------------------------------------------ VARIABLES // End variable group
133// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
134
140#ifdef __cplusplus
141extern "C"{
142#endif
143
153
162
172void canisolator_generic_multi_write ( canisolator_t *ctx, char *data_buf, uint8_t len );
173
183void canisolator_generic_multi_read ( canisolator_t *ctx, char *data_buf, uint8_t len );
184
185
195
205
206#ifdef __cplusplus
207}
208#endif
209#endif // _CANISOLATOR_H_
210 // End public_function group
213
214// ------------------------------------------------------------------------- END
#define DRV_RX_BUFFER_SIZE
Definition: canisolator.h:70
#define CANISOLATOR_RETVAL
Definition: canisolator.h:60
void canisolator_generic_multi_read(canisolator_t *ctx, char *data_buf, uint8_t len)
Generic multi read function.
void canisolator_generic_single_write(canisolator_t *ctx, char tx_data)
Generic single write function.
void canisolator_generic_multi_write(canisolator_t *ctx, char *data_buf, uint8_t len)
Generic multi write function.
CANISOLATOR_RETVAL canisolator_init(canisolator_t *ctx, canisolator_cfg_t *cfg)
Initialization function.
char canisolator_generic_single_read(canisolator_t *ctx)
Generic single read function.
void canisolator_cfg_setup(canisolator_cfg_t *cfg)
Config Object Initialization function.
Click configuration structure definition.
Definition: canisolator.h:99
uint32_t baud_rate
Definition: canisolator.h:107
bool uart_blocking
Definition: canisolator.h:108
uart_data_bits_t data_bit
Definition: canisolator.h:109
pin_name_t tx_pin
Definition: canisolator.h:103
pin_name_t rx_pin
Definition: canisolator.h:102
uart_stop_bits_t stop_bit
Definition: canisolator.h:111
uart_parity_t parity_bit
Definition: canisolator.h:110
Click ctx object definition.
Definition: canisolator.h:85
uart_t uart
Definition: canisolator.h:88