optimized i2c hal implementation logic#433
Closed
Jiyun-Yang wants to merge 1 commit into
Closed
Conversation
gmarull
reviewed
Nov 6, 2025
Member
gmarull
left a comment
There was a problem hiding this comment.
could you explain in the commit message what problem is this fixing?
| } else { | ||
| i2c_handle_transfer_event(bus, I2CTransferEvent_Error); | ||
| } | ||
| //PBL_LOG(LOG_LEVEL_DEBUG, "give sema isr"); |
Member
There was a problem hiding this comment.
Suggested change
| //PBL_LOG(LOG_LEVEL_DEBUG, "give sema isr"); |
| hal = i2c_hal; | ||
| I2C_HandleTypeDef *handle = (I2C_HandleTypeDef *)&hal->hi2c; | ||
| __HAL_I2C_ENABLE(handle); | ||
| __HAL_I2C_ENABLE(handle); |
Member
There was a problem hiding this comment.
Suggested change
| __HAL_I2C_ENABLE(handle); | |
| __HAL_I2C_ENABLE(handle); |
| status = HAL_I2C_Mem_Read_DMA(handle, msg->addr, msg->mem_addr, mem_addr_type, msg->buf, | ||
| msg->len); | ||
| } else if (hal->i2c_state->int_enabled) { | ||
| //PBL_LOG(LOG_LEVEL_DEBUG, "r1 tick:%ld", HAL_GetTick()); |
Member
There was a problem hiding this comment.
Suggested change
| //PBL_LOG(LOG_LEVEL_DEBUG, "r1 tick:%ld", HAL_GetTick()); |
| //PBL_LOG(LOG_LEVEL_DEBUG, "r1 tick:%ld", HAL_GetTick()); | ||
| status = HAL_I2C_Mem_Read_IT(handle, msg->addr, msg->mem_addr, mem_addr_type, msg->buf, | ||
| msg->len); | ||
| //PBL_LOG(LOG_LEVEL_DEBUG, "r2 tick:%ld", HAL_GetTick()); |
Member
There was a problem hiding this comment.
Suggested change
| //PBL_LOG(LOG_LEVEL_DEBUG, "r2 tick:%ld", HAL_GetTick()); |
| status = HAL_I2C_Mem_Write_DMA(handle, msg->addr, msg->mem_addr, mem_addr_type, msg->buf, | ||
| msg->len); | ||
| } else if (hal->i2c_state->int_enabled) { | ||
| //PBL_LOG(LOG_LEVEL_DEBUG, "w1 tick:%ld", HAL_GetTick()); |
Member
There was a problem hiding this comment.
Suggested change
| //PBL_LOG(LOG_LEVEL_DEBUG, "w1 tick:%ld", HAL_GetTick()); |
| //PBL_LOG(LOG_LEVEL_DEBUG, "w1 tick:%ld", HAL_GetTick()); | ||
| status = HAL_I2C_Mem_Write_IT(handle, msg->addr, msg->mem_addr, mem_addr_type, msg->buf, | ||
| msg->len); | ||
| //PBL_LOG(LOG_LEVEL_DEBUG, "w2 tick:%ld", HAL_GetTick()); |
Member
There was a problem hiding this comment.
Suggested change
| //PBL_LOG(LOG_LEVEL_DEBUG, "w2 tick:%ld", HAL_GetTick()); |
Signed-off-by: Yang Jiyun <yangjiyun@pro-well.tech>
gmarull
reviewed
Nov 6, 2025
| portBASE_TYPE should_context_switch = pdFALSE; | ||
| (void)xSemaphoreGiveFromISR(bus->event_semaphore, &should_context_switch); | ||
| return should_context_switch; | ||
| return should_context_switch; |
Member
There was a problem hiding this comment.
Suggested change
| return should_context_switch; | |
| return should_context_switch; |
gmarull
approved these changes
Nov 6, 2025
Member
gmarull
left a comment
There was a problem hiding this comment.
tiny nitpick to fix, otherwise lgtm
Member
|
merged fixing formatting issues |
This was referenced Nov 6, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
optimized i2c hal implementation logic as iic communicate failed sometimes.