Questions about 6 lines in the sensor.c file

Sry but I’m having some trouble understanding the sensor.c file. What do these 6 lines of code do?


1469	if (streaming_cb && doublebuf && image->pixels != NULL) {
            	// Call streaming callback function with previous frame.
            	// Note: Image pointer should Not be NULL in streaming mode.
1472           	streaming = streaming_cb(image);

Is this the function that calls the camera for the image? Where is streaming_cb defined?



         
1481        if (DCMI->CR & DCMI_JPEG_ENABLE) {
1482           	__HAL_DCMI_ENABLE_IT(&DCMIHandle, DCMI_IT_FRAME);
        	}

These two lines only applies if the sensor format is JPEG right?



1487	for (tick_start = HAL_GetTick(); waiting_for_data; ) {
1488            		__WFI();

Where are HAL_GetTick() and __WFI() defined? I searched the entire repo for these two functions but couldn’t find them. Is this just a timer? If so, where does the actual image transfer happen?

The first chunk is for the uvc firmware. You can ignore.

The second chunk if for JPEG mode from the OV5640/OV2640.

The third chunk is for waiting on the DMA to transfer data.

The DMA driver moves the data, then there’s a callback when the DMA is done moving the data into temporary buffers where the core moves the data from the temporary buffer to the image.

We have to do a temporary line buffer because the DMA module does very inefficient 32-bit single writes of data versus the M7 processor cache when accessing SDRAM. E.g. if you try to write the DMA data directly to SDRAM the memory system can’t keep up with the camera data rate. However, you can write the camera data to SRAM and then use the processor to write to SDRAM which has better bus utilization.