ata6501 2.2.0
Loading...
Searching...
No Matches
ata6501.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
27
28#ifndef ATA6501_H
29#define ATA6501_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
58
63
68
74#define ATA6501_TX_DRV_BUFFER_SIZE 100
75#define ATA6501_RX_DRV_BUFFER_SIZE 300
76 // ata6501_cmd
78
83
88
93#define ATA6501_MAP_MIKROBUS( cfg, mikrobus ) \
94 cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
95 cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
96 cfg.en = MIKROBUS( mikrobus, MIKROBUS_PWM );
97 // ata6501_map // ata6501
100
105typedef struct
106{
107 // Output pins
108 digital_out_t en;
109
110 // Modules
111 uart_t uart;
112
113 // Buffers
116
117} ata6501_t;
118
123typedef struct
124{
125 // Communication gpio pins
126 pin_name_t rx_pin;
127 pin_name_t tx_pin;
128
129 // Additional gpio pins
130 pin_name_t en;
131
132 // Static variable
133 uint32_t baud_rate;
135 uart_data_bits_t data_bit;
136 uart_parity_t parity_bit;
137 uart_stop_bits_t stop_bit;
138
140
145typedef enum
146{
149
151
157
168
183
196err_t ata6501_generic_write ( ata6501_t *ctx, uint8_t *data_in, uint16_t len );
197
210err_t ata6501_generic_read ( ata6501_t *ctx, uint8_t *data_out, uint16_t len );
211
221void ata6501_set_en_pin ( ata6501_t *ctx, uint8_t state );
222
223#ifdef __cplusplus
224}
225#endif
226#endif // ATA6501_H
227 // ata6501
229
230// ------------------------------------------------------------------------ END
ata6501_return_value_t
ATA6501 Click return value data.
Definition ata6501.h:146
@ ATA6501_OK
Definition ata6501.h:147
@ ATA6501_ERROR
Definition ata6501.h:148
#define ATA6501_TX_DRV_BUFFER_SIZE
ATA6501 driver buffer size.
Definition ata6501.h:74
#define ATA6501_RX_DRV_BUFFER_SIZE
Definition ata6501.h:75
err_t ata6501_generic_write(ata6501_t *ctx, uint8_t *data_in, uint16_t len)
ATA6501 data writing function.
err_t ata6501_init(ata6501_t *ctx, ata6501_cfg_t *cfg)
ATA6501 initialization function.
void ata6501_set_en_pin(ata6501_t *ctx, uint8_t state)
ATA6501 set EN pin function.
err_t ata6501_generic_read(ata6501_t *ctx, uint8_t *data_out, uint16_t len)
ATA6501 data reading function.
void ata6501_cfg_setup(ata6501_cfg_t *cfg)
ATA6501 configuration object setup function.
ATA6501 Click configuration object.
Definition ata6501.h:124
uint32_t baud_rate
Definition ata6501.h:133
bool uart_blocking
Definition ata6501.h:134
uart_data_bits_t data_bit
Definition ata6501.h:135
pin_name_t tx_pin
Definition ata6501.h:127
pin_name_t rx_pin
Definition ata6501.h:126
uart_stop_bits_t stop_bit
Definition ata6501.h:137
pin_name_t en
Definition ata6501.h:130
uart_parity_t parity_bit
Definition ata6501.h:136
ATA6501 Click context object.
Definition ata6501.h:106
uart_t uart
Definition ata6501.h:111
uint8_t uart_rx_buffer[ATA6501_RX_DRV_BUFFER_SIZE]
Definition ata6501.h:114
uint8_t uart_tx_buffer[ATA6501_TX_DRV_BUFFER_SIZE]
Definition ata6501.h:115
digital_out_t en
Definition ata6501.h:108