2 * Copyright © 2008 Keith Packard <keithp@keithp.com>
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; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
59 #define nop() _asm nop _endasm;
62 delay (unsigned char n)
92 out_byte(uint8_t byte)
96 for (s = 0; s < 8; s++) {
97 uint8_t b = (byte & 0x80) ? 1 : 0;
123 for (s = 0; s < 8; s++) {
160 write(uint32_t addr, uint8_t *bytes, uint16_t len)
165 out_byte(addr >> 16);
172 uint8_t status = rdsr();
173 if ((status & (1 << 0)) == 0)
179 read(uint32_t addr, uint8_t *bytes, uint16_t len)
183 out_byte(addr >> 16);
187 *bytes++ = in_byte();
192 debug_byte(uint8_t byte)
196 for (s = 0; s < 8; s++) {
223 * Turn off both block-protect bits
225 status &= ~((1 << 3) | (1 << 2));
227 * Turn off write protect enable
231 write(0x0, STRING, LENGTH);
233 read(0x0, buf, LENGTH);
234 for (i = 0; i < LENGTH; i++)