cancel
Showing results for 
Search instead for 
Did you mean: 

2.0" 320x240 Color IPS TFT using ST7789 on STM32U5 without HAL

Falconfighter23
Visitor

Hey, 

I am trying to find drivers for a 320x240 adafruit display that work on the STM32U5 without using the HAL. I cannot seem to find anyone who has a ST7789 driver that does not use the HAL. Have any of you used the ST7789 with the STM32U5? Any help would be appreciated. Thanks.

5 REPLIES 5
liaifat85
Senior III

You can try this way:

#define ST7789_DC_PIN     // Define as per your setup
#define ST7789_CS_PIN     // Define as per your setup

void spi_init(void) {
    // Configure SPI registers for STM32U5
}

void st7789_writeCommand(uint8_t cmd) {
    // Set D/C pin to low for command
    GPIO_WritePin(ST7789_DC_PIN, GPIO_PIN_RESET);
    // Pull CS low to select the device
    GPIO_WritePin(ST7789_CS_PIN, GPIO_PIN_RESET);
    // Write command over SPI
    SPI_WriteData(cmd);
    // Pull CS high to release the device
    GPIO_WritePin(ST7789_CS_PIN, GPIO_PIN_SET);
}

void st7789_writeData(uint8_t data) {
    // Set D/C pin high for data
    GPIO_WritePin(ST7789_DC_PIN, GPIO_PIN_SET);
    // Pull CS low to select the device
    GPIO_WritePin(ST7789_CS_PIN, GPIO_PIN_RESET);
    // Write data over SPI
    SPI_WriteData(data);
    // Pull CS high to release the device
    GPIO_WritePin(ST7789_CS_PIN, GPIO_PIN_SET);
}

void st7789_init(void) {
    st7789_writeCommand(0x01); // Software Reset
    delay_ms(150);
    st7789_writeCommand(0x11); // Sleep Out
    delay_ms(500);
    st7789_writeCommand(0x3A); // Set Color Mode
    st7789_writeData(0x55);    // 16-bit color
    st7789_writeCommand(0x29); // Display On
}

 

Andrew Neil
Evangelist III

Why does it matter what the library uses internally?

You missed the "does not use HAL" requirement, then!

The project I am working on is done without the HAL and I have not ever used the HAL. It would be very difficult to edit the whole project to work with the HAL.

You don't have to change the rest of the project.

There is no problem to have just the library using HAL while none of the rest of the project does.