How to use GFX with SPIM3?

Hello,

I'm testing the GFX example using nrf52840dk + ST7735.

It works fine but is very slow. Therefore, I referred to this article and tried to use the SPIM3 interface to transmit data.

After the modification, the screen does not work and no longer displays any patterns.

Here is the code I modified:

<sdk_config.h>

#ifndef NRFX_SPIM3_ENABLED
#define NRFX_SPIM3_ENABLED 1
#endif

#ifndef NRFX_SPIM_EXTENDED_ENABLED
#define NRFX_SPIM_EXTENDED_ENABLED 1
#endif

<st7735.h>

static const nrfx_spim_t spim = NRFX_SPIM_INSTANCE(ST7735_SPI_INSTANCE);  /**< SPI instance. */

static ret_code_t hardware_init(void)
{
    ret_code_t err_code;
	nrf_gpio_cfg_output(ST7735_DC_PIN);
	nrfx_spim_config_t spi_config = NRFX_SPIM_DEFAULT_CONFIG;

    spi_config.sck_pin  = ST7735_SCK_PIN;
    spi_config.miso_pin = ST7735_MISO_PIN;
    spi_config.mosi_pin = ST7735_MOSI_PIN;
    spi_config.ss_pin   = ST7735_SS_PIN;
	spi_config.frequency= NRF_SPIM_FREQ_32M;
	err_code = nrfx_spim_init(&spim, &spi_config, NULL, NULL);
        
	return err_code;
}

uint8_t *tx_bufs;
static inline void write_command(uint8_t c)
{
		uint32_t err_code;
		tx_bufs[0] = c;
		uint8_t m_length = 1;
		nrfx_spim_xfer_desc_t xfer_desc = NRFX_SPIM_XFER_TX(tx_bufs,m_length);
		err_code = nrfx_spim_xfer_dcx(&spim,&xfer_desc,NRF_DRV_SPI_FLAG_TX_POSTINC,1);
		APP_ERROR_CHECK(err_code);
}

static inline void write_data(uint8_t c)
{
		uint32_t err_code;
		tx_bufs[0] = c;
		uint8_t m_length = 1;
		nrfx_spim_xfer_desc_t xfer_desc = NRFX_SPIM_XFER_TX(tx_bufs,m_length);
		err_code = nrfx_spim_xfer_dcx(&spim,&xfer_desc,NRF_DRV_SPI_FLAG_TX_POSTINC,0);
		APP_ERROR_CHECK(err_code);
}

Is there anything else that needs to be modified?

Related