From 0b61f21e7b919e8996ef662e3dcd46389b6f69c6 Mon Sep 17 00:00:00 2001 From: id101010 Date: Mon, 27 Apr 2015 21:26:20 +0200 Subject: [PATCH] Fixed misplacement of prototypes in ll_tft.h and implemented a propper init function. --- common/lowlevel/ll_tft.h | 10 ---------- discovery/src/ll_system.c | 9 --------- discovery/src/ll_tft.c | 34 +++++++++++++++++++++++++++++++++- 3 files changed, 33 insertions(+), 20 deletions(-) diff --git a/common/lowlevel/ll_tft.h b/common/lowlevel/ll_tft.h index 14996cb..3353b83 100644 --- a/common/lowlevel/ll_tft.h +++ b/common/lowlevel/ll_tft.h @@ -3,16 +3,6 @@ // init functions bool ll_tft_init(); -bool ll_fsmc_init(); -bool ll_gpio_init(); - -// display control functions -void ll_tft_write_reg(uint8_t reg_adr, uint16_t reg_value); -uint16_t ll_tft_read_reg(uint8_t reg_adr); - -// fsmc functions - -// gpio functions // draw functions void ll_tft_clear(uint16_t color); diff --git a/discovery/src/ll_system.c b/discovery/src/ll_system.c index b666ff9..5858d64 100644 --- a/discovery/src/ll_system.c +++ b/discovery/src/ll_system.c @@ -8,14 +8,10 @@ #include "usbh_core.h" #include "usbh_msc_core.h" - - - USB_OTG_CORE_HANDLE USB_OTG_Core; USBH_HOST USB_Host; RCC_ClocksTypeDef RCC_Clocks; - void SysTick_Handler(void) { USBH_LL_systick(); @@ -26,13 +22,11 @@ void TIM2_IRQHandler(void) USB_OTG_BSP_TimerIRQ(); } - void OTG_FS_IRQHandler(void) { USBH_OTG_ISR_Handler(&USB_OTG_Core); } - bool ll_system_init(void) { /* Initialize LEDS */ @@ -59,13 +53,10 @@ void ll_system_process() { USBH_Process(&USB_OTG_Core, &USB_Host); } - - void ll_system_delay(uint32_t msec) { USB_OTG_BSP_mDelay(msec); } - void ll_system_toggle_led() { STM_EVAL_LEDToggle(LED6); } diff --git a/discovery/src/ll_tft.c b/discovery/src/ll_tft.c index f5fb128..e648d6e 100644 --- a/discovery/src/ll_tft.c +++ b/discovery/src/ll_tft.c @@ -22,9 +22,23 @@ #include "stm32f4xx_rcc.h" #include "stm32f4xx_fsmc.h" +/* + * ---------------------- prototypes -------------------------------------------------------------- + */ + +// init functions +bool ll_fsmc_init(); +bool ll_gpio_init(); +bool ll_display_init(); + +// display control functions +void ll_tft_write_reg(uint8_t reg_adr, uint16_t reg_value); +uint16_t ll_tft_read_reg(uint8_t reg_adr); + /* * ---------------------- defines and makros ------------------------------------------------------ */ + // Colors #define DISPLAY_COLOR_BLACK 0x0000 #define DISPLAY_COLOR_BLUE 0x001F @@ -70,7 +84,25 @@ * ---------------------- init functions ---------------------------------------------------------- */ -bool ll_tft_init() +bool ll_tft_init() +{ + bool gpio, fsmc, display; + + // init gpio + gpio = ll_gpio_init(); + // delay + system_delay(TFT_INIT_TIMEOUT); + // init fsmc + fsmc = ll_fsmc_init(); + // delay + system_delay(TFT_INIT_TIMEOUT); + // init display + display = ll_display_init(); + + return (gpio & fsmc & display); +} + +bool ll_display_init() { ll_tft_write_reg(0x0007,0x0021); system_delay(TFT_INIT_TIMEOUT);