mirror of
https://github.com/aprochazka/ProfilometerProbe.git
synced 2025-07-22 12:17:24 +02:00
More optimalizations and multithreading - 1FPS
This commit is contained in:
@ -132,9 +132,66 @@ void Cam_Init(I2C_HandleTypeDef *hi2c, SPI_HandleTypeDef *hspi)
|
|||||||
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_bulk(hi2c, ov5642_1024x768);
|
||||||
|
|
||||||
|
// 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, 0x01, 0x00); // Capture Control Register - Set to capture n+1 frames
|
||||||
|
|
||||||
|
HAL_Delay(5);
|
||||||
|
/*
|
||||||
|
Cam_I2C_write(hi2c, (uint16_t)0x3008, 0x80);
|
||||||
|
|
||||||
|
Cam_I2C_write_bulk(hi2c, OV5642_QVGA_Preview);
|
||||||
|
|
||||||
|
HAL_Delay(100);
|
||||||
|
|
||||||
|
Cam_I2C_write_bulk(hi2c, OV5642_JPEG_Capture_QSXGA);
|
||||||
|
|
||||||
//Cam_I2C_write_bulk(hi2c, ov5642_320x240);
|
//Cam_I2C_write_bulk(hi2c, ov5642_320x240);
|
||||||
//Cam_I2C_write_bulk(hi2c, ov5642_640x480);
|
|
||||||
|
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)0x4407, 0x04); // COMPRESSION CONTROL
|
||||||
|
//Cam_I2C_write(hi2c, (uint16_t)0x5888, 0x01);
|
||||||
|
Cam_I2C_write(hi2c, (uint16_t)0x5000, 0xFF);
|
||||||
|
|
||||||
|
|
||||||
|
// 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_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);
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
void Cam_Refresh(I2C_HandleTypeDef *hi2c, SPI_HandleTypeDef *hspi){
|
||||||
|
/*Cam_I2C_write(hi2c, (uint16_t)0x3008, 0x80);
|
||||||
|
|
||||||
|
Cam_I2C_write_bulk(hi2c, OV5642_QVGA_Preview);
|
||||||
|
|
||||||
|
Cam_I2C_write_bulk(hi2c, OV5642_JPEG_Capture_QSXGA);
|
||||||
|
|
||||||
|
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_bulk(hi2c, ov5642_1280x960);
|
Cam_I2C_write_bulk(hi2c, ov5642_1280x960);
|
||||||
|
|
||||||
@ -142,29 +199,82 @@ void Cam_Init(I2C_HandleTypeDef *hi2c, SPI_HandleTypeDef *hspi)
|
|||||||
Cam_SPI_write(hspi, 0x03, 0x02);
|
Cam_SPI_write(hspi, 0x03, 0x02);
|
||||||
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);*/
|
||||||
}
|
|
||||||
|
|
||||||
void Cam_Refresh(I2C_HandleTypeDef *hi2c, SPI_HandleTypeDef *hspi){
|
|
||||||
Cam_I2C_write(hi2c, (uint16_t)0x3008, 0x80);
|
|
||||||
|
|
||||||
|
// SAFE TO REMOVE
|
||||||
|
//Cam_I2C_write(hi2c, (uint16_t)0x3008, 0x80);
|
||||||
|
|
||||||
Cam_I2C_write_bulk(hi2c, OV5642_QVGA_Preview);
|
Cam_I2C_write_bulk(hi2c, OV5642_QVGA_Preview);
|
||||||
|
|
||||||
Cam_I2C_write_bulk(hi2c, OV5642_JPEG_Capture_QSXGA);
|
Cam_I2C_write_bulk(hi2c, OV5642_JPEG_Capture_QSXGA);
|
||||||
|
|
||||||
//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_bulk(hi2c, ov5642_320x240);
|
|
||||||
//ov5642_1024x768
|
|
||||||
Cam_I2C_write_bulk(hi2c, ov5642_1024x768);
|
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);
|
||||||
|
|
||||||
|
|
||||||
|
// Brightness 4
|
||||||
|
Cam_I2C_write(hi2c, (uint16_t)0x5001, 0xff);
|
||||||
|
Cam_I2C_write(hi2c, (uint16_t)0x5589, 0x30);
|
||||||
|
Cam_I2C_write(hi2c, (uint16_t)0x5580, 0x04);
|
||||||
|
Cam_I2C_write(hi2c, (uint16_t)0x558a, 0x00);
|
||||||
|
//Cam_I2C_write(hi2c, (uint16_t)0x558a, 0x08);
|
||||||
|
|
||||||
|
//Contrast 0
|
||||||
|
//Cam_I2C_write(hi2c, (uint16_t)0x5587, 0xff);
|
||||||
|
//Cam_I2C_write(hi2c, (uint16_t)0x5588, 0xff);
|
||||||
|
|
||||||
|
/*
|
||||||
|
// Exposure _17
|
||||||
|
Cam_I2C_write(hi2c, (uint16_t)0x3a0f, 0x10);
|
||||||
|
Cam_I2C_write(hi2c, (uint16_t)0x3a10, 0x08);
|
||||||
|
Cam_I2C_write(hi2c, (uint16_t)0x3a1b, 0x10);
|
||||||
|
Cam_I2C_write(hi2c, (uint16_t)0x3a1e, 0x08);
|
||||||
|
Cam_I2C_write(hi2c, (uint16_t)0x3a11, 0x20);
|
||||||
|
Cam_I2C_write(hi2c, (uint16_t)0x3a1f, 0x10);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//Exposure 17 v2
|
||||||
|
Cam_I2C_write(hi2c, (uint16_t)0x3a0f, 0x60);
|
||||||
|
Cam_I2C_write(hi2c, (uint16_t)0x3a10, 0x58);
|
||||||
|
Cam_I2C_write(hi2c, (uint16_t)0x3a11, 0xa0);
|
||||||
|
Cam_I2C_write(hi2c, (uint16_t)0x3a1b, 0x60);
|
||||||
|
Cam_I2C_write(hi2c, (uint16_t)0x3a1e, 0x58);
|
||||||
|
Cam_I2C_write(hi2c, (uint16_t)0x3a1f, 0x20);
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Exposure Manual
|
||||||
|
Cam_I2C_write(hi2c, (uint16_t)0x3503, 0x3);
|
||||||
|
Cam_I2C_write(hi2c, (uint16_t)0x350C, 0xFF);
|
||||||
|
Cam_I2C_write(hi2c, (uint16_t)0x350D, 0xFF);
|
||||||
|
|
||||||
|
Cam_I2C_write(hi2c, (uint16_t)0x3500, 0x0);
|
||||||
|
Cam_I2C_write(hi2c, (uint16_t)0x3501, 0x00);
|
||||||
|
Cam_I2C_write(hi2c, (uint16_t)0x3502, 0x0f);
|
||||||
|
|
||||||
|
//Gain MAX
|
||||||
|
Cam_I2C_write(hi2c, (uint16_t)0x350A, 0x0);
|
||||||
|
Cam_I2C_write(hi2c, (uint16_t)0x350B, 0x35);
|
||||||
|
Cam_I2C_write(hi2c, (uint16_t)0x3508, 0x0);
|
||||||
|
Cam_I2C_write(hi2c, (uint16_t)0x3509, 0x35);
|
||||||
|
|
||||||
|
// AWB
|
||||||
|
Cam_I2C_write(hi2c, (uint16_t)0x3406, 0x1);
|
||||||
|
|
||||||
|
Cam_I2C_write(hi2c, (uint16_t)0x3400, 0xf);
|
||||||
|
Cam_I2C_write(hi2c, (uint16_t)0x3401, 0xff);
|
||||||
|
Cam_I2C_write(hi2c, (uint16_t)0x3402, 0xf);
|
||||||
|
Cam_I2C_write(hi2c, (uint16_t)0x3403, 0x7f);
|
||||||
|
Cam_I2C_write(hi2c, (uint16_t)0x3404, 0xf);
|
||||||
|
Cam_I2C_write(hi2c, (uint16_t)0x3405, 0xff);
|
||||||
|
|
||||||
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);
|
||||||
@ -200,12 +310,12 @@ void Cam_Start_Capture(SPI_HandleTypeDef *hspi)
|
|||||||
Cam_SPI_write(hspi, 0x04, FIFO_Reg_Clear_Flags); // Reset FIFO Read Pointer
|
Cam_SPI_write(hspi, 0x04, FIFO_Reg_Clear_Flags); // Reset FIFO Read Pointer
|
||||||
Cam_SPI_write(hspi, 0x04, FIFO_Reg_Clear_Flags);
|
Cam_SPI_write(hspi, 0x04, FIFO_Reg_Clear_Flags);
|
||||||
*/
|
*/
|
||||||
Cam_SPI_write(hspi, 0x04, 0x01); // Start capture
|
Cam_SPI_write(hspi, 0x04, 0x01);
|
||||||
Cam_SPI_write(hspi, 0x04, 0x01); // Start capture
|
Cam_SPI_write(hspi, 0x04, 0x01);
|
||||||
|
|
||||||
HAL_Delay(1);
|
HAL_Delay(10);
|
||||||
Cam_SPI_write(hspi, 0x04, 0x02); // Start capture
|
Cam_SPI_write(hspi, 0x04, 0x02); // Start capture
|
||||||
HAL_Delay(1);
|
HAL_Delay(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Cam_Wait_Capture_Done(SPI_HandleTypeDef *hspi)
|
void Cam_Wait_Capture_Done(SPI_HandleTypeDef *hspi)
|
||||||
@ -229,6 +339,9 @@ void Cam_Start_Burst_Read(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);
|
||||||
|
|
||||||
uint8_t BURST_FIFO_READ = 0x3c;
|
uint8_t BURST_FIFO_READ = 0x3c;
|
||||||
uint8_t empty = 0x00;
|
uint8_t empty = 0x00;
|
||||||
|
|
||||||
|
@ -23,12 +23,10 @@
|
|||||||
#define __MAIN_H
|
#define __MAIN_H
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C"
|
extern "C" {
|
||||||
{
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Includes ------------------------------------------------------------------*/
|
/* Includes ------------------------------------------------------------------*/
|
||||||
#define USE_HAL_DRIVER
|
|
||||||
#include "stm32l4xx_hal.h"
|
#include "stm32l4xx_hal.h"
|
||||||
|
|
||||||
/* Private includes ----------------------------------------------------------*/
|
/* Private includes ----------------------------------------------------------*/
|
||||||
@ -45,25 +43,25 @@ extern "C"
|
|||||||
// #include "portable/st/synopsys/dcd_synopsys.c"
|
// #include "portable/st/synopsys/dcd_synopsys.c"
|
||||||
// #include "portable/st/synopsys/synopsys_common.h"
|
// #include "portable/st/synopsys/synopsys_common.h"
|
||||||
|
|
||||||
/* USER CODE END Includes */
|
/* USER CODE END Includes */
|
||||||
|
|
||||||
/* Exported types ------------------------------------------------------------*/
|
/* Exported types ------------------------------------------------------------*/
|
||||||
/* USER CODE BEGIN ET */
|
/* USER CODE BEGIN ET */
|
||||||
|
|
||||||
/* USER CODE END ET */
|
/* USER CODE END ET */
|
||||||
|
|
||||||
/* Exported constants --------------------------------------------------------*/
|
/* Exported constants --------------------------------------------------------*/
|
||||||
/* USER CODE BEGIN EC */
|
/* USER CODE BEGIN EC */
|
||||||
|
|
||||||
/* USER CODE END EC */
|
/* USER CODE END EC */
|
||||||
|
|
||||||
/* Exported macro ------------------------------------------------------------*/
|
/* Exported macro ------------------------------------------------------------*/
|
||||||
/* USER CODE BEGIN EM */
|
/* USER CODE BEGIN EM */
|
||||||
|
|
||||||
/* USER CODE END EM */
|
/* USER CODE END EM */
|
||||||
|
|
||||||
/* Exported functions prototypes ---------------------------------------------*/
|
/* Exported functions prototypes ---------------------------------------------*/
|
||||||
void Error_Handler(void);
|
void Error_Handler(void);
|
||||||
|
|
||||||
/* USER CODE BEGIN EFP */
|
/* USER CODE BEGIN EFP */
|
||||||
|
|
||||||
@ -87,9 +85,11 @@ extern "C"
|
|||||||
#define LD3_Pin GPIO_PIN_3
|
#define LD3_Pin GPIO_PIN_3
|
||||||
#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
|
||||||
/* USER CODE END Private defines */
|
#define CDC_FRAME_SIZE 64
|
||||||
|
#define CDC_FRAME_DELAY 1
|
||||||
|
/* USER CODE END Private defines */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -57,6 +57,7 @@ void PendSV_Handler(void);
|
|||||||
void SysTick_Handler(void);
|
void SysTick_Handler(void);
|
||||||
void DMA1_Channel2_IRQHandler(void);
|
void DMA1_Channel2_IRQHandler(void);
|
||||||
void DMA1_Channel3_IRQHandler(void);
|
void DMA1_Channel3_IRQHandler(void);
|
||||||
|
void SPI1_IRQHandler(void);
|
||||||
void USART2_IRQHandler(void);
|
void USART2_IRQHandler(void);
|
||||||
void USB_IRQHandler(void);
|
void USB_IRQHandler(void);
|
||||||
/* USER CODE BEGIN EFP */
|
/* USER CODE BEGIN EFP */
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
/* USER CODE END Header */
|
/* USER CODE END Header */
|
||||||
/* Includes ------------------------------------------------------------------*/
|
/* Includes ------------------------------------------------------------------*/
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "images.h"
|
|
||||||
/* Private includes ----------------------------------------------------------*/
|
/* Private includes ----------------------------------------------------------*/
|
||||||
/* USER CODE BEGIN Includes */
|
/* USER CODE BEGIN Includes */
|
||||||
#include "tusb.h"
|
#include "tusb.h"
|
||||||
@ -47,8 +47,6 @@ DMA_HandleTypeDef hdma_spi1_tx;
|
|||||||
|
|
||||||
UART_HandleTypeDef huart2;
|
UART_HandleTypeDef huart2;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
PCD_HandleTypeDef hpcd_USB_FS;
|
PCD_HandleTypeDef hpcd_USB_FS;
|
||||||
|
|
||||||
/* USER CODE BEGIN PV */
|
/* USER CODE BEGIN PV */
|
||||||
@ -62,7 +60,6 @@ int SPI_Rx_Done_Flag = 0;
|
|||||||
/* Private function prototypes -----------------------------------------------*/
|
/* Private function prototypes -----------------------------------------------*/
|
||||||
void SystemClock_Config(void);
|
void SystemClock_Config(void);
|
||||||
static void MX_GPIO_Init(void);
|
static void MX_GPIO_Init(void);
|
||||||
|
|
||||||
static void MX_DMA_Init(void);
|
static void MX_DMA_Init(void);
|
||||||
static void MX_USART2_UART_Init(void);
|
static void MX_USART2_UART_Init(void);
|
||||||
static void MX_SPI1_Init(void);
|
static void MX_SPI1_Init(void);
|
||||||
@ -221,13 +218,25 @@ int send_CDC_Bulk(){
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
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 */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The application entry point.
|
* @brief The application entry point.
|
||||||
* @retval int
|
* @retval int
|
||||||
*/
|
*/
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
/* USER CODE BEGIN 1 */
|
/* USER CODE BEGIN 1 */
|
||||||
@ -271,13 +280,15 @@ int main(void)
|
|||||||
// Wait for power stabilization
|
// Wait for power stabilization
|
||||||
//HAL_Delay(1000);
|
//HAL_Delay(1000);
|
||||||
|
|
||||||
#define CDC_BUFF_SIZE 10000
|
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];
|
||||||
|
|
||||||
|
Cam_Init(&hi2c1, &hspi1);
|
||||||
|
|
||||||
/* USER CODE END 2 */
|
/* USER CODE END 2 */
|
||||||
|
|
||||||
/* Infinite loop */
|
/* Infinite loop */
|
||||||
@ -288,6 +299,8 @@ int main(void)
|
|||||||
|
|
||||||
if(buff_stop_idx >= (int)image_size){
|
if(buff_stop_idx >= (int)image_size){
|
||||||
|
|
||||||
|
LED_Off();
|
||||||
|
|
||||||
buff_stop_idx = 0;
|
buff_stop_idx = 0;
|
||||||
last_sent_idx = 0;
|
last_sent_idx = 0;
|
||||||
|
|
||||||
@ -298,7 +311,7 @@ int main(void)
|
|||||||
|
|
||||||
tud_task();
|
tud_task();
|
||||||
|
|
||||||
Cam_Init(&hi2c1, &hspi1);
|
Cam_Refresh(&hi2c1, &hspi1);
|
||||||
|
|
||||||
tud_task();
|
tud_task();
|
||||||
|
|
||||||
@ -309,6 +322,8 @@ int main(void)
|
|||||||
image_size = Cam_FIFO_length(&hspi1);
|
image_size = Cam_FIFO_length(&hspi1);
|
||||||
Cam_Start_Burst_Read(&hspi1);
|
Cam_Start_Burst_Read(&hspi1);
|
||||||
|
|
||||||
|
LED_On();
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
//HAL_SPI_Receive(&hspi1, cdc_buff, CDC_BUFF_SIZE, HAL_MAX_DELAY);
|
//HAL_SPI_Receive(&hspi1, cdc_buff, CDC_BUFF_SIZE, HAL_MAX_DELAY);
|
||||||
@ -331,16 +346,17 @@ 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);
|
||||||
tud_cdc_write(&cdc_buff[current_sending_idx], 50);
|
current_sending_idx = current_sending_idx + CDC_FRAME_SIZE;
|
||||||
|
last_sent_idx = last_sent_idx + CDC_FRAME_SIZE;
|
||||||
tud_cdc_write_flush();
|
tud_cdc_write_flush();
|
||||||
current_sending_idx = current_sending_idx + 50;
|
//Delay between sends
|
||||||
last_sent_idx = last_sent_idx + 50;
|
int i = 0;
|
||||||
HAL_Delay(3);
|
for(;i<4000;i++);
|
||||||
}
|
}
|
||||||
while(last_sent_idx < buff_stop_idx);
|
while(last_sent_idx < buff_stop_idx);
|
||||||
|
|
||||||
LED_On();
|
|
||||||
|
|
||||||
/* USER CODE END WHILE */
|
/* USER CODE END WHILE */
|
||||||
|
|
||||||
@ -350,25 +366,25 @@ int main(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief System Clock Configuration
|
* @brief System Clock Configuration
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
void SystemClock_Config(void)
|
void SystemClock_Config(void)
|
||||||
{
|
{
|
||||||
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
|
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
|
||||||
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
|
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
|
||||||
|
|
||||||
/** Configure the main internal regulator output voltage
|
/** Configure the main internal regulator output voltage
|
||||||
*/
|
*/
|
||||||
if (HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1) != HAL_OK)
|
if (HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1) != HAL_OK)
|
||||||
{
|
{
|
||||||
Error_Handler();
|
Error_Handler();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Initializes the RCC Oscillators according to the specified parameters
|
/** Initializes the RCC Oscillators according to the specified parameters
|
||||||
* in the RCC_OscInitTypeDef structure.
|
* in the RCC_OscInitTypeDef structure.
|
||||||
*/
|
*/
|
||||||
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI48 | RCC_OSCILLATORTYPE_HSI;
|
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI48|RCC_OSCILLATORTYPE_HSI;
|
||||||
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
|
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
|
||||||
RCC_OscInitStruct.HSI48State = RCC_HSI48_ON;
|
RCC_OscInitStruct.HSI48State = RCC_HSI48_ON;
|
||||||
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
|
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
|
||||||
@ -385,8 +401,9 @@ void SystemClock_Config(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Initializes the CPU, AHB and APB buses clocks
|
/** Initializes the CPU, AHB and APB buses clocks
|
||||||
*/
|
*/
|
||||||
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2;
|
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
|
||||||
|
|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
|
||||||
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
|
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
|
||||||
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
|
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
|
||||||
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
|
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
|
||||||
@ -399,10 +416,10 @@ void SystemClock_Config(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief I2C1 Initialization Function
|
* @brief I2C1 Initialization Function
|
||||||
* @param None
|
* @param None
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
static void MX_I2C1_Init(void)
|
static void MX_I2C1_Init(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -428,14 +445,14 @@ static void MX_I2C1_Init(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Configure Analogue filter
|
/** Configure Analogue filter
|
||||||
*/
|
*/
|
||||||
if (HAL_I2CEx_ConfigAnalogFilter(&hi2c1, I2C_ANALOGFILTER_ENABLE) != HAL_OK)
|
if (HAL_I2CEx_ConfigAnalogFilter(&hi2c1, I2C_ANALOGFILTER_ENABLE) != HAL_OK)
|
||||||
{
|
{
|
||||||
Error_Handler();
|
Error_Handler();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Configure Digital filter
|
/** Configure Digital filter
|
||||||
*/
|
*/
|
||||||
if (HAL_I2CEx_ConfigDigitalFilter(&hi2c1, 0) != HAL_OK)
|
if (HAL_I2CEx_ConfigDigitalFilter(&hi2c1, 0) != HAL_OK)
|
||||||
{
|
{
|
||||||
Error_Handler();
|
Error_Handler();
|
||||||
@ -443,13 +460,14 @@ static void MX_I2C1_Init(void)
|
|||||||
/* USER CODE BEGIN I2C1_Init 2 */
|
/* USER CODE BEGIN I2C1_Init 2 */
|
||||||
|
|
||||||
/* USER CODE END I2C1_Init 2 */
|
/* USER CODE END I2C1_Init 2 */
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief SPI1 Initialization Function
|
* @brief SPI1 Initialization Function
|
||||||
* @param None
|
* @param None
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
static void MX_SPI1_Init(void)
|
static void MX_SPI1_Init(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -468,7 +486,7 @@ static void MX_SPI1_Init(void)
|
|||||||
hspi1.Init.CLKPolarity = SPI_POLARITY_LOW;
|
hspi1.Init.CLKPolarity = SPI_POLARITY_LOW;
|
||||||
hspi1.Init.CLKPhase = SPI_PHASE_1EDGE;
|
hspi1.Init.CLKPhase = SPI_PHASE_1EDGE;
|
||||||
hspi1.Init.NSS = SPI_NSS_SOFT;
|
hspi1.Init.NSS = SPI_NSS_SOFT;
|
||||||
hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_128;
|
hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_32;
|
||||||
hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB;
|
hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB;
|
||||||
hspi1.Init.TIMode = SPI_TIMODE_DISABLE;
|
hspi1.Init.TIMode = SPI_TIMODE_DISABLE;
|
||||||
hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
|
hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
|
||||||
@ -482,13 +500,14 @@ static void MX_SPI1_Init(void)
|
|||||||
/* USER CODE BEGIN SPI1_Init 2 */
|
/* USER CODE BEGIN SPI1_Init 2 */
|
||||||
|
|
||||||
/* USER CODE END SPI1_Init 2 */
|
/* USER CODE END SPI1_Init 2 */
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief USART2 Initialization Function
|
* @brief USART2 Initialization Function
|
||||||
* @param None
|
* @param None
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
static void MX_USART2_UART_Init(void)
|
static void MX_USART2_UART_Init(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -516,13 +535,14 @@ static void MX_USART2_UART_Init(void)
|
|||||||
/* USER CODE BEGIN USART2_Init 2 */
|
/* USER CODE BEGIN USART2_Init 2 */
|
||||||
|
|
||||||
/* USER CODE END USART2_Init 2 */
|
/* USER CODE END USART2_Init 2 */
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief USB Initialization Function
|
* @brief USB Initialization Function
|
||||||
* @param None
|
* @param None
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
static void MX_USB_PCD_Init(void)
|
static void MX_USB_PCD_Init(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -548,11 +568,12 @@ static void MX_USB_PCD_Init(void)
|
|||||||
/* USER CODE BEGIN USB_Init 2 */
|
/* USER CODE BEGIN USB_Init 2 */
|
||||||
|
|
||||||
/* USER CODE END USB_Init 2 */
|
/* USER CODE END USB_Init 2 */
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enable DMA controller clock
|
* Enable DMA controller clock
|
||||||
*/
|
*/
|
||||||
static void MX_DMA_Init(void)
|
static void MX_DMA_Init(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -566,13 +587,14 @@ static void MX_DMA_Init(void)
|
|||||||
/* DMA1_Channel3_IRQn interrupt configuration */
|
/* DMA1_Channel3_IRQn interrupt configuration */
|
||||||
HAL_NVIC_SetPriority(DMA1_Channel3_IRQn, 0, 0);
|
HAL_NVIC_SetPriority(DMA1_Channel3_IRQn, 0, 0);
|
||||||
HAL_NVIC_EnableIRQ(DMA1_Channel3_IRQn);
|
HAL_NVIC_EnableIRQ(DMA1_Channel3_IRQn);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief GPIO Initialization Function
|
* @brief GPIO Initialization Function
|
||||||
* @param None
|
* @param None
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
static void MX_GPIO_Init(void)
|
static void MX_GPIO_Init(void)
|
||||||
{
|
{
|
||||||
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
||||||
@ -586,7 +608,7 @@ static void MX_GPIO_Init(void)
|
|||||||
HAL_GPIO_WritePin(DEBUG_LED_GPIO_Port, DEBUG_LED_Pin, GPIO_PIN_RESET);
|
HAL_GPIO_WritePin(DEBUG_LED_GPIO_Port, DEBUG_LED_Pin, GPIO_PIN_RESET);
|
||||||
|
|
||||||
/*Configure GPIO pin Output Level */
|
/*Configure GPIO pin Output Level */
|
||||||
HAL_GPIO_WritePin(GPIOB, CHIP_SELECT_Pin | LD3_Pin, GPIO_PIN_RESET);
|
HAL_GPIO_WritePin(GPIOB, CHIP_SELECT_Pin|LD3_Pin, GPIO_PIN_RESET);
|
||||||
|
|
||||||
/*Configure GPIO pin : DEBUG_LED_Pin */
|
/*Configure GPIO pin : DEBUG_LED_Pin */
|
||||||
GPIO_InitStruct.Pin = DEBUG_LED_Pin;
|
GPIO_InitStruct.Pin = DEBUG_LED_Pin;
|
||||||
@ -596,11 +618,12 @@ static void MX_GPIO_Init(void)
|
|||||||
HAL_GPIO_Init(DEBUG_LED_GPIO_Port, &GPIO_InitStruct);
|
HAL_GPIO_Init(DEBUG_LED_GPIO_Port, &GPIO_InitStruct);
|
||||||
|
|
||||||
/*Configure GPIO pins : CHIP_SELECT_Pin LD3_Pin */
|
/*Configure GPIO pins : CHIP_SELECT_Pin LD3_Pin */
|
||||||
GPIO_InitStruct.Pin = CHIP_SELECT_Pin | LD3_Pin;
|
GPIO_InitStruct.Pin = CHIP_SELECT_Pin|LD3_Pin;
|
||||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||||
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* USER CODE BEGIN 4 */
|
/* USER CODE BEGIN 4 */
|
||||||
@ -617,9 +640,9 @@ void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart)
|
|||||||
/* USER CODE END 4 */
|
/* USER CODE END 4 */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This function is executed in case of error occurrence.
|
* @brief This function is executed in case of error occurrence.
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
void Error_Handler(void)
|
void Error_Handler(void)
|
||||||
{
|
{
|
||||||
/* USER CODE BEGIN Error_Handler_Debug */
|
/* USER CODE BEGIN Error_Handler_Debug */
|
||||||
@ -631,14 +654,14 @@ void Error_Handler(void)
|
|||||||
/* USER CODE END Error_Handler_Debug */
|
/* USER CODE END Error_Handler_Debug */
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_FULL_ASSERT
|
#ifdef USE_FULL_ASSERT
|
||||||
/**
|
/**
|
||||||
* @brief Reports the name of the source file and the source line number
|
* @brief Reports the name of the source file and the source line number
|
||||||
* where the assert_param error has occurred.
|
* where the assert_param error has occurred.
|
||||||
* @param file: pointer to the source file name
|
* @param file: pointer to the source file name
|
||||||
* @param line: assert_param error line source number
|
* @param line: assert_param error line source number
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
void assert_failed(uint8_t *file, uint32_t line)
|
void assert_failed(uint8_t *file, uint32_t line)
|
||||||
{
|
{
|
||||||
/* USER CODE BEGIN 6 */
|
/* USER CODE BEGIN 6 */
|
||||||
|
@ -221,6 +221,9 @@ void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi)
|
|||||||
|
|
||||||
__HAL_LINKDMA(hspi,hdmatx,hdma_spi1_tx);
|
__HAL_LINKDMA(hspi,hdmatx,hdma_spi1_tx);
|
||||||
|
|
||||||
|
/* SPI1 interrupt Init */
|
||||||
|
HAL_NVIC_SetPriority(SPI1_IRQn, 0, 0);
|
||||||
|
HAL_NVIC_EnableIRQ(SPI1_IRQn);
|
||||||
/* USER CODE BEGIN SPI1_MspInit 1 */
|
/* USER CODE BEGIN SPI1_MspInit 1 */
|
||||||
|
|
||||||
/* USER CODE END SPI1_MspInit 1 */
|
/* USER CODE END SPI1_MspInit 1 */
|
||||||
@ -254,6 +257,9 @@ void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi)
|
|||||||
/* SPI1 DMA DeInit */
|
/* SPI1 DMA DeInit */
|
||||||
HAL_DMA_DeInit(hspi->hdmarx);
|
HAL_DMA_DeInit(hspi->hdmarx);
|
||||||
HAL_DMA_DeInit(hspi->hdmatx);
|
HAL_DMA_DeInit(hspi->hdmatx);
|
||||||
|
|
||||||
|
/* SPI1 interrupt DeInit */
|
||||||
|
HAL_NVIC_DisableIRQ(SPI1_IRQn);
|
||||||
/* USER CODE BEGIN SPI1_MspDeInit 1 */
|
/* USER CODE BEGIN SPI1_MspDeInit 1 */
|
||||||
|
|
||||||
/* USER CODE END SPI1_MspDeInit 1 */
|
/* USER CODE END SPI1_MspDeInit 1 */
|
||||||
|
@ -57,6 +57,7 @@
|
|||||||
/* External variables --------------------------------------------------------*/
|
/* External variables --------------------------------------------------------*/
|
||||||
extern DMA_HandleTypeDef hdma_spi1_rx;
|
extern DMA_HandleTypeDef hdma_spi1_rx;
|
||||||
extern DMA_HandleTypeDef hdma_spi1_tx;
|
extern DMA_HandleTypeDef hdma_spi1_tx;
|
||||||
|
extern SPI_HandleTypeDef hspi1;
|
||||||
extern UART_HandleTypeDef huart2;
|
extern UART_HandleTypeDef huart2;
|
||||||
extern PCD_HandleTypeDef hpcd_USB_FS;
|
extern PCD_HandleTypeDef hpcd_USB_FS;
|
||||||
/* USER CODE BEGIN EV */
|
/* USER CODE BEGIN EV */
|
||||||
@ -67,8 +68,8 @@ extern PCD_HandleTypeDef hpcd_USB_FS;
|
|||||||
/* Cortex-M4 Processor Interruption and Exception Handlers */
|
/* Cortex-M4 Processor Interruption and Exception Handlers */
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
/**
|
/**
|
||||||
* @brief This function handles Non maskable interrupt.
|
* @brief This function handles Non maskable interrupt.
|
||||||
*/
|
*/
|
||||||
void NMI_Handler(void)
|
void NMI_Handler(void)
|
||||||
{
|
{
|
||||||
/* USER CODE BEGIN NonMaskableInt_IRQn 0 */
|
/* USER CODE BEGIN NonMaskableInt_IRQn 0 */
|
||||||
@ -82,8 +83,8 @@ void NMI_Handler(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This function handles Hard fault interrupt.
|
* @brief This function handles Hard fault interrupt.
|
||||||
*/
|
*/
|
||||||
void HardFault_Handler(void)
|
void HardFault_Handler(void)
|
||||||
{
|
{
|
||||||
/* USER CODE BEGIN HardFault_IRQn 0 */
|
/* USER CODE BEGIN HardFault_IRQn 0 */
|
||||||
@ -97,8 +98,8 @@ void HardFault_Handler(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This function handles Memory management fault.
|
* @brief This function handles Memory management fault.
|
||||||
*/
|
*/
|
||||||
void MemManage_Handler(void)
|
void MemManage_Handler(void)
|
||||||
{
|
{
|
||||||
/* USER CODE BEGIN MemoryManagement_IRQn 0 */
|
/* USER CODE BEGIN MemoryManagement_IRQn 0 */
|
||||||
@ -112,8 +113,8 @@ void MemManage_Handler(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This function handles Prefetch fault, memory access fault.
|
* @brief This function handles Prefetch fault, memory access fault.
|
||||||
*/
|
*/
|
||||||
void BusFault_Handler(void)
|
void BusFault_Handler(void)
|
||||||
{
|
{
|
||||||
/* USER CODE BEGIN BusFault_IRQn 0 */
|
/* USER CODE BEGIN BusFault_IRQn 0 */
|
||||||
@ -127,8 +128,8 @@ void BusFault_Handler(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This function handles Undefined instruction or illegal state.
|
* @brief This function handles Undefined instruction or illegal state.
|
||||||
*/
|
*/
|
||||||
void UsageFault_Handler(void)
|
void UsageFault_Handler(void)
|
||||||
{
|
{
|
||||||
/* USER CODE BEGIN UsageFault_IRQn 0 */
|
/* USER CODE BEGIN UsageFault_IRQn 0 */
|
||||||
@ -142,8 +143,8 @@ void UsageFault_Handler(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This function handles System service call via SWI instruction.
|
* @brief This function handles System service call via SWI instruction.
|
||||||
*/
|
*/
|
||||||
void SVC_Handler(void)
|
void SVC_Handler(void)
|
||||||
{
|
{
|
||||||
/* USER CODE BEGIN SVCall_IRQn 0 */
|
/* USER CODE BEGIN SVCall_IRQn 0 */
|
||||||
@ -155,8 +156,8 @@ void SVC_Handler(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This function handles Debug monitor.
|
* @brief This function handles Debug monitor.
|
||||||
*/
|
*/
|
||||||
void DebugMon_Handler(void)
|
void DebugMon_Handler(void)
|
||||||
{
|
{
|
||||||
/* USER CODE BEGIN DebugMonitor_IRQn 0 */
|
/* USER CODE BEGIN DebugMonitor_IRQn 0 */
|
||||||
@ -168,8 +169,8 @@ void DebugMon_Handler(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This function handles Pendable request for system service.
|
* @brief This function handles Pendable request for system service.
|
||||||
*/
|
*/
|
||||||
void PendSV_Handler(void)
|
void PendSV_Handler(void)
|
||||||
{
|
{
|
||||||
/* USER CODE BEGIN PendSV_IRQn 0 */
|
/* USER CODE BEGIN PendSV_IRQn 0 */
|
||||||
@ -181,8 +182,8 @@ void PendSV_Handler(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This function handles System tick timer.
|
* @brief This function handles System tick timer.
|
||||||
*/
|
*/
|
||||||
void SysTick_Handler(void)
|
void SysTick_Handler(void)
|
||||||
{
|
{
|
||||||
/* USER CODE BEGIN SysTick_IRQn 0 */
|
/* USER CODE BEGIN SysTick_IRQn 0 */
|
||||||
@ -202,8 +203,8 @@ void SysTick_Handler(void)
|
|||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This function handles DMA1 channel2 global interrupt.
|
* @brief This function handles DMA1 channel2 global interrupt.
|
||||||
*/
|
*/
|
||||||
void DMA1_Channel2_IRQHandler(void)
|
void DMA1_Channel2_IRQHandler(void)
|
||||||
{
|
{
|
||||||
/* USER CODE BEGIN DMA1_Channel2_IRQn 0 */
|
/* USER CODE BEGIN DMA1_Channel2_IRQn 0 */
|
||||||
@ -216,8 +217,8 @@ void DMA1_Channel2_IRQHandler(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This function handles DMA1 channel3 global interrupt.
|
* @brief This function handles DMA1 channel3 global interrupt.
|
||||||
*/
|
*/
|
||||||
void DMA1_Channel3_IRQHandler(void)
|
void DMA1_Channel3_IRQHandler(void)
|
||||||
{
|
{
|
||||||
/* USER CODE BEGIN DMA1_Channel3_IRQn 0 */
|
/* USER CODE BEGIN DMA1_Channel3_IRQn 0 */
|
||||||
@ -230,8 +231,22 @@ void DMA1_Channel3_IRQHandler(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This function handles USART2 global interrupt.
|
* @brief This function handles SPI1 global interrupt.
|
||||||
*/
|
*/
|
||||||
|
void SPI1_IRQHandler(void)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN SPI1_IRQn 0 */
|
||||||
|
|
||||||
|
/* USER CODE END SPI1_IRQn 0 */
|
||||||
|
HAL_SPI_IRQHandler(&hspi1);
|
||||||
|
/* USER CODE BEGIN SPI1_IRQn 1 */
|
||||||
|
|
||||||
|
/* USER CODE END SPI1_IRQn 1 */
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This function handles USART2 global interrupt.
|
||||||
|
*/
|
||||||
void USART2_IRQHandler(void)
|
void USART2_IRQHandler(void)
|
||||||
{
|
{
|
||||||
/* USER CODE BEGIN USART2_IRQn 0 */
|
/* USER CODE BEGIN USART2_IRQn 0 */
|
||||||
@ -244,8 +259,8 @@ void USART2_IRQHandler(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This function handles USB event interrupt through EXTI line 17.
|
* @brief This function handles USB event interrupt through EXTI line 17.
|
||||||
*/
|
*/
|
||||||
void USB_IRQHandler(void)
|
void USB_IRQHandler(void)
|
||||||
{
|
{
|
||||||
/* USER CODE BEGIN USB_IRQn 0 */
|
/* USER CODE BEGIN USB_IRQn 0 */
|
||||||
|
@ -1,139 +1,139 @@
|
|||||||
SHELL=/bin/bash
|
SHELL=/bin/bash
|
||||||
|
|
||||||
.PHONY: all build build-container cmake format format-linux flash-stlink flash-jlink format-container shell image build-container clean clean-image clean-all
|
.PHONY: all build build-container cmake format format-linux flash-stlink flash-jlink format-container shell image build-container clean clean-image clean-all
|
||||||
############################### Native Makefile ###############################
|
############################### Native Makefile ###############################
|
||||||
|
|
||||||
PROJECT_NAME ?= Probe
|
PROJECT_NAME ?= Probe
|
||||||
BUILD_DIR ?= build
|
BUILD_DIR ?= build
|
||||||
FIRMWARE := $(BUILD_DIR)/$(PROJECT_NAME).bin
|
FIRMWARE := $(BUILD_DIR)/$(PROJECT_NAME).bin
|
||||||
BUILD_TYPE ?= Debug
|
BUILD_TYPE ?= Debug
|
||||||
PLATFORM = $(if $(OS),$(OS),$(shell uname -s))
|
PLATFORM = $(if $(OS),$(OS),$(shell uname -s))
|
||||||
|
|
||||||
ifeq ($(PLATFORM),Windows_NT)
|
ifeq ($(PLATFORM),Windows_NT)
|
||||||
BUILD_SYSTEM ?= MinGW Makefiles
|
BUILD_SYSTEM ?= MinGW Makefiles
|
||||||
else
|
else
|
||||||
ifeq ($(PLATFORM),Linux)
|
ifeq ($(PLATFORM),Linux)
|
||||||
BUILD_SYSTEM ?= Unix Makefiles
|
BUILD_SYSTEM ?= Unix Makefiles
|
||||||
else
|
else
|
||||||
@echo "Unsuported platform"
|
@echo "Unsuported platform"
|
||||||
exit 1
|
exit 1
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
all: build
|
all: build
|
||||||
|
|
||||||
build: cmake
|
build: cmake
|
||||||
$(MAKE) -C $(BUILD_DIR) --no-print-directory
|
$(MAKE) -C $(BUILD_DIR) --no-print-directory
|
||||||
|
|
||||||
cmake: $(BUILD_DIR)/Makefile
|
cmake: $(BUILD_DIR)/Makefile
|
||||||
|
|
||||||
$(BUILD_DIR)/Makefile: CMakeLists.txt
|
$(BUILD_DIR)/Makefile: CMakeLists.txt
|
||||||
cmake \
|
cmake \
|
||||||
-G "$(BUILD_SYSTEM)" \
|
-G "$(BUILD_SYSTEM)" \
|
||||||
-B$(BUILD_DIR) \
|
-B$(BUILD_DIR) \
|
||||||
-DPROJECT_NAME=$(PROJECT_NAME) \
|
-DPROJECT_NAME=$(PROJECT_NAME) \
|
||||||
-DCMAKE_BUILD_TYPE=$(BUILD_TYPE) \
|
-DCMAKE_BUILD_TYPE=$(BUILD_TYPE) \
|
||||||
-DDUMP_ASM=OFF
|
-DDUMP_ASM=OFF
|
||||||
|
|
||||||
# Formats all user modified source files (add ones that are missing)
|
# Formats all user modified source files (add ones that are missing)
|
||||||
# SRCS := $(shell find Project -name '*.[ch]' -or -name '*.[ch]pp') Core/Src/main.c
|
# SRCS := $(shell find Project -name '*.[ch]' -or -name '*.[ch]pp') Core/Src/main.c
|
||||||
SRCS := $(shell find Core -name '*.[ch]' -or -name '*.[ch]pp') Core/Src/main.c
|
SRCS := $(shell find Core -name '*.[ch]' -or -name '*.[ch]pp') Core/Src/main.c
|
||||||
format: $(addsuffix .format,$(SRCS))
|
format: $(addsuffix .format,$(SRCS))
|
||||||
%.format: %
|
%.format: %
|
||||||
clang-format -i $<
|
clang-format -i $<
|
||||||
|
|
||||||
# Formats all CubeMX generated sources to unix style - removes \r from line endings
|
# Formats all CubeMX generated sources to unix style - removes \r from line endings
|
||||||
# Add any new directories, like Middlewares and hidden files
|
# Add any new directories, like Middlewares and hidden files
|
||||||
HIDDEN_FILES := .mxproject .project .cproject
|
HIDDEN_FILES := .mxproject .project .cproject
|
||||||
FOUND_HIDDEN_FILES := $(shell for f in $(HIDDEN_FILES);do if [[ -e $$f ]]; then echo $$f;fi; done)
|
FOUND_HIDDEN_FILES := $(shell for f in $(HIDDEN_FILES);do if [[ -e $$f ]]; then echo $$f;fi; done)
|
||||||
FORMAT_LINUX := $(shell find Core Drivers -name '*' -type f; find . -name '*.ioc') $(FOUND_HIDDEN_FILES)
|
FORMAT_LINUX := $(shell find Core Drivers -name '*' -type f; find . -name '*.ioc') $(FOUND_HIDDEN_FILES)
|
||||||
|
|
||||||
format-linux: $(addsuffix .format-linux,$(FORMAT_LINUX))
|
format-linux: $(addsuffix .format-linux,$(FORMAT_LINUX))
|
||||||
%.format-linux: %
|
%.format-linux: %
|
||||||
$(if $(filter $(PLATFORM),Linux),dos2unix -q $<,)
|
$(if $(filter $(PLATFORM),Linux),dos2unix -q $<,)
|
||||||
|
|
||||||
# Device specific!
|
# Device specific!
|
||||||
DEVICE ?= STM32F407VG
|
DEVICE ?= STM32F407VG
|
||||||
|
|
||||||
flash-st: build
|
flash-st: build
|
||||||
st-flash --reset write $(FIRMWARE) 0x08000000
|
st-flash --reset write $(FIRMWARE) 0x08000000
|
||||||
|
|
||||||
$(BUILD_DIR)/jlink-script:
|
$(BUILD_DIR)/jlink-script:
|
||||||
touch $@
|
touch $@
|
||||||
@echo device $(DEVICE) > $@
|
@echo device $(DEVICE) > $@
|
||||||
@echo si 1 >> $@
|
@echo si 1 >> $@
|
||||||
@echo speed 4000 >> $@
|
@echo speed 4000 >> $@
|
||||||
@echo loadfile $(FIRMWARE),0x08000000 >> $@
|
@echo loadfile $(FIRMWARE),0x08000000 >> $@
|
||||||
@echo -e "r\ng\nqc" >> $@
|
@echo -e "r\ng\nqc" >> $@
|
||||||
|
|
||||||
flash-jlink: build | $(BUILD_DIR)/jlink-script
|
flash-jlink: build | $(BUILD_DIR)/jlink-script
|
||||||
JLinkExe -commanderScript $(BUILD_DIR)/jlink-script
|
JLinkExe -commanderScript $(BUILD_DIR)/jlink-script
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf $(BUILD_DIR)
|
rm -rf $(BUILD_DIR)
|
||||||
|
|
||||||
################################## Container ##################################
|
################################## Container ##################################
|
||||||
|
|
||||||
UID ?= $(shell id -u)
|
UID ?= $(shell id -u)
|
||||||
GID ?= $(shell id -g)
|
GID ?= $(shell id -g)
|
||||||
USER ?= $(shell id -un)
|
USER ?= $(shell id -un)
|
||||||
GROUP ?= $(if $(filter $(PLATFORM), Windows_NT),$(shell id -un),$(shell id -gn))
|
GROUP ?= $(if $(filter $(PLATFORM), Windows_NT),$(shell id -un),$(shell id -gn))
|
||||||
|
|
||||||
ifeq ($(PLATFORM),Windows_NT)
|
ifeq ($(PLATFORM),Windows_NT)
|
||||||
WIN_PREFIX = winpty
|
WIN_PREFIX = winpty
|
||||||
WORKDIR_PATH = "//workdir"
|
WORKDIR_PATH = "//workdir"
|
||||||
WORKDIR_VOLUME = "/$$(pwd -W):/workdir"
|
WORKDIR_VOLUME = "/$$(pwd -W):/workdir"
|
||||||
else
|
else
|
||||||
WORKDIR_PATH = /workdir
|
WORKDIR_PATH = /workdir
|
||||||
WORKDIR_VOLUME = "$$(pwd):/workdir"
|
WORKDIR_VOLUME = "$$(pwd):/workdir"
|
||||||
endif
|
endif
|
||||||
|
|
||||||
CONTAINER_TOOL ?= docker
|
CONTAINER_TOOL ?= docker
|
||||||
CONTAINER_FILE := Dockerfile
|
CONTAINER_FILE := Dockerfile
|
||||||
IMAGE_NAME := fedora-arm-embedded-dev
|
IMAGE_NAME := fedora-arm-embedded-dev
|
||||||
CONTAINER_NAME := fedora-arm-embedded-dev
|
CONTAINER_NAME := fedora-arm-embedded-dev
|
||||||
|
|
||||||
NEED_IMAGE = $(shell $(CONTAINER_TOOL) image inspect $(IMAGE_NAME) 2> /dev/null > /dev/null || echo image)
|
NEED_IMAGE = $(shell $(CONTAINER_TOOL) image inspect $(IMAGE_NAME) 2> /dev/null > /dev/null || echo image)
|
||||||
# usefull if you have a always running container in the background: NEED_CONTAINER = $(shell $(CONTAINER_TOOL) container inspect $(CONTAINER_NAME) 2> /dev/null > /dev/null || echo container)
|
# usefull if you have a always running container in the background: NEED_CONTAINER = $(shell $(CONTAINER_TOOL) container inspect $(CONTAINER_NAME) 2> /dev/null > /dev/null || echo container)
|
||||||
PODMAN_ARG = $(if $(filter $(CONTAINER_TOOL), podman),--userns=keep-id,)
|
PODMAN_ARG = $(if $(filter $(CONTAINER_TOOL), podman),--userns=keep-id,)
|
||||||
CONTAINER_RUN = $(WIN_PREFIX) $(CONTAINER_TOOL) run \
|
CONTAINER_RUN = $(WIN_PREFIX) $(CONTAINER_TOOL) run \
|
||||||
--name $(CONTAINER_NAME) \
|
--name $(CONTAINER_NAME) \
|
||||||
--rm \
|
--rm \
|
||||||
-it \
|
-it \
|
||||||
$(PODMAN_ARG) \
|
$(PODMAN_ARG) \
|
||||||
-v $(WORKDIR_VOLUME) \
|
-v $(WORKDIR_VOLUME) \
|
||||||
-w $(WORKDIR_PATH) \
|
-w $(WORKDIR_PATH) \
|
||||||
--security-opt label=disable \
|
--security-opt label=disable \
|
||||||
--hostname $(CONTAINER_NAME) \
|
--hostname $(CONTAINER_NAME) \
|
||||||
$(IMAGE_NAME)
|
$(IMAGE_NAME)
|
||||||
|
|
||||||
build-container: $(NEED_IMAGE)
|
build-container: $(NEED_IMAGE)
|
||||||
$(CONTAINER_RUN) bash -lc 'make -j$(shell nproc)'
|
$(CONTAINER_RUN) bash -lc 'make -j$(shell nproc)'
|
||||||
|
|
||||||
format-container:
|
format-container:
|
||||||
$(CONTAINER_RUN) bash -lc 'make format -j$(shell nproc)'
|
$(CONTAINER_RUN) bash -lc 'make format -j$(shell nproc)'
|
||||||
|
|
||||||
format-linux-container:
|
format-linux-container:
|
||||||
$(CONTAINER_RUN) bash -lc 'make format-linux'
|
$(CONTAINER_RUN) bash -lc 'make format-linux'
|
||||||
|
|
||||||
shell:
|
shell:
|
||||||
$(CONTAINER_RUN) bash -l
|
$(CONTAINER_RUN) bash -l
|
||||||
|
|
||||||
image: $(CONTAINER_FILE)
|
image: $(CONTAINER_FILE)
|
||||||
$(CONTAINER_TOOL) build \
|
$(CONTAINER_TOOL) build \
|
||||||
-t $(IMAGE_NAME) \
|
-t $(IMAGE_NAME) \
|
||||||
-f=$(CONTAINER_FILE) \
|
-f=$(CONTAINER_FILE) \
|
||||||
--build-arg UID=$(UID) \
|
--build-arg UID=$(UID) \
|
||||||
--build-arg GID=$(GID) \
|
--build-arg GID=$(GID) \
|
||||||
--build-arg USERNAME=$(USER) \
|
--build-arg USERNAME=$(USER) \
|
||||||
--build-arg GROUPNAME=$(GROUP) \
|
--build-arg GROUPNAME=$(GROUP) \
|
||||||
.
|
.
|
||||||
|
|
||||||
clean-image:
|
clean-image:
|
||||||
$(CONTAINER_TOOL) container rm -f $(CONTAINER_NAME) 2> /dev/null > /dev/null || true
|
$(CONTAINER_TOOL) container rm -f $(CONTAINER_NAME) 2> /dev/null > /dev/null || true
|
||||||
$(CONTAINER_TOOL) image rmi -f $(IMAGE_NAME) 2> /dev/null > /dev/null || true
|
$(CONTAINER_TOOL) image rmi -f $(IMAGE_NAME) 2> /dev/null > /dev/null || true
|
||||||
|
|
||||||
clean-all: clean clean-image
|
clean-all: clean clean-image
|
||||||
|
|
||||||
flash:
|
flash:
|
||||||
openocd -f interface/stlink.cfg -f target/stm32l4x.cfg -c "program build/Probe.bin verify reset exit 0x08000000"
|
openocd -f interface/stlink.cfg -f target/stm32l4x.cfg -c "program build/Probe.bin verify reset exit 0x08000000"
|
||||||
|
@ -74,6 +74,7 @@ NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
|||||||
NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
||||||
NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
||||||
NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4
|
NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4
|
||||||
|
NVIC.SPI1_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true
|
||||||
NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
||||||
NVIC.SysTick_IRQn=true\:0\:0\:true\:false\:true\:true\:true\:false
|
NVIC.SysTick_IRQn=true\:0\:0\:true\:false\:true\:true\:true\:false
|
||||||
NVIC.USART2_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true
|
NVIC.USART2_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true
|
||||||
@ -160,6 +161,7 @@ ProjectManager.PreviousToolchain=
|
|||||||
ProjectManager.ProjectBuild=false
|
ProjectManager.ProjectBuild=false
|
||||||
ProjectManager.ProjectFileName=Probe.ioc
|
ProjectManager.ProjectFileName=Probe.ioc
|
||||||
ProjectManager.ProjectName=Probe
|
ProjectManager.ProjectName=Probe
|
||||||
|
ProjectManager.ProjectStructure=
|
||||||
ProjectManager.RegisterCallBack=
|
ProjectManager.RegisterCallBack=
|
||||||
ProjectManager.StackSize=0x400
|
ProjectManager.StackSize=0x400
|
||||||
ProjectManager.TargetToolchain=Makefile
|
ProjectManager.TargetToolchain=Makefile
|
||||||
@ -225,8 +227,8 @@ RCC.VCOInputFreq_Value=16000000
|
|||||||
RCC.VCOOutputFreq_Value=160000000
|
RCC.VCOOutputFreq_Value=160000000
|
||||||
RCC.VCOSAI1OutputFreq_Value=128000000
|
RCC.VCOSAI1OutputFreq_Value=128000000
|
||||||
RCC.WatchDogFreq_Value=32000
|
RCC.WatchDogFreq_Value=32000
|
||||||
SPI1.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_128
|
SPI1.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_32
|
||||||
SPI1.CalculateBaudRate=625.0 KBits/s
|
SPI1.CalculateBaudRate=2.5 MBits/s
|
||||||
SPI1.DataSize=SPI_DATASIZE_8BIT
|
SPI1.DataSize=SPI_DATASIZE_8BIT
|
||||||
SPI1.Direction=SPI_DIRECTION_2LINES
|
SPI1.Direction=SPI_DIRECTION_2LINES
|
||||||
SPI1.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate,DataSize,BaudRatePrescaler,NSSPMode
|
SPI1.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate,DataSize,BaudRatePrescaler,NSSPMode
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
CC = g++
|
CC = g++
|
||||||
CFLAGS = -pthread -std=c++11 -Wall -Wextra -pedantic
|
CFLAGS = -pthread -std=c++11 -Wall -Wextra -pedantic -O3
|
||||||
LDLIBS = -lSDL2 -lSDL2_image
|
LDLIBS = -lSDL2 -lSDL2_image
|
||||||
SRCS = $(wildcard *.cpp)
|
SRCS = $(wildcard *.cpp)
|
||||||
|
|
||||||
|
@ -64,7 +64,6 @@ int Receiver::readCdcData(uint8_t (*character)[CDC_FRAME_SIZE]) {
|
|||||||
std::cerr << "Error in read" << std::endl;
|
std::cerr << "Error in read" << std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0 // PRINT WHAT IS RECEIVED
|
#if 0 // PRINT WHAT IS RECEIVED
|
||||||
|
|
||||||
for(int i = 0; i<CDC_FRAME_SIZE; i++)
|
for(int i = 0; i<CDC_FRAME_SIZE; i++)
|
||||||
@ -77,7 +76,6 @@ int Receiver::readCdcData(uint8_t (*character)[CDC_FRAME_SIZE]) {
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,8 +122,6 @@ int Receiver::fillBuffer(){
|
|||||||
unsigned char character[CDC_FRAME_SIZE];
|
unsigned char character[CDC_FRAME_SIZE];
|
||||||
std::vector<uint8_t> tempVec{};
|
std::vector<uint8_t> tempVec{};
|
||||||
|
|
||||||
Receiver::readCdcData(&character);
|
|
||||||
|
|
||||||
int i = -1;
|
int i = -1;
|
||||||
do {
|
do {
|
||||||
Receiver::readCdcData(&character);
|
Receiver::readCdcData(&character);
|
||||||
@ -186,15 +182,17 @@ void Receiver::bufferToDisplay(){
|
|||||||
currentBufferIndexMutex.lock();
|
currentBufferIndexMutex.lock();
|
||||||
int buffIdx = currentBufferIndex;
|
int buffIdx = currentBufferIndex;
|
||||||
currentBufferIndexMutex.unlock();
|
currentBufferIndexMutex.unlock();
|
||||||
std::cout << buffIdx << std::endl;
|
|
||||||
switch(buffIdx){
|
switch(buffIdx){
|
||||||
case 0:
|
case 0:
|
||||||
|
std::cout << buffer1.size() << std::endl;
|
||||||
dis->vectorToTexture(&buffer1);
|
dis->vectorToTexture(&buffer1);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
|
std::cout << buffer2.size() << std::endl;
|
||||||
dis->vectorToTexture(&buffer2);
|
dis->vectorToTexture(&buffer2);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
|
std::cout << buffer3.size() << std::endl;
|
||||||
dis->vectorToTexture(&buffer3);
|
dis->vectorToTexture(&buffer3);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -32,11 +32,18 @@ void windowFlipThread(Displayer * displayerPtr){
|
|||||||
displayerPtr->flipThroughTextures();
|
displayerPtr->flipThroughTextures();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WrapperBufferToDisplay(Receiver ** receiverPtr){
|
||||||
|
(*receiverPtr)->bufferToDisplay();
|
||||||
|
}
|
||||||
|
|
||||||
void receiverLoop(Receiver ** receiverPtr){
|
void receiverLoop(Receiver ** receiverPtr){
|
||||||
|
std::vector<std::thread> displayThreads;
|
||||||
while(1){
|
while(1){
|
||||||
|
|
||||||
(*receiverPtr)->fillBuffer();
|
(*receiverPtr)->fillBuffer();
|
||||||
(*receiverPtr)->bufferToDisplay();
|
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(3));
|
std::thread t2(WrapperBufferToDisplay, receiverPtr);
|
||||||
|
t2.detach();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,4 +15,5 @@
|
|||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
#define CDC_FRAME_SIZE 50
|
#define CDC_FRAME_SIZE 64
|
||||||
|
#define CDC_FRAME_DELAY 1
|
||||||
|
Reference in New Issue
Block a user