From 9606a0b1ae36b7528e135e85c083c01fb9527208 Mon Sep 17 00:00:00 2001 From: hasslesstech Date: Sat, 15 Feb 2025 14:43:54 +0200 Subject: [PATCH] poll until ready before sending data, not after This change improves two aspects: - display will not receive instructions nor data until it is ready, even at startup when no previous commands have been sent - no time is wasted after writing instructions or data to the display --- Core/Src/main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Core/Src/main.c b/Core/Src/main.c index 6cf90e9..af28f1c 100644 --- a/Core/Src/main.c +++ b/Core/Src/main.c @@ -97,6 +97,8 @@ uint8_t read_status(void) void write_instruction_byte(uint8_t code) { + POLL_UNTIL_READY; + // make sure GPIOE is in correct mode GPIOE->MODER = 0x55504000; @@ -110,12 +112,12 @@ void write_instruction_byte(uint8_t code) GPIOE->ODR = (code & 0x0F) << 12; GPIOE->BSRR = DISPLAY_ENA; GPIOE->BSRR = (DISPLAY_ENA << 16); - - POLL_UNTIL_READY; } void write_data_byte(uint8_t code) { + POLL_UNTIL_READY; + // make sure GPIOE is in correct mode GPIOE->MODER = 0x55504000; @@ -129,8 +131,6 @@ void write_data_byte(uint8_t code) GPIOE->ODR = ((code & 0x0F) << 12) | (DISPLAY_RS); GPIOE->BSRR = DISPLAY_ENA; GPIOE->BSRR = DISPLAY_ENA << 16; - - POLL_UNTIL_READY; } /* USER CODE END 0 */