Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
红岛
rt-thread
提交
da0164cf
R
rt-thread
项目概览
红岛
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rt-thread
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
da0164cf
编写于
4月 13, 2022
作者:
M
Miaowulue
提交者:
guo
4月 15, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[bsp/stm32] add ov5640、dcmi、i2c for openmv
上级
7919642a
变更
15
展开全部
隐藏空白更改
内联
并排
Showing
15 changed file
with
2244 addition
and
109 deletion
+2244
-109
bsp/stm32/stm32h743-openmv-h7plus/.config
bsp/stm32/stm32h743-openmv-h7plus/.config
+24
-6
bsp/stm32/stm32h743-openmv-h7plus/README.md
bsp/stm32/stm32h743-openmv-h7plus/README.md
+7
-8
bsp/stm32/stm32h743-openmv-h7plus/applications/main.c
bsp/stm32/stm32h743-openmv-h7plus/applications/main.c
+3
-1
bsp/stm32/stm32h743-openmv-h7plus/board/CubeMX_Config/Core/Inc/main.h
...m32h743-openmv-h7plus/board/CubeMX_Config/Core/Inc/main.h
+2
-0
bsp/stm32/stm32h743-openmv-h7plus/board/CubeMX_Config/Core/Inc/stm32h7xx_hal_conf.h
...-h7plus/board/CubeMX_Config/Core/Inc/stm32h7xx_hal_conf.h
+3
-3
bsp/stm32/stm32h743-openmv-h7plus/board/CubeMX_Config/Core/Inc/stm32h7xx_it.h
...openmv-h7plus/board/CubeMX_Config/Core/Inc/stm32h7xx_it.h
+2
-0
bsp/stm32/stm32h743-openmv-h7plus/board/CubeMX_Config/Core/Src/main.c
...m32h743-openmv-h7plus/board/CubeMX_Config/Core/Src/main.c
+137
-3
bsp/stm32/stm32h743-openmv-h7plus/board/CubeMX_Config/Core/Src/stm32h7xx_hal_msp.c
...v-h7plus/board/CubeMX_Config/Core/Src/stm32h7xx_hal_msp.c
+227
-1
bsp/stm32/stm32h743-openmv-h7plus/board/CubeMX_Config/CubeMX_Config.ioc
...2h743-openmv-h7plus/board/CubeMX_Config/CubeMX_Config.ioc
+210
-84
bsp/stm32/stm32h743-openmv-h7plus/board/Kconfig
bsp/stm32/stm32h743-openmv-h7plus/board/Kconfig
+50
-1
bsp/stm32/stm32h743-openmv-h7plus/board/SConscript
bsp/stm32/stm32h743-openmv-h7plus/board/SConscript
+7
-2
bsp/stm32/stm32h743-openmv-h7plus/board/ports/drv_dcmi.c
bsp/stm32/stm32h743-openmv-h7plus/board/ports/drv_dcmi.c
+210
-0
bsp/stm32/stm32h743-openmv-h7plus/board/ports/drv_ov5640.c
bsp/stm32/stm32h743-openmv-h7plus/board/ports/drv_ov5640.c
+694
-0
bsp/stm32/stm32h743-openmv-h7plus/board/ports/drv_ov5640.h
bsp/stm32/stm32h743-openmv-h7plus/board/ports/drv_ov5640.h
+653
-0
bsp/stm32/stm32h743-openmv-h7plus/rtconfig.h
bsp/stm32/stm32h743-openmv-h7plus/rtconfig.h
+15
-0
未找到文件。
bsp/stm32/stm32h743-openmv-h7plus/.config
浏览文件 @
da0164cf
...
...
@@ -29,7 +29,7 @@ CONFIG_IDLE_THREAD_STACK_SIZE=256
# CONFIG_RT_KSERVICE_USING_STDLIB is not set
# CONFIG_RT_KSERVICE_USING_TINY_SIZE is not set
# CONFIG_RT_USING_TINY_FFS is not set
# CONFIG_RT_
PRINTF
_LONGLONG is not set
# CONFIG_RT_
KPRINTF_USING
_LONGLONG is not set
CONFIG_RT_DEBUG
=
y
CONFIG_RT_DEBUG_COLOR
=
y
# CONFIG_RT_DEBUG_INIT_CONFIG is not set
...
...
@@ -157,7 +157,10 @@ CONFIG_RT_SERIAL_RB_BUFSZ=64
# CONFIG_RT_USING_CAN is not set
# CONFIG_RT_USING_HWTIMER is not set
# CONFIG_RT_USING_CPUTIME is not set
# CONFIG_RT_USING_I2C is not set
CONFIG_RT_USING_I2C
=
y
# CONFIG_RT_I2C_DEBUG is not set
CONFIG_RT_USING_I2C_BITOPS
=
y
# CONFIG_RT_I2C_BITOPS_DEBUG is not set
# CONFIG_RT_USING_PHY is not set
CONFIG_RT_USING_PIN
=
y
# CONFIG_RT_USING_ADC is not set
...
...
@@ -166,7 +169,9 @@ CONFIG_RT_USING_PIN=y
# CONFIG_RT_USING_MTD_NOR is not set
# CONFIG_RT_USING_MTD_NAND is not set
# CONFIG_RT_USING_PM is not set
# CONFIG_RT_USING_RTC is not set
CONFIG_RT_USING_RTC
=
y
# CONFIG_RT_USING_ALARM is not set
# CONFIG_RT_USING_SOFT_RTC is not set
CONFIG_RT_USING_SDIO
=
y
CONFIG_RT_SDIO_STACK_SIZE
=
512
CONFIG_RT_SDIO_THREAD_PRIORITY
=
15
...
...
@@ -561,6 +566,7 @@ CONFIG_RT_USING_POSIX_FS=y
# CONFIG_PKG_USING_TINYUSB is not set
# CONFIG_PKG_USING_CHERRYUSB is not set
# CONFIG_PKG_USING_KMULTI_RTIMER is not set
# CONFIG_PKG_USING_TFDB is not set
#
# peripheral libraries and drivers
...
...
@@ -732,7 +738,8 @@ CONFIG_BSP_USING_UART1=y
# CONFIG_BSP_UART1_RX_USING_DMA is not set
# CONFIG_BSP_USING_UART2 is not set
# CONFIG_BSP_USING_LPUART1 is not set
# CONFIG_BSP_USING_QSPI is not set
CONFIG_BSP_USING_QSPI
=
y
# CONFIG_BSP_USING_ONCHIP_RTC is not set
# CONFIG_BSP_USING_CRC is not set
# CONFIG_BSP_USING_RNG is not set
# CONFIG_BSP_USING_UDID is not set
...
...
@@ -741,6 +748,17 @@ CONFIG_BSP_USING_UART1=y
# Onboard Peripheral Drivers
#
CONFIG_BSP_USING_SDRAM
=
y
# CONFIG_BSP_USING_QSPI_FLASH is not set
CONFIG_BSP_USING_QSPI_FLASH
=
y
# CONFIG_BSP_USING_SDMMC is not set
# CONFIG_BSP_USING_USBD is not set
CONFIG_BSP_USING_USBD
=
y
CONFIG_BSP_USING_OV5640
=
y
CONFIG_BSP_USING_DCMI
=
y
CONFIG_BSP_USING_I2C
=
y
CONFIG_BSP_USING_I2C1
=
y
#
# Notice: PB8 --> 24; PB9 --> 25
#
CONFIG_BSP_I2C1_SCL_PIN
=
24
CONFIG_BSP_I2C1_SDA_PIN
=
25
# CONFIG_BSP_USING_I2C2 is not set
bsp/stm32/stm32h743-openmv-h7plus/README.md
浏览文件 @
da0164cf
...
...
@@ -43,6 +43,10 @@ OPENMV4-H7-PLUS 是 OPENMV公司推出的一款针对 STM32H7系列设计的 Cor
| QSPI FLASH | 支持 | W25Q256JV |
| SDIO | 支持 | USD-1040310811 |
| USBCDC | 支持 | |
| RTC | 支持 | |
| CAMERA | 支持 | OV5640 |
| DCMI | 支持 | |
| I2C | 支持 | I2C1(PB8 SCL)(PB9 SDA); I2C2 (PB10 SCL)(PB11 SDA) |
## 使用说明
...
...
@@ -84,24 +88,19 @@ OPENMV4-H7-PLUS 是 OPENMV公司推出的一款针对 STM32H7系列设计的 Cor
2006 - 2019 Copyright by rt-thread team
msh
>
```
注意:由于BSP默认开启USBCDC,与shell的交互需通过虚拟串口。
### 进阶使用
此 BSP 默认
只开启了 GPIO 和 LPUART1
的功能,如果需使用更多高级功能,需要利用 ENV 工具对BSP 进行配置,步骤如下:
此 BSP 默认
开启了 GPIO 、 USART1、QSPI FLASH、USBCDC和CAMERA
的功能,如果需使用更多高级功能,需要利用 ENV 工具对BSP 进行配置,步骤如下:
1.
在 bsp 下打开 env 工具。
2.
输入
`menuconfig`
命令配置工程,配置好之后保存退出。
3.
输入
`pkgs --update`
命令更新软件包。
4.
输入
`scons --target=mdk4/mdk5/iar`
命令重新生成工程。
本章节更多详细的介绍请参考
[
STM32 系列 BSP 外设驱动使用教程
](
../docs/STM32系列BSP外设驱动使用教程.md
)
。
5.
USBD CDC使用,参考文章
[
STM32L496 USB CDC适配
](
https://club.rt-thread.org/ask/article/2959.html
)
(bsp已配置引脚和修改Kconfig)
## 注意事项
-
开机时如果不能打印 RT-Thread 版本信息,请重新选择 PC 端串口调试软件的串口号或将 BSP 中串口的 GPIO 速率调低
...
...
bsp/stm32/stm32h743-openmv-h7plus/applications/main.c
浏览文件 @
da0164cf
...
...
@@ -18,7 +18,9 @@ int main(void)
{
/* set LED2 pin mode to output */
rt_pin_mode
(
LED1_PIN
,
PIN_MODE_OUTPUT
);
#ifdef BSP_USING_USBD
rt_console_set_device
(
"vcom"
);
#endif
while
(
1
)
{
rt_pin_write
(
LED1_PIN
,
PIN_HIGH
);
...
...
bsp/stm32/stm32h743-openmv-h7plus/board/CubeMX_Config/Core/Inc/main.h
浏览文件 @
da0164cf
...
...
@@ -49,6 +49,8 @@ extern "C" {
/* USER CODE END EM */
void
HAL_TIM_MspPostInit
(
TIM_HandleTypeDef
*
htim
);
/* Exported functions prototypes ---------------------------------------------*/
void
Error_Handler
(
void
);
...
...
bsp/stm32/stm32h743-openmv-h7plus/board/CubeMX_Config/Core/Inc/stm32h7xx_hal_conf.h
浏览文件 @
da0164cf
...
...
@@ -43,7 +43,7 @@
/* #define HAL_CRC_MODULE_ENABLED */
/* #define HAL_CRYP_MODULE_ENABLED */
/* #define HAL_DAC_MODULE_ENABLED */
/* #define HAL_DCMI_MODULE_ENABLED */
#define HAL_DCMI_MODULE_ENABLED
/* #define HAL_DMA2D_MODULE_ENABLED */
/* #define HAL_ETH_MODULE_ENABLED */
/* #define HAL_NAND_MODULE_ENABLED */
...
...
@@ -74,7 +74,7 @@
/* #define HAL_SPDIFRX_MODULE_ENABLED */
/* #define HAL_SPI_MODULE_ENABLED */
/* #define HAL_SWPMI_MODULE_ENABLED */
/* #define HAL_TIM_MODULE_ENABLED */
#define HAL_TIM_MODULE_ENABLED
#define HAL_UART_MODULE_ENABLED
/* #define HAL_USART_MODULE_ENABLED */
/* #define HAL_IRDA_MODULE_ENABLED */
...
...
@@ -168,7 +168,7 @@
#define TICK_INT_PRIORITY (15UL)
/*!< tick interrupt priority */
#define USE_RTOS 0
#define USE_SD_TRANSCEIVER 0U
/*!< use uSD Transceiver */
#define USE_SPI_CRC
0U
/*!< use CRC in SPI */
#define USE_SPI_CRC
0U
/*!< use CRC in SPI */
#define USE_HAL_ADC_REGISTER_CALLBACKS 0U
/* ADC register callback disabled */
#define USE_HAL_CEC_REGISTER_CALLBACKS 0U
/* CEC register callback disabled */
...
...
bsp/stm32/stm32h743-openmv-h7plus/board/CubeMX_Config/Core/Inc/stm32h7xx_it.h
浏览文件 @
da0164cf
...
...
@@ -55,7 +55,9 @@ void SVC_Handler(void);
void
DebugMon_Handler
(
void
);
void
PendSV_Handler
(
void
);
void
SysTick_Handler
(
void
);
void
DMA1_Stream3_IRQHandler
(
void
);
void
SDMMC1_IRQHandler
(
void
);
void
DCMI_IRQHandler
(
void
);
void
OTG_FS_EP1_OUT_IRQHandler
(
void
);
void
OTG_FS_EP1_IN_IRQHandler
(
void
);
/* USER CODE BEGIN EFP */
...
...
bsp/stm32/stm32h743-openmv-h7plus/board/CubeMX_Config/Core/Src/main.c
浏览文件 @
da0164cf
...
...
@@ -40,12 +40,17 @@
/* Private variables ---------------------------------------------------------*/
DCMI_HandleTypeDef
hdcmi
;
DMA_HandleTypeDef
hdma_dcmi
;
QSPI_HandleTypeDef
hqspi
;
RTC_HandleTypeDef
hrtc
;
SD_HandleTypeDef
hsd1
;
TIM_HandleTypeDef
htim1
;
UART_HandleTypeDef
huart1
;
PCD_HandleTypeDef
hpcd_USB_OTG_FS
;
...
...
@@ -63,8 +68,11 @@ static void MX_USART1_UART_Init(void);
static
void
MX_FMC_Init
(
void
);
static
void
MX_QUADSPI_Init
(
void
);
static
void
MX_SDMMC1_SD_Init
(
void
);
static
void
MX_
USB_OTG_FS_PCD
_Init
(
void
);
static
void
MX_
DMA
_Init
(
void
);
static
void
MX_RTC_Init
(
void
);
static
void
MX_DCMI_Init
(
void
);
static
void
MX_USB_OTG_FS_PCD_Init
(
void
);
static
void
MX_TIM1_Init
(
void
);
/* USER CODE BEGIN PFP */
/* USER CODE END PFP */
...
...
@@ -112,8 +120,11 @@ int main(void)
MX_FMC_Init
();
MX_QUADSPI_Init
();
MX_SDMMC1_SD_Init
();
MX_
USB_OTG_FS_PCD
_Init
();
MX_
DMA
_Init
();
MX_RTC_Init
();
MX_DCMI_Init
();
MX_USB_OTG_FS_PCD_Init
();
MX_TIM1_Init
();
/* USER CODE BEGIN 2 */
/* USER CODE END 2 */
...
...
@@ -187,6 +198,43 @@ void SystemClock_Config(void)
}
}
/**
* @brief DCMI Initialization Function
* @param None
* @retval None
*/
static
void
MX_DCMI_Init
(
void
)
{
/* USER CODE BEGIN DCMI_Init 0 */
/* USER CODE END DCMI_Init 0 */
/* USER CODE BEGIN DCMI_Init 1 */
/* USER CODE END DCMI_Init 1 */
hdcmi
.
Instance
=
DCMI
;
hdcmi
.
Init
.
SynchroMode
=
DCMI_SYNCHRO_HARDWARE
;
hdcmi
.
Init
.
PCKPolarity
=
DCMI_PCKPOLARITY_FALLING
;
hdcmi
.
Init
.
VSPolarity
=
DCMI_VSPOLARITY_LOW
;
hdcmi
.
Init
.
HSPolarity
=
DCMI_HSPOLARITY_LOW
;
hdcmi
.
Init
.
CaptureRate
=
DCMI_CR_ALL_FRAME
;
hdcmi
.
Init
.
ExtendedDataMode
=
DCMI_EXTEND_DATA_8B
;
hdcmi
.
Init
.
JPEGMode
=
DCMI_JPEG_ENABLE
;
hdcmi
.
Init
.
ByteSelectMode
=
DCMI_BSM_ALL
;
hdcmi
.
Init
.
ByteSelectStart
=
DCMI_OEBS_ODD
;
hdcmi
.
Init
.
LineSelectMode
=
DCMI_LSM_ALL
;
hdcmi
.
Init
.
LineSelectStart
=
DCMI_OELS_ODD
;
if
(
HAL_DCMI_Init
(
&
hdcmi
)
!=
HAL_OK
)
{
Error_Handler
();
}
/* USER CODE BEGIN DCMI_Init 2 */
/* USER CODE END DCMI_Init 2 */
}
/**
* @brief QUADSPI Initialization Function
* @param None
...
...
@@ -316,6 +364,76 @@ static void MX_SDMMC1_SD_Init(void)
}
/**
* @brief TIM1 Initialization Function
* @param None
* @retval None
*/
static
void
MX_TIM1_Init
(
void
)
{
/* USER CODE BEGIN TIM1_Init 0 */
/* USER CODE END TIM1_Init 0 */
TIM_MasterConfigTypeDef
sMasterConfig
=
{
0
};
TIM_OC_InitTypeDef
sConfigOC
=
{
0
};
TIM_BreakDeadTimeConfigTypeDef
sBreakDeadTimeConfig
=
{
0
};
/* USER CODE BEGIN TIM1_Init 1 */
/* USER CODE END TIM1_Init 1 */
htim1
.
Instance
=
TIM1
;
htim1
.
Init
.
Prescaler
=
0
;
htim1
.
Init
.
CounterMode
=
TIM_COUNTERMODE_UP
;
htim1
.
Init
.
Period
=
7
;
htim1
.
Init
.
ClockDivision
=
TIM_CLOCKDIVISION_DIV1
;
htim1
.
Init
.
RepetitionCounter
=
0
;
htim1
.
Init
.
AutoReloadPreload
=
TIM_AUTORELOAD_PRELOAD_ENABLE
;
if
(
HAL_TIM_PWM_Init
(
&
htim1
)
!=
HAL_OK
)
{
Error_Handler
();
}
sMasterConfig
.
MasterOutputTrigger
=
TIM_TRGO_RESET
;
sMasterConfig
.
MasterOutputTrigger2
=
TIM_TRGO2_RESET
;
sMasterConfig
.
MasterSlaveMode
=
TIM_MASTERSLAVEMODE_DISABLE
;
if
(
HAL_TIMEx_MasterConfigSynchronization
(
&
htim1
,
&
sMasterConfig
)
!=
HAL_OK
)
{
Error_Handler
();
}
sConfigOC
.
OCMode
=
TIM_OCMODE_PWM1
;
sConfigOC
.
Pulse
=
3
;
sConfigOC
.
OCPolarity
=
TIM_OCPOLARITY_HIGH
;
sConfigOC
.
OCNPolarity
=
TIM_OCNPOLARITY_HIGH
;
sConfigOC
.
OCFastMode
=
TIM_OCFAST_DISABLE
;
sConfigOC
.
OCIdleState
=
TIM_OCIDLESTATE_RESET
;
sConfigOC
.
OCNIdleState
=
TIM_OCNIDLESTATE_RESET
;
if
(
HAL_TIM_PWM_ConfigChannel
(
&
htim1
,
&
sConfigOC
,
TIM_CHANNEL_1
)
!=
HAL_OK
)
{
Error_Handler
();
}
sBreakDeadTimeConfig
.
OffStateRunMode
=
TIM_OSSR_DISABLE
;
sBreakDeadTimeConfig
.
OffStateIDLEMode
=
TIM_OSSI_DISABLE
;
sBreakDeadTimeConfig
.
LockLevel
=
TIM_LOCKLEVEL_OFF
;
sBreakDeadTimeConfig
.
DeadTime
=
0
;
sBreakDeadTimeConfig
.
BreakState
=
TIM_BREAK_DISABLE
;
sBreakDeadTimeConfig
.
BreakPolarity
=
TIM_BREAKPOLARITY_HIGH
;
sBreakDeadTimeConfig
.
BreakFilter
=
0
;
sBreakDeadTimeConfig
.
Break2State
=
TIM_BREAK2_DISABLE
;
sBreakDeadTimeConfig
.
Break2Polarity
=
TIM_BREAK2POLARITY_HIGH
;
sBreakDeadTimeConfig
.
Break2Filter
=
0
;
sBreakDeadTimeConfig
.
AutomaticOutput
=
TIM_AUTOMATICOUTPUT_DISABLE
;
if
(
HAL_TIMEx_ConfigBreakDeadTime
(
&
htim1
,
&
sBreakDeadTimeConfig
)
!=
HAL_OK
)
{
Error_Handler
();
}
/* USER CODE BEGIN TIM1_Init 2 */
/* USER CODE END TIM1_Init 2 */
HAL_TIM_MspPostInit
(
&
htim1
);
}
/**
* @brief USART1 Initialization Function
* @param None
...
...
@@ -400,6 +518,22 @@ static void MX_USB_OTG_FS_PCD_Init(void)
}
/**
* Enable DMA controller clock
*/
static
void
MX_DMA_Init
(
void
)
{
/* DMA controller clock enable */
__HAL_RCC_DMA1_CLK_ENABLE
();
/* DMA interrupt init */
/* DMA1_Stream3_IRQn interrupt configuration */
HAL_NVIC_SetPriority
(
DMA1_Stream3_IRQn
,
0
,
0
);
HAL_NVIC_EnableIRQ
(
DMA1_Stream3_IRQn
);
}
/* FMC initialization function */
static
void
MX_FMC_Init
(
void
)
{
...
...
@@ -459,13 +593,13 @@ static void MX_GPIO_Init(void)
/* GPIO Ports Clock Enable */
__HAL_RCC_GPIOE_CLK_ENABLE
();
__HAL_RCC_GPIOC_CLK_ENABLE
();
__HAL_RCC_GPIOB_CLK_ENABLE
();
__HAL_RCC_GPIOG_CLK_ENABLE
();
__HAL_RCC_GPIOD_CLK_ENABLE
();
__HAL_RCC_GPIOA_CLK_ENABLE
();
__HAL_RCC_GPIOI_CLK_ENABLE
();
__HAL_RCC_GPIOH_CLK_ENABLE
();
__HAL_RCC_GPIOF_CLK_ENABLE
();
__HAL_RCC_GPIOB_CLK_ENABLE
();
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin
(
LED_RED_GPIO_Port
,
LED_RED_Pin
,
GPIO_PIN_RESET
);
...
...
bsp/stm32/stm32h743-openmv-h7plus/board/CubeMX_Config/Core/Src/stm32h7xx_hal_msp.c
浏览文件 @
da0164cf
...
...
@@ -25,6 +25,7 @@
#include "drv_common.h"
#endif
/* USER CODE END Includes */
extern
DMA_HandleTypeDef
hdma_dcmi
;
/* Private typedef -----------------------------------------------------------*/
/* USER CODE BEGIN TD */
...
...
@@ -59,7 +60,9 @@
/* USER CODE BEGIN 0 */
/* USER CODE END 0 */
/**
void
HAL_TIM_MspPostInit
(
TIM_HandleTypeDef
*
htim
);
/**
* Initializes the Global MSP.
*/
void
HAL_MspInit
(
void
)
...
...
@@ -77,6 +80,159 @@ void HAL_MspInit(void)
/* USER CODE END MspInit 1 */
}
/**
* @brief DCMI MSP Initialization
* This function configures the hardware resources used in this example
* @param hdcmi: DCMI handle pointer
* @retval None
*/
void
HAL_DCMI_MspInit
(
DCMI_HandleTypeDef
*
hdcmi
)
{
GPIO_InitTypeDef
GPIO_InitStruct
=
{
0
};
if
(
hdcmi
->
Instance
==
DCMI
)
{
/* USER CODE BEGIN DCMI_MspInit 0 */
/* USER CODE END DCMI_MspInit 0 */
/* Peripheral clock enable */
__HAL_RCC_DCMI_CLK_ENABLE
();
__HAL_RCC_GPIOE_CLK_ENABLE
();
__HAL_RCC_GPIOB_CLK_ENABLE
();
__HAL_RCC_GPIOG_CLK_ENABLE
();
__HAL_RCC_GPIOC_CLK_ENABLE
();
__HAL_RCC_GPIOA_CLK_ENABLE
();
/**DCMI GPIO Configuration
PE4 ------> DCMI_D4
PE5 ------> DCMI_D6
PE6 ------> DCMI_D7
PB7 ------> DCMI_VSYNC
PB6 ------> DCMI_D5
PG11 ------> DCMI_D3
PG10 ------> DCMI_D2
PC7 ------> DCMI_D1
PC6 ------> DCMI_D0
PA4 ------> DCMI_HSYNC
PA6 ------> DCMI_PIXCLK
*/
GPIO_InitStruct
.
Pin
=
GPIO_PIN_4
|
GPIO_PIN_5
|
GPIO_PIN_6
;
GPIO_InitStruct
.
Mode
=
GPIO_MODE_AF_PP
;
GPIO_InitStruct
.
Pull
=
GPIO_PULLUP
;
GPIO_InitStruct
.
Speed
=
GPIO_SPEED_FREQ_HIGH
;
GPIO_InitStruct
.
Alternate
=
GPIO_AF13_DCMI
;
HAL_GPIO_Init
(
GPIOE
,
&
GPIO_InitStruct
);
GPIO_InitStruct
.
Pin
=
GPIO_PIN_7
|
GPIO_PIN_6
;
GPIO_InitStruct
.
Mode
=
GPIO_MODE_AF_PP
;
GPIO_InitStruct
.
Pull
=
GPIO_PULLUP
;
GPIO_InitStruct
.
Speed
=
GPIO_SPEED_FREQ_HIGH
;
GPIO_InitStruct
.
Alternate
=
GPIO_AF13_DCMI
;
HAL_GPIO_Init
(
GPIOB
,
&
GPIO_InitStruct
);
GPIO_InitStruct
.
Pin
=
GPIO_PIN_11
|
GPIO_PIN_10
;
GPIO_InitStruct
.
Mode
=
GPIO_MODE_AF_PP
;
GPIO_InitStruct
.
Pull
=
GPIO_PULLUP
;
GPIO_InitStruct
.
Speed
=
GPIO_SPEED_FREQ_HIGH
;
GPIO_InitStruct
.
Alternate
=
GPIO_AF13_DCMI
;
HAL_GPIO_Init
(
GPIOG
,
&
GPIO_InitStruct
);
GPIO_InitStruct
.
Pin
=
GPIO_PIN_7
|
GPIO_PIN_6
;
GPIO_InitStruct
.
Mode
=
GPIO_MODE_AF_PP
;
GPIO_InitStruct
.
Pull
=
GPIO_PULLUP
;
GPIO_InitStruct
.
Speed
=
GPIO_SPEED_FREQ_HIGH
;
GPIO_InitStruct
.
Alternate
=
GPIO_AF13_DCMI
;
HAL_GPIO_Init
(
GPIOC
,
&
GPIO_InitStruct
);
GPIO_InitStruct
.
Pin
=
GPIO_PIN_4
|
GPIO_PIN_6
;
GPIO_InitStruct
.
Mode
=
GPIO_MODE_AF_PP
;
GPIO_InitStruct
.
Pull
=
GPIO_PULLUP
;
GPIO_InitStruct
.
Speed
=
GPIO_SPEED_FREQ_HIGH
;
GPIO_InitStruct
.
Alternate
=
GPIO_AF13_DCMI
;
HAL_GPIO_Init
(
GPIOA
,
&
GPIO_InitStruct
);
/* DCMI DMA Init */
/* DCMI Init */
hdma_dcmi
.
Instance
=
DMA1_Stream3
;
hdma_dcmi
.
Init
.
Request
=
DMA_REQUEST_DCMI
;
hdma_dcmi
.
Init
.
Direction
=
DMA_PERIPH_TO_MEMORY
;
hdma_dcmi
.
Init
.
PeriphInc
=
DMA_PINC_DISABLE
;
hdma_dcmi
.
Init
.
MemInc
=
DMA_MINC_ENABLE
;
hdma_dcmi
.
Init
.
PeriphDataAlignment
=
DMA_PDATAALIGN_WORD
;
hdma_dcmi
.
Init
.
MemDataAlignment
=
DMA_MDATAALIGN_WORD
;
hdma_dcmi
.
Init
.
Mode
=
DMA_CIRCULAR
;
hdma_dcmi
.
Init
.
Priority
=
DMA_PRIORITY_HIGH
;
hdma_dcmi
.
Init
.
FIFOMode
=
DMA_FIFOMODE_ENABLE
;
hdma_dcmi
.
Init
.
FIFOThreshold
=
DMA_FIFO_THRESHOLD_FULL
;
hdma_dcmi
.
Init
.
MemBurst
=
DMA_MBURST_SINGLE
;
hdma_dcmi
.
Init
.
PeriphBurst
=
DMA_PBURST_SINGLE
;
if
(
HAL_DMA_Init
(
&
hdma_dcmi
)
!=
HAL_OK
)
{
Error_Handler
();
}
__HAL_LINKDMA
(
hdcmi
,
DMA_Handle
,
hdma_dcmi
);
/* DCMI interrupt Init */
HAL_NVIC_SetPriority
(
DCMI_IRQn
,
0
,
0
);
HAL_NVIC_EnableIRQ
(
DCMI_IRQn
);
/* USER CODE BEGIN DCMI_MspInit 1 */
/* USER CODE END DCMI_MspInit 1 */
}
}
/**
* @brief DCMI MSP De-Initialization
* This function freeze the hardware resources used in this example
* @param hdcmi: DCMI handle pointer
* @retval None
*/
void
HAL_DCMI_MspDeInit
(
DCMI_HandleTypeDef
*
hdcmi
)
{
if
(
hdcmi
->
Instance
==
DCMI
)
{
/* USER CODE BEGIN DCMI_MspDeInit 0 */
/* USER CODE END DCMI_MspDeInit 0 */
/* Peripheral clock disable */
__HAL_RCC_DCMI_CLK_DISABLE
();
/**DCMI GPIO Configuration
PE4 ------> DCMI_D4
PE5 ------> DCMI_D6
PE6 ------> DCMI_D7
PB7 ------> DCMI_VSYNC
PB6 ------> DCMI_D5
PG11 ------> DCMI_D3
PG10 ------> DCMI_D2
PC7 ------> DCMI_D1
PC6 ------> DCMI_D0
PA4 ------> DCMI_HSYNC
PA6 ------> DCMI_PIXCLK
*/
HAL_GPIO_DeInit
(
GPIOE
,
GPIO_PIN_4
|
GPIO_PIN_5
|
GPIO_PIN_6
);
HAL_GPIO_DeInit
(
GPIOB
,
GPIO_PIN_7
|
GPIO_PIN_6
);
HAL_GPIO_DeInit
(
GPIOG
,
GPIO_PIN_11
|
GPIO_PIN_10
);
HAL_GPIO_DeInit
(
GPIOC
,
GPIO_PIN_7
|
GPIO_PIN_6
);
HAL_GPIO_DeInit
(
GPIOA
,
GPIO_PIN_4
|
GPIO_PIN_6
);
/* DCMI DMA DeInit */
HAL_DMA_DeInit
(
hdcmi
->
DMA_Handle
);
/* DCMI interrupt DeInit */
HAL_NVIC_DisableIRQ
(
DCMI_IRQn
);
/* USER CODE BEGIN DCMI_MspDeInit 1 */
/* USER CODE END DCMI_MspDeInit 1 */
}
}
/**
* @brief QSPI MSP Initialization
* This function configures the hardware resources used in this example
...
...
@@ -332,6 +488,76 @@ void HAL_SD_MspDeInit(SD_HandleTypeDef* hsd)
}
/**
* @brief TIM_PWM MSP Initialization
* This function configures the hardware resources used in this example
* @param htim_pwm: TIM_PWM handle pointer
* @retval None
*/
void
HAL_TIM_PWM_MspInit
(
TIM_HandleTypeDef
*
htim_pwm
)
{
if
(
htim_pwm
->
Instance
==
TIM1
)
{
/* USER CODE BEGIN TIM1_MspInit 0 */
/* USER CODE END TIM1_MspInit 0 */
/* Peripheral clock enable */
__HAL_RCC_TIM1_CLK_ENABLE
();
/* USER CODE BEGIN TIM1_MspInit 1 */
/* USER CODE END TIM1_MspInit 1 */
}
}
void
HAL_TIM_MspPostInit
(
TIM_HandleTypeDef
*
htim
)
{
GPIO_InitTypeDef
GPIO_InitStruct
=
{
0
};
if
(
htim
->
Instance
==
TIM1
)
{
/* USER CODE BEGIN TIM1_MspPostInit 0 */
/* USER CODE END TIM1_MspPostInit 0 */
__HAL_RCC_GPIOA_CLK_ENABLE
();
/**TIM1 GPIO Configuration
PA8 ------> TIM1_CH1
*/
GPIO_InitStruct
.
Pin
=
GPIO_PIN_8
;
GPIO_InitStruct
.
Mode
=
GPIO_MODE_AF_PP
;
GPIO_InitStruct
.
Pull
=
GPIO_PULLUP
;
GPIO_InitStruct
.
Speed
=
GPIO_SPEED_FREQ_HIGH
;
GPIO_InitStruct
.
Alternate
=
GPIO_AF1_TIM1
;
HAL_GPIO_Init
(
GPIOA
,
&
GPIO_InitStruct
);
/* USER CODE BEGIN TIM1_MspPostInit 1 */
/* USER CODE END TIM1_MspPostInit 1 */
}
}
/**
* @brief TIM_PWM MSP De-Initialization
* This function freeze the hardware resources used in this example
* @param htim_pwm: TIM_PWM handle pointer
* @retval None
*/
void
HAL_TIM_PWM_MspDeInit
(
TIM_HandleTypeDef
*
htim_pwm
)
{
if
(
htim_pwm
->
Instance
==
TIM1
)
{
/* USER CODE BEGIN TIM1_MspDeInit 0 */
/* USER CODE END TIM1_MspDeInit 0 */
/* Peripheral clock disable */
__HAL_RCC_TIM1_CLK_DISABLE
();
/* USER CODE BEGIN TIM1_MspDeInit 1 */
/* USER CODE END TIM1_MspDeInit 1 */
}
}
/**
* @brief UART MSP Initialization
* This function configures the hardware resources used in this example
...
...
bsp/stm32/stm32h743-openmv-h7plus/board/CubeMX_Config/CubeMX_Config.ioc
浏览文件 @
da0164cf
...
...
@@ -2,6 +2,31 @@
CORTEX_M7.CPU_DCache=Enabled
CORTEX_M7.CPU_ICache=Enabled
CORTEX_M7.IPParameters=CPU_ICache,CPU_DCache
DCMI.IPParameters=JPEGMode
DCMI.JPEGMode=DCMI_JPEG_ENABLE
Dma.DCMI.0.Direction=DMA_PERIPH_TO_MEMORY
Dma.DCMI.0.EventEnable=DISABLE
Dma.DCMI.0.FIFOMode=DMA_FIFOMODE_ENABLE
Dma.DCMI.0.FIFOThreshold=DMA_FIFO_THRESHOLD_FULL
Dma.DCMI.0.Instance=DMA1_Stream3
Dma.DCMI.0.MemBurst=DMA_MBURST_SINGLE
Dma.DCMI.0.MemDataAlignment=DMA_MDATAALIGN_WORD
Dma.DCMI.0.MemInc=DMA_MINC_ENABLE
Dma.DCMI.0.Mode=DMA_CIRCULAR
Dma.DCMI.0.PeriphBurst=DMA_PBURST_SINGLE
Dma.DCMI.0.PeriphDataAlignment=DMA_PDATAALIGN_WORD
Dma.DCMI.0.PeriphInc=DMA_PINC_DISABLE
Dma.DCMI.0.Polarity=HAL_DMAMUX_REQ_GEN_RISING
Dma.DCMI.0.Priority=DMA_PRIORITY_HIGH
Dma.DCMI.0.RequestNumber=1
Dma.DCMI.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,FIFOThreshold,MemBurst,PeriphBurst,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber
Dma.DCMI.0.SignalID=NONE
Dma.DCMI.0.SyncEnable=DISABLE
Dma.DCMI.0.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT
Dma.DCMI.0.SyncRequestNumber=1
Dma.DCMI.0.SyncSignalID=NONE
Dma.Request0=DCMI
Dma.RequestsNb=1
FMC.BankMapConfig=FMC_SWAPBMAP_DISABLE
FMC.CASLatency1=FMC_SDRAM_CAS_LATENCY_2
FMC.ColumnBitsNumber1=FMC_SDRAM_COLUMN_BITS_NUM_9
...
...
@@ -21,100 +46,120 @@ KeepUserPlacement=false
Mcu.CPN=STM32H743IIK6
Mcu.Family=STM32H7
Mcu.IP0=CORTEX_M7
Mcu.IP1=FMC
Mcu.IP2=NVIC
Mcu.IP3=QUADSPI
Mcu.IP4=RCC
Mcu.IP5=SDMMC1
Mcu.IP6=SYS
Mcu.IP7=USART1
Mcu.IP8=USB_OTG_FS
Mcu.IPNb=9
Mcu.IP1=DCMI
Mcu.IP10=TIM1
Mcu.IP11=USART1
Mcu.IP12=USB_OTG_FS
Mcu.IP2=DMA
Mcu.IP3=FMC
Mcu.IP4=NVIC
Mcu.IP5=QUADSPI
Mcu.IP6=RCC
Mcu.IP7=RTC
Mcu.IP8=SDMMC1
Mcu.IP9=SYS
Mcu.IPNb=13
Mcu.Name=STM32H743IIKx
Mcu.Package=UFBGA176
Mcu.Pin0=PE1
Mcu.Pin1=PE0
Mcu.Pin10=P
I5
Mcu.Pin11=PD
1
Mcu.Pin12=P
I3
Mcu.Pin13=P
I2
Mcu.Pin14=PA1
1
Mcu.Pin15=PI
9
Mcu.Pin16=PI
4
Mcu.Pin17=P
D2
Mcu.Pin18=P
H15
Mcu.Pin19=PI
1
Mcu.Pin10=P
G10
Mcu.Pin11=PD
0
Mcu.Pin12=P
C11
Mcu.Pin13=P
C10
Mcu.Pin14=PA1
2
Mcu.Pin15=PI
7
Mcu.Pin16=PI
6
Mcu.Pin17=P
I5
Mcu.Pin18=P
D1
Mcu.Pin19=PI
3
Mcu.Pin2=PC12
Mcu.Pin20=PF0
Mcu.Pin21=PI10
Mcu.Pin22=PH13
Mcu.Pin23=PH14
Mcu.Pin24=PI0
Mcu.Pin25=PC9
Mcu.Pin26=PH0-OSC_IN (PH0)
Mcu.Pin27=PC8
Mcu.Pin28=PH1-OSC_OUT (PH1)
Mcu.Pin29=PF2
Mcu.Pin3=PG15
Mcu.Pin30=PF1
Mcu.Pin31=PG8
Mcu.Pin32=PF3
Mcu.Pin33=PF4
Mcu.Pin34=PG6
Mcu.Pin35=PF7
Mcu.Pin36=PF6
Mcu.Pin37=PF5
Mcu.Pin38=PH12
Mcu.Pin39=PG5
Mcu.Pin4=PD0
Mcu.Pin40=PG4
Mcu.Pin41=PF10
Mcu.Pin42=PF9
Mcu.Pin43=PF8
Mcu.Pin44=PH11
Mcu.Pin45=PH10
Mcu.Pin46=PD15
Mcu.Pin47=PC0
Mcu.Pin48=PG1
Mcu.Pin49=PH8
Mcu.Pin5=PC11
Mcu.Pin50=PH9
Mcu.Pin51=PD14
Mcu.Pin52=PC4
Mcu.Pin53=PF13
Mcu.Pin54=PG0
Mcu.Pin55=PE13
Mcu.Pin56=PD10
Mcu.Pin57=PC5
Mcu.Pin58=PF12
Mcu.Pin59=PF15
Mcu.Pin6=PC10
Mcu.Pin60=PE8
Mcu.Pin61=PE9
Mcu.Pin62=PE11
Mcu.Pin63=PE14
Mcu.Pin64=PD9
Mcu.Pin65=PD8
Mcu.Pin66=PA7
Mcu.Pin67=PF11
Mcu.Pin68=PF14
Mcu.Pin69=PE7
Mcu.Pin7=PA12
Mcu.Pin70=PE10
Mcu.Pin71=PE12
Mcu.Pin72=PE15
Mcu.Pin73=PB14
Mcu.Pin74=PB15
Mcu.Pin75=VP_SYS_VS_Systick
Mcu.Pin8=PI7
Mcu.Pin9=PI6
Mcu.PinsNb=76
Mcu.Pin20=PI2
Mcu.Pin21=PA11
Mcu.Pin22=PI9
Mcu.Pin23=PI4
Mcu.Pin24=PD2
Mcu.Pin25=PH15
Mcu.Pin26=PI1
Mcu.Pin27=PF0
Mcu.Pin28=PI10
Mcu.Pin29=PH13
Mcu.Pin3=PE4
Mcu.Pin30=PH14
Mcu.Pin31=PI0
Mcu.Pin32=PC9
Mcu.Pin33=PA8
Mcu.Pin34=PH0-OSC_IN (PH0)
Mcu.Pin35=PC8
Mcu.Pin36=PC7
Mcu.Pin37=PH1-OSC_OUT (PH1)
Mcu.Pin38=PF2
Mcu.Pin39=PF1
Mcu.Pin4=PE5
Mcu.Pin40=PG8
Mcu.Pin41=PC6
Mcu.Pin42=PF3
Mcu.Pin43=PF4
Mcu.Pin44=PG6
Mcu.Pin45=PF7
Mcu.Pin46=PF6
Mcu.Pin47=PF5
Mcu.Pin48=PH12
Mcu.Pin49=PG5
Mcu.Pin5=PE6
Mcu.Pin50=PG4
Mcu.Pin51=PF10
Mcu.Pin52=PF9
Mcu.Pin53=PF8
Mcu.Pin54=PH11
Mcu.Pin55=PH10
Mcu.Pin56=PD15
Mcu.Pin57=PC0
Mcu.Pin58=PG1
Mcu.Pin59=PH8
Mcu.Pin6=PB7
Mcu.Pin60=PH9
Mcu.Pin61=PD14
Mcu.Pin62=PA4
Mcu.Pin63=PC4
Mcu.Pin64=PF13
Mcu.Pin65=PG0
Mcu.Pin66=PE13
Mcu.Pin67=PD10
Mcu.Pin68=PA6
Mcu.Pin69=PC5
Mcu.Pin7=PB6
Mcu.Pin70=PF12
Mcu.Pin71=PF15
Mcu.Pin72=PE8
Mcu.Pin73=PE9
Mcu.Pin74=PE11
Mcu.Pin75=PE14
Mcu.Pin76=PD9
Mcu.Pin77=PD8
Mcu.Pin78=PA7
Mcu.Pin79=PF11
Mcu.Pin8=PG15
Mcu.Pin80=PF14
Mcu.Pin81=PE7
Mcu.Pin82=PE10
Mcu.Pin83=PE12
Mcu.Pin84=PE15
Mcu.Pin85=PB14
Mcu.Pin86=PB15
Mcu.Pin87=VP_RTC_VS_RTC_Activate
Mcu.Pin88=VP_RTC_VS_RTC_Calendar
Mcu.Pin89=VP_SYS_VS_Systick
Mcu.Pin9=PG11
Mcu.PinsNb=90
Mcu.ThirdPartyNb=0
Mcu.UserConstants=
Mcu.UserName=STM32H743IIKx
MxCube.Version=6.4.0
MxDb.Version=DB.6.0.40
NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:true
NVIC.DCMI_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true
NVIC.DMA1_Stream3_IRQn=true\:0\:0\:false\:false\:true\:false\:true\:true
NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:true
NVIC.ForceEnableDMAVector=true
NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:true
...
...
@@ -136,16 +181,44 @@ PA12.GPIOParameters=GPIO_Speed
PA12.GPIO_Speed=GPIO_SPEED_FREQ_HIGH
PA12.Mode=Device_Only
PA12.Signal=USB_OTG_FS_DP
PA4.GPIOParameters=GPIO_Speed,GPIO_PuPd
PA4.GPIO_PuPd=GPIO_PULLUP
PA4.GPIO_Speed=GPIO_SPEED_FREQ_HIGH
PA4.Locked=true
PA4.Mode=Slave_8_bits_External_Synchro
PA4.Signal=DCMI_HSYNC
PA6.GPIOParameters=GPIO_Speed,GPIO_PuPd
PA6.GPIO_PuPd=GPIO_PULLUP
PA6.GPIO_Speed=GPIO_SPEED_FREQ_HIGH
PA6.Locked=true
PA6.Mode=Slave_8_bits_External_Synchro
PA6.Signal=DCMI_PIXCLK
PA7.GPIOParameters=GPIO_PuPd
PA7.GPIO_PuPd=GPIO_PULLUP
PA7.Locked=true
PA7.Signal=FMC_SDNWE
PA8.GPIOParameters=GPIO_Speed,GPIO_PuPd
PA8.GPIO_PuPd=GPIO_PULLUP
PA8.GPIO_Speed=GPIO_SPEED_FREQ_HIGH
PA8.Signal=S_TIM1_CH1
PB14.Locked=true
PB14.Mode=Asynchronous
PB14.Signal=USART1_TX
PB15.Locked=true
PB15.Mode=Asynchronous
PB15.Signal=USART1_RX
PB6.GPIOParameters=GPIO_Speed,GPIO_PuPd
PB6.GPIO_PuPd=GPIO_PULLUP
PB6.GPIO_Speed=GPIO_SPEED_FREQ_HIGH
PB6.Locked=true
PB6.Mode=Slave_8_bits_External_Synchro
PB6.Signal=DCMI_D5
PB7.GPIOParameters=GPIO_Speed,GPIO_PuPd
PB7.GPIO_PuPd=GPIO_PULLUP
PB7.GPIO_Speed=GPIO_SPEED_FREQ_HIGH
PB7.Locked=true
PB7.Mode=Slave_8_bits_External_Synchro
PB7.Signal=DCMI_VSYNC
PC0.GPIOParameters=GPIO_Label
PC0.GPIO_Label=LED_RED
PC0.Locked=true
...
...
@@ -166,6 +239,18 @@ PC5.GPIO_PuPd=GPIO_PULLUP
PC5.Locked=true
PC5.Mode=SdramChipSelect1_1
PC5.Signal=FMC_SDCKE0
PC6.GPIOParameters=GPIO_Speed,GPIO_PuPd
PC6.GPIO_PuPd=GPIO_PULLUP
PC6.GPIO_Speed=GPIO_SPEED_FREQ_HIGH
PC6.Locked=true
PC6.Mode=Slave_8_bits_External_Synchro
PC6.Signal=DCMI_D0
PC7.GPIOParameters=GPIO_Speed,GPIO_PuPd
PC7.GPIO_PuPd=GPIO_PULLUP
PC7.GPIO_Speed=GPIO_SPEED_FREQ_HIGH
PC7.Locked=true
PC7.Mode=Slave_8_bits_External_Synchro
PC7.Signal=DCMI_D1
PC8.Mode=SD_4_bits_Wide_bus
PC8.Signal=SDMMC1_D0
PC9.Mode=SD_4_bits_Wide_bus
...
...
@@ -217,6 +302,24 @@ PE14.Signal=FMC_D11_DA11
PE15.GPIOParameters=GPIO_PuPd
PE15.GPIO_PuPd=GPIO_PULLUP
PE15.Signal=FMC_D12_DA12
PE4.GPIOParameters=GPIO_Speed,GPIO_PuPd
PE4.GPIO_PuPd=GPIO_PULLUP
PE4.GPIO_Speed=GPIO_SPEED_FREQ_HIGH
PE4.Locked=true
PE4.Mode=Slave_8_bits_External_Synchro
PE4.Signal=DCMI_D4
PE5.GPIOParameters=GPIO_Speed,GPIO_PuPd
PE5.GPIO_PuPd=GPIO_PULLUP
PE5.GPIO_Speed=GPIO_SPEED_FREQ_HIGH
PE5.Locked=true
PE5.Mode=Slave_8_bits_External_Synchro
PE5.Signal=DCMI_D6
PE6.GPIOParameters=GPIO_Speed,GPIO_PuPd
PE6.GPIO_PuPd=GPIO_PULLUP
PE6.GPIO_Speed=GPIO_SPEED_FREQ_HIGH
PE6.Locked=true
PE6.Mode=Slave_8_bits_External_Synchro
PE6.Signal=DCMI_D7
PE7.GPIOParameters=GPIO_PuPd
PE7.GPIO_PuPd=GPIO_PULLUP
PE7.Signal=FMC_D4_DA4
...
...
@@ -290,6 +393,18 @@ PG0.Signal=FMC_A10
PG1.GPIOParameters=GPIO_PuPd
PG1.GPIO_PuPd=GPIO_PULLUP
PG1.Signal=FMC_A11
PG10.GPIOParameters=GPIO_Speed,GPIO_PuPd
PG10.GPIO_PuPd=GPIO_PULLUP
PG10.GPIO_Speed=GPIO_SPEED_FREQ_HIGH
PG10.Locked=true
PG10.Mode=Slave_8_bits_External_Synchro
PG10.Signal=DCMI_D2
PG11.GPIOParameters=GPIO_Speed,GPIO_PuPd
PG11.GPIO_PuPd=GPIO_PULLUP
PG11.GPIO_Speed=GPIO_SPEED_FREQ_HIGH
PG11.Locked=true
PG11.Mode=Slave_8_bits_External_Synchro
PG11.Signal=DCMI_D3
PG15.GPIOParameters=GPIO_PuPd
PG15.GPIO_PuPd=GPIO_PULLUP
PG15.Signal=FMC_SDNCAS
...
...
@@ -394,7 +509,7 @@ ProjectManager.StackSize=0x400
ProjectManager.TargetToolchain=MDK-ARM V5.32
ProjectManager.ToolChainLocation=
ProjectManager.UnderRoot=false
ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-SystemClock_Config-RCC-false-HAL-false,3-MX_USART1_UART_Init-USART1-false-HAL-true,4-MX_FMC_Init-FMC-false-HAL-true,5-MX_QUADSPI_Init-QUADSPI-false-HAL-true,6-MX_SDMMC1_SD_Init-SDMMC1-false-HAL-true,0-MX_CORTEX_M7_Init-CORTEX_M7-false-HAL-true
ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-SystemClock_Config-RCC-false-HAL-false,3-MX_USART1_UART_Init-USART1-false-HAL-true,4-MX_FMC_Init-FMC-false-HAL-true,5-MX_QUADSPI_Init-QUADSPI-false-HAL-true,6-MX_SDMMC1_SD_Init-SDMMC1-false-HAL-true,
7-MX_DMA_Init-DMA-false-HAL-true,8-MX_RTC_Init-RTC-false-HAL-true,9-MX_DCMI_Init-DCMI-false-HAL-true,10-MX_USB_OTG_FS_PCD_Init-USB_OTG_FS-false-HAL-true,
0-MX_CORTEX_M7_Init-CORTEX_M7-false-HAL-true
QUADSPI.ChipSelectHighTime=QSPI_CS_HIGH_TIME_2_CYCLE
QUADSPI.ClockPrescaler=1
QUADSPI.FifoThreshold=3
...
...
@@ -592,10 +707,21 @@ SH.FMC_SDNRAS.0=FMC_SDNRAS,12b-sda1
SH.FMC_SDNRAS.ConfNb=1
SH.FMC_SDNWE.0=FMC_SDNWE,12b-sda1
SH.FMC_SDNWE.ConfNb=1
SH.S_TIM1_CH1.0=TIM1_CH1,PWM Generation1 CH1
SH.S_TIM1_CH1.ConfNb=1
TIM1.AutoReloadPreload=TIM_AUTORELOAD_PRELOAD_ENABLE
TIM1.Channel-PWM\ Generation1\ CH1=TIM_CHANNEL_1
TIM1.IPParameters=Channel-PWM Generation1 CH1,Period,AutoReloadPreload,Pulse-PWM Generation1 CH1
TIM1.Period=7
TIM1.Pulse-PWM\ Generation1\ CH1=3
USART1.IPParameters=VirtualMode-Asynchronous
USART1.VirtualMode-Asynchronous=VM_ASYNC
USB_OTG_FS.IPParameters=VirtualMode
USB_OTG_FS.VirtualMode=Device_Only
VP_RTC_VS_RTC_Activate.Mode=RTC_Enabled
VP_RTC_VS_RTC_Activate.Signal=RTC_VS_RTC_Activate
VP_RTC_VS_RTC_Calendar.Mode=RTC_Calendar
VP_RTC_VS_RTC_Calendar.Signal=RTC_VS_RTC_Calendar
VP_SYS_VS_Systick.Mode=SysTick
VP_SYS_VS_Systick.Signal=SYS_VS_Systick
board=custom
bsp/stm32/stm32h743-openmv-h7plus/board/Kconfig
浏览文件 @
da0164cf
...
...
@@ -53,7 +53,7 @@ menu "Hardware Drivers Config"
select RT_USING_QSPI
select RT_USING_SPI
default n
config BSP_USING_ONCHIP_RTC
bool "Enable RTC"
select RT_USING_RTC
...
...
@@ -88,6 +88,55 @@ menu "Hardware Drivers Config"
select RT_USING_USB_DEVICE
default n
config BSP_USING_OV5640
bool "Enable camera (ov5640)"
select BSP_USING_DCMI
select BSP_USING_I2C
select BSP_USING_I2C1
default n
config BSP_USING_DCMI
bool "Enable DCMI"
default n
menuconfig BSP_USING_I2C
bool "Enable I2C BUS (software simulation)"
select RT_USING_I2C
select RT_USING_I2C_BITOPS
select RT_USING_PIN
default n
if BSP_USING_I2C
menuconfig BSP_USING_I2C1
bool "Enable I2C1 BUS (software simulation)"
default n
if BSP_USING_I2C1
comment "Notice: PB8 --> 24; PB9 --> 25"
config BSP_I2C1_SCL_PIN
int "i2c1 scl pin number"
range 1 176
default 24
config BSP_I2C1_SDA_PIN
int "I2C1 sda pin number"
range 1 176
default 25
endif
menuconfig BSP_USING_I2C2
bool "Enable I2C2 BUS (software simulation)"
default n
if BSP_USING_I2C2
comment "Notice: PB10 --> 26; PB11 --> 27"
config BSP_I2C2_SCL_PIN
int "i2c2 scl pin number"
range 1 176
default 26
config BSP_I2C2_SDA_PIN
int "I2C2 sda pin number"
range 1 176
default 27
endif
endif
endmenu
endmenu
bsp/stm32/stm32h743-openmv-h7plus/board/SConscript
浏览文件 @
da0164cf
...
...
@@ -4,6 +4,7 @@ from building import *
Import
(
'SDK_LIB'
)
startup_path_prefix
=
SDK_LIB
cwd
=
GetCurrentDir
()
# add general drivers
...
...
@@ -20,8 +21,12 @@ if GetDepend(['BSP_USING_QSPI_FLASH']):
src
+=
Glob
(
'ports/drv_qspi_flash.c'
)
if
GetDepend
([
'BSP_USING_SDMMC'
]):
src
+=
Glob
(
'ports/drv_sdio.c'
)
startup_path_prefix
=
SDK_LIB
if
GetDepend
([
'BSP_USING_OV5640'
]):
src
+=
Glob
(
'ports/drv_ov5640.c'
)
src
+=
[
startup_path_prefix
+
'/STM32H7xx_HAL/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_tim.c'
]
if
GetDepend
([
'BSP_USING_DCMI'
]):
src
+=
Glob
(
'ports/drv_dcmi.c'
)
src
+=
[
startup_path_prefix
+
'/STM32H7xx_HAL/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_dcmi.c'
]
if
rtconfig
.
CROSS_TOOL
==
'gcc'
:
src
+=
[
startup_path_prefix
+
'/STM32H7xx_HAL/CMSIS/Device/ST/STM32H7xx/Source/Templates/gcc/startup_stm32h743xx.s'
]
...
...
bsp/stm32/stm32h743-openmv-h7plus/board/ports/drv_dcmi.c
0 → 100644
浏览文件 @
da0164cf
/*
* Copyright (c) 2006-2022, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2020-07-27 thread-liu the first version
* 2022-04-13 Miaowulue fit openmv-h7plus
*/
#include "board.h"
#ifdef BSP_USING_DCMI
#define DRV_DEBUG
#define LOG_TAG "drv.dcmi"
#include <drv_log.h>
struct
stm32_dcmi
{
struct
rt_device
dev
;
};
static
struct
stm32_dcmi
rt_dcmi
=
{
0
};
DCMI_HandleTypeDef
dcmi
=
{
0
};
DMA_HandleTypeDef
hdma_dcmi
=
{
0
};
extern
void
jpeg_data_process
(
void
);
static
void
rt_hw_dmci_dma_init
(
void
)
{
__HAL_RCC_DMA1_CLK_ENABLE
();
hdma_dcmi
.
Instance
=
DMA1_Stream3
;
hdma_dcmi
.
Init
.
Request
=
DMA_REQUEST_DCMI
;
hdma_dcmi
.
Init
.
Direction
=
DMA_PERIPH_TO_MEMORY
;
hdma_dcmi
.
Init
.
PeriphInc
=
DMA_PINC_DISABLE
;
hdma_dcmi
.
Init
.
MemInc
=
DMA_MINC_ENABLE
;
hdma_dcmi
.
Init
.
PeriphDataAlignment
=
DMA_PDATAALIGN_WORD
;
hdma_dcmi
.
Init
.
MemDataAlignment
=
DMA_MDATAALIGN_WORD
;
hdma_dcmi
.
Init
.
Mode
=
DMA_CIRCULAR
;
hdma_dcmi
.
Init
.
Priority
=
DMA_PRIORITY_HIGH
;
hdma_dcmi
.
Init
.
FIFOMode
=
DMA_FIFOMODE_ENABLE
;
hdma_dcmi
.
Init
.
FIFOThreshold
=
DMA_FIFO_THRESHOLD_FULL
;
hdma_dcmi
.
Init
.
MemBurst
=
DMA_MBURST_SINGLE
;
hdma_dcmi
.
Init
.
PeriphBurst
=
DMA_PBURST_SINGLE
;
if
(
HAL_DMA_Init
(
&
hdma_dcmi
)
!=
HAL_OK
)
{
Error_Handler
();
}
__HAL_LINKDMA
(
&
dcmi
,
DMA_Handle
,
hdma_dcmi
);
HAL_NVIC_SetPriority
(
DMA1_Stream3_IRQn
,
0x00
,
0
);
HAL_NVIC_EnableIRQ
(
DMA1_Stream3_IRQn
);
}
void
rt_hw_dcmi_dma_config
(
rt_uint32_t
dst_addr1
,
rt_uint32_t
dst_addr2
,
rt_uint16_t
len
)
{
HAL_DMAEx_MultiBufferStart
(
&
hdma_dcmi
,
(
rt_uint32_t
)
&
DCMI
->
DR
,
dst_addr1
,
dst_addr2
,
len
);
__HAL_DMA_ENABLE_IT
(
&
hdma_dcmi
,
DMA_IT_TC
);
}
static
rt_err_t
rt_hw_dcmi_init
(
DCMI_HandleTypeDef
*
device
)
{
RT_ASSERT
(
device
!=
RT_NULL
);
dcmi
.
Instance
=
DCMI
;
dcmi
.
Init
.
SynchroMode
=
DCMI_SYNCHRO_HARDWARE
;
dcmi
.
Init
.
PCKPolarity
=
DCMI_PCKPOLARITY_RISING
;
dcmi
.
Init
.
VSPolarity
=
DCMI_VSPOLARITY_LOW
;
dcmi
.
Init
.
HSPolarity
=
DCMI_HSPOLARITY_LOW
;
dcmi
.
Init
.
CaptureRate
=
DCMI_CR_ALL_FRAME
;
dcmi
.
Init
.
ExtendedDataMode
=
DCMI_EXTEND_DATA_8B
;
dcmi
.
Init
.
JPEGMode
=
DCMI_JPEG_ENABLE
;
dcmi
.
Init
.
ByteSelectMode
=
DCMI_BSM_ALL
;
dcmi
.
Init
.
ByteSelectStart
=
DCMI_OEBS_ODD
;
dcmi
.
Init
.
LineSelectMode
=
DCMI_LSM_ALL
;
dcmi
.
Init
.
LineSelectStart
=
DCMI_OELS_ODD
;
if
(
HAL_DCMI_Init
(
device
)
!=
HAL_OK
)
{
LOG_E
(
"dcmi init error!"
);
return
RT_ERROR
;
}
DCMI
->
IER
=
0x0
;
__HAL_DCMI_ENABLE_IT
(
device
,
DCMI_IT_FRAME
);
__HAL_DCMI_ENABLE
(
device
);
rt_hw_dmci_dma_init
();
return
RT_EOK
;
}
void
DCMI_IRQHandler
(
void
)
{
/* enter interrupt */
rt_interrupt_enter
();
HAL_DCMI_IRQHandler
(
&
dcmi
);
/* leave interrupt */
rt_interrupt_leave
();
}
/* Capture a frame of the image */
void
HAL_DCMI_FrameEventCallback
(
DCMI_HandleTypeDef
*
hdcmi
)
{
/* enter interrupt */
rt_interrupt_enter
();
jpeg_data_process
();
__HAL_DCMI_ENABLE_IT
(
&
dcmi
,
DCMI_IT_FRAME
);
/* leave interrupt */
rt_interrupt_leave
();
}
void
DMA1_Stream3_IRQHandler
(
void
)
{
extern
void
rt_hw_camera_rx_callback
(
void
);
/* enter interrupt */
rt_interrupt_enter
();
if
(
__HAL_DMA_GET_FLAG
(
&
hdma_dcmi
,
DMA_FLAG_TCIF3_7
)
!=
RESET
)
{
__HAL_DMA_CLEAR_FLAG
(
&
hdma_dcmi
,
DMA_FLAG_TCIF3_7
);
rt_hw_camera_rx_callback
();
}
/* leave interrupt */
rt_interrupt_leave
();
}
static
rt_err_t
rt_dcmi_init
(
rt_device_t
dev
)
{
RT_ASSERT
(
dev
!=
RT_NULL
);
rt_err_t
result
=
RT_EOK
;
result
=
rt_hw_dcmi_init
(
&
dcmi
);
if
(
result
!=
RT_EOK
)
{
return
result
;
}
return
result
;
}
static
rt_err_t
rt_dcmi_open
(
rt_device_t
dev
,
rt_uint16_t
oflag
)
{
RT_ASSERT
(
dev
!=
RT_NULL
);
return
RT_EOK
;
}
static
rt_err_t
rt_dcmi_close
(
rt_device_t
dev
)
{
RT_ASSERT
(
dev
!=
RT_NULL
);
return
RT_EOK
;
}
static
rt_err_t
rt_dcmi_control
(
rt_device_t
dev
,
int
cmd
,
void
*
args
)
{
RT_ASSERT
(
dev
!=
RT_NULL
);
return
RT_EOK
;
}
static
rt_size_t
rt_dcmi_read
(
rt_device_t
dev
,
rt_off_t
pos
,
void
*
buffer
,
rt_size_t
size
)
{
RT_ASSERT
(
dev
!=
RT_NULL
);
return
RT_EOK
;
}
static
rt_size_t
rt_dcmi_write
(
rt_device_t
dev
,
rt_off_t
pos
,
const
void
*
buffer
,
rt_size_t
size
)
{
RT_ASSERT
(
dev
!=
RT_NULL
);
return
RT_EOK
;
}
int
dcmi_init
(
void
)
{
int
ret
=
0
;
rt_device_t
dcmi_dev
=
RT_NULL
;
rt_dcmi
.
dev
.
type
=
RT_Device_Class_Miscellaneous
;
rt_dcmi
.
dev
.
init
=
rt_dcmi_init
;
rt_dcmi
.
dev
.
open
=
rt_dcmi_open
;
rt_dcmi
.
dev
.
close
=
rt_dcmi_close
;
rt_dcmi
.
dev
.
read
=
rt_dcmi_read
;
rt_dcmi
.
dev
.
write
=
rt_dcmi_write
;
rt_dcmi
.
dev
.
control
=
rt_dcmi_control
;
rt_dcmi
.
dev
.
user_data
=
RT_NULL
;
ret
=
rt_device_register
(
&
rt_dcmi
.
dev
,
"dcmi"
,
RT_DEVICE_FLAG_RDWR
|
RT_DEVICE_FLAG_REMOVABLE
|
RT_DEVICE_FLAG_STANDALONE
);
if
(
ret
!=
RT_EOK
)
{
LOG_E
(
"dcmi registered fail!
\n\r
"
);
return
-
RT_ERROR
;
}
LOG_I
(
"dcmi init success!"
);
return
RT_EOK
;
}
INIT_BOARD_EXPORT
(
dcmi_init
);
#endif
bsp/stm32/stm32h743-openmv-h7plus/board/ports/drv_ov5640.c
0 → 100644
浏览文件 @
da0164cf
/*
* Copyright (c) 2006-2022, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2020-08-03 thread-liu the first version
* 2022-04-13 Miaowulue fit openmv-h7plus
*/
#include "board.h"
#ifdef BSP_USING_OV5640
#include <dfs_file.h>
#include <unistd.h>
#include <stdio.h>
#include <sys/stat.h>
#include <sys/statfs.h>
#include "drv_ov5640.h"
//#define DRV_DEBUG
//#define CAMERA_DUMP
#define LOG_TAG "drv.ov5640"
#include <drv_log.h>
#define CHIP_ADDRESS 0x3C
/* OV5640 address */
#define I2C_NAME "i2c1"
#define RST_PIN GET_PIN(A, 10)
#define PWDN_PIN GET_PIN(D, 7)
#define JPEG_BUF_SIZE 8 * 1024
#define JPEG_LINE_SIZE 1 * 1024
static
rt_int32_t
JPEG_DATA_BUF
[
JPEG_BUF_SIZE
];
static
rt_int32_t
JPEG_LINE_BUF
[
2
][
JPEG_LINE_SIZE
];
volatile
rt_uint32_t
jpeg_data_len
=
0
;
volatile
rt_uint8_t
jpeg_data_ok
=
0
;
struct
rt_i2c_bus_device
*
i2c_bus
=
RT_NULL
;
extern
DCMI_HandleTypeDef
dcmi
;
extern
DMA_HandleTypeDef
hdma_dcmi
;
#if defined(CAMERA_DUMP)
#define __is_print(ch) ((unsigned int)((ch) - ' ') < 127u - ' ')
static
void
dump_hex
(
const
rt_uint8_t
*
ptr
,
rt_size_t
buflen
)
{
unsigned
char
*
buf
=
(
unsigned
char
*
)
ptr
;
int
i
,
j
;
for
(
i
=
0
;
i
<
buflen
;
i
+=
16
)
{
rt_kprintf
(
"%08x:"
,
i
);
for
(
j
=
0
;
j
<
16
;
j
++
)
{
if
(
i
+
j
<
buflen
)
{
rt_kprintf
(
"%02x"
,
buf
[
i
+
j
]);
}
else
{
rt_kprintf
(
" "
);
}
}
rt_kprintf
(
" "
);
for
(
j
=
0
;
j
<
16
;
j
++
)
{
if
(
i
+
j
<
buflen
)
{
rt_kprintf
(
"%c"
,
__is_print
(
buf
[
i
+
j
])
?
buf
[
i
+
j
]
:
'.'
);
}
}
rt_kprintf
(
"
\n
"
);
}
}
#endif
/* i2c read reg */
static
rt_err_t
read_reg
(
struct
rt_i2c_bus_device
*
bus
,
rt_uint16_t
reg
,
rt_uint8_t
len
,
rt_uint8_t
*
buf
)
{
struct
rt_i2c_msg
msg
[
2
]
=
{
0
,
0
};
static
rt_uint8_t
i2c_reg
[
2
]
=
{
0
,
0
};
RT_ASSERT
(
bus
!=
RT_NULL
);
i2c_reg
[
0
]
=
((
uint16_t
)(
reg
>>
8
)
&
0xFF
);
i2c_reg
[
1
]
=
((
uint16_t
)(
reg
&
0xFF
));
msg
[
0
].
addr
=
CHIP_ADDRESS
;
msg
[
0
].
flags
=
RT_I2C_WR
;
msg
[
0
].
buf
=
i2c_reg
;
msg
[
0
].
len
=
2
;
msg
[
1
].
addr
=
CHIP_ADDRESS
;
msg
[
1
].
flags
=
RT_I2C_RD
;
msg
[
1
].
len
=
len
;
msg
[
1
].
buf
=
buf
;
if
(
rt_i2c_transfer
(
bus
,
msg
,
2
)
==
2
)
{
return
RT_EOK
;
}
return
RT_ERROR
;
}
/* i2c write reg */
static
rt_err_t
write_reg
(
struct
rt_i2c_bus_device
*
bus
,
rt_uint16_t
reg
,
rt_uint8_t
data
)
{
rt_uint8_t
buf
[
3
];
struct
rt_i2c_msg
msgs
;
RT_ASSERT
(
bus
!=
RT_NULL
);
buf
[
0
]
=
((
uint16_t
)(
reg
>>
8
)
&
0xFF
);
buf
[
1
]
=
((
uint16_t
)(
reg
)
&
0xFF
);
buf
[
2
]
=
data
;
msgs
.
addr
=
CHIP_ADDRESS
;
msgs
.
flags
=
RT_I2C_WR
;
msgs
.
buf
=
buf
;
msgs
.
len
=
3
;
if
(
rt_i2c_transfer
(
bus
,
&
msgs
,
1
)
==
1
)
{
return
RT_EOK
;
}
return
RT_ERROR
;
}
static
rt_err_t
ov5640_read_id
(
struct
rt_i2c_bus_device
*
bus
,
rt_uint16_t
*
id
)
{
rt_uint8_t
read_value
[
2
];
read_reg
(
bus
,
0x300A
,
1
,
&
read_value
[
0
]);
read_reg
(
bus
,
0x300B
,
1
,
&
read_value
[
1
]);
*
id
=
((
uint16_t
)(
read_value
[
0
]
<<
8
)
&
0xFF00
);
*
id
|=
((
uint16_t
)(
read_value
[
1
])
&
0x00FF
);
if
(
*
id
!=
OV5640_ID
)
{
LOG_E
(
"ov5640 init error, id: 0x%04x"
,
*
id
);
return
RT_ERROR
;
}
LOG_I
(
"ov5640 init success, id: 0x%04x"
,
*
id
);
return
RT_EOK
;
}
static
rt_err_t
ov5640_hard_reset
(
void
)
{
rt_pin_mode
(
RST_PIN
,
PIN_MODE_OUTPUT
);
rt_pin_mode
(
PWDN_PIN
,
PIN_MODE_OUTPUT
);
rt_pin_write
(
RST_PIN
,
PIN_LOW
);
rt_thread_mdelay
(
20
);
rt_pin_write
(
PWDN_PIN
,
PIN_LOW
);
rt_thread_mdelay
(
5
);
rt_pin_write
(
RST_PIN
,
PIN_HIGH
);
rt_thread_mdelay
(
20
);
return
RT_EOK
;
}
void
OV5640_Flash_Ctrl
(
struct
rt_i2c_bus_device
*
bus
,
rt_uint8_t
sw
)
{
write_reg
(
bus
,
0x3016
,
0X02
);
write_reg
(
bus
,
0x301C
,
0X02
);
if
(
sw
)
{
write_reg
(
bus
,
0X3019
,
0X02
);
}
else
{
write_reg
(
bus
,
0X3019
,
0X00
);
}
}
static
rt_err_t
ov5640_config
(
struct
rt_i2c_bus_device
*
bus
)
{
rt_uint32_t
i
=
0
;
rt_uint8_t
value
=
0
;
write_reg
(
bus
,
0x3103
,
0X11
);
/* system clock from pad, bit[1] */
write_reg
(
bus
,
0X3008
,
0X82
);
/* soft reset */
rt_thread_delay
(
10
);
for
(
i
=
0
;
i
<
(
sizeof
(
RGB565_Init
)
/
4
);
i
++
)
{
write_reg
(
bus
,
RGB565_Init
[
i
][
0
],
RGB565_Init
[
i
][
1
]);
rt_thread_delay
(
10
);
read_reg
(
bus
,
RGB565_Init
[
i
][
0
],
1
,
&
value
);
if
(
RGB565_Init
[
i
][
1
]
!=
value
)
{
LOG_D
(
"error reg value[0x%x]:0x%02x - 0x%02x"
,
RGB565_Init
[
i
][
0
],
RGB565_Init
[
i
][
1
],
value
);
}
}
OV5640_Flash_Ctrl
(
bus
,
1
);
/* open camera flash*/
rt_thread_delay
(
3
);
OV5640_Flash_Ctrl
(
bus
,
0
);
/* close camera flash*/
return
RT_EOK
;
}
/* JPEG */
void
ov5640_jpeg_mode
(
struct
rt_i2c_bus_device
*
bus
)
{
rt_uint16_t
i
=
0
;
for
(
i
=
0
;
i
<
(
sizeof
(
OV5640_jpeg_reg_tbl
)
/
4
);
i
++
)
{
write_reg
(
bus
,
OV5640_jpeg_reg_tbl
[
i
][
0
],
OV5640_jpeg_reg_tbl
[
i
][
1
]);
}
}
/* RGB565 */
void
ov5640_rgb565_mode
(
struct
rt_i2c_bus_device
*
bus
)
{
rt_uint16_t
i
=
0
;
for
(
i
=
0
;
i
<
(
sizeof
(
ov5640_rgb565_reg_tbl
)
/
4
);
i
++
)
{
write_reg
(
bus
,
ov5640_rgb565_reg_tbl
[
i
][
0
],
ov5640_rgb565_reg_tbl
[
i
][
1
]);
}
write_reg
(
bus
,
0x3821
,
0x06
);
}
rt_uint8_t
ov5640_focus_init
(
struct
rt_i2c_bus_device
*
bus
)
{
rt_uint16_t
tickstart
=
0
,
i
=
0
;
rt_uint16_t
addr
=
0x8000
;
rt_uint8_t
state
=
0x8F
;
write_reg
(
bus
,
0x3000
,
0x20
);
//reset MCU
for
(
i
=
0
;
i
<
sizeof
(
OV5640_AF_Config
);
i
++
)
{
write_reg
(
bus
,
addr
,
OV5640_AF_Config
[
i
]);
addr
++
;
}
write_reg
(
bus
,
0x3022
,
0x00
);
write_reg
(
bus
,
0x3023
,
0x00
);
write_reg
(
bus
,
0x3024
,
0x00
);
write_reg
(
bus
,
0x3025
,
0x00
);
write_reg
(
bus
,
0x3026
,
0x00
);
write_reg
(
bus
,
0x3027
,
0x00
);
write_reg
(
bus
,
0x3028
,
0x00
);
write_reg
(
bus
,
0x3029
,
0x7f
);
write_reg
(
bus
,
0x3000
,
0x00
);
i
=
0
;
tickstart
=
rt_tick_get
();
do
{
read_reg
(
bus
,
0x3029
,
1
,
&
state
);
if
(
rt_tick_get
()
-
tickstart
>
1000
)
{
return
RT_ERROR
;
}
}
while
(
state
!=
0x70
);
return
RT_EOK
;
}
void
ov5640_set_light
(
struct
rt_i2c_bus_device
*
bus
,
rt_uint8_t
mode
)
{
rt_uint8_t
i
=
0
;
write_reg
(
bus
,
0x3212
,
0x03
);
//start group 3
for
(
i
=
0
;
i
<
7
;
i
++
)
{
write_reg
(
bus
,
0x3400
+
i
,
OV5640_LIGHTMODE_TBL
[
mode
][
i
]);
}
write_reg
(
bus
,
0x3212
,
0x13
);
//end group 3
write_reg
(
bus
,
0x3212
,
0xa3
);
//launch group 3
}
/* sat:0~6 */
void
ov5640_color_saturation
(
struct
rt_i2c_bus_device
*
bus
,
rt_uint8_t
sat
)
{
rt_uint8_t
i
=
0
;
write_reg
(
bus
,
0x3212
,
0x03
);
//start group 3
write_reg
(
bus
,
0x5381
,
0x1c
);
write_reg
(
bus
,
0x5382
,
0x5a
);
write_reg
(
bus
,
0x5383
,
0x06
);
for
(
i
=
0
;
i
<
6
;
i
++
)
{
write_reg
(
bus
,
0x5384
+
i
,
OV5640_SATURATION_TBL
[
sat
][
i
]);
}
write_reg
(
bus
,
0x538b
,
0x98
);
write_reg
(
bus
,
0x538a
,
0x01
);
write_reg
(
bus
,
0x3212
,
0x13
);
//end group 3
write_reg
(
bus
,
0x3212
,
0xa3
);
//launch group 3
}
/* bright:0~8 */
void
ov5640_set_brightness
(
struct
rt_i2c_bus_device
*
bus
,
rt_uint8_t
bright
)
{
rt_uint8_t
brtval
;
if
(
bright
<
4
)
{
brtval
=
4
-
bright
;
}
else
{
brtval
=
bright
-
4
;
}
write_reg
(
bus
,
0x3212
,
0x03
);
//start group 3
write_reg
(
bus
,
0x5587
,
brtval
<<
4
);
if
(
bright
<
4
)
{
write_reg
(
bus
,
0x5588
,
0x09
);
}
else
{
write_reg
(
bus
,
0x5588
,
0x01
);
}
write_reg
(
bus
,
0x3212
,
0x13
);
//end group 3
write_reg
(
bus
,
0x3212
,
0xa3
);
//launch group 3
}
/* contrast:0~6 */
void
ov5640_contrast
(
struct
rt_i2c_bus_device
*
bus
,
rt_uint8_t
contrast
)
{
rt_uint8_t
reg0val
=
0x00
;
rt_uint8_t
reg1val
=
0x20
;
switch
(
contrast
)
{
case
0
:
reg1val
=
reg0val
=
0X14
;
break
;
case
1
:
reg1val
=
reg0val
=
0X18
;
break
;
case
2
:
reg1val
=
reg0val
=
0X1C
;
break
;
case
4
:
reg0val
=
0X10
;
reg1val
=
0X24
;
break
;
case
5
:
reg0val
=
0X18
;
reg1val
=
0X28
;
break
;
case
6
:
reg0val
=
0X1C
;
reg1val
=
0X2C
;
break
;
}
write_reg
(
bus
,
0x3212
,
0x03
);
//start group 3
write_reg
(
bus
,
0x5585
,
reg0val
);
write_reg
(
bus
,
0x5586
,
reg1val
);
write_reg
(
bus
,
0x3212
,
0x13
);
//end group 3
write_reg
(
bus
,
0x3212
,
0xa3
);
//launch group 3
}
/* sharp:0~33 */
void
ov5640_set_sharpness
(
struct
rt_i2c_bus_device
*
bus
,
rt_uint8_t
sharp
)
{
if
(
sharp
<
33
)
{
write_reg
(
bus
,
0x5308
,
0x65
);
write_reg
(
bus
,
0x5302
,
sharp
);
}
else
{
write_reg
(
bus
,
0x5308
,
0x25
);
write_reg
(
bus
,
0x5300
,
0x08
);
write_reg
(
bus
,
0x5301
,
0x30
);
write_reg
(
bus
,
0x5302
,
0x10
);
write_reg
(
bus
,
0x5303
,
0x00
);
write_reg
(
bus
,
0x5309
,
0x08
);
write_reg
(
bus
,
0x530a
,
0x30
);
write_reg
(
bus
,
0x530b
,
0x04
);
write_reg
(
bus
,
0x530c
,
0x06
);
}
}
rt_uint8_t
ov5640_focus_constant
(
struct
rt_i2c_bus_device
*
bus
)
{
rt_uint8_t
temp
=
0
;
rt_uint16_t
tickstrat
=
0
;
write_reg
(
bus
,
0x3023
,
0x01
);
write_reg
(
bus
,
0x3022
,
0x08
);
do
{
tickstrat
=
rt_tick_get
();
read_reg
(
bus
,
0x3023
,
1
,
&
temp
);
if
(
rt_tick_get
()
-
tickstrat
>
1000
)
{
return
RT_ERROR
;
}
}
while
(
temp
!=
0x00
);
write_reg
(
bus
,
0x3023
,
0x01
);
write_reg
(
bus
,
0x3022
,
0x04
);
do
{
tickstrat
=
rt_tick_get
();
read_reg
(
bus
,
0x3023
,
1
,
&
temp
);
if
(
rt_tick_get
()
-
tickstrat
>
1000
)
{
return
RT_ERROR
;
}
}
while
(
temp
!=
0x00
);
return
0
;
}
rt_uint8_t
ov5640_set_outsize
(
struct
rt_i2c_bus_device
*
bus
,
rt_uint16_t
offx
,
rt_uint16_t
offy
,
rt_uint16_t
width
,
rt_uint16_t
height
)
{
write_reg
(
bus
,
0X3212
,
0X03
);
write_reg
(
bus
,
0x3808
,
width
>>
8
);
write_reg
(
bus
,
0x3809
,
width
&
0xff
);
write_reg
(
bus
,
0x380a
,
height
>>
8
);
write_reg
(
bus
,
0x380b
,
height
&
0xff
);
write_reg
(
bus
,
0x3810
,
offx
>>
8
);
write_reg
(
bus
,
0x3811
,
offx
&
0xff
);
write_reg
(
bus
,
0x3812
,
offy
>>
8
);
write_reg
(
bus
,
0x3813
,
offy
&
0xff
);
write_reg
(
bus
,
0X3212
,
0X13
);
write_reg
(
bus
,
0X3212
,
0Xa3
);
return
RT_EOK
;
}
void
rt_hw_camera_rx_callback
(
void
)
{
rt_uint16_t
i
;
rt_int32_t
*
pbuf
=
RT_NULL
;
pbuf
=
JPEG_DATA_BUF
+
jpeg_data_len
;
if
(((
DMA_Stream_TypeDef
*
)
hdma_dcmi
.
Instance
)
->
CR
&
(
1
<<
19
))
{
for
(
i
=
0
;
i
<
JPEG_LINE_SIZE
;
i
++
)
{
pbuf
[
i
]
=
JPEG_LINE_BUF
[
0
][
i
];
}
jpeg_data_len
+=
JPEG_LINE_SIZE
;
}
else
{
for
(
i
=
0
;
i
<
JPEG_LINE_SIZE
;
i
++
)
{
pbuf
[
i
]
=
JPEG_LINE_BUF
[
1
][
i
];
}
jpeg_data_len
+=
JPEG_LINE_SIZE
;
}
}
/* After a frame of JPEG data has been collected. */
void
jpeg_data_process
(
void
)
{
rt_uint16_t
i
,
rlen
;
int
*
pbuf
=
RT_NULL
;
if
(
!
jpeg_data_ok
)
{
__HAL_DMA_DISABLE
(
&
hdma_dcmi
);
rlen
=
JPEG_LINE_SIZE
-
__HAL_DMA_GET_COUNTER
(
&
hdma_dcmi
);
pbuf
=
JPEG_DATA_BUF
+
jpeg_data_len
;
if
(((
DMA_Stream_TypeDef
*
)
hdma_dcmi
.
Instance
)
->
CR
&
(
1
<<
19
))
{
for
(
i
=
0
;
i
<
rlen
;
i
++
)
{
pbuf
[
i
]
=
JPEG_LINE_BUF
[
1
][
i
];
}
}
else
{
for
(
i
=
0
;
i
<
rlen
;
i
++
)
{
pbuf
[
i
]
=
JPEG_LINE_BUF
[
0
][
i
];
}
}
jpeg_data_len
+=
rlen
;
jpeg_data_ok
=
1
;
}
if
(
jpeg_data_ok
==
2
)
{
__HAL_DMA_SET_COUNTER
(
&
hdma_dcmi
,
JPEG_LINE_SIZE
);
__HAL_DMA_ENABLE
(
&
hdma_dcmi
);
jpeg_data_ok
=
0
;
jpeg_data_len
=
0
;
}
}
int
ov5640_set_xclk_frequency
(
uint32_t
frequency
)
{
extern
void
HAL_TIM_MspPostInit
(
TIM_HandleTypeDef
*
htim
);
int
tclk
=
HAL_RCC_GetPCLK2Freq
()
*
2
;
int
period
=
(
tclk
/
frequency
)
-
1
;
int
pulse
=
period
/
2
;
TIM_HandleTypeDef
TIMHandle
=
{.
Instance
=
TIM1
};
if
(
TIMHandle
.
Init
.
Period
&&
(
TIMHandle
.
Init
.
Period
!=
period
))
{
__HAL_TIM_SET_AUTORELOAD
(
&
TIMHandle
,
period
);
__HAL_TIM_SET_COMPARE
(
&
TIMHandle
,
TIM_CHANNEL_1
,
pulse
);
return
0
;
}
TIMHandle
.
Init
.
Period
=
period
;
TIMHandle
.
Init
.
Prescaler
=
0
;
TIMHandle
.
Init
.
CounterMode
=
TIM_COUNTERMODE_UP
;
TIMHandle
.
Init
.
ClockDivision
=
TIM_CLOCKDIVISION_DIV1
;
TIMHandle
.
Init
.
RepetitionCounter
=
0
;
TIMHandle
.
Init
.
AutoReloadPreload
=
TIM_AUTORELOAD_PRELOAD_ENABLE
;
TIM_OC_InitTypeDef
TIMOCHandle
;
TIMOCHandle
.
Pulse
=
pulse
;
TIMOCHandle
.
OCMode
=
TIM_OCMODE_PWM1
;
TIMOCHandle
.
OCPolarity
=
TIM_OCPOLARITY_HIGH
;
TIMOCHandle
.
OCNPolarity
=
TIM_OCNPOLARITY_HIGH
;
TIMOCHandle
.
OCFastMode
=
TIM_OCFAST_DISABLE
;
TIMOCHandle
.
OCIdleState
=
TIM_OCIDLESTATE_RESET
;
TIMOCHandle
.
OCNIdleState
=
TIM_OCNIDLESTATE_RESET
;
HAL_TIM_MspPostInit
(
&
TIMHandle
);
if
((
HAL_TIM_PWM_Init
(
&
TIMHandle
)
!=
HAL_OK
)
||
(
HAL_TIM_PWM_ConfigChannel
(
&
TIMHandle
,
&
TIMOCHandle
,
TIM_CHANNEL_1
)
!=
HAL_OK
)
||
(
HAL_TIM_PWM_Start
(
&
TIMHandle
,
TIM_CHANNEL_1
)
!=
HAL_OK
))
{
rt_kprintf
(
"config fail!
\n
"
);
return
-
1
;
}
return
0
;
}
int
rt_hw_ov5640_init
(
void
)
{
ov5640_set_xclk_frequency
(
24000000
);
extern
void
rt_hw_dcmi_dma_config
(
rt_uint32_t
dst_addr1
,
rt_uint32_t
dst_addr2
,
rt_uint16_t
len
);
static
rt_uint16_t
id
=
0
;
rt_device_t
dcmi_dev
=
RT_NULL
;
i2c_bus
=
rt_i2c_bus_device_find
(
I2C_NAME
);
if
(
i2c_bus
==
RT_NULL
)
{
LOG_E
(
"can't find %c deivce"
,
I2C_NAME
);
return
RT_ERROR
;
}
ov5640_hard_reset
();
ov5640_read_id
(
i2c_bus
,
&
id
);
ov5640_config
(
i2c_bus
);
ov5640_rgb565_mode
(
i2c_bus
);
/* rgb565 mode */
ov5640_focus_init
(
i2c_bus
);
ov5640_jpeg_mode
(
i2c_bus
);
/* jpeg mode */
ov5640_set_light
(
i2c_bus
,
0
);
/* auto mode */
ov5640_color_saturation
(
i2c_bus
,
3
);
ov5640_set_brightness
(
i2c_bus
,
4
);
/* brigetness 0 */
ov5640_contrast
(
i2c_bus
,
3
);
ov5640_set_sharpness
(
i2c_bus
,
33
);
ov5640_focus_constant
(
i2c_bus
);
/* dcmi init */
dcmi_dev
=
rt_device_find
(
"dcmi"
);
if
(
dcmi_dev
==
RT_NULL
)
{
LOG_E
(
"can't find dcmi device!"
);
return
RT_ERROR
;
}
rt_device_open
(
dcmi_dev
,
RT_DEVICE_FLAG_RDWR
);
rt_hw_dcmi_dma_config
((
rt_uint32_t
)
&
JPEG_LINE_BUF
[
0
],
(
rt_uint32_t
)
&
JPEG_LINE_BUF
[
1
],
JPEG_LINE_SIZE
);
ov5640_set_outsize
(
i2c_bus
,
4
,
0
,
jpeg_picture_size
[
1
][
0
],
jpeg_picture_size
[
1
][
1
]);
return
RT_EOK
;
}
INIT_APP_EXPORT
(
rt_hw_ov5640_init
);
int
camera_sample
(
int
argc
,
char
**
argv
)
{
int
fd
=
-
1
;
rt_uint32_t
i
,
jpg_start
,
jpg_len
;
rt_uint16_t
tickstart
=
0
;
rt_uint8_t
jpg_head
=
0
;
rt_uint8_t
*
p
=
RT_NULL
;
if
(
argc
!=
2
)
{
rt_kprintf
(
"Usage:
\n
"
);
rt_kprintf
(
"camera_sample file.jpg
\n
"
);
return
-
1
;
}
/* start dcmi capture */
__HAL_DMA_ENABLE
(
&
hdma_dcmi
);
dcmi
.
Instance
->
CR
|=
DCMI_CR_CAPTURE
;
tickstart
=
rt_tick_get
();
while
(
1
)
{
if
(
rt_tick_get
()
-
tickstart
>
1000
)
{
LOG_E
(
"picture capture overtime!"
);
break
;
}
if
(
jpeg_data_ok
==
1
)
{
dcmi
.
Instance
->
CR
&=
~
(
DCMI_CR_CAPTURE
);
tickstart
=
rt_tick_get
();
while
(
dcmi
.
Instance
->
CR
&
0x01
)
{
if
(
rt_tick_get
()
-
tickstart
>
0x1000
)
{
rt_kprintf
(
"dcmi close failed!
\n
"
);
jpeg_data_ok
=
2
;
break
;
}
}
__HAL_DMA_DISABLE
(
&
hdma_dcmi
);
p
=
(
rt_uint8_t
*
)
JPEG_DATA_BUF
;
jpg_len
=
0
;
jpg_head
=
0
;
for
(
i
=
0
;
i
<
jpeg_data_len
*
4
;
i
++
)
{
/* jpg head */
if
((
p
[
i
]
==
0xFF
)
&&
(
p
[
i
+
1
]
==
0xD8
))
{
jpg_start
=
i
;
jpg_head
=
1
;
}
/* jpg end */
if
((
p
[
i
]
==
0xFF
)
&&
(
p
[
i
+
1
]
==
0xD9
)
&&
jpg_head
)
{
jpg_len
=
i
-
jpg_start
+
2
;
/* a picture len */
break
;
}
}
if
(
jpg_len
)
{
p
+=
jpg_start
;
fd
=
open
(
argv
[
1
],
O_WRONLY
|
O_CREAT
);
if
(
fd
<
0
)
{
rt_kprintf
(
"open file for recording failed!
\n
"
);
return
-
RT_ERROR
;
}
else
{
write
(
fd
,
p
,
jpg_len
);
close
(
fd
);
rt_kprintf
(
"picture capture complate!
\n
"
);
memset
(
JPEG_DATA_BUF
,
0
,
jpeg_data_len
);
jpeg_data_len
=
0
;
jpeg_data_ok
=
0
;
break
;
}
}
jpeg_data_ok
=
2
;
}
}
return
RT_EOK
;
}
MSH_CMD_EXPORT
(
camera_sample
,
record
picture
to
a
jpg
file
);
#endif
bsp/stm32/stm32h743-openmv-h7plus/board/ports/drv_ov5640.h
0 → 100644
浏览文件 @
da0164cf
此差异已折叠。
点击以展开。
bsp/stm32/stm32h743-openmv-h7plus/rtconfig.h
浏览文件 @
da0164cf
...
...
@@ -98,7 +98,10 @@
#define RT_USING_SERIAL_V1
#define RT_SERIAL_USING_DMA
#define RT_SERIAL_RB_BUFSZ 64
#define RT_USING_I2C
#define RT_USING_I2C_BITOPS
#define RT_USING_PIN
#define RT_USING_RTC
#define RT_USING_SDIO
#define RT_SDIO_STACK_SIZE 512
#define RT_SDIO_THREAD_PRIORITY 15
...
...
@@ -236,9 +239,21 @@
#define BSP_USING_GPIO
#define BSP_USING_UART
#define BSP_USING_UART1
#define BSP_USING_QSPI
/* Onboard Peripheral Drivers */
#define BSP_USING_SDRAM
#define BSP_USING_QSPI_FLASH
#define BSP_USING_USBD
#define BSP_USING_OV5640
#define BSP_USING_DCMI
#define BSP_USING_I2C
#define BSP_USING_I2C1
/* Notice: PB8 --> 24; PB9 --> 25 */
#define BSP_I2C1_SCL_PIN 24
#define BSP_I2C1_SDA_PIN 25
#endif
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录