Auto config, no need to init before each capture, 320x240 cca 5fps

main
Adam Prochazka 2 years ago
parent 374a63bc0c
commit 58b09c93ab

@ -120,27 +120,37 @@ void Cam_I2C_write_bulk(I2C_HandleTypeDef *hi2c, const struct sensor_reg regList
void Cam_Init(I2C_HandleTypeDef *hi2c, SPI_HandleTypeDef *hspi) void Cam_Init(I2C_HandleTypeDef *hi2c, SPI_HandleTypeDef *hspi)
{ {
Cam_I2C_write(hi2c, (uint16_t)0x3008, 0x80); Cam_SPI_write(hspi, 0x07, 0x80);
HAL_Delay(100);
Cam_SPI_write(hspi, 0x07, 0x00);
HAL_Delay(100);
//Cam_SPI_write(hspi, 0x00, 0x55);
HAL_Delay(5);
Cam_I2C_write(hi2c, (uint16_t)0x3008, 0x80);
HAL_Delay(5);
Cam_I2C_write_bulk(hi2c, OV5642_QVGA_Preview); Cam_I2C_write_bulk(hi2c, OV5642_QVGA_Preview);
HAL_Delay(200);
Cam_I2C_write_bulk(hi2c, OV5642_JPEG_Capture_QSXGA); Cam_I2C_write_bulk(hi2c, OV5642_JPEG_Capture_QSXGA);
Cam_I2C_write_bulk(hi2c, ov5642_320x240);
HAL_Delay(100);
//Cam_I2C_write_bulk(hi2c, OV5642_720P_Video_setting); //Cam_I2C_write_bulk(hi2c, OV5642_720P_Video_setting);
Cam_I2C_write(hi2c, (uint16_t)0x3818, 0xa8); // TIMING CONTROL - ENABLE COMPRESSION, THUMBNAIL MODE DISABLE, VERTICAL FLIP, MIRROR Cam_I2C_write(hi2c, (uint16_t)0x3818, 0xa8); // TIMING CONTROL - ENABLE COMPRESSION, THUMBNAIL MODE DISABLE, VERTICAL FLIP, MIRROR
Cam_I2C_write(hi2c, (uint16_t)0x3621, 0x10); // REGISTER FOR CORRECT MIRROR FUNCTION Cam_I2C_write(hi2c, (uint16_t)0x3621, 0x10); // REGISTER FOR CORRECT MIRROR FUNCTION
Cam_I2C_write(hi2c, (uint16_t)0x3801, 0xb0); // TIMING HORIZONTAL START - ALSO FOR MIRROR Cam_I2C_write(hi2c, (uint16_t)0x3801, 0xb0); // TIMING HORIZONTAL START - ALSO FOR MIRROR
Cam_I2C_write(hi2c, (uint16_t)0x4407, 0x04); // COMPRESSION CONTROL Cam_I2C_write(hi2c, (uint16_t)0x4407, 0x04); // COMPRESSION CONTROL
Cam_I2C_write(hi2c, (uint16_t)0x5000, 0xFF); //Cam_I2C_write(hi2c, (uint16_t)0x5000, 0xFF);
HAL_Delay(5);
Cam_I2C_write_bulk(hi2c, ov5642_1024x768);
// Setup camera, H-sync: High, V-sync:high, Sensor_delay: no Delay, FIFO_mode:FIFO enabled, power_mode:Low_power // Setup camera, H-sync: High, V-sync:high, Sensor_delay: no Delay, FIFO_mode:FIFO enabled, power_mode:Low_power
Cam_SPI_write(hspi, 0x03, 0x02); Cam_SPI_write(hspi, 0x03, 0x02);
HAL_Delay(5);
//Cam_I2C_write_bulk(hi2c, ov5642_1024x768);
Cam_I2C_write_bulk(hi2c, ov5642_320x240);
HAL_Delay(1000);
Cam_SPI_write(hspi, 0x04, 0x01);
HAL_Delay(5);
Cam_SPI_write(hspi, 0x01, 0x00); // Capture Control Register - Set to capture n+1 frames Cam_SPI_write(hspi, 0x01, 0x00); // Capture Control Register - Set to capture n+1 frames
HAL_Delay(5); HAL_Delay(5);
/* /*
Cam_I2C_write(hi2c, (uint16_t)0x3008, 0x80); Cam_I2C_write(hi2c, (uint16_t)0x3008, 0x80);
@ -275,9 +285,8 @@ void Cam_Refresh(I2C_HandleTypeDef *hi2c, SPI_HandleTypeDef *hspi){
Cam_I2C_write(hi2c, (uint16_t)0x3404, 0xf); Cam_I2C_write(hi2c, (uint16_t)0x3404, 0xf);
Cam_I2C_write(hi2c, (uint16_t)0x3405, 0xff); Cam_I2C_write(hi2c, (uint16_t)0x3405, 0xff);
Cam_SPI_write(hspi, 0x01, 0x00); // Capture Control Register - Set to capture n+1 frames
HAL_Delay(5); HAL_Delay(50);
} }
int Cam_FIFO_length(SPI_HandleTypeDef *hspi) int Cam_FIFO_length(SPI_HandleTypeDef *hspi)
@ -311,11 +320,12 @@ void Cam_Start_Capture(SPI_HandleTypeDef *hspi)
Cam_SPI_write(hspi, 0x04, FIFO_Reg_Clear_Flags); Cam_SPI_write(hspi, 0x04, FIFO_Reg_Clear_Flags);
*/ */
Cam_SPI_write(hspi, 0x04, 0x01); Cam_SPI_write(hspi, 0x04, 0x01);
HAL_Delay(3);
Cam_SPI_write(hspi, 0x04, 0x01); Cam_SPI_write(hspi, 0x04, 0x01);
HAL_Delay(10); HAL_Delay(3);
Cam_SPI_write(hspi, 0x04, 0x02); // Start capture Cam_SPI_write(hspi, 0x04, 0x02); // Start capture
HAL_Delay(10); HAL_Delay(3);
} }
void Cam_Wait_Capture_Done(SPI_HandleTypeDef *hspi) void Cam_Wait_Capture_Done(SPI_HandleTypeDef *hspi)
@ -354,6 +364,8 @@ void Cam_Capture(SPI_HandleTypeDef *hspi)
{ {
//LED_On(); //LED_On();
Cam_SPI_write(hspi, 0x01, 0x00); // Capture Control Register - Set to capture n+1 frames
Cam_Start_Capture(hspi); Cam_Start_Capture(hspi);
Cam_Wait_Capture_Done(hspi); Cam_Wait_Capture_Done(hspi);

@ -11,37 +11,6 @@ typedef struct sensor_reg
static const struct sensor_reg ov5642_320x240[] = static const struct sensor_reg ov5642_320x240[] =
{ {
/**************************Small viewing angle and fast frame rate*************/
// {0x3800 ,0x4 },
// {0x3801 ,0xb0},
// {0x3802 ,0x2 },
// {0x3803 ,0xbc},
// {0x3804 ,0x6 },
// {0x3805 ,0x40},
// {0x3806 ,0x4 },
// {0x3807 ,0xb0},
// {0x3808 ,0x1 },
// {0x3809 ,0x40},
// {0x380a ,0x0 },
// {0x380b ,0xF0},
// {0x380c ,0xb },
// {0x380d ,0x20},
// {0x380e ,0x7 },
// {0x380f ,0xD0},
// {0x5001 ,0x7f},
// {0x5680 ,0x4 },
// {0x5681 ,0xb0},
// {0x5682 ,0x6},
// {0x5683 ,0x40},
// {0x5684 ,0x2 },
// {0x5685 ,0xbc},
// {0x5686 ,0x4 },
// {0x5687 ,0xb0},
// {0x3011 ,0x0F}, //bit[5:0] div
// {0xffff, 0xff},
/**************************Small viewing angle and fast frame rate*************/
/**************************Large viewing angle, slow frame rate*************/
{0x3800 ,0x1 }, {0x3800 ,0x1 },
{0x3801 ,0xa8}, {0x3801 ,0xa8},
{0x3802 ,0x0 }, {0x3802 ,0x0 },
@ -67,9 +36,8 @@ static const struct sensor_reg ov5642_320x240[] =
{0x5685 ,0x0 }, {0x5685 ,0x0 },
{0x5686 ,0x7 }, {0x5686 ,0x7 },
{0x5687 ,0x98}, {0x5687 ,0x98},
{0x3011, 0x0F}, // bit[5:0] div {0x3801, 0xb0},
{0xffff, 0xff}, {0xffff, 0xff},
/**************************Large viewing angle, slow frame rate*************/
}; };
static const struct sensor_reg ov5642_640x480[] = static const struct sensor_reg ov5642_640x480[] =
@ -86,20 +54,20 @@ static const struct sensor_reg ov5642_640x480[] =
{0x3809, 0x80}, {0x3809, 0x80},
{0x380a, 0x1}, {0x380a, 0x1},
{0x380b, 0xe0}, {0x380b, 0xe0},
{0x380c, 0xc}, {0x380c, 0xc}, //
{0x380d, 0x80}, {0x380d, 0x80}, //
{0x380e, 0x7}, {0x380e, 0x7}, //
{0x380f, 0xd0}, {0x380f, 0xd0}, //
{0x5001, 0x7f}, {0x5001, 0x7f}, //
{0x5680, 0x0}, {0x5680, 0x0}, //
{0x5681, 0x0}, {0x5681, 0x0}, //
{0x5682, 0xA}, {0x5682, 0xA}, //
{0x5683, 0x20}, {0x5683, 0x20}, //
{0x5684, 0x0}, {0x5684, 0x0}, //
{0x5685, 0x0}, {0x5685, 0x0}, //
{0x5686, 0x7}, {0x5686, 0x7}, //
{0x5687, 0x98}, {0x5687, 0x98}, //
{0x3801, 0xb0}, {0x3801, 0xb0}, //
{0xffff, 0xff}, {0xffff, 0xff},
}; };
@ -616,49 +584,49 @@ static const struct sensor_reg OV5642_QVGA_Preview[] =
{0x5808 ,0x26}, {0x5808 ,0x26},
{0x5809 ,0x17}, {0x5809 ,0x17},
{0x580a ,0x11}, {0x580a ,0x11},
{0x580b, 0xe}, {0x580b ,0x0e },
{0x580c, 0xd}, {0x580c ,0x0d },
{0x580d, 0xe}, {0x580d ,0x0e },
{0x580e ,0x13}, {0x580e ,0x13},
{0x580f ,0x1a}, {0x580f ,0x1a},
{0x5810 ,0x15}, {0x5810 ,0x15},
{0x5811, 0xd}, {0x5811 ,0x0d },
{0x5812, 0x8}, {0x5812 ,0x08 },
{0x5813, 0x5}, {0x5813 ,0x05 },
{0x5814, 0x4}, {0x5814 ,0x04 },
{0x5815, 0x5}, {0x5815 ,0x05 },
{0x5816, 0x9}, {0x5816 ,0x09 },
{0x5817, 0xd}, {0x5817 ,0x0d },
{0x5818 ,0x11}, {0x5818 ,0x11},
{0x5819, 0xa}, {0x5819 ,0x0a },
{0x581a, 0x4}, {0x581a ,0x04 },
{0x581b, 0x0}, {0x581b ,0x00 },
{0x581c, 0x0}, {0x581c ,0x00 },
{0x581d, 0x1}, {0x581d ,0x01 },
{0x581e, 0x6}, {0x581e ,0x06 },
{0x581f, 0x9}, {0x581f ,0x09 },
{0x5820 ,0x12}, {0x5820 ,0x12},
{0x5821, 0xb}, {0x5821 ,0x0b },
{0x5822, 0x4}, {0x5822 ,0x04 },
{0x5823, 0x0}, {0x5823 ,0x00 },
{0x5824, 0x0}, {0x5824 ,0x00 },
{0x5825, 0x1}, {0x5825 ,0x01 },
{0x5826, 0x6}, {0x5826 ,0x06 },
{0x5827, 0xa}, {0x5827 ,0x0a },
{0x5828 ,0x17}, {0x5828 ,0x17},
{0x5829, 0xf}, {0x5829 ,0x0f },
{0x582a, 0x9}, {0x582a ,0x09 },
{0x582b, 0x6}, {0x582b ,0x06 },
{0x582c, 0x5}, {0x582c ,0x05 },
{0x582d, 0x6}, {0x582d ,0x06 },
{0x582e, 0xa}, {0x582e ,0x0a },
{0x582f, 0xe}, {0x582f ,0x0e },
{0x5830 ,0x28}, {0x5830 ,0x28},
{0x5831 ,0x1a}, {0x5831 ,0x1a},
{0x5832 ,0x11}, {0x5832 ,0x11},
{0x5833, 0xe}, {0x5833 ,0x0e },
{0x5834, 0xe}, {0x5834 ,0x0e },
{0x5835, 0xf}, {0x5835 ,0x0f },
{0x5836 ,0x15}, {0x5836 ,0x15},
{0x5837 ,0x1d}, {0x5837 ,0x1d},
{0x5838 ,0x6e}, {0x5838 ,0x6e},
@ -669,42 +637,42 @@ static const struct sensor_reg OV5642_QVGA_Preview[] =
{0x583d ,0x23}, {0x583d ,0x23},
{0x583e ,0x2f}, {0x583e ,0x2f},
{0x583f ,0x41}, {0x583f ,0x41},
{0x5840, 0xe}, {0x5840 ,0x0e },
{0x5841, 0xc}, {0x5841 ,0x0c },
{0x5842, 0xd}, {0x5842 ,0x0d },
{0x5843, 0xc}, {0x5843 ,0x0c },
{0x5844, 0xc}, {0x5844 ,0x0c },
{0x5845, 0xc}, {0x5845 ,0x0c },
{0x5846, 0xc}, {0x5846 ,0x0c },
{0x5847, 0xc}, {0x5847 ,0x0c },
{0x5848, 0xd}, {0x5848 ,0x0d },
{0x5849, 0xe}, {0x5849 ,0x0e },
{0x584a, 0xe}, {0x584a ,0x0e },
{0x584b, 0xa}, {0x584b ,0x0a },
{0x584c, 0xe}, {0x584c ,0x0e },
{0x584d, 0xe}, {0x584d ,0x0e },
{0x584e ,0x10}, {0x584e ,0x10},
{0x584f ,0x10}, {0x584f ,0x10},
{0x5850 ,0x11}, {0x5850 ,0x11},
{0x5851, 0xa}, {0x5851 ,0x0a },
{0x5852, 0xf}, {0x5852 ,0x0f },
{0x5853, 0xe}, {0x5853 ,0x0e },
{0x5854 ,0x10}, {0x5854 ,0x10},
{0x5855 ,0x10}, {0x5855 ,0x10},
{0x5856 ,0x10}, {0x5856 ,0x10},
{0x5857, 0xa}, {0x5857 ,0x0a },
{0x5858, 0xe}, {0x5858 ,0x0e },
{0x5859, 0xe}, {0x5859 ,0x0e },
{0x585a, 0xf}, {0x585a ,0x0f },
{0x585b, 0xf}, {0x585b ,0x0f },
{0x585c, 0xf}, {0x585c ,0x0f },
{0x585d, 0xa}, {0x585d ,0x0a },
{0x585e, 0x9}, {0x585e ,0x09 },
{0x585f, 0xd}, {0x585f ,0x0d },
{0x5860, 0xc}, {0x5860 ,0x0c },
{0x5861, 0xb}, {0x5861 ,0x0b },
{0x5862, 0xd}, {0x5862 ,0x0d },
{0x5863, 0x7}, {0x5863 ,0x07 },
{0x5864 ,0x17}, {0x5864 ,0x17},
{0x5865 ,0x14}, {0x5865 ,0x14},
{0x5866 ,0x18}, {0x5866 ,0x18},
@ -720,7 +688,7 @@ static const struct sensor_reg OV5642_QVGA_Preview[] =
{0x5870 ,0x1c}, {0x5870 ,0x1c},
{0x5871 ,0x16}, {0x5871 ,0x16},
{0x5872 ,0x10}, {0x5872 ,0x10},
{0x5873, 0xf}, {0x5873 ,0x0f },
{0x5874 ,0x13}, {0x5874 ,0x13},
{0x5875 ,0x1c}, {0x5875 ,0x1c},
{0x5876 ,0x1e}, {0x5876 ,0x1e},
@ -922,9 +890,12 @@ static const struct sensor_reg OV5642_QVGA_Preview[] =
{0x568e ,0xaa}, {0x568e ,0xaa},
{0x568f ,0xaa}, {0x568f ,0xaa},
{0xffff,0xff}, {0xffff,0xff},
}; };
static const struct sensor_reg OV5642_JPEG_Capture_QSXGA[] = static const struct sensor_reg OV5642_JPEG_Capture_QSXGA[] =
{ {
// OV5642_ QSXGA _YUV7.5 fps // OV5642_ QSXGA _YUV7.5 fps
@ -1006,7 +977,6 @@ static const struct sensor_reg OV5642_JPEG_Capture_QSXGA[] =
{0x3a11, 0x70}, {0x3a11, 0x70},
{0x3a1f, 0x20}, {0x3a1f, 0x20},
{0xffff, 0xff}, {0xffff, 0xff},
}; };
static const struct sensor_reg OV5642_1080P_Video_setting[] = static const struct sensor_reg OV5642_1080P_Video_setting[] =

