ITADN

Typo in STM target `i2c_write` function parameter name

#545Closedpfischer1687 创建于 2026-02-17
P
pfischer1687commented
In `mbed-os/targets/TARGET_STM/i2c_api.c`, the function `i2c_write` is declared as: ```c int i2c_write(i2c_t *obj, int address, const char *data, int z, int stop) ``` Inside the function though, `z` is never used. Instead, `length` is used in calls to `HAL_I2C_Master_Seq_Transmit_IT` and for timeout calculations: ```c int ret = HAL_I2C_Master_Seq_Transmit_IT(handle, address, (uint8_t *) data, length, xferOptions); ... uint32_t timeout = BYTE_TIMEOUT_US * (length + 1); ... count = length; ``` This causes a compiler error for me: ``` Use of undeclared identifier 'length' clang(undeclared_var_use) ``` I believe the function signature should replace the argument `z` → `length`: ```c int i2c_write(i2c_t *obj, int address, const char *data, int length, int stop) ``` This bug is currently preventing me from being able to build my code that uses ```mbed-os\drivers\source\I2C.cpp I2C::Result I2C::write(int address, const char *data, int length, bool repeated) ``` When making this change I am able to successfully build locally. @multiplemonomials
关闭于 2026-02-17 2 条评论