Function | Arguments | Return |
---|---|---|
ReadFlashByte( ) |
MyAddressType flashAdr | unsigned char |
ReadFlashPage() |
MyAddressType flashStartAdr, unsigned char *dataPage | unsigned char |
WriteFlashByte( ) |
MyAddressType flashAddr, unsigned char data | unsigned char |
WriteFlashPage() |
MyAddressType flashStartAdr, unsigned char *dataPage | unsigned char |
RecoverFlash() |
Void | unsigned char |
The datatype MyAddressType
is defined in
Self_programming.h
. The size of this datatype depends on the device
that is being used. It can be defined as an long int
when using devices
with more than 64KB of Flash memory, and as an int
(16 bit) using
devices with 64KB or less of Flash memory. The datatypes are actually used as
__flash
or __farflash
pointers (consequently 16
and 24 bit). The reason why a new datatype is defined is that integer types allow a much
more flexible usage than pointer types.
The ReadFlashByte()
returns one byte located on Flash
address given by the input argument FlashAdr
.
The ReadFlashPage()
reads one Flash page from address given
by the input argument FlashStartAdr
and stores data in array given by
the input argument DataPage[]
. The number of bytes stored is depending
upon the Flash page size. The function returns FALSE if the input address is not a Flash
page address, else TRUE.
The WriteFlashByte()
writes a byte given by the input
argument Data
to Flash address given by the input argument
FlashAddr
. The function returns FALSE if the input address is not a
valid Flash byte address for writing, else TRUE.
The WriteFlashPage()
writes data from array given by the
input argument DataPage[]
to Flash page address given by the input
argument FlashStartAdr
. The number of bytes written is depending upon
the Flash page size. The function returns FALSE if the input address is not a valid
Flash page address for writing, else TRUE.
The RecoverFlash()
reads the status variable in EEPROM and
restores Flash page if necessary. The function must be called at program start-up if the
Flash recovery option is enabled. The function Returns TRUE if Flash recovery has taken
place, else FALSE.