STM32F4 DMA2D

图像处理的专门DMA

看一段示例代码

 1 /**
 2   * @brief  Displays a line.
 3   * @param Xpos: specifies the X position.
 4   * @param Ypos: specifies the Y position.
 5   * @param Length: line length.
 6   * @param Direction: line direction.
 7   *   This parameter can be one of the following values: Vertical or Horizontal.
 8   * @retval None
 9   */
10 void LCD_DrawLine(uint16_t Xpos, uint16_t Ypos, uint16_t Length, uint8_t Direction)
11 {
12   DMA2D_InitTypeDef      DMA2D_InitStruct;
13
14   uint32_t  Xaddress = 0;
15   uint16_t Red_Value = 0, Green_Value = 0, Blue_Value = 0;
16
17   Xaddress = CurrentFrameBuffer + 2*(LCD_PIXEL_WIDTH*Ypos + Xpos);
18
19   Red_Value = (0xF800 & CurrentTextColor) >> 11;
20   Blue_Value = 0x001F & CurrentTextColor;
21   Green_Value = (0x07E0 & CurrentTextColor) >> 5;
22
23   /* Configure DMA2D */
24   DMA2D_DeInit();
25   DMA2D_InitStruct.DMA2D_Mode = DMA2D_R2M;
26   DMA2D_InitStruct.DMA2D_CMode = DMA2D_RGB565;
27   DMA2D_InitStruct.DMA2D_OutputGreen = Green_Value;
28   DMA2D_InitStruct.DMA2D_OutputBlue = Blue_Value;
29   DMA2D_InitStruct.DMA2D_OutputRed = Red_Value;
30   DMA2D_InitStruct.DMA2D_OutputAlpha = 0x0F;
31   DMA2D_InitStruct.DMA2D_OutputMemoryAdd = Xaddress;
32
33   if(Direction == LCD_DIR_HORIZONTAL)
34   {
35     DMA2D_InitStruct.DMA2D_OutputOffset = 0;
36     DMA2D_InitStruct.DMA2D_NumberOfLine = 1;
37     DMA2D_InitStruct.DMA2D_PixelPerLine = Length;
38   }
39   else
40   {
41     DMA2D_InitStruct.DMA2D_OutputOffset = LCD_PIXEL_WIDTH - 1;
42     DMA2D_InitStruct.DMA2D_NumberOfLine = Length;
43     DMA2D_InitStruct.DMA2D_PixelPerLine = 1;
44   }
45
46   DMA2D_Init(&DMA2D_InitStruct);
47   /* Start Transfer */
48   DMA2D_StartTransfer();
49   /* Wait for CTC Flag activation */
50   while(DMA2D_GetFlagStatus(DMA2D_FLAG_TC) == RESET)
51   {
52   }
53
54 }

LCD_DrawLine

里面不好理解的是offset那块,其他统一模式设置看看手册即可,这个offset设置我们先看寄存器是哪个

/* Configure the line Offset */
DMA2D->OOR &= ~(uint32_t)DMA2D_OOR_LO;
DMA2D->OOR |= (DMA2D_InitStruct->DMA2D_OutputOffset);

寄存器定义:

再看代码那几句:

if(Direction == LCD_DIR_HORIZONTAL)
{
DMA2D_InitStruct.DMA2D_OutputOffset = 0;
DMA2D_InitStruct.DMA2D_NumberOfLine = 1;
DMA2D_InitStruct.DMA2D_PixelPerLine = Length;
}
else
{
DMA2D_InitStruct.DMA2D_OutputOffset = LCD_PIXEL_WIDTH - 1;
DMA2D_InitStruct.DMA2D_NumberOfLine = Length;
DMA2D_InitStruct.DMA2D_PixelPerLine = 1;
}

if里很明白,在指定位置没有offset画一条length长的线

else是画的竖线,所以每行只画一个点,画length条线,所以每行只画一个点,offset的值就是:LCD_PIXEL_WIDTH - 1

时间: 2024-10-11 08:50:35

STM32F4 DMA2D的相关文章

STM32F4——NVIC中断优先级及外部中断

NVIC中断优先级 一.简介: CM4内核可以支持256个中断,包括16个内核中断和240个外部中断,256级的可编程中断设置.对于STM32F4没有用到CM4内核的所有东西,只是用到了一部分,对于STM32F40和41系列共有92个中断,其中有10个内核中断和82个可屏蔽中断,常用的为82个可屏蔽中断. 二.相关寄存器: ISER[8]-中断使能寄存器组,用来使能中断,每一位控制一个中断,由于上面已经说明了控制82个可屏蔽的中断,因此利用ISER[0~2]这三个32位寄存器就够了.一下的几个寄

STM32F4 DMA2D_M2M_PFC

此例程为STM324x9I_EVAL:DCMI_CaptureMode,使用的stm32f4xx_hal_driver, At each camera line event, the line is converted to ARGB8888 pixel format and transferred to LCD_FRAME_BUFFER using DMA2D. 这里仅记录例程中DMA2D这段,Camera RGB565格式 LCD RGB888 1 /** 2 * @brief Conver

STM32F4 SPI with DMA

STM32F4 SPI with DMA A few people have requested code, so I thought I’d post the code showing how I’ve configured my GPIO, timer, SPI, DMA and NVIC modules, along with some explanation of how the system works.Note that I’m using the STM32F4 Standard

STM32F4 HAL Composite USB Device Example : CDC + MSC

STM32F4 USB Composite CDC + MSC I'm in the process of building a USB composite CDC + MSC device on the STM32F4 Discovery board but am having trouble getting windows to recognise it. Using USBlyzer all the descriptor info seems ok but windows will onl

STM32F4学习笔记(一)

新建工程 由于使用固件库开发的高效便捷,我选择了使用STM32F4标准外设库.开发板的芯片为STM32F429XX,其他的可根据相关情况进行变化. 在标准固件库中,存在在CMSIS和STM32F4xx_StdPeriph_Driver两个文件夹.在工程中新建一个文件夹Drivers,在此目录中再新建两个目录Inc和Src,分别用于 保存头文件和源文件.将STM32F4xx_StdPeriph_Driver目录下的头文件和源文件,分别拷贝到Drivers目录下的录中.再将CMSIS目录中的需要的文

STM32F4时钟配置分析

//学习STM32F4的过程中关于时钟上面讲的比较好 特地转发与大家分享 STM32F4时钟设置分析 原文博客链接:http://blog.csdn.net/jdh99,作者:jdh,转载请注明. 环境: 主机:WIN7 开发环境:MDK4.72 MCU:STM32F407VGT6 STM32F4启动与STM32F10X不同,时钟已经默认配置好. 1.启动代码: 文件:startup_stm32f4xx.s [cpp] view plain copy <span style="font-f

VGA Output from STM32F4 Discovery board

VGA Output from STM32F4 Discovery board I love the web! There are so many cool projects out there, and some, with a tweak or two, get me where I want to go quickly, saving a ton of time and effort. Case in point: The Artektit page on VGA output using

One-wire Demo on the STM32F4 Discovery Board

One-wire Demo on the STM32F4 Discovery Board Some of the devs at work were struggling to get their software talking to a Dallas 1-wire device.  I remember doing 1-wire comms back in the 1990s, but I hadn't done any 1-wire lately and all of my old cod

78-WS2812-Library (STM32F4)

78-WS2812-Library (STM32F4) //-------------------------------------------------------------- // File : stm32_ub_ws2812.h //-------------------------------------------------------------- //--------------------------------------------------------------