Skip to content

Commit febcbef

Browse files
committed
[iec] check ATN status before and after EOI
1 parent 793a821 commit febcbef

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

lib/bus/iec/protocol/cpbstandardserial.cpp

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,14 @@ CPBStandardSerial::~CPBStandardSerial()
9898
// it might holdback for quite a while; there's no time limit.
9999
uint8_t CPBStandardSerial::receiveByte()
100100
{
101+
bool atn_status = false;
101102
IEC.flags &= CLEAR_LOW;
102103

104+
// Sample ATN and set flag to indicate COMMAND or DATA mode
105+
atn_status = IEC.status ( PIN_IEC_ATN );
106+
if ( atn_status )
107+
IEC.flags |= ATN_PULLED;
108+
103109
// Wait for talker ready
104110
//IEC.pull ( PIN_IEC_SRQ );
105111
if ( timeoutWait ( PIN_IEC_CLK_IN, RELEASED, FOREVER, false ) == TIMED_OUT )
@@ -165,9 +171,15 @@ uint8_t CPBStandardSerial::receiveByte()
165171
}
166172
IEC.release ( PIN_IEC_SRQ );
167173

168-
// // Sample ATN and set flag to indicate COMMAND or DATA mode
169-
// if ( IEC.status ( PIN_IEC_ATN ) )
170-
// IEC.flags |= ATN_PULLED;
174+
175+
// Has ATN status changed?
176+
if ( atn_status != IEC.status ( PIN_IEC_ATN ) )
177+
{
178+
Debug_printv ( "ATN status changed!" );
179+
IEC.flags |= ATN_PULLED;
180+
return 0; // return error because timeout
181+
}
182+
171183

172184
// STEP 3: RECEIVING THE BITS
173185
//IEC.pull ( PIN_IEC_SRQ );

0 commit comments

Comments
 (0)