From: Thomas Pietrzak Date: Sun, 23 Sep 2018 15:19:17 +0000 (+0200) Subject: init X-Git-Url: https://git.thomaspietrzak.com/?a=commitdiff_plain;h=095939ca5064ddec817d52bc3d4032e405dabf40;p=gyro-stm32f429.git init --- 095939ca5064ddec817d52bc3d4032e405dabf40 diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..5ed284e --- /dev/null +++ b/Makefile @@ -0,0 +1,61 @@ +export VERBOSE = true +export DEBUG = true +ROOTDIR = $(CURDIR)/uC-sdk +export BOARD = stm32f429discovery + +TARGET = lcdexample.bin +#TARGET_OBJS = lib/stm32f429i_discovery.o lib/stm32f429i_discovery_lcd.o lib/stm32f429i_discovery_sdram.o lib/fonts.o +TARGET_SRCS = lcdexample.c lib/stm32f429i_discovery.c lib/stm32f429i_discovery_lcd.c lib/stm32f429i_discovery_sdram.c lib/fonts.c + +LIBDEPS = uC-sdk/chips/libchips.a uC-sdk/hardware/libhardware.a uC-sdk/FreeRTOS/libFreeRTOS.a uC-sdk/arch/libarch.a uC-sdk/os/libos.a uC-sdk/libc/libc.a uC-sdk/libm/libm.a uC-sdk/acorn/libacorn.a +LIBS = -Wl,--start-group $(LIBDEPS) -Wl,--end-group +TARGET_INCLUDES = include + +export MAINDIR = $(CURDIR) +export ROOTDIR = $(MAINDIR)/uC-sdk/ + +include $(MAINDIR)/lib/config.mk +include $(ROOTDIR)/common.mk + +all: deps uC-sdk lib $(TARGET) + +clean: clean-generic + $(Q)rm -f $(TARGET) + $(Q)$(MAKE) $(MAKE_OPTS) -C uC-sdk clean + $(Q)$(MAKE) $(MAKE_OPTS) -C lib clean + +.PHONY: uC-sdk lib + +uC-sdk/FreeRTOS/libFreeRTOS.a: uC-sdk +uC-sdk/arch/libarch.a: uC-sdk +uC-sdk/os/libos.a: uC-sdk +uC-sdk/libc/libc.a: uC-sdk +uC-sdk/libm/libm.a: uC-sdk +uC-sdk/acorn/libacorn.a: uC-sdk +uC-sdk/hardware/libhardware.a: uC-sdk +uC-sdk/chips/libchips.a: uC-sdk + +lib: + $(E) "[MAKE] Entering lib" + $(Q)$(MAKE) $(MAKE_OPTS) -C lib + +uC-sdk: + $(E) "[MAKE] Entering uC-sdk" + $(Q)$(MAKE) $(MAKE_OPTS) -C uC-sdk + +deps: ldeps + $(E) "[DEPS] Creating dependency tree for uC-sdk" + $(Q)$(MAKE) $(MAKE_OPTS) -C uC-sdk ldeps + $(E) "[DEPS] Creating dependency tree for lib" + $(Q)$(MAKE) $(MAKE_OPTS) -C lib ldeps + +include $(ROOTDIR)/FreeRTOS/config.mk +include $(ROOTDIR)/hardware/config.mk +include $(ROOTDIR)/arch/config.mk +include $(ROOTDIR)/os/config.mk +include $(ROOTDIR)/libc/config.mk +include $(ROOTDIR)/libm/config.mk +include $(ROOTDIR)/chips/config.mk +include $(ROOTDIR)/acorn/config.mk +include $(ROOTDIR)/target-rules.mk + diff --git a/lcdexample.c b/lcdexample.c new file mode 100644 index 0000000..09187f0 --- /dev/null +++ b/lcdexample.c @@ -0,0 +1,250 @@ +/* +st-util: +openocd -f board/stm32f4discovery.cfg + +arm-none-eabi-gdbtui -ex "target extended-remote :3333" lcdexample.elf +monitor reset halt +load +continue +*/ + + + +#include +#include +#include +#include +#include +#include +#include + +#include +//#include +#include +#include + +#include +#include +#include + +//Accelerometer +#include +//#include + +pin_t led[2]; +l3gd20_t gyro; +float gyrovalues[3]; +float angles[2]; + +float xvalues[240], yvalues[240]; +uint8_t currentvalue; + +float rx = 0, ry = 0; + +void initLed() +{ + led[0] = make_pin(GPIO_PORT_G, 13); + led[1] = make_pin(GPIO_PORT_G, 14); + gpio_config(led[0], pin_dir_write, pull_down); + gpio_config(led[1], pin_dir_write, pull_down); +} + +void initLCD() +{ + 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 initGyro() +{ + pin_t sclk = make_pin(GPIO_PORT_F, 7); + pin_t mosi = make_pin(GPIO_PORT_F, 9); + pin_t miso = make_pin(GPIO_PORT_F, 8); + pin_t cs = make_pin(GPIO_PORT_C, 1); + ssp_port_t gyroport = { .ssp = ssp_port_5, .sclk = sclk, .mosi = mosi, .miso = miso }; + + if (!l3gd20_init_ssp(&gyro, gyroport, cs)) + printf("Cannot initialize gyroscope"); +} + +void setLed(int n) +{ + gpio_set(led[n], 1); +} + +void resetLed(int n) +{ + gpio_set(led[n], 0); +} + + +void gyroTask() +{ + while(1) + { + setLed(1); + + l3gd20_read(&gyro, gyrovalues); + angles[0] = (gyrovalues[0] - xvalues[currentvalue])/0.01; + angles[1] = (gyrovalues[1] - yvalues[currentvalue])/0.01; + xvalues[currentvalue] = gyrovalues[0]; + yvalues[currentvalue] = gyrovalues[1]; + currentvalue = (currentvalue + 1) % 240; + + vTaskDelay(10); + + resetLed(1); + } +} + +void drawValues(uint16_t xpos, uint16_t ypos) +{ + uint8_t i; + LCD_SetTextColor(ASSEMBLE_RGB(0xff, 0xff, 0x00)); + for (i = 0 ; i < 240 ; i++) + LCD_DrawRect(i, xpos - (xvalues[i])/2000, 1, 1); + LCD_SetTextColor(ASSEMBLE_RGB(0x00, 0xff, 0xff)); + for (i = 0 ; i < 240 ; i++) + LCD_DrawRect(i, ypos - (yvalues[i])/2000, 1, 1); +} + +void drawSquare(uint8_t x, uint8_t y) +{ + uint8_t size = 20; + LCD_SetTextColor(ASSEMBLE_RGB(0xff, 0x00, 0x00)); + LCD_DrawFullRect(x - size, y - size, size, size); + LCD_SetTextColor(ASSEMBLE_RGB(0xff, 0xff, 0x00)); + LCD_DrawFullRect(x, y - size, size, size); + LCD_SetTextColor(ASSEMBLE_RGB(0x00, 0x00, 0xff)); + LCD_DrawFullRect(x - size, y, size, size); + LCD_SetTextColor(ASSEMBLE_RGB(0x00, 0xff, 0x00)); + LCD_DrawFullRect(x, y, size, size); +} + +void drawRainbow() +{ + uint16_t i = 0; + //rouge => jaune + for (i = 0 ; i < 40 ; i++) + { + LCD_SetTextColor(ASSEMBLE_RGB(0xff, i * 0xff / 40, 0x00)); + LCD_DrawFullRect(i, 0, 1, 10); + } + //jaune => vert + for (i = 0 ; i < 40 ; i++) + { + LCD_SetTextColor(ASSEMBLE_RGB(0xff - i * 0xff / 40, 0xff, 0x00)); + LCD_DrawFullRect(i + 40, 0, 1, 10); + } + //vert => cyan + for (i = 0 ; i < 40 ; i++) + { + LCD_SetTextColor(ASSEMBLE_RGB(0x00, 0xff, i * 0xff / 40)); + LCD_DrawFullRect(i + 80, 0, 1, 10); + } + //cyan => bleu + for (i = 0 ; i < 40 ; i++) + { + LCD_SetTextColor(ASSEMBLE_RGB(0x00, 0xff - i * 0xff / 40, 0xff)); + LCD_DrawFullRect(i + 120, 0, 1, 10); + } + //bleu => violet + for (i = 0 ; i < 40 ; i++) + { + LCD_SetTextColor(ASSEMBLE_RGB(i * 0xff / 40, 0x00, 0xff)); + LCD_DrawFullRect(i + 160, 0, 1, 10); + } + //violet => rouge + for (i = 0 ; i < 40 ; i++) + { + LCD_SetTextColor(ASSEMBLE_RGB(0xff, 0x00, 0xff - i * 0xff / 40)); + LCD_DrawFullRect(i + 200, 0, 1, 10); + } +} + +void drawGradient() +{ + uint16_t i = 0; + + for (i = 0 ; i < 0x100 ; i++) + { + LCD_SetTextColor(ASSEMBLE_RGB(i, i, i)); + LCD_DrawFullRect(0, 320 - 0xff + i - 1, 240, 1); + } +} + +void drawing() +{ + drawRainbow(); + + + LCD_SetTextColor(ASSEMBLE_RGB(0x00, 0x00, 0x00)); + LCD_DrawFullRect(00, 10, 240, 64); + + drawGradient(); + + LCD_SetBackColor(ASSEMBLE_RGB(0x00, 0x00, 0x00)); + LCD_SetTextColor(ASSEMBLE_RGB(0x33, 0xff, 0x33)); + + char buffer[32]; + sprintf(buffer, "rx=%f", gyrovalues[0]); + LCD_DisplayStringLine(24, (uint8_t *)buffer); + sprintf(buffer, "ry=%.2f", gyrovalues[1]); + LCD_DisplayStringLine(36, (uint8_t *)buffer); + + drawValues(200, 200); + + uint32_t posx = rx * 50 / 600; + uint32_t posy = ry * 50 / 600; + drawSquare(120 + posx, 160 + posy); +} + +void drawTask() +{ + while(1) + { + setLed(0); + drawing(); +// resetLed(1); +// vTaskDelay(500); + resetLed(0); +// setLed(1); + vTaskDelay(100); + } +} + +int main() +{ + init_malloc_wrapper(); + + //monitor arm semihosting enable + //register_semiio(); + //register_semifs(); + + printf("Init led\n"); + initLed(); + + printf("Init lcd\n"); + initLCD(); + + printf("Init gyro\n"); + initGyro(); + + + printf("Start task\n"); + xTaskCreate(drawTask, (const signed char *)NULL, configMINIMAL_STACK_SIZE, (void *)NULL, tskIDLE_PRIORITY, NULL); + xTaskCreate(gyroTask, (const signed char *)NULL, configMINIMAL_STACK_SIZE, (void *)NULL, tskIDLE_PRIORITY, NULL); + + //start task scheduler + vTaskStartScheduler(); + + return 0; +} diff --git a/lib/Makefile b/lib/Makefile new file mode 100644 index 0000000..332afd4 --- /dev/null +++ b/lib/Makefile @@ -0,0 +1,19 @@ +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 += i2c.c +TARGET_SRCS += fonts +TARGET_SRCS += stm32f429i_discovery.c +TARGET_SRCS += stm32f429i_discovery_lcd.c +TARGET_SRCS += stm32f429i_discovery_sdram.c +#TARGET_SRCS += stm32f4xx_discovery_lis302dl.c + +include $(ROOTDIR)/target-rules.mk + +clean: clean-generic diff --git a/lib/config.mk b/lib/config.mk new file mode 100644 index 0000000..10ef728 --- /dev/null +++ b/lib/config.mk @@ -0,0 +1,5 @@ +TARGET_INCLUDES += $(MAINDIR)/lib + +ifeq ($(USE_MPU),true) +TARGET_CPPFLAGS += -DportUSING_MPU_WRAPPERS=1 +endif diff --git a/lib/fonts.c b/lib/fonts.c new file mode 100755 index 0000000..66b6e4d --- /dev/null +++ b/lib/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/lib/fonts.h b/lib/fonts.h new file mode 100755 index 0000000..6d9f7d2 --- /dev/null +++ b/lib/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/lib/stm32f429i_discovery.c b/lib/stm32f429i_discovery.c new file mode 100755 index 0000000..5429bbd --- /dev/null +++ b/lib/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/lib/stm32f429i_discovery.h b/lib/stm32f429i_discovery.h new file mode 100755 index 0000000..07de671 --- /dev/null +++ b/lib/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/lib/stm32f429i_discovery_l3gd20.c b/lib/stm32f429i_discovery_l3gd20.c new file mode 100755 index 0000000..ac6cd9e --- /dev/null +++ b/lib/stm32f429i_discovery_l3gd20.c @@ -0,0 +1,499 @@ +/** + ****************************************************************************** + * @file stm32f429i_discovery_l3gd20.c + * @author MCD Application Team + * @version V1.0.1 + * @date 28-October-2013 + * @brief This file provides a set of functions needed to manage the l3gd20 + * MEMS three-axis digital output gyroscope available 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_l3gd20.h" +/** @addtogroup Utilities + * @{ + */ + +/** @addtogroup STM32F4_DISCOVERY + * @{ + */ + +/** @addtogroup STM32429I_DISCO + * @{ + */ + +/** @addtogroup STM32F429I_DISCOVERY_L3GD20 + * @{ + */ + + +/** @defgroup STM32F429I_DISCOVERY_L3GD20_Private_TypesDefinitions + * @{ + */ + +/** + * @} + */ + +/** @defgroup STM32F429I_DISCOVERY_L3GD20_Private_Defines + * @{ + */ + +/** + * @} + */ + +/** @defgroup STM32F429I_DISCOVERY_L3GD20_Private_Macros + * @{ + */ + +/** + * @} + */ + +/** @defgroup STM32F429I_DISCOVERY_L3GD20_Private_Variables + * @{ + */ +__IO uint32_t L3GD20Timeout = L3GD20_FLAG_TIMEOUT; +/** + * @} + */ + +/** @defgroup STM32F429I_DISCOVERY_L3GD20_Private_FunctionPrototypes + * @{ + */ +static uint8_t L3GD20_SendByte(uint8_t byte); +static void L3GD20_LowLevel_Init(void); +/** + * @} + */ + +/** @defgroup STM32F429I_DISCOVERY_L3GD20_Private_Functions + * @{ + */ + +/** + * @brief Set L3GD20 Initialization. + * @param L3GD20_InitStruct: pointer to a L3GD20_InitTypeDef structure + * that contains the configuration setting for the L3GD20. + * @retval None + */ +void L3GD20_Init(L3GD20_InitTypeDef *L3GD20_InitStruct) +{ + uint8_t ctrl1 = 0x00, ctrl4 = 0x00; + + /* Configure the low level interface ---------------------------------------*/ + L3GD20_LowLevel_Init(); + + /* Configure MEMS: data rate, power mode, full scale and axes */ + ctrl1 |= (uint8_t) (L3GD20_InitStruct->Power_Mode | L3GD20_InitStruct->Output_DataRate | \ + L3GD20_InitStruct->Axes_Enable | L3GD20_InitStruct->Band_Width); + + ctrl4 |= (uint8_t) (L3GD20_InitStruct->BlockData_Update | L3GD20_InitStruct->Endianness | \ + L3GD20_InitStruct->Full_Scale); + + /* Write value to MEMS CTRL_REG1 regsister */ + L3GD20_Write(&ctrl1, L3GD20_CTRL_REG1_ADDR, 1); + + /* Write value to MEMS CTRL_REG4 regsister */ + L3GD20_Write(&ctrl4, L3GD20_CTRL_REG4_ADDR, 1); +} + +/** + * @brief Reboot memory content of L3GD20 + * @param None + * @retval None + */ +void L3GD20_RebootCmd(void) +{ + uint8_t tmpreg; + + /* Read CTRL_REG5 register */ + L3GD20_Read(&tmpreg, L3GD20_CTRL_REG5_ADDR, 1); + + /* Enable the reboot memory */ + tmpreg |= L3GD20_BOOT_REBOOTMEMORY; + + /* Write value to MEMS CTRL_REG5 regsister */ + L3GD20_Write(&tmpreg, L3GD20_CTRL_REG5_ADDR, 1); +} + +/** + * @brief Set L3GD20 Interrupt configuration + * @param L3GD20_InterruptConfig_TypeDef: pointer to a L3GD20_InterruptConfig_TypeDef + * structure that contains the configuration setting for the L3GD20 Interrupt. + * @retval None + */ +void L3GD20_INT1InterruptConfig(L3GD20_InterruptConfigTypeDef *L3GD20_IntConfigStruct) +{ + uint8_t ctrl_cfr = 0x00, ctrl3 = 0x00; + + /* Read INT1_CFG register */ + L3GD20_Read(&ctrl_cfr, L3GD20_INT1_CFG_ADDR, 1); + + /* Read CTRL_REG3 register */ + L3GD20_Read(&ctrl3, L3GD20_CTRL_REG3_ADDR, 1); + + ctrl_cfr &= 0x80; + + ctrl3 &= 0xDF; + + /* Configure latch Interrupt request and axe interrupts */ + ctrl_cfr |= (uint8_t)(L3GD20_IntConfigStruct->Latch_Request| \ + L3GD20_IntConfigStruct->Interrupt_Axes); + + ctrl3 |= (uint8_t)(L3GD20_IntConfigStruct->Interrupt_ActiveEdge); + + /* Write value to MEMS INT1_CFG register */ + L3GD20_Write(&ctrl_cfr, L3GD20_INT1_CFG_ADDR, 1); + + /* Write value to MEMS CTRL_REG3 register */ + L3GD20_Write(&ctrl3, L3GD20_CTRL_REG3_ADDR, 1); +} + +/** + * @brief Enable or disable INT1 interrupt + * @param InterruptState: State of INT1 Interrupt + * This parameter can be: + * @arg L3GD20_INT1INTERRUPT_DISABLE + * @arg L3GD20_INT1INTERRUPT_ENABLE + * @retval None + */ +void L3GD20_INT1InterruptCmd(uint8_t InterruptState) +{ + uint8_t tmpreg; + + /* Read CTRL_REG3 register */ + L3GD20_Read(&tmpreg, L3GD20_CTRL_REG3_ADDR, 1); + + tmpreg &= 0x7F; + tmpreg |= InterruptState; + + /* Write value to MEMS CTRL_REG3 regsister */ + L3GD20_Write(&tmpreg, L3GD20_CTRL_REG3_ADDR, 1); +} + +/** + * @brief Enable or disable INT2 interrupt + * @param InterruptState: State of INT1 Interrupt + * This parameter can be: + * @arg L3GD20_INT2INTERRUPT_DISABLE + * @arg L3GD20_INT2INTERRUPT_ENABLE + * @retval None + */ +void L3GD20_INT2InterruptCmd(uint8_t InterruptState) +{ + uint8_t tmpreg; + + /* Read CTRL_REG3 register */ + L3GD20_Read(&tmpreg, L3GD20_CTRL_REG3_ADDR, 1); + + tmpreg &= 0xF7; + tmpreg |= InterruptState; + + /* Write value to MEMS CTRL_REG3 regsister */ + L3GD20_Write(&tmpreg, L3GD20_CTRL_REG3_ADDR, 1); +} + +/** + * @brief Set High Pass Filter Modality + * @param L3GD20_FilterStruct: pointer to a L3GD20_FilterConfigTypeDef structure + * that contains the configuration setting for the L3GD20. + * @retval None + */ +void L3GD20_FilterConfig(L3GD20_FilterConfigTypeDef *L3GD20_FilterStruct) +{ + uint8_t tmpreg; + + /* Read CTRL_REG2 register */ + L3GD20_Read(&tmpreg, L3GD20_CTRL_REG2_ADDR, 1); + + tmpreg &= 0xC0; + + /* Configure MEMS: mode and cutoff frquency */ + tmpreg |= (uint8_t) (L3GD20_FilterStruct->HighPassFilter_Mode_Selection |\ + L3GD20_FilterStruct->HighPassFilter_CutOff_Frequency); + + /* Write value to MEMS CTRL_REG2 regsister */ + L3GD20_Write(&tmpreg, L3GD20_CTRL_REG2_ADDR, 1); +} + +/** + * @brief Enable or Disable High Pass Filter + * @param HighPassFilterState: new state of the High Pass Filter feature. + * This parameter can be: + * @arg: L3GD20_HIGHPASSFILTER_DISABLE + * @arg: L3GD20_HIGHPASSFILTER_ENABLE + * @retval None + */ +void L3GD20_FilterCmd(uint8_t HighPassFilterState) + { + uint8_t tmpreg; + + /* Read CTRL_REG5 register */ + L3GD20_Read(&tmpreg, L3GD20_CTRL_REG5_ADDR, 1); + + tmpreg &= 0xEF; + + tmpreg |= HighPassFilterState; + + /* Write value to MEMS CTRL_REG5 regsister */ + L3GD20_Write(&tmpreg, L3GD20_CTRL_REG5_ADDR, 1); +} + +/** + * @brief Get status for L3GD20 data + * @param None + * @retval L3GD20 status + */ +uint8_t L3GD20_GetDataStatus(void) +{ + uint8_t tmpreg; + + /* Read STATUS_REG register */ + L3GD20_Read(&tmpreg, L3GD20_STATUS_REG_ADDR, 1); + + return tmpreg; +} + +/** + * @brief Writes a block of data to the L3GD20. + * @param pBuffer : pointer to the buffer containing the data to be written to the L3GD20. + * @param WriteAddr : L3GD20's internal address to write to. + * @param NumByteToWrite: Number of bytes to write. + * @retval None + */ +void L3GD20_Write(uint8_t* pBuffer, uint8_t WriteAddr, uint16_t NumByteToWrite) +{ + /* Configure the MS bit: + - When 0, the address will remain unchanged in multiple read/write commands. + - When 1, the address will be auto incremented in multiple read/write commands. + */ + if(NumByteToWrite > 0x01) + { + WriteAddr |= (uint8_t)MULTIPLEBYTE_CMD; + } + /* Set chip select Low at the start of the transmission */ + L3GD20_CS_LOW(); + + /* Send the Address of the indexed register */ + L3GD20_SendByte(WriteAddr); + + /* Send the data that will be written into the device (MSB First) */ + while(NumByteToWrite >= 0x01) + { + L3GD20_SendByte(*pBuffer); + NumByteToWrite--; + pBuffer++; + } + + /* Set chip select High at the end of the transmission */ + L3GD20_CS_HIGH(); +} + +/** + * @brief Reads a block of data from the L3GD20. + * @param pBuffer : pointer to the buffer that receives the data read from the L3GD20. + * @param ReadAddr : L3GD20's internal address to read from. + * @param NumByteToRead : number of bytes to read from the L3GD20. + * @retval None + */ +void L3GD20_Read(uint8_t* pBuffer, uint8_t ReadAddr, uint16_t NumByteToRead) +{ + if(NumByteToRead > 0x01) + { + ReadAddr |= (uint8_t)(READWRITE_CMD | MULTIPLEBYTE_CMD); + } + else + { + ReadAddr |= (uint8_t)READWRITE_CMD; + } + /* Set chip select Low at the start of the transmission */ + L3GD20_CS_LOW(); + + /* Send the Address of the indexed register */ + L3GD20_SendByte(ReadAddr); + + /* Receive the data that will be read from the device (MSB First) */ + while(NumByteToRead > 0x00) + { + /* Send dummy byte (0x00) to generate the SPI clock to L3GD20 (Slave device) */ + *pBuffer = L3GD20_SendByte(DUMMY_BYTE); + NumByteToRead--; + pBuffer++; + } + + /* Set chip select High at the end of the transmission */ + L3GD20_CS_HIGH(); +} + +/** + * @brief Initializes the low level interface used to drive the L3GD20 + * @param None + * @retval None + */ +static void L3GD20_LowLevel_Init(void) +{ + GPIO_InitTypeDef GPIO_InitStructure; + SPI_InitTypeDef SPI_InitStructure; + + /* Enable the SPI periph */ + RCC_APB2PeriphClockCmd(L3GD20_SPI_CLK, ENABLE); + + /* Enable SCK, MOSI and MISO GPIO clocks */ + RCC_AHB1PeriphClockCmd(L3GD20_SPI_SCK_GPIO_CLK | L3GD20_SPI_MISO_GPIO_CLK | L3GD20_SPI_MOSI_GPIO_CLK, ENABLE); + + /* Enable CS GPIO clock */ + RCC_AHB1PeriphClockCmd(L3GD20_SPI_CS_GPIO_CLK, ENABLE); + + /* Enable INT1 GPIO clock */ + RCC_AHB1PeriphClockCmd(L3GD20_SPI_INT1_GPIO_CLK, ENABLE); + + /* Enable INT2 GPIO clock */ + RCC_AHB1PeriphClockCmd(L3GD20_SPI_INT2_GPIO_CLK, ENABLE); + + GPIO_PinAFConfig(L3GD20_SPI_SCK_GPIO_PORT, L3GD20_SPI_SCK_SOURCE, L3GD20_SPI_SCK_AF); + GPIO_PinAFConfig(L3GD20_SPI_MISO_GPIO_PORT, L3GD20_SPI_MISO_SOURCE, L3GD20_SPI_MISO_AF); + GPIO_PinAFConfig(L3GD20_SPI_MOSI_GPIO_PORT, L3GD20_SPI_MOSI_SOURCE, L3GD20_SPI_MOSI_AF); + + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; + GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; + GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_25MHz; + + /* SPI SCK pin configuration */ + GPIO_InitStructure.GPIO_Pin = L3GD20_SPI_SCK_PIN; + GPIO_Init(L3GD20_SPI_SCK_GPIO_PORT, &GPIO_InitStructure); + + /* SPI MOSI pin configuration */ + GPIO_InitStructure.GPIO_Pin = L3GD20_SPI_MOSI_PIN; + GPIO_Init(L3GD20_SPI_MOSI_GPIO_PORT, &GPIO_InitStructure); + + /* SPI MISO pin configuration */ + GPIO_InitStructure.GPIO_Pin = L3GD20_SPI_MISO_PIN; + GPIO_Init(L3GD20_SPI_MISO_GPIO_PORT, &GPIO_InitStructure); + + /* SPI configuration -------------------------------------------------------*/ + SPI_I2S_DeInit(L3GD20_SPI); + 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(L3GD20_SPI, &SPI_InitStructure); + + /* Enable L3GD20_SPI */ + SPI_Cmd(L3GD20_SPI, ENABLE); + + /* Configure GPIO PIN for Lis Chip select */ + GPIO_InitStructure.GPIO_Pin = L3GD20_SPI_CS_PIN; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; + GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_25MHz; + GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; + GPIO_Init(L3GD20_SPI_CS_GPIO_PORT, &GPIO_InitStructure); + + /* Deselect : Chip Select high */ + GPIO_SetBits(L3GD20_SPI_CS_GPIO_PORT, L3GD20_SPI_CS_PIN); + + /* Configure GPIO PINs to detect Interrupts */ + GPIO_InitStructure.GPIO_Pin = L3GD20_SPI_INT1_PIN; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN; + GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; + GPIO_Init(L3GD20_SPI_INT1_GPIO_PORT, &GPIO_InitStructure); + + GPIO_InitStructure.GPIO_Pin = L3GD20_SPI_INT2_PIN; + GPIO_Init(L3GD20_SPI_INT2_GPIO_PORT, &GPIO_InitStructure); +} + +/** + * @brief Sends a Byte through the SPI interface and return the Byte received + * from the SPI bus. + * @param Byte : Byte send. + * @retval The received byte value + */ +static uint8_t L3GD20_SendByte(uint8_t byte) +{ + /* Loop while DR register in not empty */ + L3GD20Timeout = L3GD20_FLAG_TIMEOUT; + while (SPI_I2S_GetFlagStatus(L3GD20_SPI, SPI_I2S_FLAG_TXE) == RESET) + { + if((L3GD20Timeout--) == 0) return L3GD20_TIMEOUT_UserCallback(); + } + + /* Send a Byte through the SPI peripheral */ + SPI_I2S_SendData(L3GD20_SPI, (uint16_t)byte); + /* Wait to receive a Byte */ + L3GD20Timeout = L3GD20_FLAG_TIMEOUT; + while (SPI_I2S_GetFlagStatus(L3GD20_SPI, SPI_I2S_FLAG_RXNE) == RESET) + { + if((L3GD20Timeout--) == 0) return L3GD20_TIMEOUT_UserCallback(); + } + + /* Return the Byte read from the SPI bus */ + return (uint8_t)SPI_I2S_ReceiveData(L3GD20_SPI); +} + +#ifdef USE_DEFAULT_TIMEOUT_CALLBACK +/** + * @brief Basic management of the timeout situation. + * @param None. + * @retval None. + */ +uint32_t L3GD20_TIMEOUT_UserCallback(void) +{ + /* Block communication and all processes */ + while (1) + { + } +} +#endif /* USE_DEFAULT_TIMEOUT_CALLBACK */ + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + + /** + * @} + */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/lib/stm32f429i_discovery_l3gd20.h b/lib/stm32f429i_discovery_l3gd20.h new file mode 100755 index 0000000..bbcaccb --- /dev/null +++ b/lib/stm32f429i_discovery_l3gd20.h @@ -0,0 +1,414 @@ +/** + ****************************************************************************** + * @file stm32f429i_discovery_l3gd20.h + * @author MCD Application Team + * @version V1.0.1 + * @date 28-October-2013 + * @brief This file contains definitions for stm32f429i_discovery_l3gd20.c + * firmware 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_L3GD20_H +#define __STM32F429I_DISCOVERY_L3GD20_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "stm32f4xx.h" +#include "stm32f4xx_spi.h" +#include "stm32f4xx_rcc.h" + +/** @addtogroup Utilities + * @{ + */ + +/** @addtogroup STM32F4_DISCOVERY + * @{ + */ + +/** @addtogroup STM32F429I_DISCOVERY + * @{ + */ + +/** @addtogroup STM32F429I_DISCOVERY_L3GD20 + * @{ + */ + +/** @defgroup STM32F429I_DISCOVERY_L3GD20_Exported_Types + * @{ + */ + +/* L3GD20 struct */ +typedef struct +{ + uint8_t Power_Mode; /* Power-down/Sleep/Normal Mode */ + uint8_t Output_DataRate; /* OUT data rate */ + uint8_t Axes_Enable; /* Axes enable */ + uint8_t Band_Width; /* Bandwidth selection */ + uint8_t BlockData_Update; /* Block Data Update */ + uint8_t Endianness; /* Endian Data selection */ + uint8_t Full_Scale; /* Full Scale selection */ +}L3GD20_InitTypeDef; + +/* L3GD20 High Pass Filter struct */ +typedef struct +{ + uint8_t HighPassFilter_Mode_Selection; /* Internal filter mode */ + uint8_t HighPassFilter_CutOff_Frequency; /* High pass filter cut-off frequency */ +}L3GD20_FilterConfigTypeDef; + +/* L3GD20 Interrupt struct */ +typedef struct +{ + uint8_t Latch_Request; /* Latch interrupt request into CLICK_SRC register */ + uint8_t Interrupt_Axes; /* X, Y, Z Axes Interrupts */ + uint8_t Interrupt_ActiveEdge; /* Interrupt Active edge */ +}L3GD20_InterruptConfigTypeDef; + +/** + * @} + */ + + +/** + * @} + */ + +/** @defgroup STM32F429I-DISCO_L3GD20_Exported_Constants + * @{ + */ + +/* Read/Write command */ +#define READWRITE_CMD ((uint8_t)0x80) +/* Multiple byte read/write command */ +#define MULTIPLEBYTE_CMD ((uint8_t)0x40) +/* Dummy Byte Send by the SPI Master device in order to generate the Clock to the Slave device */ +#define DUMMY_BYTE ((uint8_t)0x00) + +/* Uncomment the following line to use the default L3GD20_TIMEOUT_UserCallback() + function implemented in stm32f429i_discovery_lgd20.c file. + L3GD20_TIMEOUT_UserCallback() function is called whenever a timeout condition + occure during communication (waiting transmit data register empty flag(TXE) + or waiting receive data register is not empty flag (RXNE)). */ +/* #define USE_DEFAULT_TIMEOUT_CALLBACK */ + +/* Maximum Timeout values for flags waiting loops. These timeouts are not based + on accurate values, they just guarantee that the application will not remain + stuck if the SPI communication is corrupted. + You may modify these timeout values depending on CPU frequency and application + conditions (interrupts routines ...). */ +#define L3GD20_FLAG_TIMEOUT ((uint32_t)0x1000) + +/** + * @brief L3GD20 SPI Interface pins + */ +#define L3GD20_SPI SPI5 +#define L3GD20_SPI_CLK RCC_APB2Periph_SPI5 + +#define L3GD20_SPI_SCK_PIN GPIO_Pin_7 /* PF.07 */ +#define L3GD20_SPI_SCK_GPIO_PORT GPIOF /* GPIOF */ +#define L3GD20_SPI_SCK_GPIO_CLK RCC_AHB1Periph_GPIOF +#define L3GD20_SPI_SCK_SOURCE GPIO_PinSource7 +#define L3GD20_SPI_SCK_AF GPIO_AF_SPI5 + +#define L3GD20_SPI_MISO_PIN GPIO_Pin_8 /* PF.08 */ +#define L3GD20_SPI_MISO_GPIO_PORT GPIOF /* GPIOF */ +#define L3GD20_SPI_MISO_GPIO_CLK RCC_AHB1Periph_GPIOF +#define L3GD20_SPI_MISO_SOURCE GPIO_PinSource8 +#define L3GD20_SPI_MISO_AF GPIO_AF_SPI5 + +#define L3GD20_SPI_MOSI_PIN GPIO_Pin_9 /* PF.09 */ +#define L3GD20_SPI_MOSI_GPIO_PORT GPIOF /* GPIOF */ +#define L3GD20_SPI_MOSI_GPIO_CLK RCC_AHB1Periph_GPIOF +#define L3GD20_SPI_MOSI_SOURCE GPIO_PinSource9 +#define L3GD20_SPI_MOSI_AF GPIO_AF_SPI5 + +#define L3GD20_SPI_CS_PIN GPIO_Pin_1 /* PC.01 */ +#define L3GD20_SPI_CS_GPIO_PORT GPIOC /* GPIOC */ +#define L3GD20_SPI_CS_GPIO_CLK RCC_AHB1Periph_GPIOC + +#define L3GD20_SPI_INT1_PIN GPIO_Pin_1 /* PA.01 */ +#define L3GD20_SPI_INT1_GPIO_PORT GPIOA /* GPIOA */ +#define L3GD20_SPI_INT1_GPIO_CLK RCC_AHB1Periph_GPIOA +#define L3GD20_SPI_INT1_EXTI_LINE EXTI_Line1 +#define L3GD20_SPI_INT1_EXTI_PORT_SOURCE EXTI_PortSourceGPIOA +#define L3GD20_SPI_INT1_EXTI_PIN_SOURCE EXTI_PinSource1 +#define L3GD20_SPI_INT1_EXTI_IRQn EXTI1_IRQn + +#define L3GD20_SPI_INT2_PIN GPIO_Pin_2 /* PA.02 */ +#define L3GD20_SPI_INT2_GPIO_PORT GPIOA /* GPIOA */ +#define L3GD20_SPI_INT2_GPIO_CLK RCC_AHB1Periph_GPIOA +#define L3GD20_SPI_INT2_EXTI_LINE EXTI_Line2 +#define L3GD20_SPI_INT2_EXTI_PORT_SOURCE EXTI_PortSourceGPIOA +#define L3GD20_SPI_INT2_EXTI_PIN_SOURCE EXTI_PinSource2 +#define L3GD20_SPI_INT2_EXTI_IRQn EXTI2_IRQn + +/******************************************************************************/ +/*************************** START REGISTER MAPPING **************************/ +/******************************************************************************/ +#define L3GD20_WHO_AM_I_ADDR 0x0F /* device identification register */ +#define L3GD20_CTRL_REG1_ADDR 0x20 /* Control register 1 */ +#define L3GD20_CTRL_REG2_ADDR 0x21 /* Control register 2 */ +#define L3GD20_CTRL_REG3_ADDR 0x22 /* Control register 3 */ +#define L3GD20_CTRL_REG4_ADDR 0x23 /* Control register 4 */ +#define L3GD20_CTRL_REG5_ADDR 0x24 /* Control register 5 */ +#define L3GD20_REFERENCE_REG_ADDR 0x25 /* Reference register */ +#define L3GD20_OUT_TEMP_ADDR 0x26 /* Out temp register */ +#define L3GD20_STATUS_REG_ADDR 0x27 /* Status register */ +#define L3GD20_OUT_X_L_ADDR 0x28 /* Output Register X */ +#define L3GD20_OUT_X_H_ADDR 0x29 /* Output Register X */ +#define L3GD20_OUT_Y_L_ADDR 0x2A /* Output Register Y */ +#define L3GD20_OUT_Y_H_ADDR 0x2B /* Output Register Y */ +#define L3GD20_OUT_Z_L_ADDR 0x2C /* Output Register Z */ +#define L3GD20_OUT_Z_H_ADDR 0x2D /* Output Register Z */ +#define L3GD20_FIFO_CTRL_REG_ADDR 0x2E /* Fifo control Register */ +#define L3GD20_FIFO_SRC_REG_ADDR 0x2F /* Fifo src Register */ + +#define L3GD20_INT1_CFG_ADDR 0x30 /* Interrupt 1 configuration Register */ +#define L3GD20_INT1_SRC_ADDR 0x31 /* Interrupt 1 source Register */ +#define L3GD20_INT1_TSH_XH_ADDR 0x32 /* Interrupt 1 Threshold X register */ +#define L3GD20_INT1_TSH_XL_ADDR 0x33 /* Interrupt 1 Threshold X register */ +#define L3GD20_INT1_TSH_YH_ADDR 0x34 /* Interrupt 1 Threshold Y register */ +#define L3GD20_INT1_TSH_YL_ADDR 0x35 /* Interrupt 1 Threshold Y register */ +#define L3GD20_INT1_TSH_ZH_ADDR 0x36 /* Interrupt 1 Threshold Z register */ +#define L3GD20_INT1_TSH_ZL_ADDR 0x37 /* Interrupt 1 Threshold Z register */ +#define L3GD20_INT1_DURATION_ADDR 0x38 /* Interrupt 1 DURATION register */ + +/******************************************************************************/ +/**************************** END REGISTER MAPPING ***************************/ +/******************************************************************************/ + +#define I_AM_L3GD20 ((uint8_t)0xD4) + +/** @defgroup Power_Mode_selection + * @{ + */ +#define L3GD20_MODE_POWERDOWN ((uint8_t)0x00) +#define L3GD20_MODE_ACTIVE ((uint8_t)0x08) +/** + * @} + */ + +/** @defgroup OutPut_DataRate_Selection + * @{ + */ +#define L3GD20_OUTPUT_DATARATE_1 ((uint8_t)0x00) +#define L3GD20_OUTPUT_DATARATE_2 ((uint8_t)0x40) +#define L3GD20_OUTPUT_DATARATE_3 ((uint8_t)0x80) +#define L3GD20_OUTPUT_DATARATE_4 ((uint8_t)0xC0) +/** + * @} + */ + +/** @defgroup Axes_Selection + * @{ + */ +#define L3GD20_X_ENABLE ((uint8_t)0x02) +#define L3GD20_Y_ENABLE ((uint8_t)0x01) +#define L3GD20_Z_ENABLE ((uint8_t)0x04) +#define L3GD20_AXES_ENABLE ((uint8_t)0x07) +#define L3GD20_AXES_DISABLE ((uint8_t)0x00) +/** + * @} + */ + +/** @defgroup BandWidth_Selection + * @{ + */ +#define L3GD20_BANDWIDTH_1 ((uint8_t)0x00) +#define L3GD20_BANDWIDTH_2 ((uint8_t)0x10) +#define L3GD20_BANDWIDTH_3 ((uint8_t)0x20) +#define L3GD20_BANDWIDTH_4 ((uint8_t)0x30) +/** + * @} + */ + +/** @defgroup Full_Scale_Selection + * @{ + */ +#define L3GD20_FULLSCALE_250 ((uint8_t)0x00) +#define L3GD20_FULLSCALE_500 ((uint8_t)0x10) +#define L3GD20_FULLSCALE_2000 ((uint8_t)0x20) +/** + * @} + */ + +/** @defgroup Block_Data_Update + * @{ + */ +#define L3GD20_BlockDataUpdate_Continous ((uint8_t)0x00) +#define L3GD20_BlockDataUpdate_Single ((uint8_t)0x80) +/** + * @} + */ + +/** @defgroup Endian_Data_selection + * @{ + */ +#define L3GD20_BLE_LSB ((uint8_t)0x00) +#define L3GD20_BLE_MSB ((uint8_t)0x40) +/** + * @} + */ + +/** @defgroup High_Pass_Filter_status + * @{ + */ +#define L3GD20_HIGHPASSFILTER_DISABLE ((uint8_t)0x00) +#define L3GD20_HIGHPASSFILTER_ENABLE ((uint8_t)0x10) +/** + * @} + */ + +/** @defgroup INT1_Interrupt_status + * @{ + */ +#define L3GD20_INT1INTERRUPT_DISABLE ((uint8_t)0x00) +#define L3GD20_INT1INTERRUPT_ENABLE ((uint8_t)0x80) +/** + * @} + */ + +/** @defgroup INT2_Interrupt_status + * @{ + */ +#define L3GD20_INT2INTERRUPT_DISABLE ((uint8_t)0x00) +#define L3GD20_INT2INTERRUPT_ENABLE ((uint8_t)0x08) +/** + * @} + */ + +/** @defgroup INT1_Interrupt_ActiveEdge + * @{ + */ +#define L3GD20_INT1INTERRUPT_LOW_EDGE ((uint8_t)0x20) +#define L3GD20_INT1INTERRUPT_HIGH_EDGE ((uint8_t)0x00) +/** + * @} + */ + +/** @defgroup Boot_Mode_selection + * @{ + */ +#define L3GD20_BOOT_NORMALMODE ((uint8_t)0x00) +#define L3GD20_BOOT_REBOOTMEMORY ((uint8_t)0x80) +/** + * @} + */ + +/** @defgroup High_Pass_Filter_Mode + * @{ + */ +#define L3GD20_HPM_NORMAL_MODE_RES ((uint8_t)0x00) +#define L3GD20_HPM_REF_SIGNAL ((uint8_t)0x10) +#define L3GD20_HPM_NORMAL_MODE ((uint8_t)0x20) +#define L3GD20_HPM_AUTORESET_INT ((uint8_t)0x30) +/** + * @} + */ + +/** @defgroup High_Pass_CUT OFF_Frequency + * @{ + */ +#define L3GD20_HPFCF_0 0x00 +#define L3GD20_HPFCF_1 0x01 +#define L3GD20_HPFCF_2 0x02 +#define L3GD20_HPFCF_3 0x03 +#define L3GD20_HPFCF_4 0x04 +#define L3GD20_HPFCF_5 0x05 +#define L3GD20_HPFCF_6 0x06 +#define L3GD20_HPFCF_7 0x07 +#define L3GD20_HPFCF_8 0x08 +#define L3GD20_HPFCF_9 0x09 +/** + * @} + */ + + +/** @defgroup STM32F429I-DISCO_L3GD20_Exported_Macros + * @{ + */ +#define L3GD20_CS_LOW() GPIO_ResetBits(L3GD20_SPI_CS_GPIO_PORT, L3GD20_SPI_CS_PIN) +#define L3GD20_CS_HIGH() GPIO_SetBits(L3GD20_SPI_CS_GPIO_PORT, L3GD20_SPI_CS_PIN) +/** + * @} + */ + +/** @defgroup STM32F429I-DISCO_L3GD20_Exported_Functions + * @{ + */ +/* Sensor Configuration Functions */ +void L3GD20_Init(L3GD20_InitTypeDef *L3GD20_InitStruct); +void L3GD20_RebootCmd(void); + +/*INT1 Interrupt Configuration Functions */ +void L3GD20_INT1InterruptCmd(uint8_t InterruptState); +void L3GD20_INT2InterruptCmd(uint8_t InterruptState); +void L3GD20_INT1InterruptConfig(L3GD20_InterruptConfigTypeDef *L3GD20_IntConfigStruct); +uint8_t L3GD20_GetDataStatus(void); + +/* High Pass Filter Configuration Functions */ +void L3GD20_FilterConfig(L3GD20_FilterConfigTypeDef *L3GD20_FilterStruct); +void L3GD20_FilterCmd(uint8_t HighPassFilterState); +void L3GD20_Write(uint8_t* pBuffer, uint8_t WriteAddr, uint16_t NumByteToWrite); +void L3GD20_Read(uint8_t* pBuffer, uint8_t ReadAddr, uint16_t NumByteToRead); + +/* USER Callbacks: This is function for which prototype only is declared in + MEMS accelerometre driver and that should be implemented into user applicaiton. */ +/* L3GD20_TIMEOUT_UserCallback() function is called whenever a timeout condition + occure during communication (waiting transmit data register empty flag(TXE) + or waiting receive data register is not empty flag (RXNE)). + You can use the default timeout callback implementation by uncommenting the + define USE_DEFAULT_TIMEOUT_CALLBACK in stm32f429i_discovery_l3gd20.h file. + Typically the user implementation of this callback should reset MEMS peripheral + and re-initialize communication or in worst case reset all the application. */ +uint32_t L3GD20_TIMEOUT_UserCallback(void); + +#ifdef __cplusplus +} +#endif + +#endif /* __STM32F429I_DISCOVERY_L3GD20_H */ +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/lib/stm32f429i_discovery_lcd.c b/lib/stm32f429i_discovery_lcd.c new file mode 100755 index 0000000..e96a12e --- /dev/null +++ b/lib/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/lib/stm32f429i_discovery_lcd.h b/lib/stm32f429i_discovery_lcd.h new file mode 100755 index 0000000..2a2965b --- /dev/null +++ b/lib/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/lib/stm32f429i_discovery_sdram.c b/lib/stm32f429i_discovery_sdram.c new file mode 100755 index 0000000..443644f --- /dev/null +++ b/lib/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/lib/stm32f429i_discovery_sdram.h b/lib/stm32f429i_discovery_sdram.h new file mode 100755 index 0000000..0bf52f5 --- /dev/null +++ b/lib/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****/