📄 intel_k3_flash.h
字号:
/*
* File: intel_k3_flash.h
* Purpose: Flash driver for programming Intel Flash devices
*
* Notes: This driver supports a single banks of Intel Flash.
* A bank is defined as one or more of the same Flash
* device connected to a single chip-select.
*/
#ifndef _INTEL_K3_FLASH_H_
#define _INTEL_K3_FLASH_H_
/********************************************************************/
void
intel_k3_flash_init(ADDRESS);
int
intel_k3_flash_erase(ADDRESS, int, void(*)(char));
int
intel_k3_flash_program(ADDRESS, ADDRESS, int, int, void(*)(void), void(*)(char));
ADDRESS
intel_k3_flash_sector_start(ADDRESS);
ADDRESS
intel_k3_flash_sector_end(ADDRESS);
/********************************************************************/
#ifndef INTEL_K3_FLASH_DEVICES
#define INTEL_K3_FLASH_DEVICES 1
#endif
/********************************************************************/
/*
* Defines used to correctly address the Flash device(s)
*
* INTEL_K3_FLASH_BUS_SHIFT - Number of bits to right-shift the byte
* offsets of the sectors
* INTEL_K3_FLASH_CELL - Port size of Flash device(s)
* INTEL_K3_FLASH_CMD_DATA - Format of data when issuing commands
*
*/
#if (INTEL_K3_FLASH_DEVICES == 1)
#define INTEL_K3_FLASH_BUS_SHIFT 1
#define INTEL_K3_FLASH_CELL vuint16
#define INTEL_K3_FLASH_CELL_BYTES 2
#define INTEL_K3_FLASH_CELL_MASK 0x1
#define INTEL_K3_FLASH_CMD_DATA(x) ((uint16)x)
#elif (INTEL_K3_FLASH_DEVICES == 2)
#define INTEL_K3_FLASH_BUS_SHIFT 2
#define INTEL_K3_FLASH_CELL vuint32
#define INTEL_K3_FLASH_CELL_BYTES 4
#define INTEL_K3_FLASH_CELL_MASK 0x3
#define INTEL_K3_FLASH_CMD_DATA(x) ((uint32)((x<<16)|x))
#else
#error "Unsupported number of Flash devices"
#endif
/********************************************************************/
/*
* Flash sector definitions - addresses are given in bytes (not words!)
*/
#if (defined(INTEL_K3_FLASH_28F640K3) || defined(INTEL_K3_FLASH_28F640K18))
/*
* Uniform sectors of 128 KBytes
*/
#define INTEL_K3_FLASH_SECTORS 64
#define K3_SSIZE(n) (0x20000 * INTEL_K3_FLASH_DEVICES)
#define K3_SOFFSET(n) (0x20000 * n)
#define K3_SADDR(n) ((0x20000 * n) >> INTEL_K3_FLASH_BUS_SHIFT)
#elif (defined(INTEL_K3_FLASH_28F128K3) || defined(INTEL_K3_FLASH_28F128K18))
/*
* Uniform sectors of 128 KBytes
*/
#define INTEL_K3_FLASH_SECTORS 128
#define K3_SSIZE(n) (0x20000 * INTEL_K3_FLASH_DEVICES)
#define K3_SOFFSET(n) (0x20000 * n)
#define K3_SADDR(n) ((0x20000 * n) >> INTEL_K3_FLASH_BUS_SHIFT)
#elif (defined(INTEL_K3_FLASH_28F256K3) || defined(INTEL_K3_FLASH_28F256K18))
/*
* Uniform sectors of 128 KBytes
*/
#define INTEL_K3_FLASH_SECTORS 256
#define K3_SSIZE(n) (0x20000 * INTEL_K3_FLASH_DEVICES)
#define K3_SOFFSET(n) (0x20000 * n)
#define K3_SADDR(n) ((0x20000 * n) >> INTEL_K3_FLASH_BUS_SHIFT)
#else
#error "Unsupported Flash device"
#endif
/********************************************************************/
#endif /* _INTEL_K3_FLASH_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -