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
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 DRV_BUFFER_SIZE 200
61  // iso9141_cmd
63 
78 #define ISO9141_MAP_MIKROBUS( cfg, mikrobus ) \
79  cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
80  cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
81 
82  // iso9141_map // iso9141
84 
89 typedef struct
90 {
91  // Modules
92  uart_t uart;
94  // Buffers
95  char uart_rx_buffer[ DRV_BUFFER_SIZE ];
96  char uart_tx_buffer[ DRV_BUFFER_SIZE ];
98 } iso9141_t;
99 
104 typedef struct
105 {
106  // Communication gpio pins
107  pin_name_t rx_pin;
108  pin_name_t tx_pin;
110  // Static variable
111  uint32_t baud_rate;
113  uart_data_bits_t data_bit;
114  uart_parity_t parity_bit;
115  uart_stop_bits_t stop_bit;
117 } iso9141_cfg_t;
118 
123 typedef enum
124 {
126  ISO9141_ERROR = -1
127 
129 
146 
161 err_t iso9141_init ( iso9141_t *ctx, iso9141_cfg_t *cfg );
162 
176 err_t iso9141_generic_write ( iso9141_t *ctx, char *data_buf, uint16_t len );
177 
191 err_t iso9141_generic_read ( iso9141_t *ctx, char *data_buf, uint16_t max_len );
192 
205 err_t iso9141_send_data ( iso9141_t *ctx, char *tx_data );
206 
207 #ifdef __cplusplus
208 }
209 #endif
210 #endif // ISO9141_H
211  // iso9141
213 
214 // ------------------------------------------------------------------------ END
DRV_BUFFER_SIZE
#define DRV_BUFFER_SIZE
ISO 9141 driver buffer size.
Definition: iso9141.h:60
ISO9141_ERROR
@ ISO9141_ERROR
Definition: iso9141.h:126
iso9141_generic_read
err_t iso9141_generic_read(iso9141_t *ctx, char *data_buf, uint16_t max_len)
ISO 9141 data reading function.
iso9141_return_value_t
iso9141_return_value_t
ISO 9141 Click return value data.
Definition: iso9141.h:124
iso9141_cfg_t::uart_blocking
bool uart_blocking
Definition: iso9141.h:112
iso9141_cfg_t::data_bit
uart_data_bits_t data_bit
Definition: iso9141.h:113
iso9141_cfg_t::rx_pin
pin_name_t rx_pin
Definition: iso9141.h:107
iso9141_generic_write
err_t iso9141_generic_write(iso9141_t *ctx, char *data_buf, uint16_t len)
ISO 9141 data writing function.
ISO9141_OK
@ ISO9141_OK
Definition: iso9141.h:125
iso9141_cfg_t::baud_rate
uint32_t baud_rate
Definition: iso9141.h:111
iso9141_cfg_t::stop_bit
uart_stop_bits_t stop_bit
Definition: iso9141.h:115
iso9141_cfg_t::parity_bit
uart_parity_t parity_bit
Definition: iso9141.h:114
iso9141_t::uart
uart_t uart
Definition: iso9141.h:92
iso9141_send_data
err_t iso9141_send_data(iso9141_t *ctx, char *tx_data)
ISO 9141 send data function.
iso9141_cfg_t
ISO 9141 Click configuration object.
Definition: iso9141.h:105
iso9141_t
ISO 9141 Click context object.
Definition: iso9141.h:90
iso9141_cfg_t::tx_pin
pin_name_t tx_pin
Definition: iso9141.h:108
iso9141_cfg_setup
void iso9141_cfg_setup(iso9141_cfg_t *cfg)
ISO 9141 configuration object setup function.
iso9141_init
err_t iso9141_init(iso9141_t *ctx, iso9141_cfg_t *cfg)
ISO 9141 initialization function.