 | RL-ARM User's Guide |  |
|
|
| Converting FlashPrg.cULINK Flash programming algorithms can be converted to be used by RL-FlashFS. The following example describes the conversion for the Am29x800BT Flash device: - Copy the file FlashPrg.c from the folder \Keil\ARM\Flash\AM29F160DB to a subfolder of \Keil\ARM\RL\FlashFS\Flash.
- Rename this file to FS_FlashPrg.c
- Change the include header file from:
#include "..\FlashOS.H" // FlashOS Structures
to the RL-FlashFS definition header.
#include <File_Config.h>
- Add the Flash driver control block definition:
/* Embedded Flash Driver Interface functions */
static BOOL Init (U32 adr, U32 clk);
static BOOL UnInit (void);
static BOOL ProgramPage (U32 adr, U32 sz, U8 *buf);
static BOOL EraseSector (U32 adr);
static BOOL EraseChip (void); /* Optional function if supported */
/* Embedded Flash Device Driver Control Block */
EFS_DRV fl0_drv = {
Init,
UnInit,
NULL, /* =NULL, use FFS internal ReadData */
ProgramPage,
EraseSector,
EraseChip
};
- Rename the functions and replace the function headers:
- Init()
int Init (unsigned long adr, unsigned long clk, unsigned long fnc) {
to
static BOOL Init (U32 adr, U32 clk) {
- UnInit()
int UnInit (unsigned long fnc) {
to
static BOOL UnInit (void) {
The fnc parameter is not used by the Flash driver. - EraseChip()
int EraseChip (void) {
to
static BOOL EraseChip (void) {
- EraseSector()
int EraseSector (unsigned long adr) {
to
static BOOL EraseSector (U32 adr) {
- ProgramPage()
int ProgramPage (unsigned long adr, unsigned long sz, unsigned char *buf) {
to
static BOOL ProgramPage (U32 adr, U32 sz, U8 *buf) {
- Modify the return values for all functions to: __TRUE on success and __FALSE on failure.
- Update the function ProgramPage() function to allow unaligned buffer access. Add the attribute __packed if buf is not accessing a byte..
/* 'buf' might be unaligned. */
M16(adr) = *(__packed U16 *)buf;
- Keep local functions that are needed, for example: Polling.
|
|