-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
ArduinoCore-avr_I2C_timeout_added #74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Added the declaration of the timeout function used in I2C operations.
Create LICENSE
You should use ISR, not SIGNAL. You also need to replace tabs with spaces |
while(TWI_MRX == twi_state){ | ||
if (twi_timeout(0)) break; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (twi_timeout(0)) break; | |
if (twi_timeout(0)) break; |
while(TWI_READY != twi_state){ | ||
if (twi_timeout(0)) | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please follow the formatting style of the rest of the code in the file and attach this brace to the if statement.
while(TWI_READY != twi_state){ | ||
if (twi_timeout(0)) | ||
{ | ||
return 32; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return 32; | |
return 32; |
if (twi_timeout(0)) | ||
{ | ||
return 32; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | |
} |
@@ -271,11 +286,16 @@ uint8_t twi_writeTo(uint8_t address, uint8_t* data, uint8_t length, uint8_t wait | |||
TWCR = _BV(TWINT) | _BV(TWEA) | _BV(TWEN) | _BV(TWIE); // enable INTs, but not START | |||
} | |||
else | |||
// send start condition | |||
// send start condition |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// send start condition | |
// send start condition |
twi_timer_count=0; | ||
// reinitialize the hardware | ||
twi_init(); | ||
return 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return 1; | |
return 1; |
// reinitialize the hardware | ||
twi_init(); | ||
return 1; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | |
} |
twi_init(); | ||
return 1; | ||
} | ||
return 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return 0; | |
return 0; |
@@ -0,0 +1,512 @@ | |||
This file includes license information for arduino avr core. The code has been forked |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this file from the PR.
@@ -0,0 +1,8 @@ | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this file from the PR.
|
To make sure that I2C read write operations does not get stuck in an infinite loop, a timeout has been added.