1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-22 23:48:12 +00:00

feat(core): expose display pixeldata accessors from C

This commit is contained in:
matejcik 2022-06-06 12:45:23 +02:00 committed by matejcik
parent 61482d0795
commit 57b12c2807
2 changed files with 23 additions and 9 deletions

View File

@ -30,11 +30,14 @@ const volatile uint8_t DISPLAY_ST7789V_INVERT_COLORS = 0;
#define DISPLAY_MEMORY_BASE 0x60000000 #define DISPLAY_MEMORY_BASE 0x60000000
#define DISPLAY_MEMORY_PIN 16 #define DISPLAY_MEMORY_PIN 16
#define CMD(X) (*((__IO uint8_t *)((uint32_t)(DISPLAY_MEMORY_BASE))) = (X)) __IO uint8_t *const DISPLAY_CMD_ADDRESS =
#define ADDR \ (__IO uint8_t *const)((uint32_t)DISPLAY_MEMORY_BASE);
(*((__IO uint8_t *)((uint32_t)(DISPLAY_MEMORY_BASE | \ __IO uint8_t *const DISPLAY_DATA_ADDRESS =
(1 << DISPLAY_MEMORY_PIN))))) (__IO uint8_t *const)((uint32_t)DISPLAY_MEMORY_BASE |
#define DATA(X) (ADDR) = (X) (1 << DISPLAY_MEMORY_PIN));
#define CMD(X) (*DISPLAY_CMD_ADDRESS = (X))
#define DATA(X) (*DISPLAY_DATA_ADDRESS = (X))
#define PIXELDATA(X) \ #define PIXELDATA(X) \
DATA((X) >> 8); \ DATA((X) >> 8); \
DATA((X)&0xFF) DATA((X)&0xFF)
@ -62,12 +65,13 @@ static uint32_t read_display_id(uint8_t command) {
volatile uint8_t c = 0; volatile uint8_t c = 0;
uint32_t id = 0; uint32_t id = 0;
CMD(command); CMD(command);
c = ADDR; // first returned value is a dummy value and should be discarded c = *DISPLAY_DATA_ADDRESS; // first returned value is a dummy value and
c = ADDR; // should be discarded
c = *DISPLAY_DATA_ADDRESS;
id |= (c << 16); id |= (c << 16);
c = ADDR; c = *DISPLAY_DATA_ADDRESS;
id |= (c << 8); id |= (c << 8);
c = ADDR; c = *DISPLAY_DATA_ADDRESS;
id |= c; id |= c;
return id; return id;
} }

View File

@ -140,4 +140,14 @@ void display_fade(int start, int end, int delay);
void display_utf8_substr(const char *buf_start, size_t buf_len, int char_off, void display_utf8_substr(const char *buf_start, size_t buf_len, int char_off,
int char_len, const char **out_start, int *out_len); int char_len, const char **out_start, int *out_len);
// pixeldata accessors
void display_set_window(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1);
void display_pixeldata(uint16_t c);
void display_pixeldata_dirty();
#if !(defined EMULATOR) && (defined TREZOR_MODEL_T)
extern volatile uint8_t *const DISPLAY_CMD_ADDRESS;
extern volatile uint8_t *const DISPLAY_DATA_ADDRESS;
#endif
#endif #endif