-
Notifications
You must be signed in to change notification settings - Fork 5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[device]修改i2c读写函数返回类型为rt_ssize_t #7029
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,11 +51,11 @@ struct rt_i2c_bus_device *rt_i2c_bus_device_find(const char *bus_name) | |
return bus; | ||
} | ||
|
||
rt_size_t rt_i2c_transfer(struct rt_i2c_bus_device *bus, | ||
rt_ssize_t rt_i2c_transfer(struct rt_i2c_bus_device *bus, | ||
struct rt_i2c_msg msgs[], | ||
rt_uint32_t num) | ||
{ | ||
rt_size_t ret; | ||
rt_ssize_t ret; | ||
|
||
if (bus->ops->master_xfer) | ||
{ | ||
|
@@ -78,7 +78,7 @@ rt_size_t rt_i2c_transfer(struct rt_i2c_bus_device *bus, | |
{ | ||
LOG_E("I2C bus operation not supported"); | ||
|
||
return 0; | ||
return -RT_ERROR; | ||
} | ||
} | ||
|
||
|
@@ -98,17 +98,17 @@ rt_err_t rt_i2c_control(struct rt_i2c_bus_device *bus, | |
{ | ||
LOG_E("I2C bus operation not supported"); | ||
|
||
return 0; | ||
return -RT_ERROR; | ||
} | ||
} | ||
|
||
rt_size_t rt_i2c_master_send(struct rt_i2c_bus_device *bus, | ||
rt_ssize_t rt_i2c_master_send(struct rt_i2c_bus_device *bus, | ||
rt_uint16_t addr, | ||
rt_uint16_t flags, | ||
const rt_uint8_t *buf, | ||
rt_uint32_t count) | ||
{ | ||
rt_size_t ret; | ||
rt_ssize_t ret; | ||
struct rt_i2c_msg msg; | ||
|
||
msg.addr = addr; | ||
|
@@ -118,16 +118,16 @@ rt_size_t rt_i2c_master_send(struct rt_i2c_bus_device *bus, | |
|
||
ret = rt_i2c_transfer(bus, &msg, 1); | ||
|
||
return (ret > 0) ? count : ret; | ||
return ret; | ||
} | ||
|
||
rt_size_t rt_i2c_master_recv(struct rt_i2c_bus_device *bus, | ||
rt_ssize_t rt_i2c_master_recv(struct rt_i2c_bus_device *bus, | ||
rt_uint16_t addr, | ||
rt_uint16_t flags, | ||
rt_uint8_t *buf, | ||
rt_uint32_t count) | ||
{ | ||
rt_size_t ret; | ||
rt_ssize_t ret; | ||
struct rt_i2c_msg msg; | ||
RT_ASSERT(bus != RT_NULL); | ||
|
||
|
@@ -138,11 +138,5 @@ rt_size_t rt_i2c_master_recv(struct rt_i2c_bus_device *bus, | |
|
||
ret = rt_i2c_transfer(bus, &msg, 1); | ||
|
||
return (ret > 0) ? count : ret; | ||
return ret; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not back-compatible. It SHOULD return byte count value if received an I2C message successfully. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 5.0.0不考虑向前兼容的问题,一些历史包袱需要在这个版本中逐步得到解决,返回值改为:如果返回值>=0 为成功传输的长度,<0为传输出现错误并返回错误码 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
所以這兩個 APIs 應該回傳成功传输 "byte count" 長度; 而不是"message number"。對嗎? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 噢噢 我理解你的意思了 这个地方有问题 返回应该是成功传输的长度,而不是message number。我落实下去来改。 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks Meco. |
||
} | ||
|
||
int rt_i2c_core_init(void) | ||
{ | ||
return 0; | ||
} | ||
INIT_COMPONENT_EXPORT(rt_i2c_core_init); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not back-compatible. It SHOULD return byte count value if sent an I2C message successfully.