@@ -18,10 +18,10 @@ static void _DelayIO(void);
18
18
19
19
/**************************************************************************/
20
20
/*!
21
- @brief We've noticed that there's an instability in some cards'
22
- implementations of I2C, and as a result we introduce an intentional
23
- delay before each and every I2C I/O.The timing was computed
24
- empirically based on a number of commercial devices.
21
+ @brief We've noticed that there's an instability in some cards'
22
+ implementations of I2C, and as a result we introduce an intentional
23
+ delay before each and every I2C I/O.The timing was computed
24
+ empirically based on a number of commercial devices.
25
25
*/
26
26
/**************************************************************************/
27
27
static void _DelayIO ()
@@ -31,12 +31,12 @@ static void _DelayIO()
31
31
32
32
/**************************************************************************/
33
33
/*!
34
- @brief Given a JSON string, perform an I2C transaction with the Notecard.
35
- @param json
36
- A c-string containing the JSON request object.
37
- @param jsonResponse
38
- An out parameter c-string buffer that will contain the JSON
39
- response from the Notercard.
34
+ @brief Given a JSON string, perform an I2C transaction with the Notecard.
35
+ @param json
36
+ A c-string containing the JSON request object.
37
+ @param jsonResponse
38
+ An out parameter c-string buffer that will contain the JSON
39
+ response from the Notercard.
40
40
@returns a c-string with an error, or `NULL` if no error ocurred.
41
41
*/
42
42
/**************************************************************************/
@@ -193,9 +193,9 @@ const char *i2cNoteTransaction(char *json, char **jsonResponse)
193
193
194
194
//**************************************************************************/
195
195
/*!
196
- @brief Initialize or re-initialize the I2C subsystem, returning false if
197
- anything fails.
198
- @returns a boolean. `true` if the reset was successful, `false`, if not.
196
+ @brief Initialize or re-initialize the I2C subsystem, returning false if
197
+ anything fails.
198
+ @returns a boolean. `true` if the reset was successful, `false`, if not.
199
199
*/
200
200
/**************************************************************************/
201
201
bool i2cNoteReset ()
@@ -209,11 +209,16 @@ bool i2cNoteReset()
209
209
return false;
210
210
}
211
211
212
- // Synchronize by guaranteeing not only that I2C works, but that we drain the remainder of any
213
- // pending partial reply from a previously-aborted session. This outer loop does retries on
214
- // I2C error, and is simply here for robustness.
212
+ // Synchronize by guaranteeing not only that I2C works, but that after we send \n that we drain
213
+ // the remainder of any pending partial reply from a previously-aborted session. This outer loop
214
+ // does retries on I2C error, and is simply here for robustness.
215
215
bool notecardReady = false;
216
216
int retries ;
217
+ _LockI2C ();
218
+ _DelayIO ();
219
+ _I2CTransmit (_I2CAddress (), (uint8_t * )"\n" , 1 );
220
+ _DelayMs (CARD_REQUEST_I2C_SEGMENT_DELAY_MS );
221
+ _UnlockI2C ();
217
222
for (retries = 0 ; !notecardReady && retries < 3 ; retries ++ ) {
218
223
219
224
// Loop to drain all chunks of data that may be ready to transmit to us
0 commit comments