/** * \brief ILI9488 Read Ext registers for SPI/SMC mode. * \param command Command to be sent * \param size Size of buffer * \returns Ext register value. */ uint32_t ILI9488ReadExtReg(uint16_t cmd,uint32_t size) { uint32_t value=0; #if !defined(BOARD_LCD_SMC) uint32_t shift_cnt = size-1; uint16_t nSpiCnt = 0x81; uint16_t def_val = 0; if (size > 4) return ILI9488_ERROR_DMA_SIZE; while(size > 0) { ILI9488_WriteReg(ILI9488_CMD_SPI_READ_SETTINGS,&nSpiCnt,1); ILI9488_SendCmd(cmd); ILI9488DmaRxTransfer( paramBuf,2); while(!ili9488DmaCtl.rxDone); ili9488DmaCtl.rxDone = 0; ILI9488_WriteReg(ILI9488_CMD_SPI_READ_SETTINGS,&def_val,1); value |= (paramBuf[1]&0xFF)<<(shift_cnt << 3); nSpiCnt++; shift_cnt--; size--; } #else value = ILI9488ReadReg(cmd,size); #endif return value; }
/** * \brief Draw a pixel on LCD with given color, DMA not used * \param x X-coordinate of pixel. * \param y Y-coordinate of pixel. * \param color Pixel color. */ void ILI9488_SetPixelColor(uint32_t x, uint32_t y, uint32_t color) { uint32_t i; /* Set Horizontal Address Start Position */ ILI9488_SendCmd(ILI9488_CMD_COLUMN_ADDRESS_SET); PIO_Set(&lcd_spi_cds_pin); SPI_Write(ILI9488_SPI, SMC_EBI_LCD_CS, get_8b_to_16b(x)); SPI_Write(ILI9488_SPI, SMC_EBI_LCD_CS, get_0b_to_8b(x)); x++; SPI_Write(ILI9488_SPI, SMC_EBI_LCD_CS, get_8b_to_16b(x)); SPI_Write(ILI9488_SPI, SMC_EBI_LCD_CS, get_0b_to_8b(x)); for (i = 0; i < 0x18; i++); ILI9488_SendCmd(ILI9488_CMD_NOP); /* Set Horizontal Address End Position */ ILI9488_SendCmd(ILI9488_CMD_PAGE_ADDRESS_SET); PIO_Set(&lcd_spi_cds_pin); SPI_Write(ILI9488_SPI, SMC_EBI_LCD_CS, get_8b_to_16b(y)); SPI_Write(ILI9488_SPI, SMC_EBI_LCD_CS, get_0b_to_8b(y)); y++; SPI_Write(ILI9488_SPI, SMC_EBI_LCD_CS, get_8b_to_16b(y)); SPI_Write(ILI9488_SPI, SMC_EBI_LCD_CS, get_0b_to_8b(y)); for (i = 0; i < 0x18; i++); ILI9488_SendCmd(ILI9488_CMD_NOP); /* Set Color */ ILI9488_SendCmd(ILI9488_CMD_MEMORY_WRITE); PIO_Set(&lcd_spi_cds_pin); SPI_Write(ILI9488_SPI, SMC_EBI_LCD_CS, get_16b_to_24b(color)); SPI_Write(ILI9488_SPI, SMC_EBI_LCD_CS, get_8b_to_16b(color)); SPI_Write(ILI9488_SPI, SMC_EBI_LCD_CS, get_0b_to_8b(color)); for (i = 0; i < 0x18; i++); }
/** * \brief ILI9488 Read registers for SPI/SMC mode. * \param command Command to be sent * \param size Size of parameters * \returns register value. */ uint32_t ILI9488ReadReg(uint16_t cmd,uint32_t size) { uint32_t i; uint32_t value = 0; uint32_t *ptr; uint32_t shift_cnt = size-1; if (size > 4) return ILI9488_ERROR_DMA_SIZE; ILI9488_SendCmd(cmd); ILI9488DmaRxTransfer(paramBuf, size+1); while(!ili9488DmaCtl.rxDone); ili9488DmaCtl.rxDone = 0; ptr = ¶mBuf[1]; for(i = 1; i < size+1; i++) { value |= (*ptr&0xFF)<<(shift_cnt << 3); ptr++; shift_cnt--; } return value; }
/** * \brief ILI9488 Write register for SPI/SMC mode. * \param command Command to be sent * \param pTxBuffer Point to tx buffer contains parameters * \param bufSize Size of buffer * \returns 0 if the xDMA transfer successfully; otherwise returns ILI9488_DMA_ERROR_XXX. */ void ILI9488_WriteReg(uint16_t command, uint16_t* pTxBuffer, uint32_t bufSize) { ILI9488_SendCmd(command); if(bufSize == 0) return; ILI9488DmaTxTransfer(pTxBuffer,bufSize); }