ata6571 2.0.0.0
ata6571.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 ATA6571_H
29#define ATA6571_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 ATA6571_OPERATING_MODE_SLEEP 0x00
60#define ATA6571_OPERATING_MODE_STANDBY 0x01
61#define ATA6571_OPERATING_MODE_SILENT 0x02
62#define ATA6571_OPERATING_MODE_NORMAL 0x03
63
68#define ATA6571_PIN_STATE_LOW 0x00
69#define ATA6571_PIN_STATE_HIGH 0x01
70
76#define DRV_BUFFER_SIZE 200
77 // ata6571_set
79
94#define ATA6571_MAP_MIKROBUS( cfg, mikrobus ) \
95 cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
96 cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
97 cfg.nstb = MIKROBUS( mikrobus, MIKROBUS_AN ); \
98 cfg.nerr = MIKROBUS( mikrobus, MIKROBUS_RST ); \
99 cfg.en = MIKROBUS( mikrobus, MIKROBUS_CS );
100 // ata6571_map // ata6571
103
108typedef struct
109{
110 // Output pins
111 digital_out_t nstb;
112 digital_out_t en;
114 // Input pins
115 digital_in_t nerr;
117 // Modules
118 uart_t uart;
120 // Buffers
121 char uart_rx_buffer[ DRV_BUFFER_SIZE ];
122 char uart_tx_buffer[ DRV_BUFFER_SIZE ];
124} ata6571_t;
125
130typedef struct
131{
132 // Communication gpio pins
133 pin_name_t rx_pin;
134 pin_name_t tx_pin;
136 // Additional gpio pins
137 pin_name_t nstb;
138 pin_name_t nerr;
139 pin_name_t en;
141 // Static variable
142 uint32_t baud_rate;
144 uart_data_bits_t data_bit;
145 uart_parity_t parity_bit;
146 uart_stop_bits_t stop_bit;
149
154typedef enum
155{
157 ATA6571_ERROR = -1
158
160
177
193
207err_t ata6571_generic_write ( ata6571_t *ctx, char *data_buf, uint16_t len );
208
222err_t ata6571_generic_read ( ata6571_t *ctx, char *data_buf, uint16_t max_len );
223
233void ata6571_set_nstb_pin ( ata6571_t *ctx, uint8_t state );
234
244void ata6571_set_en_pin ( ata6571_t *ctx, uint8_t state );
245
255
268void ata6571_set_operating_mode ( ata6571_t *ctx, uint8_t op_mode );
269
270#ifdef __cplusplus
271}
272#endif
273#endif // ATA6571_H
274 // ata6571
276
277// ------------------------------------------------------------------------ END
ata6571_return_value_t
ATA6571 Click return value data.
Definition: ata6571.h:155
@ ATA6571_OK
Definition: ata6571.h:156
@ ATA6571_ERROR
Definition: ata6571.h:157
#define DRV_BUFFER_SIZE
ATA6571 driver buffer size.
Definition: ata6571.h:76
void ata6571_cfg_setup(ata6571_cfg_t *cfg)
ATA6571 configuration object setup function.
err_t ata6571_init(ata6571_t *ctx, ata6571_cfg_t *cfg)
ATA6571 initialization function.
uint8_t ata6571_get_nerr_pin(ata6571_t *ctx)
ATA6571 get error and power-on indication output function.
err_t ata6571_generic_write(ata6571_t *ctx, char *data_buf, uint16_t len)
ATA6571 data writing function.
void ata6571_set_en_pin(ata6571_t *ctx, uint8_t state)
ATA6571 set power control function.
void ata6571_set_nstb_pin(ata6571_t *ctx, uint8_t state)
ATA6571 set standby mode control function.
err_t ata6571_generic_read(ata6571_t *ctx, char *data_buf, uint16_t max_len)
ATA6571 data reading function.
void ata6571_set_operating_mode(ata6571_t *ctx, uint8_t op_mode)
ATA6571 set operating mode function.
ATA6571 Click configuration object.
Definition: ata6571.h:131
uint32_t baud_rate
Definition: ata6571.h:142
pin_name_t nstb
Definition: ata6571.h:137
bool uart_blocking
Definition: ata6571.h:143
pin_name_t nerr
Definition: ata6571.h:138
uart_data_bits_t data_bit
Definition: ata6571.h:144
pin_name_t tx_pin
Definition: ata6571.h:134
pin_name_t rx_pin
Definition: ata6571.h:133
uart_stop_bits_t stop_bit
Definition: ata6571.h:146
pin_name_t en
Definition: ata6571.h:139
uart_parity_t parity_bit
Definition: ata6571.h:145
ATA6571 Click context object.
Definition: ata6571.h:109
digital_out_t nstb
Definition: ata6571.h:111
uart_t uart
Definition: ata6571.h:118
digital_out_t en
Definition: ata6571.h:112
digital_in_t nerr
Definition: ata6571.h:115