iso9141 2.0.0.0
iso9141.h
Go to the documentation of this file.
1/****************************************************************************
2** Copyright (C) 2021 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 ISO9141_H
29#define ISO9141_H
30
31#ifdef __cplusplus
32extern "C"{
33#endif
34
39#ifdef PREINIT_SUPPORTED
40#include "preinit.h"
41#endif
42
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
45 #include "delays.h"
46 #endif
47#endif
48
49#include "drv_digital_out.h"
50#include "drv_digital_in.h"
51#include "drv_uart.h"
52
74#define ISO9141_TX_DRV_BUFFER_SIZE 100
75#define ISO9141_RX_DRV_BUFFER_SIZE 300
76
77 // iso9141_set
78
93#define ISO9141_MAP_MIKROBUS( cfg, mikrobus ) \
94 cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
95 cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
96
97 // iso9141_map
98 // iso9141
99
104typedef struct
105{
106 // Modules
107 uart_t uart;
109 // Buffers
110 uint8_t uart_rx_buffer[ ISO9141_RX_DRV_BUFFER_SIZE ];
111 uint8_t uart_tx_buffer[ ISO9141_TX_DRV_BUFFER_SIZE ];
113} iso9141_t;
114
119typedef struct
120{
121 // Communication gpio pins
122 pin_name_t rx_pin;
123 pin_name_t tx_pin;
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 ISO9141_ERROR = -1
142
144
161
176
189err_t iso9141_generic_write ( iso9141_t *ctx, uint8_t *data_buf, uint16_t len );
190
203err_t iso9141_generic_read ( iso9141_t *ctx, uint8_t *data_buf, uint16_t max_len );
204
205#ifdef __cplusplus
206}
207#endif
208#endif // ISO9141_H
209
210 // iso9141
211
212// ------------------------------------------------------------------------ END
#define ISO9141_RX_DRV_BUFFER_SIZE
Definition iso9141.h:75
#define ISO9141_TX_DRV_BUFFER_SIZE
ISO 9141 driver buffer size.
Definition iso9141.h:74
err_t iso9141_init(iso9141_t *ctx, iso9141_cfg_t *cfg)
ISO 9141 initialization function.
void iso9141_cfg_setup(iso9141_cfg_t *cfg)
ISO 9141 configuration object setup function.
err_t iso9141_generic_read(iso9141_t *ctx, uint8_t *data_buf, uint16_t max_len)
ISO 9141 data reading function.
err_t iso9141_generic_write(iso9141_t *ctx, uint8_t *data_buf, uint16_t len)
ISO 9141 data writing function.
iso9141_return_value_t
ISO 9141 Click return value data.
Definition iso9141.h:139
@ ISO9141_OK
Definition iso9141.h:140
@ ISO9141_ERROR
Definition iso9141.h:141
ISO 9141 Click configuration object.
Definition iso9141.h:120
uint32_t baud_rate
Definition iso9141.h:126
bool uart_blocking
Definition iso9141.h:127
uart_data_bits_t data_bit
Definition iso9141.h:128
pin_name_t tx_pin
Definition iso9141.h:123
pin_name_t rx_pin
Definition iso9141.h:122
uart_stop_bits_t stop_bit
Definition iso9141.h:130
uart_parity_t parity_bit
Definition iso9141.h:129
ISO 9141 Click context object.
Definition iso9141.h:105
uart_t uart
Definition iso9141.h:107