mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-16 19:38:09 +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
|
||||
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:
|
||||
|
||||
@ -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_boardloader: ## build boardloader
|
||||
$(SCONS) build/boardloader/boardloader.bin
|
||||
$(SCONS) CFLAGS="$(CFLAGS)" build/boardloader/boardloader.bin
|
||||
|
||||
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
|
||||
$(SCONS) build/firmware/firmware.bin
|
||||
$(SCONS) CFLAGS="$(CFLAGS)" build/firmware/firmware.bin
|
||||
|
||||
build_unix: ## build unix port
|
||||
$(SCONS) build/unix/micropython $(UNIX_PORT_OPTS)
|
||||
|
@ -84,7 +84,7 @@ SOURCE_TREZORHAL = [
|
||||
'embed/trezorhal/stm32_system.c',
|
||||
]
|
||||
|
||||
env = Environment(ENV=os.environ)
|
||||
env = Environment(ENV=os.environ, CFLAGS=ARGUMENTS.get('CFLAGS', ''))
|
||||
|
||||
env.Replace(
|
||||
AS='arm-none-eabi-as',
|
||||
|
@ -102,7 +102,7 @@ SOURCE_TREZORHAL = [
|
||||
'embed/trezorhal/usbd_ioreq.c',
|
||||
]
|
||||
|
||||
env = Environment(ENV=os.environ)
|
||||
env = Environment(ENV=os.environ, CFLAGS=ARGUMENTS.get('CFLAGS', ''))
|
||||
|
||||
env.Replace(
|
||||
AS='arm-none-eabi-as',
|
||||
|
@ -299,7 +299,7 @@ SOURCE_PY.extend(Glob('src/*/*/*/*.py'))
|
||||
SOURCE_PY.extend(Glob('src/*/*/*/*/*.py'))
|
||||
SOURCE_PY_DIR = 'src/'
|
||||
|
||||
env = Environment(ENV=os.environ)
|
||||
env = Environment(ENV=os.environ, CFLAGS=ARGUMENTS.get('CFLAGS', ''))
|
||||
|
||||
env.Tool('micropython')
|
||||
|
||||
|
@ -7,8 +7,17 @@
|
||||
|
||||
#include STM32_HAL_H
|
||||
|
||||
#ifndef DISPLAY_ILI9341V
|
||||
#define DISPLAY_ILI9341V 0
|
||||
#endif
|
||||
|
||||
#ifndef DISPLAY_ST7789V
|
||||
#define DISPLAY_ST7789V 1
|
||||
#endif
|
||||
|
||||
#ifndef DISPLAY_VSYNC
|
||||
#define DISPLAY_VSYNC 1
|
||||
#endif
|
||||
|
||||
// FSMC Bank 1 - NOR/PSRAM 1
|
||||
#define DISPLAY_FSMC_BASE 0x60000000
|
||||
@ -62,53 +71,45 @@ void display_set_orientation(int degrees)
|
||||
CMD(0x36);
|
||||
#if DISPLAY_ILI9341V
|
||||
DATA(BGR | MX | MY);
|
||||
BUFFER_OFFSET_X = 0;
|
||||
BUFFER_OFFSET_Y = 80;
|
||||
#endif
|
||||
#if DISPLAY_ST7789V
|
||||
DATA(RGB | MX | MY );
|
||||
BUFFER_OFFSET_X = 0;
|
||||
BUFFER_OFFSET_Y = 80;
|
||||
DATA(RGB | MX | MY);
|
||||
#endif
|
||||
BUFFER_OFFSET_X = 0;
|
||||
BUFFER_OFFSET_Y = MAX_DISPLAY_RESY - DISPLAY_RESY;
|
||||
break;
|
||||
case 90:
|
||||
CMD(0x36);
|
||||
#if DISPLAY_ILI9341V
|
||||
DATA(BGR | MV | MX);
|
||||
BUFFER_OFFSET_X = 0;
|
||||
BUFFER_OFFSET_Y = 0;
|
||||
DATA(BGR | MV | MY);
|
||||
#endif
|
||||
#if DISPLAY_ST7789V
|
||||
DATA(RGB | MV | MY );
|
||||
BUFFER_OFFSET_X = 80;
|
||||
BUFFER_OFFSET_Y = 0;
|
||||
DATA(RGB | MV | MY);
|
||||
#endif
|
||||
BUFFER_OFFSET_X = MAX_DISPLAY_RESY - DISPLAY_RESX;
|
||||
BUFFER_OFFSET_Y = 0;
|
||||
break;
|
||||
case 180:
|
||||
CMD(0x36);
|
||||
#if DISPLAY_ILI9341V
|
||||
DATA(BGR);
|
||||
BUFFER_OFFSET_X = 0;
|
||||
BUFFER_OFFSET_Y = 0;
|
||||
#endif
|
||||
#if DISPLAY_ST7789V
|
||||
DATA(RGB);
|
||||
#endif
|
||||
BUFFER_OFFSET_X = 0;
|
||||
BUFFER_OFFSET_Y = 0;
|
||||
#endif
|
||||
break;
|
||||
case 270:
|
||||
CMD(0x36);
|
||||
#if DISPLAY_ILI9341V
|
||||
DATA(BGR | MV | MY);
|
||||
BUFFER_OFFSET_X = 80;
|
||||
BUFFER_OFFSET_Y = 0;
|
||||
DATA(BGR | MV | MX);
|
||||
#endif
|
||||
#if DISPLAY_ST7789V
|
||||
DATA(RGB | MV | MX);
|
||||
#endif
|
||||
BUFFER_OFFSET_X = 0;
|
||||
BUFFER_OFFSET_Y = 0;
|
||||
#endif
|
||||
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);
|
||||
// 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(0x21); // invert colors
|
||||
CMD(0x20); // don't invert colors
|
||||
#endif
|
||||
#if DISPLAY_ST7789V
|
||||
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) {
|
||||
#if DISPLAY_VSYNC
|
||||
// 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_SET == HAL_GPIO_ReadPin(GPIOD, GPIO_PIN_12)) { }
|
||||
#endif
|
||||
}
|
||||
|
||||
void display_save(const char *filename)
|
||||
|
@ -10,6 +10,10 @@
|
||||
|
||||
#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_RESY 240
|
||||
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
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++) {}
|
||||
display_orientation(0);
|
||||
display_backlight(255);
|
||||
display_print_color(COLOR_WHITE, COLOR_RED128);
|
||||
display_printf("\nFATAL ERROR:\n%s\n", msg);
|
||||
if (file) {
|
||||
@ -13,12 +15,7 @@ void __attribute__((noreturn)) __fatal_error(const char *msg, const char *file,
|
||||
if (func) {
|
||||
display_printf("Func: %s\n", func);
|
||||
}
|
||||
for (;;) {
|
||||
display_backlight(255);
|
||||
HAL_Delay(950);
|
||||
display_backlight(128);
|
||||
HAL_Delay(50);
|
||||
}
|
||||
for (;;);
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
|
Loading…
Reference in New Issue
Block a user