From deea9293201dbab724b6b0519c35ddba3e6b92d9 Mon Sep 17 00:00:00 2001 From: Greyson Christoforo Date: Wed, 28 Feb 2018 20:59:45 +0000 Subject: Introduce non compulsory Wire timeout move timout handling into its own function change timeout from milliseconds to microseconds don't forget operating slave address or the bitrate when we reset because of a timeout Co-Authored-By: Witold Markowski fix delay datatype uint16_t --> uint32_t Update libraries/Wire/src/utility/twi.c fix mix up using TWBR instea of TWAR! Co-Authored-By: Matthijs Kooijman Update libraries/Wire/src/utility/twi.c fix 2nd TWBR/TWAR mixup Co-Authored-By: Matthijs Kooijman twi_stop() should use the same timeout as everywhere else all while loops are now protected by timeouts Revert "twi_stop() should use the same timeout as everywhere else" This reverts commit 68fe5f1dae1bb41183bb37eeda3fb453394a580c. make timeout counter volatile rename timeout function for improved clarity - resetting the twi interface on timeouts is now optional - timeouts in the ISR are no longer hardcoded and now obey the set timeout value - a user-readable flag is now set whenever a timeout occurs - the user can clear this flag whenever they like --- libraries/Wire/src/utility/twi.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'libraries/Wire/src/utility/twi.h') diff --git a/libraries/Wire/src/utility/twi.h b/libraries/Wire/src/utility/twi.h index d27325e..85b9837 100644 --- a/libraries/Wire/src/utility/twi.h +++ b/libraries/Wire/src/utility/twi.h @@ -15,6 +15,8 @@ You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Modified 2020 by Greyson Christoforo (grey@christoforo.net) to implement timeouts */ #ifndef twi_h @@ -50,6 +52,8 @@ void twi_reply(uint8_t); void twi_stop(void); void twi_releaseBus(void); + void twi_setTimeoutInMicros(uint32_t, bool); + void twi_handleTimeout(bool); + bool twi_manageTimeoutFlag(bool); #endif - -- cgit v1.2.3-18-g5258