mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-08-01 19:38:33 +00:00
feat(core): change display type for model R
[no changelog]
This commit is contained in:
parent
c2162f0831
commit
4009a0fd2a
@ -1,6 +1,7 @@
|
||||
# pylint: disable=E0602
|
||||
|
||||
import os
|
||||
import tools
|
||||
|
||||
TREZOR_MODEL = ARGUMENTS.get('TREZOR_MODEL', 'T')
|
||||
|
||||
@ -51,7 +52,6 @@ CPPPATH_MOD += [
|
||||
SOURCE_MOD += [
|
||||
'embed/extmod/modtrezorui/display.c',
|
||||
'embed/extmod/modtrezorui/colors.c',
|
||||
f'embed/extmod/modtrezorui/display-stm32_{TREZOR_MODEL}.c',
|
||||
'embed/extmod/modtrezorui/fonts/fonts.c',
|
||||
'embed/extmod/modtrezorui/fonts/font_bitmap.c',
|
||||
]
|
||||
@ -101,6 +101,8 @@ SOURCE_TREZORHAL = [
|
||||
|
||||
env = Environment(ENV=os.environ, CFLAGS='%s -DPRODUCTION=%s' % (ARGUMENTS.get('CFLAGS', ''), ARGUMENTS.get('PRODUCTION', '0')))
|
||||
|
||||
tools.configure_board(TREZOR_MODEL, env, CPPDEFINES_MOD, SOURCE_TREZORHAL)
|
||||
|
||||
env.Replace(
|
||||
AS='arm-none-eabi-as',
|
||||
AR='arm-none-eabi-ar',
|
||||
|
@ -72,7 +72,6 @@ SOURCE_MOD += [
|
||||
'embed/extmod/modtrezorui/buffers.c',
|
||||
'embed/extmod/modtrezorui/colors.c',
|
||||
'embed/extmod/modtrezorui/display.c',
|
||||
f'embed/extmod/modtrezorui/display-stm32_{TREZOR_MODEL}.c',
|
||||
'embed/extmod/modtrezorui/fonts/fonts.c',
|
||||
'embed/extmod/modtrezorui/fonts/font_bitmap.c',
|
||||
'vendor/micropython/lib/uzlib/adler32.c',
|
||||
@ -158,6 +157,8 @@ tools.add_font('MONO', FONT_MONO, CPPDEFINES_MOD, SOURCE_MOD)
|
||||
|
||||
env = Environment(ENV=os.environ, CFLAGS='%s -DPRODUCTION=%s' % (ARGUMENTS.get('CFLAGS', ''), ARGUMENTS.get('PRODUCTION', '0')))
|
||||
|
||||
tools.configure_board(TREZOR_MODEL, env, CPPDEFINES_MOD, SOURCE_TREZORHAL)
|
||||
|
||||
env.Replace(
|
||||
AS='arm-none-eabi-as',
|
||||
AR='arm-none-eabi-ar',
|
||||
|
@ -66,7 +66,6 @@ CPPPATH_MOD += [
|
||||
SOURCE_MOD += [
|
||||
'embed/extmod/modtrezorui/display.c',
|
||||
'embed/extmod/modtrezorui/colors.c',
|
||||
f'embed/extmod/modtrezorui/display-stm32_{TREZOR_MODEL}.c',
|
||||
'embed/extmod/modtrezorui/fonts/fonts.c',
|
||||
'embed/extmod/modtrezorui/fonts/font_bitmap.c',
|
||||
'vendor/micropython/lib/uzlib/adler32.c',
|
||||
@ -138,6 +137,8 @@ tools.add_font('MONO', FONT_MONO, CPPDEFINES_MOD, SOURCE_MOD)
|
||||
|
||||
env = Environment(ENV=os.environ, CFLAGS='%s -DPRODUCTION=%s' % (ARGUMENTS.get('CFLAGS', ''), ARGUMENTS.get('PRODUCTION', '0')))
|
||||
|
||||
tools.configure_board(TREZOR_MODEL, env, CPPDEFINES_MOD, SOURCE_TREZORHAL)
|
||||
|
||||
env.Replace(
|
||||
AS='arm-none-eabi-as',
|
||||
AR='arm-none-eabi-ar',
|
||||
|
@ -182,7 +182,6 @@ SOURCE_MOD += [
|
||||
'embed/extmod/modtrezorui/buffers.c',
|
||||
'embed/extmod/modtrezorui/colors.c',
|
||||
'embed/extmod/modtrezorui/display.c',
|
||||
f'embed/extmod/modtrezorui/display-stm32_{TREZOR_MODEL}.c',
|
||||
'embed/extmod/modtrezorui/fonts/fonts.c',
|
||||
'embed/extmod/modtrezorui/fonts/font_bitmap.c',
|
||||
'embed/extmod/modtrezorui/modtrezorui.c',
|
||||
@ -449,6 +448,8 @@ SOURCE_QSTR = SOURCE_MOD + SOURCE_MICROPYTHON + SOURCE_MICROPYTHON_SPEED
|
||||
|
||||
env = Environment(ENV=os.environ, CFLAGS='%s -DPRODUCTION=%s -DPYOPT=%s -DBITCOIN_ONLY=%s' % (ARGUMENTS.get('CFLAGS', ''), ARGUMENTS.get('PRODUCTION', '0'), PYOPT, BITCOIN_ONLY))
|
||||
|
||||
tools.configure_board(TREZOR_MODEL, env, CPPDEFINES_MOD, SOURCE_TREZORHAL)
|
||||
|
||||
env.Tool('micropython')
|
||||
|
||||
env.Replace(
|
||||
@ -464,7 +465,7 @@ env.Replace(
|
||||
OBJCOPY='arm-none-eabi-objcopy', )
|
||||
|
||||
env.Replace(
|
||||
TREZOR_MODEL=TREZOR_MODEL, )
|
||||
TREZOR_MODEL=TREZOR_MODEL,)
|
||||
|
||||
if TREZOR_MODEL in ('T', 'R'):
|
||||
CPU_ASFLAGS = '-mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16'
|
||||
@ -781,6 +782,8 @@ def cargo_build():
|
||||
'-Z build-std-features=panic_immediate_abort',
|
||||
]
|
||||
|
||||
env.get('ENV')['TREZOR_MODEL'] = TREZOR_MODEL
|
||||
|
||||
return f'cd embed/rust; cargo build {profile} ' + ' '.join(cargo_opts)
|
||||
|
||||
rust = env.Command(
|
||||
|
@ -41,7 +41,6 @@ CPPPATH_MOD += [
|
||||
SOURCE_MOD += [
|
||||
'embed/extmod/modtrezorui/display.c',
|
||||
'embed/extmod/modtrezorui/colors.c',
|
||||
f'embed/extmod/modtrezorui/display-stm32_{TREZOR_MODEL}.c',
|
||||
'embed/extmod/modtrezorui/fonts/fonts.c',
|
||||
'embed/extmod/modtrezorui/fonts/font_bitmap.c',
|
||||
'embed/extmod/modtrezorui/qr-code-generator/qrcodegen.c',
|
||||
@ -107,6 +106,8 @@ tools.add_font('MONO', FONT_MONO, CPPDEFINES_MOD, SOURCE_MOD)
|
||||
|
||||
env = Environment(ENV=os.environ, CFLAGS='%s -DPRODUCTION=%s' % (ARGUMENTS.get('CFLAGS', ''), ARGUMENTS.get('PRODUCTION', '0')))
|
||||
|
||||
tools.configure_board(TREZOR_MODEL, env, CPPDEFINES_MOD, SOURCE_TREZORHAL)
|
||||
|
||||
env.Replace(
|
||||
AS='arm-none-eabi-as',
|
||||
AR='arm-none-eabi-ar',
|
||||
|
@ -36,7 +36,6 @@ CPPPATH_MOD += [
|
||||
SOURCE_MOD += [
|
||||
'embed/extmod/modtrezorui/display.c',
|
||||
'embed/extmod/modtrezorui/colors.c',
|
||||
f'embed/extmod/modtrezorui/display-stm32_{TREZOR_MODEL}.c',
|
||||
'embed/extmod/modtrezorui/fonts/fonts.c',
|
||||
'embed/extmod/modtrezorui/font_bitmap.c',
|
||||
'vendor/micropython/lib/uzlib/adler32.c',
|
||||
@ -100,6 +99,8 @@ tools.add_font('MONO', FONT_MONO, CPPDEFINES_MOD, SOURCE_MOD)
|
||||
|
||||
env = Environment(ENV=os.environ, CFLAGS='%s -DPRODUCTION=%s' % (ARGUMENTS.get('CFLAGS', ''), ARGUMENTS.get('PRODUCTION', '0')))
|
||||
|
||||
tools.configure_board(TREZOR_MODEL, env, CPPDEFINES_MOD, SOURCE_TREZORHAL)
|
||||
|
||||
env.Replace(
|
||||
AS='arm-none-eabi-as',
|
||||
AR='arm-none-eabi-ar',
|
||||
|
@ -178,7 +178,6 @@ SOURCE_MOD += [
|
||||
'embed/extmod/modtrezorui/buffers.c',
|
||||
'embed/extmod/modtrezorui/colors.c',
|
||||
'embed/extmod/modtrezorui/display.c',
|
||||
'embed/extmod/modtrezorui/display-unix.c',
|
||||
'embed/extmod/modtrezorui/fonts/fonts.c',
|
||||
'embed/extmod/modtrezorui/fonts/font_bitmap.c',
|
||||
'embed/extmod/modtrezorui/modtrezorui.c',
|
||||
@ -348,6 +347,7 @@ SOURCE_MICROPYTHON = [
|
||||
|
||||
SOURCE_UNIX = [
|
||||
'embed/unix/common.c',
|
||||
'embed/unix/display-unix.c',
|
||||
'embed/unix/flash.c',
|
||||
'embed/unix/main.c',
|
||||
'embed/unix/main_main.c',
|
||||
@ -460,6 +460,7 @@ env.Replace(
|
||||
CPPDEFINES=[
|
||||
'TREZOR_EMULATOR',
|
||||
'TREZOR_MODEL_'+TREZOR_MODEL,
|
||||
'TREZOR_BOARD=\\"board-unix.h\\"',
|
||||
('MP_CONFIGFILE', '\\"embed/unix/mpconfigport.h\\"'),
|
||||
] + CPPDEFINES_MOD,
|
||||
ASPPFLAGS='$CFLAGS $CCFLAGS', )
|
||||
@ -726,6 +727,8 @@ def cargo_build():
|
||||
if DMA2D:
|
||||
features.append('dma2d')
|
||||
|
||||
env.get('ENV')['TREZOR_MODEL'] = TREZOR_MODEL
|
||||
|
||||
return f'cd embed/rust; cargo build --profile {RUST_PROFILE} --target-dir=../../build/unix/rust --no-default-features --features "{" ".join(features)}" --target {TARGET}'
|
||||
|
||||
rust = env.Command(
|
||||
|
@ -285,6 +285,7 @@ int main(void) {
|
||||
#endif
|
||||
|
||||
#if defined TREZOR_MODEL_R
|
||||
display_init();
|
||||
button_init();
|
||||
rgb_led_init();
|
||||
#endif
|
||||
|
@ -23,7 +23,7 @@
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "common.h"
|
||||
#include "display_defs.h"
|
||||
#include TREZOR_BOARD
|
||||
|
||||
#define BUFFER_PIXELS DISPLAY_RESX
|
||||
|
||||
@ -56,4 +56,4 @@ line_buffer_16bpp_t* buffers_get_line_buffer_16bpp(uint16_t idx, bool clear);
|
||||
line_buffer_4bpp_t* buffers_get_line_buffer_4bpp(uint16_t idx, bool clear);
|
||||
buffer_text_t* buffers_get_text_buffer(uint16_t idx, bool clear);
|
||||
|
||||
#endif //_BUFFERS_H
|
||||
#endif // _BUFFERS_H
|
||||
|
@ -26,7 +26,7 @@
|
||||
|
||||
#include "buffers.h"
|
||||
#include "colors.h"
|
||||
#include "display_defs.h"
|
||||
#include TREZOR_BOARD
|
||||
#include "display_interface.h"
|
||||
#include "fonts/fonts.h"
|
||||
|
||||
|
@ -22,36 +22,15 @@
|
||||
|
||||
#include <stdint.h>
|
||||
#include "common.h"
|
||||
#include TREZOR_BOARD
|
||||
|
||||
#if !defined TREZOR_EMULATOR
|
||||
#include STM32_HAL_H
|
||||
#endif
|
||||
|
||||
#if (defined TREZOR_MODEL_T) && !(defined TREZOR_EMULATOR)
|
||||
|
||||
extern __IO uint8_t *const DISPLAY_CMD_ADDRESS;
|
||||
extern __IO uint8_t *const DISPLAY_DATA_ADDRESS;
|
||||
|
||||
#define CMD(X) (*DISPLAY_CMD_ADDRESS = (X))
|
||||
#define DATA(X) (*DISPLAY_DATA_ADDRESS = (X))
|
||||
#define PIXELDATA(X) \
|
||||
DATA((X)&0xFF); \
|
||||
DATA((X) >> 8)
|
||||
|
||||
#else
|
||||
#ifndef PIXELDATA
|
||||
#define PIXELDATA(c) display_pixeldata(c)
|
||||
#endif
|
||||
|
||||
#ifdef TREZOR_EMULATOR
|
||||
extern uint8_t *const DISPLAY_DATA_ADDRESS;
|
||||
#endif
|
||||
|
||||
void display_pixeldata(uint16_t c);
|
||||
|
||||
#if (defined TREZOR_MODEL_1) && !(defined TREZOR_EMULATOR)
|
||||
void PIXELDATA_DIRTY();
|
||||
#else
|
||||
// noop
|
||||
#ifndef PIXELDATA_DIRTY
|
||||
#define PIXELDATA_DIRTY()
|
||||
#endif
|
||||
|
||||
@ -67,9 +46,4 @@ void display_refresh(void);
|
||||
const char *display_save(const char *prefix);
|
||||
void display_clear_save(void);
|
||||
|
||||
#ifdef TREZOR_MODEL_T
|
||||
void display_set_little_endian(void);
|
||||
void display_set_big_endian(void);
|
||||
#endif
|
||||
|
||||
#endif //_DISPLAY_INTERFACE_H
|
||||
|
@ -115,6 +115,7 @@ int main(void) {
|
||||
#endif
|
||||
|
||||
#if defined TREZOR_MODEL_R
|
||||
display_init();
|
||||
button_init();
|
||||
display_clear();
|
||||
rgb_led_init();
|
||||
|
@ -19,6 +19,19 @@ fn model() -> String {
|
||||
}
|
||||
}
|
||||
|
||||
fn board() -> String {
|
||||
if !is_firmware() {
|
||||
return String::from("board-unix.h");
|
||||
}
|
||||
|
||||
match env::var("TREZOR_BOARD") {
|
||||
Ok(board) => {
|
||||
format!("boards/{}", board)
|
||||
}
|
||||
Err(_) => String::from("boards/trezor_t.h"),
|
||||
}
|
||||
}
|
||||
|
||||
/// Generates Rust module that exports QSTR constants used in firmware.
|
||||
#[cfg(feature = "micropython")]
|
||||
fn generate_qstr_bindings() {
|
||||
@ -64,6 +77,7 @@ fn prepare_bindings() -> bindgen::Builder {
|
||||
"-I../../vendor/micropython/lib/uzlib",
|
||||
"-I../extmod/modtrezorui", // for display.h
|
||||
format!("-DTREZOR_MODEL_{}", model()).as_str(),
|
||||
format!("-DTREZOR_BOARD=\"{}\"", board()).as_str(),
|
||||
]);
|
||||
|
||||
// Pass in correct include paths and defines.
|
||||
|
@ -1,3 +1,4 @@
|
||||
#include TREZOR_BOARD
|
||||
#include "buffers.h"
|
||||
#include "button.h"
|
||||
#include "common.h"
|
||||
|
33
core/embed/trezorhal/boards/trezor_1.h
Normal file
33
core/embed/trezorhal/boards/trezor_1.h
Normal file
@ -0,0 +1,33 @@
|
||||
#ifndef _TREZOR_1_H
|
||||
#define _TREZOR_1_H
|
||||
|
||||
#include "displays/vg-2864ksweg01.h"
|
||||
|
||||
#define BTN_LEFT_PIN GPIO_PIN_5
|
||||
#define BTN_LEFT_PORT GPIOC
|
||||
#define BTN_LEFT_CLK_ENA __HAL_RCC_GPIOC_CLK_ENABLE
|
||||
#define BTN_RIGHT_PIN GPIO_PIN_2
|
||||
#define BTN_RIGHT_PORT GPIOC
|
||||
#define BTN_RIGHT_CLK_ENA __HAL_RCC_GPIOC_CLK_ENABLE
|
||||
|
||||
#define OLED_DC_PORT GPIOB
|
||||
#define OLED_DC_PIN GPIO_PIN_0 // PB0 | Data/Command
|
||||
#define OLED_DC_CLK_ENA __HAL_RCC_GPIOB_CLK_ENABLE
|
||||
#define OLED_CS_PORT GPIOA
|
||||
#define OLED_CS_PIN GPIO_PIN_4 // PA4 | SPI Select
|
||||
#define OLED_CS_CLK_ENA __HAL_RCC_GPIOA_CLK_ENABLE
|
||||
#define OLED_RST_PORT GPIOB
|
||||
#define OLED_RST_PIN GPIO_PIN_1 // PB1 | Reset display
|
||||
#define OLED_RST_CLK_ENA __HAL_RCC_GPIOB_CLK_ENABLE
|
||||
|
||||
#define OLED_SPI SPI1
|
||||
#define OLED_SPI_AF GPIO_AF5_SPI1
|
||||
#define OLED_SPI_CLK_ENA __HAL_RCC_SPI1_CLK_ENABLE
|
||||
#define OLED_SPI_SCK_PORT GPIOA
|
||||
#define OLED_SPI_SCK_PIN GPIO_PIN_5 // PA5 | SPI SCK
|
||||
#define OLED_SPI_SCK_CLK_ENA __HAL_RCC_GPIOA_CLK_ENABLE
|
||||
#define OLED_SPI_MOSI_PORT GPIOA
|
||||
#define OLED_SPI_MOSI_PIN GPIO_PIN_7 // PA7 | SPI MOSI
|
||||
#define OLED_SPI_MOSI_CLK_ENA __HAL_RCC_GPIOA_CLK_ENABLE
|
||||
|
||||
#endif //_TREZOR_1_H
|
13
core/embed/trezorhal/boards/trezor_r_v3.h
Normal file
13
core/embed/trezorhal/boards/trezor_r_v3.h
Normal file
@ -0,0 +1,13 @@
|
||||
#ifndef _TREZOR_R_V3_H
|
||||
#define _TREZOR_R_V3_H
|
||||
|
||||
#include "displays/ug-2828tswig01.h"
|
||||
|
||||
#define BTN_LEFT_PIN GPIO_PIN_0
|
||||
#define BTN_LEFT_PORT GPIOA
|
||||
#define BTN_LEFT_CLK_ENA __HAL_RCC_GPIOA_CLK_ENABLE
|
||||
#define BTN_RIGHT_PIN GPIO_PIN_15
|
||||
#define BTN_RIGHT_PORT GPIOE
|
||||
#define BTN_RIGHT_CLK_ENA __HAL_RCC_GPIOE_CLK_ENABLE
|
||||
|
||||
#endif //_TREZOR_R_V3_H
|
33
core/embed/trezorhal/boards/trezor_r_v4.h
Normal file
33
core/embed/trezorhal/boards/trezor_r_v4.h
Normal file
@ -0,0 +1,33 @@
|
||||
#ifndef _TREZOR_R_V4_H
|
||||
#define _TREZOR_R_V4_H
|
||||
|
||||
#include "displays/vg-2864ksweg01.h"
|
||||
|
||||
#define BTN_LEFT_PIN GPIO_PIN_5
|
||||
#define BTN_LEFT_PORT GPIOC
|
||||
#define BTN_LEFT_CLK_ENA __HAL_RCC_GPIOC_CLK_ENABLE
|
||||
#define BTN_RIGHT_PIN GPIO_PIN_10
|
||||
#define BTN_RIGHT_PORT GPIOB
|
||||
#define BTN_RIGHT_CLK_ENA __HAL_RCC_GPIOB_CLK_ENABLE
|
||||
|
||||
#define OLED_DC_PORT GPIOD
|
||||
#define OLED_DC_PIN GPIO_PIN_0 // PD0 | Data/Command
|
||||
#define OLED_DC_CLK_ENA __HAL_RCC_GPIOD_CLK_ENABLE
|
||||
#define OLED_CS_PORT GPIOE
|
||||
#define OLED_CS_PIN GPIO_PIN_4 // PE4 | SPI Select
|
||||
#define OLED_CS_CLK_ENA __HAL_RCC_GPIOE_CLK_ENABLE
|
||||
#define OLED_RST_PORT GPIOD
|
||||
#define OLED_RST_PIN GPIO_PIN_1 // PD1 | Reset display
|
||||
#define OLED_RST_CLK_ENA __HAL_RCC_GPIOD_CLK_ENABLE
|
||||
|
||||
#define OLED_SPI SPI4
|
||||
#define OLED_SPI_AF GPIO_AF5_SPI4
|
||||
#define OLED_SPI_CLK_ENA __HAL_RCC_SPI4_CLK_ENABLE
|
||||
#define OLED_SPI_SCK_PORT GPIOE
|
||||
#define OLED_SPI_SCK_PIN GPIO_PIN_2 // PE2 | SPI SCK
|
||||
#define OLED_SPI_SCK_CLK_ENA __HAL_RCC_GPIOE_CLK_ENABLE
|
||||
#define OLED_SPI_MOSI_PORT GPIOE
|
||||
#define OLED_SPI_MOSI_PIN GPIO_PIN_6 // PE6 | SPI MOSI
|
||||
#define OLED_SPI_MOSI_CLK_ENA __HAL_RCC_GPIOE_CLK_ENABLE
|
||||
|
||||
#endif //_TREZOR_R_V4_H
|
6
core/embed/trezorhal/boards/trezor_t.h
Normal file
6
core/embed/trezorhal/boards/trezor_t.h
Normal file
@ -0,0 +1,6 @@
|
||||
#ifndef _TREZOR_T_H
|
||||
#define _TREZOR_T_H
|
||||
|
||||
#include "displays/st7789v.h"
|
||||
|
||||
#endif //_TREZOR_T_H
|
@ -1,23 +1,6 @@
|
||||
#include STM32_HAL_H
|
||||
#include "button.h"
|
||||
|
||||
#if defined TREZOR_MODEL_1
|
||||
#define BTN_LEFT_PIN GPIO_PIN_5
|
||||
#define BTN_LEFT_PORT GPIOC
|
||||
#define BTN_LEFT_CLK_ENA __HAL_RCC_GPIOC_CLK_ENABLE
|
||||
#define BTN_RIGHT_PIN GPIO_PIN_2
|
||||
#define BTN_RIGHT_PORT GPIOC
|
||||
#define BTN_RIGHT_CLK_ENA __HAL_RCC_GPIOC_CLK_ENABLE
|
||||
#elif defined TREZOR_MODEL_R
|
||||
#define BTN_LEFT_PIN GPIO_PIN_0
|
||||
#define BTN_LEFT_PORT GPIOA
|
||||
#define BTN_LEFT_CLK_ENA __HAL_RCC_GPIOA_CLK_ENABLE
|
||||
#define BTN_RIGHT_PIN GPIO_PIN_15
|
||||
#define BTN_RIGHT_PORT GPIOE
|
||||
#define BTN_RIGHT_CLK_ENA __HAL_RCC_GPIOE_CLK_ENABLE
|
||||
#else
|
||||
#error Unknown Trezor model
|
||||
#endif
|
||||
#include TREZOR_BOARD
|
||||
|
||||
static char last_left = 0, last_right = 0;
|
||||
|
||||
|
@ -18,7 +18,7 @@
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include "display_defs.h"
|
||||
#include TREZOR_BOARD
|
||||
#include "display_interface.h"
|
||||
#include "memzero.h"
|
||||
#include STM32_HAL_H
|
25
core/embed/trezorhal/displays/st7789v.h
Normal file
25
core/embed/trezorhal/displays/st7789v.h
Normal file
@ -0,0 +1,25 @@
|
||||
#ifndef _ST7789V_H
|
||||
#define _ST7789V_H
|
||||
|
||||
#include STM32_HAL_H
|
||||
|
||||
// ILI9341V, GC9307 and ST7789V drivers support 240px x 320px display resolution
|
||||
#define MAX_DISPLAY_RESX 240
|
||||
#define MAX_DISPLAY_RESY 320
|
||||
#define DISPLAY_RESX 240
|
||||
#define DISPLAY_RESY 240
|
||||
#define TREZOR_FONT_BPP 4
|
||||
|
||||
extern __IO uint8_t *const DISPLAY_CMD_ADDRESS;
|
||||
extern __IO uint8_t *const DISPLAY_DATA_ADDRESS;
|
||||
|
||||
#define CMD(X) (*DISPLAY_CMD_ADDRESS = (X))
|
||||
#define DATA(X) (*DISPLAY_DATA_ADDRESS = (X))
|
||||
#define PIXELDATA(X) \
|
||||
DATA((X)&0xFF); \
|
||||
DATA((X) >> 8)
|
||||
|
||||
void display_set_little_endian(void);
|
||||
void display_set_big_endian(void);
|
||||
|
||||
#endif //_ST7789V_H
|
@ -18,7 +18,7 @@
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include "display_defs.h"
|
||||
#include TREZOR_BOARD
|
||||
#include "display_interface.h"
|
||||
#include "memzero.h"
|
||||
#include STM32_HAL_H
|
10
core/embed/trezorhal/displays/ug-2828tswig01.h
Normal file
10
core/embed/trezorhal/displays/ug-2828tswig01.h
Normal file
@ -0,0 +1,10 @@
|
||||
#ifndef _UG_2828TSWIG01_H
|
||||
#define _UG_2828TSWIG01_H
|
||||
|
||||
#define MAX_DISPLAY_RESX 128
|
||||
#define MAX_DISPLAY_RESY 128
|
||||
#define DISPLAY_RESX 128
|
||||
#define DISPLAY_RESY 128
|
||||
#define TREZOR_FONT_BPP 1
|
||||
|
||||
#endif //_UG_2828TSWIG01_H
|
@ -19,7 +19,7 @@
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "display_defs.h"
|
||||
#include TREZOR_BOARD
|
||||
#include "display_interface.h"
|
||||
#include STM32_HAL_H
|
||||
|
||||
@ -49,13 +49,6 @@
|
||||
#define OLED_SEGREMAP 0xA0
|
||||
#define OLED_CHARGEPUMP 0x8D
|
||||
|
||||
#define OLED_DC_PORT GPIOB
|
||||
#define OLED_DC_PIN GPIO_PIN_0 // PB0 | Data/Command
|
||||
#define OLED_CS_PORT GPIOA
|
||||
#define OLED_CS_PIN GPIO_PIN_4 // PA4 | SPI Select
|
||||
#define OLED_RST_PORT GPIOB
|
||||
#define OLED_RST_PIN GPIO_PIN_1 // PB1 | Reset display
|
||||
|
||||
static int DISPLAY_BACKLIGHT = -1;
|
||||
static int DISPLAY_ORIENTATION = -1;
|
||||
static uint8_t OLED_BUFFER[OLED_BUFSIZE];
|
||||
@ -72,7 +65,7 @@ static struct {
|
||||
} pos;
|
||||
} PIXELWINDOW;
|
||||
|
||||
static bool pixeldata_dirty = true;
|
||||
static bool pixeldata_dirty_flag = true;
|
||||
|
||||
void display_pixeldata(uint16_t c) {
|
||||
if (PIXELWINDOW.pos.x <= PIXELWINDOW.end.x &&
|
||||
@ -99,7 +92,7 @@ void display_pixeldata(uint16_t c) {
|
||||
|
||||
void display_reset_state() {}
|
||||
|
||||
void PIXELDATA_DIRTY() { pixeldata_dirty = true; }
|
||||
void pixeldata_dirty(void) { pixeldata_dirty_flag = true; }
|
||||
|
||||
void display_set_window(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1) {
|
||||
PIXELWINDOW.start.x = x0;
|
||||
@ -140,9 +133,12 @@ static inline void spi_send(const uint8_t *data, int len) {
|
||||
}
|
||||
|
||||
void display_init(void) {
|
||||
__HAL_RCC_GPIOA_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOB_CLK_ENABLE();
|
||||
__HAL_RCC_SPI1_CLK_ENABLE();
|
||||
OLED_DC_CLK_ENA();
|
||||
OLED_CS_CLK_ENA();
|
||||
OLED_RST_CLK_ENA();
|
||||
OLED_SPI_SCK_CLK_ENA();
|
||||
OLED_SPI_MOSI_CLK_ENA();
|
||||
OLED_SPI_CLK_ENA();
|
||||
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
|
||||
@ -151,22 +147,27 @@ void display_init(void) {
|
||||
GPIO_InitStructure.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStructure.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
||||
GPIO_InitStructure.Alternate = 0;
|
||||
GPIO_InitStructure.Pin = GPIO_PIN_4;
|
||||
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_4, GPIO_PIN_RESET);
|
||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStructure);
|
||||
GPIO_InitStructure.Pin = GPIO_PIN_0 | GPIO_PIN_4;
|
||||
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_0 | GPIO_PIN_4, GPIO_PIN_RESET);
|
||||
HAL_GPIO_Init(GPIOB, &GPIO_InitStructure);
|
||||
GPIO_InitStructure.Pin = OLED_CS_PIN;
|
||||
HAL_GPIO_WritePin(OLED_CS_PORT, OLED_CS_PIN, GPIO_PIN_RESET);
|
||||
HAL_GPIO_Init(OLED_CS_PORT, &GPIO_InitStructure);
|
||||
GPIO_InitStructure.Pin = OLED_DC_PIN;
|
||||
HAL_GPIO_WritePin(OLED_DC_PORT, OLED_DC_PIN, GPIO_PIN_RESET);
|
||||
HAL_GPIO_Init(OLED_DC_PORT, &GPIO_InitStructure);
|
||||
GPIO_InitStructure.Pin = OLED_RST_PIN;
|
||||
HAL_GPIO_WritePin(OLED_RST_PORT, OLED_RST_PIN, GPIO_PIN_RESET);
|
||||
HAL_GPIO_Init(OLED_RST_PORT, &GPIO_InitStructure);
|
||||
|
||||
// enable SPI 1 for OLED display
|
||||
GPIO_InitStructure.Mode = GPIO_MODE_AF_PP;
|
||||
GPIO_InitStructure.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStructure.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
||||
GPIO_InitStructure.Alternate = GPIO_AF5_SPI1;
|
||||
GPIO_InitStructure.Pin = GPIO_PIN_5 | GPIO_PIN_7;
|
||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStructure);
|
||||
GPIO_InitStructure.Alternate = OLED_SPI_AF;
|
||||
GPIO_InitStructure.Pin = OLED_SPI_SCK_PIN;
|
||||
HAL_GPIO_Init(OLED_SPI_SCK_PORT, &GPIO_InitStructure);
|
||||
GPIO_InitStructure.Pin = OLED_SPI_MOSI_PIN;
|
||||
HAL_GPIO_Init(OLED_SPI_MOSI_PORT, &GPIO_InitStructure);
|
||||
|
||||
spi_handle.Instance = SPI1;
|
||||
spi_handle.Instance = OLED_SPI;
|
||||
spi_handle.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_8;
|
||||
spi_handle.Init.Direction = SPI_DIRECTION_2LINES;
|
||||
spi_handle.Init.CLKPhase = SPI_PHASE_1EDGE;
|
||||
@ -249,10 +250,10 @@ void display_refresh(void) {
|
||||
OLED_SETHIGHCOLUMN | 0x00,
|
||||
OLED_SETSTARTLINE | 0x00};
|
||||
|
||||
if (!pixeldata_dirty) {
|
||||
if (!pixeldata_dirty_flag) {
|
||||
return;
|
||||
}
|
||||
pixeldata_dirty = false;
|
||||
pixeldata_dirty_flag = false;
|
||||
|
||||
HAL_GPIO_WritePin(OLED_CS_PORT, OLED_CS_PIN, GPIO_PIN_RESET); // SPI select
|
||||
spi_send(s, 3);
|
13
core/embed/trezorhal/displays/vg-2864ksweg01.h
Normal file
13
core/embed/trezorhal/displays/vg-2864ksweg01.h
Normal file
@ -0,0 +1,13 @@
|
||||
#ifndef _VG_2864KSWEG01_H
|
||||
#define _VG_2864KSWEG01_H
|
||||
|
||||
#define MAX_DISPLAY_RESX 128
|
||||
#define MAX_DISPLAY_RESY 64
|
||||
#define DISPLAY_RESX 128
|
||||
#define DISPLAY_RESY 64
|
||||
#define TREZOR_FONT_BPP 1
|
||||
|
||||
void pixeldata_dirty(void);
|
||||
#define PIXELDATA_DIRTY() pixeldata_dirty();
|
||||
|
||||
#endif //_VG_2864KSWEG01_H
|
6
core/embed/unix/board-unix.h
Normal file
6
core/embed/unix/board-unix.h
Normal file
@ -0,0 +1,6 @@
|
||||
#ifndef _BOARD_UNIX_H
|
||||
#define _BOARD_UNIX_H
|
||||
|
||||
#include "display-unix.h"
|
||||
|
||||
#endif //_BOARD_UNIX_H
|
@ -29,7 +29,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "common.h"
|
||||
#include "display_defs.h"
|
||||
#include "display-unix.h"
|
||||
#include "display_interface.h"
|
||||
#include "profile.h"
|
||||
|
33
core/embed/unix/display-unix.h
Normal file
33
core/embed/unix/display-unix.h
Normal file
@ -0,0 +1,33 @@
|
||||
#ifndef _DISPLAY_UNIX_H
|
||||
#define _DISPLAY_UNIX_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef TREZOR_MODEL_T
|
||||
// ILI9341V, GC9307 and ST7789V drivers support 240px x 320px display resolution
|
||||
#define MAX_DISPLAY_RESX 240
|
||||
#define MAX_DISPLAY_RESY 320
|
||||
#define DISPLAY_RESX 240
|
||||
#define DISPLAY_RESY 240
|
||||
#define TREZOR_FONT_BPP 4
|
||||
#endif
|
||||
|
||||
#ifdef TREZOR_MODEL_R
|
||||
#define MAX_DISPLAY_RESX 128
|
||||
#define MAX_DISPLAY_RESY 64
|
||||
#define DISPLAY_RESX 128
|
||||
#define DISPLAY_RESY 64
|
||||
#define TREZOR_FONT_BPP 1
|
||||
#endif
|
||||
|
||||
#ifdef TREZOR_MODEL_1
|
||||
#define MAX_DISPLAY_RESX 128
|
||||
#define MAX_DISPLAY_RESY 64
|
||||
#define DISPLAY_RESX 128
|
||||
#define DISPLAY_RESY 64
|
||||
#define TREZOR_FONT_BPP 1
|
||||
#endif
|
||||
|
||||
extern uint8_t *const DISPLAY_DATA_ADDRESS;
|
||||
|
||||
#endif //_DISPLAY_UNIX_H
|
@ -1,11 +1,33 @@
|
||||
|
||||
def add_font(font_name, font, defines, sources):
|
||||
if font is not None:
|
||||
defines += [
|
||||
'TREZOR_FONT_' + font_name + '_ENABLE=' + font,
|
||||
'TREZOR_FONT_' + font_name + '_INCLUDE=\\"' + font.lower() + '.h\\"',
|
||||
]
|
||||
]
|
||||
sourcefile = 'embed/extmod/modtrezorui/fonts/' + font.lower() + '.c'
|
||||
if sourcefile not in sources:
|
||||
sources.append(sourcefile)
|
||||
|
||||
|
||||
def configure_board(model, env, defines, sources):
|
||||
model_r_version = 3
|
||||
|
||||
if model in ('1',):
|
||||
board = 'trezor_1.h'
|
||||
display = 'vg-2864ksweg01.c'
|
||||
elif model in ('T',):
|
||||
board = 'trezor_t.h'
|
||||
display = 'st7789v.c'
|
||||
elif model in ('R',):
|
||||
if model_r_version == 3:
|
||||
board = 'trezor_r_v3.h'
|
||||
display = "vg-2828tswig01.c"
|
||||
else:
|
||||
board = 'trezor_r_v4.h'
|
||||
display = 'vg-2864ksweg01.c'
|
||||
else:
|
||||
raise Exception("Unknown model")
|
||||
|
||||
defines += [f'TREZOR_BOARD=\\"boards/{board}\\"', ]
|
||||
sources += [f'embed/trezorhal/displays/{display}', ]
|
||||
env.get('ENV')['TREZOR_BOARD'] = board
|
||||
|
Loading…
Reference in New Issue
Block a user