From bd3d7de074c60d56097557caf51a471630b7f8f7 Mon Sep 17 00:00:00 2001 From: dschmenk Date: Tue, 16 Aug 2016 08:28:53 -0700 Subject: [PATCH] Longer timeout for spiSend - intial sd card access takes long time --- src/inc/cmdsys.plh | 66 +++++++++++++++++++++++++++--------------- src/inc/fileio.plh | 31 ++++++++++++++++++++ src/libsrc/fileio.pla | 32 ++++++++++++++++---- src/libsrc/spiport.pla | 2 +- 4 files changed, 101 insertions(+), 30 deletions(-) diff --git a/src/inc/cmdsys.plh b/src/inc/cmdsys.plh index bf0eb2b..59ad45d 100644 --- a/src/inc/cmdsys.plh +++ b/src/inc/cmdsys.plh @@ -1,25 +1,45 @@ import cmdsys - predef putc, putln, puts, getc, gets - predef call, syscall - predef heapmark, heapallocalign, heapalloc, heaprelease, heapavail - predef memset, memcpy - predef isugt, isuge, isult, isule - predef modload, modexec, modaddr - word MACHID, sysvars - // - // System flags: memory allocator screen holes. - // - const restxt1 = $0001 - const restxt2 = $0002 - const resxtxt1 = $0004 - const resxtxt2 = $0008 - const reshgr1 = $0010 - const reshgr2 = $0020 - const resxhgr1 = $0040 - const resxhgr2 = $0080 - // - // Module don't free memory - // - const modkeep = $2000 - const modinitkeep = $4000 + const MACHID_CLOCK = $01 + const MACHID_80COL = $02 + const MACHID_MEM = $03 + const MACHID_48K = $10 + const MACHID_64K = $20 + const MACHID_128K = $30 + const MACHID_MODEL = $C8 + const MACHID_II = $00 + const MACHID_IIPLUS= $40 + const MACHID_IIE = $80 + const MACHID_III = $C0 + const MACHID_IIC = $88 + const MACHID_I = $08 + word MACHID + // + // System flags: memory allocator screen holes. + // + const restxt1 = $0001 + const restxt2 = $0002 + const resxtxt1 = $0004 + const resxtxt2 = $0008 + const reshgr1 = $0010 + const reshgr2 = $0020 + const resxhgr1 = $0040 + const resxhgr2 = $0080 + // + // Module don't free memory + // + const modkeep = $2000 + const modinitkeep = $4000 + // + // System vars + // + word sysvars + // + // CMD exported functions + // + predef putc, putln, puts, getc, gets + predef call, syscall + predef heapmark, heapallocalign, heapalloc, heaprelease, heapavail + predef memset, memcpy + predef isugt, isuge, isult, isule + predef modload, modexec, modaddr end diff --git a/src/inc/fileio.plh b/src/inc/fileio.plh index c545d41..d8e107a 100644 --- a/src/inc/fileio.plh +++ b/src/inc/fileio.plh @@ -1,5 +1,36 @@ import fileio + // + // Useful ProDOS values + // + // MACHID is defined in cmdsys.plh + // Which slot has a ROM + const SLTBYT = $BF99 + // Prefix active + const PFIXPTR = $BF9A + // Memory alocate bitmap + const MEMTABL = $BF58 + // + // ProDOS error codes + // + const PRODOS_ERR_OK = $00 + const PRODOS_ERR_BAD_CALL_NUM = $01 + const PRODOS_ERR_BAD_PARAM_CNT = $04 + const PRODOS_ERR_INT_TBL_FULL = $25 + const PRODOS_ERR_IO = $27 + // + // System I/O buffer for PLASMA. Used when loading modules, free otherwise + // const sysbuf = $0800 + // + // File functions + // predef getpfx, setpfx, open, close, read, write, create, destroy, newline + // + // Block level I/O functions + // + predef readblock, writeblock + // + // Globally accessible error code + // byte perr end \ No newline at end of file diff --git a/src/libsrc/fileio.pla b/src/libsrc/fileio.pla index 633e404..198664c 100644 --- a/src/libsrc/fileio.pla +++ b/src/libsrc/fileio.pla @@ -23,12 +23,12 @@ export def setpfx(path) perr = syscall($C6, @params) return path end -export def open(path, buff) +export def open(path, buf) byte params[6] params.0 = 3 params:1 = path - params:3 = buff + params:3 = buf params.5 = 0 perr = syscall($C8, @params) return params.5 @@ -41,23 +41,23 @@ export def close(refnum) perr = syscall($CC, @params) return perr end -export def read(refnum, buff, len) +export def read(refnum, buf, len) byte params[8] params.0 = 4 params.1 = refnum - params:2 = buff + params:2 = buf params:4 = len params:6 = 0 perr = syscall($CA, @params) return params:6 end -export def write(refnum, buff, len) +export def write(refnum, buf, len) byte params[8] params.0 = 4 params.1 = refnum - params:2 = buff + params:2 = buf params:4 = len params:6 = 0 perr = syscall($CB, @params) @@ -95,5 +95,25 @@ export def newline(refnum, emask, nlchar) perr = syscall($C9, @params) return perr end +export def readblock(unit, buf, block) + byte params[6] + + params.0 = 3 + params.1 = unit + params:2 = buf + params:4 = block + perr = syscall($80, @params) + return perr +end +export def writeblock(unit, buf, block) + byte params[6] + + params.0 = 3 + params.1 = unit + params:2 = buf + params:4 = block + perr = syscall($81, @params) + return perr +end done diff --git a/src/libsrc/spiport.pla b/src/libsrc/spiport.pla index 9d69106..1a6bfa5 100644 --- a/src/libsrc/spiport.pla +++ b/src/libsrc/spiport.pla @@ -202,7 +202,7 @@ end export def spiSend(data) byte timeout, status - for timeout = 1 to 5 + for timeout = 1 to 100 step 10 status = spiXferByte(data) if status <> SPI_SLAVE_BUSY return status