diff options
Diffstat (limited to 'os/hal/platforms/STM32/i2c_lld.c')
-rw-r--r-- | os/hal/platforms/STM32/i2c_lld.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/os/hal/platforms/STM32/i2c_lld.c b/os/hal/platforms/STM32/i2c_lld.c index 1345c847b..bda0ba17b 100644 --- a/os/hal/platforms/STM32/i2c_lld.c +++ b/os/hal/platforms/STM32/i2c_lld.c @@ -490,6 +490,8 @@ void i2c_lld_reset(I2CDriver *i2cp){ /** * @brief Receive data via the I2C bus as master. + * @details Number of receiving bytes must be more than 1 because of stm32 + * hardware restrictions. * * @param[in] i2cp pointer to the @p I2CDriver object * @param[in] slave_addr slave device address @@ -501,6 +503,8 @@ void i2c_lld_master_receive(I2CDriver *i2cp, uint8_t slave_addr, uint32_t mode = 0; + chDbgCheck((rxbytes > 1), "i2c_lld_master_receive"); + /* init driver fields */ i2cp->slave_addr = (slave_addr << 1) | 0x01; /* LSB = 1 -> receive */ i2cp->rxbytes = rxbytes; @@ -529,6 +533,9 @@ void i2c_lld_master_receive(I2CDriver *i2cp, uint8_t slave_addr, /** * @brief Transmits data via the I2C bus as master. * + * @details Number of receiving bytes must be 0 or more than 1 because of stm32 + * hardware restrictions. + * * @param[in] i2cp pointer to the @p I2CDriver object * @param[in] slave_addr slave device address * @param[in] txbuf pointer to the transmit buffer @@ -542,6 +549,9 @@ void i2c_lld_master_transmit(I2CDriver *i2cp, uint8_t slave_addr, uint32_t mode = 0; + chDbgCheck(((rxbytes == 0) || ((rxbytes > 1) && (rxbuf != NULL))), + "i2cMasterTransmit"); + /* init driver fields */ i2cp->slave_addr = (slave_addr << 1) & 0x00FE; /* LSB = 0 -> write */ i2cp->txbytes = txbytes; |