2024-11-06 09:52 AM - last edited on 2024-11-06 10:23 AM by Andrew Neil
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.
2024-11-06 10:02 AM
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
}
2024-11-06 10:25 AM
Why does it matter what the library uses internally?
2024-11-06 10:26 AM
You missed the "does not use HAL" requirement, then!
2024-11-06 10:49 AM
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.
2024-11-06 03:21 PM
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.
2024-11-12 01:55 AM
hello @Falconfighter23 ,
You can use our ST7789 driver component, which includes both .c and .h files and replace every external function call with your own custom functions. This will ensure that the driver works seamlessly with your existing codebase. Then add the st7789.c and st7789.h files to your project directory ,Include the st7789.h header file in your main code or wherever you need to use the display functions and finally Initialize and configure the display in your main code.
Br