Skip to content

optimized i2c hal implementation logic#433

Closed
Jiyun-Yang wants to merge 1 commit into
coredevices:mainfrom
Jiyun-Yang:i2c
Closed

optimized i2c hal implementation logic#433
Jiyun-Yang wants to merge 1 commit into
coredevices:mainfrom
Jiyun-Yang:i2c

Conversation

@Jiyun-Yang
Copy link
Copy Markdown
Contributor

optimized i2c hal implementation logic as iic communicate failed sometimes.

Copy link
Copy Markdown
Member

@gmarull gmarull left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you explain in the commit message what problem is this fixing?

Comment thread src/fw/drivers/sf32lb52/i2c_hal.c Outdated
} else {
i2c_handle_transfer_event(bus, I2CTransferEvent_Error);
}
//PBL_LOG(LOG_LEVEL_DEBUG, "give sema isr");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//PBL_LOG(LOG_LEVEL_DEBUG, "give sema isr");

Comment thread src/fw/drivers/sf32lb52/i2c_hal.c Outdated
hal = i2c_hal;
I2C_HandleTypeDef *handle = (I2C_HandleTypeDef *)&hal->hi2c;
__HAL_I2C_ENABLE(handle);
__HAL_I2C_ENABLE(handle);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
__HAL_I2C_ENABLE(handle);
__HAL_I2C_ENABLE(handle);

Comment thread src/fw/drivers/sf32lb52/i2c_hal.c Outdated
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());
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//PBL_LOG(LOG_LEVEL_DEBUG, "r1 tick:%ld", HAL_GetTick());

Comment thread src/fw/drivers/sf32lb52/i2c_hal.c Outdated
//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());
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//PBL_LOG(LOG_LEVEL_DEBUG, "r2 tick:%ld", HAL_GetTick());

Comment thread src/fw/drivers/sf32lb52/i2c_hal.c Outdated
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());
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//PBL_LOG(LOG_LEVEL_DEBUG, "w1 tick:%ld", HAL_GetTick());

Comment thread src/fw/drivers/sf32lb52/i2c_hal.c Outdated
//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());
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//PBL_LOG(LOG_LEVEL_DEBUG, "w2 tick:%ld", HAL_GetTick());

Signed-off-by: Yang Jiyun <yangjiyun@pro-well.tech>
portBASE_TYPE should_context_switch = pdFALSE;
(void)xSemaphoreGiveFromISR(bus->event_semaphore, &should_context_switch);
return should_context_switch;
return should_context_switch;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return should_context_switch;
return should_context_switch;

Copy link
Copy Markdown
Member

@gmarull gmarull left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tiny nitpick to fix, otherwise lgtm

@gmarull
Copy link
Copy Markdown
Member

gmarull commented Nov 6, 2025

merged fixing formatting issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants