Skip to content

Commit

Permalink
Rebuild IEC state machine so it's handled in ISR (#816)
Browse files Browse the repository at this point in the history
* 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()
  • Loading branch information
FozzTexx authored Nov 13, 2024
1 parent 5d442e9 commit 1a3e3b3
Show file tree
Hide file tree
Showing 24 changed files with 1,193 additions and 1,753 deletions.
23 changes: 6 additions & 17 deletions include/cbm_defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ typedef enum
#define CLEAR 0x0000 // clear all flags
#define CLEAR_LOW 0xFF00 // clear low byte
#define ERROR (1 << 0) // if this flag is set, something went wrong
#define ATN_PULLED (1 << 1) // might be set by iec_receive
#define ATN_ASSERTED (1 << 1) // might be set by iec_receive
#define EOI_RECVD (1 << 2)
#define EMPTY_STREAM (1 << 3)

Expand All @@ -161,7 +161,7 @@ typedef enum

#define TIMING_Ts 70 // BIT SET-UP TALKER 71us 20us 70us -
#define TIMING_Ts0 40 // BIT SET-UP LISTENER PRE 57us 47us
#define TIMING_Ts1 35 // BIT SET-UP LISTENER POST 18us 24us
#define TIMING_Ts1 30 // BIT SET-UP LISTENER POST 18us 24us
#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. )
#define TIMING_Tv64 80 // DATA VALID C64

Expand All @@ -187,9 +187,9 @@ typedef enum

// OTHER
#define TIMING_EMPTY 512 // SIGNAL EMPTY STREAM
#define TIMEOUT_ATNCLK 70 // WAIT FOR CLK AFTER ATN IS PULLED
#define TIMEOUT_ATNCLK 70 // WAIT FOR CLK AFTER ATN IS ASSERTED
#define TIMEOUT_Ttlta 65 // TALKER/LISTENER TURNAROUND TIMEOUT
#define TIMING_Ttcp 13 // TALKER TURNAROUND CLOCK PULL
#define TIMING_Ttcp 13 // TALKER TURNAROUND CLOCK ASSERT

// SPECIAL
#define TIMING_PROTOCOL_DETECT 218 // SAUCEDOS/JIFFYDOS CAPABLE DELAY
Expand All @@ -200,18 +200,7 @@ typedef enum
#define TIMED_OUT -1
#define FOREVER 5000000 // 0

#ifndef IEC_INVERTED_LINES
// Not Inverted
#define PULLED true
#define RELEASED false
#define LOW 0x00
#define HIGH 0x01
#else
// Inverted
#define PULLED false
#define RELEASED true
#define LOW 0x01
#define HIGH 0x00
#endif
#define IEC_ASSERTED true
#define IEC_RELEASED false

#endif // CBMDEFINES_H
2 changes: 2 additions & 0 deletions include/pinmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#define PINMAP_H

#ifdef ESP_PLATFORM
#include <hal/gpio_types.h>

#include "pinmap/a2_fn10.h"
#include "pinmap/a2_rev0.h"
#include "pinmap/a2_d32pro.h"
Expand Down
18 changes: 4 additions & 14 deletions include/pinmap/iec-d32pro.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,28 +42,18 @@
#define PIN_LED_BT GPIO_NUM_5 // LOLIN D32 PRO
#endif

/* Audio Output */
#define PIN_DAC1 GPIO_NUM_25 // samlib.h

/* Commodore IEC Pins */
#define IEC_HAS_RESET // Reset line is available

#define PIN_IEC_RESET GPIO_NUM_34
#define PIN_IEC_ATN GPIO_NUM_32
#define PIN_IEC_CLK_IN GPIO_NUM_33
#define PIN_IEC_CLK_OUT GPIO_NUM_33
#define PIN_IEC_CLK_OUT PIN_IEC_CLK_IN
#define PIN_IEC_DATA_IN GPIO_NUM_25
#define PIN_IEC_DATA_OUT GPIO_NUM_25
#define PIN_IEC_DATA_OUT PIN_IEC_DATA_IN
#define PIN_IEC_SRQ GPIO_NUM_26

/* Color Computer */
#define PIN_CASS_MOTOR GPIO_NUM_34 // Second motor pin is tied to +3V
#define PIN_CASS_DATA_IN GPIO_NUM_33
#define PIN_CASS_DATA_OUT GPIO_NUM_26

#define PIN_SERIAL_CD GPIO_NUM_32
#define PIN_SERIAL_RX GPIO_NUM_9 // fnUartBUS
#define PIN_SERIAL_TX GPIO_NUM_10
#define PIN_DEBUG PIN_IEC_SRQ

#endif // PINMAP_IEC_D32PRO
#endif // PINMAP_LOLIN_D32_PRO_H
#endif // PINMAP_LOLIN_D32_PRO_H
Loading

0 comments on commit 1a3e3b3

Please sign in to comment.