-
Notifications
You must be signed in to change notification settings - Fork 87
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
fix(PeriphDrivers): Fix CSI2 Line Count Stop Condition #1167
Conversation
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.
After testing, I found that with this fix, the last row will be lost.
The proper fix would be to always process the line and reload DMA, but then stop CSI if it is the last line, something like this:
#if 0 // Older version
if (line_cnt > csi2_state.req->lines_per_frame) {
// Frame complete
line_cnt = 0;
MXC_CSI2_RevA_Stop((mxc_csi2_reva_regs_t *)MXC_CSI2);
csi2_state.capture_stats.success = true;
// TODO(Jake): Call frame complete handler here when multi-frame exposures are implemented.
} else {
// There is a line to process
// Swap line buffers and reload DMA
csi2_state.capture_stats.bytes_captured += line_byte_num;
_swap_line_buffer();
MXC_DMA->ch[csi2_state.dma_channel].cnt = line_byte_num;
MXC_DMA->ch[csi2_state.dma_channel].dst = (uint32_t)lb.active;
MXC_DMA->ch[csi2_state.dma_channel].ctrl |= MXC_F_DMA_REVA_CTRL_EN;
if (csi2_state.req->line_handler != NULL) {
// Call line handler with a pointer to the inactive line buffer
int error = csi2_state.req->line_handler(lb.inactive, line_byte_num);
if (error)
{
MXC_CSI2_RevA_Stop((mxc_csi2_reva_regs_t *)MXC_CSI2);
}
}
}
#else // suggested fix
// There is a line to process
// Swap line buffers and reload DMA
csi2_state.capture_stats.bytes_captured += line_byte_num;
_swap_line_buffer();
MXC_DMA->ch[csi2_state.dma_channel].cnt = line_byte_num;
MXC_DMA->ch[csi2_state.dma_channel].dst = (uint32_t)lb.active;
MXC_DMA->ch[csi2_state.dma_channel].ctrl |= MXC_F_DMA_REVA_CTRL_EN;
if (csi2_state.req->line_handler != NULL) {
// Call line handler with a pointer to the inactive line buffer
int error = csi2_state.req->line_handler(lb.inactive, line_byte_num);
if (error)
{
MXC_CSI2_RevA_Stop((mxc_csi2_reva_regs_t *)MXC_CSI2);
}
}
if (line_cnt >= csi2_state.req->lines_per_frame) {
// Frame complete
line_cnt = 0;
MXC_CSI2_RevA_Stop((mxc_csi2_reva_regs_t *)MXC_CSI2);
csi2_state.capture_stats.success = true;
}
#endif
Pull in the latest code from main to add the fix for the "Basic Examples Test". The CI has an older ME18 revision attached which does not have the latest cache fix. Eric added this workaround for now until the newest ME18EVKIT revisions are in stock: #1176 |
This pull request is stale because it has been open for 30 days with no activity. Remove stale label, commit, or comment or this will be closed in 7 days. |
This pull request is stale because it has been open for 30 days with no activity. Remove stale label, commit, or comment or this will be closed in 7 days. |
This pull request was closed because it has been stalled for 7 days with no activity. |
Pull Request Template
Description
Fixes #1147
Checklist Before Requesting Review