@ -86,7 +86,7 @@ void Error_Handler(void);
#define LD3_GPIO_Port GPIOB #define LD3_GPIO_Port GPIOB
/* USER CODE BEGIN Private defines */ /* USER CODE BEGIN Private defines */
#define CDC_BUFF_SIZE 10048 #define CDC_BUFF_SIZE 12800
#define CDC_FRAME_SIZE 64 #define CDC_FRAME_SIZE 64
#define CDC_FRAME_DELAY 1 #define CDC_FRAME_DELAY 1
/* USER CODE END Private defines */ /* USER CODE END Private defines */

@ -73,151 +73,7 @@ static void MX_USB_PCD_Init(void);
/* Private user code ---------------------------------------------------------*/ /* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */ /* USER CODE BEGIN 0 */
/*
static unsigned frame_num = 0;
static unsigned tx_busy = 0;
static unsigned interval_ms = 1000 / FRAME_RATE;
static struct {
uint32_t size;
uint8_t const *buffer;
} const frames[] = {
{color_bar_0_jpg_len, color_bar_0_jpg},
{color_bar_1_jpg_len, color_bar_1_jpg},
{color_bar_2_jpg_len, color_bar_2_jpg},
{color_bar_3_jpg_len, color_bar_3_jpg},
{color_bar_4_jpg_len, color_bar_4_jpg},
{color_bar_5_jpg_len, color_bar_5_jpg},
{color_bar_6_jpg_len, color_bar_6_jpg},
{color_bar_7_jpg_len, color_bar_7_jpg},
};
*/
/*
void cdc_task(void)
{
// connected() check for DTR bit
// Most but not all terminal client set this when making connection
// if ( tud_cdc_connected() )
{
// connected and there are data available
if (tud_cdc_available())
{
// read data
char buf[64];
uint32_t count = tud_cdc_read(buf, sizeof(buf));
(void)count;
//char buf_2[10] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
//uint32_t count_2 = 10;
// Echo back
// Note: Skip echo by commenting out write() and write_flush()
// for throughput test e.g
// $ dd if=/dev/zero of=/dev/ttyACM0 count=10000
tud_cdc_write(buf, count);
//tud_cdc_n_write(10, buf_2, count_2);
tud_cdc_write_flush();
}
}
}
*/
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,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xdb, 0x00, 0x43, 0x01, 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, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x00, 0x11,
0x08, 0x00, 0x60, 0x00, 0x80, 0x03, 0x01, 0x21, 0x00, 0x02, 0x11, 0x01, 0x03, 0x11, 0x01, 0xff,
0xda, 0x00, 0x0c, 0x03, 0x01, 0x00, 0x02, 0x11, 0x03, 0x11, 0x00, 0x3f, 0x00, 0x92, 0x8a, 0x00,
0x4a, 0x2b, 0x31, 0x89, 0x45, 0x6a, 0x64, 0x25, 0x15, 0x98, 0xc6, 0xd1, 0x5b, 0x1b, 0x09, 0x45,
0x66, 0x31, 0x28, 0xad, 0x4c, 0x84, 0xa2, 0xb3, 0x19, 0x62, 0x8a, 0x00, 0x4a, 0x2b, 0x31, 0x89,
0x45, 0x6a, 0x64, 0x25, 0x15, 0x98, 0xc6, 0xd1, 0x5b, 0x1b, 0x09, 0x45, 0x66, 0x31, 0x28, 0xad,
0x4c, 0x84, 0xa2, 0xb3, 0x19, 0x62, 0x8a, 0x00, 0x4a, 0x2b, 0x31, 0x89, 0x45, 0x6a, 0x64, 0x25,
0x15, 0x98, 0xc6, 0xd1, 0x5b, 0x1b, 0x09, 0x45, 0x66, 0x31, 0x28, 0xad, 0x4c, 0x84, 0xa2, 0xb3,
0x19, 0x62, 0x8a, 0x00, 0x4a, 0x2b, 0x31, 0x89, 0x45, 0x6a, 0x64, 0x25, 0x15, 0x98, 0xc6, 0xd1,
0x5b, 0x1b, 0x09, 0x45, 0x66, 0x31, 0x28, 0xad, 0x4c, 0x84, 0xa2, 0xb3, 0x19, 0x62, 0x8a, 0x00,
0x4a, 0x2b, 0x31, 0x89, 0x45, 0x6a, 0x64, 0x25, 0x15, 0x98, 0xc6, 0xd1, 0x5b, 0x1b, 0x09, 0x45,
0x66, 0x31, 0x28, 0xad, 0x4c, 0x84, 0xa2, 0xb3, 0x19, 0x62, 0x8a, 0x00, 0x4a, 0x2b, 0x31, 0x89,
0x45, 0x6a, 0x64, 0x25, 0x15, 0x98, 0xc6, 0xd1, 0x5b, 0x1b, 0x09, 0x45, 0x66, 0x31, 0x28, 0xad,
0x4c, 0x84, 0xa2, 0xb3, 0x19, 0x62, 0x8a, 0x00, 0x4a, 0x2b, 0x31, 0x89, 0x45, 0x6a, 0x64, 0x25,
0x15, 0x98, 0xc6, 0xd1, 0x5b, 0x1b, 0x09, 0x45, 0x66, 0x31, 0x28, 0xad, 0x4c, 0x84, 0xa2, 0xb3,
0x19, 0x62, 0x8a, 0x00, 0x4a, 0x2b, 0x31, 0x89, 0x45, 0x6a, 0x64, 0x25, 0x15, 0x98, 0xc6, 0xd1,
0x5b, 0x1b, 0x09, 0x45, 0x66, 0x31, 0x28, 0xad, 0x4c, 0x84, 0xa2, 0xb3, 0x19, 0x62, 0x8a, 0x00,
0x4a, 0x2b, 0x31, 0x89, 0x45, 0x6a, 0x64, 0x25, 0x15, 0x98, 0xc6, 0xd1, 0x5b, 0x1b, 0x09, 0x45,
0x66, 0x31, 0x28, 0xad, 0x4c, 0x84, 0xa2, 0xb3, 0x19, 0x62, 0x8a, 0x00, 0x4a, 0x2b, 0x31, 0x89,
0x45, 0x6a, 0x64, 0x25, 0x15, 0x98, 0xc6, 0xd1, 0x5b, 0x1b, 0x09, 0x45, 0x66, 0x31, 0x28, 0xad,
0x4c, 0x84, 0xa2, 0xb3, 0x19, 0x62, 0x8a, 0x00, 0x4a, 0x2b, 0x31, 0x89, 0x45, 0x6a, 0x64, 0x25,
0x15, 0x98, 0xc6, 0xd1, 0x5b, 0x1b, 0x09, 0x45, 0x66, 0x31, 0x28, 0xad, 0x4c, 0x84, 0xa2, 0xb3,
0x19, 0x62, 0x8a, 0x00, 0x4a, 0x2b, 0x31, 0x89, 0x45, 0x6a, 0x64, 0x25, 0x15, 0x98, 0xc6, 0xd1,
0x5b, 0x1b, 0x09, 0x45, 0x66, 0x31, 0x28, 0xad, 0x4c, 0x84, 0xa2, 0xb3, 0x19, 0xff, 0xd9, 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, 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
};
/*
int currentIdx = 0;
int currentImg = 0;
int send_CDC_Bulk(){
if(currentIdx + 10 > 530){
currentIdx = 0;
currentImg++;
currentImg %=8;
}
switch(currentImg){
case 0:
tud_cdc_write(&color_bar_0_jpg[currentIdx], 10);
break;
case 1:
tud_cdc_write(&color_bar_1_jpg[currentIdx], 10);
break;
case 2:
tud_cdc_write(&color_bar_2_jpg[currentIdx], 10);
break;
case 3:
tud_cdc_write(&color_bar_3_jpg[currentIdx], 10);
break;
case 4:
tud_cdc_write(&color_bar_4_jpg[currentIdx], 10);
break;
case 5:
tud_cdc_write(&color_bar_5_jpg[currentIdx], 10);
break;
case 6:
tud_cdc_write(&color_bar_6_jpg[currentIdx], 10);
break;
case 7:
tud_cdc_write(&color_bar_7_jpg[currentIdx], 10);
break;
default:
break;
}
//tud_cdc_write(&sendT[currentIdx], 10);
tud_cdc_write_flush();
currentIdx = currentIdx + 10;
return 1;
}
*/
void SysTick_Init(void) void SysTick_Init(void)
{ {
SysTick_Config(SystemCoreClock / 10000); // Set SysTick interrupt to occur every 100us SysTick_Config(SystemCoreClock / 10000); // Set SysTick interrupt to occur every 100us
@ -311,7 +167,8 @@ int main(void)
tud_task(); tud_task();
Cam_Refresh(&hi2c1, &hspi1); //Cam_Refresh(&hi2c1, &hspi1);
//Cam_Init(&hi2c1, &hspi1);
tud_task(); tud_task();
@ -326,7 +183,6 @@ int main(void)
continue; continue;
//HAL_SPI_Receive(&hspi1, cdc_buff, CDC_BUFF_SIZE, HAL_MAX_DELAY);
} }
else { else {
int number_to_read = 0; int number_to_read = 0;
@ -346,13 +202,19 @@ int main(void)
int current_sending_idx = 0; int current_sending_idx = 0;
do{ do{
tud_task(); tud_task();
tud_cdc_write(&cdc_buff[current_sending_idx], CDC_FRAME_SIZE); int sendLen = CDC_FRAME_SIZE;
current_sending_idx = current_sending_idx + CDC_FRAME_SIZE; if(last_sent_idx + CDC_FRAME_SIZE > buff_stop_idx){
last_sent_idx = last_sent_idx + CDC_FRAME_SIZE; sendLen = buff_stop_idx - last_sent_idx;
}
tud_cdc_write(&cdc_buff[current_sending_idx], sendLen);
current_sending_idx = current_sending_idx + sendLen;
last_sent_idx = last_sent_idx + sendLen;
tud_cdc_write_flush(); tud_cdc_write_flush();
//Delay between sends //Delay between sends
int i = 0; int i = 0;
for(;i<4000;i++); for(;i<7000;i++);
} }
while(last_sent_idx < buff_stop_idx); while(last_sent_idx < buff_stop_idx);

Loading…
Cancel
Save