Repository: incubator-mynewt-core Updated Branches: refs/heads/develop f4f67ef83 -> cad60d8f3
stm32f4 i2c; fix off-by-one check. Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/cad60d8f Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/cad60d8f Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/cad60d8f Branch: refs/heads/develop Commit: cad60d8f30cb827469b833d4e3cf4b57056dee8d Parents: f4f67ef Author: Marko Kiiskila <ma...@runtime.io> Authored: Tue Oct 11 20:09:56 2016 -0700 Committer: Marko Kiiskila <ma...@runtime.io> Committed: Tue Oct 11 20:09:56 2016 -0700 ---------------------------------------------------------------------- hw/mcu/stm/stm32f4xx/src/hal_i2c.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/cad60d8f/hw/mcu/stm/stm32f4xx/src/hal_i2c.c ---------------------------------------------------------------------- diff --git a/hw/mcu/stm/stm32f4xx/src/hal_i2c.c b/hw/mcu/stm/stm32f4xx/src/hal_i2c.c index 1dad92a..38d0316 100644 --- a/hw/mcu/stm/stm32f4xx/src/hal_i2c.c +++ b/hw/mcu/stm/stm32f4xx/src/hal_i2c.c @@ -79,7 +79,7 @@ hal_i2c_init(uint8_t i2c_num, void *usercfg) I2C_InitTypeDef *init; int rc; - if (i2c_num > HAL_I2C_MAX_DEVS || !(dev = hal_i2c_devs[i2c_num])) { + if (i2c_num >= HAL_I2C_MAX_DEVS || !(dev = hal_i2c_devs[i2c_num])) { return -1; } @@ -124,7 +124,7 @@ hal_i2c_master_write(uint8_t i2c_num, struct hal_i2c_master_data *data, { struct stm32f4_hal_i2c *dev; - if (i2c_num > HAL_I2C_MAX_DEVS || !(dev = hal_i2c_devs[i2c_num])) { + if (i2c_num >= HAL_I2C_MAX_DEVS || !(dev = hal_i2c_devs[i2c_num])) { return -1; } @@ -138,7 +138,7 @@ hal_i2c_master_read(uint8_t i2c_num, struct hal_i2c_master_data *pdata, { struct stm32f4_hal_i2c *dev; - if (i2c_num > HAL_I2C_MAX_DEVS || !(dev = hal_i2c_devs[i2c_num])) { + if (i2c_num >= HAL_I2C_MAX_DEVS || !(dev = hal_i2c_devs[i2c_num])) { return -1; } @@ -164,7 +164,7 @@ hal_i2c_master_probe(uint8_t i2c_num, uint8_t address, uint32_t timo) struct stm32f4_hal_i2c *dev; int rc; - if (i2c_num > HAL_I2C_MAX_DEVS || !(dev = hal_i2c_devs[i2c_num])) { + if (i2c_num >= HAL_I2C_MAX_DEVS || !(dev = hal_i2c_devs[i2c_num])) { return -1; }