Skip to content

Commit be34316

Browse files
committed
[iec] fix release ATN wait on bus process
1 parent a9fef60 commit be34316

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

lib/bus/iec/iec.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -483,27 +483,28 @@ void systemBus::read_command()
483483
}
484484
}
485485

486-
//if ( state == BUS_ACTIVE ) // Normal behaviour is to ignore everything if it's not for us
487-
if ( state == BUS_PROCESS ) // Use this to sniff the secondary commands
486+
if ( state == BUS_ACTIVE ) // Normal behaviour is to ignore everything if it's not for us
487+
//if ( state == BUS_PROCESS ) // Use this to sniff the secondary commands
488488
{
489489
if ( !isDeviceEnabled( data.device ) )
490490
{
491491
// Is this command for us?
492492
state = BUS_RELEASE; // NOPE!
493493
}
494494
}
495-
else if ( state == BUS_PROCESS )
495+
496+
if ( state == BUS_PROCESS )
496497
{
497498
// *** IMPORTANT! This helps keep us in sync!
498499
// Sometimes ATN isn't released immediately. Wait for ATN to be
499500
// released before trying to process the command.
500501
// Long ATN delay (>1.5ms) seems to occur more frequently with VIC-20.
501-
//pull ( PIN_IEC_SRQ );
502+
pull ( PIN_IEC_SRQ );
502503
protocol->timeoutWait ( PIN_IEC_ATN, RELEASED, TIMEOUT_DEFAULT, false );
503504

504505
// Delay after ATN is RELEASED
505506
//protocol->wait( TIMING_Ttk, false );
506-
//release ( PIN_IEC_SRQ );
507+
release ( PIN_IEC_SRQ );
507508
}
508509

509510

@@ -870,7 +871,7 @@ bool IRAM_ATTR systemBus::turnAround()
870871
*/
871872

872873
// Wait for CLK to be released
873-
//pull ( PIN_IEC_SRQ );
874+
pull ( PIN_IEC_SRQ );
874875
if (protocol->timeoutWait(PIN_IEC_CLK_IN, RELEASED, TIMEOUT_Ttlta) == TIMEOUT_Ttlta)
875876
{
876877
Debug_printv("Wait until the computer releases the CLK line\r\n");
@@ -880,7 +881,7 @@ bool IRAM_ATTR systemBus::turnAround()
880881
}
881882
release ( PIN_IEC_DATA_OUT );
882883
pull ( PIN_IEC_CLK_OUT );
883-
//release ( PIN_IEC_SRQ );
884+
release ( PIN_IEC_SRQ );
884885

885886
// 80us minimum delay after TURNAROUND
886887
// *** IMPORTANT!

lib/bus/iec/protocol/cpbstandardserial.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,9 @@ uint8_t CPBStandardSerial::receiveByte()
132132
// without the Clock line going to true, it has a special task to perform: note EOI.
133133

134134
//IEC.pull ( PIN_IEC_SRQ );
135-
//if ( timeoutWait ( PIN_IEC_CLK_IN, PULLED, TIMING_Tye, false ) == TIMING_Tye )
136-
timer_start( TIMING_Tye );
137-
while ( IEC.status ( PIN_IEC_CLK_IN ) != PULLED )
135+
if ( timeoutWait ( PIN_IEC_CLK_IN, PULLED, TIMING_Tye, false ) == TIMING_Tye )
136+
// timer_start( TIMING_Tye );
137+
// while ( IEC.status ( PIN_IEC_CLK_IN ) != PULLED )
138138
{
139139
// INTERMISSION: EOI
140140
// If the Ready for Data signal isn't acknowledged by the talker within 200 microseconds, the
@@ -152,7 +152,7 @@ uint8_t CPBStandardSerial::receiveByte()
152152

153153
//IEC.pull ( PIN_IEC_SRQ );
154154

155-
if ( timer_timedout )
155+
//if ( timer_timedout )
156156
{
157157
timer_timedout = false;
158158
IEC.flags |= EOI_RECVD;
@@ -162,6 +162,9 @@ uint8_t CPBStandardSerial::receiveByte()
162162
IEC.pull ( PIN_IEC_DATA_OUT );
163163
wait ( TIMING_Tei );
164164
IEC.release ( PIN_IEC_DATA_OUT );
165+
166+
// Wait for clock line to be pulled
167+
timeoutWait ( PIN_IEC_CLK_IN, PULLED, TIMING_Tye, false );
165168
}
166169

167170
//usleep( 2 );

0 commit comments

Comments
 (0)