/*
 * NAND_FLASH_test.h
 *
 *  Created on: 3.12.2012
 *      Author: sidorov.a
 */

#ifndef NAND_FLASH_TEST_H_
#define NAND_FLASH_TEST_H_


//
#define	FULL_CYCLE		 	(0<<13)
#define INSTRUCTION_CYCLE	(1<<13)
#define READ_CYCLE			(1<<14)
#define RECYCLER			(3<<13)


//
#define CEB4				(1<<12)
#define NVRB4				(1<<11)
#define CEB3				(1<<10)
#define NVRB3				(1<<9)
#define CEB2				(1<<8)
#define NVRB2				(1<<7)
#define CEB1				(1<<6)
#define NVRB1				(1<<5)
#define OEB					(1<<4)
#define WEB					(1<<3)
#define TMEN                (0<<2)
#define BYTEB_16			(1<<1)
#define BYTEB_8				(0<<1)
#define VREAD 				(0<<0)


//
#define FLASH_SECTOR_1		(1<<6)
#define FLASH_SECTOR_2		(1<<8)
#define FLASH_SECTOR_3		(1<<10)
#define FLASH_SECTOR_4		(1<<12)


//
//Адреса для командных последовательностей
#define ADDR_555	0x0AAA
#define ADDR_AAA    0x0555
#define ADDR_555_16 0xAAA0

// Данные для командных последовательностей
#define DATA_AA 	0x0055
#define DATA_55		0x00AA
#define DATA_A0		0x0005
#define DATA_10  	0x0800
#define DATA_80 	0x0001
#define DATA_50		0x000A

//
#define ERR_OK 						 0	//
#define ERR_DATA_NOT_WRITTEN		-1
#define ERR_SECTOR_NOT_ERRASE		-2

// Прототипы функций
void vTest_Ext_FLASH( void );
uint32_t Write_Halfword_To_Flash(uint16_t addr, uint16_t data, uint32_t Num_block);
uint32_t Erase_Sector_Flash(uint32_t Num_Sector);
uint16_t Read_Halfword_From_Flash(uint16_t addr, uint32_t Num_block);

#endif /* NAND_FLASH_TEST_H_ */
