-
Notifications
You must be signed in to change notification settings - Fork 23
I2C error handling #279
I2C error handling #279
Conversation
irq::clear(irqn); | ||
constexpr auto i2c = pick_i2c(); | ||
|
||
// Explain difference between Events and Flags ????????? |
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.
You can delete this line :)
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.
Prefix >#256
to each commit, not only 1st
// Now for any error interrupts was used common plan of action: | ||
// 1) clear error flags | ||
// 2) generate stop | ||
// This may not work for some interrupt |
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.
for some interrupts
-> for some error states
to be more specific
// TODO: Create error handling for every error flags | ||
I2C_GenerateSTOP(i2c, ENABLE); | ||
|
||
// Software reset did not help with resolving the error. |
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.
Be more verbose here; I propose use following form:
According to ... software reset (<function_name>) should help recover from error state, but when placed here it causes a hang
|
||
// Explain difference between Events and Flags ????????? | ||
// I2C_GetLastEvent() is suitable when multiple flags are monitored at the same time. | ||
// Using the function I2C_GetFlagStatus() return the status of one single flag. |
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.
I asked you to explain that I2C_GetLastEvent()
returns type which is compatible with I2C_FLAG_*
definitions.
namespace ecl | ||
{ | ||
|
||
static inline void bypass_puts(const char *str) |
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.
Missing doxygen comment
if (rc == err::ok) { | ||
i2c_dev::xfer(); | ||
// For full reset htu21d sensor need less than 15 ms as written in documentation |
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.
This comment is not relevant to the purpose of this function
rc = i2c_dev::xfer(); | ||
} | ||
i2c_dev::unlock(); | ||
rc = try_xfer(0, data, sizeof(data)); |
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.
0
is a magic number. Add CMD_NONE
to sensor I2C commands enum and use it instead of 0
@@ -214,10 +210,32 @@ err htu21d<i2c_dev>::write_user_register(uint8_t value) | |||
|
|||
i2c_dev::platform_handle::set_slave_addr(i2_addr); | |||
|
|||
err rc = try_xfer(tx_buff, nullptr, sizeof(tx_buff)); | |||
|
|||
return rc; |
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.
Lines above can be combined
Also, do not include |
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.
squash 07cf66d somewhere (see also commit style:
https://forgge.github.io/theCore/community.html#commit-and-pr-style
err rc = i2c_dev::set_buffers(tx_buff, nullptr, sizeof(tx_buff)); | ||
err rc; | ||
|
||
if (!cmd) { |
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.
-> cmd == CMD_NONE
// TODO: Create error handling for every error flags | ||
I2C_GenerateSTOP(i2c, ENABLE); | ||
|
||
// Accordint to I2C library software reset I2C_SoftwareResetCmd should help recover |
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.
-> According
irq::clear(irqn); | ||
constexpr auto i2c = pick_i2c(); | ||
|
||
// I2C_GetLastEvent() is suitable when multiple flags are monitored at the same time. Returns type is compatible with I2C_FLAG_* definitions. |
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.
- line too long, split it according to code style
Returns type is compatible
->The return type is
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.
i2c_dev::xfer(); | ||
} | ||
i2c_dev::unlock(); | ||
err rc = try_xfer(cmd, &value, 1); | ||
|
||
return rc; | ||
} |
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.
lines above can be combined
Looks good to me, thanks! |
No description provided.