|
|
(5 intermediate revisions by the same user not shown) |
Line 22: |
Line 22: |
| | | |
| ==Detailed description== | | ==Detailed description== |
| + | |
| + | |
| | | |
| | | |
Line 43: |
Line 45: |
| | | |
| | | |
− | ''<span style="color:red;">No additional examples</span>''
| |
| | | |
− | ==Macro reference==
| |
| | | |
− | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"
| + | ''<span style="color:red;">No additional examples</span>'' |
− | |-
| |
− | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadStringFromFile'''
| |
− | |-
| |
− | | colspan="2" | Reads a string from the currently open file. Auto increments the position in the file. An empty string signifies the end of the file has been reached.
| |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| |
− | | width="90%" | NumBytes
| |
− | |-
| |
− | | colspan="2" | Maximum number of bytes to attempt to read
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| |
− | | width="90%" | EndChar
| |
− | |-
| |
− | | colspan="2" | Ends the string if the value specified is found, default is 0
| |
− | |-
| |
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-string-icon.png]] - STRING
| |
− | | width="90%" style="border-top: 2px solid #000;" | ''Return''
| |
− | |}
| |
| | | |
| | | |
− | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''WriteByteToBuffer'''
| |
− | |-
| |
− | | colspan="2" | Writes a single byte to the current 512 byte local sector buffer.
| |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| |
− | | width="90%" | Address
| |
− | |-
| |
− | | colspan="2" | Address Range 0 - 511
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| |
− | | width="90%" | Data
| |
− | |-
| |
− | | colspan="2" | Data Byte to write to the buffer
| |
− | |-
| |
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
| |
− | | width="90%" style="border-top: 2px solid #000;" | ''Return''
| |
− | |}
| |
| | | |
| | | |
− | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''MoveToNextFileSector'''
| |
− | |-
| |
− | | colspan="2" | Attempts to move to the next sector in the file. When reading a file you would leave force next sector set to 0. When writing a file you would leave force next sector set to 1 to allow new sectors to be created as the file grows. Returns 0 for success
| |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| |
− | | width="90%" | Force_Next_Sector
| |
− | |-
| |
− | | colspan="2" | 0 = Don't add new sector, 1 = Add new sector if we are at the end of the file
| |
− | |-
| |
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
| |
− | | width="90%" style="border-top: 2px solid #000;" | ''Return''
| |
− | |}
| |
| | | |
| | | |
− | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''AppendByteToFile'''
| |
− | |-
| |
− | | colspan="2" | Adds a single byte to the end of the currently open file, useful for inserting the value 0 into binary file types. Returns 0 for success.
| |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| |
− | | width="90%" | Data
| |
− | |-
| |
− | | colspan="2" | Data to append to the end of the file
| |
− | |-
| |
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
| |
− | | width="90%" style="border-top: 2px solid #000;" | ''Return''
| |
− | |}
| |
| | | |
| | | |
− | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadFileSector'''
| |
− | |-
| |
− | | colspan="2" | Overwrites local buffer with the current file sector from the disk. Used to restore the local sector buffer with the actual sector stored on the card. Return = 0 : Local buffer refreshed with current card sector Return > 0 : Error
| |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
| |
− | | width="90%" style="border-top: 2px solid #000;" | ''Return''
| |
− | |}
| |
| | | |
| | | |
− | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''CloseFile'''
| |
− | |-
| |
− | | colspan="2" | Closes the current open file
| |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
| |
− | | width="90%" style="border-top: 2px solid #000;" | ''Return''
| |
− | |}
| |
| | | |
| | | |
− | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadByteFromFile'''
| |
− | |-
| |
− | | colspan="2" | Reads a byte from the currently open file. Auto increments the position in the file. A return value of 0 may signify the end of the file has been reached (depending on the contents of the file).
| |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u16-icon.png]] - UINT
| |
− | | width="90%" style="border-top: 2px solid #000;" | ''Return''
| |
− | |}
| |
| | | |
| + | ==Macro reference== |
| | | |
| + | ===AppendByteArrayToFile=== |
| {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" |
| |- | | |- |
| | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''DeleteFile''' | + | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''AppendByteArrayToFile''' |
| |- | | |- |
− | | colspan="2" | Searches for and deletes a file in the current folder location on the card. Default = Root Returns 0 for success. | + | | colspan="2" | Adds a binary byte array to the end of the file. Returns 0 for success. |
| |- | | |- |
| |- | | |- |
− | | width="10%" align="center" | [[File:Fc9-string-icon.png]] - STRING | + | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE |
− | | width="90%" | Filename
| + | | width="90%" | Data |
− | |-
| |
− | | colspan="2" | 8.3 format filename e.g."file.txt"
| |
− | |-
| |
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
| |
− | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | |
− | |}
| |
− | | |
− | | |
− | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadByteFromIndex'''
| |
− | |-
| |
− | | colspan="2" | Reads an arbitrary byte of data from the current open file. Return = Data byte read from the local sector buffer. Experimental and potentially slow if navigating backwards through the file.
| |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-u32-icon.png]] - ULONG
| |
− | | width="90%" | Address
| |
− | |-
| |
− | | colspan="2" | Contains the position of the byte to be read from the file
| |
− | |-
| |
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
| |
− | | width="90%" style="border-top: 2px solid #000;" | ''Return''
| |
− | |}
| |
− | | |
− | | |
− | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''CreateFile'''
| |
− | |-
| |
− | | colspan="2" | Creates a file in the current folder location on the card. Default = Root Returns 0 for success File must be opened using "Open_File" after creation before writing any data.
| |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-string-icon.png]] - STRING
| |
− | | width="90%" | Filename
| |
− | |-
| |
− | | colspan="2" | 8.3 format filename e.g."file.txt"
| |
− | |-
| |
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
| |
− | | width="90%" style="border-top: 2px solid #000;" | ''Return''
| |
− | |}
| |
− | | |
− | | |
− | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ScanCurrentFolder'''
| |
− | |-
| |
− | | colspan="2" | Method for retreiving file or folder names for the card to allow for dynamic file opening or playback. Does not currently simulate. 0 - Filetype found and stored into string array, 1 - End of folder reached, 2 - Filetype mismatch 3 - Empty
| |
| |- | | |- |
| + | | colspan="2" | Binary data array to append to the file |
| |- | | |- |
| | width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT | | | width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT |
− | | width="90%" | Current_Idx | + | | width="90%" | Length |
− | |-
| |
− | | colspan="2" | Contains the current pointer in the directory table. Values from 0 to 511 to completley search the current folder for a files or folders
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| |
− | | width="90%" | Scan_Type
| |
| |- | | |- |
− | | colspan="2" | Sets the scan to search for Files or Folders. 0 = Scan for files, 1 = Scan for folders | + | | colspan="2" | Number of values to append |
| |- | | |- |
| | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE | | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE |
Line 245: |
Line 87: |
| | | |
| | | |
| + | ===AppendByteToFile=== |
| {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" |
| |- | | |- |
| | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadByteFromScan''' | + | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''AppendByteToFile''' |
| |- | | |- |
− | | colspan="2" | Returns a byte of the name of the file or folder retreived from the Scan_Current_folder function. Return = ASCII byte at position Idx from the folder name or file name at position Current_Idx in the directory | + | | colspan="2" | Adds a single byte to the end of the currently open file, useful for inserting the value 0 into binary file types. Returns 0 for success. |
| |- | | |- |
| |- | | |- |
| | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE |
− | | width="90%" | idx | + | | width="90%" | Data |
| |- | | |- |
− | | colspan="2" | 0 - 11 for a file, 0 - 7 for a folder | + | | colspan="2" | Data to append to the end of the file |
| |- | | |- |
| | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE | | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE |
Line 263: |
Line 106: |
| | | |
| | | |
| + | ===AppendFloatArrayToFile=== |
| {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" |
| |- | | |- |
| | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''OpenFolder''' | + | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''AppendFloatArrayToFile''' |
| |- | | |- |
− | | colspan="2" | ".." - Jumps up a directory, if at root then remains in root "root" - Jumps directly back to the root directory "foldername" - Opens folder named foldername | + | | colspan="2" | Adds a binary float array to the end of the file. Returns 0 for success. |
| |- | | |- |
| |- | | |- |
− | | width="10%" align="center" | [[File:Fc9-string-icon.png]] - STRING | + | | width="10%" align="center" | [[File:Fc9-f32-icon.png]] - FLOAT |
− | | width="90%" | Folder_Name | + | | width="90%" | Data |
− | |-
| |
− | | colspan="2" |
| |
− | |-
| |
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
| |
− | | width="90%" style="border-top: 2px solid #000;" | ''Return''
| |
− | |}
| |
− | | |
− | | |
− | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadByteFromBuffer'''
| |
− | |-
| |
− | | colspan="2" | Reads a byte of data from the local sector buffer. Return = Data byte read from the local sector buffer.
| |
| |- | | |- |
| + | | colspan="2" | Binary data array to append to the file |
| |- | | |- |
| | width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT | | | width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT |
− | | width="90%" | Address | + | | width="90%" | Length |
| |- | | |- |
− | | colspan="2" | 0 - 511 - Contains the position of the byte to be read | + | | colspan="2" | Number of values to append |
| |- | | |- |
| | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE | | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE |
Line 299: |
Line 130: |
| | | |
| | | |
| + | ===AppendINTArrayToFile=== |
| {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" |
| |- | | |- |
| | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadFileLength''' | + | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''AppendINTArrayToFile''' |
| |- | | |- |
− | | colspan="2" | Returns the number of bytes in the current sector that are used by the current open file. Return = 512 - Sector is filled with file data Return < 512 - Last sector of the file, Retval specifies how many bytes of data are remaining in the sector | + | | colspan="2" | Adds a binary INT array to the end of the file. Returns 0 for success. |
| |- | | |- |
| |- | | |- |
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-s16-icon.png]] - INT | + | | width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT |
− | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | + | | width="90%" | Data |
− | |}
| |
− | | |
− | | |
− | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"
| |
| |- | | |- |
− | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | + | | colspan="2" | Binary data array to append to the file |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''OpenFile'''
| |
| |- | | |- |
− | | colspan="2" | Searches for and opens a file for reading or writing from within the current directory on the disk. Returns 0 for success. | + | | width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT |
| + | | width="90%" | Length |
| |- | | |- |
| + | | colspan="2" | Number of values to append |
| |- | | |- |
− | | width="10%" align="center" | [[File:Fc9-string-icon.png]] - STRING | + | | width="10%" align="center" | [[File:Fc9-bool-icon.png]] - BOOL |
− | | width="90%" | Filename | + | | width="90%" | MSBFirst |
| |- | | |- |
− | | colspan="2" | 8.3 filename of the file we are trying to open e.g. "file.txt" | + | | colspan="2" | 0=LSB then MSB, 1=MSB then LSB |
| |- | | |- |
| | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE | | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE |
Line 330: |
Line 159: |
| | | |
| | | |
| + | ===AppendLongArrayToFile=== |
| {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" |
| |- | | |- |
| | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''WriteFileSector''' | + | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''AppendLongArrayToFile''' |
| |- | | |- |
− | | colspan="2" | Overwrites the current sector on the memory card with the contents of the local sector buffer. See write_byte_to_buffer function. Return = 0 - File sector written successfully. Return > 0 - File sector write error | + | | colspan="2" | Adds a binary Long array to the end of the file. Returns 0 for success. |
| |- | | |- |
| |- | | |- |
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE | + | | width="10%" align="center" | [[File:Fc9-u32-icon.png]] - ULONG |
− | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | + | | width="90%" | Data |
− | |}
| |
− | | |
− | | |
− | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"
| |
| |- | | |- |
− | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | + | | colspan="2" | Binary data array to append to the file |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetFileIndex'''
| |
| |- | | |- |
− | | colspan="2" | Sets the current file index and used to switch between several open file streams. Default = 0. | + | | width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT |
| + | | width="90%" | Length |
| |- | | |- |
| + | | colspan="2" | Number of values to append |
| |- | | |- |
− | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | + | | width="10%" align="center" | [[File:Fc9-bool-icon.png]] - BOOL |
− | | width="90%" | File_Index | + | | width="90%" | MSBFirst |
| |- | | |- |
− | | colspan="2" | File index ranges from 0 to (Max Concurrent Files - 1) | + | | colspan="2" | 0=LSB then MSB, 1=MSB then LSB |
| |- | | |- |
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID | + | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE |
| | width="90%" style="border-top: 2px solid #000;" | ''Return'' | | | width="90%" style="border-top: 2px solid #000;" | ''Return'' |
| |} | | |} |
| | | |
| | | |
| + | ===AppendStringToFile=== |
| {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" |
| |- | | |- |
Line 379: |
Line 207: |
| | | |
| | | |
− | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"
| + | ===CloseFile=== |
− | |-
| |
− | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadFileSize'''
| |
− | |-
| |
− | | colspan="2" | Reads the entire size of the current file in bytes.
| |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u32-icon.png]] - ULONG
| |
− | | width="90%" style="border-top: 2px solid #000;" | ''Return''
| |
− | |}
| |
− | | |
− | | |
− | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''UpdateFileSector'''
| |
− | |-
| |
− | | colspan="2" | Updates a file sector with new data set from using WriteByteToBuffer. Note this cannot alter the size of the file.
| |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
| |
− | | width="90%" style="border-top: 2px solid #000;" | ''Return''
| |
− | |}
| |
− | | |
− | | |
− | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetTimeAndDate'''
| |
− | |-
| |
− | | colspan="2" | Sets the current time and date. Time = (Hour << 11) + (Min << 5) + (Sec >> 1) Date = (YearFrom1980 << 9) + (Month << 5) + (Day) Additional details can be found here: http://www.maverick-os.dk/FileSystemFormats/FAT16_FileSystem.html#TimeFormat
| |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| |
− | | width="90%" | Time
| |
− | |-
| |
− | | colspan="2" | Sets the current Time in FAT Time format hhhhhmmmmmmsssss - S=Secs/2
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| |
− | | width="90%" | Date
| |
− | |-
| |
− | | colspan="2" | Sets the current Date in FAT Date format yyyyyyymmmmddddd - Y=Years since 1980
| |
− | |-
| |
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
| |
− | | width="90%" style="border-top: 2px solid #000;" | ''Return''
| |
− | |}
| |
− | | |
− | | |
− | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Initialise'''
| |
− | |-
| |
− | | colspan="2" | Attempts to communicate with the SD card and if successful sets up the file system. Returns 0 for success.
| |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
| |
− | | width="90%" style="border-top: 2px solid #000;" | ''Return''
| |
− | |}
| |
− | | |
− | | |
− | | |
− | | |
− | ==Property reference==
| |
− | | |
− | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#D8C9D8;" | [[File:Fc9-prop-icon.png]]
| |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Properties'''
| |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
| |
− | | width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Connections
| |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
| |
− | | width="90%" | Channel
| |
− | |-
| |
− | | colspan="2" | SPI Channel selector
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-type-5-icon.png]]
| |
− | | width="90%" | MOSI
| |
− | |-
| |
− | | colspan="2" | SPI Data Out Pin SDO - Also Known as Master Out Slave In (MOSI) when used in Master mode.
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-type-5-icon.png]]
| |
− | | width="90%" | MISO
| |
− | |-
| |
− | | colspan="2" | SPI Data In Pin SDI - Also Known as Master In Slave Out (MISO) when used in Master mode.
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-type-5-icon.png]]
| |
− | | width="90%" | CLK
| |
− | |-
| |
− | | colspan="2" | SPI Clock Pin CLK - The Clock signal is driven by the SPI master.
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-type-5-icon.png]]
| |
− | | width="90%" | CS / SS
| |
− | |-
| |
− | | colspan="2" | Chip Select / Slave Select Pin Master Mode: General purpose output pin used to select the remote SPI device. Slave Mode: Hardware chip select pin input used to select the SPI device.
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
| |
− | | width="90%" | Initial Prescaler
| |
− | |-
| |
− | | colspan="2" | SPI initial clock divider - Frequency should be under 400khz to allow startup to work correctly.
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
| |
− | | width="90%" | High Speed Prescaler
| |
− | |-
| |
− | | colspan="2" | SPI high speed clock divider - Once startup is complete this is the rate that will be used to transfer data
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
| |
− | | width="90%" style="background-color:#EAE1EA; color:#4B008D;" | File System
| |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-type-14-icon.png]]
| |
− | | width="90%" | Max Concurrent Files
| |
− | |-
| |
− | | colspan="2" | Specifies how many concurrent files can be opened at any one time. Use the SetFileIndex macro to switch between concurrent files.
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
| |
− | | width="90%" | End Of File
| |
− | |-
| |
− | | colspan="2" | Specifies the way the ReadByteFromFile function indicates the end of a file. 8 Bit mode - End of the file is represented by the value 0, read multiple times to confirm that the 0 is not simply data. 16 Bit mode - End of file is represented by the value 512 allowing the values 0 - 255 to represent valid data.
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
| |
− | | width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Simulation
| |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
| |
− | | width="90%" | Sim Type
| |
− | |-
| |
− | | colspan="2" | Defines the simulation type. The default is to use the Windows file system to allow for reading and writing files. The alternative is to use the CAL functionality to allow the SPI transactions to be passed onto a seperate handler e.g. for logging or debugging purposes.
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
| |
− | | width="90%" style="background-color:#EAE1EA; color:#4B008D;" | File System
| |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-type-20-icon.png]]
| |
− | | width="90%" | Root Directory
| |
− | |-
| |
− | | colspan="2" | Directory flagged as root for simulation Default: $(srcdir) is the current project source directory. Modern windows systems do not like you writing files to a hard drive root directory so a directory off the root is advised.
| |
− | |}==Macro reference==
| |
− | | |
− | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadStringFromFile'''
| |
− | |-
| |
− | | colspan="2" | Reads a string from the currently open file. Auto increments the position in the file. An empty string signifies the end of the file has been reached.
| |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| |
− | | width="90%" | NumBytes
| |
− | |-
| |
− | | colspan="2" | Maximum number of bytes to attempt to read
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| |
− | | width="90%" | EndChar
| |
− | |-
| |
− | | colspan="2" | Ends the string if the value specified is found, default is 0
| |
− | |-
| |
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-string-icon.png]] - STRING
| |
− | | width="90%" style="border-top: 2px solid #000;" | ''Return''
| |
− | |}
| |
− | | |
− | | |
− | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''WriteByteToBuffer'''
| |
− | |-
| |
− | | colspan="2" | Writes a single byte to the current 512 byte local sector buffer.
| |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| |
− | | width="90%" | Address
| |
− | |-
| |
− | | colspan="2" | Address Range 0 - 511
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| |
− | | width="90%" | Data
| |
− | |-
| |
− | | colspan="2" | Data Byte to write to the buffer
| |
− | |-
| |
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
| |
− | | width="90%" style="border-top: 2px solid #000;" | ''Return''
| |
− | |}
| |
− | | |
− | | |
− | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''MoveToNextFileSector'''
| |
− | |-
| |
− | | colspan="2" | Attempts to move to the next sector in the file. When reading a file you would leave force next sector set to 0. When writing a file you would leave force next sector set to 1 to allow new sectors to be created as the file grows. Returns 0 for success
| |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| |
− | | width="90%" | Force_Next_Sector
| |
− | |-
| |
− | | colspan="2" | 0 = Don't add new sector, 1 = Add new sector if we are at the end of the file
| |
− | |-
| |
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
| |
− | | width="90%" style="border-top: 2px solid #000;" | ''Return''
| |
− | |}
| |
− | | |
− | | |
− | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''AppendByteToFile'''
| |
− | |-
| |
− | | colspan="2" | Adds a single byte to the end of the currently open file, useful for inserting the value 0 into binary file types. Returns 0 for success.
| |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| |
− | | width="90%" | Data
| |
− | |-
| |
− | | colspan="2" | Data to append to the end of the file
| |
− | |-
| |
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
| |
− | | width="90%" style="border-top: 2px solid #000;" | ''Return''
| |
− | |}
| |
− | | |
− | | |
− | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadFileSector'''
| |
− | |-
| |
− | | colspan="2" | Overwrites local buffer with the current file sector from the disk. Used to restore the local sector buffer with the actual sector stored on the card. Return = 0 : Local buffer refreshed with current card sector Return > 0 : Error
| |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
| |
− | | width="90%" style="border-top: 2px solid #000;" | ''Return''
| |
− | |}
| |
− | | |
− | | |
| {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" |
| |- | | |- |
Line 631: |
Line 221: |
| | | |
| | | |
| + | ===CreateFile=== |
| {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" |
| |- | | |- |
| | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadByteFromFile''' | + | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''CreateFile''' |
| |- | | |- |
− | | colspan="2" | Reads a byte from the currently open file. Auto increments the position in the file. A return value of 0 may signify the end of the file has been reached (depending on the contents of the file). | + | | colspan="2" | Creates a file in the current folder location on the card. Default = Root Returns 0 for success File must be opened using "Open_File" after creation before writing any data. |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u16-icon.png]] - UINT
| |
− | | width="90%" style="border-top: 2px solid #000;" | ''Return''
| |
− | |}
| |
− | | |
− | | |
− | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''DeleteFile'''
| |
− | |-
| |
− | | colspan="2" | Searches for and deletes a file in the current folder location on the card. Default = Root Returns 0 for success.
| |
| |- | | |- |
| |- | | |- |
Line 662: |
Line 240: |
| | | |
| | | |
| + | ===DeleteFile=== |
| {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" |
| |- | | |- |
| | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadByteFromIndex''' | + | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''DeleteFile''' |
| |- | | |- |
− | | colspan="2" | Reads an arbitrary byte of data from the current open file. Return = Data byte read from the local sector buffer. Experimental and potentially slow if navigating backwards through the file. | + | | colspan="2" | Searches for and deletes a file in the current folder location on the card. Default = Root Returns 0 for success. |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-u32-icon.png]] - ULONG
| |
− | | width="90%" | Address
| |
− | |-
| |
− | | colspan="2" | Contains the position of the byte to be read from the file
| |
− | |-
| |
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
| |
− | | width="90%" style="border-top: 2px solid #000;" | ''Return''
| |
− | |}
| |
− | | |
− | | |
− | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''CreateFile'''
| |
− | |-
| |
− | | colspan="2" | Creates a file in the current folder location on the card. Default = Root Returns 0 for success File must be opened using "Open_File" after creation before writing any data.
| |
| |- | | |- |
| |- | | |- |
Line 698: |
Line 259: |
| | | |
| | | |
| + | ===Initialise=== |
| {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" |
| |- | | |- |
| | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ScanCurrentFolder''' | + | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Initialise''' |
| |- | | |- |
− | | colspan="2" | Method for retreiving file or folder names for the card to allow for dynamic file opening or playback. Does not currently simulate. 0 - Filetype found and stored into string array, 1 - End of folder reached, 2 - Filetype mismatch 3 - Empty | + | | colspan="2" | Attempts to communicate with the SD card and if successful sets up the file system. Returns: 0=OK / 236 = MBR Invalid / 237 = MBR Fail / 254=No Response / 255=No Card |
| |- | | |- |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| |
− | | width="90%" | Current_Idx
| |
− | |-
| |
− | | colspan="2" | Contains the current pointer in the directory table. Values from 0 to 511 to completley search the current folder for a files or folders
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| |
− | | width="90%" | Scan_Type
| |
− | |-
| |
− | | colspan="2" | Sets the scan to search for Files or Folders. 0 = Scan for files, 1 = Scan for folders
| |
| |- | | |- |
| | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE | | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE |
Line 721: |
Line 273: |
| | | |
| | | |
| + | ===MoveToNextFileSector=== |
| {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" |
| |- | | |- |
| | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadByteFromScan''' | + | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''MoveToNextFileSector''' |
| |- | | |- |
− | | colspan="2" | Returns a byte of the name of the file or folder retreived from the Scan_Current_folder function. Return = ASCII byte at position Idx from the folder name or file name at position Current_Idx in the directory | + | | colspan="2" | Attempts to move to the next sector in the file. When reading a file you would leave force next sector set to 0. When writing a file you would leave force next sector set to 1 to allow new sectors to be created as the file grows. Returns 0 for success |
| |- | | |- |
| |- | | |- |
| | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE |
− | | width="90%" | idx | + | | width="90%" | Force_Next_Sector |
| |- | | |- |
− | | colspan="2" | 0 - 11 for a file, 0 - 7 for a folder | + | | colspan="2" | 0 = Don't add new sector, 1 = Add new sector if we are at the end of the file |
− | |-
| |
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
| |
− | | width="90%" style="border-top: 2px solid #000;" | ''Return''
| |
− | |}
| |
− | | |
− | | |
− | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''OpenFolder'''
| |
− | |-
| |
− | | colspan="2" | ".." - Jumps up a directory, if at root then remains in root "root" - Jumps directly back to the root directory "foldername" - Opens folder named foldername
| |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-string-icon.png]] - STRING
| |
− | | width="90%" | Folder_Name
| |
− | |-
| |
− | | colspan="2" |
| |
| |- | | |- |
| | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE | | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE |
Line 757: |
Line 292: |
| | | |
| | | |
− | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"
| + | ===OpenFile=== |
− | |-
| |
− | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadByteFromBuffer'''
| |
− | |-
| |
− | | colspan="2" | Reads a byte of data from the local sector buffer. Return = Data byte read from the local sector buffer.
| |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| |
− | | width="90%" | Address
| |
− | |-
| |
− | | colspan="2" | 0 - 511 - Contains the position of the byte to be read
| |
− | |-
| |
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
| |
− | | width="90%" style="border-top: 2px solid #000;" | ''Return''
| |
− | |}
| |
− | | |
− | | |
− | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadFileLength'''
| |
− | |-
| |
− | | colspan="2" | Returns the number of bytes in the current sector that are used by the current open file. Return = 512 - Sector is filled with file data Return < 512 - Last sector of the file, Retval specifies how many bytes of data are remaining in the sector
| |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-s16-icon.png]] - INT
| |
− | | width="90%" style="border-top: 2px solid #000;" | ''Return''
| |
− | |}
| |
− | | |
− | | |
| {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" |
| |- | | |- |
Line 806: |
Line 311: |
| | | |
| | | |
| + | ===OpenFolder=== |
| {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" |
| |- | | |- |
| | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''WriteFileSector''' | + | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''OpenFolder''' |
| |- | | |- |
− | | colspan="2" | Overwrites the current sector on the memory card with the contents of the local sector buffer. See write_byte_to_buffer function. Return = 0 - File sector written successfully. Return > 0 - File sector write error | + | | colspan="2" | ".." - Jumps up a directory, if at root then remains in root "root" - Jumps directly back to the root directory "foldername" - Opens folder named foldername |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
| |
− | | width="90%" style="border-top: 2px solid #000;" | ''Return''
| |
− | |}
| |
− | | |
− | | |
− | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetFileIndex'''
| |
− | |-
| |
− | | colspan="2" | Sets the current file index and used to switch between several open file streams. Default = 0.
| |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| |
− | | width="90%" | File_Index
| |
− | |-
| |
− | | colspan="2" | File index ranges from 0 to (Max Concurrent Files - 1)
| |
− | |-
| |
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
| |
− | | width="90%" style="border-top: 2px solid #000;" | ''Return''
| |
− | |}
| |
− | | |
− | | |
− | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''AppendStringToFile'''
| |
− | |-
| |
− | | colspan="2" | Adds the contents of the data string parameter to the end of the currently open file. Returns 0 for success.
| |
| |- | | |- |
| |- | | |- |
| | width="10%" align="center" | [[File:Fc9-string-icon.png]] - STRING | | | width="10%" align="center" | [[File:Fc9-string-icon.png]] - STRING |
− | | width="90%" | Data_String | + | | width="90%" | Folder_Name |
| |- | | |- |
− | | colspan="2" | Data to append to the end of the file | + | | colspan="2" | |
| |- | | |- |
| | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE | | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE |
Line 855: |
Line 330: |
| | | |
| | | |
| + | ===ReadByteArrayFromFile=== |
| {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" |
| |- | | |- |
| | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadFileSize''' | + | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadByteArrayFromFile''' |
| |- | | |- |
− | | colspan="2" | Reads the entire size of the current file in bytes. | + | | colspan="2" | Reads a binary byte array from the currently open file. Auto increments the position in the file. Returns the number of values read. |
| |- | | |- |
| |- | | |- |
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u32-icon.png]] - ULONG | + | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE |
− | | width="90%" style="border-top: 2px solid #000;" | ''Return''
| + | | width="90%" | Data |
− | |}
| |
− | | |
− | | |
− | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''UpdateFileSector'''
| |
− | |-
| |
− | | colspan="2" | Updates a file sector with new data set from using WriteByteToBuffer. Note this cannot alter the size of the file.
| |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
| |
− | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | |
− | |}
| |
− | | |
− | | |
− | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetTimeAndDate'''
| |
− | |-
| |
− | | colspan="2" | Sets the current time and date. Time = (Hour << 11) + (Min << 5) + (Sec >> 1) Date = (YearFrom1980 << 9) + (Month << 5) + (Day) Additional details can be found here: http://www.maverick-os.dk/FileSystemFormats/FAT16_FileSystem.html#TimeFormat
| |
| |- | | |- |
| + | | colspan="2" | Data variable to populate with data |
| |- | | |- |
| | width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT | | | width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT |
− | | width="90%" | Time | + | | width="90%" | Length |
| |- | | |- |
− | | colspan="2" | Sets the current Time in FAT Time format hhhhhmmmmmmsssss - S=Secs/2 | + | | colspan="2" | Number of values to read |
| |- | | |- |
− | | width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| + | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u16-icon.png]] - UINT |
− | | width="90%" | Date
| |
− | |-
| |
− | | colspan="2" | Sets the current Date in FAT Date format yyyyyyymmmmddddd - Y=Years since 1980
| |
− | |-
| |
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID | |
| | width="90%" style="border-top: 2px solid #000;" | ''Return'' | | | width="90%" style="border-top: 2px solid #000;" | ''Return'' |
| |} | | |} |
| | | |
| | | |
| + | ===ReadByteFromBuffer=== |
| {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" |
| |- | | |- |
| | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Initialise''' | + | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadByteFromBuffer''' |
| |- | | |- |
− | | colspan="2" | Attempts to communicate with the SD card and if successful sets up the file system. Returns 0 for success. | + | | colspan="2" | Reads a byte of data from the local sector buffer. Return = Data byte read from the local sector buffer. |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
| |
− | | width="90%" style="border-top: 2px solid #000;" | ''Return''
| |
− | |}
| |
− | | |
− | | |
− | | |
− | | |
− | ==Property reference==
| |
− | | |
− | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#D8C9D8;" | [[File:Fc9-prop-icon.png]]
| |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Properties'''
| |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
| |
− | | width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Connections
| |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
| |
− | | width="90%" | Channel
| |
− | |-
| |
− | | colspan="2" | SPI Channel selector
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-type-5-icon.png]]
| |
− | | width="90%" | MOSI
| |
− | |-
| |
− | | colspan="2" | SPI Data Out Pin SDO - Also Known as Master Out Slave In (MOSI) when used in Master mode.
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-type-5-icon.png]]
| |
− | | width="90%" | MISO
| |
− | |-
| |
− | | colspan="2" | SPI Data In Pin SDI - Also Known as Master In Slave Out (MISO) when used in Master mode.
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-type-5-icon.png]]
| |
− | | width="90%" | CLK
| |
− | |-
| |
− | | colspan="2" | SPI Clock Pin CLK - The Clock signal is driven by the SPI master.
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-type-5-icon.png]]
| |
− | | width="90%" | CS / SS
| |
− | |-
| |
− | | colspan="2" | Chip Select / Slave Select Pin Master Mode: General purpose output pin used to select the remote SPI device. Slave Mode: Hardware chip select pin input used to select the SPI device.
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
| |
− | | width="90%" | Initial Prescaler
| |
− | |-
| |
− | | colspan="2" | SPI initial clock divider - Frequency should be under 400khz to allow startup to work correctly.
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
| |
− | | width="90%" | High Speed Prescaler
| |
− | |-
| |
− | | colspan="2" | SPI high speed clock divider - Once startup is complete this is the rate that will be used to transfer data
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
| |
− | | width="90%" style="background-color:#EAE1EA; color:#4B008D;" | File System
| |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-type-14-icon.png]]
| |
− | | width="90%" | Max Concurrent Files
| |
− | |-
| |
− | | colspan="2" | Specifies how many concurrent files can be opened at any one time. Use the SetFileIndex macro to switch between concurrent files.
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
| |
− | | width="90%" | End Of File
| |
− | |-
| |
− | | colspan="2" | Specifies the way the ReadByteFromFile function indicates the end of a file. 8 Bit mode - End of the file is represented by the value 0, read multiple times to confirm that the 0 is not simply data. 16 Bit mode - End of file is represented by the value 512 allowing the values 0 - 255 to represent valid data.
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
| |
− | | width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Simulation
| |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
| |
− | | width="90%" | Sim Type
| |
− | |-
| |
− | | colspan="2" | Defines the simulation type. The default is to use the Windows file system to allow for reading and writing files. The alternative is to use the CAL functionality to allow the SPI transactions to be passed onto a seperate handler e.g. for logging or debugging purposes.
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
| |
− | | width="90%" style="background-color:#EAE1EA; color:#4B008D;" | File System
| |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-type-20-icon.png]]
| |
− | | width="90%" | Root Directory
| |
− | |-
| |
− | | colspan="2" | Directory flagged as root for simulation Default: $(srcdir) is the current project source directory. Modern windows systems do not like you writing files to a hard drive root directory so a directory off the root is advised.
| |
− | |}==Macro reference==
| |
− | | |
− | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadStringFromFile'''
| |
− | |-
| |
− | | colspan="2" | Reads a string from the currently open file. Auto increments the position in the file. An empty string signifies the end of the file has been reached.
| |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| |
− | | width="90%" | NumBytes
| |
− | |-
| |
− | | colspan="2" | Maximum number of bytes to attempt to read
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| |
− | | width="90%" | EndChar
| |
− | |-
| |
− | | colspan="2" | Ends the string if the value specified is found, default is 0
| |
− | |-
| |
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-string-icon.png]] - STRING
| |
− | | width="90%" style="border-top: 2px solid #000;" | ''Return''
| |
− | |}
| |
− | | |
− | | |
− | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''WriteByteToBuffer'''
| |
− | |-
| |
− | | colspan="2" | Writes a single byte to the current 512 byte local sector buffer.
| |
| |- | | |- |
| |- | | |- |
Line 1,033: |
Line 366: |
| | width="90%" | Address | | | width="90%" | Address |
| |- | | |- |
− | | colspan="2" | Address Range 0 - 511 | + | | colspan="2" | 0 - 511 - Contains the position of the byte to be read |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| |
− | | width="90%" | Data
| |
− | |-
| |
− | | colspan="2" | Data Byte to write to the buffer
| |
− | |-
| |
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
| |
− | | width="90%" style="border-top: 2px solid #000;" | ''Return''
| |
− | |}
| |
− | | |
− | | |
− | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''MoveToNextFileSector'''
| |
− | |-
| |
− | | colspan="2" | Attempts to move to the next sector in the file. When reading a file you would leave force next sector set to 0. When writing a file you would leave force next sector set to 1 to allow new sectors to be created as the file grows. Returns 0 for success
| |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| |
− | | width="90%" | Force_Next_Sector
| |
− | |-
| |
− | | colspan="2" | 0 = Don't add new sector, 1 = Add new sector if we are at the end of the file
| |
− | |-
| |
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
| |
− | | width="90%" style="border-top: 2px solid #000;" | ''Return''
| |
− | |}
| |
− | | |
− | | |
− | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''AppendByteToFile'''
| |
− | |-
| |
− | | colspan="2" | Adds a single byte to the end of the currently open file, useful for inserting the value 0 into binary file types. Returns 0 for success.
| |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| |
− | | width="90%" | Data
| |
− | |-
| |
− | | colspan="2" | Data to append to the end of the file
| |
− | |-
| |
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
| |
− | | width="90%" style="border-top: 2px solid #000;" | ''Return''
| |
− | |}
| |
− | | |
− | | |
− | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadFileSector'''
| |
− | |-
| |
− | | colspan="2" | Overwrites local buffer with the current file sector from the disk. Used to restore the local sector buffer with the actual sector stored on the card. Return = 0 : Local buffer refreshed with current card sector Return > 0 : Error
| |
− | |-
| |
| |- | | |- |
| | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE | | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE |
Line 1,094: |
Line 373: |
| | | |
| | | |
− | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"
| + | ===ReadByteFromFile=== |
− | |-
| |
− | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''CloseFile'''
| |
− | |-
| |
− | | colspan="2" | Closes the current open file
| |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
| |
− | | width="90%" style="border-top: 2px solid #000;" | ''Return''
| |
− | |}
| |
− | | |
− | | |
| {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" |
| |- | | |- |
Line 1,120: |
Line 387: |
| | | |
| | | |
− | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"
| + | ===ReadByteFromIndex=== |
− | |-
| |
− | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''DeleteFile'''
| |
− | |-
| |
− | | colspan="2" | Searches for and deletes a file in the current folder location on the card. Default = Root Returns 0 for success.
| |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-string-icon.png]] - STRING
| |
− | | width="90%" | Filename
| |
− | |-
| |
− | | colspan="2" | 8.3 format filename e.g."file.txt"
| |
− | |-
| |
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
| |
− | | width="90%" style="border-top: 2px solid #000;" | ''Return''
| |
− | |}
| |
− | | |
− | | |
| {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" |
| |- | | |- |
Line 1,156: |
Line 406: |
| | | |
| | | |
− | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"
| + | ===ReadByteFromScan=== |
− | |-
| |
− | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''CreateFile'''
| |
− | |-
| |
− | | colspan="2" | Creates a file in the current folder location on the card. Default = Root Returns 0 for success File must be opened using "Open_File" after creation before writing any data.
| |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-string-icon.png]] - STRING
| |
− | | width="90%" | Filename
| |
− | |-
| |
− | | colspan="2" | 8.3 format filename e.g."file.txt"
| |
− | |-
| |
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
| |
− | | width="90%" style="border-top: 2px solid #000;" | ''Return''
| |
− | |}
| |
− | | |
− | | |
− | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ScanCurrentFolder'''
| |
− | |-
| |
− | | colspan="2" | Method for retreiving file or folder names for the card to allow for dynamic file opening or playback. Does not currently simulate. 0 - Filetype found and stored into string array, 1 - End of folder reached, 2 - Filetype mismatch 3 - Empty
| |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| |
− | | width="90%" | Current_Idx
| |
− | |-
| |
− | | colspan="2" | Contains the current pointer in the directory table. Values from 0 to 511 to completley search the current folder for a files or folders
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| |
− | | width="90%" | Scan_Type
| |
− | |-
| |
− | | colspan="2" | Sets the scan to search for Files or Folders. 0 = Scan for files, 1 = Scan for folders
| |
− | |-
| |
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
| |
− | | width="90%" style="border-top: 2px solid #000;" | ''Return''
| |
− | |}
| |
− | | |
− | | |
| {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" |
| |- | | |- |
Line 1,215: |
Line 425: |
| | | |
| | | |
− | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"
| + | ===ReadFileLength=== |
− | |-
| |
− | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''OpenFolder'''
| |
− | |-
| |
− | | colspan="2" | ".." - Jumps up a directory, if at root then remains in root "root" - Jumps directly back to the root directory "foldername" - Opens folder named foldername
| |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-string-icon.png]] - STRING
| |
− | | width="90%" | Folder_Name
| |
− | |-
| |
− | | colspan="2" |
| |
− | |-
| |
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
| |
− | | width="90%" style="border-top: 2px solid #000;" | ''Return''
| |
− | |}
| |
− | | |
− | | |
− | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadByteFromBuffer'''
| |
− | |-
| |
− | | colspan="2" | Reads a byte of data from the local sector buffer. Return = Data byte read from the local sector buffer.
| |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| |
− | | width="90%" | Address
| |
− | |-
| |
− | | colspan="2" | 0 - 511 - Contains the position of the byte to be read
| |
− | |-
| |
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
| |
− | | width="90%" style="border-top: 2px solid #000;" | ''Return''
| |
− | |}
| |
− | | |
− | | |
| {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" |
| |- | | |- |
Line 1,264: |
Line 439: |
| | | |
| | | |
| + | ===ReadFileSector=== |
| {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" |
| |- | | |- |
| | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''OpenFile''' | + | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadFileSector''' |
| |- | | |- |
− | | colspan="2" | Searches for and opens a file for reading or writing from within the current directory on the disk. Returns 0 for success. | + | | colspan="2" | Overwrites local buffer with the current file sector from the disk. Used to restore the local sector buffer with the actual sector stored on the card. Return = 0 : Local buffer refreshed with current card sector Return > 0 : Error |
| |- | | |- |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-string-icon.png]] - STRING
| |
− | | width="90%" | Filename
| |
− | |-
| |
− | | colspan="2" | 8.3 filename of the file we are trying to open e.g. "file.txt"
| |
| |- | | |- |
| | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE | | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE |
Line 1,282: |
Line 453: |
| | | |
| | | |
| + | ===ReadFileSize=== |
| {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" |
| |- | | |- |
| | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''WriteFileSector''' | + | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadFileSize''' |
| |- | | |- |
− | | colspan="2" | Overwrites the current sector on the memory card with the contents of the local sector buffer. See write_byte_to_buffer function. Return = 0 - File sector written successfully. Return > 0 - File sector write error | + | | colspan="2" | Reads the entire size of the current file in bytes. |
| |- | | |- |
| |- | | |- |
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE | + | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u32-icon.png]] - ULONG |
| | width="90%" style="border-top: 2px solid #000;" | ''Return'' | | | width="90%" style="border-top: 2px solid #000;" | ''Return'' |
| |} | | |} |
| | | |
| | | |
| + | ===ReadFloatArrayFromFile=== |
| {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" |
| |- | | |- |
| | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetFileIndex''' | + | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadFloatArrayFromFile''' |
| |- | | |- |
− | | colspan="2" | Sets the current file index and used to switch between several open file streams. Default = 0. | + | | colspan="2" | Reads a binary Float array from the currently open file. Auto increments the position in the file. Returns the number of values read. |
| |- | | |- |
| |- | | |- |
− | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | + | | width="10%" align="center" | [[File:Fc9-f32-icon.png]] - FLOAT |
− | | width="90%" | File_Index | + | | width="90%" | Data |
| |- | | |- |
− | | colspan="2" | File index ranges from 0 to (Max Concurrent Files - 1) | + | | colspan="2" | Data variable to populate with data |
| |- | | |- |
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID | + | | width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT |
− | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | + | | width="90%" | Length |
− | |}
| |
− | | |
− | | |
− | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"
| |
| |- | | |- |
− | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | + | | colspan="2" | Number of values to read |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''AppendStringToFile'''
| |
| |- | | |- |
− | | colspan="2" | Adds the contents of the data string parameter to the end of the currently open file. Returns 0 for success. | + | | width="10%" align="center" | [[File:Fc9-bool-icon.png]] - BOOL |
| + | | width="90%" | MSBFirst |
| |- | | |- |
| + | | colspan="2" | 0=LSB then MSB, 1=MSB then LSB |
| |- | | |- |
− | | width="10%" align="center" | [[File:Fc9-string-icon.png]] - STRING
| + | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u16-icon.png]] - UINT |
− | | width="90%" | Data_String
| |
− | |-
| |
− | | colspan="2" | Data to append to the end of the file
| |
− | |-
| |
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE | |
| | width="90%" style="border-top: 2px solid #000;" | ''Return'' | | | width="90%" style="border-top: 2px solid #000;" | ''Return'' |
| |} | | |} |
| | | |
| | | |
| + | ===ReadINTArrayFromFile=== |
| {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" |
| |- | | |- |
| | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadFileSize''' | + | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadINTArrayFromFile''' |
| + | |- |
| + | | colspan="2" | Reads a binary INT array from the currently open file. Auto increments the position in the file. Returns the number of values read. |
| + | |- |
| |- | | |- |
− | | colspan="2" | Reads the entire size of the current file in bytes. | + | | width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT |
| + | | width="90%" | Data |
| |- | | |- |
| + | | colspan="2" | Data variable to populate with data |
| |- | | |- |
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u32-icon.png]] - ULONG | + | | width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT |
− | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | + | | width="90%" | Length |
− | |}
| |
− | | |
− | | |
− | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"
| |
| |- | | |- |
− | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | + | | colspan="2" | Number of values to read |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''UpdateFileSector'''
| |
| |- | | |- |
− | | colspan="2" | Updates a file sector with new data set from using WriteByteToBuffer. Note this cannot alter the size of the file. | + | | width="10%" align="center" | [[File:Fc9-bool-icon.png]] - BOOL |
| + | | width="90%" | MSBFirst |
| |- | | |- |
| + | | colspan="2" | 0=LSB then MSB, 1=MSB then LSB |
| |- | | |- |
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID | + | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u16-icon.png]] - UINT |
| | width="90%" style="border-top: 2px solid #000;" | ''Return'' | | | width="90%" style="border-top: 2px solid #000;" | ''Return'' |
| |} | | |} |
| | | |
| | | |
| + | ===ReadLongArrayFromFile=== |
| {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" |
| |- | | |- |
| | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetTimeAndDate''' | + | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadLongArrayFromFile''' |
| |- | | |- |
− | | colspan="2" | Sets the current time and date. Time = (Hour << 11) + (Min << 5) + (Sec >> 1) Date = (YearFrom1980 << 9) + (Month << 5) + (Day) Additional details can be found here: http://www.maverick-os.dk/FileSystemFormats/FAT16_FileSystem.html#TimeFormat | + | | colspan="2" | Reads a binary Long array from the currently open file. Auto increments the position in the file. Returns the number of values read. |
| |- | | |- |
| |- | | |- |
− | | width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT | + | | width="10%" align="center" | [[File:Fc9-u32-icon.png]] - ULONG |
− | | width="90%" | Time | + | | width="90%" | Data |
| |- | | |- |
− | | colspan="2" | Sets the current Time in FAT Time format hhhhhmmmmmmsssss - S=Secs/2 | + | | colspan="2" | Data variable to populate with data |
| |- | | |- |
| | width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT | | | width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT |
− | | width="90%" | Date | + | | width="90%" | Length |
| |- | | |- |
− | | colspan="2" | Sets the current Date in FAT Date format yyyyyyymmmmddddd - Y=Years since 1980 | + | | colspan="2" | Number of values to read |
| |- | | |- |
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID | + | | width="10%" align="center" | [[File:Fc9-bool-icon.png]] - BOOL |
− | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | + | | width="90%" | MSBFirst |
− | |}
| |
− | | |
− | | |
− | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"
| |
| |- | | |- |
− | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | + | | colspan="2" | 0=LSB then MSB, 1=MSB then LSB |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Initialise''' | |
| |- | | |- |
− | | colspan="2" | Attempts to communicate with the SD card and if successful sets up the file system. Returns 0 for success.
| + | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u16-icon.png]] - UINT |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE | |
| | width="90%" style="border-top: 2px solid #000;" | ''Return'' | | | width="90%" style="border-top: 2px solid #000;" | ''Return'' |
| |} | | |} |
| | | |
| | | |
− | | + | ===ReadStringFromFile=== |
− | | |
− | ==Property reference== | |
− | | |
− | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#D8C9D8;" | [[File:Fc9-prop-icon.png]]
| |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Properties'''
| |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
| |
− | | width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Connections
| |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
| |
− | | width="90%" | Channel
| |
− | |-
| |
− | | colspan="2" | SPI Channel selector
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-type-5-icon.png]]
| |
− | | width="90%" | MOSI
| |
− | |-
| |
− | | colspan="2" | SPI Data Out Pin SDO - Also Known as Master Out Slave In (MOSI) when used in Master mode.
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-type-5-icon.png]]
| |
− | | width="90%" | MISO
| |
− | |-
| |
− | | colspan="2" | SPI Data In Pin SDI - Also Known as Master In Slave Out (MISO) when used in Master mode.
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-type-5-icon.png]]
| |
− | | width="90%" | CLK
| |
− | |-
| |
− | | colspan="2" | SPI Clock Pin CLK - The Clock signal is driven by the SPI master.
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-type-5-icon.png]]
| |
− | | width="90%" | CS / SS
| |
− | |-
| |
− | | colspan="2" | Chip Select / Slave Select Pin Master Mode: General purpose output pin used to select the remote SPI device. Slave Mode: Hardware chip select pin input used to select the SPI device.
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
| |
− | | width="90%" | Initial Prescaler
| |
− | |-
| |
− | | colspan="2" | SPI initial clock divider - Frequency should be under 400khz to allow startup to work correctly.
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
| |
− | | width="90%" | High Speed Prescaler
| |
− | |-
| |
− | | colspan="2" | SPI high speed clock divider - Once startup is complete this is the rate that will be used to transfer data
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
| |
− | | width="90%" style="background-color:#EAE1EA; color:#4B008D;" | File System
| |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-type-14-icon.png]]
| |
− | | width="90%" | Max Concurrent Files
| |
− | |-
| |
− | | colspan="2" | Specifies how many concurrent files can be opened at any one time. Use the SetFileIndex macro to switch between concurrent files.
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
| |
− | | width="90%" | End Of File
| |
− | |-
| |
− | | colspan="2" | Specifies the way the ReadByteFromFile function indicates the end of a file. 8 Bit mode - End of the file is represented by the value 0, read multiple times to confirm that the 0 is not simply data. 16 Bit mode - End of file is represented by the value 512 allowing the values 0 - 255 to represent valid data.
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
| |
− | | width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Simulation
| |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
| |
− | | width="90%" | Sim Type
| |
− | |-
| |
− | | colspan="2" | Defines the simulation type. The default is to use the Windows file system to allow for reading and writing files. The alternative is to use the CAL functionality to allow the SPI transactions to be passed onto a seperate handler e.g. for logging or debugging purposes.
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
| |
− | | width="90%" style="background-color:#EAE1EA; color:#4B008D;" | File System
| |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-type-20-icon.png]]
| |
− | | width="90%" | Root Directory
| |
− | |-
| |
− | | colspan="2" | Directory flagged as root for simulation Default: $(srcdir) is the current project source directory. Modern windows systems do not like you writing files to a hard drive root directory so a directory off the root is advised.
| |
− | |}==Macro reference==
| |
− | | |
| {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" |
| |- | | |- |
Line 1,498: |
Line 578: |
| | | |
| | | |
− | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"
| + | ===ScanCurrentFolder=== |
− | |-
| |
− | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''WriteByteToBuffer'''
| |
− | |-
| |
− | | colspan="2" | Writes a single byte to the current 512 byte local sector buffer.
| |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| |
− | | width="90%" | Address
| |
− | |-
| |
− | | colspan="2" | Address Range 0 - 511
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| |
− | | width="90%" | Data
| |
− | |-
| |
− | | colspan="2" | Data Byte to write to the buffer
| |
− | |-
| |
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
| |
− | | width="90%" style="border-top: 2px solid #000;" | ''Return''
| |
− | |}
| |
− | | |
− | | |
− | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''MoveToNextFileSector'''
| |
− | |-
| |
− | | colspan="2" | Attempts to move to the next sector in the file. When reading a file you would leave force next sector set to 0. When writing a file you would leave force next sector set to 1 to allow new sectors to be created as the file grows. Returns 0 for success
| |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| |
− | | width="90%" | Force_Next_Sector
| |
− | |-
| |
− | | colspan="2" | 0 = Don't add new sector, 1 = Add new sector if we are at the end of the file
| |
− | |-
| |
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
| |
− | | width="90%" style="border-top: 2px solid #000;" | ''Return''
| |
− | |}
| |
− | | |
− | | |
− | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''AppendByteToFile'''
| |
− | |-
| |
− | | colspan="2" | Adds a single byte to the end of the currently open file, useful for inserting the value 0 into binary file types. Returns 0 for success.
| |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| |
− | | width="90%" | Data
| |
− | |-
| |
− | | colspan="2" | Data to append to the end of the file
| |
− | |-
| |
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
| |
− | | width="90%" style="border-top: 2px solid #000;" | ''Return''
| |
− | |}
| |
− | | |
− | | |
− | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadFileSector'''
| |
− | |-
| |
− | | colspan="2" | Overwrites local buffer with the current file sector from the disk. Used to restore the local sector buffer with the actual sector stored on the card. Return = 0 : Local buffer refreshed with current card sector Return > 0 : Error
| |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
| |
− | | width="90%" style="border-top: 2px solid #000;" | ''Return''
| |
− | |}
| |
− | | |
− | | |
− | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''CloseFile'''
| |
− | |-
| |
− | | colspan="2" | Closes the current open file
| |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
| |
− | | width="90%" style="border-top: 2px solid #000;" | ''Return''
| |
− | |}
| |
− | | |
− | | |
− | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadByteFromFile'''
| |
− | |-
| |
− | | colspan="2" | Reads a byte from the currently open file. Auto increments the position in the file. A return value of 0 may signify the end of the file has been reached (depending on the contents of the file).
| |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u16-icon.png]] - UINT
| |
− | | width="90%" style="border-top: 2px solid #000;" | ''Return''
| |
− | |}
| |
− | | |
− | | |
− | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''DeleteFile'''
| |
− | |-
| |
− | | colspan="2" | Searches for and deletes a file in the current folder location on the card. Default = Root Returns 0 for success.
| |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-string-icon.png]] - STRING
| |
− | | width="90%" | Filename
| |
− | |-
| |
− | | colspan="2" | 8.3 format filename e.g."file.txt"
| |
− | |-
| |
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
| |
− | | width="90%" style="border-top: 2px solid #000;" | ''Return''
| |
− | |}
| |
− | | |
− | | |
− | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadByteFromIndex'''
| |
− | |-
| |
− | | colspan="2" | Reads an arbitrary byte of data from the current open file. Return = Data byte read from the local sector buffer. Experimental and potentially slow if navigating backwards through the file.
| |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-u32-icon.png]] - ULONG
| |
− | | width="90%" | Address
| |
− | |-
| |
− | | colspan="2" | Contains the position of the byte to be read from the file
| |
− | |-
| |
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
| |
− | | width="90%" style="border-top: 2px solid #000;" | ''Return''
| |
− | |}
| |
− | | |
− | | |
− | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''CreateFile'''
| |
− | |-
| |
− | | colspan="2" | Creates a file in the current folder location on the card. Default = Root Returns 0 for success File must be opened using "Open_File" after creation before writing any data.
| |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-string-icon.png]] - STRING
| |
− | | width="90%" | Filename
| |
− | |-
| |
− | | colspan="2" | 8.3 format filename e.g."file.txt"
| |
− | |-
| |
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
| |
− | | width="90%" style="border-top: 2px solid #000;" | ''Return''
| |
− | |}
| |
− | | |
− | | |
| {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" |
| |- | | |- |
Line 1,673: |
Line 602: |
| | | |
| | | |
− | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"
| + | ===SetFileIndex=== |
− | |-
| |
− | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadByteFromScan'''
| |
− | |-
| |
− | | colspan="2" | Returns a byte of the name of the file or folder retreived from the Scan_Current_folder function. Return = ASCII byte at position Idx from the folder name or file name at position Current_Idx in the directory
| |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| |
− | | width="90%" | idx
| |
− | |-
| |
− | | colspan="2" | 0 - 11 for a file, 0 - 7 for a folder
| |
− | |-
| |
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
| |
− | | width="90%" style="border-top: 2px solid #000;" | ''Return''
| |
− | |}
| |
− | | |
− | | |
− | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''OpenFolder'''
| |
− | |-
| |
− | | colspan="2" | ".." - Jumps up a directory, if at root then remains in root "root" - Jumps directly back to the root directory "foldername" - Opens folder named foldername
| |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-string-icon.png]] - STRING
| |
− | | width="90%" | Folder_Name
| |
− | |-
| |
− | | colspan="2" |
| |
− | |-
| |
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
| |
− | | width="90%" style="border-top: 2px solid #000;" | ''Return''
| |
− | |}
| |
− | | |
− | | |
− | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadByteFromBuffer'''
| |
− | |-
| |
− | | colspan="2" | Reads a byte of data from the local sector buffer. Return = Data byte read from the local sector buffer.
| |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| |
− | | width="90%" | Address
| |
− | |-
| |
− | | colspan="2" | 0 - 511 - Contains the position of the byte to be read
| |
− | |-
| |
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
| |
− | | width="90%" style="border-top: 2px solid #000;" | ''Return''
| |
− | |}
| |
− | | |
− | | |
− | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadFileLength'''
| |
− | |-
| |
− | | colspan="2" | Returns the number of bytes in the current sector that are used by the current open file. Return = 512 - Sector is filled with file data Return < 512 - Last sector of the file, Retval specifies how many bytes of data are remaining in the sector
| |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-s16-icon.png]] - INT
| |
− | | width="90%" style="border-top: 2px solid #000;" | ''Return''
| |
− | |}
| |
− | | |
− | | |
− | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''OpenFile'''
| |
− | |-
| |
− | | colspan="2" | Searches for and opens a file for reading or writing from within the current directory on the disk. Returns 0 for success.
| |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" | [[File:Fc9-string-icon.png]] - STRING
| |
− | | width="90%" | Filename
| |
− | |-
| |
− | | colspan="2" | 8.3 filename of the file we are trying to open e.g. "file.txt"
| |
− | |-
| |
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
| |
− | | width="90%" style="border-top: 2px solid #000;" | ''Return''
| |
− | |}
| |
− | | |
− | | |
− | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"
| |
− | |-
| |
− | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''WriteFileSector'''
| |
− | |-
| |
− | | colspan="2" | Overwrites the current sector on the memory card with the contents of the local sector buffer. See write_byte_to_buffer function. Return = 0 - File sector written successfully. Return > 0 - File sector write error
| |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
| |
− | | width="90%" style="border-top: 2px solid #000;" | ''Return''
| |
− | |}
| |
− | | |
− | | |
| {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" |
| |- | | |- |
Line 1,789: |
Line 621: |
| | | |
| | | |
| + | ===SetTimeAndDate=== |
| {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" |
| |- | | |- |
| | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''AppendStringToFile''' | + | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetTimeAndDate''' |
| |- | | |- |
− | | colspan="2" | Adds the contents of the data string parameter to the end of the currently open file. Returns 0 for success. | + | | colspan="2" | Sets the current time and date. Time = (Hour << 11) + (Min << 5) + (Sec >> 1) Date = (YearFrom1980 << 9) + (Month << 5) + (Day) Additional details can be found here: http://www.maverick-os.dk/FileSystemFormats/FAT16_FileSystem.html#TimeFormat |
| |- | | |- |
| |- | | |- |
− | | width="10%" align="center" | [[File:Fc9-string-icon.png]] - STRING | + | | width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT |
− | | width="90%" | Data_String | + | | width="90%" | Time |
| |- | | |- |
− | | colspan="2" | Data to append to the end of the file | + | | colspan="2" | Sets the current Time in FAT Time format hhhhhmmmmmmsssss - S=Secs/2 |
| |- | | |- |
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE | + | | width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT |
− | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | + | | width="90%" | Date |
− | |}
| |
− | | |
− | | |
− | {| class="wikitable" style="width:60%; background-color:#FFFFFF;"
| |
| |- | | |- |
− | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | + | | colspan="2" | Sets the current Date in FAT Date format yyyyyyymmmmddddd - Y=Years since 1980 |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadFileSize'''
| |
| |- | | |- |
− | | colspan="2" | Reads the entire size of the current file in bytes.
| + | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID |
− | |-
| |
− | |-
| |
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u32-icon.png]] - ULONG | |
| | width="90%" style="border-top: 2px solid #000;" | ''Return'' | | | width="90%" style="border-top: 2px solid #000;" | ''Return'' |
| |} | | |} |
| | | |
| | | |
| + | ===UpdateFileSector=== |
| {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" |
| |- | | |- |
Line 1,833: |
Line 659: |
| | | |
| | | |
| + | ===WriteByteToBuffer=== |
| {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" |
| |- | | |- |
| | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetTimeAndDate''' | + | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''WriteByteToBuffer''' |
| |- | | |- |
− | | colspan="2" | Sets the current time and date. Time = (Hour << 11) + (Min << 5) + (Sec >> 1) Date = (YearFrom1980 << 9) + (Month << 5) + (Day) Additional details can be found here: http://www.maverick-os.dk/FileSystemFormats/FAT16_FileSystem.html#TimeFormat | + | | colspan="2" | Writes a single byte to the current 512 byte local sector buffer. |
| |- | | |- |
| |- | | |- |
| | width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT | | | width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT |
− | | width="90%" | Time | + | | width="90%" | Address |
| |- | | |- |
− | | colspan="2" | Sets the current Time in FAT Time format hhhhhmmmmmmsssss - S=Secs/2 | + | | colspan="2" | Address Range 0 - 511 |
| |- | | |- |
− | | width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT | + | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE |
− | | width="90%" | Date | + | | width="90%" | Data |
| |- | | |- |
− | | colspan="2" | Sets the current Date in FAT Date format yyyyyyymmmmddddd - Y=Years since 1980 | + | | colspan="2" | Data Byte to write to the buffer |
| |- | | |- |
| | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID | | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID |
Line 1,856: |
Line 683: |
| | | |
| | | |
| + | ===WriteFileSector=== |
| {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" |
| |- | | |- |
| | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] |
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Initialise''' | + | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''WriteFileSector''' |
| |- | | |- |
− | | colspan="2" | Attempts to communicate with the SD card and if successful sets up the file system. Returns 0 for success. | + | | colspan="2" | Overwrites the current sector on the memory card with the contents of the local sector buffer. See write_byte_to_buffer function. Return = 0 - File sector written successfully. Return > 0 - File sector write error |
| |- | | |- |
| |- | | |- |
Line 1,867: |
Line 695: |
| | width="90%" style="border-top: 2px solid #000;" | ''Return'' | | | width="90%" style="border-top: 2px solid #000;" | ''Return'' |
| |} | | |} |
− |
| |
− |
| |
| | | |
| | | |