diff --git a/drivers/include/periph/i2c.h b/drivers/include/periph/i2c.h index 42bcf1be2b..939884bc60 100644 --- a/drivers/include/periph/i2c.h +++ b/drivers/include/periph/i2c.h @@ -388,8 +388,8 @@ int i2c_write_bytes(i2c_t dev, uint16_t addr, const void *data, * @brief Convenience function for writing one byte to a given * register address * - * @note This function is using a repeated start sequence for writing to the - * specified register address. + * @note This function is using a continuous sequence for writing to the + * specified register address. It first writes the register then data. * * @pre i2c_acquire must be called before accessing the bus * @@ -414,8 +414,8 @@ int i2c_write_reg(i2c_t dev, uint16_t addr, uint16_t reg, /** * @brief Convenience function for writing data to a given register address * - * @note This function is using a repeated start sequence for writing to the - * specified register address. + * @note This function is using a continuous sequence for writing to the + * specified register address. It first writes the register then data. * * @pre i2c_acquire must be called before accessing the bus * diff --git a/drivers/periph_common/i2c.c b/drivers/periph_common/i2c.c index 4cde5dd493..f6e3ad0b00 100644 --- a/drivers/periph_common/i2c.c +++ b/drivers/periph_common/i2c.c @@ -17,6 +17,7 @@ * * @} */ +#include #include "board.h" #include "cpu.h" @@ -36,6 +37,9 @@ int i2c_read_reg(i2c_t dev, uint16_t addr, uint16_t reg, int i2c_read_regs(i2c_t dev, uint16_t addr, uint16_t reg, void *data, size_t len, uint8_t flags) { + if (flags & (I2C_NOSTOP | I2C_NOSTART)) { + return -EOPNOTSUPP; + } /* First set ADDR and register with no stop */ int ret = i2c_write_bytes(dev, addr, ®, (flags & I2C_REG16) ? 2 : 1, flags | I2C_NOSTOP); @@ -69,6 +73,9 @@ int i2c_write_reg(i2c_t dev, uint16_t addr, uint16_t reg, int i2c_write_regs(i2c_t dev, uint16_t addr, uint16_t reg, const void *data, size_t len, uint8_t flags) { + if (flags & (I2C_NOSTOP | I2C_NOSTART)) { + return -EOPNOTSUPP; + } /* First set ADDR and register with no stop */ int ret = i2c_write_bytes(dev, addr, ®, (flags & I2C_REG16) ? 2 : 1, flags | I2C_NOSTOP);