From 77bb029ef4ee331de57bc407594db15e2d17084f Mon Sep 17 00:00:00 2001 From: Thomas Pietrzak Date: Sun, 23 Sep 2018 23:03:44 +0200 Subject: [PATCH 01/11] draft for Graphic Library --- uGL/uGL.h | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 uGL/uGL.h diff --git a/uGL/uGL.h b/uGL/uGL.h new file mode 100644 index 0000000..c273ff2 --- /dev/null +++ b/uGL/uGL.h @@ -0,0 +1,38 @@ +#pragma once + +typedef struct { + uint8_t r; + uint8_t g; + uint8_t b; + uint8_t a; +} uGL_color; + +typedef uGL_color *uGL_lookuptable; + +typedef enum { + INDEXED1 1, + INDEXED2 2, + INDEXED4 4, + INDEXED8 8, + RGB 24, + RGBA 32 +} uGL_colormode; + +typedef struct { + uint8_t *data; + uint16_t width; + uint16_t length; + uGL_colormode colormode; + uGL_lookuptable *lookuptable; +} uGL_image; + + +uGL_init(); + +uGL_drawPixel(uint16_t x, uint16_t y, uGL_color color); +uGL_drawHLine(uint16_t x, uint16_t y, uint16_t length, uGL_color color); +uGL_drawVLine(uint16_t x, uint16_t y, uint16_t length, uGL_color color); +uGL_drawFrame(uint16_t x, uint16_t y, uint16_t width, uint16_t length, uGL_color color); +uGL_drawRectangle(uint16_t x, uint16_t y, uint16_t width, uint16_t length, uGL_color color); + +uGl_blitImage(uGL_image image, uint16_t x, uint16_t y); From 7b7e4b5e9741a498151ae989d48cb276b8752fd4 Mon Sep 17 00:00:00 2001 From: Thomas Pietrzak Date: Mon, 24 Sep 2018 08:14:30 +0200 Subject: [PATCH 02/11] data last --- uGL/uGL.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/uGL/uGL.h b/uGL/uGL.h index c273ff2..855d2e8 100644 --- a/uGL/uGL.h +++ b/uGL/uGL.h @@ -19,11 +19,11 @@ typedef enum { } uGL_colormode; typedef struct { - uint8_t *data; uint16_t width; uint16_t length; uGL_colormode colormode; uGL_lookuptable *lookuptable; + uint8_t *data; } uGL_image; From 6dbd74c451cfaa114aa8d6301000d863999b5ec4 Mon Sep 17 00:00:00 2001 From: Thomas Pietrzak Date: Mon, 24 Sep 2018 08:23:08 +0200 Subject: [PATCH 03/11] pointer to image --- uGL/uGL.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/uGL/uGL.h b/uGL/uGL.h index 855d2e8..8b94ac2 100644 --- a/uGL/uGL.h +++ b/uGL/uGL.h @@ -35,4 +35,4 @@ uGL_drawVLine(uint16_t x, uint16_t y, uint16_t length, uGL_color color); uGL_drawFrame(uint16_t x, uint16_t y, uint16_t width, uint16_t length, uGL_color color); uGL_drawRectangle(uint16_t x, uint16_t y, uint16_t width, uint16_t length, uGL_color color); -uGl_blitImage(uGL_image image, uint16_t x, uint16_t y); +uGl_blitImage(uGL_image *image, uint16_t x, uint16_t y); From 6390ab5bf8229db29f7eef1a27bf2d3b9527659c Mon Sep 17 00:00:00 2001 From: Thomas Pietrzak Date: Tue, 25 Sep 2018 10:18:14 +0200 Subject: [PATCH 04/11] example --- .gitignore | 2 + Makefile | 25 +- bootloader.c | 19 + uGL/Makefile | 18 + uGL/config.mk | 5 + uGL/fonts.c | 1003 ++++++++++++++ uGL/fonts.dep | 8 + uGL/fonts.h | 124 ++ uGL/stm32f429i_discovery.c | 428 ++++++ uGL/stm32f429i_discovery.dep | 42 + uGL/stm32f429i_discovery.h | 233 ++++ uGL/stm32f429i_discovery_lcd.c | 1968 ++++++++++++++++++++++++++++ uGL/stm32f429i_discovery_lcd.dep | 45 + uGL/stm32f429i_discovery_lcd.h | 334 +++++ uGL/stm32f429i_discovery_sdram.c | 430 ++++++ uGL/stm32f429i_discovery_sdram.dep | 43 + uGL/stm32f429i_discovery_sdram.h | 165 +++ uGL/uGL.c | 52 + uGL/uGL.h | 34 +- 19 files changed, 4951 insertions(+), 27 deletions(-) create mode 100644 uGL/Makefile create mode 100644 uGL/config.mk create mode 100755 uGL/fonts.c create mode 100644 uGL/fonts.dep create mode 100755 uGL/fonts.h create mode 100755 uGL/stm32f429i_discovery.c create mode 100644 uGL/stm32f429i_discovery.dep create mode 100755 uGL/stm32f429i_discovery.h create mode 100755 uGL/stm32f429i_discovery_lcd.c create mode 100644 uGL/stm32f429i_discovery_lcd.dep create mode 100755 uGL/stm32f429i_discovery_lcd.h create mode 100755 uGL/stm32f429i_discovery_sdram.c create mode 100644 uGL/stm32f429i_discovery_sdram.dep create mode 100755 uGL/stm32f429i_discovery_sdram.h create mode 100644 uGL/uGL.c diff --git a/.gitignore b/.gitignore index 86b64a3..d645620 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,7 @@ .DS_Store *~ +*.dep +*.bin # Prerequisites *.d diff --git a/Makefile b/Makefile index f61d0c3..9d3b68e 100644 --- a/Makefile +++ b/Makefile @@ -1,16 +1,9 @@ export BOARD = stm32f429discovery -ROOTDIR = $(CURDIR)/uC-sdk - +export ROOTDIR = $(CURDIR)/uC-sdk export VERBOSE = true -ifeq ($(wildcard $(ROOTDIR)/uC-sdk.root),) -ifneq ($(wildcard ../../../uC-sdk.root),) -ROOTDIR = ../../.. -endif -endif - TARGET = bootloader.bin -TARGET_SRCS = bootloader.c +TARGET_SRCS = bootloader.c uGL/uGL.c uGL/stm32f429i_discovery.c uGL/stm32f429i_discovery_lcd.c uGL/stm32f429i_discovery_sdram.c uGL/fonts.c LIBDEPS = \ $(ROOTDIR)/FreeRTOS/libFreeRTOS.a \ @@ -24,14 +17,18 @@ $(ROOTDIR)/hardware/libhardware.a \ LIBS = -Wl,--start-group $(LIBDEPS) -Wl,--end-group TARGET_INCLUDES = include +export MAINDIR = $(CURDIR) + +include $(MAINDIR)/uGL/config.mk include $(ROOTDIR)/common.mk -all: uC-sdk $(TARGET) +all: uC-sdk uGL $(TARGET) clean: clean-generic $(Q)$(MAKE) $(MAKE_OPTS) -C $(ROOTDIR) clean + $(Q)$(MAKE) $(MAKE_OPTS) -C uGL clean -.PHONY: uC-sdk +.PHONY: uC-sdk uGL $(ROOTDIR)/FreeRTOS/libFreeRTOS.a: uC-sdk $(ROOTDIR)/arch/libarch.a: uC-sdk @@ -41,6 +38,10 @@ $(ROOTDIR)/libm/libm.a: uC-sdk $(ROOTDIR)/acorn/libacorn.a: uC-sdk $(ROOTDIR)/hardware/libhardware.a: uC-sdk +uGL: + $(E) "[MAKE] Entering uGL" + $(Q)$(MAKE) $(MAKE_OPTS) -C uGL + uC-sdk: $(E) "[MAKE] Entering uC-sdk" $(Q)$(MAKE) $(MAKE_OPTS) -C $(ROOTDIR) @@ -48,6 +49,8 @@ uC-sdk: deps: ldeps $(E) "[DEPS] Creating dependency tree for uC-sdk" $(Q)$(MAKE) $(MAKE_OPTS) -C $(ROOTDIR) ldeps + $(E) "[DEPS] Creating dependency tree for uGL" + $(Q)$(MAKE) $(MAKE_OPTS) -C uGL ldeps include $(ROOTDIR)/FreeRTOS/config.mk include $(ROOTDIR)/arch/config.mk diff --git a/bootloader.c b/bootloader.c index f8b643a..f3b6326 100644 --- a/bootloader.c +++ b/bootloader.c @@ -1,4 +1,23 @@ +#include + +#include "uGL/uGL.h" + int main() { + uGL_init(); + + uGL_color_t backgroundcolor = { .r = 70, .g = 120, .b = 240 }; + uGL_drawRectangle(0, 0, 240, 320, backgroundcolor); + + uGL_color_t rectcolor = { .r = 250, .g = 120, .b = 40 }; + uGL_drawRectangle(50, 100, 100, 200, rectcolor); + + uGL_color_t hlinecolor = { .r = 50, .g = 240, .b = 40 }; + uGL_drawHLine(20, 50, 100, hlinecolor); + + uGL_color_t vlinecolor = { .r = 250, .g = 240, .b = 40 }; + uGL_drawVLine(50, 20, 200, vlinecolor); + + while(1); return 0; } diff --git a/uGL/Makefile b/uGL/Makefile new file mode 100644 index 0000000..3709846 --- /dev/null +++ b/uGL/Makefile @@ -0,0 +1,18 @@ +all: $(TARGET_OBJ) + +export BOARD = stm32f429discovery + +include $(ROOTDIR)/common.mk +include config.mk +include $(ROOTDIR)/arch/config.mk +include $(ROOTDIR)/FreeRTOS/config.mk + +TARGET_SRCS += font.cs +TARGET_SRCS += stm32f429i_discovery.c +TARGET_SRCS += stm32f429i_discovery_lcd.c +TARGET_SRCS += stm32f429i_discovery_sdram.c + +include $(ROOTDIR)/target-rules.mk + +clean: clean-generic + diff --git a/uGL/config.mk b/uGL/config.mk new file mode 100644 index 0000000..1397477 --- /dev/null +++ b/uGL/config.mk @@ -0,0 +1,5 @@ +TARGET_INCLUDES += $(MAINDIR)/uGL + +ifeq ($(USE_MPU),true) +TARGET_CPPFLAGS += -DportUSING_MPU_WRAPPERS=1 +endif diff --git a/uGL/fonts.c b/uGL/fonts.c new file mode 100755 index 0000000..66b6e4d --- /dev/null +++ b/uGL/fonts.c @@ -0,0 +1,1003 @@ +/** + ****************************************************************************** + * @file fonts.c + * @author MCD Application Team + * @version V5.0.2 + * @date 05-March-2012 + * @brief This file provides text fonts for STM32xx-EVAL's LCD driver. + ****************************************************************************** + * @attention + * + *

© COPYRIGHT 2012 STMicroelectronics

+ * + * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.st.com/software_license_agreement_liberty_v2 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "fonts.h" + +/** @addtogroup Utilities + * @{ + */ + +/** @addtogroup STM32_EVAL + * @{ + */ + +/** @addtogroup Common + * @{ + */ + +/** @addtogroup FONTS + * @brief This file includes the Fonts driver of STM32xx-EVAL boards. + * @{ + */ + +/** @defgroup FONTS_Private_Types + * @{ + */ +/** + * @} + */ + + +/** @defgroup FONTS_Private_Defines + * @{ + */ +/** + * @} + */ + + +/** @defgroup FONTS_Private_Macros + * @{ + */ +/** + * @} + */ + + +/** @defgroup FONTS_Private_Variables + * @{ + */ +const uint16_t ASCII16x24_Table [] = { +/** + * @brief Space ' ' + */ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/** + * @brief '!' + */ + 0x0000, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, + 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0000, 0x0000, + 0x0180, 0x0180, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/** + * @brief '"' + */ + 0x0000, 0x0000, 0x00CC, 0x00CC, 0x00CC, 0x00CC, 0x00CC, 0x00CC, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/** + * @brief '#' + */ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0C60, 0x0C60, + 0x0C60, 0x0630, 0x0630, 0x1FFE, 0x1FFE, 0x0630, 0x0738, 0x0318, + 0x1FFE, 0x1FFE, 0x0318, 0x0318, 0x018C, 0x018C, 0x018C, 0x0000, +/** + * @brief '$' + */ + 0x0000, 0x0080, 0x03E0, 0x0FF8, 0x0E9C, 0x1C8C, 0x188C, 0x008C, + 0x0098, 0x01F8, 0x07E0, 0x0E80, 0x1C80, 0x188C, 0x188C, 0x189C, + 0x0CB8, 0x0FF0, 0x03E0, 0x0080, 0x0080, 0x0000, 0x0000, 0x0000, +/** + * @brief '%' + */ + 0x0000, 0x0000, 0x0000, 0x180E, 0x0C1B, 0x0C11, 0x0611, 0x0611, + 0x0311, 0x0311, 0x019B, 0x018E, 0x38C0, 0x6CC0, 0x4460, 0x4460, + 0x4430, 0x4430, 0x4418, 0x6C18, 0x380C, 0x0000, 0x0000, 0x0000, +/** + * @brief '&' + */ + 0x0000, 0x01E0, 0x03F0, 0x0738, 0x0618, 0x0618, 0x0330, 0x01F0, + 0x00F0, 0x00F8, 0x319C, 0x330E, 0x1E06, 0x1C06, 0x1C06, 0x3F06, + 0x73FC, 0x21F0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/** + * @brief ''' + */ + 0x0000, 0x0000, 0x000C, 0x000C, 0x000C, 0x000C, 0x000C, 0x000C, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/** + * @brief '(' + */ + 0x0000, 0x0200, 0x0300, 0x0180, 0x00C0, 0x00C0, 0x0060, 0x0060, + 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, + 0x0060, 0x0060, 0x00C0, 0x00C0, 0x0180, 0x0300, 0x0200, 0x0000, +/** + * @brief ')' + */ + 0x0000, 0x0020, 0x0060, 0x00C0, 0x0180, 0x0180, 0x0300, 0x0300, + 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, + 0x0300, 0x0300, 0x0180, 0x0180, 0x00C0, 0x0060, 0x0020, 0x0000, +/** + * @brief '*' + */ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x00C0, 0x00C0, + 0x06D8, 0x07F8, 0x01E0, 0x0330, 0x0738, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/** + * @brief '+' + */ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0180, 0x0180, + 0x0180, 0x0180, 0x0180, 0x3FFC, 0x3FFC, 0x0180, 0x0180, 0x0180, + 0x0180, 0x0180, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/** + * @brief ',' + */ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0180, 0x0180, 0x0100, 0x0100, 0x0080, 0x0000, 0x0000, +/** + * @brief '-' + */ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x07E0, 0x07E0, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/** + * @brief '.' + */ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x00C0, 0x00C0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/** + * @brief '/' + */ + 0x0000, 0x0C00, 0x0C00, 0x0600, 0x0600, 0x0600, 0x0300, 0x0300, + 0x0300, 0x0380, 0x0180, 0x0180, 0x0180, 0x00C0, 0x00C0, 0x00C0, + 0x0060, 0x0060, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/** + * @brief '0' + */ + 0x0000, 0x03E0, 0x07F0, 0x0E38, 0x0C18, 0x180C, 0x180C, 0x180C, + 0x180C, 0x180C, 0x180C, 0x180C, 0x180C, 0x180C, 0x0C18, 0x0E38, + 0x07F0, 0x03E0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/** + * @brief '1' + */ + 0x0000, 0x0100, 0x0180, 0x01C0, 0x01F0, 0x0198, 0x0188, 0x0180, + 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, + 0x0180, 0x0180, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/** + * @brief '2' + */ + 0x0000, 0x03E0, 0x0FF8, 0x0C18, 0x180C, 0x180C, 0x1800, 0x1800, + 0x0C00, 0x0600, 0x0300, 0x0180, 0x00C0, 0x0060, 0x0030, 0x0018, + 0x1FFC, 0x1FFC, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/** + * @brief '3' + */ + 0x0000, 0x01E0, 0x07F8, 0x0E18, 0x0C0C, 0x0C0C, 0x0C00, 0x0600, + 0x03C0, 0x07C0, 0x0C00, 0x1800, 0x1800, 0x180C, 0x180C, 0x0C18, + 0x07F8, 0x03E0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/** + * @brief '4' + */ + 0x0000, 0x0C00, 0x0E00, 0x0F00, 0x0F00, 0x0D80, 0x0CC0, 0x0C60, + 0x0C60, 0x0C30, 0x0C18, 0x0C0C, 0x3FFC, 0x3FFC, 0x0C00, 0x0C00, + 0x0C00, 0x0C00, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/** + * @brief '5' + */ + 0x0000, 0x0FF8, 0x0FF8, 0x0018, 0x0018, 0x000C, 0x03EC, 0x07FC, + 0x0E1C, 0x1C00, 0x1800, 0x1800, 0x1800, 0x180C, 0x0C1C, 0x0E18, + 0x07F8, 0x03E0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/** + * @brief '6' + */ + 0x0000, 0x07C0, 0x0FF0, 0x1C38, 0x1818, 0x0018, 0x000C, 0x03CC, + 0x0FEC, 0x0E3C, 0x1C1C, 0x180C, 0x180C, 0x180C, 0x1C18, 0x0E38, + 0x07F0, 0x03E0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/** + * @brief '7' + */ + 0x0000, 0x1FFC, 0x1FFC, 0x0C00, 0x0600, 0x0600, 0x0300, 0x0380, + 0x0180, 0x01C0, 0x00C0, 0x00E0, 0x0060, 0x0060, 0x0070, 0x0030, + 0x0030, 0x0030, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/** + * @brief '8' + */ + 0x0000, 0x03E0, 0x07F0, 0x0E38, 0x0C18, 0x0C18, 0x0C18, 0x0638, + 0x07F0, 0x07F0, 0x0C18, 0x180C, 0x180C, 0x180C, 0x180C, 0x0C38, + 0x0FF8, 0x03E0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/** + * @brief '9' + */ + 0x0000, 0x03E0, 0x07F0, 0x0E38, 0x0C1C, 0x180C, 0x180C, 0x180C, + 0x1C1C, 0x1E38, 0x1BF8, 0x19E0, 0x1800, 0x0C00, 0x0C00, 0x0E1C, + 0x07F8, 0x01F0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/** + * @brief ':' + */ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0180, 0x0180, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0180, 0x0180, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/** + * @brief ';' + */ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0180, 0x0180, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0180, 0x0180, 0x0100, 0x0100, 0x0080, 0x0000, 0x0000, 0x0000, +/** + * @brief '<' + */ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x1000, 0x1C00, 0x0F80, 0x03E0, 0x00F8, 0x0018, 0x00F8, 0x03E0, + 0x0F80, 0x1C00, 0x1000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/** + * @brief '=' + */ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x1FF8, 0x0000, 0x0000, 0x0000, 0x1FF8, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/** + * @brief '>' + */ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0008, 0x0038, 0x01F0, 0x07C0, 0x1F00, 0x1800, 0x1F00, 0x07C0, + 0x01F0, 0x0038, 0x0008, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/** + * @brief '?' + */ + 0x0000, 0x03E0, 0x0FF8, 0x0C18, 0x180C, 0x180C, 0x1800, 0x0C00, + 0x0600, 0x0300, 0x0180, 0x00C0, 0x00C0, 0x00C0, 0x0000, 0x0000, + 0x00C0, 0x00C0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/** + * @brief '@' + */ + 0x0000, 0x0000, 0x07E0, 0x1818, 0x2004, 0x29C2, 0x4A22, 0x4411, + 0x4409, 0x4409, 0x4409, 0x2209, 0x1311, 0x0CE2, 0x4002, 0x2004, + 0x1818, 0x07E0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/** + * @brief 'A' + */ + 0x0000, 0x0380, 0x0380, 0x06C0, 0x06C0, 0x06C0, 0x0C60, 0x0C60, + 0x1830, 0x1830, 0x1830, 0x3FF8, 0x3FF8, 0x701C, 0x600C, 0x600C, + 0xC006, 0xC006, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/** + * @brief 'B' + */ + 0x0000, 0x03FC, 0x0FFC, 0x0C0C, 0x180C, 0x180C, 0x180C, 0x0C0C, + 0x07FC, 0x0FFC, 0x180C, 0x300C, 0x300C, 0x300C, 0x300C, 0x180C, + 0x1FFC, 0x07FC, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/** + * @brief 'C' + */ + 0x0000, 0x07C0, 0x1FF0, 0x3838, 0x301C, 0x700C, 0x6006, 0x0006, + 0x0006, 0x0006, 0x0006, 0x0006, 0x0006, 0x6006, 0x700C, 0x301C, + 0x1FF0, 0x07E0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/** + * @brief 'D' + */ + 0x0000, 0x03FE, 0x0FFE, 0x0E06, 0x1806, 0x1806, 0x3006, 0x3006, + 0x3006, 0x3006, 0x3006, 0x3006, 0x3006, 0x1806, 0x1806, 0x0E06, + 0x0FFE, 0x03FE, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/** + * @brief 'E' + */ + 0x0000, 0x3FFC, 0x3FFC, 0x000C, 0x000C, 0x000C, 0x000C, 0x000C, + 0x1FFC, 0x1FFC, 0x000C, 0x000C, 0x000C, 0x000C, 0x000C, 0x000C, + 0x3FFC, 0x3FFC, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/** + * @brief 'F' + */ + 0x0000, 0x3FF8, 0x3FF8, 0x0018, 0x0018, 0x0018, 0x0018, 0x0018, + 0x1FF8, 0x1FF8, 0x0018, 0x0018, 0x0018, 0x0018, 0x0018, 0x0018, + 0x0018, 0x0018, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/** + * @brief 'G' + */ + 0x0000, 0x0FE0, 0x3FF8, 0x783C, 0x600E, 0xE006, 0xC007, 0x0003, + 0x0003, 0xFE03, 0xFE03, 0xC003, 0xC007, 0xC006, 0xC00E, 0xF03C, + 0x3FF8, 0x0FE0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/** + * @brief 'H' + */ + 0x0000, 0x300C, 0x300C, 0x300C, 0x300C, 0x300C, 0x300C, 0x300C, + 0x3FFC, 0x3FFC, 0x300C, 0x300C, 0x300C, 0x300C, 0x300C, 0x300C, + 0x300C, 0x300C, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/** + * @brief 'I' + */ + 0x0000, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, + 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, + 0x0180, 0x0180, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/** + * @brief 'J' + */ + 0x0000, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, + 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0618, 0x0618, 0x0738, + 0x03F0, 0x01E0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/** + * @brief 'K' + */ + 0x0000, 0x3006, 0x1806, 0x0C06, 0x0606, 0x0306, 0x0186, 0x00C6, + 0x0066, 0x0076, 0x00DE, 0x018E, 0x0306, 0x0606, 0x0C06, 0x1806, + 0x3006, 0x6006, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/** + * @brief 'L' + */ + 0x0000, 0x0018, 0x0018, 0x0018, 0x0018, 0x0018, 0x0018, 0x0018, + 0x0018, 0x0018, 0x0018, 0x0018, 0x0018, 0x0018, 0x0018, 0x0018, + 0x1FF8, 0x1FF8, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/** + * @brief 'M' + */ + 0x0000, 0xE00E, 0xF01E, 0xF01E, 0xF01E, 0xD836, 0xD836, 0xD836, + 0xD836, 0xCC66, 0xCC66, 0xCC66, 0xC6C6, 0xC6C6, 0xC6C6, 0xC6C6, + 0xC386, 0xC386, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/** + * @brief 'N' + */ + 0x0000, 0x300C, 0x301C, 0x303C, 0x303C, 0x306C, 0x306C, 0x30CC, + 0x30CC, 0x318C, 0x330C, 0x330C, 0x360C, 0x360C, 0x3C0C, 0x3C0C, + 0x380C, 0x300C, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/** + * @brief 'O' + */ + 0x0000, 0x07E0, 0x1FF8, 0x381C, 0x700E, 0x6006, 0xC003, 0xC003, + 0xC003, 0xC003, 0xC003, 0xC003, 0xC003, 0x6006, 0x700E, 0x381C, + 0x1FF8, 0x07E0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/** + * @brief 'P' + */ + 0x0000, 0x0FFC, 0x1FFC, 0x380C, 0x300C, 0x300C, 0x300C, 0x300C, + 0x180C, 0x1FFC, 0x07FC, 0x000C, 0x000C, 0x000C, 0x000C, 0x000C, + 0x000C, 0x000C, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/** + * @brief 'Q' + */ + 0x0000, 0x07E0, 0x1FF8, 0x381C, 0x700E, 0x6006, 0xE003, 0xC003, + 0xC003, 0xC003, 0xC003, 0xC003, 0xE007, 0x6306, 0x3F0E, 0x3C1C, + 0x3FF8, 0xF7E0, 0xC000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/** + * @brief 'R' + */ + 0x0000, 0x0FFE, 0x1FFE, 0x3806, 0x3006, 0x3006, 0x3006, 0x3806, + 0x1FFE, 0x07FE, 0x0306, 0x0606, 0x0C06, 0x1806, 0x1806, 0x3006, + 0x3006, 0x6006, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/** + * @brief 'S' + */ + 0x0000, 0x03E0, 0x0FF8, 0x0C1C, 0x180C, 0x180C, 0x000C, 0x001C, + 0x03F8, 0x0FE0, 0x1E00, 0x3800, 0x3006, 0x3006, 0x300E, 0x1C1C, + 0x0FF8, 0x07E0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/** + * @brief 'T' + */ + 0x0000, 0x7FFE, 0x7FFE, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, + 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, + 0x0180, 0x0180, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/** + * @brief 'U' + */ + 0x0000, 0x300C, 0x300C, 0x300C, 0x300C, 0x300C, 0x300C, 0x300C, + 0x300C, 0x300C, 0x300C, 0x300C, 0x300C, 0x300C, 0x300C, 0x1818, + 0x1FF8, 0x07E0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/** + * @brief 'V' + */ + 0x0000, 0x6003, 0x3006, 0x3006, 0x3006, 0x180C, 0x180C, 0x180C, + 0x0C18, 0x0C18, 0x0E38, 0x0630, 0x0630, 0x0770, 0x0360, 0x0360, + 0x01C0, 0x01C0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/** + * @brief 'W' + */ + 0x0000, 0x6003, 0x61C3, 0x61C3, 0x61C3, 0x3366, 0x3366, 0x3366, + 0x3366, 0x3366, 0x3366, 0x1B6C, 0x1B6C, 0x1B6C, 0x1A2C, 0x1E3C, + 0x0E38, 0x0E38, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/** + * @brief 'X' + */ + 0x0000, 0xE00F, 0x700C, 0x3018, 0x1830, 0x0C70, 0x0E60, 0x07C0, + 0x0380, 0x0380, 0x03C0, 0x06E0, 0x0C70, 0x1C30, 0x1818, 0x300C, + 0x600E, 0xE007, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/** + * @brief 'Y' + */ + 0x0000, 0xC003, 0x6006, 0x300C, 0x381C, 0x1838, 0x0C30, 0x0660, + 0x07E0, 0x03C0, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, + 0x0180, 0x0180, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/** + * @brief 'Z' + */ + 0x0000, 0x7FFC, 0x7FFC, 0x6000, 0x3000, 0x1800, 0x0C00, 0x0600, + 0x0300, 0x0180, 0x00C0, 0x0060, 0x0030, 0x0018, 0x000C, 0x0006, + 0x7FFE, 0x7FFE, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/** + * @brief '[' + */ + 0x0000, 0x03E0, 0x03E0, 0x0060, 0x0060, 0x0060, 0x0060, 0x0060, + 0x0060, 0x0060, 0x0060, 0x0060, 0x0060, 0x0060, 0x0060, 0x0060, + 0x0060, 0x0060, 0x0060, 0x0060, 0x0060, 0x03E0, 0x03E0, 0x0000, +/** + * @brief '\' + */ + 0x0000, 0x0030, 0x0030, 0x0060, 0x0060, 0x0060, 0x00C0, 0x00C0, + 0x00C0, 0x01C0, 0x0180, 0x0180, 0x0180, 0x0300, 0x0300, 0x0300, + 0x0600, 0x0600, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/** + * @brief ']' + */ + 0x0000, 0x03E0, 0x03E0, 0x0300, 0x0300, 0x0300, 0x0300, 0x0300, + 0x0300, 0x0300, 0x0300, 0x0300, 0x0300, 0x0300, 0x0300, 0x0300, + 0x0300, 0x0300, 0x0300, 0x0300, 0x0300, 0x03E0, 0x03E0, 0x0000, +/** + * @brief '^' + */ + 0x0000, 0x0000, 0x01C0, 0x01C0, 0x0360, 0x0360, 0x0360, 0x0630, + 0x0630, 0x0C18, 0x0C18, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/** + * @brief '_' + */ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0xFFFF, 0xFFFF, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/** + * @brief ''' + */ + 0x0000, 0x000C, 0x000C, 0x000C, 0x000C, 0x000C, 0x000C, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/** + * @brief 'a' + */ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x03F0, 0x07F8, + 0x0C1C, 0x0C0C, 0x0F00, 0x0FF0, 0x0CF8, 0x0C0C, 0x0C0C, 0x0F1C, + 0x0FF8, 0x18F0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/** + * @brief 'b' + */ + 0x0000, 0x0018, 0x0018, 0x0018, 0x0018, 0x0018, 0x03D8, 0x0FF8, + 0x0C38, 0x1818, 0x1818, 0x1818, 0x1818, 0x1818, 0x1818, 0x0C38, + 0x0FF8, 0x03D8, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/** + * @brief 'c' + */ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x03C0, 0x07F0, + 0x0E30, 0x0C18, 0x0018, 0x0018, 0x0018, 0x0018, 0x0C18, 0x0E30, + 0x07F0, 0x03C0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/** + * @brief 'd' + */ + 0x0000, 0x1800, 0x1800, 0x1800, 0x1800, 0x1800, 0x1BC0, 0x1FF0, + 0x1C30, 0x1818, 0x1818, 0x1818, 0x1818, 0x1818, 0x1818, 0x1C30, + 0x1FF0, 0x1BC0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/** + * @brief 'e' + */ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x03C0, 0x0FF0, + 0x0C30, 0x1818, 0x1FF8, 0x1FF8, 0x0018, 0x0018, 0x1838, 0x1C30, + 0x0FF0, 0x07C0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/** + * @brief 'f' + */ + 0x0000, 0x0F80, 0x0FC0, 0x00C0, 0x00C0, 0x00C0, 0x07F0, 0x07F0, + 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, + 0x00C0, 0x00C0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/** + * @brief 'g' + */ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0DE0, 0x0FF8, + 0x0E18, 0x0C0C, 0x0C0C, 0x0C0C, 0x0C0C, 0x0C0C, 0x0C0C, 0x0E18, + 0x0FF8, 0x0DE0, 0x0C00, 0x0C0C, 0x061C, 0x07F8, 0x01F0, 0x0000, +/** + * @brief 'h' + */ + 0x0000, 0x0018, 0x0018, 0x0018, 0x0018, 0x0018, 0x07D8, 0x0FF8, + 0x1C38, 0x1818, 0x1818, 0x1818, 0x1818, 0x1818, 0x1818, 0x1818, + 0x1818, 0x1818, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/** + * @brief 'i' + */ + 0x0000, 0x00C0, 0x00C0, 0x0000, 0x0000, 0x0000, 0x00C0, 0x00C0, + 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, + 0x00C0, 0x00C0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/** + * @brief 'j' + */ + 0x0000, 0x00C0, 0x00C0, 0x0000, 0x0000, 0x0000, 0x00C0, 0x00C0, + 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, + 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00F8, 0x0078, 0x0000, +/** + * @brief 'k' + */ + 0x0000, 0x000C, 0x000C, 0x000C, 0x000C, 0x000C, 0x0C0C, 0x060C, + 0x030C, 0x018C, 0x00CC, 0x006C, 0x00FC, 0x019C, 0x038C, 0x030C, + 0x060C, 0x0C0C, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/** + * @brief 'l' + */ + 0x0000, 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, + 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, + 0x00C0, 0x00C0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/** + * @brief 'm' + */ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x3C7C, 0x7EFF, + 0xE3C7, 0xC183, 0xC183, 0xC183, 0xC183, 0xC183, 0xC183, 0xC183, + 0xC183, 0xC183, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/** + * @brief 'n' + */ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0798, 0x0FF8, + 0x1C38, 0x1818, 0x1818, 0x1818, 0x1818, 0x1818, 0x1818, 0x1818, + 0x1818, 0x1818, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/** + * @brief 'o' + */ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x03C0, 0x0FF0, + 0x0C30, 0x1818, 0x1818, 0x1818, 0x1818, 0x1818, 0x1818, 0x0C30, + 0x0FF0, 0x03C0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/** + * @brief 'p' + */ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x03D8, 0x0FF8, + 0x0C38, 0x1818, 0x1818, 0x1818, 0x1818, 0x1818, 0x1818, 0x0C38, + 0x0FF8, 0x03D8, 0x0018, 0x0018, 0x0018, 0x0018, 0x0018, 0x0000, +/** + * @brief 'q' + */ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x1BC0, 0x1FF0, + 0x1C30, 0x1818, 0x1818, 0x1818, 0x1818, 0x1818, 0x1818, 0x1C30, + 0x1FF0, 0x1BC0, 0x1800, 0x1800, 0x1800, 0x1800, 0x1800, 0x0000, +/** + * @brief 'r' + */ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x07B0, 0x03F0, + 0x0070, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, + 0x0030, 0x0030, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/** + * @brief 's' + */ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x03E0, 0x03F0, + 0x0E38, 0x0C18, 0x0038, 0x03F0, 0x07C0, 0x0C00, 0x0C18, 0x0E38, + 0x07F0, 0x03E0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/** + * @brief 't' + */ + 0x0000, 0x0000, 0x0080, 0x00C0, 0x00C0, 0x00C0, 0x07F0, 0x07F0, + 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, + 0x07C0, 0x0780, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/** + * @brief 'u' + */ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x1818, 0x1818, + 0x1818, 0x1818, 0x1818, 0x1818, 0x1818, 0x1818, 0x1818, 0x1C38, + 0x1FF0, 0x19E0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/** + * @brief 'v' + */ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x180C, 0x0C18, + 0x0C18, 0x0C18, 0x0630, 0x0630, 0x0630, 0x0360, 0x0360, 0x0360, + 0x01C0, 0x01C0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/** + * @brief 'w' + */ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x41C1, 0x41C1, + 0x61C3, 0x6363, 0x6363, 0x6363, 0x3636, 0x3636, 0x3636, 0x1C1C, + 0x1C1C, 0x1C1C, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/** + * @brief 'x' + */ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x381C, 0x1C38, + 0x0C30, 0x0660, 0x0360, 0x0360, 0x0360, 0x0360, 0x0660, 0x0C30, + 0x1C38, 0x381C, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/** + * @brief 'y' + */ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x3018, 0x1830, + 0x1830, 0x1870, 0x0C60, 0x0C60, 0x0CE0, 0x06C0, 0x06C0, 0x0380, + 0x0380, 0x0380, 0x0180, 0x0180, 0x01C0, 0x00F0, 0x0070, 0x0000, +/** + * @brief 'z' + */ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x1FFC, 0x1FFC, + 0x0C00, 0x0600, 0x0300, 0x0180, 0x00C0, 0x0060, 0x0030, 0x0018, + 0x1FFC, 0x1FFC, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/** + * @brief '{' + */ + 0x0000, 0x0300, 0x0180, 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x00C0, + 0x00C0, 0x0060, 0x0060, 0x0030, 0x0060, 0x0040, 0x00C0, 0x00C0, + 0x00C0, 0x00C0, 0x00C0, 0x00C0, 0x0180, 0x0300, 0x0000, 0x0000, +/** + * @brief '|' + */ + 0x0000, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, + 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, + 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0000, +/** + * @brief '}' + */ + 0x0000, 0x0060, 0x00C0, 0x01C0, 0x0180, 0x0180, 0x0180, 0x0180, + 0x0180, 0x0300, 0x0300, 0x0600, 0x0300, 0x0100, 0x0180, 0x0180, + 0x0180, 0x0180, 0x0180, 0x0180, 0x00C0, 0x0060, 0x0000, 0x0000, +/** + * @brief '~' + */ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x10F0, 0x1FF8, 0x0F08, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000}; + +const uint16_t ASCII12x12_Table [] = { + 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, + 0x0000,0x2000,0x2000,0x2000,0x2000,0x2000,0x2000,0x2000,0x0000,0x2000,0x0000,0x0000, + 0x0000,0x5000,0x5000,0x5000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, + 0x0000,0x0900,0x0900,0x1200,0x7f00,0x1200,0x7f00,0x1200,0x2400,0x2400,0x0000,0x0000, + 0x1000,0x3800,0x5400,0x5000,0x5000,0x3800,0x1400,0x5400,0x5400,0x3800,0x1000,0x0000, + 0x0000,0x3080,0x4900,0x4900,0x4a00,0x32c0,0x0520,0x0920,0x0920,0x10c0,0x0000,0x0000, + 0x0000,0x0c00,0x1200,0x1200,0x1400,0x1800,0x2500,0x2300,0x2300,0x1d80,0x0000,0x0000, + 0x0000,0x4000,0x4000,0x4000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, + 0x0000,0x0800,0x1000,0x1000,0x2000,0x2000,0x2000,0x2000,0x2000,0x2000,0x1000,0x1000, + 0x0000,0x4000,0x2000,0x2000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x2000,0x2000, + 0x0000,0x2000,0x7000,0x2000,0x5000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, + 0x0000,0x0000,0x0000,0x0800,0x0800,0x7f00,0x0800,0x0800,0x0000,0x0000,0x0000,0x0000, + 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x2000,0x2000,0x4000, + 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x7000,0x0000,0x0000,0x0000,0x0000,0x0000, + 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x2000,0x0000,0x0000, + 0x0000,0x1000,0x1000,0x1000,0x2000,0x2000,0x2000,0x2000,0x4000,0x4000,0x0000,0x0000, + 0x0000,0x1000,0x2800,0x4400,0x4400,0x4400,0x4400,0x4400,0x2800,0x1000,0x0000,0x0000, + 0x0000,0x1000,0x3000,0x5000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x0000,0x0000, + 0x0000,0x3000,0x4800,0x4400,0x0400,0x0800,0x1000,0x2000,0x4000,0x7c00,0x0000,0x0000, + 0x0000,0x3000,0x4800,0x0400,0x0800,0x1000,0x0800,0x4400,0x4800,0x3000,0x0000,0x0000, + 0x0000,0x0800,0x1800,0x1800,0x2800,0x2800,0x4800,0x7c00,0x0800,0x0800,0x0000,0x0000, + 0x0000,0x3c00,0x2000,0x4000,0x7000,0x4800,0x0400,0x4400,0x4800,0x3000,0x0000,0x0000, + 0x0000,0x1800,0x2400,0x4000,0x5000,0x6800,0x4400,0x4400,0x2800,0x1000,0x0000,0x0000, + 0x0000,0x7c00,0x0400,0x0800,0x1000,0x1000,0x1000,0x2000,0x2000,0x2000,0x0000,0x0000, + 0x0000,0x1000,0x2800,0x4400,0x2800,0x1000,0x2800,0x4400,0x2800,0x1000,0x0000,0x0000, + 0x0000,0x1000,0x2800,0x4400,0x4400,0x2c00,0x1400,0x0400,0x4800,0x3000,0x0000,0x0000, + 0x0000,0x0000,0x0000,0x2000,0x0000,0x0000,0x0000,0x0000,0x0000,0x2000,0x0000,0x0000, + 0x0000,0x0000,0x0000,0x2000,0x0000,0x0000,0x0000,0x0000,0x0000,0x2000,0x2000,0x4000, + 0x0000,0x0000,0x0400,0x0800,0x3000,0x4000,0x3000,0x0800,0x0400,0x0000,0x0000,0x0000, + 0x0000,0x0000,0x0000,0x7c00,0x0000,0x0000,0x7c00,0x0000,0x0000,0x0000,0x0000,0x0000, + 0x0000,0x0000,0x4000,0x2000,0x1800,0x0400,0x1800,0x2000,0x4000,0x0000,0x0000,0x0000, + 0x0000,0x3800,0x6400,0x4400,0x0400,0x0800,0x1000,0x1000,0x0000,0x1000,0x0000,0x0000, + 0x0000,0x0f80,0x1040,0x2ea0,0x51a0,0x5120,0x5120,0x5120,0x5320,0x4dc0,0x2020,0x1040, + 0x0000,0x0800,0x1400,0x1400,0x1400,0x2200,0x3e00,0x2200,0x4100,0x4100,0x0000,0x0000, + 0x0000,0x3c00,0x2200,0x2200,0x2200,0x3c00,0x2200,0x2200,0x2200,0x3c00,0x0000,0x0000, + 0x0000,0x0e00,0x1100,0x2100,0x2000,0x2000,0x2000,0x2100,0x1100,0x0e00,0x0000,0x0000, + 0x0000,0x3c00,0x2200,0x2100,0x2100,0x2100,0x2100,0x2100,0x2200,0x3c00,0x0000,0x0000, + 0x0000,0x3e00,0x2000,0x2000,0x2000,0x3e00,0x2000,0x2000,0x2000,0x3e00,0x0000,0x0000, + 0x0000,0x3e00,0x2000,0x2000,0x2000,0x3c00,0x2000,0x2000,0x2000,0x2000,0x0000,0x0000, + 0x0000,0x0e00,0x1100,0x2100,0x2000,0x2700,0x2100,0x2100,0x1100,0x0e00,0x0000,0x0000, + 0x0000,0x2100,0x2100,0x2100,0x2100,0x3f00,0x2100,0x2100,0x2100,0x2100,0x0000,0x0000, + 0x0000,0x2000,0x2000,0x2000,0x2000,0x2000,0x2000,0x2000,0x2000,0x2000,0x0000,0x0000, + 0x0000,0x0800,0x0800,0x0800,0x0800,0x0800,0x0800,0x4800,0x4800,0x3000,0x0000,0x0000, + 0x0000,0x2200,0x2400,0x2800,0x2800,0x3800,0x2800,0x2400,0x2400,0x2200,0x0000,0x0000, + 0x0000,0x2000,0x2000,0x2000,0x2000,0x2000,0x2000,0x2000,0x2000,0x3e00,0x0000,0x0000, + 0x0000,0x2080,0x3180,0x3180,0x3180,0x2a80,0x2a80,0x2a80,0x2a80,0x2480,0x0000,0x0000, + 0x0000,0x2100,0x3100,0x3100,0x2900,0x2900,0x2500,0x2300,0x2300,0x2100,0x0000,0x0000, + 0x0000,0x0c00,0x1200,0x2100,0x2100,0x2100,0x2100,0x2100,0x1200,0x0c00,0x0000,0x0000, + 0x0000,0x3c00,0x2200,0x2200,0x2200,0x3c00,0x2000,0x2000,0x2000,0x2000,0x0000,0x0000, + 0x0000,0x0c00,0x1200,0x2100,0x2100,0x2100,0x2100,0x2100,0x1600,0x0d00,0x0100,0x0000, + 0x0000,0x3e00,0x2100,0x2100,0x2100,0x3e00,0x2400,0x2200,0x2100,0x2080,0x0000,0x0000, + 0x0000,0x1c00,0x2200,0x2200,0x2000,0x1c00,0x0200,0x2200,0x2200,0x1c00,0x0000,0x0000, + 0x0000,0x3e00,0x0800,0x0800,0x0800,0x0800,0x0800,0x0800,0x0800,0x0800,0x0000,0x0000, + 0x0000,0x2100,0x2100,0x2100,0x2100,0x2100,0x2100,0x2100,0x1200,0x0c00,0x0000,0x0000, + 0x0000,0x4100,0x4100,0x2200,0x2200,0x2200,0x1400,0x1400,0x1400,0x0800,0x0000,0x0000, + 0x0000,0x4440,0x4a40,0x2a40,0x2a80,0x2a80,0x2a80,0x2a80,0x2a80,0x1100,0x0000,0x0000, + 0x0000,0x4100,0x2200,0x1400,0x1400,0x0800,0x1400,0x1400,0x2200,0x4100,0x0000,0x0000, + 0x0000,0x4100,0x2200,0x2200,0x1400,0x0800,0x0800,0x0800,0x0800,0x0800,0x0000,0x0000, + 0x0000,0x7e00,0x0200,0x0400,0x0800,0x1000,0x1000,0x2000,0x4000,0x7e00,0x0000,0x0000, + 0x0000,0x3000,0x2000,0x2000,0x2000,0x2000,0x2000,0x2000,0x2000,0x2000,0x2000,0x2000, + 0x0000,0x4000,0x4000,0x2000,0x2000,0x2000,0x2000,0x2000,0x1000,0x1000,0x0000,0x0000, + 0x0000,0x6000,0x2000,0x2000,0x2000,0x2000,0x2000,0x2000,0x2000,0x2000,0x2000,0x2000, + 0x0000,0x1000,0x2800,0x2800,0x2800,0x4400,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, + 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x7e00, + 0x4000,0x2000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, + 0x0000,0x0000,0x0000,0x3800,0x4400,0x0400,0x3c00,0x4400,0x4400,0x3c00,0x0000,0x0000, + 0x0000,0x4000,0x4000,0x5800,0x6400,0x4400,0x4400,0x4400,0x6400,0x5800,0x0000,0x0000, + 0x0000,0x0000,0x0000,0x3000,0x4800,0x4000,0x4000,0x4000,0x4800,0x3000,0x0000,0x0000, + 0x0000,0x0400,0x0400,0x3400,0x4c00,0x4400,0x4400,0x4400,0x4c00,0x3400,0x0000,0x0000, + 0x0000,0x0000,0x0000,0x3800,0x4400,0x4400,0x7c00,0x4000,0x4400,0x3800,0x0000,0x0000, + 0x0000,0x6000,0x4000,0xe000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x0000,0x0000, + 0x0000,0x0000,0x0000,0x3400,0x4c00,0x4400,0x4400,0x4400,0x4c00,0x3400,0x0400,0x4400, + 0x0000,0x4000,0x4000,0x5800,0x6400,0x4400,0x4400,0x4400,0x4400,0x4400,0x0000,0x0000, + 0x0000,0x4000,0x0000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x0000,0x0000, + 0x0000,0x4000,0x0000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000, + 0x0000,0x4000,0x4000,0x4800,0x5000,0x6000,0x5000,0x5000,0x4800,0x4800,0x0000,0x0000, + 0x0000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x0000,0x0000, + 0x0000,0x0000,0x0000,0x5200,0x6d00,0x4900,0x4900,0x4900,0x4900,0x4900,0x0000,0x0000, + 0x0000,0x0000,0x0000,0x5800,0x6400,0x4400,0x4400,0x4400,0x4400,0x4400,0x0000,0x0000, + 0x0000,0x0000,0x0000,0x3800,0x4400,0x4400,0x4400,0x4400,0x4400,0x3800,0x0000,0x0000, + 0x0000,0x0000,0x0000,0x5800,0x6400,0x4400,0x4400,0x4400,0x6400,0x5800,0x4000,0x4000, + 0x0000,0x0000,0x0000,0x3400,0x4c00,0x4400,0x4400,0x4400,0x4c00,0x3400,0x0400,0x0400, + 0x0000,0x0000,0x0000,0x5000,0x6000,0x4000,0x4000,0x4000,0x4000,0x4000,0x0000,0x0000, + 0x0000,0x0000,0x0000,0x3000,0x4800,0x4000,0x3000,0x0800,0x4800,0x3000,0x0000,0x0000, + 0x0000,0x4000,0x4000,0xe000,0x4000,0x4000,0x4000,0x4000,0x4000,0x6000,0x0000,0x0000, + 0x0000,0x0000,0x0000,0x4400,0x4400,0x4400,0x4400,0x4400,0x4c00,0x3400,0x0000,0x0000, + 0x0000,0x0000,0x0000,0x4400,0x4400,0x2800,0x2800,0x2800,0x2800,0x1000,0x0000,0x0000, + 0x0000,0x0000,0x0000,0x4900,0x4900,0x5500,0x5500,0x5500,0x5500,0x2200,0x0000,0x0000, + 0x0000,0x0000,0x0000,0x4400,0x2800,0x2800,0x1000,0x2800,0x2800,0x4400,0x0000,0x0000, + 0x0000,0x0000,0x0000,0x4400,0x4400,0x2800,0x2800,0x2800,0x1000,0x1000,0x1000,0x1000, + 0x0000,0x0000,0x0000,0x7800,0x0800,0x1000,0x2000,0x2000,0x4000,0x7800,0x0000,0x0000, + 0x0000,0x1000,0x2000,0x2000,0x2000,0x2000,0x4000,0x2000,0x2000,0x2000,0x2000,0x2000, + 0x0000,0x2000,0x2000,0x2000,0x2000,0x2000,0x2000,0x2000,0x2000,0x2000,0x2000,0x2000, + 0x0000,0x4000,0x2000,0x2000,0x2000,0x2000,0x1000,0x2000,0x2000,0x2000,0x2000,0x2000, + 0x0000,0x0000,0x0000,0x0000,0x7400,0x5800,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, + 0x0000,0x0000,0x7000,0x5000,0x5000,0x5000,0x5000,0x5000,0x5000,0x7000,0x0000,0x0000}; + +const uint16_t ASCII8x12_Table [] = { + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x10,0x10,0x10,0x10,0x10,0x10,0x00,0x10,0x00, + 0x00,0x00,0x00,0x28,0x28,0x28,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x14,0x14,0x3e,0x14,0x28,0x7c,0x28,0x28,0x00, + 0x00,0x00,0x10,0x38,0x54,0x50,0x38,0x14,0x14,0x54,0x38,0x10, + 0x00,0x00,0x00,0x44,0xa8,0xa8,0x50,0x14,0x1a,0x2a,0x24,0x00, + 0x00,0x00,0x00,0x20,0x50,0x50,0x20,0xe8,0x98,0x98,0x60,0x00, + 0x00,0x00,0x00,0x80,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x40,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80, + 0x00,0x00,0x00,0x80,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40, + 0x00,0x00,0x00,0x40,0xe0,0x40,0xa0,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x20,0x20,0xf8,0x20,0x20,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x40, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00, + 0x00,0x00,0x00,0x20,0x20,0x20,0x40,0x40,0x80,0x80,0x80,0x00, + 0x00,0x00,0x00,0x60,0x90,0x90,0x90,0x90,0x90,0x90,0x60,0x00, + 0x00,0x00,0x00,0x20,0x60,0xa0,0x20,0x20,0x20,0x20,0x20,0x00, + 0x00,0x00,0x00,0x60,0x90,0x10,0x10,0x20,0x40,0x80,0xf0,0x00, + 0x00,0x00,0x00,0x60,0x90,0x10,0x60,0x10,0x10,0x90,0x60,0x00, + 0x00,0x00,0x00,0x10,0x30,0x50,0x50,0x90,0xf8,0x10,0x10,0x00, + 0x00,0x00,0x00,0x70,0x40,0x80,0xe0,0x10,0x10,0x90,0x60,0x00, + 0x00,0x00,0x00,0x60,0x90,0x80,0xa0,0xd0,0x90,0x90,0x60,0x00, + 0x00,0x00,0x00,0xf0,0x10,0x20,0x20,0x20,0x40,0x40,0x40,0x00, + 0x00,0x00,0x00,0x60,0x90,0x90,0x60,0x90,0x90,0x90,0x60,0x00, + 0x00,0x00,0x00,0x60,0x90,0x90,0xb0,0x50,0x10,0x90,0x60,0x00, + 0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x40,0x00, + 0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x40,0x40, + 0x00,0x00,0x00,0x00,0x00,0x10,0x60,0x80,0x60,0x10,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x00,0xf0,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x80,0x60,0x10,0x60,0x80,0x00,0x00, + 0x00,0x00,0x00,0x60,0x90,0x10,0x20,0x40,0x40,0x00,0x40,0x00, + 0x00,0x00,0x00,0x1c,0x22,0x5b,0xa5,0xa5,0xa5,0xa5,0x9e,0x41, + 0x00,0x00,0x00,0x20,0x50,0x50,0x50,0x50,0x70,0x88,0x88,0x00, + 0x00,0x00,0x00,0xf0,0x88,0x88,0xf0,0x88,0x88,0x88,0xf0,0x00, + 0x00,0x00,0x00,0x38,0x44,0x84,0x80,0x80,0x84,0x44,0x38,0x00, + 0x00,0x00,0x00,0xe0,0x90,0x88,0x88,0x88,0x88,0x90,0xe0,0x00, + 0x00,0x00,0x00,0xf8,0x80,0x80,0xf8,0x80,0x80,0x80,0xf8,0x00, + 0x00,0x00,0x00,0x78,0x40,0x40,0x70,0x40,0x40,0x40,0x40,0x00, + 0x00,0x00,0x00,0x38,0x44,0x84,0x80,0x9c,0x84,0x44,0x38,0x00, + 0x00,0x00,0x00,0x88,0x88,0x88,0xf8,0x88,0x88,0x88,0x88,0x00, + 0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00, + 0x00,0x00,0x00,0x10,0x10,0x10,0x10,0x10,0x90,0x90,0x60,0x00, + 0x00,0x00,0x00,0x88,0x90,0xa0,0xe0,0xa0,0x90,0x90,0x88,0x00, + 0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0xf0,0x00, + 0x00,0x00,0x00,0x82,0xc6,0xc6,0xaa,0xaa,0xaa,0xaa,0x92,0x00, + 0x00,0x00,0x00,0x84,0xc4,0xa4,0xa4,0x94,0x94,0x8c,0x84,0x00, + 0x00,0x00,0x00,0x30,0x48,0x84,0x84,0x84,0x84,0x48,0x30,0x00, + 0x00,0x00,0x00,0xf0,0x88,0x88,0x88,0xf0,0x80,0x80,0x80,0x00, + 0x00,0x00,0x00,0x30,0x48,0x84,0x84,0x84,0x84,0x58,0x34,0x04, + 0x00,0x00,0x00,0x78,0x44,0x44,0x78,0x50,0x48,0x44,0x42,0x00, + 0x00,0x00,0x00,0x70,0x88,0x80,0x70,0x08,0x88,0x88,0x70,0x00, + 0x00,0x00,0x00,0xf8,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x00, + 0x00,0x00,0x00,0x84,0x84,0x84,0x84,0x84,0x84,0x48,0x30,0x00, + 0x00,0x00,0x00,0x88,0x88,0x50,0x50,0x50,0x50,0x50,0x20,0x00, + 0x00,0x00,0x00,0x92,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0x44,0x00, + 0x00,0x00,0x00,0x84,0x48,0x48,0x30,0x30,0x48,0x48,0x84,0x00, + 0x00,0x00,0x00,0x88,0x50,0x50,0x20,0x20,0x20,0x20,0x20,0x00, + 0x00,0x00,0x00,0xf8,0x08,0x10,0x20,0x20,0x40,0x80,0xf8,0x00, + 0x00,0x00,0x00,0xc0,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80, + 0x00,0x00,0x00,0x80,0x80,0x40,0x40,0x40,0x40,0x20,0x20,0x00, + 0x00,0x00,0x00,0xc0,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40, + 0x00,0x00,0x00,0x40,0xa0,0xa0,0xa0,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8, + 0x00,0x00,0x00,0x80,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0xe0,0x10,0x70,0x90,0x90,0x70,0x00, + 0x00,0x00,0x00,0x80,0x80,0xa0,0xd0,0x90,0x90,0xd0,0xa0,0x00, + 0x00,0x00,0x00,0x00,0x00,0x60,0x90,0x80,0x80,0x90,0x60,0x00, + 0x00,0x00,0x00,0x10,0x10,0x50,0xb0,0x90,0x90,0xb0,0x50,0x00, + 0x00,0x00,0x00,0x00,0x00,0x60,0x90,0xf0,0x80,0x90,0x60,0x00, + 0x00,0x00,0x00,0xc0,0x80,0xc0,0x80,0x80,0x80,0x80,0x80,0x00, + 0x00,0x00,0x00,0x00,0x00,0x50,0xb0,0x90,0x90,0xb0,0x50,0x10, + 0x00,0x00,0x00,0x80,0x80,0xa0,0xd0,0x90,0x90,0x90,0x90,0x00, + 0x00,0x00,0x00,0x80,0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x00, + 0x00,0x00,0x00,0x80,0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x80, + 0x00,0x00,0x00,0x80,0x80,0x90,0xa0,0xc0,0xa0,0x90,0x90,0x00, + 0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00, + 0x00,0x00,0x00,0x00,0x00,0xa6,0xda,0x92,0x92,0x92,0x92,0x00, + 0x00,0x00,0x00,0x00,0x00,0xa0,0xd0,0x90,0x90,0x90,0x90,0x00, + 0x00,0x00,0x00,0x00,0x00,0x60,0x90,0x90,0x90,0x90,0x60,0x00, + 0x00,0x00,0x00,0x00,0x00,0xa0,0xd0,0x90,0x90,0xd0,0xa0,0x80, + 0x00,0x00,0x00,0x00,0x00,0x50,0xb0,0x90,0x90,0xb0,0x50,0x10, + 0x00,0x00,0x00,0x00,0x00,0xa0,0xc0,0x80,0x80,0x80,0x80,0x00, + 0x00,0x00,0x00,0x00,0x00,0xe0,0x90,0x40,0x20,0x90,0x60,0x00, + 0x00,0x00,0x00,0x80,0x80,0xc0,0x80,0x80,0x80,0x80,0xc0,0x00, + 0x00,0x00,0x00,0x00,0x00,0x90,0x90,0x90,0x90,0xb0,0x50,0x00, + 0x00,0x00,0x00,0x00,0x00,0x88,0x88,0x50,0x50,0x50,0x20,0x00, + 0x00,0x00,0x00,0x00,0x00,0x92,0xaa,0xaa,0xaa,0xaa,0x44,0x00, + 0x00,0x00,0x00,0x00,0x00,0x88,0x50,0x20,0x20,0x50,0x88,0x00, + 0x00,0x00,0x00,0x00,0x00,0x88,0x50,0x50,0x50,0x20,0x20,0x20, + 0x00,0x00,0x00,0x00,0x00,0xf0,0x10,0x20,0x40,0x80,0xf0,0x00, + 0x00,0x00,0x00,0xc0,0x80,0x80,0x80,0x00,0x80,0x80,0x80,0x80, + 0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80, + 0x00,0x00,0x00,0xc0,0x40,0x40,0x40,0x20,0x40,0x40,0x40,0x40, + 0x00,0x00,0x00,0x00,0x00,0x00,0xe8,0xb0,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0xe0,0xa0,0xa0,0xa0,0xa0,0xa0,0xe0,0x00}; + +const uint16_t ASCII8x8_Table [] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, 0x40, + 0xa0, 0xa0, 0xa0, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x24, 0x24, 0xfe, 0x48, 0xfc, 0x48, 0x48, + 0x38, 0x54, 0x50, 0x38, 0x14, 0x14, 0x54, 0x38, + 0x44, 0xa8, 0xa8, 0x50, 0x14, 0x1a, 0x2a, 0x24, + 0x10, 0x28, 0x28, 0x10, 0x74, 0x4c, 0x4c, 0x30, + 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x08, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x08, + 0x10, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x10, + 0x00, 0x00, 0x24, 0x18, 0x3c, 0x18, 0x24, 0x00, + 0x00, 0x00, 0x10, 0x10, 0x7c, 0x10, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x10, + 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, + 0x08, 0x08, 0x08, 0x10, 0x10, 0x20, 0x20, 0x20, + 0x18, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x18, + 0x08, 0x18, 0x28, 0x08, 0x08, 0x08, 0x08, 0x08, + 0x38, 0x44, 0x00, 0x04, 0x08, 0x10, 0x20, 0x7c, + 0x18, 0x24, 0x04, 0x18, 0x04, 0x04, 0x24, 0x18, + 0x04, 0x0c, 0x14, 0x24, 0x44, 0x7e, 0x04, 0x04, + 0x3c, 0x20, 0x20, 0x38, 0x04, 0x04, 0x24, 0x18, + 0x18, 0x24, 0x20, 0x38, 0x24, 0x24, 0x24, 0x18, + 0x3c, 0x04, 0x08, 0x08, 0x08, 0x10, 0x10, 0x10, + 0x18, 0x24, 0x24, 0x18, 0x24, 0x24, 0x24, 0x18, + 0x18, 0x24, 0x24, 0x24, 0x1c, 0x04, 0x24, 0x18, + 0x00, 0x00, 0x10, 0x00, 0x00, 0x10, 0x00, 0x00, + 0x00, 0x00, 0x08, 0x00, 0x00, 0x08, 0x10, 0x00, + 0x00, 0x00, 0x04, 0x18, 0x20, 0x18, 0x04, 0x00, + 0x00, 0x00, 0x00, 0x3c, 0x00, 0x3c, 0x00, 0x00, + 0x00, 0x00, 0x20, 0x18, 0x04, 0x18, 0x20, 0x00, + 0x18, 0x24, 0x04, 0x08, 0x10, 0x10, 0x00, 0x10, + 0x3c, 0x42, 0x99, 0xa5, 0xa5, 0x9d, 0x42, 0x38, + 0x38, 0x44, 0x44, 0x44, 0x7c, 0x44, 0x44, 0x44, + 0x78, 0x44, 0x44, 0x78, 0x44, 0x44, 0x44, 0x78, + 0x1c, 0x22, 0x42, 0x40, 0x40, 0x42, 0x22, 0x1c, + 0x70, 0x48, 0x44, 0x44, 0x44, 0x44, 0x48, 0x70, + 0x7c, 0x40, 0x40, 0x7c, 0x40, 0x40, 0x40, 0x7c, + 0x3c, 0x20, 0x20, 0x38, 0x20, 0x20, 0x20, 0x20, + 0x1c, 0x22, 0x42, 0x40, 0x4e, 0x42, 0x22, 0x1c, + 0x44, 0x44, 0x44, 0x7c, 0x44, 0x44, 0x44, 0x44, + 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x24, 0x24, 0x18, + 0x44, 0x48, 0x50, 0x70, 0x50, 0x48, 0x48, 0x44, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3c, + 0x82, 0xc6, 0xc6, 0xaa, 0xaa, 0xaa, 0xaa, 0x92, + 0x42, 0x62, 0x52, 0x52, 0x4a, 0x4a, 0x46, 0x42, + 0x18, 0x24, 0x42, 0x42, 0x42, 0x42, 0x24, 0x18, + 0x78, 0x44, 0x44, 0x44, 0x78, 0x40, 0x40, 0x40, + 0x18, 0x24, 0x42, 0x42, 0x42, 0x42, 0x2c, 0x1a, + 0x78, 0x44, 0x44, 0x78, 0x50, 0x48, 0x44, 0x42, + 0x38, 0x44, 0x40, 0x38, 0x04, 0x44, 0x44, 0x38, + 0x7c, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, + 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x24, 0x18, + 0x44, 0x44, 0x28, 0x28, 0x28, 0x28, 0x28, 0x10, + 0x92, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x44, + 0x42, 0x24, 0x24, 0x18, 0x18, 0x24, 0x24, 0x42, + 0x44, 0x28, 0x28, 0x10, 0x10, 0x10, 0x10, 0x10, + 0x7c, 0x04, 0x08, 0x10, 0x10, 0x20, 0x40, 0x7c, + 0x1c, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x1c, + 0x10, 0x10, 0x08, 0x08, 0x08, 0x08, 0x04, 0x04, + 0x1c, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x1c, + 0x10, 0x28, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x20, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x18, 0x04, 0x1c, 0x24, 0x24, 0x1c, + 0x20, 0x20, 0x28, 0x34, 0x24, 0x24, 0x34, 0x28, + 0x00, 0x00, 0x18, 0x24, 0x20, 0x20, 0x24, 0x18, + 0x04, 0x04, 0x14, 0x2c, 0x24, 0x24, 0x2c, 0x14, + 0x00, 0x00, 0x18, 0x24, 0x3c, 0x20, 0x24, 0x18, + 0x00, 0x18, 0x10, 0x10, 0x18, 0x10, 0x10, 0x10, + 0x00, 0x18, 0x24, 0x24, 0x18, 0x04, 0x24, 0x18, + 0x20, 0x20, 0x28, 0x34, 0x24, 0x24, 0x24, 0x24, + 0x10, 0x00, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, + 0x08, 0x00, 0x08, 0x08, 0x08, 0x08, 0x28, 0x10, + 0x20, 0x20, 0x24, 0x28, 0x30, 0x28, 0x24, 0x24, + 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, + 0x00, 0x00, 0xa6, 0xda, 0x92, 0x92, 0x92, 0x92, + 0x00, 0x00, 0x28, 0x34, 0x24, 0x24, 0x24, 0x24, + 0x00, 0x00, 0x18, 0x24, 0x24, 0x24, 0x24, 0x18, + 0x00, 0x28, 0x34, 0x24, 0x38, 0x20, 0x20, 0x20, + 0x00, 0x14, 0x2c, 0x24, 0x1c, 0x04, 0x04, 0x04, + 0x00, 0x00, 0x2c, 0x30, 0x20, 0x20, 0x20, 0x20, + 0x00, 0x00, 0x18, 0x24, 0x10, 0x08, 0x24, 0x18, + 0x00, 0x10, 0x38, 0x10, 0x10, 0x10, 0x10, 0x18, + 0x00, 0x00, 0x24, 0x24, 0x24, 0x24, 0x2c, 0x14, + 0x00, 0x00, 0x44, 0x44, 0x28, 0x28, 0x28, 0x10, + 0x00, 0x00, 0x92, 0xaa, 0xaa, 0xaa, 0xaa, 0x44, + 0x00, 0x00, 0x44, 0x28, 0x10, 0x10, 0x28, 0x44, + 0x00, 0x28, 0x28, 0x28, 0x10, 0x10, 0x10, 0x10, + 0x00, 0x00, 0x3c, 0x04, 0x08, 0x10, 0x20, 0x3c, + 0x00, 0x08, 0x10, 0x10, 0x20, 0x10, 0x10, 0x08, + 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, + 0x00, 0x10, 0x08, 0x08, 0x04, 0x08, 0x08, 0x10, + 0x00, 0x00, 0x00, 0x60, 0x92, 0x0c, 0x00, 0x00, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; + + +sFONT Font16x24 = { + ASCII16x24_Table, + 16, /* Width */ + 24, /* Height */ +}; + +sFONT Font12x12 = { + ASCII12x12_Table, + 12, /* Width */ + 12, /* Height */ +}; + +sFONT Font8x12 = { + ASCII8x12_Table, + 8, /* Width */ + 12, /* Height */ +}; + + +sFONT Font8x8 = { + ASCII8x8_Table, + 8, /* Width */ + 8, /* Height */ +}; + +/** + * @} + */ + + +/** @defgroup FONTS_Private_Function_Prototypes + * @{ + */ +/** + * @} + */ + + +/** @defgroup FONTS_Private_Functions + * @{ + */ + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/uGL/fonts.dep b/uGL/fonts.dep new file mode 100644 index 0000000..7e123a4 --- /dev/null +++ b/uGL/fonts.dep @@ -0,0 +1,8 @@ +uGL/fonts.o: uGL/fonts.c uGL/fonts.h \ + /usr/local/Caskroom/gcc-arm-embedded/7-2017-q4-major/gcc-arm-none-eabi-7-2017-q4-major/lib/gcc/arm-none-eabi/7.2.1/include/stdint.h \ + /usr/local/Caskroom/gcc-arm-embedded/7-2017-q4-major/gcc-arm-none-eabi-7-2017-q4-major/arm-none-eabi/include/stdint.h \ + /usr/local/Caskroom/gcc-arm-embedded/7-2017-q4-major/gcc-arm-none-eabi-7-2017-q4-major/arm-none-eabi/include/machine/_default_types.h \ + /usr/local/Caskroom/gcc-arm-embedded/7-2017-q4-major/gcc-arm-none-eabi-7-2017-q4-major/arm-none-eabi/include/sys/features.h \ + /usr/local/Caskroom/gcc-arm-embedded/7-2017-q4-major/gcc-arm-none-eabi-7-2017-q4-major/arm-none-eabi/include/_newlib_version.h \ + /usr/local/Caskroom/gcc-arm-embedded/7-2017-q4-major/gcc-arm-none-eabi-7-2017-q4-major/arm-none-eabi/include/sys/_intsup.h \ + /usr/local/Caskroom/gcc-arm-embedded/7-2017-q4-major/gcc-arm-none-eabi-7-2017-q4-major/arm-none-eabi/include/sys/_stdint.h diff --git a/uGL/fonts.h b/uGL/fonts.h new file mode 100755 index 0000000..6d9f7d2 --- /dev/null +++ b/uGL/fonts.h @@ -0,0 +1,124 @@ +/** + ****************************************************************************** + * @file fonts.h + * @author MCD Application Team + * @version V5.0.2 + * @date 05-March-2012 + * @brief Header for fonts.c file + ****************************************************************************** + * @attention + * + *

© COPYRIGHT 2012 STMicroelectronics

+ * + * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.st.com/software_license_agreement_liberty_v2 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __FONTS_H +#define __FONTS_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include + +/** @addtogroup Utilities + * @{ + */ + +/** @addtogroup STM32_EVAL + * @{ + */ + +/** @addtogroup Common + * @{ + */ + +/** @addtogroup FONTS + * @{ + */ + +/** @defgroup FONTS_Exported_Types + * @{ + */ +typedef struct _tFont +{ + const uint16_t *table; + uint16_t Width; + uint16_t Height; + +} sFONT; + +extern sFONT Font16x24; +extern sFONT Font12x12; +extern sFONT Font8x12; +extern sFONT Font8x8; + +/** + * @} + */ + +/** @defgroup FONTS_Exported_Constants + * @{ + */ +#define LINE(x) ((x) * (((sFONT *)LCD_GetFont())->Height)) + +/** + * @} + */ + +/** @defgroup FONTS_Exported_Macros + * @{ + */ +/** + * @} + */ + +/** @defgroup FONTS_Exported_Functions + * @{ + */ +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* __FONTS_H */ + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/uGL/stm32f429i_discovery.c b/uGL/stm32f429i_discovery.c new file mode 100755 index 0000000..5429bbd --- /dev/null +++ b/uGL/stm32f429i_discovery.c @@ -0,0 +1,428 @@ +/** + ****************************************************************************** + * @file stm32f429i_discovery.c + * @author MCD Application Team + * @version V1.0.1 + * @date 28-October-2013 + * @brief This file provides set of firmware functions to manage Leds and + * push-button available on STM32F429I-DISCO Kit from STMicroelectronics. + ****************************************************************************** + * @attention + * + *

© COPYRIGHT 2013 STMicroelectronics

+ * + * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.st.com/software_license_agreement_liberty_v2 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "stm32f429i_discovery.h" + +/** @addtogroup Utilities + * @{ + */ + +/** @addtogroup STM32F4_DISCOVERY + * @{ + */ + +/** @addtogroup STM32F429I_DISCOVERY + * @{ + */ + +/** @defgroup STM32F429I-DISCOVERY_LOW_LEVEL + * @brief This file provides set of firmware functions to manage Leds and push-button + * available on STM32F429I-Discovery Kit from STMicroelectronics. + * @{ + */ + +/** @defgroup STM32F429I-DISCOVERY_LOW_LEVEL_Private_TypesDefinitions + * @{ + */ +/** + * @} + */ + + +/** @defgroup STM32F429I-DISCOVERY_LOW_LEVEL_Private_Defines + * @{ + */ +/** + * @} + */ + + +/** @defgroup STM32F429I-DISCOVERY_LOW_LEVEL_Private_Macros + * @{ + */ +/** + * @} + */ + + +/** @defgroup STM32F429I-DISCOVERY_LOW_LEVEL_Private_Variables + * @{ + */ +GPIO_TypeDef* GPIO_PORT[LEDn] = {LED3_GPIO_PORT, LED4_GPIO_PORT}; +const uint16_t GPIO_PIN[LEDn] = {LED3_PIN, LED4_PIN}; +const uint32_t GPIO_CLK[LEDn] = {LED3_GPIO_CLK, LED4_GPIO_CLK}; + +GPIO_TypeDef* BUTTON_PORT[BUTTONn] = {USER_BUTTON_GPIO_PORT}; + +const uint16_t BUTTON_PIN[BUTTONn] = {USER_BUTTON_PIN}; + +const uint32_t BUTTON_CLK[BUTTONn] = {USER_BUTTON_GPIO_CLK}; + +const uint16_t BUTTON_EXTI_LINE[BUTTONn] = {USER_BUTTON_EXTI_LINE}; + +const uint8_t BUTTON_PORT_SOURCE[BUTTONn] = {USER_BUTTON_EXTI_PORT_SOURCE}; + +const uint8_t BUTTON_PIN_SOURCE[BUTTONn] = {USER_BUTTON_EXTI_PIN_SOURCE}; +const uint8_t BUTTON_IRQn[BUTTONn] = {USER_BUTTON_EXTI_IRQn}; + +DMA_InitTypeDef sEEDMA_InitStructure; +NVIC_InitTypeDef NVIC_InitStructure; + +/** + * @} + */ + + +/** @defgroup STM32F429I-DISCOVERY_LOW_LEVEL_Private_FunctionPrototypes + * @{ + */ + +/** + * @} + */ + +/** @defgroup STM32F429I-DISCOVERY_LOW_LEVEL_Private_Functions + * @{ + */ + +/** + * @brief Configures LED GPIO. + * @param Led: Specifies the Led to be configured. + * This parameter can be one of following parameters: + * @arg LED3 + * @arg LED4 + * @retval None + */ +void STM_EVAL_LEDInit(Led_TypeDef Led) +{ + GPIO_InitTypeDef GPIO_InitStructure; + + /* Enable the GPIO_LED Clock */ + RCC_AHB1PeriphClockCmd(GPIO_CLK[Led], ENABLE); + + /* Configure the GPIO_LED pin */ + GPIO_InitStructure.GPIO_Pin = GPIO_PIN[Led]; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; + GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; + GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; + GPIO_Init(GPIO_PORT[Led], &GPIO_InitStructure); +} + +/** + * @brief Turns selected LED On. + * @param Led: Specifies the Led to be set on. + * This parameter can be one of following parameters: + * @arg LED3 + * @arg LED4 + * @retval None + */ +void STM_EVAL_LEDOn(Led_TypeDef Led) +{ + GPIO_PORT[Led]->BSRRL = GPIO_PIN[Led]; +} + +/** + * @brief Turns selected LED Off. + * @param Led: Specifies the Led to be set off. + * This parameter can be one of following parameters: + * @arg LED3 + * @arg LED4 + * @retval None + */ +void STM_EVAL_LEDOff(Led_TypeDef Led) +{ + GPIO_PORT[Led]->BSRRH = GPIO_PIN[Led]; +} + +/** + * @brief Toggles the selected LED. + * @param Led: Specifies the Led to be toggled. + * This parameter can be one of following parameters: + * @arg LED3 + * @arg LED4 + * @retval None + */ +void STM_EVAL_LEDToggle(Led_TypeDef Led) +{ + GPIO_PORT[Led]->ODR ^= GPIO_PIN[Led]; +} + +/** + * @brief Configures Button GPIO and EXTI Line. + * @param Button: Specifies the Button to be configured. + * This parameter should be: BUTTON_USER + * @param Button_Mode: Specifies Button mode. + * This parameter can be one of following parameters: + * @arg BUTTON_MODE_GPIO: Button will be used as simple IO + * @arg BUTTON_MODE_EXTI: Button will be connected to EXTI line with interrupt + * generation capability + * @retval None + */ +void STM_EVAL_PBInit(Button_TypeDef Button, ButtonMode_TypeDef Button_Mode) +{ + GPIO_InitTypeDef GPIO_InitStructure; + EXTI_InitTypeDef EXTI_InitStructure; + NVIC_InitTypeDef NVIC_InitStructure; + + /* Enable the BUTTON Clock */ + RCC_AHB1PeriphClockCmd(BUTTON_CLK[Button], ENABLE); + RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE); + + /* Configure Button pin as input */ + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN; + GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN; + GPIO_InitStructure.GPIO_Pin = BUTTON_PIN[Button]; + GPIO_Init(BUTTON_PORT[Button], &GPIO_InitStructure); + + if (Button_Mode == BUTTON_MODE_EXTI) + { + /* Connect Button EXTI Line to Button GPIO Pin */ + SYSCFG_EXTILineConfig(BUTTON_PORT_SOURCE[Button], BUTTON_PIN_SOURCE[Button]); + + /* Configure Button EXTI line */ + EXTI_InitStructure.EXTI_Line = BUTTON_EXTI_LINE[Button]; + EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt; + EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising; + EXTI_InitStructure.EXTI_LineCmd = ENABLE; + EXTI_Init(&EXTI_InitStructure); + + /* Enable and set Button EXTI Interrupt to the lowest priority */ + NVIC_InitStructure.NVIC_IRQChannel = BUTTON_IRQn[Button]; + NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x0F; + NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x0F; + NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; + + NVIC_Init(&NVIC_InitStructure); + } +} + +/** + * @brief Returns the selected Button state. + * @param Button: Specifies the Button to be checked. + * This parameter should be: BUTTON_USER + * @retval The Button GPIO pin value. + */ +uint32_t STM_EVAL_PBGetState(Button_TypeDef Button) +{ + return GPIO_ReadInputDataBit(BUTTON_PORT[Button], BUTTON_PIN[Button]); +} + +/** + * @brief DeInitializes peripherals used by the I2C EEPROM driver. + * @param None + * @retval None + */ +void sEE_LowLevel_DeInit(void) +{ + GPIO_InitTypeDef GPIO_InitStructure; + + /* sEE_I2C Peripheral Disable */ + I2C_Cmd(sEE_I2C, DISABLE); + + /* sEE_I2C DeInit */ + I2C_DeInit(sEE_I2C); + + /*!< sEE_I2C Periph clock disable */ + RCC_APB1PeriphClockCmd(sEE_I2C_CLK, DISABLE); + + /*!< GPIO configuration */ + /*!< Configure sEE_I2C pins: SCL */ + GPIO_InitStructure.GPIO_Pin = sEE_I2C_SCL_PIN; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN; + GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; + GPIO_Init(sEE_I2C_SCL_GPIO_PORT, &GPIO_InitStructure); + + /*!< Configure sEE_I2C pins: SDA */ + GPIO_InitStructure.GPIO_Pin = sEE_I2C_SDA_PIN; + GPIO_Init(sEE_I2C_SDA_GPIO_PORT, &GPIO_InitStructure); + + /* Configure and enable I2C DMA TX Stream interrupt */ + NVIC_InitStructure.NVIC_IRQChannel = sEE_I2C_DMA_TX_IRQn; + NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = sEE_I2C_DMA_PREPRIO; + NVIC_InitStructure.NVIC_IRQChannelSubPriority = sEE_I2C_DMA_SUBPRIO; + NVIC_InitStructure.NVIC_IRQChannelCmd = DISABLE; + NVIC_Init(&NVIC_InitStructure); + + /* Configure and enable I2C DMA RX Stream interrupt */ + NVIC_InitStructure.NVIC_IRQChannel = sEE_I2C_DMA_RX_IRQn; + NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = sEE_I2C_DMA_PREPRIO; + NVIC_InitStructure.NVIC_IRQChannelSubPriority = sEE_I2C_DMA_SUBPRIO; + NVIC_Init(&NVIC_InitStructure); + + /* Disable and Deinitialize the DMA Streams */ + DMA_Cmd(sEE_I2C_DMA_STREAM_TX, DISABLE); + DMA_Cmd(sEE_I2C_DMA_STREAM_RX, DISABLE); + DMA_DeInit(sEE_I2C_DMA_STREAM_TX); + DMA_DeInit(sEE_I2C_DMA_STREAM_RX); +} + +/** + * @brief Initializes peripherals used by the I2C EEPROM driver. + * @param None + * @retval None + */ +void sEE_LowLevel_Init(void) +{ + GPIO_InitTypeDef GPIO_InitStructure; + + /*!< sEE_I2C Periph clock enable */ + RCC_APB1PeriphClockCmd(sEE_I2C_CLK, ENABLE); + + /*!< sEE_I2C_SCL_GPIO_CLK and sEE_I2C_SDA_GPIO_CLK Periph clock enable */ + RCC_AHB1PeriphClockCmd(sEE_I2C_SCL_GPIO_CLK | sEE_I2C_SDA_GPIO_CLK, ENABLE); + + RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE); + + /* Reset sEE_I2C IP */ + RCC_APB1PeriphResetCmd(sEE_I2C_CLK, ENABLE); + /* Release reset signal of sEE_I2C IP */ + RCC_APB1PeriphResetCmd(sEE_I2C_CLK, DISABLE); + + /*!< GPIO configuration */ + /*!< Configure sEE_I2C pins: SCL */ + GPIO_InitStructure.GPIO_Pin = sEE_I2C_SCL_PIN; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; + GPIO_InitStructure.GPIO_OType = GPIO_OType_OD; + GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; + GPIO_Init(sEE_I2C_SCL_GPIO_PORT, &GPIO_InitStructure); + + /*!< Configure sEE_I2C pins: SDA */ + GPIO_InitStructure.GPIO_Pin = sEE_I2C_SDA_PIN; + GPIO_Init(sEE_I2C_SDA_GPIO_PORT, &GPIO_InitStructure); + + /* Connect PXx to I2C_SCL*/ + GPIO_PinAFConfig(sEE_I2C_SCL_GPIO_PORT, sEE_I2C_SCL_SOURCE, sEE_I2C_SCL_AF); + + /* Connect PXx to I2C_SDA*/ + GPIO_PinAFConfig(sEE_I2C_SDA_GPIO_PORT, sEE_I2C_SDA_SOURCE, sEE_I2C_SDA_AF); + + /* Configure and enable I2C DMA TX Channel interrupt */ + NVIC_InitStructure.NVIC_IRQChannel = sEE_I2C_DMA_TX_IRQn; + NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = sEE_I2C_DMA_PREPRIO; + NVIC_InitStructure.NVIC_IRQChannelSubPriority = sEE_I2C_DMA_SUBPRIO; + NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; + NVIC_Init(&NVIC_InitStructure); + + /* Configure and enable I2C DMA RX Channel interrupt */ + NVIC_InitStructure.NVIC_IRQChannel = sEE_I2C_DMA_RX_IRQn; + NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = sEE_I2C_DMA_PREPRIO; + NVIC_InitStructure.NVIC_IRQChannelSubPriority = sEE_I2C_DMA_SUBPRIO; + NVIC_Init(&NVIC_InitStructure); + + /*!< I2C DMA TX and RX channels configuration */ + /* Enable the DMA clock */ + RCC_AHB1PeriphClockCmd(sEE_I2C_DMA_CLK, ENABLE); + + /* Clear any pending flag on Rx Stream */ + DMA_ClearFlag(sEE_I2C_DMA_STREAM_TX, sEE_TX_DMA_FLAG_FEIF | sEE_TX_DMA_FLAG_DMEIF | sEE_TX_DMA_FLAG_TEIF | \ + sEE_TX_DMA_FLAG_HTIF | sEE_TX_DMA_FLAG_TCIF); + /* Disable the EE I2C Tx DMA stream */ + DMA_Cmd(sEE_I2C_DMA_STREAM_TX, DISABLE); + /* Configure the DMA stream for the EE I2C peripheral TX direction */ + DMA_DeInit(sEE_I2C_DMA_STREAM_TX); + sEEDMA_InitStructure.DMA_Channel = sEE_I2C_DMA_CHANNEL; + sEEDMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)sEE_I2C_DR_Address; + sEEDMA_InitStructure.DMA_Memory0BaseAddr = (uint32_t)0; /* This parameter will be configured durig communication */; + sEEDMA_InitStructure.DMA_DIR = DMA_DIR_MemoryToPeripheral; /* This parameter will be configured durig communication */ + sEEDMA_InitStructure.DMA_BufferSize = 0xFFFF; /* This parameter will be configured durig communication */ + sEEDMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; + sEEDMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable; + sEEDMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte; + sEEDMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte; + sEEDMA_InitStructure.DMA_Mode = DMA_Mode_Normal; + sEEDMA_InitStructure.DMA_Priority = DMA_Priority_VeryHigh; + sEEDMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Enable; + sEEDMA_InitStructure.DMA_FIFOThreshold = DMA_FIFOThreshold_Full; + sEEDMA_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_Single; + sEEDMA_InitStructure.DMA_PeripheralBurst = DMA_PeripheralBurst_Single; + DMA_Init(sEE_I2C_DMA_STREAM_TX, &sEEDMA_InitStructure); + + /* Clear any pending flag on Rx Stream */ + DMA_ClearFlag(sEE_I2C_DMA_STREAM_RX, sEE_RX_DMA_FLAG_FEIF | sEE_RX_DMA_FLAG_DMEIF | sEE_RX_DMA_FLAG_TEIF | \ + sEE_RX_DMA_FLAG_HTIF | sEE_RX_DMA_FLAG_TCIF); + /* Disable the EE I2C DMA Rx stream */ + DMA_Cmd(sEE_I2C_DMA_STREAM_RX, DISABLE); + /* Configure the DMA stream for the EE I2C peripheral RX direction */ + DMA_DeInit(sEE_I2C_DMA_STREAM_RX); + DMA_Init(sEE_I2C_DMA_STREAM_RX, &sEEDMA_InitStructure); + + /* Enable the DMA Channels Interrupts */ + DMA_ITConfig(sEE_I2C_DMA_STREAM_TX, DMA_IT_TC, ENABLE); + DMA_ITConfig(sEE_I2C_DMA_STREAM_RX, DMA_IT_TC, ENABLE); +} + +/** + * @brief Initializes DMA channel used by the I2C EEPROM driver. + * @param None + * @retval None + */ +void sEE_LowLevel_DMAConfig(uint32_t pBuffer, uint32_t BufferSize, uint32_t Direction) +{ + /* Initialize the DMA with the new parameters */ + if (Direction == sEE_DIRECTION_TX) + { + /* Configure the DMA Tx Stream with the buffer address and the buffer size */ + sEEDMA_InitStructure.DMA_Memory0BaseAddr = (uint32_t)pBuffer; + sEEDMA_InitStructure.DMA_DIR = DMA_DIR_MemoryToPeripheral; + sEEDMA_InitStructure.DMA_BufferSize = (uint32_t)BufferSize; + DMA_Init(sEE_I2C_DMA_STREAM_TX, &sEEDMA_InitStructure); + } + else + { + /* Configure the DMA Rx Stream with the buffer address and the buffer size */ + sEEDMA_InitStructure.DMA_Memory0BaseAddr = (uint32_t)pBuffer; + sEEDMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralToMemory; + sEEDMA_InitStructure.DMA_BufferSize = (uint32_t)BufferSize; + DMA_Init(sEE_I2C_DMA_STREAM_RX, &sEEDMA_InitStructure); + } +} + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/uGL/stm32f429i_discovery.dep b/uGL/stm32f429i_discovery.dep new file mode 100644 index 0000000..5fb60d3 --- /dev/null +++ b/uGL/stm32f429i_discovery.dep @@ -0,0 +1,42 @@ +uGL/stm32f429i_discovery.o: uGL/stm32f429i_discovery.c \ + uGL/stm32f429i_discovery.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/Core/CM4F/DeviceSupport/ST/stm32f4xx/stm32f4xx.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/Core/CM4F/CoreSupport/core_cm4.h \ + /usr/local/Caskroom/gcc-arm-embedded/7-2017-q4-major/gcc-arm-none-eabi-7-2017-q4-major/lib/gcc/arm-none-eabi/7.2.1/include/stdint.h \ + /usr/local/Caskroom/gcc-arm-embedded/7-2017-q4-major/gcc-arm-none-eabi-7-2017-q4-major/arm-none-eabi/include/stdint.h \ + /usr/local/Caskroom/gcc-arm-embedded/7-2017-q4-major/gcc-arm-none-eabi-7-2017-q4-major/arm-none-eabi/include/machine/_default_types.h \ + /usr/local/Caskroom/gcc-arm-embedded/7-2017-q4-major/gcc-arm-none-eabi-7-2017-q4-major/arm-none-eabi/include/sys/features.h \ + /usr/local/Caskroom/gcc-arm-embedded/7-2017-q4-major/gcc-arm-none-eabi-7-2017-q4-major/arm-none-eabi/include/_newlib_version.h \ + /usr/local/Caskroom/gcc-arm-embedded/7-2017-q4-major/gcc-arm-none-eabi-7-2017-q4-major/arm-none-eabi/include/sys/_intsup.h \ + /usr/local/Caskroom/gcc-arm-embedded/7-2017-q4-major/gcc-arm-none-eabi-7-2017-q4-major/arm-none-eabi/include/sys/_stdint.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/Core/CM4F/CoreSupport/core_cmInstr.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/Core/CM4F/CoreSupport/core_cmFunc.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/Core/CM4F/CoreSupport/core_cmSimd.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/Core/CM4F/DeviceSupport/ST/stm32f4xx/system_stm32f4xx.h \ + /Users/tom/Documents/src/uGames/uC-sdk/config/arm/stm32f4xx/stm32f4xx_conf.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_adc.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_can.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_crc.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_cryp.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_dac.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_dbgmcu.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_dcmi.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_dma.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_exti.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_flash.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_fsmc.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_hash.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_gpio.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_i2c.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_iwdg.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_pwr.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_rcc.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_rng.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_rtc.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_sdio.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_spi.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_syscfg.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_tim.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_usart.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_wwdg.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/misc.h diff --git a/uGL/stm32f429i_discovery.h b/uGL/stm32f429i_discovery.h new file mode 100755 index 0000000..07de671 --- /dev/null +++ b/uGL/stm32f429i_discovery.h @@ -0,0 +1,233 @@ +/** + ****************************************************************************** + * @file stm32f429i_discovery.h + * @author MCD Application Team + * @version V1.0.1 + * @date 28-October-2013 + * @brief This file contains definitions for STM32F429I-DISCO Kit Leds, push- + * buttons hardware resources. + ****************************************************************************** + * @attention + * + *

© COPYRIGHT 2013 STMicroelectronics

+ * + * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.st.com/software_license_agreement_liberty_v2 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32F429I_DISCOVERY_H +#define __STM32F429I_DISCOVERY_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ + #include "stm32f4xx.h" + +/** @addtogroup Utilities + * @{ + */ + +/** @addtogroup STM32F4_DISCOVERY + * @{ + */ + +/** @addtogroup STM32F429I_DISCOVERY + * @{ + */ + +/** @addtogroup STM32F429I_DISCOVERY_LOW_LEVEL + * @{ + */ + +/** @defgroup STM32F429I_DISCOVERY_LOW_LEVEL_Exported_Types + * @{ + */ +typedef enum +{ + LED3 = 0, + LED4 = 1 +} Led_TypeDef; + +typedef enum +{ + BUTTON_USER = 0, +} Button_TypeDef; + +typedef enum +{ + BUTTON_MODE_GPIO = 0, + BUTTON_MODE_EXTI = 1 +} ButtonMode_TypeDef; +/** + * @} + */ + +/** @defgroup STM32F429I_DISCOVERY_LOW_LEVEL_Exported_Constants + * @{ + */ + +/** + * @brief Define for STM32F429I_DISCO board + */ +#if !defined (USE_STM32F429I_DISCO) + #define USE_STM32F429I_DISCO +#endif + + +/** @addtogroup STM32F429I_DISCOVERY_LOW_LEVEL_LED + * @{ + */ +#define LEDn 2 + +#define LED3_PIN GPIO_Pin_13 +#define LED3_GPIO_PORT GPIOG +#define LED3_GPIO_CLK RCC_AHB1Periph_GPIOG + +#define LED4_PIN GPIO_Pin_14 +#define LED4_GPIO_PORT GPIOG +#define LED4_GPIO_CLK RCC_AHB1Periph_GPIOG +/** + * @} + */ + +/** @addtogroup STM32F429I_DISCOVERY_LOW_LEVEL_BUTTON + * @{ + */ +#define BUTTONn 1 + +/** + * @brief Wakeup push-button + */ +#define USER_BUTTON_PIN GPIO_Pin_0 +#define USER_BUTTON_GPIO_PORT GPIOA +#define USER_BUTTON_GPIO_CLK RCC_AHB1Periph_GPIOA +#define USER_BUTTON_EXTI_LINE EXTI_Line0 +#define USER_BUTTON_EXTI_PORT_SOURCE EXTI_PortSourceGPIOA +#define USER_BUTTON_EXTI_PIN_SOURCE EXTI_PinSource0 +#define USER_BUTTON_EXTI_IRQn EXTI0_IRQn +/** + * @} + */ + +/** @addtogroup STM32F429I_DISCOVERY_LOW_LEVEL_I2C_EE + * @{ + */ +/** + * @brief I2C EEPROM Interface pins + */ +#define sEE_I2C I2C3 +#define sEE_I2C_CLK RCC_APB1Periph_I2C3 +#define sEE_I2C_SCL_PIN GPIO_Pin_8 /* PA.08 */ +#define sEE_I2C_SCL_GPIO_PORT GPIOA /* GPIOA */ +#define sEE_I2C_SCL_GPIO_CLK RCC_AHB1Periph_GPIOA +#define sEE_I2C_SCL_SOURCE GPIO_PinSource8 +#define sEE_I2C_SCL_AF GPIO_AF_I2C3 +#define sEE_I2C_SDA_PIN GPIO_Pin_9 /* PC.09 */ +#define sEE_I2C_SDA_GPIO_PORT GPIOC /* GPIOC */ +#define sEE_I2C_SDA_GPIO_CLK RCC_AHB1Periph_GPIOC +#define sEE_I2C_SDA_SOURCE GPIO_PinSource9 +#define sEE_I2C_SDA_AF GPIO_AF_I2C3 +#define sEE_M24C64_32 + +#define sEE_I2C_DMA DMA1 +#define sEE_I2C_DMA_CHANNEL DMA_Channel_3 +#define sEE_I2C_DMA_STREAM_TX DMA1_Stream4 +#define sEE_I2C_DMA_STREAM_RX DMA1_Stream2 +#define sEE_I2C_DMA_CLK RCC_AHB1Periph_DMA1 +#define sEE_I2C_DR_Address ((uint32_t)0x40005C10) +#define sEE_USE_DMA + +#define sEE_I2C_DMA_TX_IRQn DMA1_Stream4_IRQn +#define sEE_I2C_DMA_RX_IRQn DMA1_Stream2_IRQn +#define sEE_I2C_DMA_TX_IRQHandler DMA1_Stream4_IRQHandler +#define sEE_I2C_DMA_RX_IRQHandler DMA1_Stream2_IRQHandler +#define sEE_I2C_DMA_PREPRIO 0 +#define sEE_I2C_DMA_SUBPRIO 0 + +#define sEE_TX_DMA_FLAG_FEIF DMA_FLAG_FEIF4 +#define sEE_TX_DMA_FLAG_DMEIF DMA_FLAG_DMEIF4 +#define sEE_TX_DMA_FLAG_TEIF DMA_FLAG_TEIF4 +#define sEE_TX_DMA_FLAG_HTIF DMA_FLAG_HTIF4 +#define sEE_TX_DMA_FLAG_TCIF DMA_FLAG_TCIF4 +#define sEE_RX_DMA_FLAG_FEIF DMA_FLAG_FEIF2 +#define sEE_RX_DMA_FLAG_DMEIF DMA_FLAG_DMEIF2 +#define sEE_RX_DMA_FLAG_TEIF DMA_FLAG_TEIF2 +#define sEE_RX_DMA_FLAG_HTIF DMA_FLAG_HTIF2 +#define sEE_RX_DMA_FLAG_TCIF DMA_FLAG_TCIF2 + +#define sEE_DIRECTION_TX 0 +#define sEE_DIRECTION_RX 1 + +/* I2C clock speed configuration (in Hz), used by I2C EEPROM memory and IO Expander drivers */ +#ifndef I2C_SPEED + #define I2C_SPEED 100000 +#endif /* I2C_SPEED */ + +/** + * @} + */ + +/** @defgroup STM32F429I_DISCOVERY_LOW_LEVEL_Exported_Macros + * @{ + */ +/** + * @} + */ + + +/** @defgroup STM32F429I_DISCOVERY_LOW_LEVEL_Exported_Functions + * @{ + */ +void STM_EVAL_LEDInit(Led_TypeDef Led); +void STM_EVAL_LEDOn(Led_TypeDef Led); +void STM_EVAL_LEDOff(Led_TypeDef Led); +void STM_EVAL_LEDToggle(Led_TypeDef Led); +void STM_EVAL_PBInit(Button_TypeDef Button, ButtonMode_TypeDef Button_Mode); +uint32_t STM_EVAL_PBGetState(Button_TypeDef Button); +void sEE_LowLevel_DeInit(void); +void sEE_LowLevel_Init(void); +void sEE_LowLevel_DMAConfig(uint32_t pBuffer, uint32_t BufferSize, uint32_t Direction); +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* __STM32F429I_DISCOVERY_H */ +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/uGL/stm32f429i_discovery_lcd.c b/uGL/stm32f429i_discovery_lcd.c new file mode 100755 index 0000000..8f697fc --- /dev/null +++ b/uGL/stm32f429i_discovery_lcd.c @@ -0,0 +1,1968 @@ +/** + ****************************************************************************** + * @file stm32f429i_discovery_lcd.c + * @author MCD Application Team + * @version V1.0.1 + * @date 28-October-2013 + * @brief This file includes the LCD driver for ILI9341 Liquid Crystal + * Display Modules of STM32F429I-DISCO kit (MB1075). + ****************************************************************************** + * @attention + * + *

© COPYRIGHT 2013 STMicroelectronics

+ * + * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.st.com/software_license_agreement_liberty_v2 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "stm32f429i_discovery_lcd.h" +#include "stm32f4xx_ltdc.h" +#include "stm32f4xx_dma2d.h" +//#include "fonts.c" + + +/** @addtogroup Utilities + * @{ + */ + +/** @addtogroup STM32F4_DISCOVERY + * @{ + */ + +/** @addtogroup STM32F429I_DISCOVERY + * @{ + */ + +/** @defgroup STM32F429I_DISCOVERY_LCD + * @brief This file includes the LCD driver for (ILI9341) + * @{ + */ + +/** @defgroup STM32F429I_DISCOVERY_LCD_Private_TypesDefinitions + * @{ + */ +/** + * @} + */ + +/** @defgroup STM32F429I_DISCOVERY_LCD_Private_Defines + * @{ + */ + +#define POLY_Y(Z) ((int32_t)((Points + Z)->X)) +#define POLY_X(Z) ((int32_t)((Points + Z)->Y)) +/** + * @} + */ + +/** @defgroup STM32F429I_DISCOVERY_LCD_Private_Macros + * @{ + */ +#define ABS(X) ((X) > 0 ? (X) : -(X)) +/** + * @} + */ + +/** @defgroup STM32F429I_DISCOVERY_LCD_Private_Variables + * @{ + */ +static sFONT *LCD_Currentfonts; +/* Global variables to set the written text color */ +static uint16_t CurrentTextColor = 0x0000; +static uint16_t CurrentBackColor = 0xFFFF; +/* Default LCD configuration with LCD Layer 1 */ +static uint32_t CurrentFrameBuffer = LCD_FRAME_BUFFER; +static uint32_t CurrentLayer = LCD_BACKGROUND_LAYER; +/** + * @} + */ + +/** @defgroup STM32F429I_DISCOVERY_LCD_Private_FunctionPrototypes + * @{ + */ +#ifndef USE_Delay +static void delay(__IO uint32_t nCount); +#endif /* USE_Delay*/ + +static void PutPixel(int16_t x, int16_t y); +static void LCD_PolyLineRelativeClosed(pPoint Points, uint16_t PointCount, uint16_t Closed); +static void LCD_AF_GPIOConfig(void); + +/** + * @} + */ + +/** @defgroup STM32F429I_DISCOVERY_LCD_Private_Functions + * @{ + */ + +/** + * @brief DeInitializes the LCD. + * @param None + * @retval None + */ +void LCD_DeInit(void) +{ + GPIO_InitTypeDef GPIO_InitStructure; + + /* LCD Display Off */ + LCD_DisplayOff(); + + /* LCD_SPI disable */ + SPI_Cmd(LCD_SPI, DISABLE); + + /* LCD_SPI DeInit */ + SPI_I2S_DeInit(LCD_SPI); + + /* Disable SPI clock */ + RCC_APB2PeriphClockCmd(LCD_SPI_CLK, DISABLE); + + /* Configure NCS in Output Push-Pull mode */ + GPIO_InitStructure.GPIO_Pin = LCD_NCS_PIN; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN; + GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; + GPIO_Init(LCD_NCS_GPIO_PORT, &GPIO_InitStructure); + + /* Configure SPI pins: SCK, MISO and MOSI */ + GPIO_InitStructure.GPIO_Pin = LCD_SPI_SCK_PIN; + GPIO_Init(LCD_SPI_SCK_GPIO_PORT, &GPIO_InitStructure); + + GPIO_InitStructure.GPIO_Pin = LCD_SPI_MISO_PIN; + GPIO_Init(LCD_SPI_MISO_GPIO_PORT, &GPIO_InitStructure); + + GPIO_InitStructure.GPIO_Pin = LCD_SPI_MOSI_PIN; + GPIO_Init(LCD_SPI_MOSI_GPIO_PORT, &GPIO_InitStructure); + + /* GPIOA configuration */ + GPIO_PinAFConfig(GPIOA, GPIO_PinSource3, GPIO_AF_MCO); + GPIO_PinAFConfig(GPIOA, GPIO_PinSource4, GPIO_AF_MCO); + GPIO_PinAFConfig(GPIOA, GPIO_PinSource6, GPIO_AF_MCO); + GPIO_PinAFConfig(GPIOA, GPIO_PinSource11, GPIO_AF_MCO); + GPIO_PinAFConfig(GPIOA, GPIO_PinSource12, GPIO_AF_MCO); + + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_6 | + GPIO_Pin_11 | GPIO_Pin_12; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; + GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; + GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; + GPIO_Init(GPIOA, &GPIO_InitStructure); + + /* GPIOB configuration */ + GPIO_PinAFConfig(GPIOB, GPIO_PinSource0, GPIO_AF_MCO); + GPIO_PinAFConfig(GPIOB, GPIO_PinSource1, GPIO_AF_MCO); + GPIO_PinAFConfig(GPIOB, GPIO_PinSource8, GPIO_AF_MCO); + GPIO_PinAFConfig(GPIOB, GPIO_PinSource9, GPIO_AF_MCO); + GPIO_PinAFConfig(GPIOB, GPIO_PinSource10, GPIO_AF_MCO); + GPIO_PinAFConfig(GPIOB, GPIO_PinSource11, GPIO_AF_MCO); + + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_8 | + GPIO_Pin_9 | GPIO_Pin_10 | GPIO_Pin_11; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; + GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; + GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; + GPIO_Init(GPIOB, &GPIO_InitStructure); + + /* GPIOC configuration */ + GPIO_PinAFConfig(GPIOC, GPIO_PinSource6, GPIO_AF_MCO); + GPIO_PinAFConfig(GPIOC, GPIO_PinSource7, GPIO_AF_MCO); + GPIO_PinAFConfig(GPIOC, GPIO_PinSource10, GPIO_AF_MCO); + + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7 | GPIO_Pin_10; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; + GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; + GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; + GPIO_Init(GPIOC, &GPIO_InitStructure); + + /* GPIOD configuration */ + GPIO_PinAFConfig(GPIOD, GPIO_PinSource3, GPIO_AF_MCO); + GPIO_PinAFConfig(GPIOD, GPIO_PinSource6, GPIO_AF_MCO); + + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3 | GPIO_Pin_6; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; + GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; + GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; + GPIO_Init(GPIOD, &GPIO_InitStructure); + + /* GPIOF configuration */ + GPIO_PinAFConfig(GPIOF, GPIO_PinSource10, GPIO_AF_MCO); + + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; + GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; + GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; + GPIO_Init(GPIOF, &GPIO_InitStructure); + + /* GPIOG configuration */ + GPIO_PinAFConfig(GPIOG, GPIO_PinSource6, GPIO_AF_MCO); + GPIO_PinAFConfig(GPIOG, GPIO_PinSource7, GPIO_AF_MCO); + GPIO_PinAFConfig(GPIOG, GPIO_PinSource10, GPIO_AF_MCO); + GPIO_PinAFConfig(GPIOG, GPIO_PinSource11, GPIO_AF_MCO); + GPIO_PinAFConfig(GPIOG, GPIO_PinSource12, GPIO_AF_MCO); + + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7 | GPIO_Pin_10 | + GPIO_Pin_11 | GPIO_Pin_12; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; + GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; + GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; + GPIO_Init(GPIOG, &GPIO_InitStructure); +} + +/** + * @brief Initializes the LCD. + * @param None + * @retval None + */ +void LCD_Init(void) +{ + LTDC_InitTypeDef LTDC_InitStruct; + + /* Configure the LCD Control pins ------------------------------------------*/ + LCD_CtrlLinesConfig(); + LCD_ChipSelect(DISABLE); + LCD_ChipSelect(ENABLE); + + /* Configure the LCD_SPI interface -----------------------------------------*/ + LCD_SPIConfig(); + + /* Power on the LCD --------------------------------------------------------*/ + LCD_PowerOn(); + + /* Enable the LTDC Clock */ + RCC_APB2PeriphClockCmd(RCC_APB2Periph_LTDC, ENABLE); + + /* Enable the DMA2D Clock */ + RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA2D, ENABLE); + + /* Configure the LCD Control pins */ + LCD_AF_GPIOConfig(); + + /* Configure the FMC Parallel interface : SDRAM is used as Frame Buffer for LCD */ + SDRAM_Init(); + + /* LTDC Configuration *********************************************************/ + /* Polarity configuration */ + /* Initialize the horizontal synchronization polarity as active low */ + LTDC_InitStruct.LTDC_HSPolarity = LTDC_HSPolarity_AL; + /* Initialize the vertical synchronization polarity as active low */ + LTDC_InitStruct.LTDC_VSPolarity = LTDC_VSPolarity_AL; + /* Initialize the data enable polarity as active low */ + LTDC_InitStruct.LTDC_DEPolarity = LTDC_DEPolarity_AL; + /* Initialize the pixel clock polarity as input pixel clock */ + LTDC_InitStruct.LTDC_PCPolarity = LTDC_PCPolarity_IPC; + + /* Configure R,G,B component values for LCD background color */ + LTDC_InitStruct.LTDC_BackgroundRedValue = 0; + LTDC_InitStruct.LTDC_BackgroundGreenValue = 0; + LTDC_InitStruct.LTDC_BackgroundBlueValue = 0; + + /* Configure PLLSAI prescalers for LCD */ + /* Enable Pixel Clock */ + /* PLLSAI_VCO Input = HSE_VALUE/PLL_M = 1 Mhz */ + /* PLLSAI_VCO Output = PLLSAI_VCO Input * PLLSAI_N = 192 Mhz */ + /* PLLLCDCLK = PLLSAI_VCO Output/PLLSAI_R = 192/4 = 48 Mhz */ + /* LTDC clock frequency = PLLLCDCLK / RCC_PLLSAIDivR = 48/8 = 6 Mhz */ + RCC_PLLSAIConfig(192, 7, 4); + RCC_LTDCCLKDivConfig(RCC_PLLSAIDivR_Div8); + + /* Enable PLLSAI Clock */ + RCC_PLLSAICmd(ENABLE); + /* Wait for PLLSAI activation */ + while(RCC_GetFlagStatus(RCC_FLAG_PLLSAIRDY) == RESET) + { + } + + /* Timing configuration */ + /* Configure horizontal synchronization width */ + LTDC_InitStruct.LTDC_HorizontalSync = 9; + /* Configure vertical synchronization height */ + LTDC_InitStruct.LTDC_VerticalSync = 1; + /* Configure accumulated horizontal back porch */ + LTDC_InitStruct.LTDC_AccumulatedHBP = 29; + /* Configure accumulated vertical back porch */ + LTDC_InitStruct.LTDC_AccumulatedVBP = 3; + /* Configure accumulated active width */ + LTDC_InitStruct.LTDC_AccumulatedActiveW = 269; + /* Configure accumulated active height */ + LTDC_InitStruct.LTDC_AccumulatedActiveH = 323; + /* Configure total width */ + LTDC_InitStruct.LTDC_TotalWidth = 279; + /* Configure total height */ + LTDC_InitStruct.LTDC_TotalHeigh = 327; + + LTDC_Init(<DC_InitStruct); +} + +/** + * @brief Initializes the LCD Layers. + * @param None + * @retval None + */ +void LCD_LayerInit(void) +{ + LTDC_Layer_InitTypeDef LTDC_Layer_InitStruct; + + /* Windowing configuration */ + /* In this case all the active display area is used to display a picture then : + Horizontal start = horizontal synchronization + Horizontal back porch = 30 + Horizontal stop = Horizontal start + window width -1 = 30 + 240 -1 + Vertical start = vertical synchronization + vertical back porch = 4 + Vertical stop = Vertical start + window height -1 = 4 + 320 -1 */ + LTDC_Layer_InitStruct.LTDC_HorizontalStart = 30; + LTDC_Layer_InitStruct.LTDC_HorizontalStop = (LCD_PIXEL_WIDTH + 30 - 1); + LTDC_Layer_InitStruct.LTDC_VerticalStart = 4; + LTDC_Layer_InitStruct.LTDC_VerticalStop = (LCD_PIXEL_HEIGHT + 4 - 1); + + /* Pixel Format configuration*/ + LTDC_Layer_InitStruct.LTDC_PixelFormat = LTDC_Pixelformat_RGB565; + /* Alpha constant (255 totally opaque) */ + LTDC_Layer_InitStruct.LTDC_ConstantAlpha = 255; + /* Default Color configuration (configure A,R,G,B component values) */ + LTDC_Layer_InitStruct.LTDC_DefaultColorBlue = 0; + LTDC_Layer_InitStruct.LTDC_DefaultColorGreen = 0; + LTDC_Layer_InitStruct.LTDC_DefaultColorRed = 0; + LTDC_Layer_InitStruct.LTDC_DefaultColorAlpha = 0; + /* Configure blending factors */ + LTDC_Layer_InitStruct.LTDC_BlendingFactor_1 = LTDC_BlendingFactor1_CA; + LTDC_Layer_InitStruct.LTDC_BlendingFactor_2 = LTDC_BlendingFactor2_CA; + + /* the length of one line of pixels in bytes + 3 then : + Line Lenth = Active high width x number of bytes per pixel + 3 + Active high width = LCD_PIXEL_WIDTH + number of bytes per pixel = 2 (pixel_format : RGB565) + */ + LTDC_Layer_InitStruct.LTDC_CFBLineLength = ((LCD_PIXEL_WIDTH * 2) + 3); + /* the pitch is the increment from the start of one line of pixels to the + start of the next line in bytes, then : + Pitch = Active high width x number of bytes per pixel */ + LTDC_Layer_InitStruct.LTDC_CFBPitch = (LCD_PIXEL_WIDTH * 2); + + /* Configure the number of lines */ + LTDC_Layer_InitStruct.LTDC_CFBLineNumber = LCD_PIXEL_HEIGHT; + + /* Start Address configuration : the LCD Frame buffer is defined on SDRAM */ + LTDC_Layer_InitStruct.LTDC_CFBStartAdress = LCD_FRAME_BUFFER; + + /* Initialize LTDC layer 1 */ + LTDC_LayerInit(LTDC_Layer1, <DC_Layer_InitStruct); + + /* Configure Layer2 */ + /* Start Address configuration : the LCD Frame buffer is defined on SDRAM w/ Offset */ + LTDC_Layer_InitStruct.LTDC_CFBStartAdress = LCD_FRAME_BUFFER + BUFFER_OFFSET; + + /* Configure blending factors */ + LTDC_Layer_InitStruct.LTDC_BlendingFactor_1 = LTDC_BlendingFactor1_PAxCA; + LTDC_Layer_InitStruct.LTDC_BlendingFactor_2 = LTDC_BlendingFactor2_PAxCA; + + /* Initialize LTDC layer 2 */ + LTDC_LayerInit(LTDC_Layer2, <DC_Layer_InitStruct); + + /* LTDC configuration reload */ + LTDC_ReloadConfig(LTDC_IMReload); + + /* Enable foreground & background Layers */ + LTDC_LayerCmd(LTDC_Layer1, ENABLE); + LTDC_LayerCmd(LTDC_Layer2, ENABLE); + + /* LTDC configuration reload */ + LTDC_ReloadConfig(LTDC_IMReload); + + /* Set default font */ + LCD_SetFont(&LCD_DEFAULT_FONT); + + /* dithering activation */ + LTDC_DitherCmd(ENABLE); +} + +/** + * @brief Controls LCD Chip Select (CS) pin + * @param NewState CS pin state + * @retval None + */ +void LCD_ChipSelect(FunctionalState NewState) +{ + if (NewState == DISABLE) + { + GPIO_ResetBits(LCD_NCS_GPIO_PORT, LCD_NCS_PIN); /* CS pin low: LCD disabled */ + } + else + { + GPIO_SetBits(LCD_NCS_GPIO_PORT, LCD_NCS_PIN); /* CS pin high: LCD enabled */ + } +} + +/** + * @brief Sets the LCD Layer. + * @param Layerx: specifies the Layer foreground or background. + * @retval None + */ +void LCD_SetLayer(uint32_t Layerx) +{ + if (Layerx == LCD_BACKGROUND_LAYER) + { + CurrentFrameBuffer = LCD_FRAME_BUFFER; + CurrentLayer = LCD_BACKGROUND_LAYER; + } + else + { + CurrentFrameBuffer = LCD_FRAME_BUFFER + BUFFER_OFFSET; + CurrentLayer = LCD_FOREGROUND_LAYER; + } +} + +/** + * @brief Sets the LCD Text and Background colors. + * @param TextColor: specifies the Text Color. + * @param BackColor: specifies the Background Color. + * @retval None + */ +void LCD_SetColors(uint16_t TextColor, uint16_t BackColor) +{ + CurrentTextColor = TextColor; + CurrentBackColor = BackColor; +} + +/** + * @brief Gets the LCD Text and Background colors. + * @param TextColor: pointer to the variable that will contain the Text + Color. + * @param BackColor: pointer to the variable that will contain the Background + Color. + * @retval None + */ +void LCD_GetColors(uint16_t *TextColor, uint16_t *BackColor) +{ + *TextColor = CurrentTextColor; + *BackColor = CurrentBackColor; +} + +/** + * @brief Sets the Text color. + * @param Color: specifies the Text color code RGB(5-6-5). + * @retval None + */ +void LCD_SetTextColor(uint16_t Color) +{ + CurrentTextColor = Color; +} + +/** + * @brief Sets the Background color. + * @param Color: specifies the Background color code RGB(5-6-5). + * @retval None + */ +void LCD_SetBackColor(uint16_t Color) +{ + CurrentBackColor = Color; +} + +/** + * @brief Sets the Text Font. + * @param fonts: specifies the font to be used. + * @retval None + */ +void LCD_SetFont(sFONT *fonts) +{ + LCD_Currentfonts = fonts; +} + +/** + * @brief Configure the transparency. + * @param transparency: specifies the transparency, + * This parameter must range from 0x00 to 0xFF. + * @retval None + */ +void LCD_SetTransparency(uint8_t transparency) +{ + if (CurrentLayer == LCD_BACKGROUND_LAYER) + { + LTDC_LayerAlpha(LTDC_Layer1, transparency); + } + else + { + LTDC_LayerAlpha(LTDC_Layer2, transparency); + } + LTDC_ReloadConfig(LTDC_IMReload); +} + +/** + * @brief Gets the Text Font. + * @param None. + * @retval the used font. + */ +sFONT *LCD_GetFont(void) +{ + return LCD_Currentfonts; +} + +/** + * @brief Clears the selected line. + * @param Line: the Line to be cleared. + * This parameter can be one of the following values: + * @arg LCD_LINE_x: where x can be: 0..13 if LCD_Currentfonts is Font16x24 + * 0..26 if LCD_Currentfonts is Font12x12 or Font8x12 + * 0..39 if LCD_Currentfonts is Font8x8 + * @retval None + */ +void LCD_ClearLine(uint16_t Line) +{ + uint16_t refcolumn = 0; + /* Send the string character by character on lCD */ + while ((refcolumn < LCD_PIXEL_WIDTH) && (((refcolumn + LCD_Currentfonts->Width)& 0xFFFF) >= LCD_Currentfonts->Width)) + { + /* Display one character on LCD */ + LCD_DisplayChar(Line, refcolumn, ' '); + /* Decrement the column position by 16 */ + refcolumn += LCD_Currentfonts->Width; + } +} + +/** + * @brief Clears the hole LCD. + * @param Color: the color of the background. + * @retval None + */ +void LCD_Clear(uint16_t Color) +{ + uint32_t index = 0; + + /* erase memory */ + for (index = 0x00; index < BUFFER_OFFSET; index++) + { + *(__IO uint16_t*)(CurrentFrameBuffer + (2*index)) = Color; + } +} + +/** + * @brief Sets the cursor position. + * @param Xpos: specifies the X position. + * @param Ypos: specifies the Y position. + * @retval Display Address + */ +uint32_t LCD_SetCursor(uint16_t Xpos, uint16_t Ypos) +{ + return CurrentFrameBuffer + 2*(Xpos + (LCD_PIXEL_WIDTH*Ypos)); +} + +/** + * @brief Config and Sets the color Keying. + * @param RGBValue: Specifies the Color reference. + * @retval None + */ +void LCD_SetColorKeying(uint32_t RGBValue) +{ + LTDC_ColorKeying_InitTypeDef LTDC_colorkeying_InitStruct; + + /* configure the color Keying */ + LTDC_colorkeying_InitStruct.LTDC_ColorKeyBlue = 0x0000FF & RGBValue; + LTDC_colorkeying_InitStruct.LTDC_ColorKeyGreen = (0x00FF00 & RGBValue) >> 8; + LTDC_colorkeying_InitStruct.LTDC_ColorKeyRed = (0xFF0000 & RGBValue) >> 16; + + if (CurrentLayer == LCD_BACKGROUND_LAYER) + { + /* Enable the color Keying for Layer1 */ + LTDC_ColorKeyingConfig(LTDC_Layer1, <DC_colorkeying_InitStruct, ENABLE); + LTDC_ReloadConfig(LTDC_IMReload); + } + else + { + /* Enable the color Keying for Layer2 */ + LTDC_ColorKeyingConfig(LTDC_Layer2, <DC_colorkeying_InitStruct, ENABLE); + LTDC_ReloadConfig(LTDC_IMReload); + } +} + +/** + * @brief Disable the color Keying. + * @param RGBValue: Specifies the Color reference. + * @retval None + */ +void LCD_ReSetColorKeying(void) +{ + LTDC_ColorKeying_InitTypeDef LTDC_colorkeying_InitStruct; + + if (CurrentLayer == LCD_BACKGROUND_LAYER) + { + /* Disable the color Keying for Layer1 */ + LTDC_ColorKeyingConfig(LTDC_Layer1, <DC_colorkeying_InitStruct, DISABLE); + LTDC_ReloadConfig(LTDC_IMReload); + } + else + { + /* Disable the color Keying for Layer2 */ + LTDC_ColorKeyingConfig(LTDC_Layer2, <DC_colorkeying_InitStruct, DISABLE); + LTDC_ReloadConfig(LTDC_IMReload); + } +} + +/** + * @brief Draws a character on LCD. + * @param Xpos: the Line where to display the character shape. + * @param Ypos: start column address. + * @param c: pointer to the character data. + * @retval None + */ +void LCD_DrawChar(uint16_t Xpos, uint16_t Ypos, const uint16_t *c) +{ + uint32_t index = 0, counter = 0, xpos =0; + uint32_t Xaddress = 0; + + xpos = Xpos*LCD_PIXEL_WIDTH*2; + Xaddress += Ypos; + + for(index = 0; index < LCD_Currentfonts->Height; index++) + { + + for(counter = 0; counter < LCD_Currentfonts->Width; counter++) + { + + if((((c[index] & ((0x80 << ((LCD_Currentfonts->Width / 12 ) * 8 ) ) >> counter)) == 0x00) &&(LCD_Currentfonts->Width <= 12))|| + (((c[index] & (0x1 << counter)) == 0x00)&&(LCD_Currentfonts->Width > 12 ))) + { + /* Write data value to all SDRAM memory */ + *(__IO uint16_t*) (CurrentFrameBuffer + (2*Xaddress) + xpos) = CurrentBackColor; + } + else + { + /* Write data value to all SDRAM memory */ + *(__IO uint16_t*) (CurrentFrameBuffer + (2*Xaddress) + xpos) = CurrentTextColor; + } + Xaddress++; + } + Xaddress += (LCD_PIXEL_WIDTH - LCD_Currentfonts->Width); + } +} + +/** + * @brief Displays one character (16dots width, 24dots height). + * @param Line: the Line where to display the character shape . + * This parameter can be one of the following values: + * @arg Linex: where x can be 0..29 + * @param Column: start column address. + * @param Ascii: character ascii code, must be between 0x20 and 0x7E. + * @retval None + */ +void LCD_DisplayChar(uint16_t Line, uint16_t Column, uint8_t Ascii) +{ + Ascii -= 32; + + LCD_DrawChar(Line, Column, &LCD_Currentfonts->table[Ascii * LCD_Currentfonts->Height]); +} + +/** + * @brief Displays a maximum of 20 char on the LCD. + * @param Line: the Line where to display the character shape . + * This parameter can be one of the following values: + * @arg Linex: where x can be 0..9 + * @param *ptr: pointer to string to display on LCD. + * @retval None + */ +void LCD_DisplayStringLine(uint16_t Line, uint8_t *ptr) +{ + uint16_t refcolumn = 0; + /* Send the string character by character on lCD */ + while ((refcolumn < LCD_PIXEL_WIDTH) && ((*ptr != 0) & (((refcolumn + LCD_Currentfonts->Width) & 0xFFFF) >= LCD_Currentfonts->Width))) + { + /* Display one character on LCD */ + LCD_DisplayChar(Line, refcolumn, *ptr); + /* Decrement the column position by width */ + refcolumn += LCD_Currentfonts->Width; + /* Point on the next character */ + ptr++; + } +} + +/** + * @brief Sets a display window + * @param Xpos: specifies the X bottom left position from 0 to 240. + * @param Ypos: specifies the Y bottom left position from 0 to 320. + * @param Height: display window height, can be a value from 0 to 320. + * @param Width: display window width, can be a value from 0 to 240. + * @retval None + */ +void LCD_SetDisplayWindow(uint16_t Xpos, uint16_t Ypos, uint16_t Height, uint16_t Width) +{ + + if (CurrentLayer == LCD_BACKGROUND_LAYER) + { + /* reconfigure the layer1 position */ + LTDC_LayerPosition(LTDC_Layer1, Xpos, Ypos); + LTDC_ReloadConfig(LTDC_IMReload); + + /* reconfigure the layer1 size */ + LTDC_LayerSize(LTDC_Layer1, Width, Height); + LTDC_ReloadConfig(LTDC_IMReload); + } + else + { + /* reconfigure the layer2 position */ + LTDC_LayerPosition(LTDC_Layer2, Xpos, Ypos); + LTDC_ReloadConfig(LTDC_IMReload); + + /* reconfigure the layer2 size */ + LTDC_LayerSize(LTDC_Layer2, Width, Height); + LTDC_ReloadConfig(LTDC_IMReload); + } +} + +/** + * @brief Disables LCD Window mode. + * @param None + * @retval None + */ +void LCD_WindowModeDisable(void) +{ + LCD_SetDisplayWindow(0, 0, LCD_PIXEL_HEIGHT, LCD_PIXEL_WIDTH); +} + +/** + * @brief Displays a line. + * @param Xpos: specifies the X position, can be a value from 0 to 240. + * @param Ypos: specifies the Y position, can be a value from 0 to 320. + * @param Length: line length. + * @param Direction: line direction. + * This parameter can be one of the following values: LCD_DIR_HORIZONTAL or LCD_DIR_VERTICAL. + * @retval None + */ +void LCD_DrawLine(uint16_t Xpos, uint16_t Ypos, uint16_t Length, uint8_t Direction) +{ + DMA2D_InitTypeDef DMA2D_InitStruct; + + uint32_t Xaddress = 0; + uint16_t Red_Value = 0, Green_Value = 0, Blue_Value = 0; + + Xaddress = CurrentFrameBuffer + 2*(LCD_PIXEL_WIDTH*Ypos + Xpos); + + Red_Value = (0xF800 & CurrentTextColor) >> 11; + Blue_Value = 0x001F & CurrentTextColor; + Green_Value = (0x07E0 & CurrentTextColor) >> 5; + + /* Configure DMA2D */ + DMA2D_DeInit(); + DMA2D_InitStruct.DMA2D_Mode = DMA2D_R2M; + DMA2D_InitStruct.DMA2D_CMode = DMA2D_RGB565; + DMA2D_InitStruct.DMA2D_OutputGreen = Green_Value; + DMA2D_InitStruct.DMA2D_OutputBlue = Blue_Value; + DMA2D_InitStruct.DMA2D_OutputRed = Red_Value; + DMA2D_InitStruct.DMA2D_OutputAlpha = 0x0F; + DMA2D_InitStruct.DMA2D_OutputMemoryAdd = Xaddress; + + 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; + } + + DMA2D_Init(&DMA2D_InitStruct); + /* Start Transfer */ + DMA2D_StartTransfer(); + /* Wait for CTC Flag activation */ + while(DMA2D_GetFlagStatus(DMA2D_FLAG_TC) == RESET) + { + } + +} + +/** + * @brief Displays a rectangle. + * @param Xpos: specifies the X position, can be a value from 0 to 240. + * @param Ypos: specifies the Y position, can be a value from 0 to 320. + * @param Height: display rectangle height, can be a value from 0 to 320. + * @param Width: display rectangle width, can be a value from 0 to 240. + * @retval None + */ +void LCD_DrawRect(uint16_t Xpos, uint16_t Ypos, uint16_t Height, uint16_t Width) +{ + /* draw horizontal lines */ + LCD_DrawLine(Xpos, Ypos, Width, LCD_DIR_HORIZONTAL); + LCD_DrawLine(Xpos, (Ypos+ Height), Width, LCD_DIR_HORIZONTAL); + + /* draw vertical lines */ + LCD_DrawLine(Xpos, Ypos, Height, LCD_DIR_VERTICAL); + LCD_DrawLine((Xpos + Width), Ypos, Height, LCD_DIR_VERTICAL); +} + +/** + * @brief Draw a circle. + * @param Xpos: specifies the X position, can be a value from 0 to 240. + * @param Ypos: specifies the Y position, can be a value from 0 to 320. + * @param Radius: radius of the circle. + * @retval None + */ +void LCD_DrawCircle(uint16_t Xpos, uint16_t Ypos, uint16_t Radius) +{ + int x = -Radius, y = 0, err = 2-2*Radius, e2; + do { + *(__IO uint16_t*) (CurrentFrameBuffer + (2*((Xpos-x) + LCD_PIXEL_WIDTH*(Ypos+y)))) = CurrentTextColor; + *(__IO uint16_t*) (CurrentFrameBuffer + (2*((Xpos+x) + LCD_PIXEL_WIDTH*(Ypos+y)))) = CurrentTextColor; + *(__IO uint16_t*) (CurrentFrameBuffer + (2*((Xpos+x) + LCD_PIXEL_WIDTH*(Ypos-y)))) = CurrentTextColor; + *(__IO uint16_t*) (CurrentFrameBuffer + (2*((Xpos-x) + LCD_PIXEL_WIDTH*(Ypos-y)))) = CurrentTextColor; + + e2 = err; + if (e2 <= y) { + err += ++y*2+1; + if (-x == y && e2 <= x) e2 = 0; + } + if (e2 > x) err += ++x*2+1; + } + while (x <= 0); +} + +/** + * @brief Draw a full ellipse. + * @param Xpos: specifies the X position, can be a value from 0 to 240. + * @param Ypos: specifies the Y position, can be a value from 0 to 320. + * @param Radius: minor radius of ellipse. + * @param Radius2: major radius of ellipse. + * @retval None + */ +void LCD_DrawFullEllipse(int Xpos, int Ypos, int Radius, int Radius2) +{ + int x = -Radius, y = 0, err = 2-2*Radius, e2; + float K = 0, rad1 = 0, rad2 = 0; + + rad1 = Radius; + rad2 = Radius2; + + if (Radius > Radius2) + { + do + { + K = (float)(rad1/rad2); + LCD_DrawLine((Xpos+x), (Ypos-(uint16_t)(y/K)), (2*(uint16_t)(y/K) + 1), LCD_DIR_VERTICAL); + LCD_DrawLine((Xpos-x), (Ypos-(uint16_t)(y/K)), (2*(uint16_t)(y/K) + 1), LCD_DIR_VERTICAL); + + e2 = err; + if (e2 <= y) + { + err += ++y*2+1; + if (-x == y && e2 <= x) e2 = 0; + } + if (e2 > x) err += ++x*2+1; + + } + while (x <= 0); + } + else + { + y = -Radius2; + x = 0; + do + { + K = (float)(rad2/rad1); + LCD_DrawLine((Xpos-(uint16_t)(x/K)), (Ypos+y), (2*(uint16_t)(x/K) + 1), LCD_DIR_HORIZONTAL); + LCD_DrawLine((Xpos-(uint16_t)(x/K)), (Ypos-y), (2*(uint16_t)(x/K) + 1), LCD_DIR_HORIZONTAL); + + e2 = err; + if (e2 <= x) + { + err += ++x*2+1; + if (-y == x && e2 <= y) e2 = 0; + } + if (e2 > y) err += ++y*2+1; + } + while (y <= 0); + } +} + +/** + * @brief Displays an Ellipse. + * @param Xpos: specifies the X position, can be a value from 0 to 240. + * @param Ypos: specifies the Y position, can be a value from 0 to 320. + * @param Radius: specifies Radius. + * @param Radius2: specifies Radius2. + * @retval None + */ +void LCD_DrawEllipse(int Xpos, int Ypos, int Radius, int Radius2) +{ + int x = -Radius, y = 0, err = 2-2*Radius, e2; + float K = 0, rad1 = 0, rad2 = 0; + + rad1 = Radius; + rad2 = Radius2; + + if (Radius > Radius2) + { + do { + K = (float)(rad1/rad2); + *(__IO uint16_t*) (CurrentFrameBuffer + (2*((Xpos-x) + LCD_PIXEL_WIDTH*(Ypos+(uint16_t)(y/K))))) = CurrentTextColor; + *(__IO uint16_t*) (CurrentFrameBuffer + (2*((Xpos+x) + LCD_PIXEL_WIDTH*(Ypos+(uint16_t)(y/K))))) = CurrentTextColor; + *(__IO uint16_t*) (CurrentFrameBuffer + (2*((Xpos+x) + LCD_PIXEL_WIDTH*(Ypos-(uint16_t)(y/K))))) = CurrentTextColor; + *(__IO uint16_t*) (CurrentFrameBuffer + (2*((Xpos-x) + LCD_PIXEL_WIDTH*(Ypos-(uint16_t)(y/K))))) = CurrentTextColor; + + e2 = err; + if (e2 <= y) { + err += ++y*2+1; + if (-x == y && e2 <= x) e2 = 0; + } + if (e2 > x) err += ++x*2+1; + } + while (x <= 0); + } + else + { + y = -Radius2; + x = 0; + do { + K = (float)(rad2/rad1); + *(__IO uint16_t*) (CurrentFrameBuffer + (2*((Xpos-(uint16_t)(x/K)) + LCD_PIXEL_WIDTH*(Ypos+y)))) = CurrentTextColor; + *(__IO uint16_t*) (CurrentFrameBuffer + (2*((Xpos+(uint16_t)(x/K)) + LCD_PIXEL_WIDTH*(Ypos+y)))) = CurrentTextColor; + *(__IO uint16_t*) (CurrentFrameBuffer + (2*((Xpos+(uint16_t)(x/K)) + LCD_PIXEL_WIDTH*(Ypos-y)))) = CurrentTextColor; + *(__IO uint16_t*) (CurrentFrameBuffer + (2*((Xpos-(uint16_t)(x/K)) + LCD_PIXEL_WIDTH*(Ypos-y)))) = CurrentTextColor; + + e2 = err; + if (e2 <= x) { + err += ++x*2+1; + if (-y == x && e2 <= y) e2 = 0; + } + if (e2 > y) err += ++y*2+1; + } + while (y <= 0); + } +} + +/** + * @brief Displays a mono-color picture. + * @param Pict: pointer to the picture array. + * @retval None + */ +void LCD_DrawMonoPict(const uint32_t *Pict) +{ + uint32_t index = 0, counter = 0; + + + for(index = 0; index < 2400; index++) + { + for(counter = 0; counter < 32; counter++) + { + if((Pict[index] & (1 << counter)) == 0x00) + { + *(__IO uint16_t*)(CurrentFrameBuffer) = CurrentBackColor; + } + else + { + *(__IO uint16_t*)(CurrentFrameBuffer) = CurrentTextColor; + } + } + } +} + +/** + * @brief Displays a bitmap picture loaded in the internal Flash. + * @param BmpAddress: Bmp picture address in the internal Flash. + * @retval None + */ +void LCD_WriteBMP(uint32_t BmpAddress) +{ + uint32_t index = 0, size = 0, width = 0, height = 0, bit_pixel = 0; + uint32_t Address; + uint32_t currentline = 0, linenumber = 0; + + Address = CurrentFrameBuffer; + + /* Read bitmap size */ + size = *(__IO uint16_t *) (BmpAddress + 2); + size |= (*(__IO uint16_t *) (BmpAddress + 4)) << 16; + + /* Get bitmap data address offset */ + index = *(__IO uint16_t *) (BmpAddress + 10); + index |= (*(__IO uint16_t *) (BmpAddress + 12)) << 16; + + /* Read bitmap width */ + width = *(uint16_t *) (BmpAddress + 18); + width |= (*(uint16_t *) (BmpAddress + 20)) << 16; + + /* Read bitmap height */ + height = *(uint16_t *) (BmpAddress + 22); + height |= (*(uint16_t *) (BmpAddress + 24)) << 16; + + /* Read bit/pixel */ + bit_pixel = *(uint16_t *) (BmpAddress + 28); + + if (CurrentLayer == LCD_BACKGROUND_LAYER) + { + /* reconfigure layer size in accordance with the picture */ + LTDC_LayerSize(LTDC_Layer1, width, height); + LTDC_ReloadConfig(LTDC_VBReload); + + /* Reconfigure the Layer pixel format in accordance with the picture */ + if ((bit_pixel/8) == 4) + { + LTDC_LayerPixelFormat(LTDC_Layer1, LTDC_Pixelformat_ARGB8888); + LTDC_ReloadConfig(LTDC_VBReload); + } + else if ((bit_pixel/8) == 2) + { + LTDC_LayerPixelFormat(LTDC_Layer1, LTDC_Pixelformat_RGB565); + LTDC_ReloadConfig(LTDC_VBReload); + } + else + { + LTDC_LayerPixelFormat(LTDC_Layer1, LTDC_Pixelformat_RGB888); + LTDC_ReloadConfig(LTDC_VBReload); + } + } + else + { + /* reconfigure layer size in accordance with the picture */ + LTDC_LayerSize(LTDC_Layer2, width, height); + LTDC_ReloadConfig(LTDC_VBReload); + + /* Reconfigure the Layer pixel format in accordance with the picture */ + if ((bit_pixel/8) == 4) + { + LTDC_LayerPixelFormat(LTDC_Layer2, LTDC_Pixelformat_ARGB8888); + LTDC_ReloadConfig(LTDC_VBReload); + } + else if ((bit_pixel/8) == 2) + { + LTDC_LayerPixelFormat(LTDC_Layer2, LTDC_Pixelformat_RGB565); + LTDC_ReloadConfig(LTDC_VBReload); + } + else + { + LTDC_LayerPixelFormat(LTDC_Layer2, LTDC_Pixelformat_RGB888); + LTDC_ReloadConfig(LTDC_VBReload); + } + } + + /* compute the real size of the picture (without the header)) */ + size = (size - index); + + /* bypass the bitmap header */ + BmpAddress += index; + + /* start copie image from the bottom */ + Address += width*(height-1)*(bit_pixel/8); + + for(index = 0; index < size; index++) + { + *(__IO uint8_t*) (Address) = *(__IO uint8_t *)BmpAddress; + + /*jump on next byte */ + BmpAddress++; + Address++; + currentline++; + + if((currentline/(bit_pixel/8)) == width) + { + if(linenumber < height) + { + linenumber++; + Address -=(2*width*(bit_pixel/8)); + currentline = 0; + } + } + } +} + +/** + * @brief Displays a full rectangle. + * @param Xpos: specifies the X position, can be a value from 0 to 240. + * @param Ypos: specifies the Y position, can be a value from 0 to 320. + * @param Height: rectangle height. + * @param Width: rectangle width. + * @retval None + */ +void LCD_DrawFullRect(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height) +{ + DMA2D_InitTypeDef DMA2D_InitStruct; + + uint32_t Xaddress = 0; + uint16_t Red_Value = 0, Green_Value = 0, Blue_Value = 0; + + Red_Value = (0xF800 & CurrentTextColor) >> 11; + Blue_Value = 0x001F & CurrentTextColor; + Green_Value = (0x07E0 & CurrentTextColor) >> 5; + + Xaddress = CurrentFrameBuffer + 2*(LCD_PIXEL_WIDTH*Ypos + Xpos); + + /* configure DMA2D */ + DMA2D_DeInit(); + DMA2D_InitStruct.DMA2D_Mode = DMA2D_R2M; + DMA2D_InitStruct.DMA2D_CMode = DMA2D_RGB565; + DMA2D_InitStruct.DMA2D_OutputGreen = Green_Value; + DMA2D_InitStruct.DMA2D_OutputBlue = Blue_Value; + DMA2D_InitStruct.DMA2D_OutputRed = Red_Value; + DMA2D_InitStruct.DMA2D_OutputAlpha = 0x0F; + DMA2D_InitStruct.DMA2D_OutputMemoryAdd = Xaddress; + DMA2D_InitStruct.DMA2D_OutputOffset = (LCD_PIXEL_WIDTH - Width); + DMA2D_InitStruct.DMA2D_NumberOfLine = Height; + DMA2D_InitStruct.DMA2D_PixelPerLine = Width; + DMA2D_Init(&DMA2D_InitStruct); + + /* Start Transfer */ + DMA2D_StartTransfer(); + + /* Wait for CTC Flag activation */ + while(DMA2D_GetFlagStatus(DMA2D_FLAG_TC) == RESET) + { + } + + LCD_SetTextColor(CurrentTextColor); +} + +/** + * @brief Displays a full circle. + * @param Xpos: specifies the X position, can be a value from 0 to 240. + * @param Ypos: specifies the Y position, can be a value from 0 to 320. + * @param Radius + * @retval None + */ +void LCD_DrawFullCircle(uint16_t Xpos, uint16_t Ypos, uint16_t Radius) +{ + int32_t D; /* Decision Variable */ + uint32_t CurX;/* Current X Value */ + uint32_t CurY;/* Current Y Value */ + + D = 3 - (Radius << 1); + + CurX = 0; + CurY = Radius; + + while (CurX <= CurY) + { + if(CurY > 0) + { + LCD_DrawLine(Xpos - CurX, Ypos - CurY, 2*CurY, LCD_DIR_VERTICAL); + LCD_DrawLine(Xpos + CurX, Ypos - CurY, 2*CurY, LCD_DIR_VERTICAL); + } + + if(CurX > 0) + { + LCD_DrawLine(Xpos - CurY, Ypos - CurX, 2*CurX, LCD_DIR_VERTICAL); + LCD_DrawLine(Xpos + CurY, Ypos - CurX, 2*CurX, LCD_DIR_VERTICAL); + } + if (D < 0) + { + D += (CurX << 2) + 6; + } + else + { + D += ((CurX - CurY) << 2) + 10; + CurY--; + } + CurX++; + } + + LCD_DrawCircle(Xpos, Ypos, Radius); +} + +/** + * @brief Displays an uni-line (between two points). + * @param x1: specifies the point 1 x position. + * @param y1: specifies the point 1 y position. + * @param x2: specifies the point 2 x position. + * @param y2: specifies the point 2 y position. + * @retval None + */ +void LCD_DrawUniLine(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2) +{ + int16_t deltax = 0, deltay = 0, x = 0, y = 0, xinc1 = 0, xinc2 = 0, + yinc1 = 0, yinc2 = 0, den = 0, num = 0, numadd = 0, numpixels = 0, + curpixel = 0; + + deltax = ABS(x2 - x1); /* The difference between the x's */ + deltay = ABS(y2 - y1); /* The difference between the y's */ + x = x1; /* Start x off at the first pixel */ + y = y1; /* Start y off at the first pixel */ + + if (x2 >= x1) /* The x-values are increasing */ + { + xinc1 = 1; + xinc2 = 1; + } + else /* The x-values are decreasing */ + { + xinc1 = -1; + xinc2 = -1; + } + + if (y2 >= y1) /* The y-values are increasing */ + { + yinc1 = 1; + yinc2 = 1; + } + else /* The y-values are decreasing */ + { + yinc1 = -1; + yinc2 = -1; + } + + if (deltax >= deltay) /* There is at least one x-value for every y-value */ + { + xinc1 = 0; /* Don't change the x when numerator >= denominator */ + yinc2 = 0; /* Don't change the y for every iteration */ + den = deltax; + num = deltax / 2; + numadd = deltay; + numpixels = deltax; /* There are more x-values than y-values */ + } + else /* There is at least one y-value for every x-value */ + { + xinc2 = 0; /* Don't change the x for every iteration */ + yinc1 = 0; /* Don't change the y when numerator >= denominator */ + den = deltay; + num = deltay / 2; + numadd = deltax; + numpixels = deltay; /* There are more y-values than x-values */ + } + + for (curpixel = 0; curpixel <= numpixels; curpixel++) + { + PutPixel(x, y); /* Draw the current pixel */ + num += numadd; /* Increase the numerator by the top of the fraction */ + if (num >= den) /* Check if numerator >= denominator */ + { + num -= den; /* Calculate the new numerator value */ + x += xinc1; /* Change the x as appropriate */ + y += yinc1; /* Change the y as appropriate */ + } + x += xinc2; /* Change the x as appropriate */ + y += yinc2; /* Change the y as appropriate */ + } +} + +/** + * @brief Displays an triangle. + * @param Points: pointer to the points array. + * @retval None + */ +void LCD_Triangle(pPoint Points, uint16_t PointCount) +{ + int16_t X = 0, Y = 0; + pPoint First = Points; + + if(PointCount != 3) + { + return; + } + + while(--PointCount) + { + X = Points->X; + Y = Points->Y; + Points++; + LCD_DrawUniLine(X, Y, Points->X, Points->Y); + } + LCD_DrawUniLine(First->X, First->Y, Points->X, Points->Y); +} + +/** + * @brief Fill an triangle (between 3 points). + * @param x1..3: x position of triangle point 1..3. + * @param y1..3: y position of triangle point 1..3. + * @retval None + */ +void LCD_FillTriangle(uint16_t x1, uint16_t x2, uint16_t x3, uint16_t y1, uint16_t y2, uint16_t y3) +{ + + int16_t deltax = 0, deltay = 0, x = 0, y = 0, xinc1 = 0, xinc2 = 0, + yinc1 = 0, yinc2 = 0, den = 0, num = 0, numadd = 0, numpixels = 0, + curpixel = 0; + + deltax = ABS(x2 - x1); /* The difference between the x's */ + deltay = ABS(y2 - y1); /* The difference between the y's */ + x = x1; /* Start x off at the first pixel */ + y = y1; /* Start y off at the first pixel */ + + if (x2 >= x1) /* The x-values are increasing */ + { + xinc1 = 1; + xinc2 = 1; + } + else /* The x-values are decreasing */ + { + xinc1 = -1; + xinc2 = -1; + } + + if (y2 >= y1) /* The y-values are increasing */ + { + yinc1 = 1; + yinc2 = 1; + } + else /* The y-values are decreasing */ + { + yinc1 = -1; + yinc2 = -1; + } + + if (deltax >= deltay) /* There is at least one x-value for every y-value */ + { + xinc1 = 0; /* Don't change the x when numerator >= denominator */ + yinc2 = 0; /* Don't change the y for every iteration */ + den = deltax; + num = deltax / 2; + numadd = deltay; + numpixels = deltax; /* There are more x-values than y-values */ + } + else /* There is at least one y-value for every x-value */ + { + xinc2 = 0; /* Don't change the x for every iteration */ + yinc1 = 0; /* Don't change the y when numerator >= denominator */ + den = deltay; + num = deltay / 2; + numadd = deltax; + numpixels = deltay; /* There are more y-values than x-values */ + } + + for (curpixel = 0; curpixel <= numpixels; curpixel++) + { + LCD_DrawUniLine(x, y, x3, y3); + + num += numadd; /* Increase the numerator by the top of the fraction */ + if (num >= den) /* Check if numerator >= denominator */ + { + num -= den; /* Calculate the new numerator value */ + x += xinc1; /* Change the x as appropriate */ + y += yinc1; /* Change the y as appropriate */ + } + x += xinc2; /* Change the x as appropriate */ + y += yinc2; /* Change the y as appropriate */ + } + + +} +/** + * @brief Displays an poly-line (between many points). + * @param Points: pointer to the points array. + * @param PointCount: Number of points. + * @retval None + */ +void LCD_PolyLine(pPoint Points, uint16_t PointCount) +{ + int16_t X = 0, Y = 0; + + if(PointCount < 2) + { + return; + } + + while(--PointCount) + { + X = Points->X; + Y = Points->Y; + Points++; + LCD_DrawUniLine(X, Y, Points->X, Points->Y); + } +} + +/** + * @brief Displays an relative poly-line (between many points). + * @param Points: pointer to the points array. + * @param PointCount: Number of points. + * @param Closed: specifies if the draw is closed or not. + * 1: closed, 0 : not closed. + * @retval None + */ +static void LCD_PolyLineRelativeClosed(pPoint Points, uint16_t PointCount, uint16_t Closed) +{ + int16_t X = 0, Y = 0; + pPoint First = Points; + + if(PointCount < 2) + { + return; + } + X = Points->X; + Y = Points->Y; + while(--PointCount) + { + Points++; + LCD_DrawUniLine(X, Y, X + Points->X, Y + Points->Y); + X = X + Points->X; + Y = Y + Points->Y; + } + if(Closed) + { + LCD_DrawUniLine(First->X, First->Y, X, Y); + } +} + +/** + * @brief Displays a closed poly-line (between many points). + * @param Points: pointer to the points array. + * @param PointCount: Number of points. + * @retval None + */ +void LCD_ClosedPolyLine(pPoint Points, uint16_t PointCount) +{ + LCD_PolyLine(Points, PointCount); + LCD_DrawUniLine(Points->X, Points->Y, (Points+PointCount-1)->X, (Points+PointCount-1)->Y); +} + +/** + * @brief Displays a relative poly-line (between many points). + * @param Points: pointer to the points array. + * @param PointCount: Number of points. + * @retval None + */ +void LCD_PolyLineRelative(pPoint Points, uint16_t PointCount) +{ + LCD_PolyLineRelativeClosed(Points, PointCount, 0); +} + +/** + * @brief Displays a closed relative poly-line (between many points). + * @param Points: pointer to the points array. + * @param PointCount: Number of points. + * @retval None + */ +void LCD_ClosedPolyLineRelative(pPoint Points, uint16_t PointCount) +{ + LCD_PolyLineRelativeClosed(Points, PointCount, 1); +} + +/** + * @brief Displays a full poly-line (between many points). + * @param Points: pointer to the points array. + * @param PointCount: Number of points. + * @retval None + */ +void LCD_FillPolyLine(pPoint Points, uint16_t PointCount) +{ + + int16_t X = 0, Y = 0, X2 = 0, Y2 = 0, X_center = 0, Y_center = 0, X_first = 0, Y_first = 0, pixelX = 0, pixelY = 0, counter = 0; + uint16_t IMAGE_LEFT = 0, IMAGE_RIGHT = 0, IMAGE_TOP = 0, IMAGE_BOTTOM = 0; + + IMAGE_LEFT = IMAGE_RIGHT = Points->X; + IMAGE_TOP= IMAGE_BOTTOM = Points->Y; + + for(counter = 1; counter < PointCount; counter++) + { + pixelX = POLY_X(counter); + if(pixelX < IMAGE_LEFT) + { + IMAGE_LEFT = pixelX; + } + if(pixelX > IMAGE_RIGHT) + { + IMAGE_RIGHT = pixelX; + } + + pixelY = POLY_Y(counter); + if(pixelY < IMAGE_TOP) + { + IMAGE_TOP = pixelY; + } + if(pixelY > IMAGE_BOTTOM) + { + IMAGE_BOTTOM = pixelY; + } + } + + if(PointCount < 2) + { + return; + } + + X_center = (IMAGE_LEFT + IMAGE_RIGHT)/2; + Y_center = (IMAGE_BOTTOM + IMAGE_TOP)/2; + + X_first = Points->X; + Y_first = Points->Y; + + while(--PointCount) + { + X = Points->X; + Y = Points->Y; + Points++; + X2 = Points->X; + Y2 = Points->Y; + + LCD_FillTriangle(X, X2, X_center, Y, Y2, Y_center); + LCD_FillTriangle(X, X_center, X2, Y, Y_center, Y2); + LCD_FillTriangle(X_center, X2, X, Y_center, Y2, Y); + } + + LCD_FillTriangle(X_first, X2, X_center, Y_first, Y2, Y_center); + LCD_FillTriangle(X_first, X_center, X2, Y_first, Y_center, Y2); + LCD_FillTriangle(X_center, X2, X_first, Y_center, Y2, Y_first); +} + +/** + * @brief Writes command to select the LCD register. + * @param LCD_Reg: address of the selected register. + * @retval None + */ +void LCD_WriteCommand(uint8_t LCD_Reg) +{ + /* Reset WRX to send command */ + LCD_CtrlLinesWrite(LCD_WRX_GPIO_PORT, LCD_WRX_PIN, Bit_RESET); + + /* Reset LCD control line(/CS) and Send command */ + LCD_ChipSelect(DISABLE); + SPI_I2S_SendData(LCD_SPI, LCD_Reg); + + /* Wait until a data is sent(not busy), before config /CS HIGH */ + + while(SPI_I2S_GetFlagStatus(LCD_SPI, SPI_I2S_FLAG_TXE) == RESET) ; + + while(SPI_I2S_GetFlagStatus(LCD_SPI, SPI_I2S_FLAG_BSY) != RESET); + + LCD_ChipSelect(ENABLE); +} + +/** + * @brief Writes data to select the LCD register. + * This function must be used after LCD_WriteCommand() function + * @param value: data to write to the selected register. + * @retval None + */ +void LCD_WriteData(uint8_t value) +{ + /* Set WRX to send data */ + LCD_CtrlLinesWrite(LCD_WRX_GPIO_PORT, LCD_WRX_PIN, Bit_SET); + + /* Reset LCD control line(/CS) and Send data */ + LCD_ChipSelect(DISABLE); + SPI_I2S_SendData(LCD_SPI, value); + + /* Wait until a data is sent(not busy), before config /CS HIGH */ + + while(SPI_I2S_GetFlagStatus(LCD_SPI, SPI_I2S_FLAG_TXE) == RESET) ; + + while(SPI_I2S_GetFlagStatus(LCD_SPI, SPI_I2S_FLAG_BSY) != RESET); + + LCD_ChipSelect(ENABLE); +} + +/** + * @brief Configure the LCD controller (Power On sequence as described in ILI9341 Datasheet) + * @param None + * @retval None + */ +void LCD_PowerOn(void) +{ + LCD_WriteCommand(0xCA); + LCD_WriteData(0xC3); + LCD_WriteData(0x08); + LCD_WriteData(0x50); + LCD_WriteCommand(LCD_POWERB); + LCD_WriteData(0x00); + LCD_WriteData(0xC1); + LCD_WriteData(0x30); + LCD_WriteCommand(LCD_POWER_SEQ); + LCD_WriteData(0x64); + LCD_WriteData(0x03); + LCD_WriteData(0x12); + LCD_WriteData(0x81); + LCD_WriteCommand(LCD_DTCA); + LCD_WriteData(0x85); + LCD_WriteData(0x00); + LCD_WriteData(0x78); + LCD_WriteCommand(LCD_POWERA); + LCD_WriteData(0x39); + LCD_WriteData(0x2C); + LCD_WriteData(0x00); + LCD_WriteData(0x34); + LCD_WriteData(0x02); + LCD_WriteCommand(LCD_PRC); + LCD_WriteData(0x20); + LCD_WriteCommand(LCD_DTCB); + LCD_WriteData(0x00); + LCD_WriteData(0x00); + LCD_WriteCommand(LCD_FRC); + LCD_WriteData(0x00); + LCD_WriteData(0x1B); + LCD_WriteCommand(LCD_DFC); + LCD_WriteData(0x0A); + LCD_WriteData(0xA2); + LCD_WriteCommand(LCD_POWER1); + LCD_WriteData(0x10); + LCD_WriteCommand(LCD_POWER2); + LCD_WriteData(0x10); + LCD_WriteCommand(LCD_VCOM1); + LCD_WriteData(0x45); + LCD_WriteData(0x15); + LCD_WriteCommand(LCD_VCOM2); + LCD_WriteData(0x90); + LCD_WriteCommand(LCD_MAC); + LCD_WriteData(0xC8); + LCD_WriteCommand(LCD_3GAMMA_EN); + LCD_WriteData(0x00); + LCD_WriteCommand(LCD_RGB_INTERFACE); + LCD_WriteData(0xC2); + LCD_WriteCommand(LCD_DFC); + LCD_WriteData(0x0A); + LCD_WriteData(0xA7); + LCD_WriteData(0x27); + LCD_WriteData(0x04); + + /* colomn address set */ + LCD_WriteCommand(LCD_COLUMN_ADDR); + LCD_WriteData(0x00); + LCD_WriteData(0x00); + LCD_WriteData(0x00); + LCD_WriteData(0xEF); + /* Page Address Set */ + LCD_WriteCommand(LCD_PAGE_ADDR); + LCD_WriteData(0x00); + LCD_WriteData(0x00); + LCD_WriteData(0x01); + LCD_WriteData(0x3F); + LCD_WriteCommand(LCD_INTERFACE); + LCD_WriteData(0x01); + LCD_WriteData(0x00); + LCD_WriteData(0x06); + + LCD_WriteCommand(LCD_GRAM); + delay(200); + + LCD_WriteCommand(LCD_GAMMA); + LCD_WriteData(0x01); + + LCD_WriteCommand(LCD_PGAMMA); + LCD_WriteData(0x0F); + LCD_WriteData(0x29); + LCD_WriteData(0x24); + LCD_WriteData(0x0C); + LCD_WriteData(0x0E); + LCD_WriteData(0x09); + LCD_WriteData(0x4E); + LCD_WriteData(0x78); + LCD_WriteData(0x3C); + LCD_WriteData(0x09); + LCD_WriteData(0x13); + LCD_WriteData(0x05); + LCD_WriteData(0x17); + LCD_WriteData(0x11); + LCD_WriteData(0x00); + LCD_WriteCommand(LCD_NGAMMA); + LCD_WriteData(0x00); + LCD_WriteData(0x16); + LCD_WriteData(0x1B); + LCD_WriteData(0x04); + LCD_WriteData(0x11); + LCD_WriteData(0x07); + LCD_WriteData(0x31); + LCD_WriteData(0x33); + LCD_WriteData(0x42); + LCD_WriteData(0x05); + LCD_WriteData(0x0C); + LCD_WriteData(0x0A); + LCD_WriteData(0x28); + LCD_WriteData(0x2F); + LCD_WriteData(0x0F); + + LCD_WriteCommand(LCD_SLEEP_OUT); + delay(200); + LCD_WriteCommand(LCD_DISPLAY_ON); + /* GRAM start writing */ + LCD_WriteCommand(LCD_GRAM); + } + +/** + * @brief Enables the Display. + * @param None + * @retval None + */ +void LCD_DisplayOn(void) +{ + LCD_WriteCommand(LCD_DISPLAY_ON); +} + +/** + * @brief Disables the Display. + * @param None + * @retval None + */ +void LCD_DisplayOff(void) +{ + /* Display Off */ + LCD_WriteCommand(LCD_DISPLAY_OFF); +} + +/** + * @brief Configures LCD control lines in Output Push-Pull mode. + * @note The LCD_NCS line can be configured in Open Drain mode + * when VDDIO is lower than required LCD supply. + * @param None + * @retval None + */ +void LCD_CtrlLinesConfig(void) +{ + GPIO_InitTypeDef GPIO_InitStructure; + + /* Enable GPIOs clock*/ + RCC_AHB1PeriphClockCmd(LCD_NCS_GPIO_CLK | LCD_WRX_GPIO_CLK, ENABLE); + + /* Configure NCS in Output Push-Pull mode */ + GPIO_InitStructure.GPIO_Pin = LCD_NCS_PIN; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; + GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; + GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; + GPIO_Init(LCD_NCS_GPIO_PORT, &GPIO_InitStructure); + + /* Configure WRX in Output Push-Pull mode */ + GPIO_InitStructure.GPIO_Pin = LCD_WRX_PIN; + GPIO_Init(LCD_WRX_GPIO_PORT, &GPIO_InitStructure); + + /* Set chip select pin high */ + LCD_CtrlLinesWrite(LCD_NCS_GPIO_PORT, LCD_NCS_PIN, Bit_SET); +} + +/** + * @brief Sets or reset LCD control lines. + * @param GPIOx: where x can be B or D to select the GPIO peripheral. + * @param CtrlPins: the Control line. + * This parameter can be: + * @arg LCD_NCS_PIN: Chip Select pin + * @arg LCD_NWR_PIN: Read/Write Selection pin + * @arg LCD_RS_PIN: Register/RAM Selection pin + * @param BitVal: specifies the value to be written to the selected bit. + * This parameter can be: + * @arg Bit_RESET: to clear the port pin + * @arg Bit_SET: to set the port pin + * @retval None + */ +void LCD_CtrlLinesWrite(GPIO_TypeDef* GPIOx, uint16_t CtrlPins, BitAction BitVal) +{ + /* Set or Reset the control line */ + GPIO_WriteBit(GPIOx, (uint16_t)CtrlPins, (BitAction)BitVal); +} + +/** + * @brief Configures the LCD_SPI interface. + * @param None + * @retval None + */ +void LCD_SPIConfig(void) +{ + SPI_InitTypeDef SPI_InitStructure; + GPIO_InitTypeDef GPIO_InitStructure; + + /* Enable LCD_SPI_SCK_GPIO_CLK, LCD_SPI_MISO_GPIO_CLK and LCD_SPI_MOSI_GPIO_CLK clock */ + RCC_AHB1PeriphClockCmd(LCD_SPI_SCK_GPIO_CLK | LCD_SPI_MISO_GPIO_CLK | LCD_SPI_MOSI_GPIO_CLK, ENABLE); + + /* Enable LCD_SPI and SYSCFG clock */ + RCC_APB2PeriphClockCmd(LCD_SPI_CLK, ENABLE); + + /* Configure LCD_SPI SCK pin */ + GPIO_InitStructure.GPIO_Pin = LCD_SPI_SCK_PIN; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_25MHz; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; + GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; + GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN; + GPIO_Init(LCD_SPI_SCK_GPIO_PORT, &GPIO_InitStructure); + + /* Configure LCD_SPI MISO pin */ + GPIO_InitStructure.GPIO_Pin = LCD_SPI_MISO_PIN; + GPIO_Init(LCD_SPI_MISO_GPIO_PORT, &GPIO_InitStructure); + + /* Configure LCD_SPI MOSI pin */ + GPIO_InitStructure.GPIO_Pin = LCD_SPI_MOSI_PIN; + GPIO_Init(LCD_SPI_MOSI_GPIO_PORT, &GPIO_InitStructure); + + /* Connect SPI SCK */ + GPIO_PinAFConfig(LCD_SPI_SCK_GPIO_PORT, LCD_SPI_SCK_SOURCE, LCD_SPI_SCK_AF); + + /* Connect SPI MISO */ + GPIO_PinAFConfig(LCD_SPI_MISO_GPIO_PORT, LCD_SPI_MISO_SOURCE, LCD_SPI_MISO_AF); + + /* Connect SPI MOSI */ + GPIO_PinAFConfig(LCD_SPI_MOSI_GPIO_PORT, LCD_SPI_MOSI_SOURCE, LCD_SPI_MOSI_AF); + + SPI_I2S_DeInit(LCD_SPI); + + /* SPI configuration -------------------------------------------------------*/ + /* If the SPI peripheral is already enabled, don't reconfigure it */ + if ((LCD_SPI->CR1 & SPI_CR1_SPE) == 0) + { + SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex; + SPI_InitStructure.SPI_Mode = SPI_Mode_Master; + SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b; + SPI_InitStructure.SPI_CPOL = SPI_CPOL_Low; + SPI_InitStructure.SPI_CPHA = SPI_CPHA_1Edge; + SPI_InitStructure.SPI_NSS = SPI_NSS_Soft; + /* SPI baudrate is set to 5.6 MHz (PCLK2/SPI_BaudRatePrescaler = 90/16 = 5.625 MHz) + to verify these constraints: + - ILI9341 LCD SPI interface max baudrate is 10MHz for write and 6.66MHz for read + - l3gd20 SPI interface max baudrate is 10MHz for write/read + - PCLK2 frequency is set to 90 MHz + */ + SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_16; + SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB; + SPI_InitStructure.SPI_CRCPolynomial = 7; + SPI_Init(LCD_SPI, &SPI_InitStructure); + + /* Enable L3GD20_SPI */ + SPI_Cmd(LCD_SPI, ENABLE); + } +} + +/** + * @brief GPIO config for LTDC. + * @param None + * @retval None + */ +static void LCD_AF_GPIOConfig(void) +{ + GPIO_InitTypeDef GPIO_InitStruct; + + /* Enable GPIOA, GPIOB, GPIOC, GPIOD, GPIOF, GPIOG AHB Clocks */ + RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOB | \ + RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_GPIOD | \ + RCC_AHB1Periph_GPIOF | RCC_AHB1Periph_GPIOG, ENABLE); + +/* GPIOs Configuration */ +/* + +------------------------+-----------------------+----------------------------+ + + LCD pins assignment + + +------------------------+-----------------------+----------------------------+ + | LCD_TFT R2 <-> PC.10 | LCD_TFT G2 <-> PA.06 | LCD_TFT B2 <-> PD.06 | + | LCD_TFT R3 <-> PB.00 | LCD_TFT G3 <-> PG.10 | LCD_TFT B3 <-> PG.11 | + | LCD_TFT R4 <-> PA.11 | LCD_TFT G4 <-> PB.10 | LCD_TFT B4 <-> PG.12 | + | LCD_TFT R5 <-> PA.12 | LCD_TFT G5 <-> PB.11 | LCD_TFT B5 <-> PA.03 | + | LCD_TFT R6 <-> PB.01 | LCD_TFT G6 <-> PC.07 | LCD_TFT B6 <-> PB.08 | + | LCD_TFT R7 <-> PG.06 | LCD_TFT G7 <-> PD.03 | LCD_TFT B7 <-> PB.09 | + ------------------------------------------------------------------------------- + | LCD_TFT HSYNC <-> PC.06 | LCDTFT VSYNC <-> PA.04 | + | LCD_TFT CLK <-> PG.07 | LCD_TFT DE <-> PF.10 | + ----------------------------------------------------- + +*/ + + /* GPIOA configuration */ + GPIO_PinAFConfig(GPIOA, GPIO_PinSource3, GPIO_AF_LTDC); + GPIO_PinAFConfig(GPIOA, GPIO_PinSource4, GPIO_AF_LTDC); + GPIO_PinAFConfig(GPIOA, GPIO_PinSource6, GPIO_AF_LTDC); + GPIO_PinAFConfig(GPIOA, GPIO_PinSource11, GPIO_AF_LTDC); + GPIO_PinAFConfig(GPIOA, GPIO_PinSource12, GPIO_AF_LTDC); + + GPIO_InitStruct.GPIO_Pin = GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_6 | \ + GPIO_Pin_11 | GPIO_Pin_12; + + GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz; + GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF; + GPIO_InitStruct.GPIO_OType = GPIO_OType_PP; + GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_NOPULL; + GPIO_Init(GPIOA, &GPIO_InitStruct); + + /* GPIOB configuration */ + GPIO_PinAFConfig(GPIOB, GPIO_PinSource0, 0x09); + GPIO_PinAFConfig(GPIOB, GPIO_PinSource1, 0x09); + GPIO_PinAFConfig(GPIOB, GPIO_PinSource8, GPIO_AF_LTDC); + GPIO_PinAFConfig(GPIOB, GPIO_PinSource9, GPIO_AF_LTDC); + GPIO_PinAFConfig(GPIOB, GPIO_PinSource10, GPIO_AF_LTDC); + GPIO_PinAFConfig(GPIOB, GPIO_PinSource11, GPIO_AF_LTDC); + + GPIO_InitStruct.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_8 | \ + GPIO_Pin_9 | GPIO_Pin_10 | GPIO_Pin_11; + + GPIO_Init(GPIOB, &GPIO_InitStruct); + + /* GPIOC configuration */ + GPIO_PinAFConfig(GPIOC, GPIO_PinSource6, GPIO_AF_LTDC); + GPIO_PinAFConfig(GPIOC, GPIO_PinSource7, GPIO_AF_LTDC); + GPIO_PinAFConfig(GPIOC, GPIO_PinSource10, GPIO_AF_LTDC); + + GPIO_InitStruct.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7 | GPIO_Pin_10; + + GPIO_Init(GPIOC, &GPIO_InitStruct); + + /* GPIOD configuration */ + GPIO_PinAFConfig(GPIOD, GPIO_PinSource3, GPIO_AF_LTDC); + GPIO_PinAFConfig(GPIOD, GPIO_PinSource6, GPIO_AF_LTDC); + + GPIO_InitStruct.GPIO_Pin = GPIO_Pin_3 | GPIO_Pin_6; + + GPIO_Init(GPIOD, &GPIO_InitStruct); + + /* GPIOF configuration */ + GPIO_PinAFConfig(GPIOF, GPIO_PinSource10, GPIO_AF_LTDC); + + GPIO_InitStruct.GPIO_Pin = GPIO_Pin_10; + + GPIO_Init(GPIOF, &GPIO_InitStruct); + + /* GPIOG configuration */ + GPIO_PinAFConfig(GPIOG, GPIO_PinSource6, GPIO_AF_LTDC); + GPIO_PinAFConfig(GPIOG, GPIO_PinSource7, GPIO_AF_LTDC); + GPIO_PinAFConfig(GPIOG, GPIO_PinSource10, 0x09); + GPIO_PinAFConfig(GPIOG, GPIO_PinSource11, GPIO_AF_LTDC); + GPIO_PinAFConfig(GPIOG, GPIO_PinSource12, 0x09); + + GPIO_InitStruct.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7 | GPIO_Pin_10 | \ + GPIO_Pin_11 | GPIO_Pin_12; + + GPIO_Init(GPIOG, &GPIO_InitStruct); + +} + +/** + * @brief Displays a pixel. + * @param x: pixel x. + * @param y: pixel y. + * @retval None + */ +static void PutPixel(int16_t x, int16_t y) +{ + if(x < 0 || x > 239 || y < 0 || y > 319) + { + return; + } + LCD_DrawLine(x, y, 1, LCD_DIR_HORIZONTAL); +} + +#ifndef USE_Delay +/** + * @brief Inserts a delay time. + * @param nCount: specifies the delay time length. + * @retval None + */ +static void delay(__IO uint32_t nCount) +{ + __IO uint32_t index = 0; + for(index = nCount; index != 0; index--) + { + } +} +#endif /* USE_Delay*/ +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/uGL/stm32f429i_discovery_lcd.dep b/uGL/stm32f429i_discovery_lcd.dep new file mode 100644 index 0000000..3d40dfb --- /dev/null +++ b/uGL/stm32f429i_discovery_lcd.dep @@ -0,0 +1,45 @@ +uGL/stm32f429i_discovery_lcd.o: uGL/stm32f429i_discovery_lcd.c \ + uGL/stm32f429i_discovery_lcd.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/Core/CM4F/DeviceSupport/ST/stm32f4xx/stm32f4xx.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/Core/CM4F/CoreSupport/core_cm4.h \ + /usr/local/Caskroom/gcc-arm-embedded/7-2017-q4-major/gcc-arm-none-eabi-7-2017-q4-major/lib/gcc/arm-none-eabi/7.2.1/include/stdint.h \ + /usr/local/Caskroom/gcc-arm-embedded/7-2017-q4-major/gcc-arm-none-eabi-7-2017-q4-major/arm-none-eabi/include/stdint.h \ + /usr/local/Caskroom/gcc-arm-embedded/7-2017-q4-major/gcc-arm-none-eabi-7-2017-q4-major/arm-none-eabi/include/machine/_default_types.h \ + /usr/local/Caskroom/gcc-arm-embedded/7-2017-q4-major/gcc-arm-none-eabi-7-2017-q4-major/arm-none-eabi/include/sys/features.h \ + /usr/local/Caskroom/gcc-arm-embedded/7-2017-q4-major/gcc-arm-none-eabi-7-2017-q4-major/arm-none-eabi/include/_newlib_version.h \ + /usr/local/Caskroom/gcc-arm-embedded/7-2017-q4-major/gcc-arm-none-eabi-7-2017-q4-major/arm-none-eabi/include/sys/_intsup.h \ + /usr/local/Caskroom/gcc-arm-embedded/7-2017-q4-major/gcc-arm-none-eabi-7-2017-q4-major/arm-none-eabi/include/sys/_stdint.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/Core/CM4F/CoreSupport/core_cmInstr.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/Core/CM4F/CoreSupport/core_cmFunc.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/Core/CM4F/CoreSupport/core_cmSimd.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/Core/CM4F/DeviceSupport/ST/stm32f4xx/system_stm32f4xx.h \ + /Users/tom/Documents/src/uGames/uC-sdk/config/arm/stm32f4xx/stm32f4xx_conf.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_adc.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_can.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_crc.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_cryp.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_dac.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_dbgmcu.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_dcmi.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_dma.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_exti.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_flash.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_fsmc.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_hash.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_gpio.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_i2c.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_iwdg.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_pwr.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_rcc.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_rng.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_rtc.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_sdio.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_spi.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_syscfg.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_tim.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_usart.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_wwdg.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/misc.h \ + uGL/stm32f429i_discovery.h uGL/stm32f429i_discovery_sdram.h uGL/fonts.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_ltdc.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_dma2d.h diff --git a/uGL/stm32f429i_discovery_lcd.h b/uGL/stm32f429i_discovery_lcd.h new file mode 100755 index 0000000..2a2965b --- /dev/null +++ b/uGL/stm32f429i_discovery_lcd.h @@ -0,0 +1,334 @@ +/** + ****************************************************************************** + * @file stm32f429i_discovery_lcd.h + * @author MCD Application Team + * @version V1.0.1 + * @date 28-October-2013 + * @brief This file contains all the functions prototypes for the + * stm32f429i_discovery_lcd.c driver. + ****************************************************************************** + * @attention + * + *

© COPYRIGHT 2013 STMicroelectronics

+ * + * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.st.com/software_license_agreement_liberty_v2 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32F429I_DISCOVERY_LCD_H +#define __STM32F429I_DISCOVERY_LCD_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "stm32f4xx.h" +#include "stm32f429i_discovery.h" +#include "stm32f429i_discovery_sdram.h" +#include "fonts.h" + +/** @addtogroup Utilities + * @{ + */ + +/** @addtogroup STM32F4_DISCOVERY + * @{ + */ + +/** @addtogroup STM32F429I_DISCOVERY + * @{ + */ + +/** @addtogroup STM32F429I_DISCOVERY_LCD + * @{ + */ + + +/** @defgroup STM32F429I_DISCOVERY_LCD_Exported_Types + * @{ + */ +typedef struct +{ + int16_t X; + int16_t Y; +} Point, * pPoint; +/** + * @} + */ + +/** @defgroup stm32f429i_discovery_LCD_Exported_Constants + * @{ + */ + +/* LCD Size (Width and Height) */ +#define LCD_PIXEL_WIDTH ((uint16_t)240) +#define LCD_PIXEL_HEIGHT ((uint16_t)320) + +#define LCD_FRAME_BUFFER ((uint32_t)0xD0000000) +#define BUFFER_OFFSET ((uint32_t)0x50000) +/** + * @brief Uncomment the line below if you want to use user defined Delay function + * (for precise timing), otherwise default _delay_ function defined within + * this driver is used (less precise timing). + */ +/* #define USE_Delay */ + +#ifdef USE_Delay +#include "main.h" + #define _delay_ Delay /* !< User can provide more timing precise _delay_ function + (with 10ms time base), using SysTick for example */ +#else + #define _delay_ delay /* !< Default _delay_ function with less precise timing */ +#endif + + +/** + * @brief LCD Control pin + */ +#define LCD_NCS_PIN GPIO_Pin_2 +#define LCD_NCS_GPIO_PORT GPIOC +#define LCD_NCS_GPIO_CLK RCC_AHB1Periph_GPIOC + +/** + * @brief LCD Command/data pin + */ +#define LCD_WRX_PIN GPIO_Pin_13 +#define LCD_WRX_GPIO_PORT GPIOD +#define LCD_WRX_GPIO_CLK RCC_AHB1Periph_GPIOD + +/** + * @brief LCD SPI Interface pins + */ +#define LCD_SPI_SCK_PIN GPIO_Pin_7 /* PF.07 */ +#define LCD_SPI_SCK_GPIO_PORT GPIOF /* GPIOF */ +#define LCD_SPI_SCK_GPIO_CLK RCC_AHB1Periph_GPIOF +#define LCD_SPI_SCK_SOURCE GPIO_PinSource7 +#define LCD_SPI_SCK_AF GPIO_AF_SPI5 +#define LCD_SPI_MISO_PIN GPIO_Pin_8 /* PF.08 */ +#define LCD_SPI_MISO_GPIO_PORT GPIOF /* GPIOF */ +#define LCD_SPI_MISO_GPIO_CLK RCC_AHB1Periph_GPIOF +#define LCD_SPI_MISO_SOURCE GPIO_PinSource8 +#define LCD_SPI_MISO_AF GPIO_AF_SPI5 +#define LCD_SPI_MOSI_PIN GPIO_Pin_9 /* PF.09 */ +#define LCD_SPI_MOSI_GPIO_PORT GPIOF /* GPIOF */ +#define LCD_SPI_MOSI_GPIO_CLK RCC_AHB1Periph_GPIOF +#define LCD_SPI_MOSI_SOURCE GPIO_PinSource9 +#define LCD_SPI_MOSI_AF GPIO_AF_SPI5 +#define LCD_SPI SPI5 +#define LCD_SPI_CLK RCC_APB2Periph_SPI5 + +/** + * @brief LCD Registers + */ +#define LCD_SLEEP_OUT 0x11 /* Sleep out register */ +#define LCD_GAMMA 0x26 /* Gamma register */ +#define LCD_DISPLAY_OFF 0x28 /* Display off register */ +#define LCD_DISPLAY_ON 0x29 /* Display on register */ +#define LCD_COLUMN_ADDR 0x2A /* Colomn address register */ +#define LCD_PAGE_ADDR 0x2B /* Page address register */ +#define LCD_GRAM 0x2C /* GRAM register */ +#define LCD_MAC 0x36 /* Memory Access Control register*/ +#define LCD_PIXEL_FORMAT 0x3A /* Pixel Format register */ +#define LCD_WDB 0x51 /* Write Brightness Display register */ +#define LCD_WCD 0x53 /* Write Control Display register*/ +#define LCD_RGB_INTERFACE 0xB0 /* RGB Interface Signal Control */ +#define LCD_FRC 0xB1 /* Frame Rate Control register */ +#define LCD_BPC 0xB5 /* Blanking Porch Control register*/ +#define LCD_DFC 0xB6 /* Display Function Control register*/ +#define LCD_POWER1 0xC0 /* Power Control 1 register */ +#define LCD_POWER2 0xC1 /* Power Control 2 register */ +#define LCD_VCOM1 0xC5 /* VCOM Control 1 register */ +#define LCD_VCOM2 0xC7 /* VCOM Control 2 register */ +#define LCD_POWERA 0xCB /* Power control A register */ +#define LCD_POWERB 0xCF /* Power control B register */ +#define LCD_PGAMMA 0xE0 /* Positive Gamma Correction register*/ +#define LCD_NGAMMA 0xE1 /* Negative Gamma Correction register*/ +#define LCD_DTCA 0xE8 /* Driver timing control A */ +#define LCD_DTCB 0xEA /* Driver timing control B */ +#define LCD_POWER_SEQ 0xED /* Power on sequence register */ +#define LCD_3GAMMA_EN 0xF2 /* 3 Gamma enable register */ +#define LCD_INTERFACE 0xF6 /* Interface control register */ +#define LCD_PRC 0xF7 /* Pump ratio control register */ + +/** + * @brief LCD color + */ +#define LCD_COLOR_WHITE 0xFFFF +#define LCD_COLOR_BLACK 0x0000 +#define LCD_COLOR_GREY 0xF7DE +#define LCD_COLOR_BLUE 0x001F +#define LCD_COLOR_BLUE2 0x051F +#define LCD_COLOR_RED 0xF800 +#define LCD_COLOR_MAGENTA 0xF81F +#define LCD_COLOR_GREEN 0x07E0 +#define LCD_COLOR_CYAN 0x7FFF +#define LCD_COLOR_YELLOW 0xFFE0 + +/** + * @brief LCD Lines depending on the chosen fonts. + */ +#define LCD_LINE_0 LINE(0) +#define LCD_LINE_1 LINE(1) +#define LCD_LINE_2 LINE(2) +#define LCD_LINE_3 LINE(3) +#define LCD_LINE_4 LINE(4) +#define LCD_LINE_5 LINE(5) +#define LCD_LINE_6 LINE(6) +#define LCD_LINE_7 LINE(7) +#define LCD_LINE_8 LINE(8) +#define LCD_LINE_9 LINE(9) +#define LCD_LINE_10 LINE(10) +#define LCD_LINE_11 LINE(11) +#define LCD_LINE_12 LINE(12) +#define LCD_LINE_13 LINE(13) +#define LCD_LINE_14 LINE(14) +#define LCD_LINE_15 LINE(15) +#define LCD_LINE_16 LINE(16) +#define LCD_LINE_17 LINE(17) +#define LCD_LINE_18 LINE(18) +#define LCD_LINE_19 LINE(19) +#define LCD_LINE_20 LINE(20) +#define LCD_LINE_21 LINE(21) +#define LCD_LINE_22 LINE(22) +#define LCD_LINE_23 LINE(23) +#define LCD_LINE_24 LINE(24) +#define LCD_LINE_25 LINE(25) +#define LCD_LINE_26 LINE(26) +#define LCD_LINE_27 LINE(27) +#define LCD_LINE_28 LINE(28) +#define LCD_LINE_29 LINE(29) +#define LCD_LINE_30 LINE(30) +#define LCD_LINE_31 LINE(31) +#define LCD_LINE_32 LINE(32) +#define LCD_LINE_33 LINE(33) +#define LCD_LINE_34 LINE(34) +#define LCD_LINE_35 LINE(35) +#define LCD_LINE_36 LINE(36) +#define LCD_LINE_37 LINE(37) +#define LCD_LINE_38 LINE(38) +#define LCD_LINE_39 LINE(39) + +/** + * @brief LCD default font + */ +#define LCD_DEFAULT_FONT Font16x24 + +/** + * @brief LCD Direction + */ +#define LCD_DIR_HORIZONTAL 0x0000 +#define LCD_DIR_VERTICAL 0x0001 + +/** + * @} + */ + +/** + * @brief LCD Layer + */ +#define LCD_BACKGROUND_LAYER 0x0000 +#define LCD_FOREGROUND_LAYER 0x0001 + +/** + * @} + */ + +/** @defgroup STM32F429I_DISCOVERY_LCD_Exported_Macros + * @{ + */ +#define ASSEMBLE_RGB(R, G, B) ((((R)& 0xF8) << 8) | (((G) & 0xFC) << 3) | (((B) & 0xF8) >> 3)) + +/** + * @} + */ + +/** @defgroup STM32F429I_DISCOVERY_LCD_Exported_Functions + * @{ + */ +void LCD_DeInit(void); +void LCD_Init(void); +void LCD_LayerInit(void); +void LCD_ChipSelect(FunctionalState NewState); +void LCD_SetLayer(uint32_t Layerx); +void LCD_SetColors(uint16_t _TextColor, uint16_t _BackColor); +void LCD_GetColors(uint16_t *_TextColor, uint16_t *_BackColor); +void LCD_SetTextColor(uint16_t Color); +void LCD_SetBackColor(uint16_t Color); +void LCD_SetTransparency(uint8_t transparency); +void LCD_ClearLine(uint16_t Line); +void LCD_Clear(uint16_t Color); +uint32_t LCD_SetCursor(uint16_t Xpos, uint16_t Ypos); +void LCD_SetColorKeying(uint32_t RGBValue); +void LCD_ReSetColorKeying(void); +void LCD_DrawChar(uint16_t Xpos, uint16_t Ypos, const uint16_t *c); +void LCD_DisplayChar(uint16_t Line, uint16_t Column, uint8_t Ascii); +void LCD_SetFont(sFONT *fonts); +sFONT * LCD_GetFont(void); +void LCD_DisplayStringLine(uint16_t Line, uint8_t *ptr); +void LCD_SetDisplayWindow(uint16_t Xpos, uint16_t Ypos, uint16_t Height, uint16_t Width); +void LCD_WindowModeDisable(void); +void LCD_DrawLine(uint16_t Xpos, uint16_t Ypos, uint16_t Length, uint8_t Direction); +void LCD_DrawRect(uint16_t Xpos, uint16_t Ypos, uint16_t Height, uint16_t Width); +void LCD_DrawCircle(uint16_t Xpos, uint16_t Ypos, uint16_t Radius); +void LCD_DrawEllipse(int Xpos, int Ypos, int Radius, int Radius2); +void LCD_DrawFullEllipse(int Xpos, int Ypos, int Radius, int Radius2); +void LCD_DrawMonoPict(const uint32_t *Pict); +void LCD_WriteBMP(uint32_t BmpAddress); +void LCD_DrawUniLine(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2); +void LCD_DrawFullRect(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height); +void LCD_DrawFullCircle(uint16_t Xpos, uint16_t Ypos, uint16_t Radius); +void LCD_PolyLine(pPoint Points, uint16_t PointCount); +void LCD_PolyLineRelative(pPoint Points, uint16_t PointCount); +void LCD_ClosedPolyLine(pPoint Points, uint16_t PointCount); +void LCD_ClosedPolyLineRelative(pPoint Points, uint16_t PointCount); +void LCD_FillPolyLine(pPoint Points, uint16_t PointCount); +void LCD_Triangle(pPoint Points, uint16_t PointCount); +void LCD_FillTriangle(uint16_t x1, uint16_t x2, uint16_t x3, uint16_t y1, uint16_t y2, uint16_t y3); +void LCD_WriteCommand(uint8_t LCD_Reg); +void LCD_WriteData(uint8_t value); +void LCD_PowerOn(void); +void LCD_DisplayOn(void); +void LCD_DisplayOff(void); +void LCD_CtrlLinesConfig(void); +void LCD_CtrlLinesWrite(GPIO_TypeDef* GPIOx, uint16_t CtrlPins, BitAction BitVal); +void LCD_SPIConfig(void); +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* __STM32F429I_DISCOVERY_LCD_H */ + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/uGL/stm32f429i_discovery_sdram.c b/uGL/stm32f429i_discovery_sdram.c new file mode 100755 index 0000000..443644f --- /dev/null +++ b/uGL/stm32f429i_discovery_sdram.c @@ -0,0 +1,430 @@ +/** + ****************************************************************************** + * @file stm32f429i_discovery_sdram.c + * @author MCD Application Team + * @version V1.0.1 + * @date 28-October-2013 + * @brief This file provides a set of functions needed to drive the + * IS42S16400J SDRAM memory mounted on STM32F429I-DISCO Kit. + ****************************************************************************** + * @attention + * + *

© COPYRIGHT 2013 STMicroelectronics

+ * + * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.st.com/software_license_agreement_liberty_v2 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "stm32f429i_discovery_sdram.h" +#include "stm32f4xx_fmc.h" +/** @addtogroup Utilities + * @{ + */ + +/** @addtogroup STM32F4_DISCOVERY + * @{ + */ + +/** @addtogroup STM32429I_DISCO + * @{ + */ + +/** @addtogroup STM32429I_DISCO_SDRAM + * @brief This file provides a set of functions needed to drive the + * IS42S16400J SDRAM memory mounted on STM32429I-DISCO board. + * @{ + */ + +/** @defgroup STM32429I_DISCO_SDRAM_Private_Functions + * @{ + */ + +#ifndef USE_Delay +static void delay(__IO uint32_t nCount); +#endif /* USE_Delay*/ + +/** + * @brief Configures the FMC and GPIOs to interface with the SDRAM memory. + * This function must be called before any read/write operation + * on the SDRAM. + * @param None + * @retval None + */ +void SDRAM_Init(void) +{ + FMC_SDRAMInitTypeDef FMC_SDRAMInitStructure; + FMC_SDRAMTimingInitTypeDef FMC_SDRAMTimingInitStructure; + + /* GPIO configuration for FMC SDRAM bank */ + SDRAM_GPIOConfig(); + + /* Enable FMC clock */ + RCC_AHB3PeriphClockCmd(RCC_AHB3Periph_FMC, ENABLE); + +/* FMC Configuration ---------------------------------------------------------*/ +/* FMC SDRAM Bank configuration */ + /* Timing configuration for 90 Mhz of SD clock frequency (180Mhz/2) */ + /* TMRD: 2 Clock cycles */ + FMC_SDRAMTimingInitStructure.FMC_LoadToActiveDelay = 2; + /* TXSR: min=70ns (7x11.11ns) */ + FMC_SDRAMTimingInitStructure.FMC_ExitSelfRefreshDelay = 7; + /* TRAS: min=42ns (4x11.11ns) max=120k (ns) */ + FMC_SDRAMTimingInitStructure.FMC_SelfRefreshTime = 4; + /* TRC: min=70 (7x11.11ns) */ + FMC_SDRAMTimingInitStructure.FMC_RowCycleDelay = 7; + /* TWR: min=1+ 7ns (1+1x11.11ns) */ + FMC_SDRAMTimingInitStructure.FMC_WriteRecoveryTime = 2; + /* TRP: 20ns => 2x11.11ns */ + FMC_SDRAMTimingInitStructure.FMC_RPDelay = 2; + /* TRCD: 20ns => 2x11.11ns */ + FMC_SDRAMTimingInitStructure.FMC_RCDDelay = 2; + +/* FMC SDRAM control configuration */ + FMC_SDRAMInitStructure.FMC_Bank = FMC_Bank2_SDRAM; + /* Row addressing: [7:0] */ + FMC_SDRAMInitStructure.FMC_ColumnBitsNumber = FMC_ColumnBits_Number_8b; + /* Column addressing: [11:0] */ + FMC_SDRAMInitStructure.FMC_RowBitsNumber = FMC_RowBits_Number_12b; + FMC_SDRAMInitStructure.FMC_SDMemoryDataWidth = SDRAM_MEMORY_WIDTH; + FMC_SDRAMInitStructure.FMC_InternalBankNumber = FMC_InternalBank_Number_4; + FMC_SDRAMInitStructure.FMC_CASLatency = SDRAM_CAS_LATENCY; + FMC_SDRAMInitStructure.FMC_WriteProtection = FMC_Write_Protection_Disable; + FMC_SDRAMInitStructure.FMC_SDClockPeriod = SDCLOCK_PERIOD; + FMC_SDRAMInitStructure.FMC_ReadBurst = SDRAM_READBURST; + FMC_SDRAMInitStructure.FMC_ReadPipeDelay = FMC_ReadPipe_Delay_1; + FMC_SDRAMInitStructure.FMC_SDRAMTimingStruct = &FMC_SDRAMTimingInitStructure; + + /* FMC SDRAM bank initialization */ + FMC_SDRAMInit(&FMC_SDRAMInitStructure); + + /* FMC SDRAM device initialization sequence */ + SDRAM_InitSequence(); + +} + +/** + * @brief Configures all SDRAM memory I/Os pins. + * @param None. + * @retval None. + */ +void SDRAM_GPIOConfig(void) +{ + GPIO_InitTypeDef GPIO_InitStructure; + + /* Enable GPIOs clock */ + RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB | RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_GPIOD | + RCC_AHB1Periph_GPIOE | RCC_AHB1Periph_GPIOF | RCC_AHB1Periph_GPIOG, ENABLE); + +/*-- GPIOs Configuration -----------------------------------------------------*/ +/* + +-------------------+--------------------+--------------------+--------------------+ + + SDRAM pins assignment + + +-------------------+--------------------+--------------------+--------------------+ + | PD0 <-> FMC_D2 | PE0 <-> FMC_NBL0 | PF0 <-> FMC_A0 | PG0 <-> FMC_A10 | + | PD1 <-> FMC_D3 | PE1 <-> FMC_NBL1 | PF1 <-> FMC_A1 | PG1 <-> FMC_A11 | + | PD8 <-> FMC_D13 | PE7 <-> FMC_D4 | PF2 <-> FMC_A2 | PG8 <-> FMC_SDCLK | + | PD9 <-> FMC_D14 | PE8 <-> FMC_D5 | PF3 <-> FMC_A3 | PG15 <-> FMC_NCAS | + | PD10 <-> FMC_D15 | PE9 <-> FMC_D6 | PF4 <-> FMC_A4 |--------------------+ + | PD14 <-> FMC_D0 | PE10 <-> FMC_D7 | PF5 <-> FMC_A5 | + | PD15 <-> FMC_D1 | PE11 <-> FMC_D8 | PF11 <-> FMC_NRAS | + +-------------------| PE12 <-> FMC_D9 | PF12 <-> FMC_A6 | + | PE13 <-> FMC_D10 | PF13 <-> FMC_A7 | + | PE14 <-> FMC_D11 | PF14 <-> FMC_A8 | + | PE15 <-> FMC_D12 | PF15 <-> FMC_A9 | + +-------------------+--------------------+--------------------+ + | PB5 <-> FMC_SDCKE1| + | PB6 <-> FMC_SDNE1 | + | PC0 <-> FMC_SDNWE | + +-------------------+ + +*/ + + /* Common GPIO configuration */ + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; + GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; + GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; + + /* GPIOB configuration */ + GPIO_PinAFConfig(GPIOB, GPIO_PinSource5 , GPIO_AF_FMC); + GPIO_PinAFConfig(GPIOB, GPIO_PinSource6 , GPIO_AF_FMC); + + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5 | GPIO_Pin_6; + + GPIO_Init(GPIOB, &GPIO_InitStructure); + + /* GPIOC configuration */ + GPIO_PinAFConfig(GPIOC, GPIO_PinSource0 , GPIO_AF_FMC); + + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0; + + GPIO_Init(GPIOC, &GPIO_InitStructure); + + /* GPIOD configuration */ + GPIO_PinAFConfig(GPIOD, GPIO_PinSource0, GPIO_AF_FMC); + GPIO_PinAFConfig(GPIOD, GPIO_PinSource1, GPIO_AF_FMC); + GPIO_PinAFConfig(GPIOD, GPIO_PinSource8, GPIO_AF_FMC); + GPIO_PinAFConfig(GPIOD, GPIO_PinSource9, GPIO_AF_FMC); + GPIO_PinAFConfig(GPIOD, GPIO_PinSource10, GPIO_AF_FMC); + GPIO_PinAFConfig(GPIOD, GPIO_PinSource14, GPIO_AF_FMC); + GPIO_PinAFConfig(GPIOD, GPIO_PinSource15, GPIO_AF_FMC); + + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_8 | + GPIO_Pin_9 | GPIO_Pin_10 | GPIO_Pin_14 | + GPIO_Pin_15; + + GPIO_Init(GPIOD, &GPIO_InitStructure); + + /* GPIOE configuration */ + GPIO_PinAFConfig(GPIOE, GPIO_PinSource0 , GPIO_AF_FMC); + GPIO_PinAFConfig(GPIOE, GPIO_PinSource1 , GPIO_AF_FMC); + GPIO_PinAFConfig(GPIOE, GPIO_PinSource7 , GPIO_AF_FMC); + GPIO_PinAFConfig(GPIOE, GPIO_PinSource8 , GPIO_AF_FMC); + GPIO_PinAFConfig(GPIOE, GPIO_PinSource9 , GPIO_AF_FMC); + GPIO_PinAFConfig(GPIOE, GPIO_PinSource10 , GPIO_AF_FMC); + GPIO_PinAFConfig(GPIOE, GPIO_PinSource11 , GPIO_AF_FMC); + GPIO_PinAFConfig(GPIOE, GPIO_PinSource12 , GPIO_AF_FMC); + GPIO_PinAFConfig(GPIOE, GPIO_PinSource13 , GPIO_AF_FMC); + GPIO_PinAFConfig(GPIOE, GPIO_PinSource14 , GPIO_AF_FMC); + GPIO_PinAFConfig(GPIOE, GPIO_PinSource15 , GPIO_AF_FMC); + + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_7 | + GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 | + GPIO_Pin_11 | GPIO_Pin_12 | GPIO_Pin_13 | + GPIO_Pin_14 | GPIO_Pin_15; + + GPIO_Init(GPIOE, &GPIO_InitStructure); + + /* GPIOF configuration */ + GPIO_PinAFConfig(GPIOF, GPIO_PinSource0 , GPIO_AF_FMC); + GPIO_PinAFConfig(GPIOF, GPIO_PinSource1 , GPIO_AF_FMC); + GPIO_PinAFConfig(GPIOF, GPIO_PinSource2 , GPIO_AF_FMC); + GPIO_PinAFConfig(GPIOF, GPIO_PinSource3 , GPIO_AF_FMC); + GPIO_PinAFConfig(GPIOF, GPIO_PinSource4 , GPIO_AF_FMC); + GPIO_PinAFConfig(GPIOF, GPIO_PinSource5 , GPIO_AF_FMC); + GPIO_PinAFConfig(GPIOF, GPIO_PinSource11 , GPIO_AF_FMC); + GPIO_PinAFConfig(GPIOF, GPIO_PinSource12 , GPIO_AF_FMC); + GPIO_PinAFConfig(GPIOF, GPIO_PinSource13 , GPIO_AF_FMC); + GPIO_PinAFConfig(GPIOF, GPIO_PinSource14 , GPIO_AF_FMC); + GPIO_PinAFConfig(GPIOF, GPIO_PinSource15 , GPIO_AF_FMC); + + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | + GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_5 | + GPIO_Pin_11 | GPIO_Pin_12 | GPIO_Pin_13 | + GPIO_Pin_14 | GPIO_Pin_15; + + GPIO_Init(GPIOF, &GPIO_InitStructure); + + /* GPIOG configuration */ + GPIO_PinAFConfig(GPIOG, GPIO_PinSource0 , GPIO_AF_FMC); + GPIO_PinAFConfig(GPIOG, GPIO_PinSource1 , GPIO_AF_FMC); + GPIO_PinAFConfig(GPIOG, GPIO_PinSource4 , GPIO_AF_FMC); + GPIO_PinAFConfig(GPIOG, GPIO_PinSource5 , GPIO_AF_FMC); + GPIO_PinAFConfig(GPIOG, GPIO_PinSource8 , GPIO_AF_FMC); + GPIO_PinAFConfig(GPIOG, GPIO_PinSource15 , GPIO_AF_FMC); + + + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_4 | + GPIO_Pin_5 | GPIO_Pin_8 | GPIO_Pin_15; + + GPIO_Init(GPIOG, &GPIO_InitStructure); +} + +/** + * @brief Executes the SDRAM memory initialization sequence. + * @param None. + * @retval None. + */ +void SDRAM_InitSequence(void) +{ + FMC_SDRAMCommandTypeDef FMC_SDRAMCommandStructure; + uint32_t tmpr = 0; + +/* Step 3 --------------------------------------------------------------------*/ + /* Configure a clock configuration enable command */ + FMC_SDRAMCommandStructure.FMC_CommandMode = FMC_Command_Mode_CLK_Enabled; + FMC_SDRAMCommandStructure.FMC_CommandTarget = FMC_Command_Target_bank2; + FMC_SDRAMCommandStructure.FMC_AutoRefreshNumber = 1; + FMC_SDRAMCommandStructure.FMC_ModeRegisterDefinition = 0; + /* Wait until the SDRAM controller is ready */ + while(FMC_GetFlagStatus(FMC_Bank2_SDRAM, FMC_FLAG_Busy) != RESET) + { + } + /* Send the command */ + FMC_SDRAMCmdConfig(&FMC_SDRAMCommandStructure); + +/* Step 4 --------------------------------------------------------------------*/ + /* Insert 100 ms delay */ + __Delay(10); + +/* Step 5 --------------------------------------------------------------------*/ + /* Configure a PALL (precharge all) command */ + FMC_SDRAMCommandStructure.FMC_CommandMode = FMC_Command_Mode_PALL; + FMC_SDRAMCommandStructure.FMC_CommandTarget = FMC_Command_Target_bank2; + FMC_SDRAMCommandStructure.FMC_AutoRefreshNumber = 1; + FMC_SDRAMCommandStructure.FMC_ModeRegisterDefinition = 0; + /* Wait until the SDRAM controller is ready */ + while(FMC_GetFlagStatus(FMC_Bank2_SDRAM, FMC_FLAG_Busy) != RESET) + { + } + /* Send the command */ + FMC_SDRAMCmdConfig(&FMC_SDRAMCommandStructure); + +/* Step 6 --------------------------------------------------------------------*/ + /* Configure a Auto-Refresh command */ + FMC_SDRAMCommandStructure.FMC_CommandMode = FMC_Command_Mode_AutoRefresh; + FMC_SDRAMCommandStructure.FMC_CommandTarget = FMC_Command_Target_bank2; + FMC_SDRAMCommandStructure.FMC_AutoRefreshNumber = 4; + FMC_SDRAMCommandStructure.FMC_ModeRegisterDefinition = 0; + /* Wait until the SDRAM controller is ready */ + while(FMC_GetFlagStatus(FMC_Bank2_SDRAM, FMC_FLAG_Busy) != RESET) + { + } + /* Send the first command */ + FMC_SDRAMCmdConfig(&FMC_SDRAMCommandStructure); + + /* Wait until the SDRAM controller is ready */ + while(FMC_GetFlagStatus(FMC_Bank2_SDRAM, FMC_FLAG_Busy) != RESET) + { + } + /* Send the second command */ + FMC_SDRAMCmdConfig(&FMC_SDRAMCommandStructure); + +/* Step 7 --------------------------------------------------------------------*/ + /* Program the external memory mode register */ + tmpr = (uint32_t)SDRAM_MODEREG_BURST_LENGTH_2 | + SDRAM_MODEREG_BURST_TYPE_SEQUENTIAL | + SDRAM_MODEREG_CAS_LATENCY_3 | + SDRAM_MODEREG_OPERATING_MODE_STANDARD | + SDRAM_MODEREG_WRITEBURST_MODE_SINGLE; + + /* Configure a load Mode register command*/ + FMC_SDRAMCommandStructure.FMC_CommandMode = FMC_Command_Mode_LoadMode; + FMC_SDRAMCommandStructure.FMC_CommandTarget = FMC_Command_Target_bank2; + FMC_SDRAMCommandStructure.FMC_AutoRefreshNumber = 1; + FMC_SDRAMCommandStructure.FMC_ModeRegisterDefinition = tmpr; + /* Wait until the SDRAM controller is ready */ + while(FMC_GetFlagStatus(FMC_Bank2_SDRAM, FMC_FLAG_Busy) != RESET) + { + } + /* Send the command */ + FMC_SDRAMCmdConfig(&FMC_SDRAMCommandStructure); + +/* Step 8 --------------------------------------------------------------------*/ + + /* Set the refresh rate counter */ + /* (15.62 us x Freq) - 20 */ + /* Set the device refresh counter */ + FMC_SetRefreshCount(1386); + /* Wait until the SDRAM controller is ready */ + while(FMC_GetFlagStatus(FMC_Bank2_SDRAM, FMC_FLAG_Busy) != RESET) + { + } +} + + +/** + * @brief Writes a Entire-word buffer to the SDRAM memory. + * @param pBuffer: pointer to buffer. + * @param uwWriteAddress: SDRAM memory internal address from which the data will be + * written. + * @param uwBufferSize: number of words to write. + * @retval None. + */ +void SDRAM_WriteBuffer(uint32_t* pBuffer, uint32_t uwWriteAddress, uint32_t uwBufferSize) +{ + __IO uint32_t write_pointer = (uint32_t)uwWriteAddress; + + /* Disable write protection */ + FMC_SDRAMWriteProtectionConfig(FMC_Bank2_SDRAM, DISABLE); + + /* Wait until the SDRAM controller is ready */ + while(FMC_GetFlagStatus(FMC_Bank2_SDRAM, FMC_FLAG_Busy) != RESET) + { + } + + /* While there is data to write */ + for (; uwBufferSize != 0; uwBufferSize--) + { + /* Transfer data to the memory */ + *(uint32_t *) (SDRAM_BANK_ADDR + write_pointer) = *pBuffer++; + + /* Increment the address*/ + write_pointer += 4; + } + +} + +/** + * @brief Reads data buffer from the SDRAM memory. + * @param pBuffer: pointer to buffer. + * @param ReadAddress: SDRAM memory internal address from which the data will be + * read. + * @param uwBufferSize: number of words to write. + * @retval None. + */ +void SDRAM_ReadBuffer(uint32_t* pBuffer, uint32_t uwReadAddress, uint32_t uwBufferSize) +{ + __IO uint32_t write_pointer = (uint32_t)uwReadAddress; + + + /* Wait until the SDRAM controller is ready */ + while(FMC_GetFlagStatus(FMC_Bank2_SDRAM, FMC_FLAG_Busy) != RESET) + { + } + + /* Read data */ + for(; uwBufferSize != 0x00; uwBufferSize--) + { + *pBuffer++ = *(__IO uint32_t *)(SDRAM_BANK_ADDR + write_pointer ); + + /* Increment the address*/ + write_pointer += 4; + } +} + +#ifndef USE_Delay +/** + * @brief Inserts a delay time. + * @param nCount: specifies the delay time length. + * @retval None + */ +static void delay(__IO uint32_t nCount) +{ + __IO uint32_t index = 0; + for(index = (100000 * nCount); index != 0; index--) + { + } +} +#endif /* USE_Delay */ + + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/uGL/stm32f429i_discovery_sdram.dep b/uGL/stm32f429i_discovery_sdram.dep new file mode 100644 index 0000000..6a5c778 --- /dev/null +++ b/uGL/stm32f429i_discovery_sdram.dep @@ -0,0 +1,43 @@ +uGL/stm32f429i_discovery_sdram.o: uGL/stm32f429i_discovery_sdram.c \ + uGL/stm32f429i_discovery_sdram.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/Core/CM4F/DeviceSupport/ST/stm32f4xx/stm32f4xx.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/Core/CM4F/CoreSupport/core_cm4.h \ + /usr/local/Caskroom/gcc-arm-embedded/7-2017-q4-major/gcc-arm-none-eabi-7-2017-q4-major/lib/gcc/arm-none-eabi/7.2.1/include/stdint.h \ + /usr/local/Caskroom/gcc-arm-embedded/7-2017-q4-major/gcc-arm-none-eabi-7-2017-q4-major/arm-none-eabi/include/stdint.h \ + /usr/local/Caskroom/gcc-arm-embedded/7-2017-q4-major/gcc-arm-none-eabi-7-2017-q4-major/arm-none-eabi/include/machine/_default_types.h \ + /usr/local/Caskroom/gcc-arm-embedded/7-2017-q4-major/gcc-arm-none-eabi-7-2017-q4-major/arm-none-eabi/include/sys/features.h \ + /usr/local/Caskroom/gcc-arm-embedded/7-2017-q4-major/gcc-arm-none-eabi-7-2017-q4-major/arm-none-eabi/include/_newlib_version.h \ + /usr/local/Caskroom/gcc-arm-embedded/7-2017-q4-major/gcc-arm-none-eabi-7-2017-q4-major/arm-none-eabi/include/sys/_intsup.h \ + /usr/local/Caskroom/gcc-arm-embedded/7-2017-q4-major/gcc-arm-none-eabi-7-2017-q4-major/arm-none-eabi/include/sys/_stdint.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/Core/CM4F/CoreSupport/core_cmInstr.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/Core/CM4F/CoreSupport/core_cmFunc.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/Core/CM4F/CoreSupport/core_cmSimd.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/Core/CM4F/DeviceSupport/ST/stm32f4xx/system_stm32f4xx.h \ + /Users/tom/Documents/src/uGames/uC-sdk/config/arm/stm32f4xx/stm32f4xx_conf.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_adc.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_can.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_crc.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_cryp.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_dac.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_dbgmcu.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_dcmi.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_dma.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_exti.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_flash.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_fsmc.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_hash.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_gpio.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_i2c.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_iwdg.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_pwr.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_rcc.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_rng.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_rtc.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_sdio.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_spi.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_syscfg.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_tim.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_usart.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_wwdg.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/misc.h \ + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_fmc.h diff --git a/uGL/stm32f429i_discovery_sdram.h b/uGL/stm32f429i_discovery_sdram.h new file mode 100755 index 0000000..0bf52f5 --- /dev/null +++ b/uGL/stm32f429i_discovery_sdram.h @@ -0,0 +1,165 @@ +/** + ****************************************************************************** + * @file stm32f429i_discovery_sdram.h + * @author MCD Application Team + * @version V1.0.1 + * @date 28-October-2013 + * @brief This file contains all the functions prototypes for the + * stm324x9i_disco_sdram.c driver. + ****************************************************************************** + * @attention + * + *

© COPYRIGHT 2013 STMicroelectronics

+ * + * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.st.com/software_license_agreement_liberty_v2 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32429I_DISCO_SDRAM_H +#define __STM32429I_DISCO_SDRAM_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "stm32f4xx.h" + +/** @addtogroup Utilities + * @{ + */ + +/** @addtogroup STM32F4_EVAL + * @{ + */ + +/** @addtogroup STM32F429I_DISCOVERY + * @{ + */ + +/** @addtogroup STM32F429I_DISCOVERY_SDRAM + * @{ + */ + +/** @defgroup STM32429I_DISCO_SDRAM_Private_Defines + * @{ + */ + +/** + * @brief FMC SDRAM Bank address + */ +#define SDRAM_BANK_ADDR ((uint32_t)0xD0000000) + +/** + * @brief FMC SDRAM Memory Width + */ +/* #define SDRAM_MEMORY_WIDTH FMC_SDMemory_Width_8b */ +#define SDRAM_MEMORY_WIDTH FMC_SDMemory_Width_16b + +/** + * @brief FMC SDRAM CAS Latency + */ +/* #define SDRAM_CAS_LATENCY FMC_CAS_Latency_2 */ +#define SDRAM_CAS_LATENCY FMC_CAS_Latency_3 + +/** + * @brief FMC SDRAM Memory clock period + */ +#define SDCLOCK_PERIOD FMC_SDClock_Period_2 /* Default configuration used with LCD */ +/* #define SDCLOCK_PERIOD FMC_SDClock_Period_3 */ + +/** + * @brief FMC SDRAM Memory Read Burst feature + */ +#define SDRAM_READBURST FMC_Read_Burst_Disable /* Default configuration used with LCD */ +/* #define SDRAM_READBURST FMC_Read_Burst_Enable */ + +/** + * @brief FMC SDRAM Bank Remap + */ +/* #define SDRAM_BANK_REMAP */ + + + +/** + * @brief Uncomment the line below if you want to use user defined Delay function + * (for precise timing), otherwise default _delay_ function defined within + * this driver is used (less precise timing). + */ + +/* #define USE_Delay */ + +#ifdef USE_Delay + #define __Delay Delay /* User can provide more timing precise __Delay function + (with 10ms time base), using SysTick for example */ +#else + #define __Delay delay /* Default __Delay function with less precise timing */ +#endif + +/** + * @brief FMC SDRAM Mode definition register defines + */ +#define SDRAM_MODEREG_BURST_LENGTH_1 ((uint16_t)0x0000) +#define SDRAM_MODEREG_BURST_LENGTH_2 ((uint16_t)0x0001) +#define SDRAM_MODEREG_BURST_LENGTH_4 ((uint16_t)0x0002) +#define SDRAM_MODEREG_BURST_LENGTH_8 ((uint16_t)0x0004) +#define SDRAM_MODEREG_BURST_TYPE_SEQUENTIAL ((uint16_t)0x0000) +#define SDRAM_MODEREG_BURST_TYPE_INTERLEAVED ((uint16_t)0x0008) +#define SDRAM_MODEREG_CAS_LATENCY_2 ((uint16_t)0x0020) +#define SDRAM_MODEREG_CAS_LATENCY_3 ((uint16_t)0x0030) +#define SDRAM_MODEREG_OPERATING_MODE_STANDARD ((uint16_t)0x0000) +#define SDRAM_MODEREG_WRITEBURST_MODE_PROGRAMMED ((uint16_t)0x0000) +#define SDRAM_MODEREG_WRITEBURST_MODE_SINGLE ((uint16_t)0x0200) + +/** + * @} + */ + +/** @defgroup STM32429I_DISCO_SDRAM_Exported_Functions + * @{ + */ +void SDRAM_Init(void); +void SDRAM_GPIOConfig(void); +void SDRAM_InitSequence(void); +void SDRAM_WriteBuffer(uint32_t* pBuffer, uint32_t uwWriteAddress, uint32_t uwBufferSize); +void SDRAM_ReadBuffer(uint32_t* pBuffer, uint32_t uwReadAddress, uint32_t uwBufferSize); + +#ifdef __cplusplus +} +#endif + +#endif /* __STM32429I_DISCO_SDRAM_H */ + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/uGL/uGL.c b/uGL/uGL.c new file mode 100644 index 0000000..3ae0a26 --- /dev/null +++ b/uGL/uGL.c @@ -0,0 +1,52 @@ +#include "uGL.h" + +#include "stm32f429i_discovery_lcd.h" +#include + +void uGL_init() +{ + LCD_Init(); + + LCD_LayerInit(); + LTDC_Cmd(ENABLE); + + LCD_SetFont(&Font8x8); + LCD_SetLayer(LCD_BACKGROUND_LAYER); +// LCD_Clear(ASSEMBLE_RGB(0x00, 0x66, 0x00)); + LCD_SetLayer(LCD_FOREGROUND_LAYER); + LCD_SetBackColor(ASSEMBLE_RGB(0x00, 0x00, 0xFF)); +} + +void uGL_drawPixel(uint16_t x, uint16_t y, uGL_color_t color) +{ + LCD_SetTextColor(ASSEMBLE_RGB(color.r, color.g, color.b)); +// PutPixel(int16_t x, int16_t y); +} + +void uGL_drawHLine(uint16_t x, uint16_t y, uint16_t length, uGL_color_t color) +{ + LCD_SetTextColor(ASSEMBLE_RGB(color.r, color.g, color.b)); + LCD_DrawLine(x, y, length, LCD_DIR_HORIZONTAL); +} + +void uGL_drawVLine(uint16_t x, uint16_t y, uint16_t length, uGL_color_t color) +{ + LCD_SetTextColor(ASSEMBLE_RGB(color.r, color.g, color.b)); + LCD_DrawLine(x, y, length, LCD_DIR_VERTICAL); +} + +void uGL_drawFrame(uint16_t x, uint16_t y, uint16_t width, uint16_t length, uGL_color_t color) +{ + LCD_SetTextColor(ASSEMBLE_RGB(color.r, color.g, color.b)); + LCD_DrawRect(x, y, width, length); +} + +void uGL_drawRectangle(uint16_t x, uint16_t y, uint16_t width, uint16_t length, uGL_color_t color) +{ + LCD_SetTextColor(ASSEMBLE_RGB(color.r, color.g, color.b)); + LCD_DrawFullRect(x, y, width, length); +} + +void uGl_blitImage(uGL_image_t *image, uint16_t x, uint16_t y) +{ +} diff --git a/uGL/uGL.h b/uGL/uGL.h index 8b94ac2..7035d4d 100644 --- a/uGL/uGL.h +++ b/uGL/uGL.h @@ -1,21 +1,23 @@ #pragma once +#include + typedef struct { uint8_t r; uint8_t g; uint8_t b; uint8_t a; -} uGL_color; +} uGL_color_t; -typedef uGL_color *uGL_lookuptable; +typedef uGL_color_t *uGL_lookuptable; typedef enum { - INDEXED1 1, - INDEXED2 2, - INDEXED4 4, - INDEXED8 8, - RGB 24, - RGBA 32 + INDEXED1 = 1, + INDEXED2 = 2, + INDEXED4 = 4, + INDEXED8 = 8, + RGB = 24, + RGBA = 32 } uGL_colormode; typedef struct { @@ -24,15 +26,15 @@ typedef struct { uGL_colormode colormode; uGL_lookuptable *lookuptable; uint8_t *data; -} uGL_image; +} uGL_image_t; -uGL_init(); +void uGL_init(); -uGL_drawPixel(uint16_t x, uint16_t y, uGL_color color); -uGL_drawHLine(uint16_t x, uint16_t y, uint16_t length, uGL_color color); -uGL_drawVLine(uint16_t x, uint16_t y, uint16_t length, uGL_color color); -uGL_drawFrame(uint16_t x, uint16_t y, uint16_t width, uint16_t length, uGL_color color); -uGL_drawRectangle(uint16_t x, uint16_t y, uint16_t width, uint16_t length, uGL_color color); +void uGL_drawPixel(uint16_t x, uint16_t y, uGL_color_t color); +void uGL_drawHLine(uint16_t x, uint16_t y, uint16_t length, uGL_color_t color); +void uGL_drawVLine(uint16_t x, uint16_t y, uint16_t length, uGL_color_t color); +void uGL_drawFrame(uint16_t x, uint16_t y, uint16_t width, uint16_t length, uGL_color_t color); +void uGL_drawRectangle(uint16_t x, uint16_t y, uint16_t width, uint16_t length, uGL_color_t color); -uGl_blitImage(uGL_image *image, uint16_t x, uint16_t y); +void uGl_blitImage(uGL_image_t *image, uint16_t x, uint16_t y); From 3e3e53ee0662e5c91249cf9d5a6e51ab0a802f69 Mon Sep 17 00:00:00 2001 From: Thomas Pietrzak Date: Tue, 25 Sep 2018 15:07:02 +0200 Subject: [PATCH 05/11] early factorize --- bootloader.c | 7 + uGL/stm32f429i_discovery_lcd.c | 1032 ++++++++++++------------------ uGL/stm32f429i_discovery_lcd.dep | 6 +- uGL/stm32f429i_discovery_lcd.h | 130 ++-- uGL/stm32f429i_discovery_sdram.c | 180 +++--- uGL/uGL.c | 46 +- uGL/uGL.h | 7 +- 7 files changed, 624 insertions(+), 784 deletions(-) diff --git a/bootloader.c b/bootloader.c index f3b6326..a2855df 100644 --- a/bootloader.c +++ b/bootloader.c @@ -6,6 +6,13 @@ int main() { uGL_init(); + uGL_color_t gradientcolor = { .r = 0, .g = 0, .b = 0 }; + for (int i = 0 ; i < 256 ; i++) + { + gradientcolor.g = i; + uGL_drawPixel(10, i, gradientcolor); + } + uGL_color_t backgroundcolor = { .r = 70, .g = 120, .b = 240 }; uGL_drawRectangle(0, 0, 240, 320, backgroundcolor); diff --git a/uGL/stm32f429i_discovery_lcd.c b/uGL/stm32f429i_discovery_lcd.c index 8f697fc..804a83e 100755 --- a/uGL/stm32f429i_discovery_lcd.c +++ b/uGL/stm32f429i_discovery_lcd.c @@ -4,7 +4,7 @@ * @author MCD Application Team * @version V1.0.1 * @date 28-October-2013 - * @brief This file includes the LCD driver for ILI9341 Liquid Crystal + * @brief This file includes the LCD driver for ILI9341 Liquid Crystal * Display Modules of STM32F429I-DISCO kit (MB1075). ****************************************************************************** * @attention @@ -17,8 +17,8 @@ * * http://www.st.com/software_license_agreement_liberty_v2 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. @@ -32,52 +32,27 @@ #include "stm32f4xx_dma2d.h" //#include "fonts.c" +#include +#include +ssp_port_t lcd_port = { + .ssp = ssp_5, + .sclk = { .port = gpio_port_f, .pin = 7 }, + .mosi = { .port = gpio_port_f, .pin = 9 }, + .miso = { .port = gpio_port_f, .pin = 8 }, + .ss = PIN_NULL, + .mode = ssp_master + }; +pin_t lcd_ncs = { .port = gpio_port_c, .pin = 2 }; +pin_t lcd_wrx = { .port = gpio_port_d, .pin = 13 }; -/** @addtogroup Utilities - * @{ - */ - -/** @addtogroup STM32F4_DISCOVERY - * @{ - */ -/** @addtogroup STM32F429I_DISCOVERY - * @{ - */ - -/** @defgroup STM32F429I_DISCOVERY_LCD - * @brief This file includes the LCD driver for (ILI9341) - * @{ - */ -/** @defgroup STM32F429I_DISCOVERY_LCD_Private_TypesDefinitions - * @{ - */ -/** - * @} - */ -/** @defgroup STM32F429I_DISCOVERY_LCD_Private_Defines - * @{ - */ #define POLY_Y(Z) ((int32_t)((Points + Z)->X)) -#define POLY_X(Z) ((int32_t)((Points + Z)->Y)) -/** - * @} - */ +#define POLY_X(Z) ((int32_t)((Points + Z)->Y)) +#define ABS(X) ((X) > 0 ? (X) : -(X)) -/** @defgroup STM32F429I_DISCOVERY_LCD_Private_Macros - * @{ - */ -#define ABS(X) ((X) > 0 ? (X) : -(X)) -/** - * @} - */ - -/** @defgroup STM32F429I_DISCOVERY_LCD_Private_Variables - * @{ - */ static sFONT *LCD_Currentfonts; /* Global variables to set the written text color */ static uint16_t CurrentTextColor = 0x0000; @@ -85,28 +60,164 @@ static uint16_t CurrentBackColor = 0xFFFF; /* Default LCD configuration with LCD Layer 1 */ static uint32_t CurrentFrameBuffer = LCD_FRAME_BUFFER; static uint32_t CurrentLayer = LCD_BACKGROUND_LAYER; -/** - * @} - */ -/** @defgroup STM32F429I_DISCOVERY_LCD_Private_FunctionPrototypes - * @{ - */ #ifndef USE_Delay static void delay(__IO uint32_t nCount); #endif /* USE_Delay*/ static void PutPixel(int16_t x, int16_t y); static void LCD_PolyLineRelativeClosed(pPoint Points, uint16_t PointCount, uint16_t Closed); -static void LCD_AF_GPIOConfig(void); + + + +void LCD_Init(void) +{ + LTDC_InitTypeDef LTDC_InitStruct; + + /* Configure the LCD Control pins ------------------------------------------*/ + gpio_config(lcd_ncs, pin_dir_write, pull_none); + gpio_config(lcd_wrx, pin_dir_write, pull_none); + + gpio_set(lcd_ncs, 0); + gpio_set(lcd_ncs, 1); + + ssp_config(lcd_port, 5600000); + + + +// LCD_ChipSelect(DISABLE); +// LCD_ChipSelect(ENABLE); + + /* Configure the LCD_SPI interface -----------------------------------------*/ +// LCD_SPIConfig(); + + /* Power on the LCD --------------------------------------------------------*/ + LCD_PowerOn(); + + /* Enable the LTDC Clock */ + RCC_APB2PeriphClockCmd(RCC_APB2Periph_LTDC, ENABLE); + + /* Enable the DMA2D Clock */ + RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA2D, ENABLE); + + /* Configure the LCD Control pins */ +/* + +------------------------+-----------------------+----------------------------+ + + LCD pins assignment + + +------------------------+-----------------------+----------------------------+ + | LCD_TFT R2 <-> PC.10 | LCD_TFT G2 <-> PA.06 | LCD_TFT B2 <-> PD.06 | + | LCD_TFT R3 <-> PB.00 | LCD_TFT G3 <-> PG.10 | LCD_TFT B3 <-> PG.11 | + | LCD_TFT R4 <-> PA.11 | LCD_TFT G4 <-> PB.10 | LCD_TFT B4 <-> PG.12 | + | LCD_TFT R5 <-> PA.12 | LCD_TFT G5 <-> PB.11 | LCD_TFT B5 <-> PA.03 | + | LCD_TFT R6 <-> PB.01 | LCD_TFT G6 <-> PC.07 | LCD_TFT B6 <-> PB.08 | + | LCD_TFT R7 <-> PG.06 | LCD_TFT G7 <-> PD.03 | LCD_TFT B7 <-> PB.09 | + ------------------------------------------------------------------------------- + | LCD_TFT HSYNC <-> PC.06 | LCDTFT VSYNC <-> PA.04 | + | LCD_TFT CLK <-> PG.07 | LCD_TFT DE <-> PF.10 | + ----------------------------------------------------- +*/ + pin_t lcd_pin[] = { + //r + make_pin(gpio_port_c, 10), + make_pin(gpio_port_b, 0), + make_pin(gpio_port_a, 11), + make_pin(gpio_port_a, 12), + make_pin(gpio_port_b, 1), + make_pin(gpio_port_g, 6), + //g + make_pin(gpio_port_a, 6), + make_pin(gpio_port_g, 10), + make_pin(gpio_port_b, 10), + make_pin(gpio_port_b, 11), + make_pin(gpio_port_c, 7), + make_pin(gpio_port_d, 3), + //b + make_pin(gpio_port_d, 6), + make_pin(gpio_port_g, 11), + make_pin(gpio_port_g, 12), + make_pin(gpio_port_a, 3), + make_pin(gpio_port_b, 8), + make_pin(gpio_port_b, 9), + //hsync + make_pin(gpio_port_c, 6), + //vsync + make_pin(gpio_port_a, 4), + //clk + make_pin(gpio_port_g, 7), + //de + make_pin(gpio_port_f, 10), + }; + for (int i = 0 ; i < 22 ; i++) + gpio_config_alternate(lcd_pin[i], pin_dir_write, pull_none, 0x0E); + + + + + + /* Configure the FMC Parallel interface : SDRAM is used as Frame Buffer for LCD */ + SDRAM_Init(); + + /* LTDC Configuration *********************************************************/ + /* Polarity configuration */ + /* Initialize the horizontal synchronization polarity as active low */ + LTDC_InitStruct.LTDC_HSPolarity = LTDC_HSPolarity_AL; + /* Initialize the vertical synchronization polarity as active low */ + LTDC_InitStruct.LTDC_VSPolarity = LTDC_VSPolarity_AL; + /* Initialize the data enable polarity as active low */ + LTDC_InitStruct.LTDC_DEPolarity = LTDC_DEPolarity_AL; + /* Initialize the pixel clock polarity as input pixel clock */ + LTDC_InitStruct.LTDC_PCPolarity = LTDC_PCPolarity_IPC; + + /* Configure R,G,B component values for LCD background color */ + LTDC_InitStruct.LTDC_BackgroundRedValue = 0; + LTDC_InitStruct.LTDC_BackgroundGreenValue = 0; + LTDC_InitStruct.LTDC_BackgroundBlueValue = 0; + + /* Configure PLLSAI prescalers for LCD */ + /* Enable Pixel Clock */ + /* PLLSAI_VCO Input = HSE_VALUE/PLL_M = 1 Mhz */ + /* PLLSAI_VCO Output = PLLSAI_VCO Input * PLLSAI_N = 192 Mhz */ + /* PLLLCDCLK = PLLSAI_VCO Output/PLLSAI_R = 192/4 = 48 Mhz */ + /* LTDC clock frequency = PLLLCDCLK / RCC_PLLSAIDivR = 48/8 = 6 Mhz */ + RCC_PLLSAIConfig(192, 7, 4); + RCC_LTDCCLKDivConfig(RCC_PLLSAIDivR_Div8); + + /* Enable PLLSAI Clock */ + RCC_PLLSAICmd(ENABLE); + /* Wait for PLLSAI activation */ + while(RCC_GetFlagStatus(RCC_FLAG_PLLSAIRDY) == RESET) + { + } + + /* Timing configuration */ + /* Configure horizontal synchronization width */ + LTDC_InitStruct.LTDC_HorizontalSync = 9; + /* Configure vertical synchronization height */ + LTDC_InitStruct.LTDC_VerticalSync = 1; + /* Configure accumulated horizontal back porch */ + LTDC_InitStruct.LTDC_AccumulatedHBP = 29; + /* Configure accumulated vertical back porch */ + LTDC_InitStruct.LTDC_AccumulatedVBP = 3; + /* Configure accumulated active width */ + LTDC_InitStruct.LTDC_AccumulatedActiveW = 269; + /* Configure accumulated active height */ + LTDC_InitStruct.LTDC_AccumulatedActiveH = 323; + /* Configure total width */ + LTDC_InitStruct.LTDC_TotalWidth = 279; + /* Configure total height */ + LTDC_InitStruct.LTDC_TotalHeigh = 327; + + LTDC_Init(<DC_InitStruct); +} + /** * @} - */ + */ /** @defgroup STM32F429I_DISCOVERY_LCD_Private_Functions * @{ - */ + */ /** * @brief DeInitializes the LCD. @@ -114,7 +225,7 @@ static void LCD_AF_GPIOConfig(void); * @retval None */ void LCD_DeInit(void) -{ +{ GPIO_InitTypeDef GPIO_InitStructure; /* LCD Display Off */ @@ -122,26 +233,26 @@ void LCD_DeInit(void) /* LCD_SPI disable */ SPI_Cmd(LCD_SPI, DISABLE); - + /* LCD_SPI DeInit */ SPI_I2S_DeInit(LCD_SPI); - + /* Disable SPI clock */ RCC_APB2PeriphClockCmd(LCD_SPI_CLK, DISABLE); - + /* Configure NCS in Output Push-Pull mode */ GPIO_InitStructure.GPIO_Pin = LCD_NCS_PIN; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; GPIO_Init(LCD_NCS_GPIO_PORT, &GPIO_InitStructure); - + /* Configure SPI pins: SCK, MISO and MOSI */ GPIO_InitStructure.GPIO_Pin = LCD_SPI_SCK_PIN; GPIO_Init(LCD_SPI_SCK_GPIO_PORT, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = LCD_SPI_MISO_PIN; GPIO_Init(LCD_SPI_MISO_GPIO_PORT, &GPIO_InitStructure); - + GPIO_InitStructure.GPIO_Pin = LCD_SPI_MOSI_PIN; GPIO_Init(LCD_SPI_MOSI_GPIO_PORT, &GPIO_InitStructure); @@ -151,7 +262,7 @@ void LCD_DeInit(void) GPIO_PinAFConfig(GPIOA, GPIO_PinSource6, GPIO_AF_MCO); GPIO_PinAFConfig(GPIOA, GPIO_PinSource11, GPIO_AF_MCO); GPIO_PinAFConfig(GPIOA, GPIO_PinSource12, GPIO_AF_MCO); - + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_6 | GPIO_Pin_11 | GPIO_Pin_12; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; @@ -167,7 +278,7 @@ void LCD_DeInit(void) GPIO_PinAFConfig(GPIOB, GPIO_PinSource9, GPIO_AF_MCO); GPIO_PinAFConfig(GPIOB, GPIO_PinSource10, GPIO_AF_MCO); GPIO_PinAFConfig(GPIOB, GPIO_PinSource11, GPIO_AF_MCO); - + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 | GPIO_Pin_11; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; @@ -175,39 +286,39 @@ void LCD_DeInit(void) GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; GPIO_Init(GPIOB, &GPIO_InitStructure); - + /* GPIOC configuration */ GPIO_PinAFConfig(GPIOC, GPIO_PinSource6, GPIO_AF_MCO); GPIO_PinAFConfig(GPIOC, GPIO_PinSource7, GPIO_AF_MCO); GPIO_PinAFConfig(GPIOC, GPIO_PinSource10, GPIO_AF_MCO); - + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7 | GPIO_Pin_10; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; GPIO_Init(GPIOC, &GPIO_InitStructure); - + /* GPIOD configuration */ GPIO_PinAFConfig(GPIOD, GPIO_PinSource3, GPIO_AF_MCO); GPIO_PinAFConfig(GPIOD, GPIO_PinSource6, GPIO_AF_MCO); - - GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3 | GPIO_Pin_6; + + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3 | GPIO_Pin_6; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; - GPIO_Init(GPIOD, &GPIO_InitStructure); + GPIO_Init(GPIOD, &GPIO_InitStructure); /* GPIOF configuration */ GPIO_PinAFConfig(GPIOF, GPIO_PinSource10, GPIO_AF_MCO); - - GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10; + + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; - GPIO_Init(GPIOF, &GPIO_InitStructure); + GPIO_Init(GPIOF, &GPIO_InitStructure); /* GPIOG configuration */ GPIO_PinAFConfig(GPIOG, GPIO_PinSource6, GPIO_AF_MCO); @@ -215,7 +326,7 @@ void LCD_DeInit(void) GPIO_PinAFConfig(GPIOG, GPIO_PinSource10, GPIO_AF_MCO); GPIO_PinAFConfig(GPIOG, GPIO_PinSource11, GPIO_AF_MCO); GPIO_PinAFConfig(GPIOG, GPIO_PinSource12, GPIO_AF_MCO); - + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7 | GPIO_Pin_10 | GPIO_Pin_11 | GPIO_Pin_12; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; @@ -225,91 +336,6 @@ void LCD_DeInit(void) GPIO_Init(GPIOG, &GPIO_InitStructure); } -/** - * @brief Initializes the LCD. - * @param None - * @retval None - */ -void LCD_Init(void) -{ - LTDC_InitTypeDef LTDC_InitStruct; - - /* Configure the LCD Control pins ------------------------------------------*/ - LCD_CtrlLinesConfig(); - LCD_ChipSelect(DISABLE); - LCD_ChipSelect(ENABLE); - - /* Configure the LCD_SPI interface -----------------------------------------*/ - LCD_SPIConfig(); - - /* Power on the LCD --------------------------------------------------------*/ - LCD_PowerOn(); - - /* Enable the LTDC Clock */ - RCC_APB2PeriphClockCmd(RCC_APB2Periph_LTDC, ENABLE); - - /* Enable the DMA2D Clock */ - RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA2D, ENABLE); - - /* Configure the LCD Control pins */ - LCD_AF_GPIOConfig(); - - /* Configure the FMC Parallel interface : SDRAM is used as Frame Buffer for LCD */ - SDRAM_Init(); - - /* LTDC Configuration *********************************************************/ - /* Polarity configuration */ - /* Initialize the horizontal synchronization polarity as active low */ - LTDC_InitStruct.LTDC_HSPolarity = LTDC_HSPolarity_AL; - /* Initialize the vertical synchronization polarity as active low */ - LTDC_InitStruct.LTDC_VSPolarity = LTDC_VSPolarity_AL; - /* Initialize the data enable polarity as active low */ - LTDC_InitStruct.LTDC_DEPolarity = LTDC_DEPolarity_AL; - /* Initialize the pixel clock polarity as input pixel clock */ - LTDC_InitStruct.LTDC_PCPolarity = LTDC_PCPolarity_IPC; - - /* Configure R,G,B component values for LCD background color */ - LTDC_InitStruct.LTDC_BackgroundRedValue = 0; - LTDC_InitStruct.LTDC_BackgroundGreenValue = 0; - LTDC_InitStruct.LTDC_BackgroundBlueValue = 0; - - /* Configure PLLSAI prescalers for LCD */ - /* Enable Pixel Clock */ - /* PLLSAI_VCO Input = HSE_VALUE/PLL_M = 1 Mhz */ - /* PLLSAI_VCO Output = PLLSAI_VCO Input * PLLSAI_N = 192 Mhz */ - /* PLLLCDCLK = PLLSAI_VCO Output/PLLSAI_R = 192/4 = 48 Mhz */ - /* LTDC clock frequency = PLLLCDCLK / RCC_PLLSAIDivR = 48/8 = 6 Mhz */ - RCC_PLLSAIConfig(192, 7, 4); - RCC_LTDCCLKDivConfig(RCC_PLLSAIDivR_Div8); - - /* Enable PLLSAI Clock */ - RCC_PLLSAICmd(ENABLE); - /* Wait for PLLSAI activation */ - while(RCC_GetFlagStatus(RCC_FLAG_PLLSAIRDY) == RESET) - { - } - - /* Timing configuration */ - /* Configure horizontal synchronization width */ - LTDC_InitStruct.LTDC_HorizontalSync = 9; - /* Configure vertical synchronization height */ - LTDC_InitStruct.LTDC_VerticalSync = 1; - /* Configure accumulated horizontal back porch */ - LTDC_InitStruct.LTDC_AccumulatedHBP = 29; - /* Configure accumulated vertical back porch */ - LTDC_InitStruct.LTDC_AccumulatedVBP = 3; - /* Configure accumulated active width */ - LTDC_InitStruct.LTDC_AccumulatedActiveW = 269; - /* Configure accumulated active height */ - LTDC_InitStruct.LTDC_AccumulatedActiveH = 323; - /* Configure total width */ - LTDC_InitStruct.LTDC_TotalWidth = 279; - /* Configure total height */ - LTDC_InitStruct.LTDC_TotalHeigh = 327; - - LTDC_Init(<DC_InitStruct); -} - /** * @brief Initializes the LCD Layers. * @param None @@ -317,76 +343,76 @@ void LCD_Init(void) */ void LCD_LayerInit(void) { - LTDC_Layer_InitTypeDef LTDC_Layer_InitStruct; - + LTDC_Layer_InitTypeDef LTDC_Layer_InitStruct; + /* Windowing configuration */ /* In this case all the active display area is used to display a picture then : - Horizontal start = horizontal synchronization + Horizontal back porch = 30 + Horizontal start = horizontal synchronization + Horizontal back porch = 30 Horizontal stop = Horizontal start + window width -1 = 30 + 240 -1 Vertical start = vertical synchronization + vertical back porch = 4 - Vertical stop = Vertical start + window height -1 = 4 + 320 -1 */ + Vertical stop = Vertical start + window height -1 = 4 + 320 -1 */ LTDC_Layer_InitStruct.LTDC_HorizontalStart = 30; - LTDC_Layer_InitStruct.LTDC_HorizontalStop = (LCD_PIXEL_WIDTH + 30 - 1); + LTDC_Layer_InitStruct.LTDC_HorizontalStop = (LCD_PIXEL_WIDTH + 30 - 1); LTDC_Layer_InitStruct.LTDC_VerticalStart = 4; LTDC_Layer_InitStruct.LTDC_VerticalStop = (LCD_PIXEL_HEIGHT + 4 - 1); - + /* Pixel Format configuration*/ LTDC_Layer_InitStruct.LTDC_PixelFormat = LTDC_Pixelformat_RGB565; /* Alpha constant (255 totally opaque) */ - LTDC_Layer_InitStruct.LTDC_ConstantAlpha = 255; - /* Default Color configuration (configure A,R,G,B component values) */ - LTDC_Layer_InitStruct.LTDC_DefaultColorBlue = 0; - LTDC_Layer_InitStruct.LTDC_DefaultColorGreen = 0; - LTDC_Layer_InitStruct.LTDC_DefaultColorRed = 0; + LTDC_Layer_InitStruct.LTDC_ConstantAlpha = 255; + /* Default Color configuration (configure A,R,G,B component values) */ + LTDC_Layer_InitStruct.LTDC_DefaultColorBlue = 0; + LTDC_Layer_InitStruct.LTDC_DefaultColorGreen = 0; + LTDC_Layer_InitStruct.LTDC_DefaultColorRed = 0; LTDC_Layer_InitStruct.LTDC_DefaultColorAlpha = 0; - /* Configure blending factors */ - LTDC_Layer_InitStruct.LTDC_BlendingFactor_1 = LTDC_BlendingFactor1_CA; + /* Configure blending factors */ + LTDC_Layer_InitStruct.LTDC_BlendingFactor_1 = LTDC_BlendingFactor1_CA; LTDC_Layer_InitStruct.LTDC_BlendingFactor_2 = LTDC_BlendingFactor2_CA; - + /* the length of one line of pixels in bytes + 3 then : - Line Lenth = Active high width x number of bytes per pixel + 3 - Active high width = LCD_PIXEL_WIDTH - number of bytes per pixel = 2 (pixel_format : RGB565) + Line Lenth = Active high width x number of bytes per pixel + 3 + Active high width = LCD_PIXEL_WIDTH + number of bytes per pixel = 2 (pixel_format : RGB565) */ LTDC_Layer_InitStruct.LTDC_CFBLineLength = ((LCD_PIXEL_WIDTH * 2) + 3); - /* the pitch is the increment from the start of one line of pixels to the + /* the pitch is the increment from the start of one line of pixels to the start of the next line in bytes, then : - Pitch = Active high width x number of bytes per pixel */ + Pitch = Active high width x number of bytes per pixel */ LTDC_Layer_InitStruct.LTDC_CFBPitch = (LCD_PIXEL_WIDTH * 2); - - /* Configure the number of lines */ + + /* Configure the number of lines */ LTDC_Layer_InitStruct.LTDC_CFBLineNumber = LCD_PIXEL_HEIGHT; - - /* Start Address configuration : the LCD Frame buffer is defined on SDRAM */ + + /* Start Address configuration : the LCD Frame buffer is defined on SDRAM */ LTDC_Layer_InitStruct.LTDC_CFBStartAdress = LCD_FRAME_BUFFER; - + /* Initialize LTDC layer 1 */ LTDC_LayerInit(LTDC_Layer1, <DC_Layer_InitStruct); - + /* Configure Layer2 */ - /* Start Address configuration : the LCD Frame buffer is defined on SDRAM w/ Offset */ + /* Start Address configuration : the LCD Frame buffer is defined on SDRAM w/ Offset */ LTDC_Layer_InitStruct.LTDC_CFBStartAdress = LCD_FRAME_BUFFER + BUFFER_OFFSET; - - /* Configure blending factors */ - LTDC_Layer_InitStruct.LTDC_BlendingFactor_1 = LTDC_BlendingFactor1_PAxCA; + + /* Configure blending factors */ + LTDC_Layer_InitStruct.LTDC_BlendingFactor_1 = LTDC_BlendingFactor1_PAxCA; LTDC_Layer_InitStruct.LTDC_BlendingFactor_2 = LTDC_BlendingFactor2_PAxCA; - + /* Initialize LTDC layer 2 */ LTDC_LayerInit(LTDC_Layer2, <DC_Layer_InitStruct); - - /* LTDC configuration reload */ + + /* LTDC configuration reload */ LTDC_ReloadConfig(LTDC_IMReload); - + /* Enable foreground & background Layers */ - LTDC_LayerCmd(LTDC_Layer1, ENABLE); + LTDC_LayerCmd(LTDC_Layer1, ENABLE); LTDC_LayerCmd(LTDC_Layer2, ENABLE); - - /* LTDC configuration reload */ + + /* LTDC configuration reload */ LTDC_ReloadConfig(LTDC_IMReload); - - /* Set default font */ - LCD_SetFont(&LCD_DEFAULT_FONT); - + + /* Set default font */ + LCD_SetFont(&LCD_DEFAULT_FONT); + /* dithering activation */ LTDC_DitherCmd(ENABLE); } @@ -417,7 +443,7 @@ void LCD_SetLayer(uint32_t Layerx) { if (Layerx == LCD_BACKGROUND_LAYER) { - CurrentFrameBuffer = LCD_FRAME_BUFFER; + CurrentFrameBuffer = LCD_FRAME_BUFFER; CurrentLayer = LCD_BACKGROUND_LAYER; } else @@ -425,7 +451,7 @@ void LCD_SetLayer(uint32_t Layerx) CurrentFrameBuffer = LCD_FRAME_BUFFER + BUFFER_OFFSET; CurrentLayer = LCD_FOREGROUND_LAYER; } -} +} /** * @brief Sets the LCD Text and Background colors. @@ -435,15 +461,15 @@ void LCD_SetLayer(uint32_t Layerx) */ void LCD_SetColors(uint16_t TextColor, uint16_t BackColor) { - CurrentTextColor = TextColor; + CurrentTextColor = TextColor; CurrentBackColor = BackColor; } /** * @brief Gets the LCD Text and Background colors. - * @param TextColor: pointer to the variable that will contain the Text + * @param TextColor: pointer to the variable that will contain the Text Color. - * @param BackColor: pointer to the variable that will contain the Background + * @param BackColor: pointer to the variable that will contain the Background Color. * @retval None */ @@ -485,7 +511,7 @@ void LCD_SetFont(sFONT *fonts) /** * @brief Configure the transparency. - * @param transparency: specifies the transparency, + * @param transparency: specifies the transparency, * This parameter must range from 0x00 to 0xFF. * @retval None */ @@ -496,7 +522,7 @@ void LCD_SetTransparency(uint8_t transparency) LTDC_LayerAlpha(LTDC_Layer1, transparency); } else - { + { LTDC_LayerAlpha(LTDC_Layer2, transparency); } LTDC_ReloadConfig(LTDC_IMReload); @@ -542,41 +568,41 @@ void LCD_ClearLine(uint16_t Line) void LCD_Clear(uint16_t Color) { uint32_t index = 0; - + /* erase memory */ for (index = 0x00; index < BUFFER_OFFSET; index++) { *(__IO uint16_t*)(CurrentFrameBuffer + (2*index)) = Color; - } + } } /** * @brief Sets the cursor position. * @param Xpos: specifies the X position. - * @param Ypos: specifies the Y position. + * @param Ypos: specifies the Y position. * @retval Display Address */ uint32_t LCD_SetCursor(uint16_t Xpos, uint16_t Ypos) -{ +{ return CurrentFrameBuffer + 2*(Xpos + (LCD_PIXEL_WIDTH*Ypos)); } /** * @brief Config and Sets the color Keying. - * @param RGBValue: Specifies the Color reference. + * @param RGBValue: Specifies the Color reference. * @retval None */ void LCD_SetColorKeying(uint32_t RGBValue) -{ +{ LTDC_ColorKeying_InitTypeDef LTDC_colorkeying_InitStruct; - + /* configure the color Keying */ LTDC_colorkeying_InitStruct.LTDC_ColorKeyBlue = 0x0000FF & RGBValue; LTDC_colorkeying_InitStruct.LTDC_ColorKeyGreen = (0x00FF00 & RGBValue) >> 8; - LTDC_colorkeying_InitStruct.LTDC_ColorKeyRed = (0xFF0000 & RGBValue) >> 16; + LTDC_colorkeying_InitStruct.LTDC_ColorKeyRed = (0xFF0000 & RGBValue) >> 16; if (CurrentLayer == LCD_BACKGROUND_LAYER) - { + { /* Enable the color Keying for Layer1 */ LTDC_ColorKeyingConfig(LTDC_Layer1, <DC_colorkeying_InitStruct, ENABLE); LTDC_ReloadConfig(LTDC_IMReload); @@ -591,15 +617,15 @@ void LCD_SetColorKeying(uint32_t RGBValue) /** * @brief Disable the color Keying. - * @param RGBValue: Specifies the Color reference. + * @param RGBValue: Specifies the Color reference. * @retval None */ void LCD_ReSetColorKeying(void) { LTDC_ColorKeying_InitTypeDef LTDC_colorkeying_InitStruct; - + if (CurrentLayer == LCD_BACKGROUND_LAYER) - { + { /* Disable the color Keying for Layer1 */ LTDC_ColorKeyingConfig(LTDC_Layer1, <DC_colorkeying_InitStruct, DISABLE); LTDC_ReloadConfig(LTDC_IMReload); @@ -610,7 +636,7 @@ void LCD_ReSetColorKeying(void) LTDC_ColorKeyingConfig(LTDC_Layer2, <DC_colorkeying_InitStruct, DISABLE); LTDC_ReloadConfig(LTDC_IMReload); } -} +} /** * @brief Draws a character on LCD. @@ -623,16 +649,16 @@ void LCD_DrawChar(uint16_t Xpos, uint16_t Ypos, const uint16_t *c) { uint32_t index = 0, counter = 0, xpos =0; uint32_t Xaddress = 0; - + xpos = Xpos*LCD_PIXEL_WIDTH*2; Xaddress += Ypos; - + for(index = 0; index < LCD_Currentfonts->Height; index++) { - + for(counter = 0; counter < LCD_Currentfonts->Width; counter++) { - + if((((c[index] & ((0x80 << ((LCD_Currentfonts->Width / 12 ) * 8 ) ) >> counter)) == 0x00) &&(LCD_Currentfonts->Width <= 12))|| (((c[index] & (0x1 << counter)) == 0x00)&&(LCD_Currentfonts->Width > 12 ))) { @@ -642,7 +668,7 @@ void LCD_DrawChar(uint16_t Xpos, uint16_t Ypos, const uint16_t *c) else { /* Write data value to all SDRAM memory */ - *(__IO uint16_t*) (CurrentFrameBuffer + (2*Xaddress) + xpos) = CurrentTextColor; + *(__IO uint16_t*) (CurrentFrameBuffer + (2*Xaddress) + xpos) = CurrentTextColor; } Xaddress++; } @@ -675,7 +701,7 @@ void LCD_DisplayChar(uint16_t Line, uint16_t Column, uint8_t Ascii) * @retval None */ void LCD_DisplayStringLine(uint16_t Line, uint8_t *ptr) -{ +{ uint16_t refcolumn = 0; /* Send the string character by character on lCD */ while ((refcolumn < LCD_PIXEL_WIDTH) && ((*ptr != 0) & (((refcolumn + LCD_Currentfonts->Width) & 0xFFFF) >= LCD_Currentfonts->Width))) @@ -701,21 +727,21 @@ void LCD_SetDisplayWindow(uint16_t Xpos, uint16_t Ypos, uint16_t Height, uint16_ { if (CurrentLayer == LCD_BACKGROUND_LAYER) - { + { /* reconfigure the layer1 position */ LTDC_LayerPosition(LTDC_Layer1, Xpos, Ypos); LTDC_ReloadConfig(LTDC_IMReload); - + /* reconfigure the layer1 size */ LTDC_LayerSize(LTDC_Layer1, Width, Height); LTDC_ReloadConfig(LTDC_IMReload); } else - { + { /* reconfigure the layer2 position */ LTDC_LayerPosition(LTDC_Layer2, Xpos, Ypos); - LTDC_ReloadConfig(LTDC_IMReload); - + LTDC_ReloadConfig(LTDC_IMReload); + /* reconfigure the layer2 size */ LTDC_LayerSize(LTDC_Layer2, Width, Height); LTDC_ReloadConfig(LTDC_IMReload); @@ -729,7 +755,7 @@ void LCD_SetDisplayWindow(uint16_t Xpos, uint16_t Ypos, uint16_t Height, uint16_ */ void LCD_WindowModeDisable(void) { - LCD_SetDisplayWindow(0, 0, LCD_PIXEL_HEIGHT, LCD_PIXEL_WIDTH); + LCD_SetDisplayWindow(0, 0, LCD_PIXEL_HEIGHT, LCD_PIXEL_WIDTH); } /** @@ -744,47 +770,47 @@ void LCD_WindowModeDisable(void) void LCD_DrawLine(uint16_t Xpos, uint16_t Ypos, uint16_t Length, uint8_t Direction) { DMA2D_InitTypeDef DMA2D_InitStruct; - + uint32_t Xaddress = 0; uint16_t Red_Value = 0, Green_Value = 0, Blue_Value = 0; - + Xaddress = CurrentFrameBuffer + 2*(LCD_PIXEL_WIDTH*Ypos + Xpos); - + Red_Value = (0xF800 & CurrentTextColor) >> 11; Blue_Value = 0x001F & CurrentTextColor; Green_Value = (0x07E0 & CurrentTextColor) >> 5; - /* Configure DMA2D */ - DMA2D_DeInit(); - DMA2D_InitStruct.DMA2D_Mode = DMA2D_R2M; - DMA2D_InitStruct.DMA2D_CMode = DMA2D_RGB565; - DMA2D_InitStruct.DMA2D_OutputGreen = Green_Value; - DMA2D_InitStruct.DMA2D_OutputBlue = Blue_Value; - DMA2D_InitStruct.DMA2D_OutputRed = Red_Value; - DMA2D_InitStruct.DMA2D_OutputAlpha = 0x0F; - DMA2D_InitStruct.DMA2D_OutputMemoryAdd = Xaddress; - + /* Configure DMA2D */ + DMA2D_DeInit(); + DMA2D_InitStruct.DMA2D_Mode = DMA2D_R2M; + DMA2D_InitStruct.DMA2D_CMode = DMA2D_RGB565; + DMA2D_InitStruct.DMA2D_OutputGreen = Green_Value; + DMA2D_InitStruct.DMA2D_OutputBlue = Blue_Value; + DMA2D_InitStruct.DMA2D_OutputRed = Red_Value; + DMA2D_InitStruct.DMA2D_OutputAlpha = 0x0F; + DMA2D_InitStruct.DMA2D_OutputMemoryAdd = Xaddress; + if(Direction == LCD_DIR_HORIZONTAL) - { - DMA2D_InitStruct.DMA2D_OutputOffset = 0; - DMA2D_InitStruct.DMA2D_NumberOfLine = 1; - DMA2D_InitStruct.DMA2D_PixelPerLine = Length; + { + 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; + { + DMA2D_InitStruct.DMA2D_OutputOffset = LCD_PIXEL_WIDTH - 1; + DMA2D_InitStruct.DMA2D_NumberOfLine = Length; + DMA2D_InitStruct.DMA2D_PixelPerLine = 1; } - - DMA2D_Init(&DMA2D_InitStruct); - /* Start Transfer */ - DMA2D_StartTransfer(); + + DMA2D_Init(&DMA2D_InitStruct); + /* Start Transfer */ + DMA2D_StartTransfer(); /* Wait for CTC Flag activation */ while(DMA2D_GetFlagStatus(DMA2D_FLAG_TC) == RESET) { } - + } /** @@ -800,7 +826,7 @@ void LCD_DrawRect(uint16_t Xpos, uint16_t Ypos, uint16_t Height, uint16_t Width) /* draw horizontal lines */ LCD_DrawLine(Xpos, Ypos, Width, LCD_DIR_HORIZONTAL); LCD_DrawLine(Xpos, (Ypos+ Height), Width, LCD_DIR_HORIZONTAL); - + /* draw vertical lines */ LCD_DrawLine(Xpos, Ypos, Height, LCD_DIR_VERTICAL); LCD_DrawLine((Xpos + Width), Ypos, Height, LCD_DIR_VERTICAL); @@ -817,11 +843,11 @@ void LCD_DrawCircle(uint16_t Xpos, uint16_t Ypos, uint16_t Radius) { int x = -Radius, y = 0, err = 2-2*Radius, e2; do { - *(__IO uint16_t*) (CurrentFrameBuffer + (2*((Xpos-x) + LCD_PIXEL_WIDTH*(Ypos+y)))) = CurrentTextColor; + *(__IO uint16_t*) (CurrentFrameBuffer + (2*((Xpos-x) + LCD_PIXEL_WIDTH*(Ypos+y)))) = CurrentTextColor; *(__IO uint16_t*) (CurrentFrameBuffer + (2*((Xpos+x) + LCD_PIXEL_WIDTH*(Ypos+y)))) = CurrentTextColor; *(__IO uint16_t*) (CurrentFrameBuffer + (2*((Xpos+x) + LCD_PIXEL_WIDTH*(Ypos-y)))) = CurrentTextColor; *(__IO uint16_t*) (CurrentFrameBuffer + (2*((Xpos-x) + LCD_PIXEL_WIDTH*(Ypos-y)))) = CurrentTextColor; - + e2 = err; if (e2 <= y) { err += ++y*2+1; @@ -837,48 +863,48 @@ void LCD_DrawCircle(uint16_t Xpos, uint16_t Ypos, uint16_t Radius) * @param Xpos: specifies the X position, can be a value from 0 to 240. * @param Ypos: specifies the Y position, can be a value from 0 to 320. * @param Radius: minor radius of ellipse. - * @param Radius2: major radius of ellipse. + * @param Radius2: major radius of ellipse. * @retval None */ void LCD_DrawFullEllipse(int Xpos, int Ypos, int Radius, int Radius2) { int x = -Radius, y = 0, err = 2-2*Radius, e2; float K = 0, rad1 = 0, rad2 = 0; - + rad1 = Radius; rad2 = Radius2; - + if (Radius > Radius2) - { - do + { + do { K = (float)(rad1/rad2); LCD_DrawLine((Xpos+x), (Ypos-(uint16_t)(y/K)), (2*(uint16_t)(y/K) + 1), LCD_DIR_VERTICAL); LCD_DrawLine((Xpos-x), (Ypos-(uint16_t)(y/K)), (2*(uint16_t)(y/K) + 1), LCD_DIR_VERTICAL); - + e2 = err; - if (e2 <= y) + if (e2 <= y) { err += ++y*2+1; if (-x == y && e2 <= x) e2 = 0; } if (e2 > x) err += ++x*2+1; - + } while (x <= 0); } else { - y = -Radius2; + y = -Radius2; x = 0; - do - { - K = (float)(rad2/rad1); + do + { + K = (float)(rad2/rad1); LCD_DrawLine((Xpos-(uint16_t)(x/K)), (Ypos+y), (2*(uint16_t)(x/K) + 1), LCD_DIR_HORIZONTAL); LCD_DrawLine((Xpos-(uint16_t)(x/K)), (Ypos-y), (2*(uint16_t)(x/K) + 1), LCD_DIR_HORIZONTAL); - + e2 = err; - if (e2 <= x) + if (e2 <= x) { err += ++x*2+1; if (-y == x && e2 <= y) e2 = 0; @@ -901,19 +927,19 @@ void LCD_DrawEllipse(int Xpos, int Ypos, int Radius, int Radius2) { int x = -Radius, y = 0, err = 2-2*Radius, e2; float K = 0, rad1 = 0, rad2 = 0; - + rad1 = Radius; rad2 = Radius2; - + if (Radius > Radius2) - { + { do { K = (float)(rad1/rad2); - *(__IO uint16_t*) (CurrentFrameBuffer + (2*((Xpos-x) + LCD_PIXEL_WIDTH*(Ypos+(uint16_t)(y/K))))) = CurrentTextColor; + *(__IO uint16_t*) (CurrentFrameBuffer + (2*((Xpos-x) + LCD_PIXEL_WIDTH*(Ypos+(uint16_t)(y/K))))) = CurrentTextColor; *(__IO uint16_t*) (CurrentFrameBuffer + (2*((Xpos+x) + LCD_PIXEL_WIDTH*(Ypos+(uint16_t)(y/K))))) = CurrentTextColor; *(__IO uint16_t*) (CurrentFrameBuffer + (2*((Xpos+x) + LCD_PIXEL_WIDTH*(Ypos-(uint16_t)(y/K))))) = CurrentTextColor; *(__IO uint16_t*) (CurrentFrameBuffer + (2*((Xpos-x) + LCD_PIXEL_WIDTH*(Ypos-(uint16_t)(y/K))))) = CurrentTextColor; - + e2 = err; if (e2 <= y) { err += ++y*2+1; @@ -925,21 +951,21 @@ void LCD_DrawEllipse(int Xpos, int Ypos, int Radius, int Radius2) } else { - y = -Radius2; + y = -Radius2; x = 0; - do { + do { K = (float)(rad2/rad1); - *(__IO uint16_t*) (CurrentFrameBuffer + (2*((Xpos-(uint16_t)(x/K)) + LCD_PIXEL_WIDTH*(Ypos+y)))) = CurrentTextColor; + *(__IO uint16_t*) (CurrentFrameBuffer + (2*((Xpos-(uint16_t)(x/K)) + LCD_PIXEL_WIDTH*(Ypos+y)))) = CurrentTextColor; *(__IO uint16_t*) (CurrentFrameBuffer + (2*((Xpos+(uint16_t)(x/K)) + LCD_PIXEL_WIDTH*(Ypos+y)))) = CurrentTextColor; *(__IO uint16_t*) (CurrentFrameBuffer + (2*((Xpos+(uint16_t)(x/K)) + LCD_PIXEL_WIDTH*(Ypos-y)))) = CurrentTextColor; *(__IO uint16_t*) (CurrentFrameBuffer + (2*((Xpos-(uint16_t)(x/K)) + LCD_PIXEL_WIDTH*(Ypos-y)))) = CurrentTextColor; - + e2 = err; if (e2 <= x) { err += ++x*2+1; if (-y == x && e2 <= y) e2 = 0; } - if (e2 > y) err += ++y*2+1; + if (e2 > y) err += ++y*2+1; } while (y <= 0); } @@ -953,8 +979,8 @@ void LCD_DrawEllipse(int Xpos, int Ypos, int Radius, int Radius2) void LCD_DrawMonoPict(const uint32_t *Pict) { uint32_t index = 0, counter = 0; - - + + for(index = 0; index < 2400; index++) { for(counter = 0; counter < 32; counter++) @@ -981,13 +1007,13 @@ void LCD_WriteBMP(uint32_t BmpAddress) uint32_t index = 0, size = 0, width = 0, height = 0, bit_pixel = 0; uint32_t Address; uint32_t currentline = 0, linenumber = 0; - + Address = CurrentFrameBuffer; /* Read bitmap size */ size = *(__IO uint16_t *) (BmpAddress + 2); size |= (*(__IO uint16_t *) (BmpAddress + 4)) << 16; - + /* Get bitmap data address offset */ index = *(__IO uint16_t *) (BmpAddress + 10); index |= (*(__IO uint16_t *) (BmpAddress + 12)) << 16; @@ -1001,15 +1027,15 @@ void LCD_WriteBMP(uint32_t BmpAddress) height |= (*(uint16_t *) (BmpAddress + 24)) << 16; /* Read bit/pixel */ - bit_pixel = *(uint16_t *) (BmpAddress + 28); - + bit_pixel = *(uint16_t *) (BmpAddress + 28); + if (CurrentLayer == LCD_BACKGROUND_LAYER) { /* reconfigure layer size in accordance with the picture */ LTDC_LayerSize(LTDC_Layer1, width, height); LTDC_ReloadConfig(LTDC_VBReload); - /* Reconfigure the Layer pixel format in accordance with the picture */ + /* Reconfigure the Layer pixel format in accordance with the picture */ if ((bit_pixel/8) == 4) { LTDC_LayerPixelFormat(LTDC_Layer1, LTDC_Pixelformat_ARGB8888); @@ -1020,18 +1046,18 @@ void LCD_WriteBMP(uint32_t BmpAddress) LTDC_LayerPixelFormat(LTDC_Layer1, LTDC_Pixelformat_RGB565); LTDC_ReloadConfig(LTDC_VBReload); } - else + else { LTDC_LayerPixelFormat(LTDC_Layer1, LTDC_Pixelformat_RGB888); LTDC_ReloadConfig(LTDC_VBReload); - } + } } else { /* reconfigure layer size in accordance with the picture */ LTDC_LayerSize(LTDC_Layer2, width, height); - LTDC_ReloadConfig(LTDC_VBReload); - + LTDC_ReloadConfig(LTDC_VBReload); + /* Reconfigure the Layer pixel format in accordance with the picture */ if ((bit_pixel/8) == 4) { @@ -1046,28 +1072,28 @@ void LCD_WriteBMP(uint32_t BmpAddress) else { LTDC_LayerPixelFormat(LTDC_Layer2, LTDC_Pixelformat_RGB888); - LTDC_ReloadConfig(LTDC_VBReload); + LTDC_ReloadConfig(LTDC_VBReload); } } - - /* compute the real size of the picture (without the header)) */ - size = (size - index); + + /* compute the real size of the picture (without the header)) */ + size = (size - index); /* bypass the bitmap header */ BmpAddress += index; /* start copie image from the bottom */ Address += width*(height-1)*(bit_pixel/8); - + for(index = 0; index < size; index++) { *(__IO uint8_t*) (Address) = *(__IO uint8_t *)BmpAddress; - - /*jump on next byte */ + + /*jump on next byte */ BmpAddress++; Address++; currentline++; - + if((currentline/(bit_pixel/8)) == width) { if(linenumber < height) @@ -1091,37 +1117,37 @@ void LCD_WriteBMP(uint32_t BmpAddress) void LCD_DrawFullRect(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height) { DMA2D_InitTypeDef DMA2D_InitStruct; - - uint32_t Xaddress = 0; + + uint32_t Xaddress = 0; uint16_t Red_Value = 0, Green_Value = 0, Blue_Value = 0; - + Red_Value = (0xF800 & CurrentTextColor) >> 11; Blue_Value = 0x001F & CurrentTextColor; Green_Value = (0x07E0 & CurrentTextColor) >> 5; - + Xaddress = CurrentFrameBuffer + 2*(LCD_PIXEL_WIDTH*Ypos + Xpos); - + /* configure DMA2D */ DMA2D_DeInit(); - DMA2D_InitStruct.DMA2D_Mode = DMA2D_R2M; - DMA2D_InitStruct.DMA2D_CMode = DMA2D_RGB565; - DMA2D_InitStruct.DMA2D_OutputGreen = Green_Value; - DMA2D_InitStruct.DMA2D_OutputBlue = Blue_Value; - DMA2D_InitStruct.DMA2D_OutputRed = Red_Value; - DMA2D_InitStruct.DMA2D_OutputAlpha = 0x0F; - DMA2D_InitStruct.DMA2D_OutputMemoryAdd = Xaddress; - DMA2D_InitStruct.DMA2D_OutputOffset = (LCD_PIXEL_WIDTH - Width); - DMA2D_InitStruct.DMA2D_NumberOfLine = Height; + DMA2D_InitStruct.DMA2D_Mode = DMA2D_R2M; + DMA2D_InitStruct.DMA2D_CMode = DMA2D_RGB565; + DMA2D_InitStruct.DMA2D_OutputGreen = Green_Value; + DMA2D_InitStruct.DMA2D_OutputBlue = Blue_Value; + DMA2D_InitStruct.DMA2D_OutputRed = Red_Value; + DMA2D_InitStruct.DMA2D_OutputAlpha = 0x0F; + DMA2D_InitStruct.DMA2D_OutputMemoryAdd = Xaddress; + DMA2D_InitStruct.DMA2D_OutputOffset = (LCD_PIXEL_WIDTH - Width); + DMA2D_InitStruct.DMA2D_NumberOfLine = Height; DMA2D_InitStruct.DMA2D_PixelPerLine = Width; - DMA2D_Init(&DMA2D_InitStruct); - - /* Start Transfer */ + DMA2D_Init(&DMA2D_InitStruct); + + /* Start Transfer */ DMA2D_StartTransfer(); - + /* Wait for CTC Flag activation */ while(DMA2D_GetFlagStatus(DMA2D_FLAG_TC) == RESET) { - } + } LCD_SetTextColor(CurrentTextColor); } @@ -1135,30 +1161,30 @@ void LCD_DrawFullRect(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Hei */ void LCD_DrawFullCircle(uint16_t Xpos, uint16_t Ypos, uint16_t Radius) { - int32_t D; /* Decision Variable */ + int32_t D; /* Decision Variable */ uint32_t CurX;/* Current X Value */ - uint32_t CurY;/* Current Y Value */ - + uint32_t CurY;/* Current Y Value */ + D = 3 - (Radius << 1); - + CurX = 0; CurY = Radius; - + while (CurX <= CurY) { - if(CurY > 0) + if(CurY > 0) { LCD_DrawLine(Xpos - CurX, Ypos - CurY, 2*CurY, LCD_DIR_VERTICAL); LCD_DrawLine(Xpos + CurX, Ypos - CurY, 2*CurY, LCD_DIR_VERTICAL); } - - if(CurX > 0) + + if(CurX > 0) { LCD_DrawLine(Xpos - CurY, Ypos - CurX, 2*CurX, LCD_DIR_VERTICAL); LCD_DrawLine(Xpos + CurY, Ypos - CurX, 2*CurX, LCD_DIR_VERTICAL); } if (D < 0) - { + { D += (CurX << 2) + 6; } else @@ -1168,8 +1194,8 @@ void LCD_DrawFullCircle(uint16_t Xpos, uint16_t Ypos, uint16_t Radius) } CurX++; } - - LCD_DrawCircle(Xpos, Ypos, Radius); + + LCD_DrawCircle(Xpos, Ypos, Radius); } /** @@ -1182,15 +1208,15 @@ void LCD_DrawFullCircle(uint16_t Xpos, uint16_t Ypos, uint16_t Radius) */ void LCD_DrawUniLine(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2) { - int16_t deltax = 0, deltay = 0, x = 0, y = 0, xinc1 = 0, xinc2 = 0, - yinc1 = 0, yinc2 = 0, den = 0, num = 0, numadd = 0, numpixels = 0, + int16_t deltax = 0, deltay = 0, x = 0, y = 0, xinc1 = 0, xinc2 = 0, + yinc1 = 0, yinc2 = 0, den = 0, num = 0, numadd = 0, numpixels = 0, curpixel = 0; - + deltax = ABS(x2 - x1); /* The difference between the x's */ deltay = ABS(y2 - y1); /* The difference between the y's */ x = x1; /* Start x off at the first pixel */ y = y1; /* Start y off at the first pixel */ - + if (x2 >= x1) /* The x-values are increasing */ { xinc1 = 1; @@ -1201,7 +1227,7 @@ void LCD_DrawUniLine(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2) xinc1 = -1; xinc2 = -1; } - + if (y2 >= y1) /* The y-values are increasing */ { yinc1 = 1; @@ -1212,7 +1238,7 @@ void LCD_DrawUniLine(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2) yinc1 = -1; yinc2 = -1; } - + if (deltax >= deltay) /* There is at least one x-value for every y-value */ { xinc1 = 0; /* Don't change the x when numerator >= denominator */ @@ -1231,7 +1257,7 @@ void LCD_DrawUniLine(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2) numadd = deltax; numpixels = deltay; /* There are more y-values than x-values */ } - + for (curpixel = 0; curpixel <= numpixels; curpixel++) { PutPixel(x, y); /* Draw the current pixel */ @@ -1279,17 +1305,17 @@ void LCD_Triangle(pPoint Points, uint16_t PointCount) * @retval None */ void LCD_FillTriangle(uint16_t x1, uint16_t x2, uint16_t x3, uint16_t y1, uint16_t y2, uint16_t y3) -{ - - int16_t deltax = 0, deltay = 0, x = 0, y = 0, xinc1 = 0, xinc2 = 0, - yinc1 = 0, yinc2 = 0, den = 0, num = 0, numadd = 0, numpixels = 0, +{ + + int16_t deltax = 0, deltay = 0, x = 0, y = 0, xinc1 = 0, xinc2 = 0, + yinc1 = 0, yinc2 = 0, den = 0, num = 0, numadd = 0, numpixels = 0, curpixel = 0; - + deltax = ABS(x2 - x1); /* The difference between the x's */ deltay = ABS(y2 - y1); /* The difference between the y's */ x = x1; /* Start x off at the first pixel */ y = y1; /* Start y off at the first pixel */ - + if (x2 >= x1) /* The x-values are increasing */ { xinc1 = 1; @@ -1300,7 +1326,7 @@ void LCD_FillTriangle(uint16_t x1, uint16_t x2, uint16_t x3, uint16_t y1, uint16 xinc1 = -1; xinc2 = -1; } - + if (y2 >= y1) /* The y-values are increasing */ { yinc1 = 1; @@ -1311,7 +1337,7 @@ void LCD_FillTriangle(uint16_t x1, uint16_t x2, uint16_t x3, uint16_t y1, uint16 yinc1 = -1; yinc2 = -1; } - + if (deltax >= deltay) /* There is at least one x-value for every y-value */ { xinc1 = 0; /* Don't change the x when numerator >= denominator */ @@ -1330,11 +1356,11 @@ void LCD_FillTriangle(uint16_t x1, uint16_t x2, uint16_t x3, uint16_t y1, uint16 numadd = deltax; numpixels = deltay; /* There are more y-values than x-values */ } - + for (curpixel = 0; curpixel <= numpixels; curpixel++) { LCD_DrawUniLine(x, y, x3, y3); - + num += numadd; /* Increase the numerator by the top of the fraction */ if (num >= den) /* Check if numerator >= denominator */ { @@ -1344,9 +1370,9 @@ void LCD_FillTriangle(uint16_t x1, uint16_t x2, uint16_t x3, uint16_t y1, uint16 } x += xinc2; /* Change the x as appropriate */ y += yinc2; /* Change the y as appropriate */ - } - - + } + + } /** * @brief Displays an poly-line (between many points). @@ -1388,7 +1414,7 @@ static void LCD_PolyLineRelativeClosed(pPoint Points, uint16_t PointCount, uint1 if(PointCount < 2) { return; - } + } X = Points->X; Y = Points->Y; while(--PointCount) @@ -1401,7 +1427,7 @@ static void LCD_PolyLineRelativeClosed(pPoint Points, uint16_t PointCount, uint1 if(Closed) { LCD_DrawUniLine(First->X, First->Y, X, Y); - } + } } /** @@ -1446,9 +1472,9 @@ void LCD_ClosedPolyLineRelative(pPoint Points, uint16_t PointCount) */ void LCD_FillPolyLine(pPoint Points, uint16_t PointCount) { - + int16_t X = 0, Y = 0, X2 = 0, Y2 = 0, X_center = 0, Y_center = 0, X_first = 0, Y_first = 0, pixelX = 0, pixelY = 0, counter = 0; - uint16_t IMAGE_LEFT = 0, IMAGE_RIGHT = 0, IMAGE_TOP = 0, IMAGE_BOTTOM = 0; + uint16_t IMAGE_LEFT = 0, IMAGE_RIGHT = 0, IMAGE_TOP = 0, IMAGE_BOTTOM = 0; IMAGE_LEFT = IMAGE_RIGHT = Points->X; IMAGE_TOP= IMAGE_BOTTOM = Points->Y; @@ -1464,45 +1490,45 @@ void LCD_FillPolyLine(pPoint Points, uint16_t PointCount) { IMAGE_RIGHT = pixelX; } - + pixelY = POLY_Y(counter); if(pixelY < IMAGE_TOP) - { + { IMAGE_TOP = pixelY; } if(pixelY > IMAGE_BOTTOM) { IMAGE_BOTTOM = pixelY; } - } - + } + if(PointCount < 2) { return; } - + X_center = (IMAGE_LEFT + IMAGE_RIGHT)/2; Y_center = (IMAGE_BOTTOM + IMAGE_TOP)/2; - + X_first = Points->X; Y_first = Points->Y; - + while(--PointCount) { X = Points->X; Y = Points->Y; Points++; X2 = Points->X; - Y2 = Points->Y; - + Y2 = Points->Y; + LCD_FillTriangle(X, X2, X_center, Y, Y2, Y_center); LCD_FillTriangle(X, X_center, X2, Y, Y_center, Y2); - LCD_FillTriangle(X_center, X2, X, Y_center, Y2, Y); + LCD_FillTriangle(X_center, X2, X, Y_center, Y2, Y); } - + LCD_FillTriangle(X_first, X2, X_center, Y_first, Y2, Y_center); LCD_FillTriangle(X_first, X_center, X2, Y_first, Y_center, Y2); - LCD_FillTriangle(X_center, X2, X_first, Y_center, Y2, Y_first); + LCD_FillTriangle(X_center, X2, X_first, Y_center, Y2, Y_first); } /** @@ -1512,20 +1538,15 @@ void LCD_FillPolyLine(pPoint Points, uint16_t PointCount) */ void LCD_WriteCommand(uint8_t LCD_Reg) { - /* Reset WRX to send command */ - LCD_CtrlLinesWrite(LCD_WRX_GPIO_PORT, LCD_WRX_PIN, Bit_RESET); - - /* Reset LCD control line(/CS) and Send command */ - LCD_ChipSelect(DISABLE); - SPI_I2S_SendData(LCD_SPI, LCD_Reg); - - /* Wait until a data is sent(not busy), before config /CS HIGH */ - - while(SPI_I2S_GetFlagStatus(LCD_SPI, SPI_I2S_FLAG_TXE) == RESET) ; - + gpio_set(lcd_wrx, 0); + + gpio_set(lcd_ncs, 0); + + ssp_write(ssp_5, LCD_Reg); + while(SPI_I2S_GetFlagStatus(LCD_SPI, SPI_I2S_FLAG_BSY) != RESET); - - LCD_ChipSelect(ENABLE); + + gpio_set(lcd_ncs, 1); } /** @@ -1536,20 +1557,15 @@ void LCD_WriteCommand(uint8_t LCD_Reg) */ void LCD_WriteData(uint8_t value) { - /* Set WRX to send data */ - LCD_CtrlLinesWrite(LCD_WRX_GPIO_PORT, LCD_WRX_PIN, Bit_SET); - - /* Reset LCD control line(/CS) and Send data */ - LCD_ChipSelect(DISABLE); - SPI_I2S_SendData(LCD_SPI, value); - - /* Wait until a data is sent(not busy), before config /CS HIGH */ - - while(SPI_I2S_GetFlagStatus(LCD_SPI, SPI_I2S_FLAG_TXE) == RESET) ; - + gpio_set(lcd_wrx, 1); + + gpio_set(lcd_ncs, 0); + + ssp_write(ssp_5, value); + while(SPI_I2S_GetFlagStatus(LCD_SPI, SPI_I2S_FLAG_BSY) != RESET); - - LCD_ChipSelect(ENABLE); + + gpio_set(lcd_ncs, 1); } /** @@ -1630,13 +1646,13 @@ void LCD_PowerOn(void) LCD_WriteData(0x01); LCD_WriteData(0x00); LCD_WriteData(0x06); - + LCD_WriteCommand(LCD_GRAM); delay(200); - + LCD_WriteCommand(LCD_GAMMA); LCD_WriteData(0x01); - + LCD_WriteCommand(LCD_PGAMMA); LCD_WriteData(0x0F); LCD_WriteData(0x29); @@ -1669,7 +1685,7 @@ void LCD_PowerOn(void) LCD_WriteData(0x28); LCD_WriteData(0x2F); LCD_WriteData(0x0F); - + LCD_WriteCommand(LCD_SLEEP_OUT); delay(200); LCD_WriteCommand(LCD_DISPLAY_ON); @@ -1698,36 +1714,6 @@ void LCD_DisplayOff(void) LCD_WriteCommand(LCD_DISPLAY_OFF); } -/** - * @brief Configures LCD control lines in Output Push-Pull mode. - * @note The LCD_NCS line can be configured in Open Drain mode - * when VDDIO is lower than required LCD supply. - * @param None - * @retval None - */ -void LCD_CtrlLinesConfig(void) -{ - GPIO_InitTypeDef GPIO_InitStructure; - - /* Enable GPIOs clock*/ - RCC_AHB1PeriphClockCmd(LCD_NCS_GPIO_CLK | LCD_WRX_GPIO_CLK, ENABLE); - - /* Configure NCS in Output Push-Pull mode */ - GPIO_InitStructure.GPIO_Pin = LCD_NCS_PIN; - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; - GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; - GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; - GPIO_Init(LCD_NCS_GPIO_PORT, &GPIO_InitStructure); - - /* Configure WRX in Output Push-Pull mode */ - GPIO_InitStructure.GPIO_Pin = LCD_WRX_PIN; - GPIO_Init(LCD_WRX_GPIO_PORT, &GPIO_InitStructure); - - /* Set chip select pin high */ - LCD_CtrlLinesWrite(LCD_NCS_GPIO_PORT, LCD_NCS_PIN, Bit_SET); -} - /** * @brief Sets or reset LCD control lines. * @param GPIOx: where x can be B or D to select the GPIO peripheral. @@ -1748,185 +1734,18 @@ void LCD_CtrlLinesWrite(GPIO_TypeDef* GPIOx, uint16_t CtrlPins, BitAction BitVal GPIO_WriteBit(GPIOx, (uint16_t)CtrlPins, (BitAction)BitVal); } -/** - * @brief Configures the LCD_SPI interface. - * @param None - * @retval None - */ -void LCD_SPIConfig(void) -{ - SPI_InitTypeDef SPI_InitStructure; - GPIO_InitTypeDef GPIO_InitStructure; - - /* Enable LCD_SPI_SCK_GPIO_CLK, LCD_SPI_MISO_GPIO_CLK and LCD_SPI_MOSI_GPIO_CLK clock */ - RCC_AHB1PeriphClockCmd(LCD_SPI_SCK_GPIO_CLK | LCD_SPI_MISO_GPIO_CLK | LCD_SPI_MOSI_GPIO_CLK, ENABLE); - - /* Enable LCD_SPI and SYSCFG clock */ - RCC_APB2PeriphClockCmd(LCD_SPI_CLK, ENABLE); - - /* Configure LCD_SPI SCK pin */ - GPIO_InitStructure.GPIO_Pin = LCD_SPI_SCK_PIN; - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_25MHz; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; - GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; - GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN; - GPIO_Init(LCD_SPI_SCK_GPIO_PORT, &GPIO_InitStructure); - - /* Configure LCD_SPI MISO pin */ - GPIO_InitStructure.GPIO_Pin = LCD_SPI_MISO_PIN; - GPIO_Init(LCD_SPI_MISO_GPIO_PORT, &GPIO_InitStructure); - - /* Configure LCD_SPI MOSI pin */ - GPIO_InitStructure.GPIO_Pin = LCD_SPI_MOSI_PIN; - GPIO_Init(LCD_SPI_MOSI_GPIO_PORT, &GPIO_InitStructure); - - /* Connect SPI SCK */ - GPIO_PinAFConfig(LCD_SPI_SCK_GPIO_PORT, LCD_SPI_SCK_SOURCE, LCD_SPI_SCK_AF); - - /* Connect SPI MISO */ - GPIO_PinAFConfig(LCD_SPI_MISO_GPIO_PORT, LCD_SPI_MISO_SOURCE, LCD_SPI_MISO_AF); - - /* Connect SPI MOSI */ - GPIO_PinAFConfig(LCD_SPI_MOSI_GPIO_PORT, LCD_SPI_MOSI_SOURCE, LCD_SPI_MOSI_AF); - - SPI_I2S_DeInit(LCD_SPI); - - /* SPI configuration -------------------------------------------------------*/ - /* If the SPI peripheral is already enabled, don't reconfigure it */ - if ((LCD_SPI->CR1 & SPI_CR1_SPE) == 0) - { - SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex; - SPI_InitStructure.SPI_Mode = SPI_Mode_Master; - SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b; - SPI_InitStructure.SPI_CPOL = SPI_CPOL_Low; - SPI_InitStructure.SPI_CPHA = SPI_CPHA_1Edge; - SPI_InitStructure.SPI_NSS = SPI_NSS_Soft; - /* SPI baudrate is set to 5.6 MHz (PCLK2/SPI_BaudRatePrescaler = 90/16 = 5.625 MHz) - to verify these constraints: - - ILI9341 LCD SPI interface max baudrate is 10MHz for write and 6.66MHz for read - - l3gd20 SPI interface max baudrate is 10MHz for write/read - - PCLK2 frequency is set to 90 MHz - */ - SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_16; - SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB; - SPI_InitStructure.SPI_CRCPolynomial = 7; - SPI_Init(LCD_SPI, &SPI_InitStructure); - - /* Enable L3GD20_SPI */ - SPI_Cmd(LCD_SPI, ENABLE); - } -} - -/** - * @brief GPIO config for LTDC. - * @param None - * @retval None - */ -static void LCD_AF_GPIOConfig(void) -{ - GPIO_InitTypeDef GPIO_InitStruct; - - /* Enable GPIOA, GPIOB, GPIOC, GPIOD, GPIOF, GPIOG AHB Clocks */ - RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOB | \ - RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_GPIOD | \ - RCC_AHB1Periph_GPIOF | RCC_AHB1Periph_GPIOG, ENABLE); - -/* GPIOs Configuration */ -/* - +------------------------+-----------------------+----------------------------+ - + LCD pins assignment + - +------------------------+-----------------------+----------------------------+ - | LCD_TFT R2 <-> PC.10 | LCD_TFT G2 <-> PA.06 | LCD_TFT B2 <-> PD.06 | - | LCD_TFT R3 <-> PB.00 | LCD_TFT G3 <-> PG.10 | LCD_TFT B3 <-> PG.11 | - | LCD_TFT R4 <-> PA.11 | LCD_TFT G4 <-> PB.10 | LCD_TFT B4 <-> PG.12 | - | LCD_TFT R5 <-> PA.12 | LCD_TFT G5 <-> PB.11 | LCD_TFT B5 <-> PA.03 | - | LCD_TFT R6 <-> PB.01 | LCD_TFT G6 <-> PC.07 | LCD_TFT B6 <-> PB.08 | - | LCD_TFT R7 <-> PG.06 | LCD_TFT G7 <-> PD.03 | LCD_TFT B7 <-> PB.09 | - ------------------------------------------------------------------------------- - | LCD_TFT HSYNC <-> PC.06 | LCDTFT VSYNC <-> PA.04 | - | LCD_TFT CLK <-> PG.07 | LCD_TFT DE <-> PF.10 | - ----------------------------------------------------- - -*/ - - /* GPIOA configuration */ - GPIO_PinAFConfig(GPIOA, GPIO_PinSource3, GPIO_AF_LTDC); - GPIO_PinAFConfig(GPIOA, GPIO_PinSource4, GPIO_AF_LTDC); - GPIO_PinAFConfig(GPIOA, GPIO_PinSource6, GPIO_AF_LTDC); - GPIO_PinAFConfig(GPIOA, GPIO_PinSource11, GPIO_AF_LTDC); - GPIO_PinAFConfig(GPIOA, GPIO_PinSource12, GPIO_AF_LTDC); - - GPIO_InitStruct.GPIO_Pin = GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_6 | \ - GPIO_Pin_11 | GPIO_Pin_12; - - GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz; - GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF; - GPIO_InitStruct.GPIO_OType = GPIO_OType_PP; - GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_NOPULL; - GPIO_Init(GPIOA, &GPIO_InitStruct); - - /* GPIOB configuration */ - GPIO_PinAFConfig(GPIOB, GPIO_PinSource0, 0x09); - GPIO_PinAFConfig(GPIOB, GPIO_PinSource1, 0x09); - GPIO_PinAFConfig(GPIOB, GPIO_PinSource8, GPIO_AF_LTDC); - GPIO_PinAFConfig(GPIOB, GPIO_PinSource9, GPIO_AF_LTDC); - GPIO_PinAFConfig(GPIOB, GPIO_PinSource10, GPIO_AF_LTDC); - GPIO_PinAFConfig(GPIOB, GPIO_PinSource11, GPIO_AF_LTDC); - - GPIO_InitStruct.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_8 | \ - GPIO_Pin_9 | GPIO_Pin_10 | GPIO_Pin_11; - - GPIO_Init(GPIOB, &GPIO_InitStruct); - - /* GPIOC configuration */ - GPIO_PinAFConfig(GPIOC, GPIO_PinSource6, GPIO_AF_LTDC); - GPIO_PinAFConfig(GPIOC, GPIO_PinSource7, GPIO_AF_LTDC); - GPIO_PinAFConfig(GPIOC, GPIO_PinSource10, GPIO_AF_LTDC); - - GPIO_InitStruct.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7 | GPIO_Pin_10; - - GPIO_Init(GPIOC, &GPIO_InitStruct); - - /* GPIOD configuration */ - GPIO_PinAFConfig(GPIOD, GPIO_PinSource3, GPIO_AF_LTDC); - GPIO_PinAFConfig(GPIOD, GPIO_PinSource6, GPIO_AF_LTDC); - - GPIO_InitStruct.GPIO_Pin = GPIO_Pin_3 | GPIO_Pin_6; - - GPIO_Init(GPIOD, &GPIO_InitStruct); - - /* GPIOF configuration */ - GPIO_PinAFConfig(GPIOF, GPIO_PinSource10, GPIO_AF_LTDC); - - GPIO_InitStruct.GPIO_Pin = GPIO_Pin_10; - - GPIO_Init(GPIOF, &GPIO_InitStruct); - - /* GPIOG configuration */ - GPIO_PinAFConfig(GPIOG, GPIO_PinSource6, GPIO_AF_LTDC); - GPIO_PinAFConfig(GPIOG, GPIO_PinSource7, GPIO_AF_LTDC); - GPIO_PinAFConfig(GPIOG, GPIO_PinSource10, 0x09); - GPIO_PinAFConfig(GPIOG, GPIO_PinSource11, GPIO_AF_LTDC); - GPIO_PinAFConfig(GPIOG, GPIO_PinSource12, 0x09); - - GPIO_InitStruct.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7 | GPIO_Pin_10 | \ - GPIO_Pin_11 | GPIO_Pin_12; - - GPIO_Init(GPIOG, &GPIO_InitStruct); - -} /** * @brief Displays a pixel. * @param x: pixel x. - * @param y: pixel y. + * @param y: pixel y. * @retval None */ static void PutPixel(int16_t x, int16_t y) -{ +{ if(x < 0 || x > 239 || y < 0 || y > 319) { - return; + return; } LCD_DrawLine(x, y, 1, LCD_DIR_HORIZONTAL); } @@ -1939,30 +1758,9 @@ static void PutPixel(int16_t x, int16_t y) */ static void delay(__IO uint32_t nCount) { - __IO uint32_t index = 0; + __IO uint32_t index = 0; for(index = nCount; index != 0; index--) { } } -#endif /* USE_Delay*/ -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ +#endif diff --git a/uGL/stm32f429i_discovery_lcd.dep b/uGL/stm32f429i_discovery_lcd.dep index 3d40dfb..060b566 100644 --- a/uGL/stm32f429i_discovery_lcd.dep +++ b/uGL/stm32f429i_discovery_lcd.dep @@ -42,4 +42,8 @@ uGL/stm32f429i_discovery_lcd.o: uGL/stm32f429i_discovery_lcd.c \ /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/misc.h \ uGL/stm32f429i_discovery.h uGL/stm32f429i_discovery_sdram.h uGL/fonts.h \ /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_ltdc.h \ - /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_dma2d.h + /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_dma2d.h \ + /Users/tom/Documents/src/uGames/uC-sdk/hardware/include/gpio.h \ + /Users/tom/Documents/src/uGames/uC-sdk/libc/include/decl.h \ + /usr/local/Caskroom/gcc-arm-embedded/7-2017-q4-major/gcc-arm-none-eabi-7-2017-q4-major/lib/gcc/arm-none-eabi/7.2.1/include/stdbool.h \ + /Users/tom/Documents/src/uGames/uC-sdk/hardware/include/ssp.h diff --git a/uGL/stm32f429i_discovery_lcd.h b/uGL/stm32f429i_discovery_lcd.h index 2a2965b..3db34b7 100755 --- a/uGL/stm32f429i_discovery_lcd.h +++ b/uGL/stm32f429i_discovery_lcd.h @@ -4,7 +4,7 @@ * @author MCD Application Team * @version V1.0.1 * @date 28-October-2013 - * @brief This file contains all the functions prototypes for the + * @brief This file contains all the functions prototypes for the * stm32f429i_discovery_lcd.c driver. ****************************************************************************** * @attention @@ -17,8 +17,8 @@ * * http://www.st.com/software_license_agreement_liberty_v2 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. @@ -32,7 +32,7 @@ #ifdef __cplusplus extern "C" { -#endif +#endif /* Includes ------------------------------------------------------------------*/ #include "stm32f4xx.h" @@ -46,48 +46,48 @@ /** @addtogroup STM32F4_DISCOVERY * @{ - */ + */ /** @addtogroup STM32F429I_DISCOVERY * @{ */ - + /** @addtogroup STM32F429I_DISCOVERY_LCD * @{ - */ + */ /** @defgroup STM32F429I_DISCOVERY_LCD_Exported_Types * @{ */ -typedef struct +typedef struct { int16_t X; int16_t Y; -} Point, * pPoint; +} Point, * pPoint; /** * @} - */ + */ /** @defgroup stm32f429i_discovery_LCD_Exported_Constants * @{ - */ + */ /* LCD Size (Width and Height) */ #define LCD_PIXEL_WIDTH ((uint16_t)240) #define LCD_PIXEL_HEIGHT ((uint16_t)320) #define LCD_FRAME_BUFFER ((uint32_t)0xD0000000) -#define BUFFER_OFFSET ((uint32_t)0x50000) +#define BUFFER_OFFSET ((uint32_t)0x50000) /** * @brief Uncomment the line below if you want to use user defined Delay function * (for precise timing), otherwise default _delay_ function defined within - * this driver is used (less precise timing). + * this driver is used (less precise timing). */ /* #define USE_Delay */ #ifdef USE_Delay -#include "main.h" +#include "main.h" #define _delay_ Delay /* !< User can provide more timing precise _delay_ function (with 10ms time base), using SysTick for example */ #else @@ -95,51 +95,51 @@ typedef struct #endif -/** - * @brief LCD Control pin - */ -#define LCD_NCS_PIN GPIO_Pin_2 -#define LCD_NCS_GPIO_PORT GPIOC -#define LCD_NCS_GPIO_CLK RCC_AHB1Periph_GPIOC +/** + * @brief LCD Control pin + */ +#define LCD_NCS_PIN GPIO_Pin_2 +#define LCD_NCS_GPIO_PORT GPIOC +#define LCD_NCS_GPIO_CLK RCC_AHB1Periph_GPIOC -/** - * @brief LCD Command/data pin +/** + * @brief LCD Command/data pin */ -#define LCD_WRX_PIN GPIO_Pin_13 +#define LCD_WRX_PIN GPIO_Pin_13 #define LCD_WRX_GPIO_PORT GPIOD -#define LCD_WRX_GPIO_CLK RCC_AHB1Periph_GPIOD +#define LCD_WRX_GPIO_CLK RCC_AHB1Periph_GPIOD -/** - * @brief LCD SPI Interface pins - */ +/** + * @brief LCD SPI Interface pins + */ #define LCD_SPI_SCK_PIN GPIO_Pin_7 /* PF.07 */ #define LCD_SPI_SCK_GPIO_PORT GPIOF /* GPIOF */ -#define LCD_SPI_SCK_GPIO_CLK RCC_AHB1Periph_GPIOF +#define LCD_SPI_SCK_GPIO_CLK RCC_AHB1Periph_GPIOF #define LCD_SPI_SCK_SOURCE GPIO_PinSource7 #define LCD_SPI_SCK_AF GPIO_AF_SPI5 #define LCD_SPI_MISO_PIN GPIO_Pin_8 /* PF.08 */ #define LCD_SPI_MISO_GPIO_PORT GPIOF /* GPIOF */ -#define LCD_SPI_MISO_GPIO_CLK RCC_AHB1Periph_GPIOF +#define LCD_SPI_MISO_GPIO_CLK RCC_AHB1Periph_GPIOF #define LCD_SPI_MISO_SOURCE GPIO_PinSource8 #define LCD_SPI_MISO_AF GPIO_AF_SPI5 #define LCD_SPI_MOSI_PIN GPIO_Pin_9 /* PF.09 */ #define LCD_SPI_MOSI_GPIO_PORT GPIOF /* GPIOF */ -#define LCD_SPI_MOSI_GPIO_CLK RCC_AHB1Periph_GPIOF +#define LCD_SPI_MOSI_GPIO_CLK RCC_AHB1Periph_GPIOF #define LCD_SPI_MOSI_SOURCE GPIO_PinSource9 #define LCD_SPI_MOSI_AF GPIO_AF_SPI5 #define LCD_SPI SPI5 -#define LCD_SPI_CLK RCC_APB2Periph_SPI5 +#define LCD_SPI_CLK RCC_APB2Periph_SPI5 -/** - * @brief LCD Registers - */ +/** + * @brief LCD Registers + */ #define LCD_SLEEP_OUT 0x11 /* Sleep out register */ #define LCD_GAMMA 0x26 /* Gamma register */ #define LCD_DISPLAY_OFF 0x28 /* Display off register */ #define LCD_DISPLAY_ON 0x29 /* Display on register */ -#define LCD_COLUMN_ADDR 0x2A /* Colomn address register */ -#define LCD_PAGE_ADDR 0x2B /* Page address register */ -#define LCD_GRAM 0x2C /* GRAM register */ +#define LCD_COLUMN_ADDR 0x2A /* Colomn address register */ +#define LCD_PAGE_ADDR 0x2B /* Page address register */ +#define LCD_GRAM 0x2C /* GRAM register */ #define LCD_MAC 0x36 /* Memory Access Control register*/ #define LCD_PIXEL_FORMAT 0x3A /* Pixel Format register */ #define LCD_WDB 0x51 /* Write Brightness Display register */ @@ -163,9 +163,9 @@ typedef struct #define LCD_INTERFACE 0xF6 /* Interface control register */ #define LCD_PRC 0xF7 /* Pump ratio control register */ -/** - * @brief LCD color - */ +/** + * @brief LCD color + */ #define LCD_COLOR_WHITE 0xFFFF #define LCD_COLOR_BLACK 0x0000 #define LCD_COLOR_GREY 0xF7DE @@ -177,8 +177,8 @@ typedef struct #define LCD_COLOR_CYAN 0x7FFF #define LCD_COLOR_YELLOW 0xFFE0 -/** - * @brief LCD Lines depending on the chosen fonts. +/** + * @brief LCD Lines depending on the chosen fonts. */ #define LCD_LINE_0 LINE(0) #define LCD_LINE_1 LINE(1) @@ -221,49 +221,49 @@ typedef struct #define LCD_LINE_38 LINE(38) #define LCD_LINE_39 LINE(39) -/** - * @brief LCD default font - */ +/** + * @brief LCD default font + */ #define LCD_DEFAULT_FONT Font16x24 -/** - * @brief LCD Direction - */ +/** + * @brief LCD Direction + */ #define LCD_DIR_HORIZONTAL 0x0000 #define LCD_DIR_VERTICAL 0x0001 /** * @} - */ + */ -/** - * @brief LCD Layer - */ +/** + * @brief LCD Layer + */ #define LCD_BACKGROUND_LAYER 0x0000 #define LCD_FOREGROUND_LAYER 0x0001 /** * @} - */ + */ /** @defgroup STM32F429I_DISCOVERY_LCD_Exported_Macros * @{ - */ -#define ASSEMBLE_RGB(R, G, B) ((((R)& 0xF8) << 8) | (((G) & 0xFC) << 3) | (((B) & 0xF8) >> 3)) + */ +#define ASSEMBLE_RGB(R, G, B) ((((R)& 0xF8) << 8) | (((G) & 0xFC) << 3) | (((B) & 0xF8) >> 3)) /** * @} - */ + */ /** @defgroup STM32F429I_DISCOVERY_LCD_Exported_Functions * @{ - */ -void LCD_DeInit(void); + */ +void LCD_DeInit(void); void LCD_Init(void); void LCD_LayerInit(void); void LCD_ChipSelect(FunctionalState NewState); void LCD_SetLayer(uint32_t Layerx); -void LCD_SetColors(uint16_t _TextColor, uint16_t _BackColor); +void LCD_SetColors(uint16_t _TextColor, uint16_t _BackColor); void LCD_GetColors(uint16_t *_TextColor, uint16_t *_BackColor); void LCD_SetTextColor(uint16_t Color); void LCD_SetBackColor(uint16_t Color); @@ -307,8 +307,8 @@ void LCD_CtrlLinesWrite(GPIO_TypeDef* GPIOx, uint16_t CtrlPins, BitAction Bi void LCD_SPIConfig(void); /** * @} - */ - + */ + #ifdef __cplusplus } #endif @@ -317,18 +317,18 @@ void LCD_SPIConfig(void); /** * @} - */ + */ /** * @} - */ + */ /** * @} - */ + */ /** * @} */ - + /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/uGL/stm32f429i_discovery_sdram.c b/uGL/stm32f429i_discovery_sdram.c index 443644f..54e64d5 100755 --- a/uGL/stm32f429i_discovery_sdram.c +++ b/uGL/stm32f429i_discovery_sdram.c @@ -5,7 +5,7 @@ * @version V1.0.1 * @date 28-October-2013 * @brief This file provides a set of functions needed to drive the - * IS42S16400J SDRAM memory mounted on STM32F429I-DISCO Kit. + * IS42S16400J SDRAM memory mounted on STM32F429I-DISCO Kit. ****************************************************************************** * @attention * @@ -17,8 +17,8 @@ * * http://www.st.com/software_license_agreement_liberty_v2 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. @@ -31,21 +31,21 @@ #include "stm32f4xx_fmc.h" /** @addtogroup Utilities * @{ - */ + */ /** @addtogroup STM32F4_DISCOVERY * @{ - */ + */ /** @addtogroup STM32429I_DISCO * @{ */ - + /** @addtogroup STM32429I_DISCO_SDRAM - * @brief This file provides a set of functions needed to drive the + * @brief This file provides a set of functions needed to drive the * IS42S16400J SDRAM memory mounted on STM32429I-DISCO board. * @{ - */ + */ /** @defgroup STM32429I_DISCO_SDRAM_Private_Functions * @{ @@ -65,29 +65,29 @@ static void delay(__IO uint32_t nCount); void SDRAM_Init(void) { FMC_SDRAMInitTypeDef FMC_SDRAMInitStructure; - FMC_SDRAMTimingInitTypeDef FMC_SDRAMTimingInitStructure; - + FMC_SDRAMTimingInitTypeDef FMC_SDRAMTimingInitStructure; + /* GPIO configuration for FMC SDRAM bank */ SDRAM_GPIOConfig(); - + /* Enable FMC clock */ RCC_AHB3PeriphClockCmd(RCC_AHB3Periph_FMC, ENABLE); - + /* FMC Configuration ---------------------------------------------------------*/ -/* FMC SDRAM Bank configuration */ +/* FMC SDRAM Bank configuration */ /* Timing configuration for 90 Mhz of SD clock frequency (180Mhz/2) */ /* TMRD: 2 Clock cycles */ - FMC_SDRAMTimingInitStructure.FMC_LoadToActiveDelay = 2; + FMC_SDRAMTimingInitStructure.FMC_LoadToActiveDelay = 2; /* TXSR: min=70ns (7x11.11ns) */ FMC_SDRAMTimingInitStructure.FMC_ExitSelfRefreshDelay = 7; /* TRAS: min=42ns (4x11.11ns) max=120k (ns) */ FMC_SDRAMTimingInitStructure.FMC_SelfRefreshTime = 4; - /* TRC: min=70 (7x11.11ns) */ - FMC_SDRAMTimingInitStructure.FMC_RowCycleDelay = 7; + /* TRC: min=70 (7x11.11ns) */ + FMC_SDRAMTimingInitStructure.FMC_RowCycleDelay = 7; /* TWR: min=1+ 7ns (1+1x11.11ns) */ - FMC_SDRAMTimingInitStructure.FMC_WriteRecoveryTime = 2; + FMC_SDRAMTimingInitStructure.FMC_WriteRecoveryTime = 2; /* TRP: 20ns => 2x11.11ns */ - FMC_SDRAMTimingInitStructure.FMC_RPDelay = 2; + FMC_SDRAMTimingInitStructure.FMC_RPDelay = 2; /* TRCD: 20ns => 2x11.11ns */ FMC_SDRAMTimingInitStructure.FMC_RCDDelay = 2; @@ -99,34 +99,34 @@ void SDRAM_Init(void) FMC_SDRAMInitStructure.FMC_RowBitsNumber = FMC_RowBits_Number_12b; FMC_SDRAMInitStructure.FMC_SDMemoryDataWidth = SDRAM_MEMORY_WIDTH; FMC_SDRAMInitStructure.FMC_InternalBankNumber = FMC_InternalBank_Number_4; - FMC_SDRAMInitStructure.FMC_CASLatency = SDRAM_CAS_LATENCY; + FMC_SDRAMInitStructure.FMC_CASLatency = SDRAM_CAS_LATENCY; FMC_SDRAMInitStructure.FMC_WriteProtection = FMC_Write_Protection_Disable; - FMC_SDRAMInitStructure.FMC_SDClockPeriod = SDCLOCK_PERIOD; + FMC_SDRAMInitStructure.FMC_SDClockPeriod = SDCLOCK_PERIOD; FMC_SDRAMInitStructure.FMC_ReadBurst = SDRAM_READBURST; FMC_SDRAMInitStructure.FMC_ReadPipeDelay = FMC_ReadPipe_Delay_1; FMC_SDRAMInitStructure.FMC_SDRAMTimingStruct = &FMC_SDRAMTimingInitStructure; - + /* FMC SDRAM bank initialization */ - FMC_SDRAMInit(&FMC_SDRAMInitStructure); - + FMC_SDRAMInit(&FMC_SDRAMInitStructure); + /* FMC SDRAM device initialization sequence */ - SDRAM_InitSequence(); - + SDRAM_InitSequence(); + } /** - * @brief Configures all SDRAM memory I/Os pins. - * @param None. + * @brief Configures all SDRAM memory I/Os pins. + * @param None. * @retval None. */ void SDRAM_GPIOConfig(void) { GPIO_InitTypeDef GPIO_InitStructure; - + /* Enable GPIOs clock */ RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB | RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_GPIOD | RCC_AHB1Periph_GPIOE | RCC_AHB1Periph_GPIOF | RCC_AHB1Periph_GPIOG, ENABLE); - + /*-- GPIOs Configuration -----------------------------------------------------*/ /* +-------------------+--------------------+--------------------+--------------------+ @@ -136,21 +136,21 @@ void SDRAM_GPIOConfig(void) | PD1 <-> FMC_D3 | PE1 <-> FMC_NBL1 | PF1 <-> FMC_A1 | PG1 <-> FMC_A11 | | PD8 <-> FMC_D13 | PE7 <-> FMC_D4 | PF2 <-> FMC_A2 | PG8 <-> FMC_SDCLK | | PD9 <-> FMC_D14 | PE8 <-> FMC_D5 | PF3 <-> FMC_A3 | PG15 <-> FMC_NCAS | - | PD10 <-> FMC_D15 | PE9 <-> FMC_D6 | PF4 <-> FMC_A4 |--------------------+ - | PD14 <-> FMC_D0 | PE10 <-> FMC_D7 | PF5 <-> FMC_A5 | - | PD15 <-> FMC_D1 | PE11 <-> FMC_D8 | PF11 <-> FMC_NRAS | - +-------------------| PE12 <-> FMC_D9 | PF12 <-> FMC_A6 | - | PE13 <-> FMC_D10 | PF13 <-> FMC_A7 | + | PD10 <-> FMC_D15 | PE9 <-> FMC_D6 | PF4 <-> FMC_A4 |--------------------+ + | PD14 <-> FMC_D0 | PE10 <-> FMC_D7 | PF5 <-> FMC_A5 | + | PD15 <-> FMC_D1 | PE11 <-> FMC_D8 | PF11 <-> FMC_NRAS | + +-------------------| PE12 <-> FMC_D9 | PF12 <-> FMC_A6 | + | PE13 <-> FMC_D10 | PF13 <-> FMC_A7 | | PE14 <-> FMC_D11 | PF14 <-> FMC_A8 | | PE15 <-> FMC_D12 | PF15 <-> FMC_A9 | +-------------------+--------------------+--------------------+ - | PB5 <-> FMC_SDCKE1| - | PB6 <-> FMC_SDNE1 | + | PB5 <-> FMC_SDCKE1| + | PB6 <-> FMC_SDNE1 | | PC0 <-> FMC_SDNWE | - +-------------------+ - + +-------------------+ + */ - + /* Common GPIO configuration */ GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; @@ -160,18 +160,18 @@ void SDRAM_GPIOConfig(void) /* GPIOB configuration */ GPIO_PinAFConfig(GPIOB, GPIO_PinSource5 , GPIO_AF_FMC); GPIO_PinAFConfig(GPIOB, GPIO_PinSource6 , GPIO_AF_FMC); - - GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5 | GPIO_Pin_6; - GPIO_Init(GPIOB, &GPIO_InitStructure); + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5 | GPIO_Pin_6; + + GPIO_Init(GPIOB, &GPIO_InitStructure); /* GPIOC configuration */ GPIO_PinAFConfig(GPIOC, GPIO_PinSource0 , GPIO_AF_FMC); - - GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0; - GPIO_Init(GPIOC, &GPIO_InitStructure); - + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0; + + GPIO_Init(GPIOC, &GPIO_InitStructure); + /* GPIOD configuration */ GPIO_PinAFConfig(GPIOD, GPIO_PinSource0, GPIO_AF_FMC); GPIO_PinAFConfig(GPIOD, GPIO_PinSource1, GPIO_AF_FMC); @@ -220,10 +220,10 @@ void SDRAM_GPIOConfig(void) GPIO_PinAFConfig(GPIOF, GPIO_PinSource14 , GPIO_AF_FMC); GPIO_PinAFConfig(GPIOF, GPIO_PinSource15 , GPIO_AF_FMC); - GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_11 | GPIO_Pin_12 | GPIO_Pin_13 | - GPIO_Pin_14 | GPIO_Pin_15; + GPIO_Pin_14 | GPIO_Pin_15; GPIO_Init(GPIOF, &GPIO_InitStructure); @@ -234,74 +234,74 @@ void SDRAM_GPIOConfig(void) GPIO_PinAFConfig(GPIOG, GPIO_PinSource5 , GPIO_AF_FMC); GPIO_PinAFConfig(GPIOG, GPIO_PinSource8 , GPIO_AF_FMC); GPIO_PinAFConfig(GPIOG, GPIO_PinSource15 , GPIO_AF_FMC); - + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_8 | GPIO_Pin_15; - GPIO_Init(GPIOG, &GPIO_InitStructure); + GPIO_Init(GPIOG, &GPIO_InitStructure); } /** - * @brief Executes the SDRAM memory initialization sequence. - * @param None. + * @brief Executes the SDRAM memory initialization sequence. + * @param None. * @retval None. */ void SDRAM_InitSequence(void) { FMC_SDRAMCommandTypeDef FMC_SDRAMCommandStructure; uint32_t tmpr = 0; - + /* Step 3 --------------------------------------------------------------------*/ /* Configure a clock configuration enable command */ FMC_SDRAMCommandStructure.FMC_CommandMode = FMC_Command_Mode_CLK_Enabled; FMC_SDRAMCommandStructure.FMC_CommandTarget = FMC_Command_Target_bank2; FMC_SDRAMCommandStructure.FMC_AutoRefreshNumber = 1; FMC_SDRAMCommandStructure.FMC_ModeRegisterDefinition = 0; - /* Wait until the SDRAM controller is ready */ + /* Wait until the SDRAM controller is ready */ while(FMC_GetFlagStatus(FMC_Bank2_SDRAM, FMC_FLAG_Busy) != RESET) { } /* Send the command */ - FMC_SDRAMCmdConfig(&FMC_SDRAMCommandStructure); - + FMC_SDRAMCmdConfig(&FMC_SDRAMCommandStructure); + /* Step 4 --------------------------------------------------------------------*/ /* Insert 100 ms delay */ __Delay(10); - + /* Step 5 --------------------------------------------------------------------*/ - /* Configure a PALL (precharge all) command */ + /* Configure a PALL (precharge all) command */ FMC_SDRAMCommandStructure.FMC_CommandMode = FMC_Command_Mode_PALL; FMC_SDRAMCommandStructure.FMC_CommandTarget = FMC_Command_Target_bank2; FMC_SDRAMCommandStructure.FMC_AutoRefreshNumber = 1; FMC_SDRAMCommandStructure.FMC_ModeRegisterDefinition = 0; - /* Wait until the SDRAM controller is ready */ + /* Wait until the SDRAM controller is ready */ while(FMC_GetFlagStatus(FMC_Bank2_SDRAM, FMC_FLAG_Busy) != RESET) { } /* Send the command */ FMC_SDRAMCmdConfig(&FMC_SDRAMCommandStructure); - + /* Step 6 --------------------------------------------------------------------*/ - /* Configure a Auto-Refresh command */ + /* Configure a Auto-Refresh command */ FMC_SDRAMCommandStructure.FMC_CommandMode = FMC_Command_Mode_AutoRefresh; FMC_SDRAMCommandStructure.FMC_CommandTarget = FMC_Command_Target_bank2; FMC_SDRAMCommandStructure.FMC_AutoRefreshNumber = 4; FMC_SDRAMCommandStructure.FMC_ModeRegisterDefinition = 0; - /* Wait until the SDRAM controller is ready */ + /* Wait until the SDRAM controller is ready */ while(FMC_GetFlagStatus(FMC_Bank2_SDRAM, FMC_FLAG_Busy) != RESET) { } /* Send the first command */ FMC_SDRAMCmdConfig(&FMC_SDRAMCommandStructure); - - /* Wait until the SDRAM controller is ready */ + + /* Wait until the SDRAM controller is ready */ while(FMC_GetFlagStatus(FMC_Bank2_SDRAM, FMC_FLAG_Busy) != RESET) { } /* Send the second command */ FMC_SDRAMCmdConfig(&FMC_SDRAMCommandStructure); - + /* Step 7 --------------------------------------------------------------------*/ /* Program the external memory mode register */ tmpr = (uint32_t)SDRAM_MODEREG_BURST_LENGTH_2 | @@ -309,26 +309,26 @@ void SDRAM_InitSequence(void) SDRAM_MODEREG_CAS_LATENCY_3 | SDRAM_MODEREG_OPERATING_MODE_STANDARD | SDRAM_MODEREG_WRITEBURST_MODE_SINGLE; - - /* Configure a load Mode register command*/ + + /* Configure a load Mode register command*/ FMC_SDRAMCommandStructure.FMC_CommandMode = FMC_Command_Mode_LoadMode; FMC_SDRAMCommandStructure.FMC_CommandTarget = FMC_Command_Target_bank2; FMC_SDRAMCommandStructure.FMC_AutoRefreshNumber = 1; FMC_SDRAMCommandStructure.FMC_ModeRegisterDefinition = tmpr; - /* Wait until the SDRAM controller is ready */ + /* Wait until the SDRAM controller is ready */ while(FMC_GetFlagStatus(FMC_Bank2_SDRAM, FMC_FLAG_Busy) != RESET) { } /* Send the command */ FMC_SDRAMCmdConfig(&FMC_SDRAMCommandStructure); - + /* Step 8 --------------------------------------------------------------------*/ /* Set the refresh rate counter */ /* (15.62 us x Freq) - 20 */ /* Set the device refresh counter */ FMC_SetRefreshCount(1386); - /* Wait until the SDRAM controller is ready */ + /* Wait until the SDRAM controller is ready */ while(FMC_GetFlagStatus(FMC_Bank2_SDRAM, FMC_FLAG_Busy) != RESET) { } @@ -336,11 +336,11 @@ void SDRAM_InitSequence(void) /** - * @brief Writes a Entire-word buffer to the SDRAM memory. - * @param pBuffer: pointer to buffer. - * @param uwWriteAddress: SDRAM memory internal address from which the data will be + * @brief Writes a Entire-word buffer to the SDRAM memory. + * @param pBuffer: pointer to buffer. + * @param uwWriteAddress: SDRAM memory internal address from which the data will be * written. - * @param uwBufferSize: number of words to write. + * @param uwBufferSize: number of words to write. * @retval None. */ void SDRAM_WriteBuffer(uint32_t* pBuffer, uint32_t uwWriteAddress, uint32_t uwBufferSize) @@ -349,14 +349,14 @@ void SDRAM_WriteBuffer(uint32_t* pBuffer, uint32_t uwWriteAddress, uint32_t uwBu /* Disable write protection */ FMC_SDRAMWriteProtectionConfig(FMC_Bank2_SDRAM, DISABLE); - - /* Wait until the SDRAM controller is ready */ + + /* Wait until the SDRAM controller is ready */ while(FMC_GetFlagStatus(FMC_Bank2_SDRAM, FMC_FLAG_Busy) != RESET) { } /* While there is data to write */ - for (; uwBufferSize != 0; uwBufferSize--) + for (; uwBufferSize != 0; uwBufferSize--) { /* Transfer data to the memory */ *(uint32_t *) (SDRAM_BANK_ADDR + write_pointer) = *pBuffer++; @@ -364,35 +364,35 @@ void SDRAM_WriteBuffer(uint32_t* pBuffer, uint32_t uwWriteAddress, uint32_t uwBu /* Increment the address*/ write_pointer += 4; } - + } /** - * @brief Reads data buffer from the SDRAM memory. - * @param pBuffer: pointer to buffer. - * @param ReadAddress: SDRAM memory internal address from which the data will be + * @brief Reads data buffer from the SDRAM memory. + * @param pBuffer: pointer to buffer. + * @param ReadAddress: SDRAM memory internal address from which the data will be * read. - * @param uwBufferSize: number of words to write. + * @param uwBufferSize: number of words to write. * @retval None. */ void SDRAM_ReadBuffer(uint32_t* pBuffer, uint32_t uwReadAddress, uint32_t uwBufferSize) { __IO uint32_t write_pointer = (uint32_t)uwReadAddress; - - - /* Wait until the SDRAM controller is ready */ + + + /* Wait until the SDRAM controller is ready */ while(FMC_GetFlagStatus(FMC_Bank2_SDRAM, FMC_FLAG_Busy) != RESET) { } - + /* Read data */ for(; uwBufferSize != 0x00; uwBufferSize--) { *pBuffer++ = *(__IO uint32_t *)(SDRAM_BANK_ADDR + write_pointer ); - + /* Increment the address*/ write_pointer += 4; - } + } } #ifndef USE_Delay @@ -403,7 +403,7 @@ void SDRAM_ReadBuffer(uint32_t* pBuffer, uint32_t uwReadAddress, uint32_t uwBuff */ static void delay(__IO uint32_t nCount) { - __IO uint32_t index = 0; + __IO uint32_t index = 0; for(index = (100000 * nCount); index != 0; index--) { } @@ -425,6 +425,6 @@ static void delay(__IO uint32_t nCount) /** * @} - */ + */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/uGL/uGL.c b/uGL/uGL.c index 3ae0a26..7956045 100644 --- a/uGL/uGL.c +++ b/uGL/uGL.c @@ -1,8 +1,14 @@ #include "uGL.h" +#include + #include "stm32f429i_discovery_lcd.h" #include +static uint8_t *_framebuffer = (uint8_t *)LCD_FRAME_BUFFER; +static const uint16_t screenwidth = 240; +static const uint16_t screenheight = 320; + void uGL_init() { LCD_Init(); @@ -10,16 +16,33 @@ void uGL_init() LCD_LayerInit(); LTDC_Cmd(ENABLE); - LCD_SetFont(&Font8x8); - LCD_SetLayer(LCD_BACKGROUND_LAYER); +// LCD_SetFont(&Font8x8); +// LCD_SetLayer(LCD_BACKGROUND_LAYER); // LCD_Clear(ASSEMBLE_RGB(0x00, 0x66, 0x00)); LCD_SetLayer(LCD_FOREGROUND_LAYER); - LCD_SetBackColor(ASSEMBLE_RGB(0x00, 0x00, 0xFF)); +// LCD_SetBackColor(ASSEMBLE_RGB(0x00, 0x00, 0xFF)); +} + + +uint16_t uGL_getScreenHeight() +{ + return screenheight; } +uint16_t uGL_getScreenWidth() +{ + return screenwidth; +} + + void uGL_drawPixel(uint16_t x, uint16_t y, uGL_color_t color) { - LCD_SetTextColor(ASSEMBLE_RGB(color.r, color.g, color.b)); + uint8_t c[3] = { color.r, color.g, color.b }; + //LCD_SetTextColor(ASSEMBLE_RGB(color.r, color.g, color.b)); + memcpy(c, _framebuffer + 3 * (x + screenwidth * y), 3 * sizeof(uint8_t)); + /*_framebuffer[3 * (x + screenwidth * y)] = color.r; + _framebuffer[3 * (x + screenwidth * y) + 1] = color.g; + _framebuffer[3 * (x + screenwidth * y) + 2] = color.b;*/ // PutPixel(int16_t x, int16_t y); } @@ -27,6 +50,9 @@ void uGL_drawHLine(uint16_t x, uint16_t y, uint16_t length, uGL_color_t color) { LCD_SetTextColor(ASSEMBLE_RGB(color.r, color.g, color.b)); LCD_DrawLine(x, y, length, LCD_DIR_HORIZONTAL); + //TODO: optimize +// for (int i = 0 ; i < length ; i++) +// uGL_drawPixel(x + i, y, color); } void uGL_drawVLine(uint16_t x, uint16_t y, uint16_t length, uGL_color_t color) @@ -35,16 +61,18 @@ void uGL_drawVLine(uint16_t x, uint16_t y, uint16_t length, uGL_color_t color) LCD_DrawLine(x, y, length, LCD_DIR_VERTICAL); } -void uGL_drawFrame(uint16_t x, uint16_t y, uint16_t width, uint16_t length, uGL_color_t color) +void uGL_drawFrame(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uGL_color_t color) { - LCD_SetTextColor(ASSEMBLE_RGB(color.r, color.g, color.b)); - LCD_DrawRect(x, y, width, length); + uGL_drawHLine(x, y, width, color); + uGL_drawHLine(x, (y + height), width, color); + uGL_drawVLine(x, y, height, color); + uGL_drawVLine((x + width), y, height, color); } -void uGL_drawRectangle(uint16_t x, uint16_t y, uint16_t width, uint16_t length, uGL_color_t color) +void uGL_drawRectangle(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uGL_color_t color) { LCD_SetTextColor(ASSEMBLE_RGB(color.r, color.g, color.b)); - LCD_DrawFullRect(x, y, width, length); + LCD_DrawFullRect(x, y, width, height); } void uGl_blitImage(uGL_image_t *image, uint16_t x, uint16_t y) diff --git a/uGL/uGL.h b/uGL/uGL.h index 7035d4d..b5c67d1 100644 --- a/uGL/uGL.h +++ b/uGL/uGL.h @@ -31,10 +31,13 @@ typedef struct { void uGL_init(); +uint16_t uGL_getScreenHeight(); +uint16_t uGL_getScreenWidth(); + void uGL_drawPixel(uint16_t x, uint16_t y, uGL_color_t color); void uGL_drawHLine(uint16_t x, uint16_t y, uint16_t length, uGL_color_t color); void uGL_drawVLine(uint16_t x, uint16_t y, uint16_t length, uGL_color_t color); -void uGL_drawFrame(uint16_t x, uint16_t y, uint16_t width, uint16_t length, uGL_color_t color); -void uGL_drawRectangle(uint16_t x, uint16_t y, uint16_t width, uint16_t length, uGL_color_t color); +void uGL_drawFrame(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uGL_color_t color); +void uGL_drawRectangle(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uGL_color_t color); void uGl_blitImage(uGL_image_t *image, uint16_t x, uint16_t y); From cba1d4792b6e1cde692051d48caa6bdff954564d Mon Sep 17 00:00:00 2001 From: Thomas Pietrzak Date: Tue, 25 Sep 2018 21:45:17 +0200 Subject: [PATCH 06/11] fix framebuffer --- bootloader.c | 22 +- uGL/stm32f429i_discovery_lcd.c | 603 ++++++++++++++----------------- uGL/stm32f429i_discovery_lcd.dep | 10 +- uGL/stm32f429i_discovery_lcd.h | 129 +++---- uGL/uGL.c | 28 +- uGL/uGL.h | 2 +- 6 files changed, 375 insertions(+), 419 deletions(-) diff --git a/bootloader.c b/bootloader.c index a2855df..5eb1443 100644 --- a/bootloader.c +++ b/bootloader.c @@ -6,23 +6,31 @@ int main() { uGL_init(); + uGL_color_t backgroundcolor = { .r = 255, .g = 255, .b = 255 }; + uGL_drawRectangle(0, 0, 240, 320, backgroundcolor); + uGL_color_t gradientcolor = { .r = 0, .g = 0, .b = 0 }; - for (int i = 0 ; i < 256 ; i++) + for (uint8_t i = 0 ; i < 255 ; i++) { gradientcolor.g = i; uGL_drawPixel(10, i, gradientcolor); + uGL_drawHLine(20, i, 10, gradientcolor); } - uGL_color_t backgroundcolor = { .r = 70, .g = 120, .b = 240 }; - uGL_drawRectangle(0, 0, 240, 320, backgroundcolor); + uGL_color_t black = { .r = 0, .g = 0, .b = 0 }; + for (uint8_t i = 0 ; i < 6 ; i++) + uGL_drawHLine(0, i * 50, 240, black); + + for (uint8_t i = 0 ; i < 4 ; i++) + uGL_drawVLine(i * 50, 0, 320, black); - uGL_color_t rectcolor = { .r = 250, .g = 120, .b = 40 }; - uGL_drawRectangle(50, 100, 100, 200, rectcolor); + uGL_color_t rectcolor = { .r = 250, .g = 120, .b = 10 }; + uGL_drawFrame(10, 30, 100, 50, rectcolor); - uGL_color_t hlinecolor = { .r = 50, .g = 240, .b = 40 }; + uGL_color_t hlinecolor = { .r = 50, .g = 240, .b = 20 }; uGL_drawHLine(20, 50, 100, hlinecolor); - uGL_color_t vlinecolor = { .r = 250, .g = 240, .b = 40 }; + uGL_color_t vlinecolor = { .r = 250, .g = 240, .b = 10 }; uGL_drawVLine(50, 20, 200, vlinecolor); while(1); diff --git a/uGL/stm32f429i_discovery_lcd.c b/uGL/stm32f429i_discovery_lcd.c index 804a83e..2e31ba4 100755 --- a/uGL/stm32f429i_discovery_lcd.c +++ b/uGL/stm32f429i_discovery_lcd.c @@ -32,6 +32,8 @@ #include "stm32f4xx_dma2d.h" //#include "fonts.c" +#include + #include #include ssp_port_t lcd_port = { @@ -153,7 +155,6 @@ void LCD_Init(void) - /* Configure the FMC Parallel interface : SDRAM is used as Frame Buffer for LCD */ SDRAM_Init(); @@ -211,131 +212,6 @@ void LCD_Init(void) } -/** - * @} - */ - -/** @defgroup STM32F429I_DISCOVERY_LCD_Private_Functions - * @{ - */ - -/** - * @brief DeInitializes the LCD. - * @param None - * @retval None - */ -void LCD_DeInit(void) -{ - GPIO_InitTypeDef GPIO_InitStructure; - - /* LCD Display Off */ - LCD_DisplayOff(); - - /* LCD_SPI disable */ - SPI_Cmd(LCD_SPI, DISABLE); - - /* LCD_SPI DeInit */ - SPI_I2S_DeInit(LCD_SPI); - - /* Disable SPI clock */ - RCC_APB2PeriphClockCmd(LCD_SPI_CLK, DISABLE); - - /* Configure NCS in Output Push-Pull mode */ - GPIO_InitStructure.GPIO_Pin = LCD_NCS_PIN; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN; - GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; - GPIO_Init(LCD_NCS_GPIO_PORT, &GPIO_InitStructure); - - /* Configure SPI pins: SCK, MISO and MOSI */ - GPIO_InitStructure.GPIO_Pin = LCD_SPI_SCK_PIN; - GPIO_Init(LCD_SPI_SCK_GPIO_PORT, &GPIO_InitStructure); - - GPIO_InitStructure.GPIO_Pin = LCD_SPI_MISO_PIN; - GPIO_Init(LCD_SPI_MISO_GPIO_PORT, &GPIO_InitStructure); - - GPIO_InitStructure.GPIO_Pin = LCD_SPI_MOSI_PIN; - GPIO_Init(LCD_SPI_MOSI_GPIO_PORT, &GPIO_InitStructure); - - /* GPIOA configuration */ - GPIO_PinAFConfig(GPIOA, GPIO_PinSource3, GPIO_AF_MCO); - GPIO_PinAFConfig(GPIOA, GPIO_PinSource4, GPIO_AF_MCO); - GPIO_PinAFConfig(GPIOA, GPIO_PinSource6, GPIO_AF_MCO); - GPIO_PinAFConfig(GPIOA, GPIO_PinSource11, GPIO_AF_MCO); - GPIO_PinAFConfig(GPIOA, GPIO_PinSource12, GPIO_AF_MCO); - - GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_6 | - GPIO_Pin_11 | GPIO_Pin_12; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; - GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; - GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; - GPIO_Init(GPIOA, &GPIO_InitStructure); - - /* GPIOB configuration */ - GPIO_PinAFConfig(GPIOB, GPIO_PinSource0, GPIO_AF_MCO); - GPIO_PinAFConfig(GPIOB, GPIO_PinSource1, GPIO_AF_MCO); - GPIO_PinAFConfig(GPIOB, GPIO_PinSource8, GPIO_AF_MCO); - GPIO_PinAFConfig(GPIOB, GPIO_PinSource9, GPIO_AF_MCO); - GPIO_PinAFConfig(GPIOB, GPIO_PinSource10, GPIO_AF_MCO); - GPIO_PinAFConfig(GPIOB, GPIO_PinSource11, GPIO_AF_MCO); - - GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_8 | - GPIO_Pin_9 | GPIO_Pin_10 | GPIO_Pin_11; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; - GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; - GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; - GPIO_Init(GPIOB, &GPIO_InitStructure); - - /* GPIOC configuration */ - GPIO_PinAFConfig(GPIOC, GPIO_PinSource6, GPIO_AF_MCO); - GPIO_PinAFConfig(GPIOC, GPIO_PinSource7, GPIO_AF_MCO); - GPIO_PinAFConfig(GPIOC, GPIO_PinSource10, GPIO_AF_MCO); - - GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7 | GPIO_Pin_10; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; - GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; - GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; - GPIO_Init(GPIOC, &GPIO_InitStructure); - - /* GPIOD configuration */ - GPIO_PinAFConfig(GPIOD, GPIO_PinSource3, GPIO_AF_MCO); - GPIO_PinAFConfig(GPIOD, GPIO_PinSource6, GPIO_AF_MCO); - - GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3 | GPIO_Pin_6; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; - GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; - GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; - GPIO_Init(GPIOD, &GPIO_InitStructure); - - /* GPIOF configuration */ - GPIO_PinAFConfig(GPIOF, GPIO_PinSource10, GPIO_AF_MCO); - - GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; - GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; - GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; - GPIO_Init(GPIOF, &GPIO_InitStructure); - - /* GPIOG configuration */ - GPIO_PinAFConfig(GPIOG, GPIO_PinSource6, GPIO_AF_MCO); - GPIO_PinAFConfig(GPIOG, GPIO_PinSource7, GPIO_AF_MCO); - GPIO_PinAFConfig(GPIOG, GPIO_PinSource10, GPIO_AF_MCO); - GPIO_PinAFConfig(GPIOG, GPIO_PinSource11, GPIO_AF_MCO); - GPIO_PinAFConfig(GPIOG, GPIO_PinSource12, GPIO_AF_MCO); - - GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7 | GPIO_Pin_10 | - GPIO_Pin_11 | GPIO_Pin_12; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; - GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; - GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; - GPIO_Init(GPIOG, &GPIO_InitStructure); -} - /** * @brief Initializes the LCD Layers. * @param None @@ -417,6 +293,147 @@ void LCD_LayerInit(void) LTDC_DitherCmd(ENABLE); } +void LCD_WriteChunk(uint8_t command, uint8_t *data, uint8_t nb) +{ + gpio_set(lcd_wrx, 0); + gpio_set(lcd_ncs, 0); + ssp_write(ssp_5, command); + while(SPI_I2S_GetFlagStatus(LCD_SPI, SPI_I2S_FLAG_BSY) != RESET); + //gpio_set(lcd_ncs, 1); + + for (int i = 0 ; i < nb ; i++) + { + gpio_set(lcd_wrx, 1); + //gpio_set(lcd_ncs, 0); + ssp_write(ssp_5, data[i]); + while(SPI_I2S_GetFlagStatus(LCD_SPI, SPI_I2S_FLAG_BSY) != RESET); + + } + gpio_set(lcd_ncs, 1); +} + + +/** + * @brief Configure the LCD controller (Power On sequence as described in ILI9341 Datasheet) + * @param None + * @retval None + */ +void LCD_PowerOn(void) +{ + uint8_t buffer_init[] = {0xC3, 0x08, 0x50}; + LCD_WriteChunk(0xCA, buffer_init, 3); + + uint8_t buffer_powerb[] = {0x00, 0xC1, 0x30}; + LCD_WriteChunk(LCD_POWERB, buffer_powerb, 3); + + uint8_t buffer_powerseq[] = {0x64, 0x03, 0x12, 0x81}; + LCD_WriteChunk(LCD_POWER_SEQ, buffer_powerseq, 4); + + uint8_t buffer_dtca[] = {0x85, 0x00, 0x78}; + LCD_WriteChunk(LCD_DTCA, buffer_dtca, 3); + + uint8_t buffer_powera[] = {0x39, 0x2C, 0x00, 0x34, 0x02}; + LCD_WriteChunk(LCD_DTCA, buffer_powera, 5); + + uint8_t buffer_prc[] = {0x20}; + LCD_WriteChunk(LCD_PRC, buffer_prc, 1); + + uint8_t buffer_dtcb[] = {0x00, 0x00}; + LCD_WriteChunk(LCD_DTCB, buffer_dtcb, 2); + + uint8_t buffer_frc[] = {0x00, 0x1B}; + LCD_WriteChunk(LCD_FRC, buffer_frc, 2); + + uint8_t buffer_dfc[] = {0x0A, 0xA2}; + LCD_WriteChunk(LCD_DFC, buffer_dfc, 2); + + uint8_t buffer_power1[] = {0x10}; + LCD_WriteChunk(LCD_POWER1, buffer_power1, 1); + + uint8_t buffer_power2[] = {0x10}; + LCD_WriteChunk(LCD_POWER2, buffer_power2, 1); + + uint8_t buffer_vcom1[] = {0x45, 0x15}; + LCD_WriteChunk(LCD_VCOM1, buffer_vcom1, 2); + + uint8_t buffer_vcom2[] = {0x90}; + LCD_WriteChunk(LCD_VCOM2, buffer_vcom2, 1); + + uint8_t buffer_mac[] = {0xC8}; + LCD_WriteChunk(LCD_MAC, buffer_mac, 1); + + uint8_t buffer_3gammaen[] = {0x00}; + LCD_WriteChunk(LCD_3GAMMA_EN, buffer_3gammaen, 1); + + uint8_t buffer_rgbinterface[] = {0xc2}; + LCD_WriteChunk(LCD_RGB_INTERFACE, buffer_rgbinterface, 1); + + uint8_t buffer_dfc2[] = {0x0A, 0xA7, 0x27, 0x04}; + LCD_WriteChunk(LCD_DFC, buffer_dfc2, 4); + + uint8_t buffer_coladdr[] = {0x00, 0x00, 0x00, 0xEF}; + LCD_WriteChunk(LCD_COLUMN_ADDR, buffer_coladdr, 4); + + uint8_t buffer_pageaddr[] = {0x00, 0x00, 0x01, 0x3F}; + LCD_WriteChunk(LCD_PAGE_ADDR, buffer_pageaddr, 4); + + uint8_t buffer_interface[] = {0x01, 0x00, 0x06}; + LCD_WriteChunk(LCD_INTERFACE, buffer_interface, 3); + + LCD_WriteChunk(LCD_GRAM, NULL, 0); + + delay(200); + + uint8_t buffer_gamma[] = {0x01}; + LCD_WriteChunk(LCD_GAMMA, buffer_gamma, 1); + + uint8_t buffer_pgamma[] = {0x0F, 0x29, 0x24, 0x0C, 0x0E, 0x09, 0x4E, 0x78, 0x3C, 0x09, 0x13, 0x05, 0x17, 0x11, 0x00}; + LCD_WriteChunk(LCD_PGAMMA, buffer_pgamma, 15); + + uint8_t buffer_ngamma[] = {0x00, 0x16, 0x1B, 0x04, 0x11, 0x07, 0x31, 0x33, 0x42, 0x05, 0x0C, 0x0A, 0x28, 0x2F, 0x0F}; + LCD_WriteChunk(LCD_NGAMMA, buffer_ngamma, 15); + + LCD_WriteChunk(LCD_SLEEP_OUT, NULL, 0); + + delay(200); + + LCD_WriteChunk(LCD_DISPLAY_ON, NULL, 0); + LCD_WriteChunk(LCD_GRAM, NULL, 0); +} + +/** + * @brief Enables the Display. + * @param None + * @retval None + */ +void LCD_DisplayOn(void) +{ + LCD_WriteChunk(LCD_DISPLAY_ON, NULL, 0); +} + +/** + * @brief Disables the Display. + * @param None + * @retval None + */ +void LCD_DisplayOff(void) +{ + LCD_WriteChunk(LCD_DISPLAY_OFF, NULL, 0); +} + + + + + + + + + + + + + + /** * @brief Controls LCD Chip Select (CS) pin * @param NewState CS pin state @@ -1531,209 +1548,6 @@ void LCD_FillPolyLine(pPoint Points, uint16_t PointCount) LCD_FillTriangle(X_center, X2, X_first, Y_center, Y2, Y_first); } -/** - * @brief Writes command to select the LCD register. - * @param LCD_Reg: address of the selected register. - * @retval None - */ -void LCD_WriteCommand(uint8_t LCD_Reg) -{ - gpio_set(lcd_wrx, 0); - - gpio_set(lcd_ncs, 0); - - ssp_write(ssp_5, LCD_Reg); - - while(SPI_I2S_GetFlagStatus(LCD_SPI, SPI_I2S_FLAG_BSY) != RESET); - - gpio_set(lcd_ncs, 1); -} - -/** - * @brief Writes data to select the LCD register. - * This function must be used after LCD_WriteCommand() function - * @param value: data to write to the selected register. - * @retval None - */ -void LCD_WriteData(uint8_t value) -{ - gpio_set(lcd_wrx, 1); - - gpio_set(lcd_ncs, 0); - - ssp_write(ssp_5, value); - - while(SPI_I2S_GetFlagStatus(LCD_SPI, SPI_I2S_FLAG_BSY) != RESET); - - gpio_set(lcd_ncs, 1); -} - -/** - * @brief Configure the LCD controller (Power On sequence as described in ILI9341 Datasheet) - * @param None - * @retval None - */ -void LCD_PowerOn(void) -{ - LCD_WriteCommand(0xCA); - LCD_WriteData(0xC3); - LCD_WriteData(0x08); - LCD_WriteData(0x50); - LCD_WriteCommand(LCD_POWERB); - LCD_WriteData(0x00); - LCD_WriteData(0xC1); - LCD_WriteData(0x30); - LCD_WriteCommand(LCD_POWER_SEQ); - LCD_WriteData(0x64); - LCD_WriteData(0x03); - LCD_WriteData(0x12); - LCD_WriteData(0x81); - LCD_WriteCommand(LCD_DTCA); - LCD_WriteData(0x85); - LCD_WriteData(0x00); - LCD_WriteData(0x78); - LCD_WriteCommand(LCD_POWERA); - LCD_WriteData(0x39); - LCD_WriteData(0x2C); - LCD_WriteData(0x00); - LCD_WriteData(0x34); - LCD_WriteData(0x02); - LCD_WriteCommand(LCD_PRC); - LCD_WriteData(0x20); - LCD_WriteCommand(LCD_DTCB); - LCD_WriteData(0x00); - LCD_WriteData(0x00); - LCD_WriteCommand(LCD_FRC); - LCD_WriteData(0x00); - LCD_WriteData(0x1B); - LCD_WriteCommand(LCD_DFC); - LCD_WriteData(0x0A); - LCD_WriteData(0xA2); - LCD_WriteCommand(LCD_POWER1); - LCD_WriteData(0x10); - LCD_WriteCommand(LCD_POWER2); - LCD_WriteData(0x10); - LCD_WriteCommand(LCD_VCOM1); - LCD_WriteData(0x45); - LCD_WriteData(0x15); - LCD_WriteCommand(LCD_VCOM2); - LCD_WriteData(0x90); - LCD_WriteCommand(LCD_MAC); - LCD_WriteData(0xC8); - LCD_WriteCommand(LCD_3GAMMA_EN); - LCD_WriteData(0x00); - LCD_WriteCommand(LCD_RGB_INTERFACE); - LCD_WriteData(0xC2); - LCD_WriteCommand(LCD_DFC); - LCD_WriteData(0x0A); - LCD_WriteData(0xA7); - LCD_WriteData(0x27); - LCD_WriteData(0x04); - - /* colomn address set */ - LCD_WriteCommand(LCD_COLUMN_ADDR); - LCD_WriteData(0x00); - LCD_WriteData(0x00); - LCD_WriteData(0x00); - LCD_WriteData(0xEF); - /* Page Address Set */ - LCD_WriteCommand(LCD_PAGE_ADDR); - LCD_WriteData(0x00); - LCD_WriteData(0x00); - LCD_WriteData(0x01); - LCD_WriteData(0x3F); - LCD_WriteCommand(LCD_INTERFACE); - LCD_WriteData(0x01); - LCD_WriteData(0x00); - LCD_WriteData(0x06); - - LCD_WriteCommand(LCD_GRAM); - delay(200); - - LCD_WriteCommand(LCD_GAMMA); - LCD_WriteData(0x01); - - LCD_WriteCommand(LCD_PGAMMA); - LCD_WriteData(0x0F); - LCD_WriteData(0x29); - LCD_WriteData(0x24); - LCD_WriteData(0x0C); - LCD_WriteData(0x0E); - LCD_WriteData(0x09); - LCD_WriteData(0x4E); - LCD_WriteData(0x78); - LCD_WriteData(0x3C); - LCD_WriteData(0x09); - LCD_WriteData(0x13); - LCD_WriteData(0x05); - LCD_WriteData(0x17); - LCD_WriteData(0x11); - LCD_WriteData(0x00); - LCD_WriteCommand(LCD_NGAMMA); - LCD_WriteData(0x00); - LCD_WriteData(0x16); - LCD_WriteData(0x1B); - LCD_WriteData(0x04); - LCD_WriteData(0x11); - LCD_WriteData(0x07); - LCD_WriteData(0x31); - LCD_WriteData(0x33); - LCD_WriteData(0x42); - LCD_WriteData(0x05); - LCD_WriteData(0x0C); - LCD_WriteData(0x0A); - LCD_WriteData(0x28); - LCD_WriteData(0x2F); - LCD_WriteData(0x0F); - - LCD_WriteCommand(LCD_SLEEP_OUT); - delay(200); - LCD_WriteCommand(LCD_DISPLAY_ON); - /* GRAM start writing */ - LCD_WriteCommand(LCD_GRAM); - } - -/** - * @brief Enables the Display. - * @param None - * @retval None - */ -void LCD_DisplayOn(void) -{ - LCD_WriteCommand(LCD_DISPLAY_ON); -} - -/** - * @brief Disables the Display. - * @param None - * @retval None - */ -void LCD_DisplayOff(void) -{ - /* Display Off */ - LCD_WriteCommand(LCD_DISPLAY_OFF); -} - -/** - * @brief Sets or reset LCD control lines. - * @param GPIOx: where x can be B or D to select the GPIO peripheral. - * @param CtrlPins: the Control line. - * This parameter can be: - * @arg LCD_NCS_PIN: Chip Select pin - * @arg LCD_NWR_PIN: Read/Write Selection pin - * @arg LCD_RS_PIN: Register/RAM Selection pin - * @param BitVal: specifies the value to be written to the selected bit. - * This parameter can be: - * @arg Bit_RESET: to clear the port pin - * @arg Bit_SET: to set the port pin - * @retval None - */ -void LCD_CtrlLinesWrite(GPIO_TypeDef* GPIOx, uint16_t CtrlPins, BitAction BitVal) -{ - /* Set or Reset the control line */ - GPIO_WriteBit(GPIOx, (uint16_t)CtrlPins, (BitAction)BitVal); -} - /** * @brief Displays a pixel. @@ -1764,3 +1578,134 @@ static void delay(__IO uint32_t nCount) } } #endif + + + + + + + +/** + * @} + */ + +/** @defgroup STM32F429I_DISCOVERY_LCD_Private_Functions + * @{ + */ + +/** + * @brief DeInitializes the LCD. + * @param None + * @retval None + */ +void LCD_DeInit(void) +{ + GPIO_InitTypeDef GPIO_InitStructure; + + /* LCD Display Off */ + LCD_DisplayOff(); + + /* LCD_SPI disable */ + SPI_Cmd(LCD_SPI, DISABLE); + + /* LCD_SPI DeInit */ + SPI_I2S_DeInit(LCD_SPI); + + /* Disable SPI clock */ + RCC_APB2PeriphClockCmd(LCD_SPI_CLK, DISABLE); + + /* Configure NCS in Output Push-Pull mode */ + GPIO_InitStructure.GPIO_Pin = LCD_NCS_PIN; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN; + GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; + GPIO_Init(LCD_NCS_GPIO_PORT, &GPIO_InitStructure); + + /* Configure SPI pins: SCK, MISO and MOSI */ + GPIO_InitStructure.GPIO_Pin = LCD_SPI_SCK_PIN; + GPIO_Init(LCD_SPI_SCK_GPIO_PORT, &GPIO_InitStructure); + + GPIO_InitStructure.GPIO_Pin = LCD_SPI_MISO_PIN; + GPIO_Init(LCD_SPI_MISO_GPIO_PORT, &GPIO_InitStructure); + + GPIO_InitStructure.GPIO_Pin = LCD_SPI_MOSI_PIN; + GPIO_Init(LCD_SPI_MOSI_GPIO_PORT, &GPIO_InitStructure); + + /* GPIOA configuration */ + GPIO_PinAFConfig(GPIOA, GPIO_PinSource3, GPIO_AF_MCO); + GPIO_PinAFConfig(GPIOA, GPIO_PinSource4, GPIO_AF_MCO); + GPIO_PinAFConfig(GPIOA, GPIO_PinSource6, GPIO_AF_MCO); + GPIO_PinAFConfig(GPIOA, GPIO_PinSource11, GPIO_AF_MCO); + GPIO_PinAFConfig(GPIOA, GPIO_PinSource12, GPIO_AF_MCO); + + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_6 | + GPIO_Pin_11 | GPIO_Pin_12; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; + GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; + GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; + GPIO_Init(GPIOA, &GPIO_InitStructure); + + /* GPIOB configuration */ + GPIO_PinAFConfig(GPIOB, GPIO_PinSource0, GPIO_AF_MCO); + GPIO_PinAFConfig(GPIOB, GPIO_PinSource1, GPIO_AF_MCO); + GPIO_PinAFConfig(GPIOB, GPIO_PinSource8, GPIO_AF_MCO); + GPIO_PinAFConfig(GPIOB, GPIO_PinSource9, GPIO_AF_MCO); + GPIO_PinAFConfig(GPIOB, GPIO_PinSource10, GPIO_AF_MCO); + GPIO_PinAFConfig(GPIOB, GPIO_PinSource11, GPIO_AF_MCO); + + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_8 | + GPIO_Pin_9 | GPIO_Pin_10 | GPIO_Pin_11; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; + GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; + GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; + GPIO_Init(GPIOB, &GPIO_InitStructure); + + /* GPIOC configuration */ + GPIO_PinAFConfig(GPIOC, GPIO_PinSource6, GPIO_AF_MCO); + GPIO_PinAFConfig(GPIOC, GPIO_PinSource7, GPIO_AF_MCO); + GPIO_PinAFConfig(GPIOC, GPIO_PinSource10, GPIO_AF_MCO); + + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7 | GPIO_Pin_10; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; + GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; + GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; + GPIO_Init(GPIOC, &GPIO_InitStructure); + + /* GPIOD configuration */ + GPIO_PinAFConfig(GPIOD, GPIO_PinSource3, GPIO_AF_MCO); + GPIO_PinAFConfig(GPIOD, GPIO_PinSource6, GPIO_AF_MCO); + + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3 | GPIO_Pin_6; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; + GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; + GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; + GPIO_Init(GPIOD, &GPIO_InitStructure); + + /* GPIOF configuration */ + GPIO_PinAFConfig(GPIOF, GPIO_PinSource10, GPIO_AF_MCO); + + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; + GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; + GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; + GPIO_Init(GPIOF, &GPIO_InitStructure); + + /* GPIOG configuration */ + GPIO_PinAFConfig(GPIOG, GPIO_PinSource6, GPIO_AF_MCO); + GPIO_PinAFConfig(GPIOG, GPIO_PinSource7, GPIO_AF_MCO); + GPIO_PinAFConfig(GPIOG, GPIO_PinSource10, GPIO_AF_MCO); + GPIO_PinAFConfig(GPIOG, GPIO_PinSource11, GPIO_AF_MCO); + GPIO_PinAFConfig(GPIOG, GPIO_PinSource12, GPIO_AF_MCO); + + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7 | GPIO_Pin_10 | + GPIO_Pin_11 | GPIO_Pin_12; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; + GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; + GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; + GPIO_Init(GPIOG, &GPIO_InitStructure); +} diff --git a/uGL/stm32f429i_discovery_lcd.dep b/uGL/stm32f429i_discovery_lcd.dep index 060b566..5accf3e 100644 --- a/uGL/stm32f429i_discovery_lcd.dep +++ b/uGL/stm32f429i_discovery_lcd.dep @@ -43,7 +43,15 @@ uGL/stm32f429i_discovery_lcd.o: uGL/stm32f429i_discovery_lcd.c \ uGL/stm32f429i_discovery.h uGL/stm32f429i_discovery_sdram.h uGL/fonts.h \ /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_ltdc.h \ /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_dma2d.h \ - /Users/tom/Documents/src/uGames/uC-sdk/hardware/include/gpio.h \ + /Users/tom/Documents/src/uGames/uC-sdk/libc/include/stdlib.h \ /Users/tom/Documents/src/uGames/uC-sdk/libc/include/decl.h \ + /Users/tom/Documents/src/uGames/uC-sdk/libc/include/reent.h \ + /Users/tom/Documents/src/uGames/uC-sdk/libc/include/errno.h \ + /Users/tom/Documents/src/uGames/uC-sdk/libc/include/malloc.h \ + /usr/local/Caskroom/gcc-arm-embedded/7-2017-q4-major/gcc-arm-none-eabi-7-2017-q4-major/lib/gcc/arm-none-eabi/7.2.1/include/stddef.h \ + /Users/tom/Documents/src/uGames/uC-sdk/libc/include/stdio.h \ + /usr/local/Caskroom/gcc-arm-embedded/7-2017-q4-major/gcc-arm-none-eabi-7-2017-q4-major/lib/gcc/arm-none-eabi/7.2.1/include/stdarg.h \ + /Users/tom/Documents/src/uGames/uC-sdk/libc/include/unistd.h \ + /Users/tom/Documents/src/uGames/uC-sdk/hardware/include/gpio.h \ /usr/local/Caskroom/gcc-arm-embedded/7-2017-q4-major/gcc-arm-none-eabi-7-2017-q4-major/lib/gcc/arm-none-eabi/7.2.1/include/stdbool.h \ /Users/tom/Documents/src/uGames/uC-sdk/hardware/include/ssp.h diff --git a/uGL/stm32f429i_discovery_lcd.h b/uGL/stm32f429i_discovery_lcd.h index 3db34b7..6ff8125 100755 --- a/uGL/stm32f429i_discovery_lcd.h +++ b/uGL/stm32f429i_discovery_lcd.h @@ -4,7 +4,7 @@ * @author MCD Application Team * @version V1.0.1 * @date 28-October-2013 - * @brief This file contains all the functions prototypes for the + * @brief This file contains all the functions prototypes for the * stm32f429i_discovery_lcd.c driver. ****************************************************************************** * @attention @@ -17,8 +17,8 @@ * * http://www.st.com/software_license_agreement_liberty_v2 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. @@ -32,7 +32,7 @@ #ifdef __cplusplus extern "C" { -#endif +#endif /* Includes ------------------------------------------------------------------*/ #include "stm32f4xx.h" @@ -46,48 +46,48 @@ /** @addtogroup STM32F4_DISCOVERY * @{ - */ + */ /** @addtogroup STM32F429I_DISCOVERY * @{ */ - + /** @addtogroup STM32F429I_DISCOVERY_LCD * @{ - */ + */ /** @defgroup STM32F429I_DISCOVERY_LCD_Exported_Types * @{ */ -typedef struct +typedef struct { int16_t X; int16_t Y; -} Point, * pPoint; +} Point, * pPoint; /** * @} - */ + */ /** @defgroup stm32f429i_discovery_LCD_Exported_Constants * @{ - */ + */ /* LCD Size (Width and Height) */ #define LCD_PIXEL_WIDTH ((uint16_t)240) #define LCD_PIXEL_HEIGHT ((uint16_t)320) #define LCD_FRAME_BUFFER ((uint32_t)0xD0000000) -#define BUFFER_OFFSET ((uint32_t)0x50000) +#define BUFFER_OFFSET ((uint32_t)0x50000) /** * @brief Uncomment the line below if you want to use user defined Delay function * (for precise timing), otherwise default _delay_ function defined within - * this driver is used (less precise timing). + * this driver is used (less precise timing). */ /* #define USE_Delay */ #ifdef USE_Delay -#include "main.h" +#include "main.h" #define _delay_ Delay /* !< User can provide more timing precise _delay_ function (with 10ms time base), using SysTick for example */ #else @@ -95,51 +95,51 @@ typedef struct #endif -/** - * @brief LCD Control pin - */ -#define LCD_NCS_PIN GPIO_Pin_2 -#define LCD_NCS_GPIO_PORT GPIOC -#define LCD_NCS_GPIO_CLK RCC_AHB1Periph_GPIOC +/** + * @brief LCD Control pin + */ +#define LCD_NCS_PIN GPIO_Pin_2 +#define LCD_NCS_GPIO_PORT GPIOC +#define LCD_NCS_GPIO_CLK RCC_AHB1Periph_GPIOC -/** - * @brief LCD Command/data pin +/** + * @brief LCD Command/data pin */ -#define LCD_WRX_PIN GPIO_Pin_13 +#define LCD_WRX_PIN GPIO_Pin_13 #define LCD_WRX_GPIO_PORT GPIOD -#define LCD_WRX_GPIO_CLK RCC_AHB1Periph_GPIOD +#define LCD_WRX_GPIO_CLK RCC_AHB1Periph_GPIOD -/** - * @brief LCD SPI Interface pins - */ +/** + * @brief LCD SPI Interface pins + */ #define LCD_SPI_SCK_PIN GPIO_Pin_7 /* PF.07 */ #define LCD_SPI_SCK_GPIO_PORT GPIOF /* GPIOF */ -#define LCD_SPI_SCK_GPIO_CLK RCC_AHB1Periph_GPIOF +#define LCD_SPI_SCK_GPIO_CLK RCC_AHB1Periph_GPIOF #define LCD_SPI_SCK_SOURCE GPIO_PinSource7 #define LCD_SPI_SCK_AF GPIO_AF_SPI5 #define LCD_SPI_MISO_PIN GPIO_Pin_8 /* PF.08 */ #define LCD_SPI_MISO_GPIO_PORT GPIOF /* GPIOF */ -#define LCD_SPI_MISO_GPIO_CLK RCC_AHB1Periph_GPIOF +#define LCD_SPI_MISO_GPIO_CLK RCC_AHB1Periph_GPIOF #define LCD_SPI_MISO_SOURCE GPIO_PinSource8 #define LCD_SPI_MISO_AF GPIO_AF_SPI5 #define LCD_SPI_MOSI_PIN GPIO_Pin_9 /* PF.09 */ #define LCD_SPI_MOSI_GPIO_PORT GPIOF /* GPIOF */ -#define LCD_SPI_MOSI_GPIO_CLK RCC_AHB1Periph_GPIOF +#define LCD_SPI_MOSI_GPIO_CLK RCC_AHB1Periph_GPIOF #define LCD_SPI_MOSI_SOURCE GPIO_PinSource9 #define LCD_SPI_MOSI_AF GPIO_AF_SPI5 #define LCD_SPI SPI5 -#define LCD_SPI_CLK RCC_APB2Periph_SPI5 +#define LCD_SPI_CLK RCC_APB2Periph_SPI5 -/** - * @brief LCD Registers - */ +/** + * @brief LCD Registers + */ #define LCD_SLEEP_OUT 0x11 /* Sleep out register */ #define LCD_GAMMA 0x26 /* Gamma register */ #define LCD_DISPLAY_OFF 0x28 /* Display off register */ #define LCD_DISPLAY_ON 0x29 /* Display on register */ -#define LCD_COLUMN_ADDR 0x2A /* Colomn address register */ -#define LCD_PAGE_ADDR 0x2B /* Page address register */ -#define LCD_GRAM 0x2C /* GRAM register */ +#define LCD_COLUMN_ADDR 0x2A /* Colomn address register */ +#define LCD_PAGE_ADDR 0x2B /* Page address register */ +#define LCD_GRAM 0x2C /* GRAM register */ #define LCD_MAC 0x36 /* Memory Access Control register*/ #define LCD_PIXEL_FORMAT 0x3A /* Pixel Format register */ #define LCD_WDB 0x51 /* Write Brightness Display register */ @@ -163,9 +163,9 @@ typedef struct #define LCD_INTERFACE 0xF6 /* Interface control register */ #define LCD_PRC 0xF7 /* Pump ratio control register */ -/** - * @brief LCD color - */ +/** + * @brief LCD color + */ #define LCD_COLOR_WHITE 0xFFFF #define LCD_COLOR_BLACK 0x0000 #define LCD_COLOR_GREY 0xF7DE @@ -177,8 +177,8 @@ typedef struct #define LCD_COLOR_CYAN 0x7FFF #define LCD_COLOR_YELLOW 0xFFE0 -/** - * @brief LCD Lines depending on the chosen fonts. +/** + * @brief LCD Lines depending on the chosen fonts. */ #define LCD_LINE_0 LINE(0) #define LCD_LINE_1 LINE(1) @@ -221,49 +221,50 @@ typedef struct #define LCD_LINE_38 LINE(38) #define LCD_LINE_39 LINE(39) -/** - * @brief LCD default font - */ +/** + * @brief LCD default font + */ #define LCD_DEFAULT_FONT Font16x24 -/** - * @brief LCD Direction - */ +/** + * @brief LCD Direction + */ #define LCD_DIR_HORIZONTAL 0x0000 #define LCD_DIR_VERTICAL 0x0001 /** * @} - */ + */ -/** - * @brief LCD Layer - */ +/** + * @brief LCD Layer + */ #define LCD_BACKGROUND_LAYER 0x0000 #define LCD_FOREGROUND_LAYER 0x0001 /** * @} - */ + */ /** @defgroup STM32F429I_DISCOVERY_LCD_Exported_Macros * @{ - */ + */ #define ASSEMBLE_RGB(R, G, B) ((((R)& 0xF8) << 8) | (((G) & 0xFC) << 3) | (((B) & 0xF8) >> 3)) +#define ASSEMBLE_RGB2(RGB) (((RGB.r & 0xF8) << 8) | (((RGB.g) & 0xFC) << 3) | (((RGB.b) & 0xF8) >> 3)) /** * @} - */ + */ /** @defgroup STM32F429I_DISCOVERY_LCD_Exported_Functions * @{ - */ -void LCD_DeInit(void); + */ +void LCD_DeInit(void); void LCD_Init(void); void LCD_LayerInit(void); void LCD_ChipSelect(FunctionalState NewState); void LCD_SetLayer(uint32_t Layerx); -void LCD_SetColors(uint16_t _TextColor, uint16_t _BackColor); +void LCD_SetColors(uint16_t _TextColor, uint16_t _BackColor); void LCD_GetColors(uint16_t *_TextColor, uint16_t *_BackColor); void LCD_SetTextColor(uint16_t Color); void LCD_SetBackColor(uint16_t Color); @@ -307,8 +308,8 @@ void LCD_CtrlLinesWrite(GPIO_TypeDef* GPIOx, uint16_t CtrlPins, BitAction Bi void LCD_SPIConfig(void); /** * @} - */ - + */ + #ifdef __cplusplus } #endif @@ -317,18 +318,18 @@ void LCD_SPIConfig(void); /** * @} - */ + */ /** * @} - */ + */ /** * @} - */ + */ /** * @} */ - + /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/uGL/uGL.c b/uGL/uGL.c index 7956045..d87c4d5 100644 --- a/uGL/uGL.c +++ b/uGL/uGL.c @@ -5,7 +5,7 @@ #include "stm32f429i_discovery_lcd.h" #include -static uint8_t *_framebuffer = (uint8_t *)LCD_FRAME_BUFFER; +static uint16_t *_framebuffer = (uint16_t *)(LCD_FRAME_BUFFER + BUFFER_OFFSET); static const uint16_t screenwidth = 240; static const uint16_t screenheight = 320; @@ -34,31 +34,23 @@ uint16_t uGL_getScreenWidth() return screenwidth; } - void uGL_drawPixel(uint16_t x, uint16_t y, uGL_color_t color) { - uint8_t c[3] = { color.r, color.g, color.b }; - //LCD_SetTextColor(ASSEMBLE_RGB(color.r, color.g, color.b)); - memcpy(c, _framebuffer + 3 * (x + screenwidth * y), 3 * sizeof(uint8_t)); - /*_framebuffer[3 * (x + screenwidth * y)] = color.r; - _framebuffer[3 * (x + screenwidth * y) + 1] = color.g; - _framebuffer[3 * (x + screenwidth * y) + 2] = color.b;*/ -// PutPixel(int16_t x, int16_t y); + _framebuffer[x + screenwidth * y] = ASSEMBLE_RGB2(color); } void uGL_drawHLine(uint16_t x, uint16_t y, uint16_t length, uGL_color_t color) { - LCD_SetTextColor(ASSEMBLE_RGB(color.r, color.g, color.b)); - LCD_DrawLine(x, y, length, LCD_DIR_HORIZONTAL); - //TODO: optimize -// for (int i = 0 ; i < length ; i++) -// uGL_drawPixel(x + i, y, color); + for (int i = 0 ; i < length ; i++) + uGL_drawPixel(x + i, y, color); } void uGL_drawVLine(uint16_t x, uint16_t y, uint16_t length, uGL_color_t color) { - LCD_SetTextColor(ASSEMBLE_RGB(color.r, color.g, color.b)); - LCD_DrawLine(x, y, length, LCD_DIR_VERTICAL); + LCD_SetTextColor(ASSEMBLE_RGB2(color)); + for (int i = 0 ; i < length ; i++) + uGL_drawPixel(x, y + i, color); + //LCD_DrawLine(x, y, length, LCD_DIR_VERTICAL); } void uGL_drawFrame(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uGL_color_t color) @@ -71,7 +63,9 @@ void uGL_drawFrame(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uGL_ void uGL_drawRectangle(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uGL_color_t color) { - LCD_SetTextColor(ASSEMBLE_RGB(color.r, color.g, color.b)); + LCD_SetTextColor(ASSEMBLE_RGB2(color)); +// LCD_SetTextColor(color); + //LCD_SetTextColor(ASSEMBLE_RGB(color.r, color.g, color.b)); LCD_DrawFullRect(x, y, width, height); } diff --git a/uGL/uGL.h b/uGL/uGL.h index b5c67d1..d6b268f 100644 --- a/uGL/uGL.h +++ b/uGL/uGL.h @@ -2,7 +2,7 @@ #include -typedef struct { +typedef union { uint8_t r; uint8_t g; uint8_t b; From 2599693f4fec12809a47dc19f2155acc213fecfd Mon Sep 17 00:00:00 2001 From: Thomas Pietrzak Date: Tue, 25 Sep 2018 23:04:18 +0200 Subject: [PATCH 07/11] fix colors --- bootloader.c | 44 +++++++++++++++++++++++++++------- uGL/stm32f429i_discovery_lcd.c | 32 +++++-------------------- uGL/stm32f429i_discovery_lcd.h | 37 +--------------------------- uGL/uGL.c | 4 +++- uGL/uGL.h | 2 +- 5 files changed, 47 insertions(+), 72 deletions(-) diff --git a/bootloader.c b/bootloader.c index 5eb1443..9636acd 100644 --- a/bootloader.c +++ b/bootloader.c @@ -2,6 +2,32 @@ #include "uGL/uGL.h" +void drawRainbow() +{ + uGL_color_t c; + for (uint16_t i = 0 ; i < 40 ; i++) + { + //rouge => jaune + c.r = 0xff; c.g = i * 0xff / 40; c.b = 0x00; + uGL_drawVLine(i, 0, 10, c); + //jaune => vert + c.r = 0xff - i * 0xff / 40; c.g = 0xff; c.b = 0x00; + uGL_drawVLine(i + 40, 0, 10, c); + //vert => cyan + c.r = 0x00; c.g = 0xff; c.b = i * 0xff / 40; + uGL_drawVLine(i + 80, 0, 10, c); + //cyan => bleu + c.r = 0x00; c.g = 0xff - i * 0xff / 40; c.b = 0xff; + uGL_drawVLine(i + 120, 0, 10, c); + //bleu => violet + c.r = i * 0xff / 40; c.g = 0x00; c.b = 0xff; + uGL_drawVLine(i + 160, 0, 10, c); + //violet => rouge + c.r = 0xff; c.g = 0x00; c.b = 0xff - i * 0xff / 40; + uGL_drawVLine(i + 200, 0, 10, c); + } +} + int main() { uGL_init(); @@ -9,6 +35,13 @@ int main() uGL_color_t backgroundcolor = { .r = 255, .g = 255, .b = 255 }; uGL_drawRectangle(0, 0, 240, 320, backgroundcolor); + uGL_color_t black = { .r = 0, .g = 0, .b = 0 }; + for (uint8_t i = 0 ; i < 6 ; i++) + uGL_drawHLine(0, i * 50, 240, black); + + for (uint8_t i = 0 ; i < 4 ; i++) + uGL_drawVLine(i * 50, 0, 320, black); + uGL_color_t gradientcolor = { .r = 0, .g = 0, .b = 0 }; for (uint8_t i = 0 ; i < 255 ; i++) { @@ -17,21 +50,16 @@ int main() uGL_drawHLine(20, i, 10, gradientcolor); } - uGL_color_t black = { .r = 0, .g = 0, .b = 0 }; - for (uint8_t i = 0 ; i < 6 ; i++) - uGL_drawHLine(0, i * 50, 240, black); - - for (uint8_t i = 0 ; i < 4 ; i++) - uGL_drawVLine(i * 50, 0, 320, black); + drawRainbow(); uGL_color_t rectcolor = { .r = 250, .g = 120, .b = 10 }; uGL_drawFrame(10, 30, 100, 50, rectcolor); uGL_color_t hlinecolor = { .r = 50, .g = 240, .b = 20 }; - uGL_drawHLine(20, 50, 100, hlinecolor); + uGL_drawHLine(120, 80, 100, hlinecolor); uGL_color_t vlinecolor = { .r = 250, .g = 240, .b = 10 }; - uGL_drawVLine(50, 20, 200, vlinecolor); + uGL_drawVLine(90, 20, 200, vlinecolor); while(1); return 0; diff --git a/uGL/stm32f429i_discovery_lcd.c b/uGL/stm32f429i_discovery_lcd.c index 2e31ba4..a27be64 100755 --- a/uGL/stm32f429i_discovery_lcd.c +++ b/uGL/stm32f429i_discovery_lcd.c @@ -298,7 +298,7 @@ void LCD_WriteChunk(uint8_t command, uint8_t *data, uint8_t nb) gpio_set(lcd_wrx, 0); gpio_set(lcd_ncs, 0); ssp_write(ssp_5, command); - while(SPI_I2S_GetFlagStatus(LCD_SPI, SPI_I2S_FLAG_BSY) != RESET); + while(SPI_I2S_GetFlagStatus(SPI5, SPI_I2S_FLAG_BSY) != RESET); //gpio_set(lcd_ncs, 1); for (int i = 0 ; i < nb ; i++) @@ -306,8 +306,7 @@ void LCD_WriteChunk(uint8_t command, uint8_t *data, uint8_t nb) gpio_set(lcd_wrx, 1); //gpio_set(lcd_ncs, 0); ssp_write(ssp_5, data[i]); - while(SPI_I2S_GetFlagStatus(LCD_SPI, SPI_I2S_FLAG_BSY) != RESET); - + while(SPI_I2S_GetFlagStatus(SPI5, SPI_I2S_FLAG_BSY) != RESET); } gpio_set(lcd_ncs, 1); } @@ -431,26 +430,6 @@ void LCD_DisplayOff(void) - - - -/** - * @brief Controls LCD Chip Select (CS) pin - * @param NewState CS pin state - * @retval None - */ -void LCD_ChipSelect(FunctionalState NewState) -{ - if (NewState == DISABLE) - { - GPIO_ResetBits(LCD_NCS_GPIO_PORT, LCD_NCS_PIN); /* CS pin low: LCD disabled */ - } - else - { - GPIO_SetBits(LCD_NCS_GPIO_PORT, LCD_NCS_PIN); /* CS pin high: LCD enabled */ - } -} - /** * @brief Sets the LCD Layer. * @param Layerx: specifies the Layer foreground or background. @@ -1592,7 +1571,7 @@ static void delay(__IO uint32_t nCount) /** @defgroup STM32F429I_DISCOVERY_LCD_Private_Functions * @{ */ - +#if 0 /** * @brief DeInitializes the LCD. * @param None @@ -1606,10 +1585,10 @@ void LCD_DeInit(void) LCD_DisplayOff(); /* LCD_SPI disable */ - SPI_Cmd(LCD_SPI, DISABLE); + SPI_Cmd(SPI_5, DISABLE); /* LCD_SPI DeInit */ - SPI_I2S_DeInit(LCD_SPI); + SPI_I2S_DeInit(SPI_5); /* Disable SPI clock */ RCC_APB2PeriphClockCmd(LCD_SPI_CLK, DISABLE); @@ -1709,3 +1688,4 @@ void LCD_DeInit(void) GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; GPIO_Init(GPIOG, &GPIO_InitStructure); } +#endif diff --git a/uGL/stm32f429i_discovery_lcd.h b/uGL/stm32f429i_discovery_lcd.h index 6ff8125..5d50f13 100755 --- a/uGL/stm32f429i_discovery_lcd.h +++ b/uGL/stm32f429i_discovery_lcd.h @@ -95,41 +95,6 @@ typedef struct #endif -/** - * @brief LCD Control pin - */ -#define LCD_NCS_PIN GPIO_Pin_2 -#define LCD_NCS_GPIO_PORT GPIOC -#define LCD_NCS_GPIO_CLK RCC_AHB1Periph_GPIOC - -/** - * @brief LCD Command/data pin - */ -#define LCD_WRX_PIN GPIO_Pin_13 -#define LCD_WRX_GPIO_PORT GPIOD -#define LCD_WRX_GPIO_CLK RCC_AHB1Periph_GPIOD - -/** - * @brief LCD SPI Interface pins - */ -#define LCD_SPI_SCK_PIN GPIO_Pin_7 /* PF.07 */ -#define LCD_SPI_SCK_GPIO_PORT GPIOF /* GPIOF */ -#define LCD_SPI_SCK_GPIO_CLK RCC_AHB1Periph_GPIOF -#define LCD_SPI_SCK_SOURCE GPIO_PinSource7 -#define LCD_SPI_SCK_AF GPIO_AF_SPI5 -#define LCD_SPI_MISO_PIN GPIO_Pin_8 /* PF.08 */ -#define LCD_SPI_MISO_GPIO_PORT GPIOF /* GPIOF */ -#define LCD_SPI_MISO_GPIO_CLK RCC_AHB1Periph_GPIOF -#define LCD_SPI_MISO_SOURCE GPIO_PinSource8 -#define LCD_SPI_MISO_AF GPIO_AF_SPI5 -#define LCD_SPI_MOSI_PIN GPIO_Pin_9 /* PF.09 */ -#define LCD_SPI_MOSI_GPIO_PORT GPIOF /* GPIOF */ -#define LCD_SPI_MOSI_GPIO_CLK RCC_AHB1Periph_GPIOF -#define LCD_SPI_MOSI_SOURCE GPIO_PinSource9 -#define LCD_SPI_MOSI_AF GPIO_AF_SPI5 -#define LCD_SPI SPI5 -#define LCD_SPI_CLK RCC_APB2Periph_SPI5 - /** * @brief LCD Registers */ @@ -250,7 +215,7 @@ typedef struct * @{ */ #define ASSEMBLE_RGB(R, G, B) ((((R)& 0xF8) << 8) | (((G) & 0xFC) << 3) | (((B) & 0xF8) >> 3)) -#define ASSEMBLE_RGB2(RGB) (((RGB.r & 0xF8) << 8) | (((RGB.g) & 0xFC) << 3) | (((RGB.b) & 0xF8) >> 3)) +//#define ASSEMBLE_RGB2(RGB) (((((uint16_t)(RGB.r)) & 0xF8) << 8) | ((((uint16_t)(RGB.g)) & 0xFC) << 3) | ((((uint16_t)(RGB.b)) & 0xF8) >> 3)) /** * @} diff --git a/uGL/uGL.c b/uGL/uGL.c index d87c4d5..c93d199 100644 --- a/uGL/uGL.c +++ b/uGL/uGL.c @@ -5,10 +5,12 @@ #include "stm32f429i_discovery_lcd.h" #include -static uint16_t *_framebuffer = (uint16_t *)(LCD_FRAME_BUFFER + BUFFER_OFFSET); +static uint16_t *_framebuffer = (uint16_t *)(0xD0000000 + 0x50000); static const uint16_t screenwidth = 240; static const uint16_t screenheight = 320; +#define ASSEMBLE_RGB2(RGB) ((((RGB.r) & 0xF8) << 8) | (((RGB.g) & 0xFC) << 3) | (((RGB.b) & 0xF8) >> 3)) + void uGL_init() { LCD_Init(); diff --git a/uGL/uGL.h b/uGL/uGL.h index d6b268f..b5c67d1 100644 --- a/uGL/uGL.h +++ b/uGL/uGL.h @@ -2,7 +2,7 @@ #include -typedef union { +typedef struct { uint8_t r; uint8_t g; uint8_t b; From b6a812261f218e70961b2b3e335a89267fc80ac5 Mon Sep 17 00:00:00 2001 From: Thomas Pietrzak Date: Thu, 4 Oct 2018 11:02:18 +0200 Subject: [PATCH 08/11] lcd integration --- Makefile | 2 +- uC-sdk | 2 +- uGL/Makefile | 2 +- uGL/stm32f429i_discovery_lcd.c | 1691 ------------------------------ uGL/stm32f429i_discovery_lcd.dep | 57 - uGL/stm32f429i_discovery_lcd.h | 300 ------ uGL/uGL.c | 248 ++++- uGL/uGL.h | 3 + 8 files changed, 240 insertions(+), 2065 deletions(-) delete mode 100755 uGL/stm32f429i_discovery_lcd.c delete mode 100644 uGL/stm32f429i_discovery_lcd.dep delete mode 100755 uGL/stm32f429i_discovery_lcd.h diff --git a/Makefile b/Makefile index 9d3b68e..e5272d7 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ export ROOTDIR = $(CURDIR)/uC-sdk export VERBOSE = true TARGET = bootloader.bin -TARGET_SRCS = bootloader.c uGL/uGL.c uGL/stm32f429i_discovery.c uGL/stm32f429i_discovery_lcd.c uGL/stm32f429i_discovery_sdram.c uGL/fonts.c +TARGET_SRCS = bootloader.c uGL/uGL.c uGL/stm32f429i_discovery.c uGL/stm32f429i_discovery_sdram.c uGL/fonts.c LIBDEPS = \ $(ROOTDIR)/FreeRTOS/libFreeRTOS.a \ diff --git a/uC-sdk b/uC-sdk index 6c9a872..e42bd8c 160000 --- a/uC-sdk +++ b/uC-sdk @@ -1 +1 @@ -Subproject commit 6c9a872c309c264129aab94a5e1afc633839345e +Subproject commit e42bd8c59b0318772831261f87ace7aeeef756dc diff --git a/uGL/Makefile b/uGL/Makefile index 3709846..f39c23f 100644 --- a/uGL/Makefile +++ b/uGL/Makefile @@ -9,7 +9,7 @@ include $(ROOTDIR)/FreeRTOS/config.mk TARGET_SRCS += font.cs TARGET_SRCS += stm32f429i_discovery.c -TARGET_SRCS += stm32f429i_discovery_lcd.c +#TARGET_SRCS += stm32f429i_discovery_lcd.c TARGET_SRCS += stm32f429i_discovery_sdram.c include $(ROOTDIR)/target-rules.mk diff --git a/uGL/stm32f429i_discovery_lcd.c b/uGL/stm32f429i_discovery_lcd.c deleted file mode 100755 index a27be64..0000000 --- a/uGL/stm32f429i_discovery_lcd.c +++ /dev/null @@ -1,1691 +0,0 @@ -/** - ****************************************************************************** - * @file stm32f429i_discovery_lcd.c - * @author MCD Application Team - * @version V1.0.1 - * @date 28-October-2013 - * @brief This file includes the LCD driver for ILI9341 Liquid Crystal - * Display Modules of STM32F429I-DISCO kit (MB1075). - ****************************************************************************** - * @attention - * - *

© COPYRIGHT 2013 STMicroelectronics

- * - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - ****************************************************************************** - */ - -/* Includes ------------------------------------------------------------------*/ -#include "stm32f429i_discovery_lcd.h" -#include "stm32f4xx_ltdc.h" -#include "stm32f4xx_dma2d.h" -//#include "fonts.c" - -#include - -#include -#include -ssp_port_t lcd_port = { - .ssp = ssp_5, - .sclk = { .port = gpio_port_f, .pin = 7 }, - .mosi = { .port = gpio_port_f, .pin = 9 }, - .miso = { .port = gpio_port_f, .pin = 8 }, - .ss = PIN_NULL, - .mode = ssp_master - }; -pin_t lcd_ncs = { .port = gpio_port_c, .pin = 2 }; -pin_t lcd_wrx = { .port = gpio_port_d, .pin = 13 }; - - - - - -#define POLY_Y(Z) ((int32_t)((Points + Z)->X)) -#define POLY_X(Z) ((int32_t)((Points + Z)->Y)) -#define ABS(X) ((X) > 0 ? (X) : -(X)) - -static sFONT *LCD_Currentfonts; -/* Global variables to set the written text color */ -static uint16_t CurrentTextColor = 0x0000; -static uint16_t CurrentBackColor = 0xFFFF; -/* Default LCD configuration with LCD Layer 1 */ -static uint32_t CurrentFrameBuffer = LCD_FRAME_BUFFER; -static uint32_t CurrentLayer = LCD_BACKGROUND_LAYER; - -#ifndef USE_Delay -static void delay(__IO uint32_t nCount); -#endif /* USE_Delay*/ - -static void PutPixel(int16_t x, int16_t y); -static void LCD_PolyLineRelativeClosed(pPoint Points, uint16_t PointCount, uint16_t Closed); - - - -void LCD_Init(void) -{ - LTDC_InitTypeDef LTDC_InitStruct; - - /* Configure the LCD Control pins ------------------------------------------*/ - gpio_config(lcd_ncs, pin_dir_write, pull_none); - gpio_config(lcd_wrx, pin_dir_write, pull_none); - - gpio_set(lcd_ncs, 0); - gpio_set(lcd_ncs, 1); - - ssp_config(lcd_port, 5600000); - - - -// LCD_ChipSelect(DISABLE); -// LCD_ChipSelect(ENABLE); - - /* Configure the LCD_SPI interface -----------------------------------------*/ -// LCD_SPIConfig(); - - /* Power on the LCD --------------------------------------------------------*/ - LCD_PowerOn(); - - /* Enable the LTDC Clock */ - RCC_APB2PeriphClockCmd(RCC_APB2Periph_LTDC, ENABLE); - - /* Enable the DMA2D Clock */ - RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA2D, ENABLE); - - /* Configure the LCD Control pins */ -/* - +------------------------+-----------------------+----------------------------+ - + LCD pins assignment + - +------------------------+-----------------------+----------------------------+ - | LCD_TFT R2 <-> PC.10 | LCD_TFT G2 <-> PA.06 | LCD_TFT B2 <-> PD.06 | - | LCD_TFT R3 <-> PB.00 | LCD_TFT G3 <-> PG.10 | LCD_TFT B3 <-> PG.11 | - | LCD_TFT R4 <-> PA.11 | LCD_TFT G4 <-> PB.10 | LCD_TFT B4 <-> PG.12 | - | LCD_TFT R5 <-> PA.12 | LCD_TFT G5 <-> PB.11 | LCD_TFT B5 <-> PA.03 | - | LCD_TFT R6 <-> PB.01 | LCD_TFT G6 <-> PC.07 | LCD_TFT B6 <-> PB.08 | - | LCD_TFT R7 <-> PG.06 | LCD_TFT G7 <-> PD.03 | LCD_TFT B7 <-> PB.09 | - ------------------------------------------------------------------------------- - | LCD_TFT HSYNC <-> PC.06 | LCDTFT VSYNC <-> PA.04 | - | LCD_TFT CLK <-> PG.07 | LCD_TFT DE <-> PF.10 | - ----------------------------------------------------- -*/ - pin_t lcd_pin[] = { - //r - make_pin(gpio_port_c, 10), - make_pin(gpio_port_b, 0), - make_pin(gpio_port_a, 11), - make_pin(gpio_port_a, 12), - make_pin(gpio_port_b, 1), - make_pin(gpio_port_g, 6), - //g - make_pin(gpio_port_a, 6), - make_pin(gpio_port_g, 10), - make_pin(gpio_port_b, 10), - make_pin(gpio_port_b, 11), - make_pin(gpio_port_c, 7), - make_pin(gpio_port_d, 3), - //b - make_pin(gpio_port_d, 6), - make_pin(gpio_port_g, 11), - make_pin(gpio_port_g, 12), - make_pin(gpio_port_a, 3), - make_pin(gpio_port_b, 8), - make_pin(gpio_port_b, 9), - //hsync - make_pin(gpio_port_c, 6), - //vsync - make_pin(gpio_port_a, 4), - //clk - make_pin(gpio_port_g, 7), - //de - make_pin(gpio_port_f, 10), - }; - for (int i = 0 ; i < 22 ; i++) - gpio_config_alternate(lcd_pin[i], pin_dir_write, pull_none, 0x0E); - - - - - /* Configure the FMC Parallel interface : SDRAM is used as Frame Buffer for LCD */ - SDRAM_Init(); - - /* LTDC Configuration *********************************************************/ - /* Polarity configuration */ - /* Initialize the horizontal synchronization polarity as active low */ - LTDC_InitStruct.LTDC_HSPolarity = LTDC_HSPolarity_AL; - /* Initialize the vertical synchronization polarity as active low */ - LTDC_InitStruct.LTDC_VSPolarity = LTDC_VSPolarity_AL; - /* Initialize the data enable polarity as active low */ - LTDC_InitStruct.LTDC_DEPolarity = LTDC_DEPolarity_AL; - /* Initialize the pixel clock polarity as input pixel clock */ - LTDC_InitStruct.LTDC_PCPolarity = LTDC_PCPolarity_IPC; - - /* Configure R,G,B component values for LCD background color */ - LTDC_InitStruct.LTDC_BackgroundRedValue = 0; - LTDC_InitStruct.LTDC_BackgroundGreenValue = 0; - LTDC_InitStruct.LTDC_BackgroundBlueValue = 0; - - /* Configure PLLSAI prescalers for LCD */ - /* Enable Pixel Clock */ - /* PLLSAI_VCO Input = HSE_VALUE/PLL_M = 1 Mhz */ - /* PLLSAI_VCO Output = PLLSAI_VCO Input * PLLSAI_N = 192 Mhz */ - /* PLLLCDCLK = PLLSAI_VCO Output/PLLSAI_R = 192/4 = 48 Mhz */ - /* LTDC clock frequency = PLLLCDCLK / RCC_PLLSAIDivR = 48/8 = 6 Mhz */ - RCC_PLLSAIConfig(192, 7, 4); - RCC_LTDCCLKDivConfig(RCC_PLLSAIDivR_Div8); - - /* Enable PLLSAI Clock */ - RCC_PLLSAICmd(ENABLE); - /* Wait for PLLSAI activation */ - while(RCC_GetFlagStatus(RCC_FLAG_PLLSAIRDY) == RESET) - { - } - - /* Timing configuration */ - /* Configure horizontal synchronization width */ - LTDC_InitStruct.LTDC_HorizontalSync = 9; - /* Configure vertical synchronization height */ - LTDC_InitStruct.LTDC_VerticalSync = 1; - /* Configure accumulated horizontal back porch */ - LTDC_InitStruct.LTDC_AccumulatedHBP = 29; - /* Configure accumulated vertical back porch */ - LTDC_InitStruct.LTDC_AccumulatedVBP = 3; - /* Configure accumulated active width */ - LTDC_InitStruct.LTDC_AccumulatedActiveW = 269; - /* Configure accumulated active height */ - LTDC_InitStruct.LTDC_AccumulatedActiveH = 323; - /* Configure total width */ - LTDC_InitStruct.LTDC_TotalWidth = 279; - /* Configure total height */ - LTDC_InitStruct.LTDC_TotalHeigh = 327; - - LTDC_Init(<DC_InitStruct); -} - - -/** - * @brief Initializes the LCD Layers. - * @param None - * @retval None - */ -void LCD_LayerInit(void) -{ - LTDC_Layer_InitTypeDef LTDC_Layer_InitStruct; - - /* Windowing configuration */ - /* In this case all the active display area is used to display a picture then : - Horizontal start = horizontal synchronization + Horizontal back porch = 30 - Horizontal stop = Horizontal start + window width -1 = 30 + 240 -1 - Vertical start = vertical synchronization + vertical back porch = 4 - Vertical stop = Vertical start + window height -1 = 4 + 320 -1 */ - LTDC_Layer_InitStruct.LTDC_HorizontalStart = 30; - LTDC_Layer_InitStruct.LTDC_HorizontalStop = (LCD_PIXEL_WIDTH + 30 - 1); - LTDC_Layer_InitStruct.LTDC_VerticalStart = 4; - LTDC_Layer_InitStruct.LTDC_VerticalStop = (LCD_PIXEL_HEIGHT + 4 - 1); - - /* Pixel Format configuration*/ - LTDC_Layer_InitStruct.LTDC_PixelFormat = LTDC_Pixelformat_RGB565; - /* Alpha constant (255 totally opaque) */ - LTDC_Layer_InitStruct.LTDC_ConstantAlpha = 255; - /* Default Color configuration (configure A,R,G,B component values) */ - LTDC_Layer_InitStruct.LTDC_DefaultColorBlue = 0; - LTDC_Layer_InitStruct.LTDC_DefaultColorGreen = 0; - LTDC_Layer_InitStruct.LTDC_DefaultColorRed = 0; - LTDC_Layer_InitStruct.LTDC_DefaultColorAlpha = 0; - /* Configure blending factors */ - LTDC_Layer_InitStruct.LTDC_BlendingFactor_1 = LTDC_BlendingFactor1_CA; - LTDC_Layer_InitStruct.LTDC_BlendingFactor_2 = LTDC_BlendingFactor2_CA; - - /* the length of one line of pixels in bytes + 3 then : - Line Lenth = Active high width x number of bytes per pixel + 3 - Active high width = LCD_PIXEL_WIDTH - number of bytes per pixel = 2 (pixel_format : RGB565) - */ - LTDC_Layer_InitStruct.LTDC_CFBLineLength = ((LCD_PIXEL_WIDTH * 2) + 3); - /* the pitch is the increment from the start of one line of pixels to the - start of the next line in bytes, then : - Pitch = Active high width x number of bytes per pixel */ - LTDC_Layer_InitStruct.LTDC_CFBPitch = (LCD_PIXEL_WIDTH * 2); - - /* Configure the number of lines */ - LTDC_Layer_InitStruct.LTDC_CFBLineNumber = LCD_PIXEL_HEIGHT; - - /* Start Address configuration : the LCD Frame buffer is defined on SDRAM */ - LTDC_Layer_InitStruct.LTDC_CFBStartAdress = LCD_FRAME_BUFFER; - - /* Initialize LTDC layer 1 */ - LTDC_LayerInit(LTDC_Layer1, <DC_Layer_InitStruct); - - /* Configure Layer2 */ - /* Start Address configuration : the LCD Frame buffer is defined on SDRAM w/ Offset */ - LTDC_Layer_InitStruct.LTDC_CFBStartAdress = LCD_FRAME_BUFFER + BUFFER_OFFSET; - - /* Configure blending factors */ - LTDC_Layer_InitStruct.LTDC_BlendingFactor_1 = LTDC_BlendingFactor1_PAxCA; - LTDC_Layer_InitStruct.LTDC_BlendingFactor_2 = LTDC_BlendingFactor2_PAxCA; - - /* Initialize LTDC layer 2 */ - LTDC_LayerInit(LTDC_Layer2, <DC_Layer_InitStruct); - - /* LTDC configuration reload */ - LTDC_ReloadConfig(LTDC_IMReload); - - /* Enable foreground & background Layers */ - LTDC_LayerCmd(LTDC_Layer1, ENABLE); - LTDC_LayerCmd(LTDC_Layer2, ENABLE); - - /* LTDC configuration reload */ - LTDC_ReloadConfig(LTDC_IMReload); - - /* Set default font */ - LCD_SetFont(&LCD_DEFAULT_FONT); - - /* dithering activation */ - LTDC_DitherCmd(ENABLE); -} - -void LCD_WriteChunk(uint8_t command, uint8_t *data, uint8_t nb) -{ - gpio_set(lcd_wrx, 0); - gpio_set(lcd_ncs, 0); - ssp_write(ssp_5, command); - while(SPI_I2S_GetFlagStatus(SPI5, SPI_I2S_FLAG_BSY) != RESET); - //gpio_set(lcd_ncs, 1); - - for (int i = 0 ; i < nb ; i++) - { - gpio_set(lcd_wrx, 1); - //gpio_set(lcd_ncs, 0); - ssp_write(ssp_5, data[i]); - while(SPI_I2S_GetFlagStatus(SPI5, SPI_I2S_FLAG_BSY) != RESET); - } - gpio_set(lcd_ncs, 1); -} - - -/** - * @brief Configure the LCD controller (Power On sequence as described in ILI9341 Datasheet) - * @param None - * @retval None - */ -void LCD_PowerOn(void) -{ - uint8_t buffer_init[] = {0xC3, 0x08, 0x50}; - LCD_WriteChunk(0xCA, buffer_init, 3); - - uint8_t buffer_powerb[] = {0x00, 0xC1, 0x30}; - LCD_WriteChunk(LCD_POWERB, buffer_powerb, 3); - - uint8_t buffer_powerseq[] = {0x64, 0x03, 0x12, 0x81}; - LCD_WriteChunk(LCD_POWER_SEQ, buffer_powerseq, 4); - - uint8_t buffer_dtca[] = {0x85, 0x00, 0x78}; - LCD_WriteChunk(LCD_DTCA, buffer_dtca, 3); - - uint8_t buffer_powera[] = {0x39, 0x2C, 0x00, 0x34, 0x02}; - LCD_WriteChunk(LCD_DTCA, buffer_powera, 5); - - uint8_t buffer_prc[] = {0x20}; - LCD_WriteChunk(LCD_PRC, buffer_prc, 1); - - uint8_t buffer_dtcb[] = {0x00, 0x00}; - LCD_WriteChunk(LCD_DTCB, buffer_dtcb, 2); - - uint8_t buffer_frc[] = {0x00, 0x1B}; - LCD_WriteChunk(LCD_FRC, buffer_frc, 2); - - uint8_t buffer_dfc[] = {0x0A, 0xA2}; - LCD_WriteChunk(LCD_DFC, buffer_dfc, 2); - - uint8_t buffer_power1[] = {0x10}; - LCD_WriteChunk(LCD_POWER1, buffer_power1, 1); - - uint8_t buffer_power2[] = {0x10}; - LCD_WriteChunk(LCD_POWER2, buffer_power2, 1); - - uint8_t buffer_vcom1[] = {0x45, 0x15}; - LCD_WriteChunk(LCD_VCOM1, buffer_vcom1, 2); - - uint8_t buffer_vcom2[] = {0x90}; - LCD_WriteChunk(LCD_VCOM2, buffer_vcom2, 1); - - uint8_t buffer_mac[] = {0xC8}; - LCD_WriteChunk(LCD_MAC, buffer_mac, 1); - - uint8_t buffer_3gammaen[] = {0x00}; - LCD_WriteChunk(LCD_3GAMMA_EN, buffer_3gammaen, 1); - - uint8_t buffer_rgbinterface[] = {0xc2}; - LCD_WriteChunk(LCD_RGB_INTERFACE, buffer_rgbinterface, 1); - - uint8_t buffer_dfc2[] = {0x0A, 0xA7, 0x27, 0x04}; - LCD_WriteChunk(LCD_DFC, buffer_dfc2, 4); - - uint8_t buffer_coladdr[] = {0x00, 0x00, 0x00, 0xEF}; - LCD_WriteChunk(LCD_COLUMN_ADDR, buffer_coladdr, 4); - - uint8_t buffer_pageaddr[] = {0x00, 0x00, 0x01, 0x3F}; - LCD_WriteChunk(LCD_PAGE_ADDR, buffer_pageaddr, 4); - - uint8_t buffer_interface[] = {0x01, 0x00, 0x06}; - LCD_WriteChunk(LCD_INTERFACE, buffer_interface, 3); - - LCD_WriteChunk(LCD_GRAM, NULL, 0); - - delay(200); - - uint8_t buffer_gamma[] = {0x01}; - LCD_WriteChunk(LCD_GAMMA, buffer_gamma, 1); - - uint8_t buffer_pgamma[] = {0x0F, 0x29, 0x24, 0x0C, 0x0E, 0x09, 0x4E, 0x78, 0x3C, 0x09, 0x13, 0x05, 0x17, 0x11, 0x00}; - LCD_WriteChunk(LCD_PGAMMA, buffer_pgamma, 15); - - uint8_t buffer_ngamma[] = {0x00, 0x16, 0x1B, 0x04, 0x11, 0x07, 0x31, 0x33, 0x42, 0x05, 0x0C, 0x0A, 0x28, 0x2F, 0x0F}; - LCD_WriteChunk(LCD_NGAMMA, buffer_ngamma, 15); - - LCD_WriteChunk(LCD_SLEEP_OUT, NULL, 0); - - delay(200); - - LCD_WriteChunk(LCD_DISPLAY_ON, NULL, 0); - LCD_WriteChunk(LCD_GRAM, NULL, 0); -} - -/** - * @brief Enables the Display. - * @param None - * @retval None - */ -void LCD_DisplayOn(void) -{ - LCD_WriteChunk(LCD_DISPLAY_ON, NULL, 0); -} - -/** - * @brief Disables the Display. - * @param None - * @retval None - */ -void LCD_DisplayOff(void) -{ - LCD_WriteChunk(LCD_DISPLAY_OFF, NULL, 0); -} - - - - - - - - - - - -/** - * @brief Sets the LCD Layer. - * @param Layerx: specifies the Layer foreground or background. - * @retval None - */ -void LCD_SetLayer(uint32_t Layerx) -{ - if (Layerx == LCD_BACKGROUND_LAYER) - { - CurrentFrameBuffer = LCD_FRAME_BUFFER; - CurrentLayer = LCD_BACKGROUND_LAYER; - } - else - { - CurrentFrameBuffer = LCD_FRAME_BUFFER + BUFFER_OFFSET; - CurrentLayer = LCD_FOREGROUND_LAYER; - } -} - -/** - * @brief Sets the LCD Text and Background colors. - * @param TextColor: specifies the Text Color. - * @param BackColor: specifies the Background Color. - * @retval None - */ -void LCD_SetColors(uint16_t TextColor, uint16_t BackColor) -{ - CurrentTextColor = TextColor; - CurrentBackColor = BackColor; -} - -/** - * @brief Gets the LCD Text and Background colors. - * @param TextColor: pointer to the variable that will contain the Text - Color. - * @param BackColor: pointer to the variable that will contain the Background - Color. - * @retval None - */ -void LCD_GetColors(uint16_t *TextColor, uint16_t *BackColor) -{ - *TextColor = CurrentTextColor; - *BackColor = CurrentBackColor; -} - -/** - * @brief Sets the Text color. - * @param Color: specifies the Text color code RGB(5-6-5). - * @retval None - */ -void LCD_SetTextColor(uint16_t Color) -{ - CurrentTextColor = Color; -} - -/** - * @brief Sets the Background color. - * @param Color: specifies the Background color code RGB(5-6-5). - * @retval None - */ -void LCD_SetBackColor(uint16_t Color) -{ - CurrentBackColor = Color; -} - -/** - * @brief Sets the Text Font. - * @param fonts: specifies the font to be used. - * @retval None - */ -void LCD_SetFont(sFONT *fonts) -{ - LCD_Currentfonts = fonts; -} - -/** - * @brief Configure the transparency. - * @param transparency: specifies the transparency, - * This parameter must range from 0x00 to 0xFF. - * @retval None - */ -void LCD_SetTransparency(uint8_t transparency) -{ - if (CurrentLayer == LCD_BACKGROUND_LAYER) - { - LTDC_LayerAlpha(LTDC_Layer1, transparency); - } - else - { - LTDC_LayerAlpha(LTDC_Layer2, transparency); - } - LTDC_ReloadConfig(LTDC_IMReload); -} - -/** - * @brief Gets the Text Font. - * @param None. - * @retval the used font. - */ -sFONT *LCD_GetFont(void) -{ - return LCD_Currentfonts; -} - -/** - * @brief Clears the selected line. - * @param Line: the Line to be cleared. - * This parameter can be one of the following values: - * @arg LCD_LINE_x: where x can be: 0..13 if LCD_Currentfonts is Font16x24 - * 0..26 if LCD_Currentfonts is Font12x12 or Font8x12 - * 0..39 if LCD_Currentfonts is Font8x8 - * @retval None - */ -void LCD_ClearLine(uint16_t Line) -{ - uint16_t refcolumn = 0; - /* Send the string character by character on lCD */ - while ((refcolumn < LCD_PIXEL_WIDTH) && (((refcolumn + LCD_Currentfonts->Width)& 0xFFFF) >= LCD_Currentfonts->Width)) - { - /* Display one character on LCD */ - LCD_DisplayChar(Line, refcolumn, ' '); - /* Decrement the column position by 16 */ - refcolumn += LCD_Currentfonts->Width; - } -} - -/** - * @brief Clears the hole LCD. - * @param Color: the color of the background. - * @retval None - */ -void LCD_Clear(uint16_t Color) -{ - uint32_t index = 0; - - /* erase memory */ - for (index = 0x00; index < BUFFER_OFFSET; index++) - { - *(__IO uint16_t*)(CurrentFrameBuffer + (2*index)) = Color; - } -} - -/** - * @brief Sets the cursor position. - * @param Xpos: specifies the X position. - * @param Ypos: specifies the Y position. - * @retval Display Address - */ -uint32_t LCD_SetCursor(uint16_t Xpos, uint16_t Ypos) -{ - return CurrentFrameBuffer + 2*(Xpos + (LCD_PIXEL_WIDTH*Ypos)); -} - -/** - * @brief Config and Sets the color Keying. - * @param RGBValue: Specifies the Color reference. - * @retval None - */ -void LCD_SetColorKeying(uint32_t RGBValue) -{ - LTDC_ColorKeying_InitTypeDef LTDC_colorkeying_InitStruct; - - /* configure the color Keying */ - LTDC_colorkeying_InitStruct.LTDC_ColorKeyBlue = 0x0000FF & RGBValue; - LTDC_colorkeying_InitStruct.LTDC_ColorKeyGreen = (0x00FF00 & RGBValue) >> 8; - LTDC_colorkeying_InitStruct.LTDC_ColorKeyRed = (0xFF0000 & RGBValue) >> 16; - - if (CurrentLayer == LCD_BACKGROUND_LAYER) - { - /* Enable the color Keying for Layer1 */ - LTDC_ColorKeyingConfig(LTDC_Layer1, <DC_colorkeying_InitStruct, ENABLE); - LTDC_ReloadConfig(LTDC_IMReload); - } - else - { - /* Enable the color Keying for Layer2 */ - LTDC_ColorKeyingConfig(LTDC_Layer2, <DC_colorkeying_InitStruct, ENABLE); - LTDC_ReloadConfig(LTDC_IMReload); - } -} - -/** - * @brief Disable the color Keying. - * @param RGBValue: Specifies the Color reference. - * @retval None - */ -void LCD_ReSetColorKeying(void) -{ - LTDC_ColorKeying_InitTypeDef LTDC_colorkeying_InitStruct; - - if (CurrentLayer == LCD_BACKGROUND_LAYER) - { - /* Disable the color Keying for Layer1 */ - LTDC_ColorKeyingConfig(LTDC_Layer1, <DC_colorkeying_InitStruct, DISABLE); - LTDC_ReloadConfig(LTDC_IMReload); - } - else - { - /* Disable the color Keying for Layer2 */ - LTDC_ColorKeyingConfig(LTDC_Layer2, <DC_colorkeying_InitStruct, DISABLE); - LTDC_ReloadConfig(LTDC_IMReload); - } -} - -/** - * @brief Draws a character on LCD. - * @param Xpos: the Line where to display the character shape. - * @param Ypos: start column address. - * @param c: pointer to the character data. - * @retval None - */ -void LCD_DrawChar(uint16_t Xpos, uint16_t Ypos, const uint16_t *c) -{ - uint32_t index = 0, counter = 0, xpos =0; - uint32_t Xaddress = 0; - - xpos = Xpos*LCD_PIXEL_WIDTH*2; - Xaddress += Ypos; - - for(index = 0; index < LCD_Currentfonts->Height; index++) - { - - for(counter = 0; counter < LCD_Currentfonts->Width; counter++) - { - - if((((c[index] & ((0x80 << ((LCD_Currentfonts->Width / 12 ) * 8 ) ) >> counter)) == 0x00) &&(LCD_Currentfonts->Width <= 12))|| - (((c[index] & (0x1 << counter)) == 0x00)&&(LCD_Currentfonts->Width > 12 ))) - { - /* Write data value to all SDRAM memory */ - *(__IO uint16_t*) (CurrentFrameBuffer + (2*Xaddress) + xpos) = CurrentBackColor; - } - else - { - /* Write data value to all SDRAM memory */ - *(__IO uint16_t*) (CurrentFrameBuffer + (2*Xaddress) + xpos) = CurrentTextColor; - } - Xaddress++; - } - Xaddress += (LCD_PIXEL_WIDTH - LCD_Currentfonts->Width); - } -} - -/** - * @brief Displays one character (16dots width, 24dots height). - * @param Line: the Line where to display the character shape . - * This parameter can be one of the following values: - * @arg Linex: where x can be 0..29 - * @param Column: start column address. - * @param Ascii: character ascii code, must be between 0x20 and 0x7E. - * @retval None - */ -void LCD_DisplayChar(uint16_t Line, uint16_t Column, uint8_t Ascii) -{ - Ascii -= 32; - - LCD_DrawChar(Line, Column, &LCD_Currentfonts->table[Ascii * LCD_Currentfonts->Height]); -} - -/** - * @brief Displays a maximum of 20 char on the LCD. - * @param Line: the Line where to display the character shape . - * This parameter can be one of the following values: - * @arg Linex: where x can be 0..9 - * @param *ptr: pointer to string to display on LCD. - * @retval None - */ -void LCD_DisplayStringLine(uint16_t Line, uint8_t *ptr) -{ - uint16_t refcolumn = 0; - /* Send the string character by character on lCD */ - while ((refcolumn < LCD_PIXEL_WIDTH) && ((*ptr != 0) & (((refcolumn + LCD_Currentfonts->Width) & 0xFFFF) >= LCD_Currentfonts->Width))) - { - /* Display one character on LCD */ - LCD_DisplayChar(Line, refcolumn, *ptr); - /* Decrement the column position by width */ - refcolumn += LCD_Currentfonts->Width; - /* Point on the next character */ - ptr++; - } -} - -/** - * @brief Sets a display window - * @param Xpos: specifies the X bottom left position from 0 to 240. - * @param Ypos: specifies the Y bottom left position from 0 to 320. - * @param Height: display window height, can be a value from 0 to 320. - * @param Width: display window width, can be a value from 0 to 240. - * @retval None - */ -void LCD_SetDisplayWindow(uint16_t Xpos, uint16_t Ypos, uint16_t Height, uint16_t Width) -{ - - if (CurrentLayer == LCD_BACKGROUND_LAYER) - { - /* reconfigure the layer1 position */ - LTDC_LayerPosition(LTDC_Layer1, Xpos, Ypos); - LTDC_ReloadConfig(LTDC_IMReload); - - /* reconfigure the layer1 size */ - LTDC_LayerSize(LTDC_Layer1, Width, Height); - LTDC_ReloadConfig(LTDC_IMReload); - } - else - { - /* reconfigure the layer2 position */ - LTDC_LayerPosition(LTDC_Layer2, Xpos, Ypos); - LTDC_ReloadConfig(LTDC_IMReload); - - /* reconfigure the layer2 size */ - LTDC_LayerSize(LTDC_Layer2, Width, Height); - LTDC_ReloadConfig(LTDC_IMReload); - } -} - -/** - * @brief Disables LCD Window mode. - * @param None - * @retval None - */ -void LCD_WindowModeDisable(void) -{ - LCD_SetDisplayWindow(0, 0, LCD_PIXEL_HEIGHT, LCD_PIXEL_WIDTH); -} - -/** - * @brief Displays a line. - * @param Xpos: specifies the X position, can be a value from 0 to 240. - * @param Ypos: specifies the Y position, can be a value from 0 to 320. - * @param Length: line length. - * @param Direction: line direction. - * This parameter can be one of the following values: LCD_DIR_HORIZONTAL or LCD_DIR_VERTICAL. - * @retval None - */ -void LCD_DrawLine(uint16_t Xpos, uint16_t Ypos, uint16_t Length, uint8_t Direction) -{ - DMA2D_InitTypeDef DMA2D_InitStruct; - - uint32_t Xaddress = 0; - uint16_t Red_Value = 0, Green_Value = 0, Blue_Value = 0; - - Xaddress = CurrentFrameBuffer + 2*(LCD_PIXEL_WIDTH*Ypos + Xpos); - - Red_Value = (0xF800 & CurrentTextColor) >> 11; - Blue_Value = 0x001F & CurrentTextColor; - Green_Value = (0x07E0 & CurrentTextColor) >> 5; - - /* Configure DMA2D */ - DMA2D_DeInit(); - DMA2D_InitStruct.DMA2D_Mode = DMA2D_R2M; - DMA2D_InitStruct.DMA2D_CMode = DMA2D_RGB565; - DMA2D_InitStruct.DMA2D_OutputGreen = Green_Value; - DMA2D_InitStruct.DMA2D_OutputBlue = Blue_Value; - DMA2D_InitStruct.DMA2D_OutputRed = Red_Value; - DMA2D_InitStruct.DMA2D_OutputAlpha = 0x0F; - DMA2D_InitStruct.DMA2D_OutputMemoryAdd = Xaddress; - - 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; - } - - DMA2D_Init(&DMA2D_InitStruct); - /* Start Transfer */ - DMA2D_StartTransfer(); - /* Wait for CTC Flag activation */ - while(DMA2D_GetFlagStatus(DMA2D_FLAG_TC) == RESET) - { - } - -} - -/** - * @brief Displays a rectangle. - * @param Xpos: specifies the X position, can be a value from 0 to 240. - * @param Ypos: specifies the Y position, can be a value from 0 to 320. - * @param Height: display rectangle height, can be a value from 0 to 320. - * @param Width: display rectangle width, can be a value from 0 to 240. - * @retval None - */ -void LCD_DrawRect(uint16_t Xpos, uint16_t Ypos, uint16_t Height, uint16_t Width) -{ - /* draw horizontal lines */ - LCD_DrawLine(Xpos, Ypos, Width, LCD_DIR_HORIZONTAL); - LCD_DrawLine(Xpos, (Ypos+ Height), Width, LCD_DIR_HORIZONTAL); - - /* draw vertical lines */ - LCD_DrawLine(Xpos, Ypos, Height, LCD_DIR_VERTICAL); - LCD_DrawLine((Xpos + Width), Ypos, Height, LCD_DIR_VERTICAL); -} - -/** - * @brief Draw a circle. - * @param Xpos: specifies the X position, can be a value from 0 to 240. - * @param Ypos: specifies the Y position, can be a value from 0 to 320. - * @param Radius: radius of the circle. - * @retval None - */ -void LCD_DrawCircle(uint16_t Xpos, uint16_t Ypos, uint16_t Radius) -{ - int x = -Radius, y = 0, err = 2-2*Radius, e2; - do { - *(__IO uint16_t*) (CurrentFrameBuffer + (2*((Xpos-x) + LCD_PIXEL_WIDTH*(Ypos+y)))) = CurrentTextColor; - *(__IO uint16_t*) (CurrentFrameBuffer + (2*((Xpos+x) + LCD_PIXEL_WIDTH*(Ypos+y)))) = CurrentTextColor; - *(__IO uint16_t*) (CurrentFrameBuffer + (2*((Xpos+x) + LCD_PIXEL_WIDTH*(Ypos-y)))) = CurrentTextColor; - *(__IO uint16_t*) (CurrentFrameBuffer + (2*((Xpos-x) + LCD_PIXEL_WIDTH*(Ypos-y)))) = CurrentTextColor; - - e2 = err; - if (e2 <= y) { - err += ++y*2+1; - if (-x == y && e2 <= x) e2 = 0; - } - if (e2 > x) err += ++x*2+1; - } - while (x <= 0); -} - -/** - * @brief Draw a full ellipse. - * @param Xpos: specifies the X position, can be a value from 0 to 240. - * @param Ypos: specifies the Y position, can be a value from 0 to 320. - * @param Radius: minor radius of ellipse. - * @param Radius2: major radius of ellipse. - * @retval None - */ -void LCD_DrawFullEllipse(int Xpos, int Ypos, int Radius, int Radius2) -{ - int x = -Radius, y = 0, err = 2-2*Radius, e2; - float K = 0, rad1 = 0, rad2 = 0; - - rad1 = Radius; - rad2 = Radius2; - - if (Radius > Radius2) - { - do - { - K = (float)(rad1/rad2); - LCD_DrawLine((Xpos+x), (Ypos-(uint16_t)(y/K)), (2*(uint16_t)(y/K) + 1), LCD_DIR_VERTICAL); - LCD_DrawLine((Xpos-x), (Ypos-(uint16_t)(y/K)), (2*(uint16_t)(y/K) + 1), LCD_DIR_VERTICAL); - - e2 = err; - if (e2 <= y) - { - err += ++y*2+1; - if (-x == y && e2 <= x) e2 = 0; - } - if (e2 > x) err += ++x*2+1; - - } - while (x <= 0); - } - else - { - y = -Radius2; - x = 0; - do - { - K = (float)(rad2/rad1); - LCD_DrawLine((Xpos-(uint16_t)(x/K)), (Ypos+y), (2*(uint16_t)(x/K) + 1), LCD_DIR_HORIZONTAL); - LCD_DrawLine((Xpos-(uint16_t)(x/K)), (Ypos-y), (2*(uint16_t)(x/K) + 1), LCD_DIR_HORIZONTAL); - - e2 = err; - if (e2 <= x) - { - err += ++x*2+1; - if (-y == x && e2 <= y) e2 = 0; - } - if (e2 > y) err += ++y*2+1; - } - while (y <= 0); - } -} - -/** - * @brief Displays an Ellipse. - * @param Xpos: specifies the X position, can be a value from 0 to 240. - * @param Ypos: specifies the Y position, can be a value from 0 to 320. - * @param Radius: specifies Radius. - * @param Radius2: specifies Radius2. - * @retval None - */ -void LCD_DrawEllipse(int Xpos, int Ypos, int Radius, int Radius2) -{ - int x = -Radius, y = 0, err = 2-2*Radius, e2; - float K = 0, rad1 = 0, rad2 = 0; - - rad1 = Radius; - rad2 = Radius2; - - if (Radius > Radius2) - { - do { - K = (float)(rad1/rad2); - *(__IO uint16_t*) (CurrentFrameBuffer + (2*((Xpos-x) + LCD_PIXEL_WIDTH*(Ypos+(uint16_t)(y/K))))) = CurrentTextColor; - *(__IO uint16_t*) (CurrentFrameBuffer + (2*((Xpos+x) + LCD_PIXEL_WIDTH*(Ypos+(uint16_t)(y/K))))) = CurrentTextColor; - *(__IO uint16_t*) (CurrentFrameBuffer + (2*((Xpos+x) + LCD_PIXEL_WIDTH*(Ypos-(uint16_t)(y/K))))) = CurrentTextColor; - *(__IO uint16_t*) (CurrentFrameBuffer + (2*((Xpos-x) + LCD_PIXEL_WIDTH*(Ypos-(uint16_t)(y/K))))) = CurrentTextColor; - - e2 = err; - if (e2 <= y) { - err += ++y*2+1; - if (-x == y && e2 <= x) e2 = 0; - } - if (e2 > x) err += ++x*2+1; - } - while (x <= 0); - } - else - { - y = -Radius2; - x = 0; - do { - K = (float)(rad2/rad1); - *(__IO uint16_t*) (CurrentFrameBuffer + (2*((Xpos-(uint16_t)(x/K)) + LCD_PIXEL_WIDTH*(Ypos+y)))) = CurrentTextColor; - *(__IO uint16_t*) (CurrentFrameBuffer + (2*((Xpos+(uint16_t)(x/K)) + LCD_PIXEL_WIDTH*(Ypos+y)))) = CurrentTextColor; - *(__IO uint16_t*) (CurrentFrameBuffer + (2*((Xpos+(uint16_t)(x/K)) + LCD_PIXEL_WIDTH*(Ypos-y)))) = CurrentTextColor; - *(__IO uint16_t*) (CurrentFrameBuffer + (2*((Xpos-(uint16_t)(x/K)) + LCD_PIXEL_WIDTH*(Ypos-y)))) = CurrentTextColor; - - e2 = err; - if (e2 <= x) { - err += ++x*2+1; - if (-y == x && e2 <= y) e2 = 0; - } - if (e2 > y) err += ++y*2+1; - } - while (y <= 0); - } -} - -/** - * @brief Displays a mono-color picture. - * @param Pict: pointer to the picture array. - * @retval None - */ -void LCD_DrawMonoPict(const uint32_t *Pict) -{ - uint32_t index = 0, counter = 0; - - - for(index = 0; index < 2400; index++) - { - for(counter = 0; counter < 32; counter++) - { - if((Pict[index] & (1 << counter)) == 0x00) - { - *(__IO uint16_t*)(CurrentFrameBuffer) = CurrentBackColor; - } - else - { - *(__IO uint16_t*)(CurrentFrameBuffer) = CurrentTextColor; - } - } - } -} - -/** - * @brief Displays a bitmap picture loaded in the internal Flash. - * @param BmpAddress: Bmp picture address in the internal Flash. - * @retval None - */ -void LCD_WriteBMP(uint32_t BmpAddress) -{ - uint32_t index = 0, size = 0, width = 0, height = 0, bit_pixel = 0; - uint32_t Address; - uint32_t currentline = 0, linenumber = 0; - - Address = CurrentFrameBuffer; - - /* Read bitmap size */ - size = *(__IO uint16_t *) (BmpAddress + 2); - size |= (*(__IO uint16_t *) (BmpAddress + 4)) << 16; - - /* Get bitmap data address offset */ - index = *(__IO uint16_t *) (BmpAddress + 10); - index |= (*(__IO uint16_t *) (BmpAddress + 12)) << 16; - - /* Read bitmap width */ - width = *(uint16_t *) (BmpAddress + 18); - width |= (*(uint16_t *) (BmpAddress + 20)) << 16; - - /* Read bitmap height */ - height = *(uint16_t *) (BmpAddress + 22); - height |= (*(uint16_t *) (BmpAddress + 24)) << 16; - - /* Read bit/pixel */ - bit_pixel = *(uint16_t *) (BmpAddress + 28); - - if (CurrentLayer == LCD_BACKGROUND_LAYER) - { - /* reconfigure layer size in accordance with the picture */ - LTDC_LayerSize(LTDC_Layer1, width, height); - LTDC_ReloadConfig(LTDC_VBReload); - - /* Reconfigure the Layer pixel format in accordance with the picture */ - if ((bit_pixel/8) == 4) - { - LTDC_LayerPixelFormat(LTDC_Layer1, LTDC_Pixelformat_ARGB8888); - LTDC_ReloadConfig(LTDC_VBReload); - } - else if ((bit_pixel/8) == 2) - { - LTDC_LayerPixelFormat(LTDC_Layer1, LTDC_Pixelformat_RGB565); - LTDC_ReloadConfig(LTDC_VBReload); - } - else - { - LTDC_LayerPixelFormat(LTDC_Layer1, LTDC_Pixelformat_RGB888); - LTDC_ReloadConfig(LTDC_VBReload); - } - } - else - { - /* reconfigure layer size in accordance with the picture */ - LTDC_LayerSize(LTDC_Layer2, width, height); - LTDC_ReloadConfig(LTDC_VBReload); - - /* Reconfigure the Layer pixel format in accordance with the picture */ - if ((bit_pixel/8) == 4) - { - LTDC_LayerPixelFormat(LTDC_Layer2, LTDC_Pixelformat_ARGB8888); - LTDC_ReloadConfig(LTDC_VBReload); - } - else if ((bit_pixel/8) == 2) - { - LTDC_LayerPixelFormat(LTDC_Layer2, LTDC_Pixelformat_RGB565); - LTDC_ReloadConfig(LTDC_VBReload); - } - else - { - LTDC_LayerPixelFormat(LTDC_Layer2, LTDC_Pixelformat_RGB888); - LTDC_ReloadConfig(LTDC_VBReload); - } - } - - /* compute the real size of the picture (without the header)) */ - size = (size - index); - - /* bypass the bitmap header */ - BmpAddress += index; - - /* start copie image from the bottom */ - Address += width*(height-1)*(bit_pixel/8); - - for(index = 0; index < size; index++) - { - *(__IO uint8_t*) (Address) = *(__IO uint8_t *)BmpAddress; - - /*jump on next byte */ - BmpAddress++; - Address++; - currentline++; - - if((currentline/(bit_pixel/8)) == width) - { - if(linenumber < height) - { - linenumber++; - Address -=(2*width*(bit_pixel/8)); - currentline = 0; - } - } - } -} - -/** - * @brief Displays a full rectangle. - * @param Xpos: specifies the X position, can be a value from 0 to 240. - * @param Ypos: specifies the Y position, can be a value from 0 to 320. - * @param Height: rectangle height. - * @param Width: rectangle width. - * @retval None - */ -void LCD_DrawFullRect(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height) -{ - DMA2D_InitTypeDef DMA2D_InitStruct; - - uint32_t Xaddress = 0; - uint16_t Red_Value = 0, Green_Value = 0, Blue_Value = 0; - - Red_Value = (0xF800 & CurrentTextColor) >> 11; - Blue_Value = 0x001F & CurrentTextColor; - Green_Value = (0x07E0 & CurrentTextColor) >> 5; - - Xaddress = CurrentFrameBuffer + 2*(LCD_PIXEL_WIDTH*Ypos + Xpos); - - /* configure DMA2D */ - DMA2D_DeInit(); - DMA2D_InitStruct.DMA2D_Mode = DMA2D_R2M; - DMA2D_InitStruct.DMA2D_CMode = DMA2D_RGB565; - DMA2D_InitStruct.DMA2D_OutputGreen = Green_Value; - DMA2D_InitStruct.DMA2D_OutputBlue = Blue_Value; - DMA2D_InitStruct.DMA2D_OutputRed = Red_Value; - DMA2D_InitStruct.DMA2D_OutputAlpha = 0x0F; - DMA2D_InitStruct.DMA2D_OutputMemoryAdd = Xaddress; - DMA2D_InitStruct.DMA2D_OutputOffset = (LCD_PIXEL_WIDTH - Width); - DMA2D_InitStruct.DMA2D_NumberOfLine = Height; - DMA2D_InitStruct.DMA2D_PixelPerLine = Width; - DMA2D_Init(&DMA2D_InitStruct); - - /* Start Transfer */ - DMA2D_StartTransfer(); - - /* Wait for CTC Flag activation */ - while(DMA2D_GetFlagStatus(DMA2D_FLAG_TC) == RESET) - { - } - - LCD_SetTextColor(CurrentTextColor); -} - -/** - * @brief Displays a full circle. - * @param Xpos: specifies the X position, can be a value from 0 to 240. - * @param Ypos: specifies the Y position, can be a value from 0 to 320. - * @param Radius - * @retval None - */ -void LCD_DrawFullCircle(uint16_t Xpos, uint16_t Ypos, uint16_t Radius) -{ - int32_t D; /* Decision Variable */ - uint32_t CurX;/* Current X Value */ - uint32_t CurY;/* Current Y Value */ - - D = 3 - (Radius << 1); - - CurX = 0; - CurY = Radius; - - while (CurX <= CurY) - { - if(CurY > 0) - { - LCD_DrawLine(Xpos - CurX, Ypos - CurY, 2*CurY, LCD_DIR_VERTICAL); - LCD_DrawLine(Xpos + CurX, Ypos - CurY, 2*CurY, LCD_DIR_VERTICAL); - } - - if(CurX > 0) - { - LCD_DrawLine(Xpos - CurY, Ypos - CurX, 2*CurX, LCD_DIR_VERTICAL); - LCD_DrawLine(Xpos + CurY, Ypos - CurX, 2*CurX, LCD_DIR_VERTICAL); - } - if (D < 0) - { - D += (CurX << 2) + 6; - } - else - { - D += ((CurX - CurY) << 2) + 10; - CurY--; - } - CurX++; - } - - LCD_DrawCircle(Xpos, Ypos, Radius); -} - -/** - * @brief Displays an uni-line (between two points). - * @param x1: specifies the point 1 x position. - * @param y1: specifies the point 1 y position. - * @param x2: specifies the point 2 x position. - * @param y2: specifies the point 2 y position. - * @retval None - */ -void LCD_DrawUniLine(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2) -{ - int16_t deltax = 0, deltay = 0, x = 0, y = 0, xinc1 = 0, xinc2 = 0, - yinc1 = 0, yinc2 = 0, den = 0, num = 0, numadd = 0, numpixels = 0, - curpixel = 0; - - deltax = ABS(x2 - x1); /* The difference between the x's */ - deltay = ABS(y2 - y1); /* The difference between the y's */ - x = x1; /* Start x off at the first pixel */ - y = y1; /* Start y off at the first pixel */ - - if (x2 >= x1) /* The x-values are increasing */ - { - xinc1 = 1; - xinc2 = 1; - } - else /* The x-values are decreasing */ - { - xinc1 = -1; - xinc2 = -1; - } - - if (y2 >= y1) /* The y-values are increasing */ - { - yinc1 = 1; - yinc2 = 1; - } - else /* The y-values are decreasing */ - { - yinc1 = -1; - yinc2 = -1; - } - - if (deltax >= deltay) /* There is at least one x-value for every y-value */ - { - xinc1 = 0; /* Don't change the x when numerator >= denominator */ - yinc2 = 0; /* Don't change the y for every iteration */ - den = deltax; - num = deltax / 2; - numadd = deltay; - numpixels = deltax; /* There are more x-values than y-values */ - } - else /* There is at least one y-value for every x-value */ - { - xinc2 = 0; /* Don't change the x for every iteration */ - yinc1 = 0; /* Don't change the y when numerator >= denominator */ - den = deltay; - num = deltay / 2; - numadd = deltax; - numpixels = deltay; /* There are more y-values than x-values */ - } - - for (curpixel = 0; curpixel <= numpixels; curpixel++) - { - PutPixel(x, y); /* Draw the current pixel */ - num += numadd; /* Increase the numerator by the top of the fraction */ - if (num >= den) /* Check if numerator >= denominator */ - { - num -= den; /* Calculate the new numerator value */ - x += xinc1; /* Change the x as appropriate */ - y += yinc1; /* Change the y as appropriate */ - } - x += xinc2; /* Change the x as appropriate */ - y += yinc2; /* Change the y as appropriate */ - } -} - -/** - * @brief Displays an triangle. - * @param Points: pointer to the points array. - * @retval None - */ -void LCD_Triangle(pPoint Points, uint16_t PointCount) -{ - int16_t X = 0, Y = 0; - pPoint First = Points; - - if(PointCount != 3) - { - return; - } - - while(--PointCount) - { - X = Points->X; - Y = Points->Y; - Points++; - LCD_DrawUniLine(X, Y, Points->X, Points->Y); - } - LCD_DrawUniLine(First->X, First->Y, Points->X, Points->Y); -} - -/** - * @brief Fill an triangle (between 3 points). - * @param x1..3: x position of triangle point 1..3. - * @param y1..3: y position of triangle point 1..3. - * @retval None - */ -void LCD_FillTriangle(uint16_t x1, uint16_t x2, uint16_t x3, uint16_t y1, uint16_t y2, uint16_t y3) -{ - - int16_t deltax = 0, deltay = 0, x = 0, y = 0, xinc1 = 0, xinc2 = 0, - yinc1 = 0, yinc2 = 0, den = 0, num = 0, numadd = 0, numpixels = 0, - curpixel = 0; - - deltax = ABS(x2 - x1); /* The difference between the x's */ - deltay = ABS(y2 - y1); /* The difference between the y's */ - x = x1; /* Start x off at the first pixel */ - y = y1; /* Start y off at the first pixel */ - - if (x2 >= x1) /* The x-values are increasing */ - { - xinc1 = 1; - xinc2 = 1; - } - else /* The x-values are decreasing */ - { - xinc1 = -1; - xinc2 = -1; - } - - if (y2 >= y1) /* The y-values are increasing */ - { - yinc1 = 1; - yinc2 = 1; - } - else /* The y-values are decreasing */ - { - yinc1 = -1; - yinc2 = -1; - } - - if (deltax >= deltay) /* There is at least one x-value for every y-value */ - { - xinc1 = 0; /* Don't change the x when numerator >= denominator */ - yinc2 = 0; /* Don't change the y for every iteration */ - den = deltax; - num = deltax / 2; - numadd = deltay; - numpixels = deltax; /* There are more x-values than y-values */ - } - else /* There is at least one y-value for every x-value */ - { - xinc2 = 0; /* Don't change the x for every iteration */ - yinc1 = 0; /* Don't change the y when numerator >= denominator */ - den = deltay; - num = deltay / 2; - numadd = deltax; - numpixels = deltay; /* There are more y-values than x-values */ - } - - for (curpixel = 0; curpixel <= numpixels; curpixel++) - { - LCD_DrawUniLine(x, y, x3, y3); - - num += numadd; /* Increase the numerator by the top of the fraction */ - if (num >= den) /* Check if numerator >= denominator */ - { - num -= den; /* Calculate the new numerator value */ - x += xinc1; /* Change the x as appropriate */ - y += yinc1; /* Change the y as appropriate */ - } - x += xinc2; /* Change the x as appropriate */ - y += yinc2; /* Change the y as appropriate */ - } - - -} -/** - * @brief Displays an poly-line (between many points). - * @param Points: pointer to the points array. - * @param PointCount: Number of points. - * @retval None - */ -void LCD_PolyLine(pPoint Points, uint16_t PointCount) -{ - int16_t X = 0, Y = 0; - - if(PointCount < 2) - { - return; - } - - while(--PointCount) - { - X = Points->X; - Y = Points->Y; - Points++; - LCD_DrawUniLine(X, Y, Points->X, Points->Y); - } -} - -/** - * @brief Displays an relative poly-line (between many points). - * @param Points: pointer to the points array. - * @param PointCount: Number of points. - * @param Closed: specifies if the draw is closed or not. - * 1: closed, 0 : not closed. - * @retval None - */ -static void LCD_PolyLineRelativeClosed(pPoint Points, uint16_t PointCount, uint16_t Closed) -{ - int16_t X = 0, Y = 0; - pPoint First = Points; - - if(PointCount < 2) - { - return; - } - X = Points->X; - Y = Points->Y; - while(--PointCount) - { - Points++; - LCD_DrawUniLine(X, Y, X + Points->X, Y + Points->Y); - X = X + Points->X; - Y = Y + Points->Y; - } - if(Closed) - { - LCD_DrawUniLine(First->X, First->Y, X, Y); - } -} - -/** - * @brief Displays a closed poly-line (between many points). - * @param Points: pointer to the points array. - * @param PointCount: Number of points. - * @retval None - */ -void LCD_ClosedPolyLine(pPoint Points, uint16_t PointCount) -{ - LCD_PolyLine(Points, PointCount); - LCD_DrawUniLine(Points->X, Points->Y, (Points+PointCount-1)->X, (Points+PointCount-1)->Y); -} - -/** - * @brief Displays a relative poly-line (between many points). - * @param Points: pointer to the points array. - * @param PointCount: Number of points. - * @retval None - */ -void LCD_PolyLineRelative(pPoint Points, uint16_t PointCount) -{ - LCD_PolyLineRelativeClosed(Points, PointCount, 0); -} - -/** - * @brief Displays a closed relative poly-line (between many points). - * @param Points: pointer to the points array. - * @param PointCount: Number of points. - * @retval None - */ -void LCD_ClosedPolyLineRelative(pPoint Points, uint16_t PointCount) -{ - LCD_PolyLineRelativeClosed(Points, PointCount, 1); -} - -/** - * @brief Displays a full poly-line (between many points). - * @param Points: pointer to the points array. - * @param PointCount: Number of points. - * @retval None - */ -void LCD_FillPolyLine(pPoint Points, uint16_t PointCount) -{ - - int16_t X = 0, Y = 0, X2 = 0, Y2 = 0, X_center = 0, Y_center = 0, X_first = 0, Y_first = 0, pixelX = 0, pixelY = 0, counter = 0; - uint16_t IMAGE_LEFT = 0, IMAGE_RIGHT = 0, IMAGE_TOP = 0, IMAGE_BOTTOM = 0; - - IMAGE_LEFT = IMAGE_RIGHT = Points->X; - IMAGE_TOP= IMAGE_BOTTOM = Points->Y; - - for(counter = 1; counter < PointCount; counter++) - { - pixelX = POLY_X(counter); - if(pixelX < IMAGE_LEFT) - { - IMAGE_LEFT = pixelX; - } - if(pixelX > IMAGE_RIGHT) - { - IMAGE_RIGHT = pixelX; - } - - pixelY = POLY_Y(counter); - if(pixelY < IMAGE_TOP) - { - IMAGE_TOP = pixelY; - } - if(pixelY > IMAGE_BOTTOM) - { - IMAGE_BOTTOM = pixelY; - } - } - - if(PointCount < 2) - { - return; - } - - X_center = (IMAGE_LEFT + IMAGE_RIGHT)/2; - Y_center = (IMAGE_BOTTOM + IMAGE_TOP)/2; - - X_first = Points->X; - Y_first = Points->Y; - - while(--PointCount) - { - X = Points->X; - Y = Points->Y; - Points++; - X2 = Points->X; - Y2 = Points->Y; - - LCD_FillTriangle(X, X2, X_center, Y, Y2, Y_center); - LCD_FillTriangle(X, X_center, X2, Y, Y_center, Y2); - LCD_FillTriangle(X_center, X2, X, Y_center, Y2, Y); - } - - LCD_FillTriangle(X_first, X2, X_center, Y_first, Y2, Y_center); - LCD_FillTriangle(X_first, X_center, X2, Y_first, Y_center, Y2); - LCD_FillTriangle(X_center, X2, X_first, Y_center, Y2, Y_first); -} - - -/** - * @brief Displays a pixel. - * @param x: pixel x. - * @param y: pixel y. - * @retval None - */ -static void PutPixel(int16_t x, int16_t y) -{ - if(x < 0 || x > 239 || y < 0 || y > 319) - { - return; - } - LCD_DrawLine(x, y, 1, LCD_DIR_HORIZONTAL); -} - -#ifndef USE_Delay -/** - * @brief Inserts a delay time. - * @param nCount: specifies the delay time length. - * @retval None - */ -static void delay(__IO uint32_t nCount) -{ - __IO uint32_t index = 0; - for(index = nCount; index != 0; index--) - { - } -} -#endif - - - - - - - -/** - * @} - */ - -/** @defgroup STM32F429I_DISCOVERY_LCD_Private_Functions - * @{ - */ -#if 0 -/** - * @brief DeInitializes the LCD. - * @param None - * @retval None - */ -void LCD_DeInit(void) -{ - GPIO_InitTypeDef GPIO_InitStructure; - - /* LCD Display Off */ - LCD_DisplayOff(); - - /* LCD_SPI disable */ - SPI_Cmd(SPI_5, DISABLE); - - /* LCD_SPI DeInit */ - SPI_I2S_DeInit(SPI_5); - - /* Disable SPI clock */ - RCC_APB2PeriphClockCmd(LCD_SPI_CLK, DISABLE); - - /* Configure NCS in Output Push-Pull mode */ - GPIO_InitStructure.GPIO_Pin = LCD_NCS_PIN; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN; - GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; - GPIO_Init(LCD_NCS_GPIO_PORT, &GPIO_InitStructure); - - /* Configure SPI pins: SCK, MISO and MOSI */ - GPIO_InitStructure.GPIO_Pin = LCD_SPI_SCK_PIN; - GPIO_Init(LCD_SPI_SCK_GPIO_PORT, &GPIO_InitStructure); - - GPIO_InitStructure.GPIO_Pin = LCD_SPI_MISO_PIN; - GPIO_Init(LCD_SPI_MISO_GPIO_PORT, &GPIO_InitStructure); - - GPIO_InitStructure.GPIO_Pin = LCD_SPI_MOSI_PIN; - GPIO_Init(LCD_SPI_MOSI_GPIO_PORT, &GPIO_InitStructure); - - /* GPIOA configuration */ - GPIO_PinAFConfig(GPIOA, GPIO_PinSource3, GPIO_AF_MCO); - GPIO_PinAFConfig(GPIOA, GPIO_PinSource4, GPIO_AF_MCO); - GPIO_PinAFConfig(GPIOA, GPIO_PinSource6, GPIO_AF_MCO); - GPIO_PinAFConfig(GPIOA, GPIO_PinSource11, GPIO_AF_MCO); - GPIO_PinAFConfig(GPIOA, GPIO_PinSource12, GPIO_AF_MCO); - - GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_6 | - GPIO_Pin_11 | GPIO_Pin_12; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; - GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; - GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; - GPIO_Init(GPIOA, &GPIO_InitStructure); - - /* GPIOB configuration */ - GPIO_PinAFConfig(GPIOB, GPIO_PinSource0, GPIO_AF_MCO); - GPIO_PinAFConfig(GPIOB, GPIO_PinSource1, GPIO_AF_MCO); - GPIO_PinAFConfig(GPIOB, GPIO_PinSource8, GPIO_AF_MCO); - GPIO_PinAFConfig(GPIOB, GPIO_PinSource9, GPIO_AF_MCO); - GPIO_PinAFConfig(GPIOB, GPIO_PinSource10, GPIO_AF_MCO); - GPIO_PinAFConfig(GPIOB, GPIO_PinSource11, GPIO_AF_MCO); - - GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_8 | - GPIO_Pin_9 | GPIO_Pin_10 | GPIO_Pin_11; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; - GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; - GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; - GPIO_Init(GPIOB, &GPIO_InitStructure); - - /* GPIOC configuration */ - GPIO_PinAFConfig(GPIOC, GPIO_PinSource6, GPIO_AF_MCO); - GPIO_PinAFConfig(GPIOC, GPIO_PinSource7, GPIO_AF_MCO); - GPIO_PinAFConfig(GPIOC, GPIO_PinSource10, GPIO_AF_MCO); - - GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7 | GPIO_Pin_10; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; - GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; - GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; - GPIO_Init(GPIOC, &GPIO_InitStructure); - - /* GPIOD configuration */ - GPIO_PinAFConfig(GPIOD, GPIO_PinSource3, GPIO_AF_MCO); - GPIO_PinAFConfig(GPIOD, GPIO_PinSource6, GPIO_AF_MCO); - - GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3 | GPIO_Pin_6; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; - GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; - GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; - GPIO_Init(GPIOD, &GPIO_InitStructure); - - /* GPIOF configuration */ - GPIO_PinAFConfig(GPIOF, GPIO_PinSource10, GPIO_AF_MCO); - - GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; - GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; - GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; - GPIO_Init(GPIOF, &GPIO_InitStructure); - - /* GPIOG configuration */ - GPIO_PinAFConfig(GPIOG, GPIO_PinSource6, GPIO_AF_MCO); - GPIO_PinAFConfig(GPIOG, GPIO_PinSource7, GPIO_AF_MCO); - GPIO_PinAFConfig(GPIOG, GPIO_PinSource10, GPIO_AF_MCO); - GPIO_PinAFConfig(GPIOG, GPIO_PinSource11, GPIO_AF_MCO); - GPIO_PinAFConfig(GPIOG, GPIO_PinSource12, GPIO_AF_MCO); - - GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7 | GPIO_Pin_10 | - GPIO_Pin_11 | GPIO_Pin_12; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; - GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; - GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; - GPIO_Init(GPIOG, &GPIO_InitStructure); -} -#endif diff --git a/uGL/stm32f429i_discovery_lcd.dep b/uGL/stm32f429i_discovery_lcd.dep deleted file mode 100644 index 5accf3e..0000000 --- a/uGL/stm32f429i_discovery_lcd.dep +++ /dev/null @@ -1,57 +0,0 @@ -uGL/stm32f429i_discovery_lcd.o: uGL/stm32f429i_discovery_lcd.c \ - uGL/stm32f429i_discovery_lcd.h \ - /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/Core/CM4F/DeviceSupport/ST/stm32f4xx/stm32f4xx.h \ - /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/Core/CM4F/CoreSupport/core_cm4.h \ - /usr/local/Caskroom/gcc-arm-embedded/7-2017-q4-major/gcc-arm-none-eabi-7-2017-q4-major/lib/gcc/arm-none-eabi/7.2.1/include/stdint.h \ - /usr/local/Caskroom/gcc-arm-embedded/7-2017-q4-major/gcc-arm-none-eabi-7-2017-q4-major/arm-none-eabi/include/stdint.h \ - /usr/local/Caskroom/gcc-arm-embedded/7-2017-q4-major/gcc-arm-none-eabi-7-2017-q4-major/arm-none-eabi/include/machine/_default_types.h \ - /usr/local/Caskroom/gcc-arm-embedded/7-2017-q4-major/gcc-arm-none-eabi-7-2017-q4-major/arm-none-eabi/include/sys/features.h \ - /usr/local/Caskroom/gcc-arm-embedded/7-2017-q4-major/gcc-arm-none-eabi-7-2017-q4-major/arm-none-eabi/include/_newlib_version.h \ - /usr/local/Caskroom/gcc-arm-embedded/7-2017-q4-major/gcc-arm-none-eabi-7-2017-q4-major/arm-none-eabi/include/sys/_intsup.h \ - /usr/local/Caskroom/gcc-arm-embedded/7-2017-q4-major/gcc-arm-none-eabi-7-2017-q4-major/arm-none-eabi/include/sys/_stdint.h \ - /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/Core/CM4F/CoreSupport/core_cmInstr.h \ - /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/Core/CM4F/CoreSupport/core_cmFunc.h \ - /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/Core/CM4F/CoreSupport/core_cmSimd.h \ - /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/Core/CM4F/DeviceSupport/ST/stm32f4xx/system_stm32f4xx.h \ - /Users/tom/Documents/src/uGames/uC-sdk/config/arm/stm32f4xx/stm32f4xx_conf.h \ - /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_adc.h \ - /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_can.h \ - /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_crc.h \ - /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_cryp.h \ - /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_dac.h \ - /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_dbgmcu.h \ - /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_dcmi.h \ - /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_dma.h \ - /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_exti.h \ - /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_flash.h \ - /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_fsmc.h \ - /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_hash.h \ - /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_gpio.h \ - /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_i2c.h \ - /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_iwdg.h \ - /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_pwr.h \ - /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_rcc.h \ - /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_rng.h \ - /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_rtc.h \ - /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_sdio.h \ - /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_spi.h \ - /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_syscfg.h \ - /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_tim.h \ - /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_usart.h \ - /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_wwdg.h \ - /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/misc.h \ - uGL/stm32f429i_discovery.h uGL/stm32f429i_discovery_sdram.h uGL/fonts.h \ - /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_ltdc.h \ - /Users/tom/Documents/src/uGames/uC-sdk/arch/arm/stm32f4xx/Drivers/include/stm32f4xx_dma2d.h \ - /Users/tom/Documents/src/uGames/uC-sdk/libc/include/stdlib.h \ - /Users/tom/Documents/src/uGames/uC-sdk/libc/include/decl.h \ - /Users/tom/Documents/src/uGames/uC-sdk/libc/include/reent.h \ - /Users/tom/Documents/src/uGames/uC-sdk/libc/include/errno.h \ - /Users/tom/Documents/src/uGames/uC-sdk/libc/include/malloc.h \ - /usr/local/Caskroom/gcc-arm-embedded/7-2017-q4-major/gcc-arm-none-eabi-7-2017-q4-major/lib/gcc/arm-none-eabi/7.2.1/include/stddef.h \ - /Users/tom/Documents/src/uGames/uC-sdk/libc/include/stdio.h \ - /usr/local/Caskroom/gcc-arm-embedded/7-2017-q4-major/gcc-arm-none-eabi-7-2017-q4-major/lib/gcc/arm-none-eabi/7.2.1/include/stdarg.h \ - /Users/tom/Documents/src/uGames/uC-sdk/libc/include/unistd.h \ - /Users/tom/Documents/src/uGames/uC-sdk/hardware/include/gpio.h \ - /usr/local/Caskroom/gcc-arm-embedded/7-2017-q4-major/gcc-arm-none-eabi-7-2017-q4-major/lib/gcc/arm-none-eabi/7.2.1/include/stdbool.h \ - /Users/tom/Documents/src/uGames/uC-sdk/hardware/include/ssp.h diff --git a/uGL/stm32f429i_discovery_lcd.h b/uGL/stm32f429i_discovery_lcd.h deleted file mode 100755 index 5d50f13..0000000 --- a/uGL/stm32f429i_discovery_lcd.h +++ /dev/null @@ -1,300 +0,0 @@ -/** - ****************************************************************************** - * @file stm32f429i_discovery_lcd.h - * @author MCD Application Team - * @version V1.0.1 - * @date 28-October-2013 - * @brief This file contains all the functions prototypes for the - * stm32f429i_discovery_lcd.c driver. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT 2013 STMicroelectronics

- * - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM32F429I_DISCOVERY_LCD_H -#define __STM32F429I_DISCOVERY_LCD_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "stm32f4xx.h" -#include "stm32f429i_discovery.h" -#include "stm32f429i_discovery_sdram.h" -#include "fonts.h" - -/** @addtogroup Utilities - * @{ - */ - -/** @addtogroup STM32F4_DISCOVERY - * @{ - */ - -/** @addtogroup STM32F429I_DISCOVERY - * @{ - */ - -/** @addtogroup STM32F429I_DISCOVERY_LCD - * @{ - */ - - -/** @defgroup STM32F429I_DISCOVERY_LCD_Exported_Types - * @{ - */ -typedef struct -{ - int16_t X; - int16_t Y; -} Point, * pPoint; -/** - * @} - */ - -/** @defgroup stm32f429i_discovery_LCD_Exported_Constants - * @{ - */ - -/* LCD Size (Width and Height) */ -#define LCD_PIXEL_WIDTH ((uint16_t)240) -#define LCD_PIXEL_HEIGHT ((uint16_t)320) - -#define LCD_FRAME_BUFFER ((uint32_t)0xD0000000) -#define BUFFER_OFFSET ((uint32_t)0x50000) -/** - * @brief Uncomment the line below if you want to use user defined Delay function - * (for precise timing), otherwise default _delay_ function defined within - * this driver is used (less precise timing). - */ -/* #define USE_Delay */ - -#ifdef USE_Delay -#include "main.h" - #define _delay_ Delay /* !< User can provide more timing precise _delay_ function - (with 10ms time base), using SysTick for example */ -#else - #define _delay_ delay /* !< Default _delay_ function with less precise timing */ -#endif - - -/** - * @brief LCD Registers - */ -#define LCD_SLEEP_OUT 0x11 /* Sleep out register */ -#define LCD_GAMMA 0x26 /* Gamma register */ -#define LCD_DISPLAY_OFF 0x28 /* Display off register */ -#define LCD_DISPLAY_ON 0x29 /* Display on register */ -#define LCD_COLUMN_ADDR 0x2A /* Colomn address register */ -#define LCD_PAGE_ADDR 0x2B /* Page address register */ -#define LCD_GRAM 0x2C /* GRAM register */ -#define LCD_MAC 0x36 /* Memory Access Control register*/ -#define LCD_PIXEL_FORMAT 0x3A /* Pixel Format register */ -#define LCD_WDB 0x51 /* Write Brightness Display register */ -#define LCD_WCD 0x53 /* Write Control Display register*/ -#define LCD_RGB_INTERFACE 0xB0 /* RGB Interface Signal Control */ -#define LCD_FRC 0xB1 /* Frame Rate Control register */ -#define LCD_BPC 0xB5 /* Blanking Porch Control register*/ -#define LCD_DFC 0xB6 /* Display Function Control register*/ -#define LCD_POWER1 0xC0 /* Power Control 1 register */ -#define LCD_POWER2 0xC1 /* Power Control 2 register */ -#define LCD_VCOM1 0xC5 /* VCOM Control 1 register */ -#define LCD_VCOM2 0xC7 /* VCOM Control 2 register */ -#define LCD_POWERA 0xCB /* Power control A register */ -#define LCD_POWERB 0xCF /* Power control B register */ -#define LCD_PGAMMA 0xE0 /* Positive Gamma Correction register*/ -#define LCD_NGAMMA 0xE1 /* Negative Gamma Correction register*/ -#define LCD_DTCA 0xE8 /* Driver timing control A */ -#define LCD_DTCB 0xEA /* Driver timing control B */ -#define LCD_POWER_SEQ 0xED /* Power on sequence register */ -#define LCD_3GAMMA_EN 0xF2 /* 3 Gamma enable register */ -#define LCD_INTERFACE 0xF6 /* Interface control register */ -#define LCD_PRC 0xF7 /* Pump ratio control register */ - -/** - * @brief LCD color - */ -#define LCD_COLOR_WHITE 0xFFFF -#define LCD_COLOR_BLACK 0x0000 -#define LCD_COLOR_GREY 0xF7DE -#define LCD_COLOR_BLUE 0x001F -#define LCD_COLOR_BLUE2 0x051F -#define LCD_COLOR_RED 0xF800 -#define LCD_COLOR_MAGENTA 0xF81F -#define LCD_COLOR_GREEN 0x07E0 -#define LCD_COLOR_CYAN 0x7FFF -#define LCD_COLOR_YELLOW 0xFFE0 - -/** - * @brief LCD Lines depending on the chosen fonts. - */ -#define LCD_LINE_0 LINE(0) -#define LCD_LINE_1 LINE(1) -#define LCD_LINE_2 LINE(2) -#define LCD_LINE_3 LINE(3) -#define LCD_LINE_4 LINE(4) -#define LCD_LINE_5 LINE(5) -#define LCD_LINE_6 LINE(6) -#define LCD_LINE_7 LINE(7) -#define LCD_LINE_8 LINE(8) -#define LCD_LINE_9 LINE(9) -#define LCD_LINE_10 LINE(10) -#define LCD_LINE_11 LINE(11) -#define LCD_LINE_12 LINE(12) -#define LCD_LINE_13 LINE(13) -#define LCD_LINE_14 LINE(14) -#define LCD_LINE_15 LINE(15) -#define LCD_LINE_16 LINE(16) -#define LCD_LINE_17 LINE(17) -#define LCD_LINE_18 LINE(18) -#define LCD_LINE_19 LINE(19) -#define LCD_LINE_20 LINE(20) -#define LCD_LINE_21 LINE(21) -#define LCD_LINE_22 LINE(22) -#define LCD_LINE_23 LINE(23) -#define LCD_LINE_24 LINE(24) -#define LCD_LINE_25 LINE(25) -#define LCD_LINE_26 LINE(26) -#define LCD_LINE_27 LINE(27) -#define LCD_LINE_28 LINE(28) -#define LCD_LINE_29 LINE(29) -#define LCD_LINE_30 LINE(30) -#define LCD_LINE_31 LINE(31) -#define LCD_LINE_32 LINE(32) -#define LCD_LINE_33 LINE(33) -#define LCD_LINE_34 LINE(34) -#define LCD_LINE_35 LINE(35) -#define LCD_LINE_36 LINE(36) -#define LCD_LINE_37 LINE(37) -#define LCD_LINE_38 LINE(38) -#define LCD_LINE_39 LINE(39) - -/** - * @brief LCD default font - */ -#define LCD_DEFAULT_FONT Font16x24 - -/** - * @brief LCD Direction - */ -#define LCD_DIR_HORIZONTAL 0x0000 -#define LCD_DIR_VERTICAL 0x0001 - -/** - * @} - */ - -/** - * @brief LCD Layer - */ -#define LCD_BACKGROUND_LAYER 0x0000 -#define LCD_FOREGROUND_LAYER 0x0001 - -/** - * @} - */ - -/** @defgroup STM32F429I_DISCOVERY_LCD_Exported_Macros - * @{ - */ -#define ASSEMBLE_RGB(R, G, B) ((((R)& 0xF8) << 8) | (((G) & 0xFC) << 3) | (((B) & 0xF8) >> 3)) -//#define ASSEMBLE_RGB2(RGB) (((((uint16_t)(RGB.r)) & 0xF8) << 8) | ((((uint16_t)(RGB.g)) & 0xFC) << 3) | ((((uint16_t)(RGB.b)) & 0xF8) >> 3)) - -/** - * @} - */ - -/** @defgroup STM32F429I_DISCOVERY_LCD_Exported_Functions - * @{ - */ -void LCD_DeInit(void); -void LCD_Init(void); -void LCD_LayerInit(void); -void LCD_ChipSelect(FunctionalState NewState); -void LCD_SetLayer(uint32_t Layerx); -void LCD_SetColors(uint16_t _TextColor, uint16_t _BackColor); -void LCD_GetColors(uint16_t *_TextColor, uint16_t *_BackColor); -void LCD_SetTextColor(uint16_t Color); -void LCD_SetBackColor(uint16_t Color); -void LCD_SetTransparency(uint8_t transparency); -void LCD_ClearLine(uint16_t Line); -void LCD_Clear(uint16_t Color); -uint32_t LCD_SetCursor(uint16_t Xpos, uint16_t Ypos); -void LCD_SetColorKeying(uint32_t RGBValue); -void LCD_ReSetColorKeying(void); -void LCD_DrawChar(uint16_t Xpos, uint16_t Ypos, const uint16_t *c); -void LCD_DisplayChar(uint16_t Line, uint16_t Column, uint8_t Ascii); -void LCD_SetFont(sFONT *fonts); -sFONT * LCD_GetFont(void); -void LCD_DisplayStringLine(uint16_t Line, uint8_t *ptr); -void LCD_SetDisplayWindow(uint16_t Xpos, uint16_t Ypos, uint16_t Height, uint16_t Width); -void LCD_WindowModeDisable(void); -void LCD_DrawLine(uint16_t Xpos, uint16_t Ypos, uint16_t Length, uint8_t Direction); -void LCD_DrawRect(uint16_t Xpos, uint16_t Ypos, uint16_t Height, uint16_t Width); -void LCD_DrawCircle(uint16_t Xpos, uint16_t Ypos, uint16_t Radius); -void LCD_DrawEllipse(int Xpos, int Ypos, int Radius, int Radius2); -void LCD_DrawFullEllipse(int Xpos, int Ypos, int Radius, int Radius2); -void LCD_DrawMonoPict(const uint32_t *Pict); -void LCD_WriteBMP(uint32_t BmpAddress); -void LCD_DrawUniLine(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2); -void LCD_DrawFullRect(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height); -void LCD_DrawFullCircle(uint16_t Xpos, uint16_t Ypos, uint16_t Radius); -void LCD_PolyLine(pPoint Points, uint16_t PointCount); -void LCD_PolyLineRelative(pPoint Points, uint16_t PointCount); -void LCD_ClosedPolyLine(pPoint Points, uint16_t PointCount); -void LCD_ClosedPolyLineRelative(pPoint Points, uint16_t PointCount); -void LCD_FillPolyLine(pPoint Points, uint16_t PointCount); -void LCD_Triangle(pPoint Points, uint16_t PointCount); -void LCD_FillTriangle(uint16_t x1, uint16_t x2, uint16_t x3, uint16_t y1, uint16_t y2, uint16_t y3); -void LCD_WriteCommand(uint8_t LCD_Reg); -void LCD_WriteData(uint8_t value); -void LCD_PowerOn(void); -void LCD_DisplayOn(void); -void LCD_DisplayOff(void); -void LCD_CtrlLinesConfig(void); -void LCD_CtrlLinesWrite(GPIO_TypeDef* GPIOx, uint16_t CtrlPins, BitAction BitVal); -void LCD_SPIConfig(void); -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __STM32F429I_DISCOVERY_LCD_H */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/uGL/uGL.c b/uGL/uGL.c index c93d199..354a273 100644 --- a/uGL/uGL.c +++ b/uGL/uGL.c @@ -2,29 +2,251 @@ #include -#include "stm32f429i_discovery_lcd.h" -#include +//#include "stm32f429i_discovery_lcd.h" +#include "stm32f429i_discovery_sdram.h" + +#include +#include + + +/** + * @brief LCD Registers + */ +#define LCD_SLEEP_OUT 0x11 /* Sleep out register */ +#define LCD_GAMMA 0x26 /* Gamma register */ +#define LCD_DISPLAY_OFF 0x28 /* Display off register */ +#define LCD_DISPLAY_ON 0x29 /* Display on register */ +#define LCD_COLUMN_ADDR 0x2A /* Colomn address register */ +#define LCD_PAGE_ADDR 0x2B /* Page address register */ +#define LCD_GRAM 0x2C /* GRAM register */ +#define LCD_MAC 0x36 /* Memory Access Control register*/ +#define LCD_PIXEL_FORMAT 0x3A /* Pixel Format register */ +#define LCD_WDB 0x51 /* Write Brightness Display register */ +#define LCD_WCD 0x53 /* Write Control Display register*/ +#define LCD_RGB_INTERFACE 0xB0 /* RGB Interface Signal Control */ +#define LCD_FRC 0xB1 /* Frame Rate Control register */ +#define LCD_BPC 0xB5 /* Blanking Porch Control register*/ +#define LCD_DFC 0xB6 /* Display Function Control register*/ +#define LCD_POWER1 0xC0 /* Power Control 1 register */ +#define LCD_POWER2 0xC1 /* Power Control 2 register */ +#define LCD_VCOM1 0xC5 /* VCOM Control 1 register */ +#define LCD_VCOM2 0xC7 /* VCOM Control 2 register */ +#define LCD_POWERA 0xCB /* Power control A register */ +#define LCD_POWERB 0xCF /* Power control B register */ +#define LCD_PGAMMA 0xE0 /* Positive Gamma Correction register*/ +#define LCD_NGAMMA 0xE1 /* Negative Gamma Correction register*/ +#define LCD_DTCA 0xE8 /* Driver timing control A */ +#define LCD_DTCB 0xEA /* Driver timing control B */ +#define LCD_POWER_SEQ 0xED /* Power on sequence register */ +#define LCD_3GAMMA_EN 0xF2 /* 3 Gamma enable register */ +#define LCD_INTERFACE 0xF6 /* Interface control register */ +#define LCD_PRC 0xF7 /* Pump ratio control register */ + static uint16_t *_framebuffer = (uint16_t *)(0xD0000000 + 0x50000); static const uint16_t screenwidth = 240; static const uint16_t screenheight = 320; +#include +#include +ssp_port_t lcd_port = { + .ssp = ssp_5, + .sclk = { .port = gpio_port_f, .pin = 7 }, + .mosi = { .port = gpio_port_f, .pin = 9 }, + .miso = { .port = gpio_port_f, .pin = 8 }, + .ss = PIN_NULL, + .mode = ssp_master + }; +pin_t lcd_ncs = { .port = gpio_port_c, .pin = 2 }; +pin_t lcd_wrx = { .port = gpio_port_d, .pin = 13 }; + #define ASSEMBLE_RGB2(RGB) ((((RGB.r) & 0xF8) << 8) | (((RGB.g) & 0xFC) << 3) | (((RGB.b) & 0xF8) >> 3)) +void uGL_writeChunk(uint8_t *data, uint8_t nb) +{ + if (nb < 1) return; + gpio_set(lcd_wrx, 0); + gpio_set(lcd_ncs, 0); + ssp_write(ssp_5, data[0]); + while(SPI_I2S_GetFlagStatus(SPI5, SPI_I2S_FLAG_BSY) != RESET); + + for (int i = 1 ; i < nb ; i++) + { + gpio_set(lcd_wrx, 1); + ssp_write(ssp_5, data[i]); + while(SPI_I2S_GetFlagStatus(SPI5, SPI_I2S_FLAG_BSY) != RESET); + } + gpio_set(lcd_ncs, 1); +} + +#ifndef USE_Delay +/** + * @brief Inserts a delay time. + * @param nCount: specifies the delay time length. + * @retval None + */ +static void delay(__IO uint32_t nCount) +{ + __IO uint32_t index = 0; + for(index = nCount; index != 0; index--) + { + } +} +#endif + +void uGL_init_sequence() { + + uint8_t buffer_init[] = {0xCA, 0xC3, 0x08, 0x50}; + uGL_writeChunk(buffer_init, 4); + + uint8_t buffer_powerb[] = {LCD_POWERB, 0x00, 0xC1, 0x30}; + uGL_writeChunk(buffer_powerb, 4); + + uint8_t buffer_powerseq[] = {LCD_POWER_SEQ, 0x64, 0x03, 0x12, 0x81}; + uGL_writeChunk(buffer_powerseq, 5); + + uint8_t buffer_dtca[] = {LCD_DTCA, 0x85, 0x00, 0x78}; + uGL_writeChunk(buffer_dtca, 4); + + uint8_t buffer_powera[] = {LCD_DTCA, 0x39, 0x2C, 0x00, 0x34, 0x02}; + uGL_writeChunk(buffer_powera, 6); + + uint8_t buffer_prc[] = {LCD_PRC, 0x20}; + uGL_writeChunk(buffer_prc, 2); + + uint8_t buffer_dtcb[] = {LCD_DTCB, 0x00, 0x00}; + uGL_writeChunk(buffer_dtcb, 3); + + uint8_t buffer_frc[] = {LCD_FRC, 0x00, 0x1B}; + uGL_writeChunk(buffer_frc, 3); + + uint8_t buffer_dfc[] = {LCD_DFC, 0x0A, 0xA2}; + uGL_writeChunk(buffer_dfc, 3); + + uint8_t buffer_power1[] = {LCD_POWER1, 0x10}; + uGL_writeChunk(buffer_power1, 2); + + uint8_t buffer_power2[] = {LCD_POWER2, 0x10}; + uGL_writeChunk(buffer_power2, 2); + + uint8_t buffer_vcom1[] = {LCD_VCOM1, 0x45, 0x15}; + uGL_writeChunk(buffer_vcom1, 3); + + uint8_t buffer_vcom2[] = {LCD_VCOM2, 0x90}; + uGL_writeChunk(buffer_vcom2, 2); + + uint8_t buffer_mac[] = {LCD_MAC, 0xC8}; + uGL_writeChunk(buffer_mac, 2); + + uint8_t buffer_3gammaen[] = {LCD_3GAMMA_EN, 0x00}; + uGL_writeChunk(buffer_3gammaen, 2); + + uint8_t buffer_rgbinterface[] = {LCD_RGB_INTERFACE, 0xc2}; + uGL_writeChunk(buffer_rgbinterface, 2); + + uint8_t buffer_dfc2[] = {LCD_DFC, 0x0A, 0xA7, 0x27, 0x04}; + uGL_writeChunk(buffer_dfc2, 5); + + uint8_t buffer_coladdr[] = {LCD_COLUMN_ADDR, 0x00, 0x00, 0x00, 0xEF}; + uGL_writeChunk(buffer_coladdr, 5); + + uint8_t buffer_pageaddr[] = {LCD_PAGE_ADDR, 0x00, 0x00, 0x01, 0x3F}; + uGL_writeChunk(buffer_pageaddr, 5); + + uint8_t buffer_interface[] = {LCD_INTERFACE, 0x01, 0x00, 0x06}; + uGL_writeChunk(buffer_interface, 4); + + uint8_t buffer_gram[] = {LCD_GRAM}; + uGL_writeChunk(buffer_gram, 1); + + delay(200); + + uint8_t buffer_gamma[] = {LCD_GAMMA, 0x01}; + uGL_writeChunk(buffer_gamma, 2); + + uint8_t buffer_pgamma[] = {LCD_PGAMMA, 0x0F, 0x29, 0x24, 0x0C, 0x0E, 0x09, 0x4E, 0x78, 0x3C, 0x09, 0x13, 0x05, 0x17, 0x11, 0x00}; + uGL_writeChunk(buffer_pgamma, 16); + + uint8_t buffer_ngamma[] = {LCD_NGAMMA, 0x00, 0x16, 0x1B, 0x04, 0x11, 0x07, 0x31, 0x33, 0x42, 0x05, 0x0C, 0x0A, 0x28, 0x2F, 0x0F}; + uGL_writeChunk(buffer_ngamma, 16); + + uint8_t buffer_sleepout[] = {LCD_SLEEP_OUT}; + uGL_writeChunk(buffer_sleepout, 1); + + delay(200); + + uint8_t buffer_displayon[] = {LCD_DISPLAY_ON}; + uGL_writeChunk(buffer_displayon, 1); + + uGL_writeChunk(buffer_gram, 1); +} + void uGL_init() { - LCD_Init(); + //configure the LCD SPI pins + gpio_config(lcd_ncs, pin_dir_write, pull_none); + gpio_config(lcd_wrx, pin_dir_write, pull_none); + gpio_set(lcd_ncs, 0); + gpio_set(lcd_ncs, 1); + ssp_config(lcd_port, 5600000); + + //send the init sequence to the LCD + uGL_init_sequence(); + + //clock DMA2D + RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA2D, ENABLE); - LCD_LayerInit(); - LTDC_Cmd(ENABLE); + //init LCD pins + pin_t lcd_pin[] = { + //r + make_pin(gpio_port_c, 10), + make_pin(gpio_port_b, 0), + make_pin(gpio_port_a, 11), + make_pin(gpio_port_a, 12), + make_pin(gpio_port_b, 1), + make_pin(gpio_port_g, 6), + //g + make_pin(gpio_port_a, 6), + make_pin(gpio_port_g, 10), + make_pin(gpio_port_b, 10), + make_pin(gpio_port_b, 11), + make_pin(gpio_port_c, 7), + make_pin(gpio_port_d, 3), + //b + make_pin(gpio_port_d, 6), + make_pin(gpio_port_g, 11), + make_pin(gpio_port_g, 12), + make_pin(gpio_port_a, 3), + make_pin(gpio_port_b, 8), + make_pin(gpio_port_b, 9), + //hsync + make_pin(gpio_port_c, 6), + //vsync + make_pin(gpio_port_a, 4), + //clk + make_pin(gpio_port_g, 7), + //de + make_pin(gpio_port_f, 10), + }; + for (int i = 0 ; i < 22 ; i++) + gpio_config_alternate(lcd_pin[i], pin_dir_write, pull_none, 0x0E); -// LCD_SetFont(&Font8x8); -// LCD_SetLayer(LCD_BACKGROUND_LAYER); -// LCD_Clear(ASSEMBLE_RGB(0x00, 0x66, 0x00)); - LCD_SetLayer(LCD_FOREGROUND_LAYER); -// LCD_SetBackColor(ASSEMBLE_RGB(0x00, 0x00, 0xFF)); + SDRAM_Init(); + + lcddriver_config(); +} + +void uGL_displayOn() +{ + uint8_t command = LCD_DISPLAY_ON; + uGL_writeChunk(&command, 1); } +void uGL_displayOff() +{ + uint8_t command = LCD_DISPLAY_OFF; + uGL_writeChunk(&command, 1); +} uint16_t uGL_getScreenHeight() { @@ -49,10 +271,8 @@ void uGL_drawHLine(uint16_t x, uint16_t y, uint16_t length, uGL_color_t color) void uGL_drawVLine(uint16_t x, uint16_t y, uint16_t length, uGL_color_t color) { - LCD_SetTextColor(ASSEMBLE_RGB2(color)); for (int i = 0 ; i < length ; i++) uGL_drawPixel(x, y + i, color); - //LCD_DrawLine(x, y, length, LCD_DIR_VERTICAL); } void uGL_drawFrame(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uGL_color_t color) @@ -65,10 +285,10 @@ void uGL_drawFrame(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uGL_ void uGL_drawRectangle(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uGL_color_t color) { - LCD_SetTextColor(ASSEMBLE_RGB2(color)); +// LCD_SetTextColor(ASSEMBLE_RGB2(color)); // LCD_SetTextColor(color); //LCD_SetTextColor(ASSEMBLE_RGB(color.r, color.g, color.b)); - LCD_DrawFullRect(x, y, width, height); +// LCD_DrawFullRect(x, y, width, height); } void uGl_blitImage(uGL_image_t *image, uint16_t x, uint16_t y) diff --git a/uGL/uGL.h b/uGL/uGL.h index b5c67d1..e2ce7fe 100644 --- a/uGL/uGL.h +++ b/uGL/uGL.h @@ -31,6 +31,9 @@ typedef struct { void uGL_init(); +void uGL_displayOn(); +void uGL_displayOff(); + uint16_t uGL_getScreenHeight(); uint16_t uGL_getScreenWidth(); From 358caefc483daa024ab1873d7065f2239d66c917 Mon Sep 17 00:00:00 2001 From: Thomas Pietrzak Date: Tue, 16 Oct 2018 08:03:43 +0200 Subject: [PATCH 09/11] rename uGL implementation --- Makefile | 2 +- uGL/Makefile | 3 ++- uGL/{uGL.c => uGL-stm32f429discovery.c} | 0 3 files changed, 3 insertions(+), 2 deletions(-) rename uGL/{uGL.c => uGL-stm32f429discovery.c} (100%) diff --git a/Makefile b/Makefile index e5272d7..5773a66 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ export ROOTDIR = $(CURDIR)/uC-sdk export VERBOSE = true TARGET = bootloader.bin -TARGET_SRCS = bootloader.c uGL/uGL.c uGL/stm32f429i_discovery.c uGL/stm32f429i_discovery_sdram.c uGL/fonts.c +TARGET_SRCS = bootloader.c uGL-stm32f429discovery.c uGL/stm32f429i_discovery.c uGL/stm32f429i_discovery_sdram.c uGL/fonts.c LIBDEPS = \ $(ROOTDIR)/FreeRTOS/libFreeRTOS.a \ diff --git a/uGL/Makefile b/uGL/Makefile index f39c23f..bae6c85 100644 --- a/uGL/Makefile +++ b/uGL/Makefile @@ -7,7 +7,8 @@ include config.mk include $(ROOTDIR)/arch/config.mk include $(ROOTDIR)/FreeRTOS/config.mk -TARGET_SRCS += font.cs +TARGET_SRCS += font.c +TARGET_SRCS += uGL-stm32f429discovery.c TARGET_SRCS += stm32f429i_discovery.c #TARGET_SRCS += stm32f429i_discovery_lcd.c TARGET_SRCS += stm32f429i_discovery_sdram.c diff --git a/uGL/uGL.c b/uGL/uGL-stm32f429discovery.c similarity index 100% rename from uGL/uGL.c rename to uGL/uGL-stm32f429discovery.c From 3ed09fe0d7b219271b2f8ead09c83708a3c9c840 Mon Sep 17 00:00:00 2001 From: Thomas Pietrzak Date: Sat, 20 Oct 2018 14:08:48 +0200 Subject: [PATCH 10/11] draft implentation for uGPU --- Makefile | 3 +- bootloader.c | 11 +- logo.h | 636 +++++++++++++++++++++++++++++++++++ uC-sdk | 2 +- uGL/Makefile | 5 +- uGL/uGL-stm32f429discovery.c | 2 +- uGL/uGL-uGPU.c | 113 +++++++ uGL/uGL.h | 38 ++- 8 files changed, 795 insertions(+), 15 deletions(-) create mode 100644 logo.h create mode 100644 uGL/uGL-uGPU.c diff --git a/Makefile b/Makefile index 5773a66..0202ed0 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,8 @@ export ROOTDIR = $(CURDIR)/uC-sdk export VERBOSE = true TARGET = bootloader.bin -TARGET_SRCS = bootloader.c uGL-stm32f429discovery.c uGL/stm32f429i_discovery.c uGL/stm32f429i_discovery_sdram.c uGL/fonts.c +#TARGET_SRCS = bootloader.c uGL-stm32f429discovery.c uGL/stm32f429i_discovery.c uGL/stm32f429i_discovery_sdram.c uGL/fonts.c +TARGET_SRCS = bootloader.c uGL/uGL-uGPU.c LIBDEPS = \ $(ROOTDIR)/FreeRTOS/libFreeRTOS.a \ diff --git a/bootloader.c b/bootloader.c index 9636acd..7a93dba 100644 --- a/bootloader.c +++ b/bootloader.c @@ -1,7 +1,8 @@ #include #include "uGL/uGL.h" - +#include "logo.h" +/* void drawRainbow() { uGL_color_t c; @@ -26,12 +27,16 @@ void drawRainbow() c.r = 0xff; c.g = 0x00; c.b = 0xff - i * 0xff / 40; uGL_drawVLine(i + 200, 0, 10, c); } -} +}*/ int main() { uGL_init(); + uGL_sprite_t sprite_logo = { .id = 0, .pixels = &logo}; + uGl_loadSprite(&sprite_logo); + uGl_drawSprite(&sprite_logo, (480 - 64) / 2, (272 - 64) / 2); +/* uGL_color_t backgroundcolor = { .r = 255, .g = 255, .b = 255 }; uGL_drawRectangle(0, 0, 240, 320, backgroundcolor); @@ -59,7 +64,7 @@ int main() uGL_drawHLine(120, 80, 100, hlinecolor); uGL_color_t vlinecolor = { .r = 250, .g = 240, .b = 10 }; - uGL_drawVLine(90, 20, 200, vlinecolor); + uGL_drawVLine(90, 20, 200, vlinecolor);*/ while(1); return 0; diff --git a/logo.h b/logo.h new file mode 100644 index 0000000..8c31090 --- /dev/null +++ b/logo.h @@ -0,0 +1,636 @@ +uGL_image_t logo = { + .width = 64, + .height = 64, + .colormode = 24, + .data = { .rgb = (uGL_color_rgb_t *) + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\376\376\376\376\376\376\376\376\376" + "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376" + "\376\376\376\376\376\376\360\360\360\306\306\305\254\245\243\226\207\203" + "\227\204\177\250\235\232\277\275\274\347\347\350\375\375\375\376\376\376" + "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376" + "\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376\376" + "\376\376\376\376\376\376\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\362\362\361\246\241\237" + "o?&\204F\036\206G\036\206G\036\207H\037\205G\036o;\035a\062\026rN?tM;\232\221\214" + "\337\340\341\376\376\376\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\340\342\340z]R\206G\037\207H\036\207H\037\206G\036\207" + "H\037s>\037o;\035\202F\036\210F\040\205H!\200C\036\207H\040r?\"\315\314\314\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\350\351\351wQB\207" + "G\036\206G\037\207H\037\207G\040\202F\040s=\036\200E\040|C\037yM\061\260\231\202\330" + "\302\254\346\320\267\314\270\242l>\"qL<\357\357\357\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\375\375\375\212xr\206G\036\207G\037\207G\037\206G\036\207G\036\201" + "D\037\206G\036\177T>\336\311\260\323\277\250\355\330\274\375\342\305\376\343" + "\306\376\342\306\271\244\217\204F!\261\256\254\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\317\316\316\201D\037\207H\036\206G\036\207G\036\206G\036\206G\036\206" + "G\036\207G\040\250\222~\335\310\257\267\247\225\374\343\306\375\342\305\375" + "\342\305\376\342\305\367\336\302\177WA\177dY\376\376\376\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\343" + "\344\343mL?\207G\037\207H\037\206G\037\206G\037\207H\037\207G\040\207G\040\206j" + "Y\353\325\272\337\313\262\327\304\252\306\265\237\375\342\305\376\343\306" + "\376\343\306\375\343\307\270\242\214r<\035\361\361\361\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\365\366\365\201i_w@" + "\035\207H\037\207H\037\206G\037\206G\037\206G\036\207G\036xB\"\343\316\264\376\343" + "\306\375\342\305\375\342\306\250\233\212\373\342\306\376\343\306\375\342" + "\305\375\342\306\335\311\260v?\034\346\346\346\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\376\377\253\246\243\204F\040|A\036\206" + "G\036\206G\036\206G\036\206G\036\206G\036\205F\036\247\226\205\376\342\305\376" + "\343\306\376\343\306\376\342\306\330\304\254\330\303\254\376\343\306\376" + "\343\306\374\342\305\313\273\247{bO\345\345\345\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\357\356\356o>\"\207G\036\206G\040\207G\037" + "\207H\037\206G\036\206G\036\210G\036\206of\322\307\274\376\342\305\376\343\306" + "\376\343\306\375\343\306\322\311\276\277\263\245\357\330\275\363\332\276" + "\330\305\255\224\214}\222\203q\357\356\356\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\274\273\271\206F\040\210G\037\207G\036\207G\037" + "\207H\037\206G\036\207G\036{Q?\342\342\342\322\302\256\360\331\276\357\330\276" + "\376\342\306\360\330\276\344\345\345\300\275\270\337\316\265\317\276\252" + "\301\267\247\347\322\271u`X\376\376\376\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\231\216\212\207F\036\210F\036\207F\037\206G\037\210" + "G\037\205H\040\201e[\340\340\340\324\323\322\365\335\302\357\331\276\271\255" + "\234\372\342\305\322\300\252\324\325\324\315\302\265\342\317\267\333\333" + "\331\336\322\303\300\255\225\257\250\244\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\376\376\376}d[\207H\036\210G\037{C!{B\037\223~" + "v\316\313\314\370\370\367\353\353\352\332\311\263\375\342\305\376\342\306" + "\372\340\305\314\273\246\232\216{\210\206\205\361\332\300\314\271\243\304" + "\304\304\353\325\273\204p^\347\350\347\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\376\376\376mA,\207G\036\207H\037r>\037{B\037\251\241" + "\236\341\341\341\362\362\361\320\301\257\376\343\306\376\343\306\376\343" + "\306\376\343\306\374\342\305\225\211z\322\277\250\375\342\304\267\250\224" + "\313\275\251\332\307\257\230\224\223\347\347\347\373\373\374\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\376\377\377oF\063\207G\036\207G\040k\071" + "\033\257\253\251\365\365\365\375\375\375\304\273\260\375\342\306\375\342\305" + "\375\342\306\375\345\310\375\345\307\360\332\276\301\232\216\313\215\201" + "\314\236\221\274\216\205\333\230\216\341\232\217\350\236\222\345\235\220" + "\315\227\217\327\325\324\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\376\376\376" + "\204og\207H\037}B\033p;\034\253\252\251\376\376\376\321\320\316\367\336\303" + "\374\342\305\315\275\250\267\253\227\322\300\247\323\301\245\274\242\220" + "\370\251\233\370\251\234\370\251\234\350\240\225\370\251\234\370\251\234" + "\370\251\234\370\251\234\370\251\234\330\226\214\345\345\345\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\376\376\230\212\206\207G\036\204F\037cG<\363\363\363\376\376" + "\376\317\300\260\376\342\306\336\313\263\344\316\265\352\322\270\307\270" + "\243\372\341\305\322\261\235\367\251\233\370\251\234\370\251\234\370\251" + "\234\370\251\234\370\251\234\370\251\234\370\251\234\370\251\234\370\251" + "\234\306\266\266\376\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\257\251\247\210G\037" + "\206G\037\254\242\237\363\363\363\367\370\367\341\314\262\376\342\306\375" + "\342\305\376\343\306\374\342\306\370\340\304\314\274\247\331\305\253\361" + "\245\231\370\251\234\370\251\234\370\251\234\370\251\234\370\251\234\370" + "\251\234\370\251\234\370\251\234\370\251\234\307\261\257\376\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\303\302\301\207G\036\207G\037\243\235\232\336\336\336" + "\375\376\375\321\303\261\375\342\304\375\343\306\362\332\277\323\301\253" + "\307\272\251\343\316\266\325\304\253\311\234\214\370\251\233\370\251\234" + "\370\251\234\370\251\234\370\251\234\370\251\234\370\251\234\370\251\234" + "\361\245\230\314\311\311\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\376\376\253\254\252" + "\210G\037\210F\036w?\034\350\350\350\377\377\377\363\363\363\330\327\323\332" + "\330\325\345\346\345\376\376\376\360\361\361\327\306\262\336\312\261\266" + "\253\227\306\212\203\370\251\233\370\251\233\370\251\234\370\251\234\370" + "\251\234\370\251\233\367\251\234\272\225\221\372\372\372\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\362\362\362aF<\207H\037\210G\037\200D\037\340\340\340\372\372\372\324" + "\320\321\306\253\255\314\275\275\372\372\372\377\377\377\377\377\377\341" + "\342\341\273\260\237\323\304\256\302\264\237\247\210\201\324\224\213\357" + "\244\231\370\252\236\362\247\233\325\223\211\267\237\235\360\360\360\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\256\250\247zC!\207G\037\206G\036\206G\035\214" + "}y\267Z]\331\037.\340\036-\340\037/\320\273\274\377\377\377\377\377\377\377" + "\377\377\321\311\300\376\342\304\375\343\306\351\322\267\303\266\251\314" + "\314\314\312\311\311\316\316\316\300\300\300\375\375\375\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\362\362\362uD.\206F\040\211G\036\207G\037z@\035\302\036*" + "\341\036.\341\036.\341\036.\340\036.\307\221\223\376\377\377\377\377\377\377" + "\377\377\357\360\360\313\300\256\343\316\265\346\322\271\322\300\250\271" + "\266\262\363\363\363\377\377\377\353\353\353\255ru\317\306\306\364\365\364" + "\376\376\376\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\302\303\302\206F\036\210G\037\207G\037\207G\037\237+\"\341\036.\341" + "\036.\341\036.\341\036.\337\037-\313\237\240\377\377\377\377\377\377\377\377" + "\377\377\377\377\376\376\376\305\300\273\337\313\262\374\343\307\356\330" + "\276\257\250\233\356\356\356\330\330\331\301mp\336\040.\303-\064\303\223\224" + "\325\323\324\374\374\374\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\253\254\251\207H\037\210F\036\207G\037w=\035\311\034*\341\036/\341\036.\341\036" + ".\341\036.\341\036-\317\265\265\377\377\377\377\377\377\377\377\377\377\377" + "\377\371\372\372\332\304\255\363\332\277\301\263\234\333\305\257\364\335" + "\301\321\300\254\346\346\345\270JO\326\036-\335\037.\341\036.\333\037-\246\210" + "w\352\352\351\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\332\332\332y@\036\206F\040" + "\203\063\040\273\032(\341\036.\341\036.\341\036.\341\036.\341\036.\341\036-\312\301" + "\302\371\371\371\377\377\377\361\361\361\322\314\303\321\311\275\315\272" + "\244\327\303\255\375\343\306\371\337\303\356\327\275\376\344\307\263\251" + "\246\240~\201\242\033*\323\036.\341\036.\335\036-\255\212U\270\235{\373\374\374" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\376\376\376\274\272\273\234#!\334\037/\341\036.\341" + "\036.\341\036.\341\036.\341\036.\341\036.\342\036-\262\232\233\376\376\376\376" + "\377\376\324\313\300\375\343\306\376\343\306\320\277\251\327\305\255\375" + "\343\307\363\333\300\320\275\247\376\343\306\300ti\266\034)\341\036,\342\035" + "/\341\036.\341\036.\261C\065\271\222Z\332\332\331\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\376\376\375\306" + "\305\300\260*\062\341\036/\341\036.\341\036.\341\036.\341\036.\341\036.\341\036." + "\340\036.\334\037/\300\200\202\374\374\374\377\377\377\332\326\317\327\306" + "\263\345\317\266\325\303\254\250\234\211\374\343\306\324\301\250\365\335" + "\301\375\343\306\265zp\330\037-\341\036.\341\036.\341\036.\341\036.\341\036/\266" + "G\067\315\314\314\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\376\302\276\271\245\204O\323\035+\341\036.\341\036" + ".\341\036.\341\036.\341\036.\341\036.\340\037.\322\036,\267\033+\300\205\206\355" + "\355\356\377\377\377\377\377\376\376\377\376\346\346\346\334\311\261\354" + "\326\273\314\273\244\333\310\255\375\343\306\375\343\306\333\310\257\323" + "\035+\341\036-\341\036.\341\036.\341\036.\341\036.\311\033*\351\352\351\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\337\337" + "\336\301\231\\\244\203O\331!-\341\036.\341\036.\341\036.\341\036.\341\036.\341" + "\036/\311\032)\273\034'\335\040.\306w{\327\327\327\377\377\377\377\377\377\377" + "\377\377\377\377\377\321\317\314\360\333\300\361\332\277\376\343\306\376" + "\342\306\376\342\306\375\343\305\301kb\341\036.\341\036.\341\036.\341\036.\342" + "\036.\265\214\217\376\375\375\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\302\265\247\320\246`\270\223Y\323\035-\341\036" + ".\341\036.\341\036.\340\036.\334\037-\240\031$\307\035)\340\037/\341\036.\320'\061" + "\277\257\257\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\335\334\333\233zq\340\314\262\352\325\273\307\244\224\314\230\207\255KI" + "\341\036.\341\036.\341\036.\341\036.\272PU\357\356\356\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\272\250\223" + "\320\245a\255fB\337\036-\341\036.\341\036.\341\037/\275\032(\261\035(\250\031$\310" + "\035*\332\036-\341\036.\340\036.\271jm\375\376\376\376\376\376\377\377\377\377" + "\377\377\377\377\377\375\376\375\305\217\221\314\035*\315\035+\341\036.\341" + "\037/\275\032(\325\034*\341\037/\337\037.\274LQ\342\342\343\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\302\274\266\247\202M\327\037-\341\036.\341\036.\337\037.\301\035*\273\033" + ")\233\030&\260\037)\231\030\040\324\036,\341\036.\341\036.\314\034+\347\347\347\351" + "\351\351\377\377\377\377\377\377\377\377\377\376\377\377\331\326\326\330" + "\036,\341\036/\341\036.\341\036.\270\030&\313\034)\336\036/\262df\321\320\321\376" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\355\356\356\244SK\340\036-\341\036.\341\036" + ".\341\036/\274\033'\264\033%\331\037.\341\036-\314\034*O\015\021\277\032*\341\037-" + "\341\036-\277\235\237\331\332\333\376\376\377\377\377\377\377\377\377\377" + "\377\377\375\376\376\272\205\207\315\037-\331\036-\331\036.\271\033)\257\031$" + "\301\247\250\371\371\371\330\330\330\324\324\324\375\375\375\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\376\376\337\336\336\260VX\333\036-\335\036.\254\032'\322\037+\340\036-\341" + "\036.\341\036.\341\036.\305\033)'\005\007\242\026#\336\037-\323\035,\243\215\220\334" + "\326\327\377\377\377\377\377\377\377\377\377\377\377\377\356\357\357\272" + "Y^\304\035+\302\033*\335\037-\311\275\275\376\377\377\377\377\377\377\377\377" + "\364\364\364\314\314\314\330\330\330\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\370\370\371" + "\330\324\324\243Y]\334\036\060\340\037.\341\036.\341\036.\341\036.\341\036.\311" + "\035)\263\031'\016\003\002w\020\031\321\036+\334\036/\302PU\357\357\360\377\377\377" + "\377\377\377\377\377\377\376\377\377\354\356\357\276\220\222\271HK\306\257" + "\257\374\375\375\377\377\377\377\377\377\377\377\377\352\352\352\300\300" + "\300\312\312\312\315\315\315\346\346\346\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\376\376\376\253\227" + "\230\265\033'\272\027'\263\032&\323\036*\341\036.\340\036.\303\032.\323\037,\267" + "\031'\032\005\004)\006\010\233\024\037\310\035)\247ff\356\357\357\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\375\376\376\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\372\372\372\312\312\312\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\344\343\344\312\065<\341\036.\340" + "\037.\341\036.\277\033(\306\035*\340\037.\302\033)\337\036/\340\036-\312\033*i\015" + "\025\030\021\016\330\243$\004\002\006QPP\334\334\334\377\376\376\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\366\366\366\314\314\314\316\316\316\373\373" + "\373\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\376\376\376\271~\200\340\036-\341\036.\341\036.\341\036.\341\036.\315\034" + "-\262\035,\317\035,\341\036.\341\036.\341\036-\342\037.\277Y,\357\261\033\247|\016" + "\257\203\040\237w&\266\244\245\362\363\364\377\377\377\377\377\377\377\377" + "\377\377\377\377\376\376\376\372\372\372\345\345\345\323\323\323\314\314" + "\314\322\322\322\371\371\371\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\350\350\350\313\033*" + "\341\036.\341\036.\341\036.\341\036.\341\036.\337\037-\343\036/\340\036.\341\036." + "\341\036.\341\036.\341\036.\314\035+\253`!\221i\034h;\037\327\036-\303\033(\253X" + "Z\304\304\304\323\323\323\353\353\353\365\365\365\327\327\327\243\243\243" + "\341\341\341\376\376\376\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\314\314\314\340\037\060\341\036.\341\036.\341\036.\341\036.\341\036" + ".\341\036.\341\036.\341\036.\341\036.\341\036.\341\036.\340\036-\264\032*\242+#\207" + "H\037x@\035\326\037,\276\034(\277\071>\375\375\375\364\364\364\341\341\341\324" + "\324\324\335\335\335\364\364\364\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\333\335\335\316\035+\340\036." + "\342\036-\341\036.\341\036.\341\036.\341\036.\341\036.\341\036.\341\036.\341\036." + "\340\037.\273\033'\316\034-z@\037\207G\036y?\035\324\035,\317\033)\317\036-\340\341" + "\342\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\376\376\376\343\345\345\312\313\311\204b`\225&\037\301\036)\342\036.\341" + "\036.\341\036.\341\036.\341\036.\341\036.\341\037.\310\035-\246%\"\211F\037\210G" + "\037z@\033\317\033*\337\036.\340\037.\272\243\243\376\376\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\222~x\207H\036x?\035\231#\"\335\036/\341\036.\341\036.\341\036.\341\036" + ".\341\036.\337\040-\206\063\"\207G\035\207F\037\200B\034\312\033*\341\036.\341\036" + "/\301\036,\335\337\336\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\376\376\376\224\202}\206G\036\206G\036\204" + "G\040\203+\035\327\035-\341\036.\341\036.\341\036.\341\036.\337\040\061o\071\031\206" + "G\037\200D\037\207H!\271\032$\341\036.\341\036.\340\036.\266OS\363\363\363\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\254\245\243\210F\035\210G\037\210H\037\207G\040{\064\035\317\035+\341\036" + ".\341\036.\341\036.\333\036/f\066\033n=\040|B\036\207G\040\244*&\341\036.\341\036." + "\333\036-\263vv\362\362\362\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\313\312\313\204G\040\206G\036\206G\036" + "\207H\037\206G\035z:\035\307\036)\341\036.\341\036.\333\037-p=\036v?\040\204E\037\210" + "G\037z:\036\332\036-\331\036-\273\244\245\373\373\373\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\363\363\363q@%\206G\036\206G\036\206G\036\206G\036\206G\036zA\036\240&&\325\035" + ",\314\034-\177C\036\206G\036\206G\036\207H\037\206H\040\210\064\"\233wx\376\376" + "\376\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\376\377\376\250\235\230\206G\040" + "\201D\037\206G\036\206G\036\206G\036\206G\037\224\200z\346\346\346\306\306\305" + "\202D\037\210G\037\210G\037\207G\037zA\036\203F!\256\240\235\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\316\317\316\177C\037w?\037\205F\040" + "\210G\036\203F\037\206G\036\253\243\241\377\377\377\375\376\375\215~y\207H\037" + "\207G\037\206G\036\207H\037\200E\037\233\206\177\376\376\376\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\305\303\301\206F\036\207G\037m:\035o<\034\200" + "D\040\204F\037\211vs\375\376\376\376\377\376\224\204~\210G\037\207G\036\207H" + "\037\207G\037\210G\037i;\"\322\323\322\372\372\372\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\311\310\307x?\035oB$l<\035\200B\036\206H\040\207H\037rD\060\375\376\374" + "\316\311\303\201^>\207G\037\207F\036\206G\036\204F\037\214f;\306\236_\314\243" + "_\251\224w\360\360\357\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\307\305\301\272\224X\321\245" + "`\320\245b\263\220R\200V\064\207H\037tH)\336\335\333\272\255\233\225sC\207" + "G\037\207F\036\203E\040\226rD\317\244_\320\245`\320\245`\320\246`\271\253\231" + "\376\376\375\376\376\376\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\376\376\376\261\225m\322\244^\320\246_\321\245_\320\246`\313" + "\242]\210a\070\214c:\271\245\215\340\341\337\256\214Y\221l=v@\035\243~J\321" + "\246a\320\245`\321\245`\276\231Z\260\216Y\251\206Q\251\206Q\265\244\214\331" + "\331\330\352\353\352\375\375\375\376\376\376\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\376\377\376\332\331\331\236" + "\177O\251\211U\253\211T\255\212S\264\220U\320\246_\306\236]\252\207P\274" + "\252\224\323\321\316\306\237_\317\246`\316\242`\320\245`\320\245`\320\245" + "`\314\241_\315\243`\320\245`\310\240`\267\223W\255\212T\273\230X\267\223" + "[\251\215b\300\272\261\371\371\371\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\376\376\376\276\265\253\304\234\\\320\245`\320\245`\317\246_\320" + "\245a\315\242^\264\222\\\315\243`\314\242`\273\260\242\306\272\247\320\245" + "b\320\245`\320\245`\320\245`\320\245`\320\245`\320\245_\320\245`\320\245" + "a\317\245_\320\245`\320\246_\321\246a\320\245`\316\244`\267\225X\243\230" + "\206\305\301\275\346\350\347\376\377\376\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\376\376\376\303\303\301\246\205" + "M\251\206L\261\214Q\301\232[\321\246_\320\245`\320\245`\320\245a\317\244" + "`\320\245`\256\221b\310\303\273\315\243`\321\245a\320\245`\320\245_\320\245" + "_\320\245`\320\245`\321\246a\320\245`\320\245`\320\245`\320\245`\320\245" + "`\320\245`\316\243`\321\245`\322\245b\320\246a\265\222]\343\343\344\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\376\376\376\324\323\321\250\222" + "x\266\222W\310\241\\\320\250d\315\242^\275\227Z\260\214R\266\224[\307\236" + "a\321\246a\320\246`\317\245`\253\221o\373\373\372\305\300\274\254\224v\253" + "\210M\255\215Z\253\212Q\314\242_\320\245`\320\245`\320\245`\320\245`\320" + "\245`\320\245`\320\245`\320\245`\320\245`\320\245`\320\245`\320\245`\307" + "\237^\326\326\326\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\322\321" + "\316\277\230Y\320\245a\320\245`\320\245`\320\245`\320\245`\320\245`\320\245" + "`\320\245`\312\242`\316\244`\320\245_\254\216f\341\340\337\377\377\377\377" + "\377\377\377\377\376\374\374\373\361\362\361\367\370\366\321\317\316\260" + "\236\210\264\220U\317\245a\317\245`\320\245_\320\245`\320\245`\316\244a\272" + "\225Z\265\220X\261\215U\257\224o\310\304\300\376\377\376\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\274\247\212\320\245`\320\245_\315\241`\305" + "\234[\321\246a\320\245`\320\245`\320\245`\320\245`\320\245`\321\246a\320" + "\246a\323\320\314\376\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\352\353\351\303\301" + "\276\263\244\223\250\210Z\263\217U\274\226[\262\216T\266\241\207\344\342" + "\342\371\371\367\377\377\376\377\377\376\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\274\253\222\300\232Y\252\212T\265\220U\302\232" + "X\314\241]\320\245_\320\245`\320\245`\320\245`\320\245`\320\245_\260\217" + "^\360\360\360\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\376\376\376\362\361\360\351\351\347\365\366\364\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\347\347\345\250\206V\320\246`\320\245" + "`\320\245`\320\246`\320\245a\320\246`\320\245`\320\245`\320\245a\256\215" + "Z\317\316\315\376\376\376\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\376\376\263\250\231" + "\305\235_\321\247c\312\241_\264\222^\245\220t\247\214a\263\231z\265\246\222" + "\301\277\272\355\355\355\377\377\376\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\375\375\374\327\330\327\312\312\312\324\324\324\365\365\365" + "\376\376\376\377\377\377\376\376\376\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377" + }}; + diff --git a/uC-sdk b/uC-sdk index e42bd8c..fd14802 160000 --- a/uC-sdk +++ b/uC-sdk @@ -1 +1 @@ -Subproject commit e42bd8c59b0318772831261f87ace7aeeef756dc +Subproject commit fd1480298124310cc5b3dae19c15182961609975 diff --git a/uGL/Makefile b/uGL/Makefile index bae6c85..0a7dc58 100644 --- a/uGL/Makefile +++ b/uGL/Makefile @@ -5,10 +5,11 @@ export BOARD = stm32f429discovery include $(ROOTDIR)/common.mk include config.mk include $(ROOTDIR)/arch/config.mk -include $(ROOTDIR)/FreeRTOS/config.mk +include $(ROOTDIR)/hardware/config.mk TARGET_SRCS += font.c -TARGET_SRCS += uGL-stm32f429discovery.c +#TARGET_SRCS += uGL-stm32f429discovery.c +TARGET_SRCS += uGL-uGPU.c TARGET_SRCS += stm32f429i_discovery.c #TARGET_SRCS += stm32f429i_discovery_lcd.c TARGET_SRCS += stm32f429i_discovery_sdram.c diff --git a/uGL/uGL-stm32f429discovery.c b/uGL/uGL-stm32f429discovery.c index 354a273..55540f2 100644 --- a/uGL/uGL-stm32f429discovery.c +++ b/uGL/uGL-stm32f429discovery.c @@ -291,6 +291,6 @@ void uGL_drawRectangle(uint16_t x, uint16_t y, uint16_t width, uint16_t height, // LCD_DrawFullRect(x, y, width, height); } -void uGl_blitImage(uGL_image_t *image, uint16_t x, uint16_t y) +void uGl_drawImage(uGL_image_t *image, uint16_t x, uint16_t y) { } diff --git a/uGL/uGL-uGPU.c b/uGL/uGL-uGPU.c new file mode 100644 index 0000000..b9a4802 --- /dev/null +++ b/uGL/uGL-uGPU.c @@ -0,0 +1,113 @@ +#include "uGL.h" + +#include + +#include +#include + +pin_t cs; + +#define SSP ssp_4 +#define SPRITE_SIZE (16*16) + +void ssp_write_uint16(uint16_t v) { + ssp_write(SSP, (uint8_t)(v >> 8)); + ssp_write(SSP, (uint8_t)(v & 0x00ff)); +} + +void uGL_init() { + pin_t sck = make_pin(gpio_port_e, 2); + pin_t miso = make_pin(gpio_port_e, 5); + pin_t mosi = make_pin(gpio_port_e, 6); + ssp_port_t ssp = { + .sclk = sck, + .mosi = mosi, + .miso = miso, + .ss = PIN_NULL, + .mode = ssp_master, + .polarity = ssp_polarity_mode_0, + .ssp = ssp_4 + }; + ssp_config(ssp, 8000000); + + cs = make_pin(gpio_port_d, 1); + + gpio_config(cs, pin_dir_write, pull_none); + gpio_set(cs, 1); + + gpio_set(cs, 0); + ssp_write(SSP, 's'); + ssp_write_uint16((uint16_t) 480); + ssp_write_uint16((uint16_t) 272); + gpio_set(cs, 1); + + uGL_displayOn(); +} + +void uGL_displayOn() { + gpio_set(cs, 0); + ssp_write(SSP, 'o'); + gpio_set(cs, 1); +} + +void uGL_displayOff() { + gpio_set(cs, 0); + ssp_write(SSP, 'f'); + gpio_set(cs, 1); +} + +void uGL_drawText(uint16_t x, uint16_t y, uint8_t font, char *text, uint8_t nb, uGL_color_rgb_t color) { + for (uint8_t i = 0 ; i < nb ; i++) { + gpio_set(cs, 0); + ssp_write(SSP, 't'); + ssp_write(SSP, font); + ssp_write(SSP, text[i]); + ssp_write_uint16(x + i * font); + ssp_write_uint16(y); + ssp_write(SSP, color.r); + ssp_write(SSP, color.g); + ssp_write(SSP, color.b); + gpio_set(cs, 1); + } +} + +void uGl_loadSprite(uGL_sprite_t *sprite) { + //check image size? + //do we assume it is RGB? RGBA? + gpio_set(cs, 0); + ssp_write(SSP, 'l'); + ssp_write(SSP, sprite->id); + for (unsigned i = 0 ; i < SPRITE_SIZE ; i++) { + ssp_write(SSP, sprite->pixels->data.rgb[i].r); + ssp_write(SSP, sprite->pixels->data.rgb[i].g); + ssp_write(SSP, sprite->pixels->data.rgb[i].b); + } + gpio_set(cs, 1); +} + +void uGl_unloadSprite(uGL_sprite_t *sprite) { + gpio_set(cs, 0); + ssp_write(SSP, 'u'); + ssp_write(SSP, sprite->id); + gpio_set(cs, 1); +} + +void uGl_drawSprite(uGL_sprite_t *sprite, uint16_t x, uint16_t y) { + gpio_set(cs, 0); + ssp_write(SSP, 'd'); + ssp_write_uint16((uint16_t) x); + ssp_write_uint16((uint16_t) y); + gpio_set(cs, 1); +} + +void uGl_setLookupTable(uGL_colormode bitspercolor, uGL_color_rgb_t *colors) { + gpio_set(cs, 0); + ssp_write(SSP, 'i'); + ssp_write(SSP, bitspercolor); + for (uint8_t i = 0 ; i < pow(2, bitspercolor) ; i++) { + ssp_write(SSP, colors[i].r); + ssp_write(SSP, colors[i].g); + ssp_write(SSP, colors[i].b); + } + gpio_set(cs, 1); +} diff --git a/uGL/uGL.h b/uGL/uGL.h index e2ce7fe..1ae89c0 100644 --- a/uGL/uGL.h +++ b/uGL/uGL.h @@ -7,9 +7,15 @@ typedef struct { uint8_t g; uint8_t b; uint8_t a; -} uGL_color_t; +} uGL_color_rgba_t; -typedef uGL_color_t *uGL_lookuptable; +typedef struct { + uint8_t r; + uint8_t g; + uint8_t b; +} uGL_color_rgb_t; + +typedef uint8_t uGL_color_indexed_t; typedef enum { INDEXED1 = 1, @@ -22,12 +28,22 @@ typedef enum { typedef struct { uint16_t width; - uint16_t length; + uint16_t height; uGL_colormode colormode; - uGL_lookuptable *lookuptable; - uint8_t *data; + union { + uGL_color_rgb_t *rgb; + uGL_color_rgba_t *rgba; + uGL_color_indexed_t *indexed; + } data; } uGL_image_t; +typedef uGL_color_rgb_t *uGL_lookuptable; + +typedef struct { + uint8_t id; + uGL_image_t *pixels; +} uGL_sprite_t; + void uGL_init(); @@ -36,11 +52,19 @@ void uGL_displayOff(); uint16_t uGL_getScreenHeight(); uint16_t uGL_getScreenWidth(); - +/* void uGL_drawPixel(uint16_t x, uint16_t y, uGL_color_t color); void uGL_drawHLine(uint16_t x, uint16_t y, uint16_t length, uGL_color_t color); void uGL_drawVLine(uint16_t x, uint16_t y, uint16_t length, uGL_color_t color); void uGL_drawFrame(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uGL_color_t color); void uGL_drawRectangle(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uGL_color_t color); -void uGl_blitImage(uGL_image_t *image, uint16_t x, uint16_t y); +void uGl_drawImage(uGL_image_t *image, uint16_t x, uint16_t y); +*/ +void uGL_drawText(uint16_t x, uint16_t y, uint8_t font, char *text, uint8_t nb, uGL_color_rgb_t color); + +void uGl_loadSprite(uGL_sprite_t *sprite); +void uGl_unloadSprite(uGL_sprite_t *sprite); +void uGl_drawSprite(uGL_sprite_t *sprite, uint16_t x, uint16_t y); + +void uGl_setLookupTable(uGL_colormode bitspercolor, uGL_color_rgb_t *colors); From 4a837cebc2044b8def810c48c777f8f2684f2f13 Mon Sep 17 00:00:00 2001 From: Thomas Pietrzak Date: Sat, 20 Oct 2018 14:15:01 +0200 Subject: [PATCH 11/11] change default sprite size --- uGL/uGL-uGPU.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/uGL/uGL-uGPU.c b/uGL/uGL-uGPU.c index b9a4802..062063b 100644 --- a/uGL/uGL-uGPU.c +++ b/uGL/uGL-uGPU.c @@ -8,7 +8,7 @@ pin_t cs; #define SSP ssp_4 -#define SPRITE_SIZE (16*16) +#define SPRITE_SIZE (64*64) void ssp_write_uint16(uint16_t v) { ssp_write(SSP, (uint8_t)(v >> 8));