Camera_driver: add image data export to RS-485 interface

Camera_driver
Petr Malanik 2 years ago
parent 9ce15191d3
commit cd0af22b26

@ -37,29 +37,32 @@ Mcu.IP3=RCC
Mcu.IP4=SPI1
Mcu.IP5=SYS
Mcu.IP6=USART1
Mcu.IPNb=7
Mcu.IP7=USART3
Mcu.IPNb=8
Mcu.Name=STM32L452C(C-E)Ux
Mcu.Package=UFQFPN48
Mcu.Pin0=PA0
Mcu.Pin1=PA1
Mcu.Pin10=PA9
Mcu.Pin11=PA10
Mcu.Pin12=PA13 (JTMS/SWDIO)
Mcu.Pin13=PA14 (JTCK/SWCLK)
Mcu.Pin14=PA15 (JTDI)
Mcu.Pin15=PH3-BOOT0 (BOOT0)
Mcu.Pin16=PB8
Mcu.Pin17=PB9
Mcu.Pin18=VP_SYS_VS_Systick
Mcu.Pin10=PB15
Mcu.Pin11=PA8
Mcu.Pin12=PA9
Mcu.Pin13=PA10
Mcu.Pin14=PA13 (JTMS/SWDIO)
Mcu.Pin15=PA14 (JTCK/SWCLK)
Mcu.Pin16=PA15 (JTDI)
Mcu.Pin17=PH3-BOOT0 (BOOT0)
Mcu.Pin18=PB8
Mcu.Pin19=PB9
Mcu.Pin2=PA2
Mcu.Pin20=VP_SYS_VS_Systick
Mcu.Pin3=PA4
Mcu.Pin4=PA5
Mcu.Pin5=PA6
Mcu.Pin6=PA7
Mcu.Pin7=PB0
Mcu.Pin8=PB15
Mcu.Pin9=PA8
Mcu.PinsNb=19
Mcu.Pin8=PB10
Mcu.Pin9=PB11
Mcu.PinsNb=21
Mcu.ThirdPartyNb=0
Mcu.UserConstants=
Mcu.UserName=STM32L452CEUx
@ -133,6 +136,10 @@ PB0.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH
PB0.Locked=true
PB0.PinState=GPIO_PIN_RESET
PB0.Signal=GPIO_Output
PB10.Mode=Asynchronous
PB10.Signal=USART3_TX
PB11.Mode=Asynchronous
PB11.Signal=USART3_RX
PB15.GPIOParameters=GPIO_PuPd,GPIO_Label
PB15.GPIO_Label=LED1
PB15.GPIO_PuPd=GPIO_PULLUP
@ -230,6 +237,8 @@ SPI1.Mode=SPI_MODE_MASTER
SPI1.VirtualType=VM_MASTER
USART1.IPParameters=VirtualMode-Asynchronous
USART1.VirtualMode-Asynchronous=VM_ASYNC
USART3.IPParameters=VirtualMode-Asynchronous
USART3.VirtualMode-Asynchronous=VM_ASYNC
VP_SYS_VS_Systick.Mode=SysTick
VP_SYS_VS_Systick.Signal=SYS_VS_Systick
board=custom

@ -1,5 +1,5 @@
##########################################################################################################################
# File automatically-generated by tool: [projectgenerator] version: [3.18.0-B7] date: [Mon Jan 23 18:29:42 CET 2023]
# File automatically-generated by tool: [projectgenerator] version: [3.18.0-B7] date: [Mon Jan 23 20:27:29 CET 2023]
##########################################################################################################################
# ------------------------------------------------

