I can read from the driver using appropriate instructions. But i am not able to write to any of the registers. Please Help. I have attached the functions and datasheet.EPD-Controller-UC8156c-Datasheet-D0.7.pdf
We have used following functions -
uint8_t * UC8156_drv_spi(uint8_t byte) //Transfer and Receive data through spi
{
// Reset rx buffer and transfer done flag
memset(m_rx_buf, 0, m_rx_length);
spi_xfer_done = false;
m_tx_buf[0] = byte;
APP_ERROR_CHECK(nrf_drv_spi_transfer(&spi, m_tx_buf, m_tx_length, m_rx_buf, m_rx_length));
while (!spi_xfer_done)
{
__WFE();
}
NRF_LOG_FLUSH();
NRF_LOG_INFO("%x %x %x %x %x \n",m_rx_buf[0],m_rx_buf[1],m_rx_buf[2],m_rx_buf[3],m_rx_buf[4]);
return m_rx_buf;
}
void UC8156_drv_spi_write(uint8_t const * p_byte,int length)
{
// Reset rx buffer and transfer done flag
memset(m_rx_buf, 0, m_rx_length);
spi_xfer_done = false;
APP_ERROR_CHECK(nrf_drv_spi_transfer(&spi, p_byte, length, m_rx_buf, m_rx_length));
while (!spi_xfer_done)
{
__WFE();
}
NRF_LOG_FLUSH();
bsp_board_led_invert(BSP_BOARD_LED_0);
NRF_LOG_INFO("%x %x %x %x %x \n",m_rx_buf[0],m_rx_buf[1],m_rx_buf[2],m_rx_buf[3],m_rx_buf[4]);
}
void spi_write_command_1param(uint8_t command, uint8_t param1)
{
command &= ~0x80;
uint8_t m_array[2];
m_array[0] = command;
m_array[1] = param1;
UC8156_drv_spi(m_array[0]);
UC8156_drv_spi(m_array[1]);
}
uint8_t spi_read_command_1param(uint8_t command)
{ uint8_t * p_buff;
command |= 0x80;
p_buff = UC8156_drv_spi(command);
p_buff++;
uint8_t temp = *p_buff;
nrf_gpio_pin_write(SPI_SS_PIN,1);
return temp;
}
int main (){
spi_write_command_1param(0x01,0x01);
spi_read_command_1param(0x01);
}