From 5955588c9da02d9688aade8c74b890fdece58990 Mon Sep 17 00:00:00 2001 From: Peter Weingartner Date: Mon, 5 Aug 2024 16:24:32 -0400 Subject: [PATCH] Printer mostly working over IEC Seems to be a problem with iecll_unlisten hanging. --- docs/f256k2_registers.txt | 8 ++++++++ src/C256/flash-f256.scm | 35 +++++++++++++++++++++++++++++++++++ src/C256/iecll.s | 7 +++++++ src/dev/iec.c | 14 ++++++++++++++ src/dev/iec.h | 2 ++ src/toolbox.c | 9 ++++++--- 6 files changed, 72 insertions(+), 3 deletions(-) create mode 100644 src/C256/flash-f256.scm diff --git a/docs/f256k2_registers.txt b/docs/f256k2_registers.txt index 8adc6ee..6f16f31 100644 --- a/docs/f256k2_registers.txt +++ b/docs/f256k2_registers.txt @@ -8,3 +8,11 @@ $F0_1D60 - $F0_1D7F - Wiznet Copper SPI Interface $F0_1D80 - $F0_1D9F - Wiznet WIFI UART interface (115K or 2M) $F0_1DA0 - $F0_1DBF - MIDI UART (Fixed @ 31,250Baud) $F0_1DC0 - $F0_1DDF - Master SPI Interface to Supervisor (RP2040)* + +/* SPI Controler 0 Registers - External Access (Front of Unit)*/ +#define SD0_CTRL (*(volatile __far uint8_t *)0xF01D00) +#define SD0_DATA (*(volatile __far uint8_t *)0xF01D01) +/* SPI Controler 1 Registers - Internal Access (underneath of Unit - uSDCard) */ +// Specific to the F256xE - Internal SDCard (Permanent Disk) +#define SD1_CTRL (*(volatile __far uint8_t *)0xF01D20) <---- +#define SD1_DATA (*(volatile __far uint8_t *)0xF01D21) <---- \ No newline at end of file diff --git a/src/C256/flash-f256.scm b/src/C256/flash-f256.scm new file mode 100644 index 0000000..a825401 --- /dev/null +++ b/src/C256/flash-f256.scm @@ -0,0 +1,35 @@ +(define memories + '((memory flash (address (#xf80000 . #xffffff)) + (fill 0) + (section + (LoCodeStorage #xffe000) + (VectorStorage #xffffe0))) + (memory DirectPage (address (#x00c000 . #x00c0ff)) + (section (registers ztiny))) + (memory LoRAM (address (#x00c100 . #x00efff)) + (section stack data zdata data heap)) + (memory NearRAM1 (address (#x050000 . #x057fff)) + (section znear near)) + (memory NearRAM2 (address (#x058000 . #x05ffff)) + (section cnear)) + (memory FarRAM1 (address (#x060000 . #x06ffff)) + (section far huge)) + (memory FarRAM2 (address (#x070000 . #x07ffff)) + (section zfar zhuge)) + (memory LoCode (address (#x00e000 . #x00ffdf)) + (scatter-to LoCodeStorage) + (section code cdata (jumptable #x00e000))) + (memory Vector (address (#x00ffe0 . #x00ffff)) + (scatter-to VectorStorage) + (section (reset #xfffc))) + (memory HiCode1 (address (#xf80000 . #xf8ffff)) + (section cfar switch data_init_table ifar farcode)) + (memory HiCode2 (address (#xf90000 . #xf9ffff)) + (section cfar switch data_init_table ifar farcode)) + (memory HiCode3 (address (#xfa0000 . #xfaffff)) + (section cfar switch data_init_table ifar farcode)) + (block stack (size #x1000)) + (block heap (size #x1000)) + (base-address _DirectPageStart DirectPage 0) + (base-address _NearBaseAddress NearRAM1 0) +)) diff --git a/src/C256/iecll.s b/src/C256/iecll.s index dfd9f93..6d46218 100644 --- a/src/C256/iecll.s +++ b/src/C256/iecll.s @@ -62,6 +62,13 @@ loop$ lda IEC_INPUT_PORT pla rts .endm + +emit: .macro char + pha + lda #(\char) + sta long: 0xf04000 + pla + .endm ;; ;; Private functions diff --git a/src/dev/iec.c b/src/dev/iec.c index e975b7e..3d10c94 100644 --- a/src/dev/iec.c +++ b/src/dev/iec.c @@ -26,6 +26,20 @@ void iec_close(uint8_t device, uint8_t channel) { iecll_unlisten(); } +void iec_print(uint8_t device, char * message) { + // Open the device, channel 1 + uint8_t channel = 1; + iecll_listen(device); + iecll_listen_sa(0x60 | channel); + + for (char *x = message; *x; x++) { + iecll_out(*x); + } + + iecll_unlisten(); + iec_close(4, channel); +} + /** * @brief Retrieve the raw status string from an IEC device * diff --git a/src/dev/iec.h b/src/dev/iec.h index 1004323..ba0d544 100644 --- a/src/dev/iec.h +++ b/src/dev/iec.h @@ -14,6 +14,8 @@ #include +extern void iec_print(uint8_t device, char * message); + /** * @brief Retrieve the raw status string from an IEC device * diff --git a/src/toolbox.c b/src/toolbox.c index 8186725..f91a8b2 100644 --- a/src/toolbox.c +++ b/src/toolbox.c @@ -493,10 +493,13 @@ int main(int argc, char * argv[]) { printf("Error initializing IEC.\n"); } - printf("Attempting to get status for IEC drive #8: "); - short n = iec_status(8, message, 256); + // printf("Attempting to get status for IEC drive #8: "); + // short n = iec_status(8, message, 256); + // printf("\"%s\"\n", message); - printf("\"%s\"\n", message); + printf("Attempting to write to the printer.\n"); + iec_print(4, "\e1THIS IS PRINTED FROM AN F256K OVER THE IEC PORT!\r"); + printf("Done.\n"); // Attempt to start up the user code // log(LOG_INFO, "Looking for user startup code:");