diff options
Diffstat (limited to 'frontends/calculator/CEdev/examples/fileio_read_write')
5 files changed, 300 insertions, 300 deletions
diff --git a/frontends/calculator/CEdev/examples/fileio_read_write/autotester.json b/frontends/calculator/CEdev/examples/fileio_read_write/autotester.json index bd30851..77be90b 100644 --- a/frontends/calculator/CEdev/examples/fileio_read_write/autotester.json +++ b/frontends/calculator/CEdev/examples/fileio_read_write/autotester.json @@ -1,33 +1,33 @@ -{ - "rom": "84pce_515.rom", - "transfer_files": [ - "bin/DEMO.8xp" - ], - "target": { - "name": "DEMO", - "isASM": true - }, - "sequence": [ - "action|launch", - "delay|1000", - "hash|1", - "key|enter", - "delay|200", - "hashWait|2" - ], - "hashes": { - "1": { - "description": "Assert that the read was succesful", - "start": "vram_start", - "size": "vram_16_size", - "expected_CRCs": [ "D720F0D9" ] - }, - "2": { - "description": "Back to the home screen (exit check)", - "start": "vram_start", - "size": "vram_16_size", - "expected_CRCs": [ "FFAF89BA", "101734A5", "9DA19F44" ] - } - } -} - +{
+ "rom": "84pce_515.rom",
+ "transfer_files": [
+ "bin/DEMO.8xp"
+ ],
+ "target": {
+ "name": "DEMO",
+ "isASM": true
+ },
+ "sequence": [
+ "action|launch",
+ "delay|1000",
+ "hash|1",
+ "key|enter",
+ "delay|200",
+ "hashWait|2"
+ ],
+ "hashes": {
+ "1": {
+ "description": "Assert that the read was succesful",
+ "start": "vram_start",
+ "size": "vram_16_size",
+ "expected_CRCs": [ "D720F0D9" ]
+ },
+ "2": {
+ "description": "Back to the home screen (exit check)",
+ "start": "vram_start",
+ "size": "vram_16_size",
+ "expected_CRCs": [ "FFAF89BA", "101734A5", "9DA19F44" ]
+ }
+ }
+}
+
diff --git a/frontends/calculator/CEdev/examples/fileio_read_write/bin/DEMO.map b/frontends/calculator/CEdev/examples/fileio_read_write/bin/DEMO.map index 7cf5131..6d7aa9a 100644 --- a/frontends/calculator/CEdev/examples/fileio_read_write/bin/DEMO.map +++ b/frontends/calculator/CEdev/examples/fileio_read_write/bin/DEMO.map @@ -1,154 +1,154 @@ -Segment Base Top High Length --------- ------ ------ ------ ------- -icon D1A882 D1A882 0h -launcher D1A882 D1A8DA 58h -libs D1A8DA D1A906 2Ch -startup D1A906 D1A945 3Fh -cleanup D1A945 D1A959 14h -exit D1A959 D1A95F 6h -code D1A95F D1AB0A 1ABh -data D1AB0A D1AB2F 25h -strsect D1AB2F D1AB6E 3Fh -text D1AB6E D1AB6E 0h -bss D031F6 D03207 D13FD6 11h -header D1A87F D1A882 3h - -Label Value -------------------------- ------ -_os_DisableHomeTextBuffer = D1A95F -_os_EnableHomeTextBuffer = D1A971 -_boot_GetBootMajorVer = 000080 -_boot_GetHardwareVer = 000084 -_boot_GetBootMinorVer = 00008C -_boot_DebugPrintf = 0000B4 -_boot_ClearVRAM = 000374 -_boot_TurnOff = 000388 -_boot_NewLine = 000390 -_boot_Set6MHzMode = 00039C -_boot_Set48MHzMode = 0003A0 -_boot_Set6MHzModeI = 0003A4 -_boot_Set48MHzModeI = 0003A8 -_boot_GetBatteryStatus = 0003B0 -_boot_WaitShort = 0003B4 -_boot_CheckOnPressed = 00057C -_boot_SetDate = 000598 -_boot_GetDate = 0005A8 -_boot_GetTime = 0005B0 -_boot_SetTime = 0005B4 -_boot_IsAfterNoon = 0005C8 -_os_NewLine = 0207F0 -_os_PushErrorHandler = 021C78 -_os_PopErrorHandler = 021C7C -_os_ThrowError = 021C80 -_os_RealCopy = 021C84 -_os_RealAsinRad = 021C88 -_os_RealAcosRad = 021C8C -_os_RealAtanRad = 021C90 -_os_RealAdd = 021C94 -_os_CplxSquare = 021C98 -_os_RealCompare = 021C9C -_os_RealCosRad = 021CA0 -_os_RealRadToDeg = 021CA4 -_os_RealDiv = 021CA8 -_os_RealExp = 021CAC -_os_RealFloor = 021CB0 -_os_RealToStr = 021CB4 -_os_RealFrac = 021CB8 -_os_RealGcd = 021CBC -_os_RealRoundInt = 021CC0 -_os_RealLcm = 021CC4 -_os_RealLog = 021CC8 -_os_RealMax = 021CCC -_os_RealMin = 021CD0 -_os_RealMul = 021CD4 -_os_RealNcr = 021CD8 -_os_RealNeg = 021CDC -_os_RealNpr = 021CE0 -_os_RealPow = 021CE4 -_os_RealDegToRad = 021CE8 -_os_RealRandInt = 021CEC -_os_RealInv = 021CF0 -_os_RealMod = 021CF4 -_os_RealRound = 021CF8 -_os_RealSinRad = 021CFC -_os_RealSqrt = 021D00 -_os_RealSub = 021D04 -_os_RealTanRad = 021D08 -_os_StrToReal = 021D0C -_os_RealInt = 021D10 -_os_SetFlagBits = 021D14 -_os_ResetFlagBits = 021D18 -_os_TestFlagBits = 021D1C -_os_SetFlagByte = 021D20 -_os_GetFlagByte = 021D24 -_os_GetCursorPos = 021D28 -_os_PutStrFull = 021D2C -_os_PutStrLine = 021D30 -_os_SetCursorPos = 021D34 -_os_AppInit = 021D40 -_os_GetKey = 021D38 -_os_GetCSC = 021D3C -_os_DisableCursor = 021DE4 -_os_EnableCursor = 021DE8 -_os_FontDrawText = 021E00 -_os_FontGetHeight = 021E14 -_os_FontGetWidth = 021E18 -_os_InitDrawing = 021E1C -_os_SetDrawBGColor = 021E20 -_os_SetDrawFGColor = 021E24 -_os_FontSelect = 021E28 -_os_RclAns = 021E70 -_os_SetTimer1 = 021EC8 -_os_DisableTimer1 = 021ECC -_os_GetSystemStats = 021ED4 -_os_GetDrawBGColor = 021EE4 -_os_GetDrawFGColor = 021EE8 -_os_FontGetID = 021EEC -_os_RealToInt24 = 021EF4 -_os_Int24ToReal = 021EF8 -_os_ForceCmdNoChar = 021FA8 -_os_GetSymTablePtr = 021FB0 -_os_NextSymEntry = 021FB4 -_os_ChkFindSym = 021FB8 -_os_MemChk = 021FF0 -_os_SetTimer2 = 022080 -_os_DisableTimer2 = 022084 -_os_FloatToReal = 022170 -_os_RealToFloat = 022174 -_os_FontDrawTransText = 022178 -_os_CreateAppVar = 022184 -_asm_MoveDown = 0207F4 -_asm_MoveUp = 020800 -_asm_ClrLCDFull = 020808 -_asm_ClrLCD = 02080C -_asm_ClrTxtShd = 020818 -_asm_HomeUp = 020828 -_asm_RunIndicOn = 020844 -_asm_RunIndicOff = 020848 -_asm_DelRes = 020E5C -_asm_DisableAPD = 021134 -_asm_EnableAPD = 021138 -_asm_DrawStatusBar = 021A3C -_asm_ArcChk = 022040 -__OS = D1A983 -__frameset0 = D1A98D -__frameset = D1A998 -_strcpy = 0000CC -__findlibload = D1A882 -__ccleanup = D1A945 -_errno = D008DC -_init = D1A882 -_exit = D1A95B -__exit = D1A934 -__exitsp = D1A934 -__errsp = D1A934 -_printText = D1AAE8 -_main = D1A9A6 -_data = D031F6 -_appvarName = D1AB2C -_ti_CloseAll = D1A8EE -_ti_Open = D1A8F2 -_ti_Write = D1A8F6 -_ti_Read = D1A8FA -_ti_Rewind = D1A8FE -_ti_GetName = D1A902 +Segment Base Top High Length
+-------- ------ ------ ------ -------
+icon D1A882 D1A882 0h
+launcher D1A882 D1A8DA 58h
+libs D1A8DA D1A906 2Ch
+startup D1A906 D1A945 3Fh
+cleanup D1A945 D1A959 14h
+exit D1A959 D1A95F 6h
+code D1A95F D1AB0A 1ABh
+data D1AB0A D1AB2F 25h
+strsect D1AB2F D1AB6E 3Fh
+text D1AB6E D1AB6E 0h
+bss D031F6 D03207 D13FD6 11h
+header D1A87F D1A882 3h
+
+Label Value
+------------------------- ------
+_os_DisableHomeTextBuffer = D1A95F
+_os_EnableHomeTextBuffer = D1A971
+_boot_GetBootMajorVer = 000080
+_boot_GetHardwareVer = 000084
+_boot_GetBootMinorVer = 00008C
+_boot_DebugPrintf = 0000B4
+_boot_ClearVRAM = 000374
+_boot_TurnOff = 000388
+_boot_NewLine = 000390
+_boot_Set6MHzMode = 00039C
+_boot_Set48MHzMode = 0003A0
+_boot_Set6MHzModeI = 0003A4
+_boot_Set48MHzModeI = 0003A8
+_boot_GetBatteryStatus = 0003B0
+_boot_WaitShort = 0003B4
+_boot_CheckOnPressed = 00057C
+_boot_SetDate = 000598
+_boot_GetDate = 0005A8
+_boot_GetTime = 0005B0
+_boot_SetTime = 0005B4
+_boot_IsAfterNoon = 0005C8
+_os_NewLine = 0207F0
+_os_PushErrorHandler = 021C78
+_os_PopErrorHandler = 021C7C
+_os_ThrowError = 021C80
+_os_RealCopy = 021C84
+_os_RealAsinRad = 021C88
+_os_RealAcosRad = 021C8C
+_os_RealAtanRad = 021C90
+_os_RealAdd = 021C94
+_os_CplxSquare = 021C98
+_os_RealCompare = 021C9C
+_os_RealCosRad = 021CA0
+_os_RealRadToDeg = 021CA4
+_os_RealDiv = 021CA8
+_os_RealExp = 021CAC
+_os_RealFloor = 021CB0
+_os_RealToStr = 021CB4
+_os_RealFrac = 021CB8
+_os_RealGcd = 021CBC
+_os_RealRoundInt = 021CC0
+_os_RealLcm = 021CC4
+_os_RealLog = 021CC8
+_os_RealMax = 021CCC
+_os_RealMin = 021CD0
+_os_RealMul = 021CD4
+_os_RealNcr = 021CD8
+_os_RealNeg = 021CDC
+_os_RealNpr = 021CE0
+_os_RealPow = 021CE4
+_os_RealDegToRad = 021CE8
+_os_RealRandInt = 021CEC
+_os_RealInv = 021CF0
+_os_RealMod = 021CF4
+_os_RealRound = 021CF8
+_os_RealSinRad = 021CFC
+_os_RealSqrt = 021D00
+_os_RealSub = 021D04
+_os_RealTanRad = 021D08
+_os_StrToReal = 021D0C
+_os_RealInt = 021D10
+_os_SetFlagBits = 021D14
+_os_ResetFlagBits = 021D18
+_os_TestFlagBits = 021D1C
+_os_SetFlagByte = 021D20
+_os_GetFlagByte = 021D24
+_os_GetCursorPos = 021D28
+_os_PutStrFull = 021D2C
+_os_PutStrLine = 021D30
+_os_SetCursorPos = 021D34
+_os_AppInit = 021D40
+_os_GetKey = 021D38
+_os_GetCSC = 021D3C
+_os_DisableCursor = 021DE4
+_os_EnableCursor = 021DE8
+_os_FontDrawText = 021E00
+_os_FontGetHeight = 021E14
+_os_FontGetWidth = 021E18
+_os_InitDrawing = 021E1C
+_os_SetDrawBGColor = 021E20
+_os_SetDrawFGColor = 021E24
+_os_FontSelect = 021E28
+_os_RclAns = 021E70
+_os_SetTimer1 = 021EC8
+_os_DisableTimer1 = 021ECC
+_os_GetSystemStats = 021ED4
+_os_GetDrawBGColor = 021EE4
+_os_GetDrawFGColor = 021EE8
+_os_FontGetID = 021EEC
+_os_RealToInt24 = 021EF4
+_os_Int24ToReal = 021EF8
+_os_ForceCmdNoChar = 021FA8
+_os_GetSymTablePtr = 021FB0
+_os_NextSymEntry = 021FB4
+_os_ChkFindSym = 021FB8
+_os_MemChk = 021FF0
+_os_SetTimer2 = 022080
+_os_DisableTimer2 = 022084
+_os_FloatToReal = 022170
+_os_RealToFloat = 022174
+_os_FontDrawTransText = 022178
+_os_CreateAppVar = 022184
+_asm_MoveDown = 0207F4
+_asm_MoveUp = 020800
+_asm_ClrLCDFull = 020808
+_asm_ClrLCD = 02080C
+_asm_ClrTxtShd = 020818
+_asm_HomeUp = 020828
+_asm_RunIndicOn = 020844
+_asm_RunIndicOff = 020848
+_asm_DelRes = 020E5C
+_asm_DisableAPD = 021134
+_asm_EnableAPD = 021138
+_asm_DrawStatusBar = 021A3C
+_asm_ArcChk = 022040
+__OS = D1A983
+__frameset0 = D1A98D
+__frameset = D1A998
+_strcpy = 0000CC
+__findlibload = D1A882
+__ccleanup = D1A945
+_errno = D008DC
+_init = D1A882
+_exit = D1A95B
+__exit = D1A934
+__exitsp = D1A934
+__errsp = D1A934
+_printText = D1AAE8
+_main = D1A9A6
+_data = D031F6
+_appvarName = D1AB2C
+_ti_CloseAll = D1A8EE
+_ti_Open = D1A8F2
+_ti_Write = D1A8F6
+_ti_Read = D1A8FA
+_ti_Rewind = D1A8FE
+_ti_GetName = D1A902
diff --git a/frontends/calculator/CEdev/examples/fileio_read_write/makefile b/frontends/calculator/CEdev/examples/fileio_read_write/makefile index 1f1b36b..d3deba8 100644 --- a/frontends/calculator/CEdev/examples/fileio_read_write/makefile +++ b/frontends/calculator/CEdev/examples/fileio_read_write/makefile @@ -1,15 +1,15 @@ -# ---------------------------- -# Set NAME to the program name -# Set ICON to the png icon file name -# Set DESCRIPTION to display within a compatible shell -# Set COMPRESSED to "YES" to create a compressed program -# ---------------------------- - -NAME ?= DEMO -COMPRESSED ?= NO -ICON ?= iconc.png -DESCRIPTION ?= "C SDK Demo" - -# ---------------------------- - -include $(CEDEV)/include/.makefile +# ----------------------------
+# Set NAME to the program name
+# Set ICON to the png icon file name
+# Set DESCRIPTION to display within a compatible shell
+# Set COMPRESSED to "YES" to create a compressed program
+# ----------------------------
+
+NAME ?= DEMO
+COMPRESSED ?= NO
+ICON ?= iconc.png
+DESCRIPTION ?= "C SDK Demo"
+
+# ----------------------------
+
+include $(CEDEV)/include/.makefile
diff --git a/frontends/calculator/CEdev/examples/fileio_read_write/readme.md b/frontends/calculator/CEdev/examples/fileio_read_write/readme.md index 8666507..5c3a134 100644 --- a/frontends/calculator/CEdev/examples/fileio_read_write/readme.md +++ b/frontends/calculator/CEdev/examples/fileio_read_write/readme.md @@ -1,10 +1,10 @@ -### FileIO Write/Read Demo - -This example demonstrates writing some data to a file and then reading it back out to make sure it was written correctly - - - ---- - -This demo is a part of the C SDK Toolchain for use on the CE. - +### FileIO Write/Read Demo
+
+This example demonstrates writing some data to a file and then reading it back out to make sure it was written correctly
+
+
+
+---
+
+This demo is a part of the C SDK Toolchain for use on the CE.
+
diff --git a/frontends/calculator/CEdev/examples/fileio_read_write/src/main.c b/frontends/calculator/CEdev/examples/fileio_read_write/src/main.c index a776037..4747b99 100644 --- a/frontends/calculator/CEdev/examples/fileio_read_write/src/main.c +++ b/frontends/calculator/CEdev/examples/fileio_read_write/src/main.c @@ -1,88 +1,88 @@ -#include <stdbool.h> -#include <stddef.h> -#include <stdint.h> -#include <tice.h> - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include <fileioc.h> - -/* Declare some variables */ -const char *appvarName = "AppVar"; - -typedef struct { - char name[15]; - uint8_t var1; - uint8_t var2; -} data_t; - -data_t data; - -#define VAR1_VALUE 10 -#define VAR2_VALUE 20 - -/* Function prototypes */ -void printText(int8_t xpos, int8_t ypos, const char *text); - -/* Main Function */ -void main(void) { - char nameBuffer[10]; - ti_var_t myAppVar; - int x; - - /* Clear the homescreen */ - os_ClrHome(); - - /* Declare some variable values */ - strcpy(data.name, "My Data"); - data.var1 = VAR1_VALUE; - data.var2 = VAR2_VALUE; - - /* Close any files that may be open already */ - ti_CloseAll(); - - /* Open a new variable; deleting it if it already exists */ - myAppVar = ti_Open(appvarName, "w"); - - /* Make sure we opened okay */ - if (!myAppVar) goto err; - - /* Write the structure to the appvar */ - if (ti_Write(&data, sizeof(data_t), 1, myAppVar) != 1) goto err; - - /* Go back to the start of the file */ - if (ti_Rewind(myAppVar) == EOF) goto err; - - /* Let's read it just to make sure we wrote it correctly */ - if (ti_Read(&data, sizeof(data_t), 1, myAppVar) != 1) goto err; - - /* Make sure we read these variables correctly too */ - if (data.var1 != VAR1_VALUE && data.var2 != VAR2_VALUE) goto err; - - /* Ensure the name of the AppVar is correct */ - ti_GetName(nameBuffer, myAppVar); - - printText(0, 0, "Appvar: "); - printText(8, 0, nameBuffer); - printText(0, 1, "Read was successful"); - goto noerr; - -err: - printText(0, 0, "An error occured"); -noerr: - - /* Pause */ - while (!os_GetCSC()); - - /* Close all open files */ - ti_CloseAll(); -} - -/* Draw text on the homescreen at the given X/Y location */ -void printText(int8_t xpos, int8_t ypos, const char *text) { - os_SetCursorPos(ypos, xpos); - os_PutStrFull(text); -} - +#include <stdbool.h>
+#include <stddef.h>
+#include <stdint.h>
+#include <tice.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <fileioc.h>
+
+/* Declare some variables */
+const char *appvarName = "AppVar";
+
+typedef struct {
+ char name[15];
+ uint8_t var1;
+ uint8_t var2;
+} data_t;
+
+data_t data;
+
+#define VAR1_VALUE 10
+#define VAR2_VALUE 20
+
+/* Function prototypes */
+void printText(int8_t xpos, int8_t ypos, const char *text);
+
+/* Main Function */
+void main(void) {
+ char nameBuffer[10];
+ ti_var_t myAppVar;
+ int x;
+
+ /* Clear the homescreen */
+ os_ClrHome();
+
+ /* Declare some variable values */
+ strcpy(data.name, "My Data");
+ data.var1 = VAR1_VALUE;
+ data.var2 = VAR2_VALUE;
+
+ /* Close any files that may be open already */
+ ti_CloseAll();
+
+ /* Open a new variable; deleting it if it already exists */
+ myAppVar = ti_Open(appvarName, "w");
+
+ /* Make sure we opened okay */
+ if (!myAppVar) goto err;
+
+ /* Write the structure to the appvar */
+ if (ti_Write(&data, sizeof(data_t), 1, myAppVar) != 1) goto err;
+
+ /* Go back to the start of the file */
+ if (ti_Rewind(myAppVar) == EOF) goto err;
+
+ /* Let's read it just to make sure we wrote it correctly */
+ if (ti_Read(&data, sizeof(data_t), 1, myAppVar) != 1) goto err;
+
+ /* Make sure we read these variables correctly too */
+ if (data.var1 != VAR1_VALUE && data.var2 != VAR2_VALUE) goto err;
+
+ /* Ensure the name of the AppVar is correct */
+ ti_GetName(nameBuffer, myAppVar);
+
+ printText(0, 0, "Appvar: ");
+ printText(8, 0, nameBuffer);
+ printText(0, 1, "Read was successful");
+ goto noerr;
+
+err:
+ printText(0, 0, "An error occured");
+noerr:
+
+ /* Pause */
+ while (!os_GetCSC());
+
+ /* Close all open files */
+ ti_CloseAll();
+}
+
+/* Draw text on the homescreen at the given X/Y location */
+void printText(int8_t xpos, int8_t ypos, const char *text) {
+ os_SetCursorPos(ypos, xpos);
+ os_PutStrFull(text);
+}
+
|