[NUCLEO_F030R8] enhance I2C for EEPROM

pull/383/head
dbestm 2014-07-01 14:15:07 +02:00
parent 2af0e5b5fc
commit 7b4bcd6eaf
1 changed files with 3 additions and 7 deletions

View File

@ -178,8 +178,6 @@ int i2c_read(i2c_t *obj, int address, char *data, int length, int stop) {
int timeout;
int value;
if (length == 0) return 0;
// Configure slave address, nbytes, reload, end mode and start or stop generation
I2C_TransferHandling(i2c, address, length, I2C_SoftEnd_Mode, I2C_Generate_Start_Read);
@ -192,7 +190,7 @@ int i2c_read(i2c_t *obj, int address, char *data, int length, int stop) {
timeout = FLAG_TIMEOUT;
while (!I2C_GetFlagStatus(i2c, I2C_FLAG_TC)) {
timeout--;
if (timeout == 0) return 0;
if (timeout == 0) return -1;
}
if (stop) i2c_stop(obj);
@ -205,8 +203,6 @@ int i2c_write(i2c_t *obj, int address, const char *data, int length, int stop) {
int timeout;
int count;
if (length == 0) return 0;
// Configure slave address, nbytes, reload, end mode and start generation
I2C_TransferHandling(i2c, address, length, I2C_SoftEnd_Mode, I2C_Generate_Start_Write);
@ -218,7 +214,7 @@ int i2c_write(i2c_t *obj, int address, const char *data, int length, int stop) {
timeout = FLAG_TIMEOUT;
while (!I2C_GetFlagStatus(i2c, I2C_FLAG_TC)) {
timeout--;
if (timeout == 0) return 0;
if (timeout == 0) return -1;
}
if (stop) i2c_stop(obj);
@ -236,7 +232,7 @@ int i2c_byte_read(i2c_t *obj, int last) {
while (I2C_GetFlagStatus(i2c, I2C_ISR_RXNE) == RESET) {
timeout--;
if (timeout == 0) {
return 0;
return -1;
}
}