@@ -18,10 +18,10 @@ static void _DelayIO(void);
1818
1919/**************************************************************************/
2020/*!
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.
2525*/
2626/**************************************************************************/
2727static void _DelayIO ()
@@ -31,12 +31,12 @@ static void _DelayIO()
3131
3232/**************************************************************************/
3333/*!
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.
4040 @returns a c-string with an error, or `NULL` if no error ocurred.
4141*/
4242/**************************************************************************/
@@ -193,9 +193,9 @@ const char *i2cNoteTransaction(char *json, char **jsonResponse)
193193
194194//**************************************************************************/
195195/*!
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.
199199*/
200200/**************************************************************************/
201201bool i2cNoteReset ()
@@ -209,11 +209,16 @@ bool i2cNoteReset()
209209 return false;
210210 }
211211
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.
215215 bool notecardReady = false;
216216 int retries ;
217+ _LockI2C ();
218+ _DelayIO ();
219+ _I2CTransmit (_I2CAddress (), (uint8_t * )"\n" , 1 );
220+ _DelayMs (CARD_REQUEST_I2C_SEGMENT_DELAY_MS );
221+ _UnlockI2C ();
217222 for (retries = 0 ; !notecardReady && retries < 3 ; retries ++ ) {
218223
219224 // Loop to drain all chunks of data that may be ready to transmit to us
0 commit comments