source: arduino-1-6-7/trunk/fuentes/arduino-ide-amd64/libraries/WiFi/extras/wifiHD/src/SOFTWARE_FRAMEWORK/COMPONENTS/MEMORY/DATA_FLASH/AT45DBX/at45dbx.h @ 46

Last change on this file since 46 was 46, checked in by jrpelegrina, 4 years ago

First release to Xenial

File size: 7.6 KB
Line 
1/* This header file is part of the ATMEL AVR-UC3-SoftwareFramework-1.7.0 Release */
2
3/*This file is prepared for Doxygen automatic documentation generation.*/
4/*! \file *********************************************************************
5 *
6 * \brief Management of the AT45DBX data flash controller through SPI.
7 *
8 * This file manages the accesses to the AT45DBX data flash components.
9 *
10 * - Compiler:           IAR EWAVR32 and GNU GCC for AVR32
11 * - Supported devices:  All AVR32 devices with an SPI module can be used.
12 * - AppNote:
13 *
14 * \author               Atmel Corporation: http://www.atmel.com \n
15 *                       Support and FAQ: http://support.atmel.no/
16 *
17 ******************************************************************************/
18
19/* Copyright (c) 2009 Atmel Corporation. All rights reserved.
20 *
21 * Redistribution and use in source and binary forms, with or without
22 * modification, are permitted provided that the following conditions are met:
23 *
24 * 1. Redistributions of source code must retain the above copyright notice, this
25 * list of conditions and the following disclaimer.
26 *
27 * 2. Redistributions in binary form must reproduce the above copyright notice,
28 * this list of conditions and the following disclaimer in the documentation
29 * and/or other materials provided with the distribution.
30 *
31 * 3. The name of Atmel may not be used to endorse or promote products derived
32 * from this software without specific prior written permission.
33 *
34 * 4. This software may only be redistributed and used in connection with an Atmel
35 * AVR product.
36 *
37 * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
38 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
39 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
40 * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
41 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
42 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
43 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
44 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
45 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
46 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
47 *
48 */
49
50#ifndef _AT45DBX_H_
51#define _AT45DBX_H_
52
53
54#include "conf_access.h"
55
56#if AT45DBX_MEM == DISABLE
57  #error at45dbx.h is #included although AT45DBX_MEM is disabled
58#endif
59
60
61#include "spi.h"
62
63
64//_____ D E F I N I T I O N S ______________________________________________
65
66/*! \name Available AT45DBX Sizes
67 *
68 * Number of address bits of available AT45DBX data flash memories.
69 *
70 * \note Only memories with page sizes of at least 512 bytes (sector size) are
71 *       supported.
72 */
73//! @{
74#define AT45DBX_1MB             20
75#define AT45DBX_2MB             21
76#define AT45DBX_4MB             22
77#define AT45DBX_8MB             23
78//! @}
79
80// AT45DBX_1MB
81#define AT45DBX_SECTOR_BITS                             8                 //! Number of bits for addresses within sectors.
82// AT45DBX_2MB AT45DBX_4MB AT45DBX_8MB
83//#define AT45DBX_SECTOR_BITS                           9                 //! Number of bits for addresses within sectors.
84
85//! Sector size in bytes.
86#define AT45DBX_SECTOR_SIZE     (1 << AT45DBX_SECTOR_BITS)
87
88
89//_____ D E C L A R A T I O N S ____________________________________________
90
91/*! \name Control Functions
92 */
93//! @{
94
95/*! \brief Initializes the data flash controller and the SPI channel by which
96 *         the DF is controlled.
97 *
98 * \param spiOptions  Initialization options of the DF SPI channel.
99 * \param pba_hz      SPI module input clock frequency (PBA clock, Hz).
100 *
101 * \retval OK Success.
102 * \retval KO Failure.
103 */
104extern Bool at45dbx_init(spi_options_t spiOptions, unsigned int pba_hz);
105
106/*! \brief Performs a memory check on all DFs.
107 *
108 * \retval OK Success.
109 * \retval KO Failure.
110 */
111extern Bool at45dbx_mem_check(void);
112
113/*! \brief Opens a DF memory in read mode at a given sector.
114 *
115 * \param sector  Start sector.
116 *
117 * \retval OK Success.
118 * \retval KO Failure.
119 *
120 * \note Sector may be page-unaligned (depending on the DF page size).
121 */
122extern Bool at45dbx_read_open(U32 sector);
123
124/*! \brief Unselects the current DF memory.
125 */
126extern void at45dbx_read_close(void);
127
128/*! \brief This function opens a DF memory in write mode at a given sector.
129 *
130 * \param sector  Start sector.
131 *
132 * \retval OK Success.
133 * \retval KO Failure.
134 *
135 * \note Sector may be page-unaligned (depending on the DF page size).
136 *
137 * \note If \ref AT45DBX_PAGE_SIZE > \ref AT45DBX_SECTOR_SIZE, page content is
138 *       first loaded in buffer to then be partially updated by write byte or
139 *       write sector functions.
140 */
141extern Bool at45dbx_write_open(U32 sector);
142
143/*! \brief Fills the end of the current logical sector and launches page programming.
144 */
145extern void at45dbx_write_close(void);
146
147//! @}
148
149
150/*! \name Single-Byte Access Functions
151 */
152//! @{
153
154/*! \brief Performs a single byte read from DF memory.
155 *
156 * \return The read byte.
157 *
158 * \note First call must be preceded by a call to the \ref at45dbx_read_open
159 *       function.
160 */
161extern U8 at45dbx_read_byte(void);
162
163/*! \brief Performs a single byte write to DF memory.
164 *
165 * \param b The byte to write.
166 *
167 * \retval OK Success.
168 * \retval KO Failure.
169 *
170 * \note First call must be preceded by a call to the \ref at45dbx_write_open
171 *       function.
172 */
173extern Bool at45dbx_write_byte(U8 b);
174
175//! @}
176
177
178/*! \name Multiple-Sector Access Functions
179 */
180//! @{
181
182/*! \brief Reads \a nb_sector sectors from DF memory.
183 *
184 * Data flow is: DF -> callback.
185 *
186 * \param nb_sector Number of contiguous sectors to read.
187 *
188 * \retval OK Success.
189 * \retval KO Failure.
190 *
191 * \note First call must be preceded by a call to the \ref at45dbx_read_open
192 *       function.
193 *
194 * \note As \ref AT45DBX_PAGE_SIZE is always a multiple of
195 *       \ref AT45DBX_SECTOR_SIZE, there is no need to check page end for each
196 *       byte.
197 */
198extern Bool at45dbx_read_multiple_sector(U16 nb_sector);
199
200/*! \brief Callback function invoked after each sector read during
201 *         \ref at45dbx_read_multiple_sector.
202 *
203 * \param psector Pointer to read sector.
204 */
205extern void at45dbx_read_multiple_sector_callback(const void *psector);
206
207/*! \brief Writes \a nb_sector sectors to DF memory.
208 *
209 * Data flow is: callback -> DF.
210 *
211 * \param nb_sector Number of contiguous sectors to write.
212 *
213 * \retval OK Success.
214 * \retval KO Failure.
215 *
216 * \note First call must be preceded by a call to the \ref at45dbx_write_open
217 *       function.
218 *
219 * \note As \ref AT45DBX_PAGE_SIZE is always a multiple of
220 *       \ref AT45DBX_SECTOR_SIZE, there is no need to check page end for each
221 *       byte.
222 */
223extern Bool at45dbx_write_multiple_sector(U16 nb_sector);
224
225/*! \brief Callback function invoked before each sector write during
226 *         \ref at45dbx_write_multiple_sector.
227 *
228 * \param psector Pointer to sector to write.
229 */
230extern void at45dbx_write_multiple_sector_callback(void *psector);
231
232//! @}
233
234
235/*! \name Single-Sector Access Functions
236 */
237//! @{
238
239/*! \brief Reads 1 DF sector to a RAM buffer.
240 *
241 * Data flow is: DF -> RAM.
242 *
243 * \param ram Pointer to RAM buffer.
244 *
245 * \retval OK Success.
246 * \retval KO Failure.
247 *
248 * \note First call must be preceded by a call to the \ref at45dbx_read_open
249 *       function.
250 */
251extern Bool at45dbx_read_sector_2_ram(void *ram);
252
253/*! \brief Writes 1 DF sector from a RAM buffer.
254 *
255 * Data flow is: RAM -> DF.
256 *
257 * \param ram Pointer to RAM buffer.
258 *
259 * \retval OK Success.
260 * \retval KO Failure.
261 *
262 * \note First call must be preceded by a call to the \ref at45dbx_write_open
263 *       function.
264 */
265extern Bool at45dbx_write_sector_from_ram(const void *ram);
266
267//! @}
268
269
270#endif  // _AT45DBX_H_
Note: See TracBrowser for help on using the repository browser.