First fully working camera capture, transfer and receive!

This commit is contained in:
Adam Prochazka
2023-04-07 21:34:59 +02:00
parent 5132e015bd
commit 2007a5de10
11 changed files with 146 additions and 310 deletions

View File

@ -127,7 +127,7 @@ void cdc_task(void)
}
*/
uint8_t sendT[600] = {
uint8_t sendT[700] = {
0xff, 0xd8, 0xff, 0xdb, 0x00, 0x43, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
@ -166,7 +166,14 @@ uint8_t sendT[600] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
/*
@ -274,18 +281,19 @@ int main(void)
uint16_t image_size = Cam_FIFO_length(&hspi1);
uint8_t image_data[10000];
//memset(image_data, 0x00, image_size);
memset(image_data, 0x00, 10000);
Cam_Start_Burst_Read(&hspi1);
HAL_SPI_Receive_DMA(&hspi1, image_data, image_size);
//HAL_SPI_Receive(&hspi1, image_data, image_size, HAL_MAX_DELAY);
//HAL_SPI_Receive_DMA(&hspi1, image_data, 10000);
HAL_SPI_Receive(&hspi1, image_data, 10000, HAL_MAX_DELAY);
LED_On();
while (SPI_Rx_Done_Flag == 0)
{
// Wait for SPI transfer to finish
break;
}
LED_On();
CS_Off();
SPI_Rx_Done_Flag = 0;
@ -298,12 +306,15 @@ int main(void)
tud_task();
if(currentSendingIndex >= 9989){
if(currentSendingIndex >= 9949){
//if(false){
currentSendingIndex = 0;
//free(image_data);
Cam_Capture(&hspi1);
for(int i = 0; i < 10000; i++) image_data[i] = 0x00;
Cam_Init(&hi2c1, &hspi1);
Cam_Capture(&hspi1);
image_size = Cam_FIFO_length(&hspi1);
@ -312,29 +323,31 @@ int main(void)
Cam_Start_Burst_Read(&hspi1);
HAL_SPI_Receive_DMA(&hspi1, image_data, 10000);
HAL_SPI_Receive(&hspi1, image_data, 10000, HAL_MAX_DELAY);
//Debug_LED_On();
while (SPI_Rx_Done_Flag == 0)
{
// Wait for SPI transfer to finish
tud_task();
//tud_task();
break;
}
CS_Off();
SPI_Rx_Done_Flag = 0;
//SPI_Rx_Done_Flag = 0;
if(image_size < 1){
currentSendingIndex = 10000;
currentSendingIndex = 10000;
LED_On();
}
}
else {
LED_On();
//tud_cdc_write("11111111\r\n", 10);
//tud_cdc_write_flush();
//tud_cdc_write(&sendT[currentSendingIndex], 10);
tud_cdc_write(&image_data[currentSendingIndex], 10);
//tud_cdc_write(&sendT[currentSendingIndex], 50);
tud_cdc_write(&image_data[currentSendingIndex], 50);
tud_cdc_write_flush();
currentSendingIndex = currentSendingIndex + 10;
currentSendingIndex = currentSendingIndex + 50;
HAL_Delay(5);
}