cfm_flash.h
来自「motorola 针对coldfire 5275 评估板的Dbug bootlo」· C头文件 代码 · 共 125 行
H
125 行
/*
* File: cfm_flash.h
* Purpose: Flash driver for programming the ColdFire Flash Module
*
* Notes: Based on the SSD CFM driver
*
*/
#ifndef _CFM_FLASH_H_
#define _CFM_FLASH_H_
/********************************************************************/
/*
* CFM configuration structure
*/
typedef struct {
uint32 RegBase; /* Base address of CFM control registers */
uint32 CoreBusBase; /* Base address of CFM core bus space */
uint32 IPSBase; /* Base address of CFM IPS space */
uint32 BlockSize; /* Size of CFM logical blocks */
uint32 BlockNum; /* Number of CFM logical blocks */
uint32 ISREnable; /* Interrupt mode or polling mode */
uint32 BDMEnable; /* Debug mode or embedded application mode */
} CFM_CONFIG;
/*
* Function prototypes
*/
void
cfm_flash_init(void);
int
cfm_flash_erase(ADDRESS, int, void(*)(char));
int
cfm_flash_program(ADDRESS, ADDRESS, int, int, void(*)(void), void(*)(char));
ADDRESS
cfm_flash_page_start(ADDRESS);
ADDRESS
cfm_flash_page_end(ADDRESS);
/********************************************************************/
/*
* Implementations specific settings
*/
#if (defined(CPU_MCF5282))
#define PGSZ (0x800) /* Page Size */
#define PGOFST(n) (PGSZ * n) /* Page Offset */
#define CFM_BLOCK_SIZE (0x40000) /* Logical Block Size */
#define CFM_BLOCK_NUM (2) /* Number of Logical Blocks */
#define CFM_FLASH_SIZE (CFM_BLOCK_SIZE * CFM_BLOCK_NUM)
#define CFM_FLASH_PAGES (CFM_FLASH_SIZE / PGSZ)
#define CFM_WORD_SIZE (0x4)
#define CFM_WORD_MASK (0x3)
#define CFM_WORD uint32
#elif (defined(CPU_MCF5213) || defined(CPU_MCF5212))
#define PGSZ (0x800) /* Page Size */
#define PGOFST(n) (PGSZ * n) /* Page Offset */
#define CFM_BLOCK_SIZE (0x40000) /* Logical Block Size */
#define CFM_BLOCK_NUM (1) /* Number of Logical Blocks */
#define CFM_FLASH_SIZE (CFM_BLOCK_SIZE * CFM_BLOCK_NUM)
#define CFM_FLASH_PAGES (CFM_FLASH_SIZE / PGSZ)
#define CFM_WORD_SIZE (0x4)
#define CFM_WORD_MASK (0x3)
#define CFM_WORD uint32
#elif (defined(CPU_MCF5211))
#define PGSZ (0x800) /* Page Size */
#define PGOFST(n) (PGSZ * n) /* Page Offset */
#define CFM_BLOCK_SIZE (0x20000) /* Logical Block Size */
#define CFM_BLOCK_NUM (1) /* Number of Logical Blocks */
#define CFM_FLASH_SIZE (CFM_BLOCK_SIZE * CFM_BLOCK_NUM)
#define CFM_FLASH_PAGES (CFM_FLASH_SIZE / PGSZ)
#define CFM_WORD_SIZE (0x4)
#define CFM_WORD_MASK (0x3)
#define CFM_WORD uint32
#else
#error "Define a valid CPU for the CFM driver"
#endif
/********************************************************************/
/*
* Macros for Calculating Clock Divider Value
* The BSP must define SYS_CLK_KHZ
*/
#define MIN_SYS_CLK 900 /* 900 KHz */
#define MAX_SYS_CLK 204800 /* 204.8 MHz */
#ifndef SYS_CLK_KHZ
#error "SYS_CLK_KHZ is not defined!"
#endif
#if (SYS_CLK_KHZ > MAX_SYS_CLK) || (SYS_CLK_KHZ < MIN_SYS_CLK)
#error "System clock frequency is out of range!"
#endif
#define CFM_INPUT_CLOCK_RATE (SYS_CLK_KHZ / 2)
#if CFM_INPUT_CLOCK_RATE > 12800
#define CFM_CLOCK (CFM_INPUT_CLOCK_RATE / 8)
#define CFM_CLOCK_PRDIV8 (0x40)
#else
#define CFM_CLOCK (CFM_INPUT_CLOCK_RATE)
#define CFM_CLOCK_PRDIV8 (0)
#endif
#define CLOCK_DIV (CFM_CLOCK / 200)
#if (CFM_CLOCK % 200)
#define CFM_CLOCK_DIV (CLOCK_DIV)
#else
#define CFM_CLOCK_DIV (CLOCK_DIV - 1)
#endif
#define CFMCLKD (CFM_CLOCK_PRDIV8 | CFM_CLOCK_DIV)
/********************************************************************/
#endif /* _CFM_FLASH_H_ */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?