Fix all stdio reading functions to be __critical
[fw/altos] / src / at45db161d.h
1 /*
2  * Copyright © 2010 Keith Packard <keithp@keithp.com>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; version 2 of the License.
7  *
8  * This program is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11  * General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License along
14  * with this program; if not, write to the Free Software Foundation, Inc.,
15  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
16  */
17
18 /* Defines for the Atmel AT45DB161D 16Mbit SPI Bus DataFlash® */
19
20 #ifndef _AT45DB161D_H_
21 #define _AT45DB161D_H_
22
23 /*
24  * We reserve the last block on the device for
25  * configuration space. Writes and reads in this
26  * area return errors.
27  */
28
29 #define FLASH_BLOCK_SIZE_MAX    512
30 #define FLASH_BLOCK_SHIFT       (ao_flash_block_shift)
31 #define FLASH_BLOCK_SIZE        (ao_flash_block_size)
32 #define FLASH_BLOCK_MASK        (FLASH_BLOCK_SIZE - 1)
33 #define FLASH_DEVICE_SIZE       (ao_flash_device_size)
34 #define FLASH_DATA_SIZE         (FLASH_DEVICE_SIZE - (uint32_t) FLASH_BLOCK_SIZE)
35 #define FLASH_CONFIG_BLOCK      ((uint16_t) (FLASH_DATA_SIZE / FLASH_BLOCK_SIZE))
36
37 #define FLASH_READ              0x03
38 #define FLASH_WRITE             0x82
39 #define FLASH_READ_STATUS       0xd7
40 #define FLASH_SET_CONFIG        0x3d
41
42 #define FLASH_SET_512_BYTE_0    0x2a
43 #define FLASH_SET_512_BYTE_1    0x80
44 #define FLASH_SET_512_BYTE_2    0xa6
45
46 #define FLASH_STATUS_RDY                (1 << 7)
47 #define FLASH_STATUS_COMP               (1 << 6)
48 #define FLASH_STATUS_PROTECT            (1 << 1)
49 #define FLASH_STATUS_PAGESIZE_512       (1 << 0)
50
51 #endif /* _AT45DB161D_H_ */