mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-26 09:28:13 +00:00
better support ILI9341 testing, make tearing effect synch optional, minor fixes
This commit is contained in:
parent
2303acb7a9
commit
5c21c4a96b
14
Makefile
14
Makefile
@ -16,6 +16,14 @@ UNIX_PORT_OPTS ?= TREZOR_X86=1
|
|||||||
endif
|
endif
|
||||||
CROSS_PORT_OPTS ?= MICROPY_FORCE_32BIT=1
|
CROSS_PORT_OPTS ?= MICROPY_FORCE_32BIT=1
|
||||||
|
|
||||||
|
ifeq ($(DISPLAY_ILI9341V), 1)
|
||||||
|
CFLAGS += -DDISPLAY_ILI9341V=1
|
||||||
|
CFLAGS += -DDISPLAY_ST7789V=0
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(DISPLAY_VSYNC), 0)
|
||||||
|
CFLAGS += -DDISPLAY_VSYNC=0
|
||||||
|
endif
|
||||||
|
|
||||||
## help commands:
|
## help commands:
|
||||||
|
|
||||||
@ -57,13 +65,13 @@ style: ## run code style check on application sources
|
|||||||
build: build_boardloader build_bootloader build_firmware build_unix build_cross ## build all
|
build: build_boardloader build_bootloader build_firmware build_unix build_cross ## build all
|
||||||
|
|
||||||
build_boardloader: ## build boardloader
|
build_boardloader: ## build boardloader
|
||||||
$(SCONS) build/boardloader/boardloader.bin
|
$(SCONS) CFLAGS="$(CFLAGS)" build/boardloader/boardloader.bin
|
||||||
|
|
||||||
build_bootloader: ## build bootloader
|
build_bootloader: ## build bootloader
|
||||||
$(SCONS) build/bootloader/bootloader.bin
|
$(SCONS) CFLAGS="$(CFLAGS)" build/bootloader/bootloader.bin
|
||||||
|
|
||||||
build_firmware: res build_cross ## build firmware with frozen modules
|
build_firmware: res build_cross ## build firmware with frozen modules
|
||||||
$(SCONS) build/firmware/firmware.bin
|
$(SCONS) CFLAGS="$(CFLAGS)" build/firmware/firmware.bin
|
||||||
|
|
||||||
build_unix: ## build unix port
|
build_unix: ## build unix port
|
||||||
$(SCONS) build/unix/micropython $(UNIX_PORT_OPTS)
|
$(SCONS) build/unix/micropython $(UNIX_PORT_OPTS)
|
||||||
|
@ -84,7 +84,7 @@ SOURCE_TREZORHAL = [
|
|||||||
'embed/trezorhal/stm32_system.c',
|
'embed/trezorhal/stm32_system.c',
|
||||||
]
|
]
|
||||||
|
|
||||||
env = Environment(ENV=os.environ)
|
env = Environment(ENV=os.environ, CFLAGS=ARGUMENTS.get('CFLAGS', ''))
|
||||||
|
|
||||||
env.Replace(
|
env.Replace(
|
||||||
AS='arm-none-eabi-as',
|
AS='arm-none-eabi-as',
|
||||||
|
@ -102,7 +102,7 @@ SOURCE_TREZORHAL = [
|
|||||||
'embed/trezorhal/usbd_ioreq.c',
|
'embed/trezorhal/usbd_ioreq.c',
|
||||||
]
|
]
|
||||||
|
|
||||||
env = Environment(ENV=os.environ)
|
env = Environment(ENV=os.environ, CFLAGS=ARGUMENTS.get('CFLAGS', ''))
|
||||||
|
|
||||||
env.Replace(
|
env.Replace(
|
||||||
AS='arm-none-eabi-as',
|
AS='arm-none-eabi-as',
|
||||||
|
@ -299,7 +299,7 @@ SOURCE_PY.extend(Glob('src/*/*/*/*.py'))
|
|||||||
SOURCE_PY.extend(Glob('src/*/*/*/*/*.py'))
|
SOURCE_PY.extend(Glob('src/*/*/*/*/*.py'))
|
||||||
SOURCE_PY_DIR = 'src/'
|
SOURCE_PY_DIR = 'src/'
|
||||||
|
|
||||||
env = Environment(ENV=os.environ)
|
env = Environment(ENV=os.environ, CFLAGS=ARGUMENTS.get('CFLAGS', ''))
|
||||||
|
|
||||||
env.Tool('micropython')
|
env.Tool('micropython')
|
||||||
|
|
||||||
|
@ -7,8 +7,17 @@
|
|||||||
|
|
||||||
#include STM32_HAL_H
|
#include STM32_HAL_H
|
||||||
|
|
||||||
|
#ifndef DISPLAY_ILI9341V
|
||||||
#define DISPLAY_ILI9341V 0
|
#define DISPLAY_ILI9341V 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef DISPLAY_ST7789V
|
||||||
#define DISPLAY_ST7789V 1
|
#define DISPLAY_ST7789V 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef DISPLAY_VSYNC
|
||||||
|
#define DISPLAY_VSYNC 1
|
||||||
|
#endif
|
||||||
|
|
||||||
// FSMC Bank 1 - NOR/PSRAM 1
|
// FSMC Bank 1 - NOR/PSRAM 1
|
||||||
#define DISPLAY_FSMC_BASE 0x60000000
|
#define DISPLAY_FSMC_BASE 0x60000000
|
||||||
@ -62,53 +71,45 @@ void display_set_orientation(int degrees)
|
|||||||
CMD(0x36);
|
CMD(0x36);
|
||||||
#if DISPLAY_ILI9341V
|
#if DISPLAY_ILI9341V
|
||||||
DATA(BGR | MX | MY);
|
DATA(BGR | MX | MY);
|
||||||
BUFFER_OFFSET_X = 0;
|
|
||||||
BUFFER_OFFSET_Y = 80;
|
|
||||||
#endif
|
#endif
|
||||||
#if DISPLAY_ST7789V
|
#if DISPLAY_ST7789V
|
||||||
DATA(RGB | MX | MY );
|
DATA(RGB | MX | MY);
|
||||||
BUFFER_OFFSET_X = 0;
|
|
||||||
BUFFER_OFFSET_Y = 80;
|
|
||||||
#endif
|
#endif
|
||||||
|
BUFFER_OFFSET_X = 0;
|
||||||
|
BUFFER_OFFSET_Y = MAX_DISPLAY_RESY - DISPLAY_RESY;
|
||||||
break;
|
break;
|
||||||
case 90:
|
case 90:
|
||||||
CMD(0x36);
|
CMD(0x36);
|
||||||
#if DISPLAY_ILI9341V
|
#if DISPLAY_ILI9341V
|
||||||
DATA(BGR | MV | MX);
|
DATA(BGR | MV | MY);
|
||||||
BUFFER_OFFSET_X = 0;
|
|
||||||
BUFFER_OFFSET_Y = 0;
|
|
||||||
#endif
|
#endif
|
||||||
#if DISPLAY_ST7789V
|
#if DISPLAY_ST7789V
|
||||||
DATA(RGB | MV | MY );
|
DATA(RGB | MV | MY);
|
||||||
BUFFER_OFFSET_X = 80;
|
|
||||||
BUFFER_OFFSET_Y = 0;
|
|
||||||
#endif
|
#endif
|
||||||
|
BUFFER_OFFSET_X = MAX_DISPLAY_RESY - DISPLAY_RESX;
|
||||||
|
BUFFER_OFFSET_Y = 0;
|
||||||
break;
|
break;
|
||||||
case 180:
|
case 180:
|
||||||
CMD(0x36);
|
CMD(0x36);
|
||||||
#if DISPLAY_ILI9341V
|
#if DISPLAY_ILI9341V
|
||||||
DATA(BGR);
|
DATA(BGR);
|
||||||
BUFFER_OFFSET_X = 0;
|
|
||||||
BUFFER_OFFSET_Y = 0;
|
|
||||||
#endif
|
#endif
|
||||||
#if DISPLAY_ST7789V
|
#if DISPLAY_ST7789V
|
||||||
DATA(RGB);
|
DATA(RGB);
|
||||||
|
#endif
|
||||||
BUFFER_OFFSET_X = 0;
|
BUFFER_OFFSET_X = 0;
|
||||||
BUFFER_OFFSET_Y = 0;
|
BUFFER_OFFSET_Y = 0;
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
case 270:
|
case 270:
|
||||||
CMD(0x36);
|
CMD(0x36);
|
||||||
#if DISPLAY_ILI9341V
|
#if DISPLAY_ILI9341V
|
||||||
DATA(BGR | MV | MY);
|
DATA(BGR | MV | MX);
|
||||||
BUFFER_OFFSET_X = 80;
|
|
||||||
BUFFER_OFFSET_Y = 0;
|
|
||||||
#endif
|
#endif
|
||||||
#if DISPLAY_ST7789V
|
#if DISPLAY_ST7789V
|
||||||
DATA(RGB | MV | MX);
|
DATA(RGB | MV | MX);
|
||||||
|
#endif
|
||||||
BUFFER_OFFSET_X = 0;
|
BUFFER_OFFSET_X = 0;
|
||||||
BUFFER_OFFSET_Y = 0;
|
BUFFER_OFFSET_Y = 0;
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -244,7 +245,7 @@ int display_init(void) {
|
|||||||
CMD(0xE0); DATA(0x0F); DATA(0x2F); DATA(0x2C); DATA(0x0B); DATA(0x0F); DATA(0x09); DATA(0x56); DATA(0xD9); DATA(0x4A); DATA(0x0B); DATA(0x14); DATA(0x05); DATA(0x0C); DATA(0x06); DATA(0x00);
|
CMD(0xE0); DATA(0x0F); DATA(0x2F); DATA(0x2C); DATA(0x0B); DATA(0x0F); DATA(0x09); DATA(0x56); DATA(0xD9); DATA(0x4A); DATA(0x0B); DATA(0x14); DATA(0x05); DATA(0x0C); DATA(0x06); DATA(0x00);
|
||||||
// gamma curve 2
|
// gamma curve 2
|
||||||
CMD(0xE1); DATA(0x00); DATA(0x10); DATA(0x13); DATA(0x04); DATA(0x10); DATA(0x06); DATA(0x25); DATA(0x26); DATA(0x3B); DATA(0x04); DATA(0x0B); DATA(0x0A); DATA(0x33); DATA(0x39); DATA(0x0F);
|
CMD(0xE1); DATA(0x00); DATA(0x10); DATA(0x13); DATA(0x04); DATA(0x10); DATA(0x06); DATA(0x25); DATA(0x26); DATA(0x3B); DATA(0x04); DATA(0x0B); DATA(0x0A); DATA(0x33); DATA(0x39); DATA(0x0F);
|
||||||
CMD(0x21); // invert colors
|
CMD(0x20); // don't invert colors
|
||||||
#endif
|
#endif
|
||||||
#if DISPLAY_ST7789V
|
#if DISPLAY_ST7789V
|
||||||
CMD(0x01); // software reset
|
CMD(0x01); // software reset
|
||||||
@ -288,9 +289,11 @@ static void display_set_window(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y
|
|||||||
}
|
}
|
||||||
|
|
||||||
void display_refresh(void) {
|
void display_refresh(void) {
|
||||||
|
#if DISPLAY_VSYNC
|
||||||
// synchronize with the panel synchronization signal in order to avoid visual tearing effects
|
// synchronize with the panel synchronization signal in order to avoid visual tearing effects
|
||||||
while (GPIO_PIN_RESET == HAL_GPIO_ReadPin(GPIOD, GPIO_PIN_12)) { }
|
while (GPIO_PIN_RESET == HAL_GPIO_ReadPin(GPIOD, GPIO_PIN_12)) { }
|
||||||
while (GPIO_PIN_SET == HAL_GPIO_ReadPin(GPIOD, GPIO_PIN_12)) { }
|
while (GPIO_PIN_SET == HAL_GPIO_ReadPin(GPIOD, GPIO_PIN_12)) { }
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void display_save(const char *filename)
|
void display_save(const char *filename)
|
||||||
|
@ -10,6 +10,10 @@
|
|||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
// ILI9341V and ST7789V drivers both support 240px x 320px display resolution
|
||||||
|
#define MAX_DISPLAY_RESX 240
|
||||||
|
#define MAX_DISPLAY_RESY 320
|
||||||
|
// X and Y display resolution used
|
||||||
#define DISPLAY_RESX 240
|
#define DISPLAY_RESX 240
|
||||||
#define DISPLAY_RESY 240
|
#define DISPLAY_RESY 240
|
||||||
|
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
|
|
||||||
void __attribute__((noreturn)) __fatal_error(const char *msg, const char *file, int line, const char *func) {
|
void __attribute__((noreturn)) __fatal_error(const char *msg, const char *file, int line, const char *func) {
|
||||||
for (volatile uint32_t delay = 0; delay < 10000000; delay++) {}
|
for (volatile uint32_t delay = 0; delay < 10000000; delay++) {}
|
||||||
|
display_orientation(0);
|
||||||
|
display_backlight(255);
|
||||||
display_print_color(COLOR_WHITE, COLOR_RED128);
|
display_print_color(COLOR_WHITE, COLOR_RED128);
|
||||||
display_printf("\nFATAL ERROR:\n%s\n", msg);
|
display_printf("\nFATAL ERROR:\n%s\n", msg);
|
||||||
if (file) {
|
if (file) {
|
||||||
@ -13,12 +15,7 @@ void __attribute__((noreturn)) __fatal_error(const char *msg, const char *file,
|
|||||||
if (func) {
|
if (func) {
|
||||||
display_printf("Func: %s\n", func);
|
display_printf("Func: %s\n", func);
|
||||||
}
|
}
|
||||||
for (;;) {
|
for (;;);
|
||||||
display_backlight(255);
|
|
||||||
HAL_Delay(950);
|
|
||||||
display_backlight(128);
|
|
||||||
HAL_Delay(50);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
|
Loading…
Reference in New Issue
Block a user