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
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
73#define ATA6571_OPERATING_MODE_SLEEP 0x00
74#define ATA6571_OPERATING_MODE_STANDBY 0x01
75#define ATA6571_OPERATING_MODE_SILENT 0x02
76#define ATA6571_OPERATING_MODE_NORMAL 0x03
77
82#define ATA6571_PIN_STATE_LOW 0x00
83#define ATA6571_PIN_STATE_HIGH 0x01
84
90#define DRV_BUFFER_SIZE 200
91
92 // ata6571_set
93
108#define ATA6571_MAP_MIKROBUS( cfg, mikrobus ) \
109 cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
110 cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
111 cfg.nstb = MIKROBUS( mikrobus, MIKROBUS_AN ); \
112 cfg.nerr = MIKROBUS( mikrobus, MIKROBUS_RST ); \
113 cfg.en = MIKROBUS( mikrobus, MIKROBUS_CS );
114
115 // ata6571_map
116 // ata6571
117
122typedef struct
123{
124 // Output pins
125 digital_out_t nstb;
126 digital_out_t en;
128 // Input pins
129 digital_in_t nerr;
131 // Modules
132 uart_t uart;
134 // Buffers
135 char uart_rx_buffer[ DRV_BUFFER_SIZE ];
136 char uart_tx_buffer[ DRV_BUFFER_SIZE ];
138} ata6571_t;
139
144typedef struct
145{
146 // Communication gpio pins
147 pin_name_t rx_pin;
148 pin_name_t tx_pin;
150 // Additional gpio pins
151 pin_name_t nstb;
152 pin_name_t nerr;
153 pin_name_t en;
155 // Static variable
156 uint32_t baud_rate;
158 uart_data_bits_t data_bit;
159 uart_parity_t parity_bit;
160 uart_stop_bits_t stop_bit;
163
168typedef enum
169{
171 ATA6571_ERROR = -1
172
174
191
207
221err_t ata6571_generic_write ( ata6571_t *ctx, char *data_buf, uint16_t len );
222
236err_t ata6571_generic_read ( ata6571_t *ctx, char *data_buf, uint16_t max_len );
237
247void ata6571_set_nstb_pin ( ata6571_t *ctx, uint8_t state );
248
258void ata6571_set_en_pin ( ata6571_t *ctx, uint8_t state );
259
269
282void ata6571_set_operating_mode ( ata6571_t *ctx, uint8_t op_mode );
283
284#ifdef __cplusplus
285}
286#endif
287#endif // ATA6571_H
288
289 // ata6571
290
291// ------------------------------------------------------------------------ END
ata6571_return_value_t
ATA6571 Click return value data.
Definition ata6571.h:169
@ ATA6571_OK
Definition ata6571.h:170
@ ATA6571_ERROR
Definition ata6571.h:171
#define DRV_BUFFER_SIZE
ATA6571 driver buffer size.
Definition ata6571.h:90
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:145
uint32_t baud_rate
Definition ata6571.h:156
pin_name_t nstb
Definition ata6571.h:151
bool uart_blocking
Definition ata6571.h:157
pin_name_t nerr
Definition ata6571.h:152
uart_data_bits_t data_bit
Definition ata6571.h:158
pin_name_t tx_pin
Definition ata6571.h:148
pin_name_t rx_pin
Definition ata6571.h:147
uart_stop_bits_t stop_bit
Definition ata6571.h:160
pin_name_t en
Definition ata6571.h:153
uart_parity_t parity_bit
Definition ata6571.h:159
ATA6571 Click context object.
Definition ata6571.h:123
digital_out_t nstb
Definition ata6571.h:125
uart_t uart
Definition ata6571.h:132
digital_out_t en
Definition ata6571.h:126
digital_in_t nerr
Definition ata6571.h:129