Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Jake-Carter
Copy link
Contributor

Pull Request Template

Description

Fixes #1147

Checklist Before Requesting Review

  • PR Title follows correct guidelines.
  • Description of changes and all other relevant information.
  • (Optional) Link any related GitHub issues using a keyword
  • (Optional) Provide info on any relevant functional testing/validation. For API changes or significant features, this is not optional.

Copy link
Contributor

@aniktash aniktash left a 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

@sihyung-maxim
Copy link
Contributor

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

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.

csi2_reva: Incorrect line count in end of frame detection in void MXC_CSI2_RevA_DMA_Handler()
3 participants