From: Nathael Pajani Date: Wed, 13 Mar 2013 15:25:58 +0000 (+0100) Subject: Re-init of read index in i2c structure in case i2c_read is called with only write... X-Git-Url: http://git.techno-innov.fr/?a=commitdiff_plain;h=29e2760d75a3f1a7a64497387d527fa27d37ef1f;p=soft%2Flpc122x%2Fcore Re-init of read index in i2c structure in case i2c_read is called with only write operations Comments and indentation --- diff --git a/drivers/eeprom.c b/drivers/eeprom.c index 94247fa..027d0d8 100644 --- a/drivers/eeprom.c +++ b/drivers/eeprom.c @@ -159,7 +159,7 @@ int eeprom_write(uint32_t offset, const void *buf, size_t count) char full_buff[(EEPROM_ID_MAX_PAGE_SIZE + MAX_CMD_SIZE)]; int eeprom_type = get_eeprom_type(); - switch (eeprom_type) { + switch (eeprom_type) { case EEPROM_TYPE_SMALL: cmd_size = CMD_SIZE_SMALL; page_size = EEPROM_ID_SMALL_PAGE_SIZE; diff --git a/drivers/i2c.c b/drivers/i2c.c index e629857..8f75684 100644 --- a/drivers/i2c.c +++ b/drivers/i2c.c @@ -111,7 +111,9 @@ void I2C_0_Handler(void) break; case 0x10: /* A repeated START has been transmitted. */ /* Setting read_index to 0 is usefull only if next data byte is - * Slave Address + Read (SLA + R), but it's OK if we will write too. */ + * Slave Address + Read (SLA + R), but it's OK if we perform a write too, and + * is necessary for read with a null data length used to probe for devices. + */ i2c->read_index = 0; /* Send Slave Address and Read/Write bit (SLA + R/W) * Depending on R/W bit, Master Receive or master Transmit mode will be enterred. */ @@ -254,7 +256,6 @@ void I2C_0_Handler(void) - /***************************************************************************** */ /* I2C access */ /***************************************************************************** */ @@ -307,6 +308,7 @@ int i2c_read(const void *cmd_buf, size_t cmd_size, const void* ctrl_buf, void* i /* read buffer */ mod_i2c.in_buff = inbuff; mod_i2c.read_length = count; + mod_i2c.read_index = 0; /* Start the process */ mod_i2c.state = I2C_BUSY;