TM STM32F4xx Libraries  v1.0.0
Libraries for STM32F4xx devices from Tilen Majerle
tm_stm32f4_dma2d_graphic.h
1 
30 #ifndef TM_DMA2DGRAPHIC_H
31 #define TM_DMA2DGRAPHIC_H 100
32 
33 /* C++ detection */
34 #ifdef __cplusplus
35 extern C {
36 #endif
37 
84 #include "stm32f4xx.h"
85 #include "stm32f4xx_rcc.h"
86 #include "stm32f4xx_dma2d.h"
87 #include "defines.h"
88 
98 #ifndef DMA2D_GRAPHIC_LCD_WIDTH
99  #if defined(DMA2D_GRAPHIC_USE_STM324x9_EVAL) || defined(TM_DISCO_STM324x9_EVAL)
100  #define DMA2D_GRAPHIC_LCD_WIDTH 640
101  #else
102  #define DMA2D_GRAPHIC_LCD_WIDTH 240
103  #endif
104 #endif
105 
109 #ifndef DMA2D_GRAPHIC_LCD_HEIGHT
110  #if defined(DMA2D_GRAPHIC_USE_STM324x9_EVAL) || defined(TM_DISCO_STM324x9_EVAL)
111  #define DMA2D_GRAPHIC_LCD_HEIGHT 480
112  #else
113  #define DMA2D_GRAPHIC_LCD_HEIGHT 320
114  #endif
115 #endif
116 
121 #ifndef DMA2D_GRAPHIC_RAM_ADDR
122  #if defined(DMA2D_GRAPHIC_USE_STM324x9_EVAL) || defined(TM_DISCO_STM324x9_EVAL)
123  #define DMA2D_GRAPHIC_RAM_ADDR 0xC0000000
124  #else
125  #define DMA2D_GRAPHIC_RAM_ADDR 0xD0000000
126  #endif
127 #endif
128 
132 #ifndef DMA2D_GRAPHIC_TIMEOUT
133 #define DMA2D_GRAPHIC_TIMEOUT (uint32_t)10000000
134 #endif
135 
138 #define DMA2D_GRAPHIC_PIXELS DMA2D_GRAPHIC_LCD_WIDTH * DMA2D_GRAPHIC_LCD_HEIGHT
139 
147 #define GRAPHIC_COLOR_WHITE 0xFFFF
148 #define GRAPHIC_COLOR_BLACK 0x0000
149 #define GRAPHIC_COLOR_RED 0xF800
150 #define GRAPHIC_COLOR_GREEN 0x07E0
151 #define GRAPHIC_COLOR_GREEN2 0xB723
152 #define GRAPHIC_COLOR_BLUE 0x001F
153 #define GRAPHIC_COLOR_BLUE2 0x051D
154 #define GRAPHIC_COLOR_YELLOW 0xFFE0
155 #define GRAPHIC_COLOR_ORANGE 0xFBE4
156 #define GRAPHIC_COLOR_CYAN 0x07FF
157 #define GRAPHIC_COLOR_MAGENTA 0xA254
158 #define GRAPHIC_COLOR_GRAY 0x7BEF
159 #define GRAPHIC_COLOR_BROWN 0xBBCA
160 
161 /* Waiting flags */
162 #define DMA2D_WORKING ((DMA2D->CR & DMA2D_CR_START))
163 #define DMA2D_WAIT do { while (DMA2D_WORKING); DMA2D->IFCR = DMA2D_IFSR_CTCIF;} while (0);
164 
183 typedef struct {
184  uint16_t X;
185  uint16_t Y;
187 
192 typedef struct {
193  uint16_t Width;
194  uint16_t Height;
195  uint8_t BytesPerPixel;
196  uint32_t BufferStart;
197  uint32_t BufferOffset;
198  uint8_t Orientation;
200 
217 void TM_DMA2DGRAPHIC_Init(void);
218 
229 void TM_DMA2DGRAPHIC_SetLayer(uint8_t layer_number);
230 
242 void TM_DMA2DGRAPHIC_SetOrientation(uint8_t orientation);
243 
249 void TM_DMA2DGRAPHIC_Fill(uint32_t color);
250 
258 void TM_DMA2DGRAPHIC_DrawPixel(uint16_t x, uint16_t y, uint32_t color);
259 
266 uint32_t TM_DMA2DGRAPHIC_GetPixel(uint16_t x, uint16_t y);
267 
276 void TM_DMA2DGRAPHIC_DrawVerticalLine(int16_t x, int16_t y, uint16_t length, uint32_t color);
277 
286 void TM_DMA2DGRAPHIC_DrawHorizontalLine(int16_t x, int16_t y, uint16_t length, uint32_t color);
287 
297 void TM_DMA2DGRAPHIC_DrawLine(int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint32_t color);
298 
306 void TM_DMA2DGRAPHIC_DrawPolyLine(TM_DMA2DRAPHIC_Poly_t* Coordinates, uint16_t count, uint32_t color);
307 
317 void TM_DMA2DGRAPHIC_DrawRectangle(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint32_t color);
318 
328 void TM_DMA2DGRAPHIC_DrawFilledRectangle(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint32_t color);
329 
340 void TM_DMA2DGRAPHIC_DrawRoundedRectangle(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t r, uint32_t color);
341 
352 void TM_DMA2DGRAPHIC_DrawFilledRoundedRectangle(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t r, uint32_t color);
353 
362 void TM_DMA2DGRAPHIC_DrawCircle(uint16_t x0, uint16_t y0, uint16_t r, uint32_t color);
363 
372 void TM_DMA2DGRAPHIC_DrawFilledCircle(uint16_t x0, uint16_t y0, uint16_t r, uint32_t color);
373 
385 void TM_DMA2DGRAPHIC_DrawTriangle(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t x3, uint16_t y3, uint32_t color);
386 
398 void TM_DMA2DGRAPHIC_DrawFilledTriangle(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t x3, uint16_t y3, uint32_t color);
399 
400 void TM_DMA2DGRAPHIC_CopyBuffer(void* pSrc, void* pDst, uint32_t xSize, uint32_t ySize, uint32_t OffLineSrc, uint32_t OffLineDst);
401 void TM_DMA2DGRAPHIC_CopyBufferIT(void* pSrc, void* pDst, uint32_t xSize, uint32_t ySize, uint32_t OffLineSrc, uint32_t OffLineDst);
402 
403 /* Private functions */
404 void TM_INT_DMA2DGRAPHIC_SetConf(TM_DMA2DGRAPHIC_INT_Conf_t* Conf);
405 
418 /* C++ detection */
419 #ifdef __cplusplus
420 }
421 #endif
422 
423 #endif
Structure for polygon line.
Definition: tm_stm32f4_dma2d_graphic.h:183
void TM_DMA2DGRAPHIC_DrawPixel(uint16_t x, uint16_t y, uint32_t color)
Draws single pixel on currently active layer.
uint32_t TM_DMA2DGRAPHIC_GetPixel(uint16_t x, uint16_t y)
Gets single pixel on currently active layer.
void TM_DMA2DGRAPHIC_DrawRectangle(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint32_t color)
Draws rectangle on currently active layer.
void TM_DMA2DGRAPHIC_Init(void)
Initializes and prepare DMA2D for working.
void TM_DMA2DGRAPHIC_DrawCircle(uint16_t x0, uint16_t y0, uint16_t r, uint32_t color)
Draws circle on currently active layer.
void TM_DMA2DGRAPHIC_DrawRoundedRectangle(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t r, uint32_t color)
Draws rounded rectangle on currently active layer.
void TM_DMA2DGRAPHIC_SetLayer(uint8_t layer_number)
Sets layer for DMA2D working memory.
void TM_DMA2DGRAPHIC_DrawFilledRectangle(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint32_t color)
Draws filled rectangle on currently active layer.
Configuration structure.
Definition: tm_stm32f4_dma2d_graphic.h:192
void TM_DMA2DGRAPHIC_DrawFilledTriangle(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t x3, uint16_t y3, uint32_t color)
Draws filled triangle on currently active layer.
uint16_t X
Definition: tm_stm32f4_dma2d_graphic.h:184
void TM_DMA2DGRAPHIC_DrawVerticalLine(int16_t x, int16_t y, uint16_t length, uint32_t color)
Draws vertical line on currently active layer.
void TM_DMA2DGRAPHIC_SetOrientation(uint8_t orientation)
Sets orientation for DMA2D peripheral.
void TM_DMA2DGRAPHIC_DrawHorizontalLine(int16_t x, int16_t y, uint16_t length, uint32_t color)
Draws horizontal line on currently active layer.
void TM_DMA2DGRAPHIC_Fill(uint32_t color)
Fills entire LCD memory layer with custom color.
void TM_DMA2DGRAPHIC_DrawPolyLine(TM_DMA2DRAPHIC_Poly_t *Coordinates, uint16_t count, uint32_t color)
Draws polygon line on currently active layer.
void TM_DMA2DGRAPHIC_DrawLine(int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint32_t color)
Draws line on currently active layer.
void TM_DMA2DGRAPHIC_DrawTriangle(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t x3, uint16_t y3, uint32_t color)
Draws triangle on currently active layer.
void TM_DMA2DGRAPHIC_DrawFilledCircle(uint16_t x0, uint16_t y0, uint16_t r, uint32_t color)
Draws filed circle on currently active layer.
void TM_DMA2DGRAPHIC_DrawFilledRoundedRectangle(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t r, uint32_t color)
Draws filled rounded rectangle on currently active layer.
uint16_t Y
Definition: tm_stm32f4_dma2d_graphic.h:185