mirror of
https://github.com/aprochazka/ProfilometerProbe.git
synced 2025-07-22 04:07:25 +02:00
720p resolution
This commit is contained in:
50
.vscode/settings.json
vendored
Normal file
50
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
{
|
||||||
|
"files.associations": {
|
||||||
|
"chrono": "cpp",
|
||||||
|
"array": "cpp",
|
||||||
|
"atomic": "cpp",
|
||||||
|
"*.tcc": "cpp",
|
||||||
|
"cctype": "cpp",
|
||||||
|
"clocale": "cpp",
|
||||||
|
"cmath": "cpp",
|
||||||
|
"compare": "cpp",
|
||||||
|
"concepts": "cpp",
|
||||||
|
"condition_variable": "cpp",
|
||||||
|
"cstdint": "cpp",
|
||||||
|
"cstdio": "cpp",
|
||||||
|
"cstdlib": "cpp",
|
||||||
|
"cstring": "cpp",
|
||||||
|
"ctime": "cpp",
|
||||||
|
"cwchar": "cpp",
|
||||||
|
"cwctype": "cpp",
|
||||||
|
"map": "cpp",
|
||||||
|
"vector": "cpp",
|
||||||
|
"exception": "cpp",
|
||||||
|
"initializer_list": "cpp",
|
||||||
|
"iomanip": "cpp",
|
||||||
|
"iosfwd": "cpp",
|
||||||
|
"iostream": "cpp",
|
||||||
|
"istream": "cpp",
|
||||||
|
"limits": "cpp",
|
||||||
|
"mutex": "cpp",
|
||||||
|
"new": "cpp",
|
||||||
|
"numbers": "cpp",
|
||||||
|
"ostream": "cpp",
|
||||||
|
"ratio": "cpp",
|
||||||
|
"semaphore": "cpp",
|
||||||
|
"sstream": "cpp",
|
||||||
|
"stdexcept": "cpp",
|
||||||
|
"stop_token": "cpp",
|
||||||
|
"streambuf": "cpp",
|
||||||
|
"string": "cpp",
|
||||||
|
"string_view": "cpp",
|
||||||
|
"system_error": "cpp",
|
||||||
|
"thread": "cpp",
|
||||||
|
"tuple": "cpp",
|
||||||
|
"type_traits": "cpp",
|
||||||
|
"typeinfo": "cpp",
|
||||||
|
"utility": "cpp",
|
||||||
|
"fstream": "cpp"
|
||||||
|
},
|
||||||
|
"cmake.sourceDirectory": "${workspaceFolder}/Firmware"
|
||||||
|
}
|
File diff suppressed because one or more lines are too long
@ -120,75 +120,43 @@ 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_SPI_write(hspi, 0x07, 0x80);
|
Cam_SPI_write(hspi, 0x07, 0x80);
|
||||||
HAL_Delay(100);
|
HAL_Delay(100);
|
||||||
Cam_SPI_write(hspi, 0x07, 0x00);
|
Cam_SPI_write(hspi, 0x07, 0x00);
|
||||||
HAL_Delay(100);
|
HAL_Delay(100);
|
||||||
|
|
||||||
//Cam_SPI_write(hspi, 0x00, 0x55);
|
|
||||||
HAL_Delay(5);
|
|
||||||
Cam_I2C_write(hi2c, (uint16_t)0x3008, 0x80);
|
Cam_I2C_write(hi2c, (uint16_t)0x3008, 0x80);
|
||||||
HAL_Delay(5);
|
|
||||||
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_320x240);
|
|
||||||
HAL_Delay(100);
|
|
||||||
//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)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)0x4407, 0x04); // COMPRESSION CONTROL
|
|
||||||
//Cam_I2C_write(hi2c, (uint16_t)0x5000, 0xFF);
|
|
||||||
HAL_Delay(5);
|
|
||||||
// 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);
|
|
||||||
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
|
|
||||||
HAL_Delay(5);
|
HAL_Delay(5);
|
||||||
/*
|
|
||||||
Cam_I2C_write(hi2c, (uint16_t)0x3008, 0x80);
|
|
||||||
|
|
||||||
Cam_I2C_write_bulk(hi2c, OV5642_QVGA_Preview);
|
Cam_I2C_write_bulk(hi2c, OV5642_QVGA_Preview);
|
||||||
|
HAL_Delay(200);
|
||||||
HAL_Delay(100);
|
|
||||||
|
|
||||||
Cam_I2C_write_bulk(hi2c, OV5642_JPEG_Capture_QSXGA);
|
Cam_I2C_write_bulk(hi2c, OV5642_JPEG_Capture_QSXGA);
|
||||||
|
Cam_I2C_write_bulk(hi2c, ov5642_1024x768);
|
||||||
|
|
||||||
//Cam_I2C_write_bulk(hi2c, ov5642_320x240);
|
//Cam_I2C_write_bulk(hi2c, ov5642_320x240);
|
||||||
|
|
||||||
HAL_Delay(100);
|
HAL_Delay(100);
|
||||||
|
|
||||||
//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, 0x09); // COMPRESSION CONTROL
|
||||||
Cam_I2C_write(hi2c, (uint16_t)0x4407, 0x04); // COMPRESSION CONTROL
|
|
||||||
//Cam_I2C_write(hi2c, (uint16_t)0x5888, 0x01);
|
|
||||||
Cam_I2C_write(hi2c, (uint16_t)0x5000, 0xFF);
|
|
||||||
|
|
||||||
|
|
||||||
|
HAL_Delay(5);
|
||||||
// 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);
|
||||||
|
|
||||||
Cam_I2C_write_bulk(hi2c, ov5642_320x240);
|
|
||||||
//Cam_I2C_write_bulk(hi2c, ov5642_1024x768);
|
|
||||||
|
|
||||||
|
|
||||||
Cam_SPI_write(hspi, 0x04, 0x01);
|
|
||||||
|
|
||||||
Cam_SPI_write(hspi, 0x01, 0x00); // Capture Control Register - Set to capture n+1 frames
|
|
||||||
|
|
||||||
HAL_Delay(5);
|
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
|
||||||
|
|
||||||
|
HAL_Delay(5);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Cam_Refresh(I2C_HandleTypeDef *hi2c, SPI_HandleTypeDef *hspi){
|
void Cam_Refresh(I2C_HandleTypeDef *hi2c, SPI_HandleTypeDef *hspi){
|
||||||
@ -294,7 +262,7 @@ int Cam_FIFO_length(SPI_HandleTypeDef *hspi)
|
|||||||
uint32_t len1, len2, len3, len = 0;
|
uint32_t len1, len2, len3, len = 0;
|
||||||
len1 = Cam_SPI_read(hspi, 0x42);
|
len1 = Cam_SPI_read(hspi, 0x42);
|
||||||
len2 = Cam_SPI_read(hspi, 0x43);
|
len2 = Cam_SPI_read(hspi, 0x43);
|
||||||
len3 = Cam_SPI_read(hspi, 0x44) & 0x7f;
|
len3 = Cam_SPI_read(hspi, 0x44)& 0x7f;
|
||||||
len = ((len3 << 16) | (len2 << 8) | len1) & 0x07fffff;
|
len = ((len3 << 16) | (len2 << 8) | len1) & 0x07fffff;
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -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 12800
|
#define CDC_BUFF_SIZE 51200
|
||||||
#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,20 +73,6 @@ static void MX_USB_PCD_Init(void);
|
|||||||
|
|
||||||
/* Private user code ---------------------------------------------------------*/
|
/* Private user code ---------------------------------------------------------*/
|
||||||
/* USER CODE BEGIN 0 */
|
/* USER CODE BEGIN 0 */
|
||||||
|
|
||||||
void SysTick_Init(void)
|
|
||||||
{
|
|
||||||
SysTick_Config(SystemCoreClock / 10000); // Set SysTick interrupt to occur every 100us
|
|
||||||
}
|
|
||||||
|
|
||||||
void delay_us(uint32_t us)
|
|
||||||
{
|
|
||||||
uint32_t start = SysTick->VAL;
|
|
||||||
uint32_t ticks = us * 10;
|
|
||||||
|
|
||||||
while ((start - SysTick->VAL) < ticks);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* USER CODE END 0 */
|
/* USER CODE END 0 */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -96,7 +82,6 @@ void delay_us(uint32_t us)
|
|||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
/* USER CODE BEGIN 1 */
|
/* USER CODE BEGIN 1 */
|
||||||
LED_On();
|
|
||||||
/* USER CODE END 1 */
|
/* USER CODE END 1 */
|
||||||
|
|
||||||
/* MCU Configuration--------------------------------------------------------*/
|
/* MCU Configuration--------------------------------------------------------*/
|
||||||
@ -124,24 +109,24 @@ int main(void)
|
|||||||
MX_I2C1_Init();
|
MX_I2C1_Init();
|
||||||
MX_USB_PCD_Init();
|
MX_USB_PCD_Init();
|
||||||
/* USER CODE BEGIN 2 */
|
/* USER CODE BEGIN 2 */
|
||||||
//MX_DAC1_Init();
|
LED_On();
|
||||||
//MX_TIM15_Init();
|
|
||||||
HAL_PWREx_EnableVddUSB();
|
HAL_PWREx_EnableVddUSB();
|
||||||
HAL_Delay(1);
|
HAL_Delay(1);
|
||||||
|
|
||||||
tud_init(BOARD_DEVICE_RHPORT_NUM);
|
tud_init(BOARD_DEVICE_RHPORT_NUM);
|
||||||
|
|
||||||
HAL_Delay(10);
|
HAL_Delay(10);
|
||||||
SPI_Init(&hspi1);
|
SPI_Init(&hspi1);
|
||||||
|
|
||||||
// Wait for power stabilization
|
|
||||||
//HAL_Delay(1000);
|
|
||||||
|
|
||||||
tud_task();
|
tud_task();
|
||||||
|
|
||||||
int last_sent_idx = 0;
|
int last_sent_idx = 0;
|
||||||
int buff_stop_idx = 0;
|
int buff_stop_idx = 0;
|
||||||
uint16_t image_size = 0;
|
uint16_t image_size = 0;
|
||||||
uint8_t cdc_buff[CDC_BUFF_SIZE];
|
uint8_t cdc_buff[CDC_BUFF_SIZE+CDC_FRAME_SIZE];
|
||||||
|
for(int i = 0; i < (CDC_BUFF_SIZE+CDC_FRAME_SIZE); i++) cdc_buff[i] = 0x00;
|
||||||
|
|
||||||
|
|
||||||
Cam_Init(&hi2c1, &hspi1);
|
Cam_Init(&hi2c1, &hspi1);
|
||||||
|
|
||||||
@ -160,22 +145,13 @@ int main(void)
|
|||||||
buff_stop_idx = 0;
|
buff_stop_idx = 0;
|
||||||
last_sent_idx = 0;
|
last_sent_idx = 0;
|
||||||
|
|
||||||
for(int i = 0; i < CDC_BUFF_SIZE; i++) cdc_buff[i] = 0x00;
|
//for(int i = 0; i < CDC_BUFF_SIZE; i++) cdc_buff[i] = 0x00;
|
||||||
|
|
||||||
CS_Off();
|
CS_Off();
|
||||||
CS_On();
|
CS_On();
|
||||||
|
|
||||||
tud_task();
|
|
||||||
|
|
||||||
//Cam_Refresh(&hi2c1, &hspi1);
|
|
||||||
//Cam_Init(&hi2c1, &hspi1);
|
|
||||||
|
|
||||||
tud_task();
|
|
||||||
|
|
||||||
Cam_Capture(&hspi1);
|
Cam_Capture(&hspi1);
|
||||||
|
|
||||||
tud_task();
|
|
||||||
|
|
||||||
image_size = Cam_FIFO_length(&hspi1);
|
image_size = Cam_FIFO_length(&hspi1);
|
||||||
Cam_Start_Burst_Read(&hspi1);
|
Cam_Start_Burst_Read(&hspi1);
|
||||||
|
|
||||||
@ -185,8 +161,10 @@ int main(void)
|
|||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
LED_Off();
|
||||||
|
|
||||||
int number_to_read = 0;
|
int number_to_read = 0;
|
||||||
for(int i = 0; i < CDC_BUFF_SIZE; i++) cdc_buff[i] = 0x00;
|
//for(int i = 0; i < CDC_BUFF_SIZE; i++) cdc_buff[i] = 0x00;
|
||||||
if((buff_stop_idx + CDC_BUFF_SIZE) > (int) image_size){
|
if((buff_stop_idx + CDC_BUFF_SIZE) > (int) image_size){
|
||||||
number_to_read = (int) image_size - buff_stop_idx;
|
number_to_read = (int) image_size - buff_stop_idx;
|
||||||
}
|
}
|
||||||
@ -197,6 +175,8 @@ int main(void)
|
|||||||
HAL_SPI_Receive(&hspi1, cdc_buff, number_to_read, HAL_MAX_DELAY);
|
HAL_SPI_Receive(&hspi1, cdc_buff, number_to_read, HAL_MAX_DELAY);
|
||||||
|
|
||||||
buff_stop_idx = buff_stop_idx + number_to_read;
|
buff_stop_idx = buff_stop_idx + number_to_read;
|
||||||
|
|
||||||
|
LED_On();
|
||||||
}
|
}
|
||||||
|
|
||||||
int current_sending_idx = 0;
|
int current_sending_idx = 0;
|
||||||
@ -214,12 +194,10 @@ int main(void)
|
|||||||
tud_cdc_write_flush();
|
tud_cdc_write_flush();
|
||||||
//Delay between sends
|
//Delay between sends
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for(;i<7000;i++);
|
for(;i<4000;i++);
|
||||||
}
|
}
|
||||||
while(last_sent_idx < buff_stop_idx);
|
while(last_sent_idx < buff_stop_idx);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* USER CODE END WHILE */
|
/* USER CODE END WHILE */
|
||||||
|
|
||||||
/* USER CODE BEGIN 3 */
|
/* USER CODE BEGIN 3 */
|
||||||
|
63
Receiver/.vscode/settings.json
vendored
Normal file
63
Receiver/.vscode/settings.json
vendored
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
{
|
||||||
|
"files.associations": {
|
||||||
|
"thread": "cpp",
|
||||||
|
"chrono": "cpp",
|
||||||
|
"ostream": "cpp",
|
||||||
|
"array": "cpp",
|
||||||
|
"atomic": "cpp",
|
||||||
|
"bit": "cpp",
|
||||||
|
"*.tcc": "cpp",
|
||||||
|
"cctype": "cpp",
|
||||||
|
"clocale": "cpp",
|
||||||
|
"cmath": "cpp",
|
||||||
|
"compare": "cpp",
|
||||||
|
"concepts": "cpp",
|
||||||
|
"condition_variable": "cpp",
|
||||||
|
"cstdarg": "cpp",
|
||||||
|
"cstddef": "cpp",
|
||||||
|
"cstdint": "cpp",
|
||||||
|
"cstdio": "cpp",
|
||||||
|
"cstdlib": "cpp",
|
||||||
|
"cstring": "cpp",
|
||||||
|
"ctime": "cpp",
|
||||||
|
"cwchar": "cpp",
|
||||||
|
"cwctype": "cpp",
|
||||||
|
"deque": "cpp",
|
||||||
|
"map": "cpp",
|
||||||
|
"string": "cpp",
|
||||||
|
"unordered_map": "cpp",
|
||||||
|
"vector": "cpp",
|
||||||
|
"exception": "cpp",
|
||||||
|
"algorithm": "cpp",
|
||||||
|
"functional": "cpp",
|
||||||
|
"iterator": "cpp",
|
||||||
|
"memory": "cpp",
|
||||||
|
"memory_resource": "cpp",
|
||||||
|
"numeric": "cpp",
|
||||||
|
"optional": "cpp",
|
||||||
|
"random": "cpp",
|
||||||
|
"ratio": "cpp",
|
||||||
|
"string_view": "cpp",
|
||||||
|
"system_error": "cpp",
|
||||||
|
"tuple": "cpp",
|
||||||
|
"type_traits": "cpp",
|
||||||
|
"utility": "cpp",
|
||||||
|
"initializer_list": "cpp",
|
||||||
|
"iomanip": "cpp",
|
||||||
|
"iosfwd": "cpp",
|
||||||
|
"iostream": "cpp",
|
||||||
|
"istream": "cpp",
|
||||||
|
"limits": "cpp",
|
||||||
|
"mutex": "cpp",
|
||||||
|
"new": "cpp",
|
||||||
|
"numbers": "cpp",
|
||||||
|
"ranges": "cpp",
|
||||||
|
"semaphore": "cpp",
|
||||||
|
"sstream": "cpp",
|
||||||
|
"stdexcept": "cpp",
|
||||||
|
"stop_token": "cpp",
|
||||||
|
"streambuf": "cpp",
|
||||||
|
"cinttypes": "cpp",
|
||||||
|
"typeinfo": "cpp"
|
||||||
|
}
|
||||||
|
}
|
BIN
Receiver/Displayer.o
Normal file
BIN
Receiver/Displayer.o
Normal file
Binary file not shown.
@ -11,7 +11,7 @@ void Receiver::printHex(unsigned char value) {
|
|||||||
void Receiver::openStream(){
|
void Receiver::openStream(){
|
||||||
while(1){
|
while(1){
|
||||||
// Open the CDC device file for reading
|
// Open the CDC device file for reading
|
||||||
cdcFile = open("/dev/ttyACM1", O_RDWR | O_NOCTTY);
|
cdcFile = open("/dev/ttyACM0", O_RDWR | O_NOCTTY);
|
||||||
if(cdcFile == -1){
|
if(cdcFile == -1){
|
||||||
std::cerr << "Failed to open CDC device file" << std::endl;
|
std::cerr << "Failed to open CDC device file" << std::endl;
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||||
|
BIN
Receiver/Receiver.o
Normal file
BIN
Receiver/Receiver.o
Normal file
Binary file not shown.
BIN
Receiver/main
Executable file
BIN
Receiver/main
Executable file
Binary file not shown.
BIN
Receiver/main.o
Normal file
BIN
Receiver/main.o
Normal file
Binary file not shown.
33720
Receiver/out.txt
Normal file
33720
Receiver/out.txt
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user