|
|
/*------------------------------------------------------------------------------
|
|
|
-- This file is a part of the libuc, microcontroler library
|
|
|
-- Copyright (C) 2013, Alexis Jeandet
|
|
|
--
|
|
|
-- This program is free software; you can redistribute it and/or modify
|
|
|
-- it under the terms of the GNU General Public License as published by
|
|
|
-- the Free Software Foundation; either version 3 of the License, or
|
|
|
-- (at your option) any later version.
|
|
|
--
|
|
|
-- This program is distributed in the hope that it will be useful,
|
|
|
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
-- GNU General Public License for more details.
|
|
|
--
|
|
|
-- You should have received a copy of the GNU General Public License
|
|
|
-- along with this program; if not, write to the Free Software
|
|
|
-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
-------------------------------------------------------------------------------
|
|
|
-- Author : Alexis Jeandet
|
|
|
-- Mail : alexis.jeandet@member.fsf.org
|
|
|
-------------------------------------------------------------------------------*/
|
|
|
#ifndef N25Q128_H
|
|
|
#define N25Q128_H
|
|
|
|
|
|
#include <spi.h>
|
|
|
|
|
|
typedef struct eepromN25Q128Dev
|
|
|
{
|
|
|
spi_t spidev;
|
|
|
void (*select)(int sel);
|
|
|
void (*writeprotect)(int wp);
|
|
|
void (*holdreset)(int hr);
|
|
|
}eepromN25Q128Dev;
|
|
|
|
|
|
#define N25Q128_PAGE_SZ 256
|
|
|
#define N25Q128_CAPACITY_IN_BYTES (1024*1024*16) /*16MB*/
|
|
|
|
|
|
#define N25Q128_READID 0x9E
|
|
|
#define N25Q128_READ 0x03
|
|
|
#define N25Q128_FASTREAD 0x0B
|
|
|
#define N25Q128_DOFR 0x3B
|
|
|
#define N25Q128_DIOFR 0xBB
|
|
|
#define N25Q128_QOFR 0x6B
|
|
|
#define N25Q128_QIOFR 0xEB
|
|
|
#define N25Q128_ROTP 0x4B
|
|
|
#define N25Q128_WREN 0x06
|
|
|
#define N25Q128_WRDI 0x04
|
|
|
#define N25Q128_PP 0x02
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
extern void eepromN25Q128open(eepromN25Q128Dev* dev,spi_t spidev,void (*select)(int sel),void (*writeprotect)(int wp),void (*holdreset)(int hr));
|
|
|
extern void eepromN25Q128pagewrite(eepromN25Q128Dev* dev,uint32_t address,unsigned char* page);
|
|
|
extern void eepromN25Q128pageread(eepromN25Q128Dev* dev,uint32_t address,unsigned char* page);
|
|
|
extern void eepromN25Q128bytewrite(eepromN25Q128Dev* dev,uint32_t address,unsigned char data);
|
|
|
extern unsigned char eepromN25Q128byteread(eepromN25Q128Dev* dev,uint32_t address);
|
|
|
extern void eepromN25Q128readn(eepromN25Q128Dev* dev,uint32_t address,unsigned char* data, unsigned int count);
|
|
|
extern void eepromN25Q128writen(eepromN25Q128Dev* dev,uint32_t address,unsigned char* data, unsigned int count);
|
|
|
extern void eepromN25Q128enablewrite(eepromN25Q128Dev* dev);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|