Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

F4 lcd #336

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 78 additions & 0 deletions target/stm32f429i-disco/include/target/lcd.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#pragma once
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a short license header here?

/* LCD Size (Width and Height) */
#define LCD_SIZE_PIXEL_WIDTH ((uint16_t)240)
#define LCD_SIZE_PIXEL_HEIGHT ((uint16_t)320)

#define LCD_FRAME_BUFFER ((uint32_t)0xD0000000)
#define BUFFER_OFFSET ((uint32_t)0x50000)

#define LCD_BACKGROUND_LAYER 0x0000

/**
* @brief LCD Control pin
*/
#define LCD_NCS_PIN GPIO_Pin_2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should there be some #includes up at the top of this file to make sure these are already defined?

#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 */

4 changes: 4 additions & 0 deletions target/stm32f429i-disco/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,15 @@
#include <stm32f4xx_usart.h>
#include <stm32f4xx_rcc.h>
#include <stm32f4xx_gpio.h>
#include <stm32f4xx_ltdc.h>
#include <platform/stm32.h>
#include <platform/gpio.h>
#include <target.h>
#include <target/debugconfig.h>
#include <target/gpioconfig.h>

extern uint8_t STM_LCD_Init(void);

void target_early_init(void) {
#ifdef DEBUG_UART
#if DEBUG_UART == 1
Expand All @@ -38,6 +41,7 @@ void target_early_init(void) {
gpio_config(GPIO_LED1, GPIO_OUTPUT);
gpio_config(GPIO_LED2, GPIO_OUTPUT);
gpio_config(GPIO_LED3, GPIO_OUTPUT);
STM_LCD_Init();
}

void target_init(void) {
Expand Down
Loading