User`s manual
OEM User’s Manual 45
sbfWriteFlash
int sbfWriteFlash(unsigned long flashDst, void* Src,
unsigned len);
DESCRIPTION
Writes
len
bytes (up to 64K) to physical address
flashDst
from
Src
.
Keep calling
sbfWriteFlash()
until it returns zero or a negative error code. A pos-
itive return value indicates that the serial flash SPI port is being used by another device.
If you are using µC/OS-II and
_SPI_USE_UCOS_MUTEX
is
#defined
, you may
call
sbfWriteFlash()
just once. If more than
_SPI_MAXTIME
milliseconds
elapse while waiting for the SPI port to become available, one of the following two run-
time errors will occur:
ERR_SPI_MUTEX_ERROR
(when using µC/OS-II) or
-ETIME
(if not using µC/OS-II).
NOTE: This function call is not power-fail safe. The
writeUserBlock()
function
call provides a safer way to store critical data using redundant copies.
PARAMETERS
flashDst the physical address of the flash destination
Src near pointer to the source data
len the number of bytes to write
RETURN VALUE
0 if successful.
-1 if an attempt was made to write to the user/ID block or program area.
The return values below apply only if
_SPI_USE_UCOS_MUTEX
is not
#defined
:
-EBUSY
to indicate a busy writing to the serial flash
positive
N
to indicate that the SPI port is being used by device n
if more than
_SPI_MAXTIME
milliseconds elapse while waiting for the SPI port to become
available, one of the following two runtime errors will occur:
ERR_SPI_MUTEX_ERROR
(when using µC/OS-II) or
-ETIME
(if not using µC/OS-II).