You are currently viewing the documentation for:
m_fnWriteSector writes a single sector to the block device (usually an SD card or flash memory).
ECF_ErrorCode m_fnWriteSector(
   struct ECF_BlockDriver *pBlockDriver,
   uint32_t sector,
   uint8_t *pData,
   uint8_t flags
This is a pointer to the struct ECF_BlockDriver that the function is a member of. It can be used by the block driver to access the m_BlockDriverData member or to call the other functions.
This specifies which sector to write.
This points to a uint8_t array with the data for the block driver to write.
These are flags for the write.
If this flag is set, the block driver only needs to write 512 bytes, regardless of the sector size. The buffer pointed to by pData is only 512 bytes big so if set, you must not read more than 512 bytes.
If this flag is set, the block that is about to be written has previously been trimmed and is probably already cleared.
Return value
Return ECFERR_SUCCESS if the read was successful. If the write fails, return one of the EcFAT error codes defined in EcFAT.h. You can also define your own error codes, error no 64 to 127 are reserved for custom block driver errors.
The m_fnWriteSector function is part of struct ECF_BlockDriver. You need to supply it when writing a block driver. EcFAT will call this function when it wants to write a sector to the storage device. On both single- and multithreaded systems, EcFAT will make certain that it will not call any of the other block driver functions until this call has been completed so you do not need to implement any locking in the block driver unless it is needed for other purposes. Note: If you use journaling and/or wear-leveling, you must respect the ECF_WRITESECTOR_512_BYTES_ONLY flag. If you ignore it and write the entire sector you risk reading beyond the end of the buffer pointed to by pData which can result in a bus fault.
Example Code
See example for m_fnReadSector