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
This commit is contained in:
ІО-23 Шмуляр Олег 2025-02-15 14:43:54 +02:00
parent e696d2f52f
commit 9606a0b1ae
1 changed files with 4 additions and 4 deletions

View File

@ -97,6 +97,8 @@ uint8_t read_status(void)
void write_instruction_byte(uint8_t code) void write_instruction_byte(uint8_t code)
{ {
POLL_UNTIL_READY;
// make sure GPIOE is in correct mode // make sure GPIOE is in correct mode
GPIOE->MODER = 0x55504000; GPIOE->MODER = 0x55504000;
@ -110,12 +112,12 @@ void write_instruction_byte(uint8_t code)
GPIOE->ODR = (code & 0x0F) << 12; GPIOE->ODR = (code & 0x0F) << 12;
GPIOE->BSRR = DISPLAY_ENA; GPIOE->BSRR = DISPLAY_ENA;
GPIOE->BSRR = (DISPLAY_ENA << 16); GPIOE->BSRR = (DISPLAY_ENA << 16);
POLL_UNTIL_READY;
} }
void write_data_byte(uint8_t code) void write_data_byte(uint8_t code)
{ {
POLL_UNTIL_READY;
// make sure GPIOE is in correct mode // make sure GPIOE is in correct mode
GPIOE->MODER = 0x55504000; GPIOE->MODER = 0x55504000;
@ -129,8 +131,6 @@ void write_data_byte(uint8_t code)
GPIOE->ODR = ((code & 0x0F) << 12) | (DISPLAY_RS); GPIOE->ODR = ((code & 0x0F) << 12) | (DISPLAY_RS);
GPIOE->BSRR = DISPLAY_ENA; GPIOE->BSRR = DISPLAY_ENA;
GPIOE->BSRR = DISPLAY_ENA << 16; GPIOE->BSRR = DISPLAY_ENA << 16;
POLL_UNTIL_READY;
} }
/* USER CODE END 0 */ /* USER CODE END 0 */