canfd7 2.1.0.0
canfd7.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 CANFD7_H
29#define CANFD7_H
30
31#ifdef __cplusplus
32extern "C"{
33#endif
34
35#include "drv_digital_out.h"
36#include "drv_digital_in.h"
37#include "drv_uart.h"
38
59#define CANFD7_STANDBY_ON 0x01
60#define CANFD7_STANDBY_OFF 0x00
61
67#define CANFD7_TX_DRV_BUFFER_SIZE 100
68#define CANFD7_RX_DRV_BUFFER_SIZE 300
69 // canfd7_cmd
71
86#define CANFD7_MAP_MIKROBUS( cfg, mikrobus ) \
87 cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
88 cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
89 cfg.stb = MIKROBUS( mikrobus, MIKROBUS_RST )
90 // canfd7_map // canfd7
93
98typedef struct
99{
100 // Output pins
101 digital_out_t stb;
103 // Modules
104 uart_t uart;
106 // Buffers
107 uint8_t uart_rx_buffer[ CANFD7_RX_DRV_BUFFER_SIZE ];
108 uint8_t uart_tx_buffer[ CANFD7_TX_DRV_BUFFER_SIZE ];
110} canfd7_t;
111
116typedef struct
117{
118 // Communication gpio pins
119 pin_name_t rx_pin;
120 pin_name_t tx_pin;
122 // Additional gpio pins
123 pin_name_t stb;
125 // Static variable
126 uint32_t baud_rate;
128 uart_data_bits_t data_bit;
129 uart_parity_t parity_bit;
130 uart_stop_bits_t stop_bit;
133
138typedef enum
139{
141 CANFD7_ERROR = -1
142
144
161
175err_t canfd7_init ( canfd7_t *ctx, canfd7_cfg_t *cfg );
176
188
201err_t canfd7_generic_write ( canfd7_t *ctx, uint8_t *data_in, uint16_t len );
202
215err_t canfd7_generic_read ( canfd7_t *ctx, uint8_t *data_out, uint16_t len );
216
226void canfd7_set_stb_pin ( canfd7_t *ctx, uint8_t pin_state );
227
228#ifdef __cplusplus
229}
230#endif
231#endif // CANFD7_H
232 // canfd7
234
235// ------------------------------------------------------------------------ END
canfd7_return_value_t
CAN FD 7 Click return value data.
Definition: canfd7.h:139
@ CANFD7_OK
Definition: canfd7.h:140
@ CANFD7_ERROR
Definition: canfd7.h:141
#define CANFD7_TX_DRV_BUFFER_SIZE
CAN FD 7 driver buffer size.
Definition: canfd7.h:67
#define CANFD7_RX_DRV_BUFFER_SIZE
Definition: canfd7.h:68
void canfd7_cfg_setup(canfd7_cfg_t *cfg)
CAN FD 7 configuration object setup function.
err_t canfd7_generic_write(canfd7_t *ctx, uint8_t *data_in, uint16_t len)
CAN FD 7 data writing function.
void canfd7_set_stb_pin(canfd7_t *ctx, uint8_t pin_state)
CAN FD 7 set STB pin function.
err_t canfd7_generic_read(canfd7_t *ctx, uint8_t *data_out, uint16_t len)
CAN FD 7 data reading function.
void canfd7_default_cfg(canfd7_t *ctx)
CAN FD 7 default configuration function.
err_t canfd7_init(canfd7_t *ctx, canfd7_cfg_t *cfg)
CAN FD 7 initialization function.
CAN FD 7 Click configuration object.
Definition: canfd7.h:117
uint32_t baud_rate
Definition: canfd7.h:126
bool uart_blocking
Definition: canfd7.h:127
uart_data_bits_t data_bit
Definition: canfd7.h:128
pin_name_t tx_pin
Definition: canfd7.h:120
pin_name_t rx_pin
Definition: canfd7.h:119
uart_stop_bits_t stop_bit
Definition: canfd7.h:130
uart_parity_t parity_bit
Definition: canfd7.h:129
pin_name_t stb
Definition: canfd7.h:123
CAN FD 7 Click context object.
Definition: canfd7.h:99
digital_out_t stb
Definition: canfd7.h:101
uart_t uart
Definition: canfd7.h:104