Platform Package reference: Function EwRegisterFlashAreaReader()
Description of the function EwRegisterFlashAreaReader() available in Platform Packages for C compatible target systems. This function is intended to be used when integrating the Embedded Wizard created GUI application with the underlying graphics subsystem, graphics hardware or other external GUI applications coexisting on the same system.
Declaration
void EwRegisterFlashAreaReader
(
XFlashAreaReaderProc aReaderProc,
void* aStartAddress,
void* aEndAddress,
int aBlockSize
);
typedef const void* (*XFlashAreaReaderProc)
(
const void* aAddress
);
Parameters
aReaderProc
User implemented function to read Flash memory areas into internal buffers. This function has to conform the above type declaration XFlashAreaReaderProc.
aStartAddress
Start address of the Flash area to take in account.
aEndAddress
End address of the Flash area to take in account.
aBlockSize
Size of the page or block, the function will read from the Flash memory. The value is expressed in bytes and it should be a power of two value (e.g. 512, 1024, ... 4096, etc.).
aAddress
The address to load the corresponding area from the Flash.
Discussion
The function EwRegisterFlashAreaReader() registers a specified memory area aStartAddress..aEndAddress as belonging to Flash memory not intended to be directly addressed by the CPU. In order to access this Flash memory, the respective Flash pages need to be loaded first into internal buffer. This reading operation has to be handled by external function, specified in the first parameter aReaderProc. The implementation of the function is up to the user.
Embedded Wizard invokes the specified external aReaderProc function automatically during the decompression of bitmap, font or string data to map the Flash contents into the CPU address space. Also, the function is used for bitmaps stored in DirectAccess mode if the bitmap pixel data is not directly accessible by the CPU. In all cases, the not directly accessible Flash data can be processed by Embedded Wizard - though at the expense of performance. Please note: in case of the above mentioned bitmap DirectAccess mode, it is obligatory to recompile the Graphics Engine with the C macro EW_USE_READER_FOR_CONST_SURFACES being defined. If you are using one of our prepared Build Environments you can configure this macro in the file ewconfig.h.
Embedded Wizard allows only one reader to be registered at the same time. Invoking the function EwRegisterFlashAreaReader() twice with different start/end addresses reports an error. In order to remove the previously registered reader, invoke the function with the previously specified start and end addresses and NULL in the aReaderProc parameter. The function EwRegisterFlashAreaReader() should be invoked before invoking EwInitGraphicsEngine().
The implementation of the external function specified in the parameter aReaderProc should perform following steps:
1.Calculate from the given address aAddress the corresponding page within the Flash memory. The size of the page should correspond to the value specified in the parameter aBlockSize.
2.Load this complete page into an internal, static buffer. For optimization purpose it is recommended, that the function caches the read data to prevent the flash contents from being loaded repeatedly. It is also recommended to cache several (for example 4) recently accessed Flash pages.
3.Estimate the memory cell within the internal buffer corresponding to the originally given address aAddress.
4.Return a pointer to the estimated memory cell so that the caller can use it to read the data as if the Flash memory would be accessible by the CPU.
5.If the loading fails or aAddress does not lie within the Flash memory, the function should return aAddress without any changes on it.