Skip to content

Commit 5da2b73

Browse files
authored
Rebuild IEC state machine so it's handled in ISR (FujiNetWIFI#816)
* Eliminate a bunch of warnings. * There doesn't seem to be a contains() method in std::string * Use commit date instead of newest modified file date by default. * Print IEC transfer speed. * Clarify which pins are used for IEC on Lolin D32 * There is no up/down/pull/true/false/high/low/0/1, only assert/release. * Start moving IEC bus access and state management out of virtual devices. * Make IEC state private and move IEC access macros to _protocol.h * Speed up transfer. * Don't blindly read past end of D64 sector. * Whitespace cleanup. * Put state machine into cbm_on_clk_isr_handler() * Add dynamic delaying before starting transfer. * JiffyDOS. * Remove unused functions. * Don't set bus idle when there's no current command. * Remove COMPLEX_WAIT ifdef * Remove legacy IEC_ASSERT_RELEASE_AS_FUNCTIONS * Don't send command on EOI, wait for unlisten. * Don't releaseLines() until ATN is released. * Don't try to do secondary command if there's no primary command. * Don't discard bytes during LISTEN. * Release lines immediately on LISTEN. * Set state to BUS_IDLE when releasing lines. * Fix problems with transferDelaySinceLast()
1 parent 245c954 commit 5da2b73

File tree

24 files changed

+1193
-1753
lines changed

24 files changed

+1193
-1753
lines changed

include/cbm_defines.h

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ typedef enum
140140
#define CLEAR 0x0000 // clear all flags
141141
#define CLEAR_LOW 0xFF00 // clear low byte
142142
#define ERROR (1 << 0) // if this flag is set, something went wrong
143-
#define ATN_PULLED (1 << 1) // might be set by iec_receive
143+
#define ATN_ASSERTED (1 << 1) // might be set by iec_receive
144144
#define EOI_RECVD (1 << 2)
145145
#define EMPTY_STREAM (1 << 3)
146146

@@ -161,7 +161,7 @@ typedef enum
161161

162162
#define TIMING_Ts 70 // BIT SET-UP TALKER 71us 20us 70us -
163163
#define TIMING_Ts0 40 // BIT SET-UP LISTENER PRE 57us 47us
164-
#define TIMING_Ts1 35 // BIT SET-UP LISTENER POST 18us 24us
164+
#define TIMING_Ts1 30 // BIT SET-UP LISTENER POST 18us 24us
165165
#define TIMING_Tv 20 // DATA VALID VIC20 76us 26us 20us 20us - (Tv and Tpr minimum must be 60μ s for external device to be a talker. )
166166
#define TIMING_Tv64 80 // DATA VALID C64
167167

@@ -187,9 +187,9 @@ typedef enum
187187

188188
// OTHER
189189
#define TIMING_EMPTY 512 // SIGNAL EMPTY STREAM
190-
#define TIMEOUT_ATNCLK 70 // WAIT FOR CLK AFTER ATN IS PULLED
190+
#define TIMEOUT_ATNCLK 70 // WAIT FOR CLK AFTER ATN IS ASSERTED
191191
#define TIMEOUT_Ttlta 65 // TALKER/LISTENER TURNAROUND TIMEOUT
192-
#define TIMING_Ttcp 13 // TALKER TURNAROUND CLOCK PULL
192+
#define TIMING_Ttcp 13 // TALKER TURNAROUND CLOCK ASSERT
193193

194194
// SPECIAL
195195
#define TIMING_PROTOCOL_DETECT 218 // SAUCEDOS/JIFFYDOS CAPABLE DELAY
@@ -200,18 +200,7 @@ typedef enum
200200
#define TIMED_OUT -1
201201
#define FOREVER 5000000 // 0
202202

203-
#ifndef IEC_INVERTED_LINES
204-
// Not Inverted
205-
#define PULLED true
206-
#define RELEASED false
207-
#define LOW 0x00
208-
#define HIGH 0x01
209-
#else
210-
// Inverted
211-
#define PULLED false
212-
#define RELEASED true
213-
#define LOW 0x01
214-
#define HIGH 0x00
215-
#endif
203+
#define IEC_ASSERTED true
204+
#define IEC_RELEASED false
216205

217206
#endif // CBMDEFINES_H

include/pinmap.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
#define PINMAP_H
44

55
#ifdef ESP_PLATFORM
6+
#include <hal/gpio_types.h>
7+
68
#include "pinmap/a2_fn10.h"
79
#include "pinmap/a2_rev0.h"
810
#include "pinmap/a2_d32pro.h"

include/pinmap/iec-d32pro.h

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -42,28 +42,18 @@
4242
#define PIN_LED_BT GPIO_NUM_5 // LOLIN D32 PRO
4343
#endif
4444

45-
/* Audio Output */
46-
#define PIN_DAC1 GPIO_NUM_25 // samlib.h
47-
4845
/* Commodore IEC Pins */
4946
#define IEC_HAS_RESET // Reset line is available
5047

5148
#define PIN_IEC_RESET GPIO_NUM_34
5249
#define PIN_IEC_ATN GPIO_NUM_32
5350
#define PIN_IEC_CLK_IN GPIO_NUM_33
54-
#define PIN_IEC_CLK_OUT GPIO_NUM_33
51+
#define PIN_IEC_CLK_OUT PIN_IEC_CLK_IN
5552
#define PIN_IEC_DATA_IN GPIO_NUM_25
56-
#define PIN_IEC_DATA_OUT GPIO_NUM_25
53+
#define PIN_IEC_DATA_OUT PIN_IEC_DATA_IN
5754
#define PIN_IEC_SRQ GPIO_NUM_26
5855

59-
/* Color Computer */
60-
#define PIN_CASS_MOTOR GPIO_NUM_34 // Second motor pin is tied to +3V
61-
#define PIN_CASS_DATA_IN GPIO_NUM_33
62-
#define PIN_CASS_DATA_OUT GPIO_NUM_26
63-
64-
#define PIN_SERIAL_CD GPIO_NUM_32
65-
#define PIN_SERIAL_RX GPIO_NUM_9 // fnUartBUS
66-
#define PIN_SERIAL_TX GPIO_NUM_10
56+
#define PIN_DEBUG PIN_IEC_SRQ
6757

6858
#endif // PINMAP_IEC_D32PRO
69-
#endif // PINMAP_LOLIN_D32_PRO_H
59+
#endif // PINMAP_LOLIN_D32_PRO_H

0 commit comments

Comments
 (0)