@ -50,6 +50,7 @@ DMA_HandleTypeDef hdma_spi1_rx;
DMA_HandleTypeDef hdma_spi1_tx;
UART_HandleTypeDef huart1;
UART_HandleTypeDef huart3;
/* USER CODE BEGIN PV */
@ -62,6 +63,7 @@ static void MX_DMA_Init(void);
static void MX_I2C1_Init(void);
static void MX_SPI1_Init(void);
static void MX_USART1_UART_Init(void);
static void MX_USART3_UART_Init(void);
/* USER CODE BEGIN PFP */
/* USER CODE END PFP */
@ -89,23 +91,28 @@ void Image_capture(OV2640 *camera, ButCube_imager *transmitter){
int main(void){
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_DMA_Init();
MX_I2C1_Init();
MX_SPI1_Init();
MX_USART1_UART_Init();
MX_USART3_UART_Init();
/* USER CODE BEGIN 2 */
// Initialize SPI clock
@ -123,6 +130,7 @@ int main(void){
ButCube_imager *transmitter = new ButCube_imager();
transmitter->Add_output(huart1);
transmitter->Add_output(huart3);
transmitter->Camera_power(true);
// Wait for power rail to stabilize
@ -131,10 +139,12 @@ int main(void){
OV2640 *camera = new OV2640(hi2c1, 0x60, hspi1, SPI_camera::Chip_select_pin{ GPIOB, GPIO_PIN_0 });
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1) {
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
Image_capture(camera, transmitter);
}
@ -296,6 +306,37 @@ static void MX_USART1_UART_Init(void){
/* USER CODE END USART1_Init 2 */
}
/**
* @brief USART3 Initialization Function
* @param None
* @retval None
*/
static void MX_USART3_UART_Init(void){
/* USER CODE BEGIN USART3_Init 0 */
/* USER CODE END USART3_Init 0 */
/* USER CODE BEGIN USART3_Init 1 */
/* USER CODE END USART3_Init 1 */
huart3.Instance = USART3;
huart3.Init.BaudRate = 115200;
huart3.Init.WordLength = UART_WORDLENGTH_8B;
huart3.Init.StopBits = UART_STOPBITS_1;
huart3.Init.Parity = UART_PARITY_NONE;
huart3.Init.Mode = UART_MODE_TX_RX;
huart3.Init.HwFlowCtl = UART_HWCONTROL_NONE;
huart3.Init.OverSampling = UART_OVERSAMPLING_16;
huart3.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
huart3.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
if (HAL_UART_Init(&huart3) != HAL_OK) {
Error_Handler();
}
/* USER CODE BEGIN USART3_Init 2 */
/* USER CODE END USART3_Init 2 */
}
/**
* Enable DMA controller clock
*/

@ -305,6 +305,40 @@ void HAL_UART_MspInit(UART_HandleTypeDef* huart)
/* USER CODE END USART1_MspInit 1 */
}
else if(huart->Instance==USART3)
{
/* USER CODE BEGIN USART3_MspInit 0 */
/* USER CODE END USART3_MspInit 0 */
/** Initializes the peripherals clock
*/
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USART3;
PeriphClkInit.Usart3ClockSelection = RCC_USART3CLKSOURCE_PCLK1;
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)
{
Error_Handler();
}
/* Peripheral clock enable */
__HAL_RCC_USART3_CLK_ENABLE();
__HAL_RCC_GPIOB_CLK_ENABLE();
/**USART3 GPIO Configuration
PB10 ------> USART3_TX
PB11 ------> USART3_RX
*/
GPIO_InitStruct.Pin = GPIO_PIN_10|GPIO_PIN_11;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF7_USART3;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
/* USER CODE BEGIN USART3_MspInit 1 */
/* USER CODE END USART3_MspInit 1 */
}
}
@ -334,6 +368,24 @@ void HAL_UART_MspDeInit(UART_HandleTypeDef* huart)
/* USER CODE END USART1_MspDeInit 1 */
}
else if(huart->Instance==USART3)
{
/* USER CODE BEGIN USART3_MspDeInit 0 */
/* USER CODE END USART3_MspDeInit 0 */
/* Peripheral clock disable */
__HAL_RCC_USART3_CLK_DISABLE();
/**USART3 GPIO Configuration
PB10 ------> USART3_TX
PB11 ------> USART3_RX
*/
HAL_GPIO_DeInit(GPIOB, GPIO_PIN_10|GPIO_PIN_11);
/* USER CODE BEGIN USART3_MspDeInit 1 */
/* USER CODE END USART3_MspDeInit 1 */
}
}

Loading…
Cancel
Save