Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: Picaso_4DGL-32PTU_Media.cpp
- Revision:
- 20:88e137b9ea46
- Parent:
- 19:a259bc128867
diff -r a259bc128867 -r 88e137b9ea46 Picaso_4DGL-32PTU_Media.cpp --- a/Picaso_4DGL-32PTU_Media.cpp Thu Sep 15 13:31:53 2016 +0000 +++ b/Picaso_4DGL-32PTU_Media.cpp Mon Sep 26 10:51:02 2016 +0000 @@ -233,6 +233,55 @@ return success; } +//************************************************************************** +// Writes a word to the current media address that was initially set with the +// “Set Sector Address” command. +// +// Note: Writing bytes or words to a media sector must start from the beginning +// of the sector. All writes will be incremental until the “Flush Media” command +// is executed, or the sector address rolls over to the next sector. +// When the “Flush Media” command is called, any remaining bytes in the sector +// will be padded with 0xFF, destroying the previous contents. +// An attempt to use the “Set Byte Address” command will result in the +// lower 9 bits being interpreted as zero. If the writing rolls over to the +// next sector, the “Flush Media” command is issued automatically internally. +//************************************************************************** +bool PICASO_4DGL :: media_WriteWord(short value) { + + char command[4] = ""; + + command[0] = (MEDIA_WRITE_WORD >> (8*1)) & 0xff; + command[1] = (MEDIA_WRITE_WORD >> (8*0)) & 0xff; + command[2] = (value >> (8*1)) & 0xff; + command[3] = (value >> (8*0)) & 0xff; + + writeCOMMAND(command, 4); + bool success = writeByteResponse(); +#ifdef DEBUGMODE + pc.printf("\n\r DEBUG: Write Byte: %i\n\r", success); +#endif + return success; +} + +//************************************************************************** +// After writing any data to a sector, the Flush Media command should be called +// to ensure that the current sector that is being written is correctly stored +// back to the media else write operations may be unpredictable. +//************************************************************************** +bool PICASO_4DGL :: media_Flush() { + + char command[2] = ""; + + command[0] = (MEDIA_FLUSH >> (8*1)) & 0xff; + command[1] = (MEDIA_FLUSH >> (8*0)) & 0xff; + + writeCOMMAND(command, 2); + bool success = writeByteResponse(); +#ifdef DEBUGMODE + pc.printf("\n\r DEBUG: Read Word: %i\n\r", success); +#endif + return success; +} @@ -263,3 +312,4 @@ +