mirror of
https://github.com/aprochazka/ProfilometerProbe.git
synced 2025-06-30 17:47:20 +02:00
Auto config, no need to init before each capture, 320x240 cca 5fps
This commit is contained in:
@ -73,151 +73,7 @@ static void MX_USB_PCD_Init(void);
|
||||
|
||||
/* Private user code ---------------------------------------------------------*/
|
||||
/* 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)
|
||||
{
|
||||
SysTick_Config(SystemCoreClock / 10000); // Set SysTick interrupt to occur every 100us
|
||||
@ -311,8 +167,9 @@ int main(void)
|
||||
|
||||
tud_task();
|
||||
|
||||
Cam_Refresh(&hi2c1, &hspi1);
|
||||
|
||||
//Cam_Refresh(&hi2c1, &hspi1);
|
||||
//Cam_Init(&hi2c1, &hspi1);
|
||||
|
||||
tud_task();
|
||||
|
||||
Cam_Capture(&hspi1);
|
||||
@ -326,7 +183,6 @@ int main(void)
|
||||
|
||||
continue;
|
||||
|
||||
//HAL_SPI_Receive(&hspi1, cdc_buff, CDC_BUFF_SIZE, HAL_MAX_DELAY);
|
||||
}
|
||||
else {
|
||||
int number_to_read = 0;
|
||||
@ -346,13 +202,19 @@ int main(void)
|
||||
int current_sending_idx = 0;
|
||||
do{
|
||||
tud_task();
|
||||
tud_cdc_write(&cdc_buff[current_sending_idx], CDC_FRAME_SIZE);
|
||||
current_sending_idx = current_sending_idx + CDC_FRAME_SIZE;
|
||||
last_sent_idx = last_sent_idx + CDC_FRAME_SIZE;
|
||||
int sendLen = CDC_FRAME_SIZE;
|
||||
if(last_sent_idx + CDC_FRAME_SIZE > buff_stop_idx){
|
||||
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();
|
||||
//Delay between sends
|
||||
int i = 0;
|
||||
for(;i<4000;i++);
|
||||
for(;i<7000;i++);
|
||||
}
|
||||
while(last_sent_idx < buff_stop_idx);
|
||||
|
||||
|
Reference in New Issue
Block a user