Closed ghost closed 3 years ago
hmmh ? merged to somewhere else ?
I'd done some more work on this recently and modified things a little outside the scope of the original pull request. I merged this work from 'testing' into my master.
From testing, the mods I've made has solved a lot of my issues but I'm not sure if it is of any use to anyone else. Feel free to grab whatever you may find helpful for your own projects.
Added 'busy' flag to enable slave time to finish processing previous request.
Moved the setting of SDA as input to SET_USI_TO_TWI_START_CONDITION_MODE. This helps to prevent conditions where SDA is held low indefinitely after a SET_USI_TO_SEND_ACK or SET_USI_TO_SEND_DATA, due to a missed clock pulse.
Added macro SET_USI_TO_TWI_OVERFLOW_MODE.
Added a timeout to wait for proper start condition latch. Helps with second point above.
Added function usiTwiHandleSTOP which is called when a stop condition is detected via TinyWireS_stop_check. This ensures use of new 'busy' flag.
TinyWireS_stop_check modified to use usiTwiHandleSTOP.
Reinstated multibyte 'requestFrom' by master functionality.
Added tws_delay_micros function.
Added a few more comments and reduced some confusion resulting from mixing up the roles of 'Master read' and 'Master write' with what the slave is doing. I think that one actually came from the app note and original source!
Tested with ATtiny85 (1MHz) and SAMD21 (48MHz) as master.
Fixes issue #44 . Potentially helps with issues #24 , #36 , #43 and #47 ?