IlyaM Posted September 10, 2018 Report Share Posted September 10, 2018 Hey, I gonna use uGFX with ST7735, unfortunately there is no board_ST7735_template.h for this driver and I wrote my own: #ifndef GDISP_LLD_BOARD_H #define GDISP_LLD_BOARD_H #include "nrf_gpio.h" #include "nrf_drv_spi.h" #include "nrf_delay.h" #include "nrf_log.h" #include "app_error.h" #define GDISP_LLD_PIXELFORMAT GDISP_PIXELFORMAT_RGB565 #define LCD_SCK 29 #define LCD_MISO 22 #define LCD_MOSI 28 #define LCD_CS 24 #define LCD_DC 20 #define LCD_RST 23 //#define LCD_RW 6 #define SPI_INSTANCE 1 /**< SPI instance index. */ static const nrf_drv_spi_t spi = NRF_DRV_SPI_INSTANCE(SPI_INSTANCE); /**< SPI instance. */ nrf_drv_spi_config_t lcd_spi_config = NRF_DRV_SPI_DEFAULT_CONFIG; static volatile bool lcd_spi_xfer_done; /**< Flag used to indicate that SPI instance completed the transfer. */ void lcd_spi_event_handler(nrf_drv_spi_evt_t const * p_event) { lcd_spi_xfer_done = true; //NRF_LOG_DEBUG("spi transfer completed.\n"); } static GFXINLINE void init_board(GDisplay *g) { NRF_LOG_RAW_INFO("ST7735 init_board\n"); // setup pins nrf_gpio_cfg_output(LCD_CS); nrf_gpio_cfg_output(LCD_DC); nrf_gpio_cfg_output(LCD_RST); //nrf_gpio_cfg_output(LCD_RW); nrf_gpio_pin_write(LCD_CS, 1); //nrf_gpio_pin_write(LCD_RW, 1); // reset board nrf_gpio_pin_write(LCD_RST, 0); nrf_delay_ms(100); nrf_gpio_pin_write(LCD_RST, 1); // setup spi lcd_spi_config.miso_pin = LCD_MISO; lcd_spi_config.mosi_pin = LCD_MOSI; lcd_spi_config.sck_pin = LCD_SCK; lcd_spi_config.frequency = NRF_DRV_SPI_FREQ_8M; APP_ERROR_CHECK(nrf_drv_spi_init(&spi, &lcd_spi_config, lcd_spi_event_handler)); (void) g; } static GFXINLINE void post_init_board(GDisplay *g) { (void) g; } static GFXINLINE void setpin_reset(GDisplay *g, gBool state) { NRF_LOG_RAW_INFO("setpin_reset: %d\r\n", state); nrf_gpio_pin_write(LCD_RST, state); (void) g; (void) state; } static GFXINLINE void set_backlight(GDisplay *g, uint8_t percent) { (void) g; (void) percent; } static GFXINLINE void acquire_bus(GDisplay *g) { nrf_gpio_pin_write(LCD_CS, 0); (void) g; } static GFXINLINE void release_bus(GDisplay *g) { nrf_gpio_pin_write(LCD_CS, 1); (void) g; } static GFXINLINE void write_cmd(GDisplay *g, uint8_t cmd) { // dc low nrf_gpio_pin_write(LCD_DC, 0); lcd_spi_xfer_done = false; APP_ERROR_CHECK(nrf_drv_spi_transfer(&spi, &cmd, 1, NULL, 0)); //while (!lcd_spi_xfer_done){}; (void) g; (void) cmd; } static GFXINLINE void write_data(GDisplay *g, uint8_t data) { (void) g; (void) data; nrf_gpio_pin_write(LCD_DC, 1); lcd_spi_xfer_done = false; APP_ERROR_CHECK(nrf_drv_spi_transfer(&spi, &data, sizeof(data), NULL, 0)); //while (!lcd_spi_xfer_done){}; } static GFXINLINE void write_data_byte(GDisplay *g, uint8_t arg) { // dc high nrf_gpio_pin_write(LCD_DC, 1); lcd_spi_xfer_done = false; APP_ERROR_CHECK(nrf_drv_spi_transfer(&spi, &arg, 1, NULL, 0)); //while (!lcd_spi_xfer_done){}; (void) g; (void) arg; } static GFXINLINE uint16_t read_data(GDisplay *g) { (void) g; return 0; } #endif /* GDISP_LLD_BOARD_H */ nrf51 doesn't have systick and instead of this one I use RTC timer with frequency 32kHz, but when I compile it (without errors) I see nothing on my display and in the console output. if I comment out everything with uGFX I see console output, more over I have my own lib for ST7735 and it works fine. May I use uGFX without systick, I think it needs for display's backligh? Maybe someone had have an experience with this display and nrf51822? Link to comment Share on other sites More sharing options...
Joel Bodenmann Posted September 17, 2018 Report Share Posted September 17, 2018 Please excuse the late reply - I wanted to digg out some sources. We've plenty of people that use µGFX on nRF51 and nRF52 platforms. The nRF51 does have a systick. I've attached a GOS port and the corresponding systick handler implementation for an nRF51 port I made quite some time ago. In general: You might want to check whether the µGFX core runs before starting to use optional modules such as GDISP and GINPUT. You can have a look at the GOS demos - they allow you to check whether the µGFX core is working correctly without using the display code. ugfx_port.c gos_nrf5sdk11.c gos_nrf5sdk11.h Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now