Skip to content

Commit beb822a

Browse files
committed
[iec] reset protocol to standard serial before read_command()
adjust bus state for device detect
1 parent 38de5de commit beb822a

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

lib/bus/iec/iec.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,13 @@ void IRAM_ATTR systemBus::service()
264264
{
265265
//pull ( PIN_IEC_SRQ );
266266

267+
// Switch to standard serial protocol
268+
if ( detected_protocol != PROTOCOL_SERIAL)
269+
{
270+
detected_protocol = PROTOCOL_SERIAL;
271+
protocol = selectProtocol();
272+
}
273+
267274
// *** IMPORTANT! This helps keep us in sync!
268275
// Sometimes the C64 pulls ATN but doesn't pull CLOCK right away
269276
protocol->timeoutWait ( PIN_IEC_CLK_IN, PULLED, TIMEOUT_ATNCLK, false );
@@ -329,24 +336,18 @@ void IRAM_ATTR systemBus::service()
329336
// for (auto devicep : _daisyChain)
330337
// {
331338
device_state = d->process();
332-
if ( device_state < DEVICE_ACTIVE || device_state == DEVICE_TALK )
333-
{
334-
state = BUS_RELEASE;
335-
}
336339
// }
337340
}
338341

339342
//Debug_printv("bus[%d] device[%d] flags[%d]", state, device_state, flags);
340343

341-
// Switch back to standard serial
342-
if ( detected_protocol != PROTOCOL_SERIAL)
343-
{
344-
detected_protocol = PROTOCOL_SERIAL;
345-
protocol = selectProtocol();
346-
}
344+
347345
//release ( PIN_IEC_SRQ );
348346
}
349347

348+
if ( state == BUS_RELEASE )
349+
break;
350+
350351
// Let's check ATN again before we exit and clean up
351352
if ( status ( PIN_IEC_ATN ) )
352353
{

lib/bus/iec/protocol/cpbstandardserial.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,6 @@ uint8_t CPBStandardSerial::receiveByte()
183183
portENABLE_INTERRUPTS();
184184
//IEC.release ( PIN_IEC_SRQ );
185185

186-
187186
// Has ATN status changed?
188187
if ( atn_status != IEC.status ( PIN_IEC_ATN ) )
189188
{
@@ -192,7 +191,6 @@ uint8_t CPBStandardSerial::receiveByte()
192191
return 0;
193192
}
194193

195-
196194
// STEP 3: RECEIVING THE BITS
197195
//IEC.pull ( PIN_IEC_SRQ );
198196
uint8_t data = receiveBits();

0 commit comments

Comments
 (0)