From 28345045bac3b0800053c19d6bb1ae8cad3129ff Mon Sep 17 00:00:00 2001 From: Petr Malanik Date: Mon, 23 Jan 2023 21:02:37 +0100 Subject: [PATCH] Camera_driver: fix camera power control --- resources/FC_camera/App/butcube_imager.cpp | 2 +- resources/FC_camera/Camera_driver/OV2640.cpp | 2 +- resources/FC_camera/FC_camera.ioc | 39 ++++++++------------ resources/FC_camera/Makefile | 2 +- resources/FC_camera/STM32L452CEUx_FLASH.ld | 2 +- resources/FC_camera/Src/main.c | 1 + 6 files changed, 20 insertions(+), 28 deletions(-) diff --git a/resources/FC_camera/App/butcube_imager.cpp b/resources/FC_camera/App/butcube_imager.cpp index eba1a72..bfbb96f 100644 --- a/resources/FC_camera/App/butcube_imager.cpp +++ b/resources/FC_camera/App/butcube_imager.cpp @@ -14,5 +14,5 @@ int ButCube_imager::Add_output(UART_HandleTypeDef uart_output){ } void ButCube_imager::Camera_power(bool state){ - HAL_GPIO_WritePin(GPIOB, CAMERA_CS_Pin, (GPIO_PinState)state); + HAL_GPIO_WritePin(GPIOA, CAMERA_EN_Pin, (GPIO_PinState)!state); } diff --git a/resources/FC_camera/Camera_driver/OV2640.cpp b/resources/FC_camera/Camera_driver/OV2640.cpp index e9fdbb7..ba4a2a8 100644 --- a/resources/FC_camera/Camera_driver/OV2640.cpp +++ b/resources/FC_camera/Camera_driver/OV2640.cpp @@ -47,7 +47,7 @@ void OV2640::Capture(){ ArduChip_start_DMA_transfer(image_size); // while(SPI_handle.State != HAL_SPI_STATE_READY){;} - HAL_Delay(300); // delay to ensure full dma transmission + HAL_Delay(500); // delay to ensure full dma transmission ArduChip_CS_disable(); diff --git a/resources/FC_camera/FC_camera.ioc b/resources/FC_camera/FC_camera.ioc index ef99cf3..7534110 100644 --- a/resources/FC_camera/FC_camera.ioc +++ b/resources/FC_camera/FC_camera.ioc @@ -37,32 +37,29 @@ Mcu.IP3=RCC Mcu.IP4=SPI1 Mcu.IP5=SYS Mcu.IP6=USART1 -Mcu.IP7=USART3 -Mcu.IPNb=8 +Mcu.IPNb=7 Mcu.Name=STM32L452C(C-E)Ux Mcu.Package=UFQFPN48 Mcu.Pin0=PA0 Mcu.Pin1=PA1 -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.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.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=PB10 -Mcu.Pin9=PB11 -Mcu.PinsNb=21 +Mcu.Pin8=PB15 +Mcu.Pin9=PA8 +Mcu.PinsNb=19 Mcu.ThirdPartyNb=0 Mcu.UserConstants= Mcu.UserName=STM32L452CEUx @@ -136,10 +133,6 @@ 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 @@ -168,7 +161,7 @@ ProjectManager.DeviceId=STM32L452CEUx ProjectManager.FirmwarePackage=STM32Cube FW_L4 V1.17.2 ProjectManager.FreePins=false ProjectManager.HalAssertFull=false -ProjectManager.HeapSize=0x400 +ProjectManager.HeapSize=0x2000 ProjectManager.KeepUserCode=true ProjectManager.LastFirmware=true ProjectManager.LibraryCopy=0 @@ -183,7 +176,7 @@ ProjectManager.StackSize=0x800 ProjectManager.TargetToolchain=Makefile ProjectManager.ToolChainLocation= ProjectManager.UnderRoot=false -ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_DMA_Init-DMA-false-HAL-true,4-MX_I2C1_Init-I2C1-false-HAL-true,5-MX_SPI1_Init-SPI1-false-HAL-true,6-MX_USART1_UART_Init-USART1-false-HAL-true +ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_DMA_Init-DMA-false-HAL-true,4-MX_I2C1_Init-I2C1-false-HAL-true,5-MX_SPI1_Init-SPI1-false-HAL-true,6-MX_USART1_UART_Init-USART1-false-HAL-true,7-MX_USART3_UART_Init-USART3-false-HAL-true RCC.AHBFreq_Value=80000000 RCC.APB1Freq_Value=80000000 RCC.APB1TimFreq_Value=80000000 @@ -237,8 +230,6 @@ 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 diff --git a/resources/FC_camera/Makefile b/resources/FC_camera/Makefile index 9ac6063..d1c738c 100644 --- a/resources/FC_camera/Makefile +++ b/resources/FC_camera/Makefile @@ -1,5 +1,5 @@ ########################################################################################################################## -# File automatically-generated by tool: [projectgenerator] version: [3.18.0-B7] date: [Mon Jan 23 20:27:29 CET 2023] +# File automatically-generated by tool: [projectgenerator] version: [3.18.0-B7] date: [Mon Jan 23 20:54:47 CET 2023] ########################################################################################################################## # ------------------------------------------------ diff --git a/resources/FC_camera/STM32L452CEUx_FLASH.ld b/resources/FC_camera/STM32L452CEUx_FLASH.ld index 81445c4..55af456 100644 --- a/resources/FC_camera/STM32L452CEUx_FLASH.ld +++ b/resources/FC_camera/STM32L452CEUx_FLASH.ld @@ -55,7 +55,7 @@ ENTRY(Reset_Handler) /* Highest address of the user mode stack */ _estack = ORIGIN(RAM) + LENGTH(RAM); /* end of RAM */ /* Generate a link error if heap and stack don't fit into RAM */ -_Min_Heap_Size = 0x400; /* required amount of heap */ +_Min_Heap_Size = 0x2000; /* required amount of heap */ _Min_Stack_Size = 0x800; /* required amount of stack */ /* Specify the memory areas */ diff --git a/resources/FC_camera/Src/main.c b/resources/FC_camera/Src/main.c index 6a4a764..742ac14 100644 --- a/resources/FC_camera/Src/main.c +++ b/resources/FC_camera/Src/main.c @@ -80,6 +80,7 @@ void Image_capture(OV2640 *camera, ButCube_imager *transmitter){ camera->Capture(); transmitter->Transmit(camera->Image_data()); + HAL_Delay(1000); } /* USER CODE END 0 */