Esempio n. 1
0
/**
 * \brief Sets the orientation of the display data
 *
 * Configures the display for a given orientation, including mirroring and/or
 * screen rotation.
 *
 * \param flags Orientation flags to use, see \ref ILI9341_FLIP_X, \ref ILI9341_FLIP_Y
 *        and \ref ILI9341_SWITCH_XY.
 */
void ili9341_set_orientation(uint8_t flags)
{
	uint8_t madctl = 0x48;

	/* Pretend the display is in landscape mode by default to match other display drivers */
	flags ^= ILI9341_SWITCH_XY | ILI9341_FLIP_X;

	if (flags & ILI9341_FLIP_X) {
		madctl &= ~(1 << 6);
	}

	if (flags & ILI9341_FLIP_Y) {
		madctl |= 1 << 7;
	}

	if (flags & ILI9341_SWITCH_XY) {
		madctl |= 1 << 5;
	}

	ili9341_send_command(ILI9341_CMD_MEMORY_ACCESS_CONTROL);
	ili9341_send_byte(madctl);
	ili9341_wait_for_send_done();
	ili9341_deselect_chip();
}
/**
 * \internal
 * \brief Initialize the hardware interface to the controller
 *
 * This will initialize the module used for communication with the controller.
 * Currently supported interfaces by this component driver are the SPI
 * interface through either the SPI module in master mode or the USART in
 * Master SPI mode.  Configuration must be done in the associated
 * conf_ili9341.h file.
 */
static void ili9341_interface_init(void)
{
#if defined(CONF_ILI9341_USART_SPI) || defined(CONF_ILI9341_SPI)
	spi_flags_t spi_flags = SPI_MODE_0;
	board_spi_select_id_t spi_select_id = 0;
#else
	#error Interface for ILI9341 has not been selected or interface not\
	supported, please configure component driver using the conf_ili9341.h\
	file!
#endif

#if defined(CONF_ILI9341_USART_SPI)
	struct usart_spi_device device = {
		.id = 0,
	};

	usart_spi_init(CONF_ILI9341_USART_SPI);
	usart_spi_setup_device(CONF_ILI9341_USART_SPI, &device, spi_flags,
			CONF_ILI9341_CLOCK_SPEED, spi_select_id);

#elif defined(CONF_ILI9341_SPI)
	struct spi_device device = {
		.id = 0,
	};

	spi_master_init(CONF_ILI9341_SPI);
	spi_master_setup_device(CONF_ILI9341_SPI, &device, spi_flags,
			CONF_ILI9341_CLOCK_SPEED, spi_select_id);
	spi_enable(CONF_ILI9341_SPI);

#  if UC3
	spi_set_chipselect(CONF_ILI9341_SPI, ~(1 << 0));

#    if defined(ILI9341_DMA_ENABLED)
	sysclk_enable_peripheral_clock(&AVR32_PDCA);
#    endif
#  endif

	/* Send one dummy byte for the spi_is_tx_ok() to work as expected */
	spi_write_single(CONF_ILI9341_SPI, 0);
#endif
}

/**
 * \internal
 * \brief Initialize all the display registers
 *
 * This function will set up all the internal registers according the the
 * manufacturer's description.
 */
static void ili9341_controller_init_registers(void)
{
	ili9341_send_command(ILI9341_CMD_POWER_CONTROL_A);
	ili9341_send_byte(0x39);
	ili9341_send_byte(0x2C);
	ili9341_send_byte(0x00);
	ili9341_send_byte(0x34);
	ili9341_send_byte(0x02);
	ili9341_wait_for_send_done();
	ili9341_deselect_chip();

	ili9341_send_command(ILI9341_CMD_POWER_CONTROL_B);
	ili9341_send_byte(0x00);
	ili9341_send_byte(0xAA);
	ili9341_send_byte(0XB0);
	ili9341_wait_for_send_done();
	ili9341_deselect_chip();

	ili9341_send_command(ILI9341_CMD_PUMP_RATIO_CONTROL);
	ili9341_send_byte(0x30);
	ili9341_wait_for_send_done();
	ili9341_deselect_chip();

	ili9341_send_command(ILI9341_CMD_POWER_CONTROL_1);
	ili9341_send_byte(0x25);
	ili9341_wait_for_send_done();
	ili9341_deselect_chip();

	ili9341_send_command(ILI9341_CMD_POWER_CONTROL_2);
	ili9341_send_byte(0x11);
	ili9341_wait_for_send_done();
	ili9341_deselect_chip();

	ili9341_send_command(ILI9341_CMD_VCOM_CONTROL_1);
	ili9341_send_byte(0x5C);
	ili9341_send_byte(0x4C);
	ili9341_wait_for_send_done();
	ili9341_deselect_chip();

	ili9341_send_command(ILI9341_CMD_VCOM_CONTROL_2);
	ili9341_send_byte(0x94);
	ili9341_wait_for_send_done();
	ili9341_deselect_chip();

	ili9341_send_command(ILI9341_CMD_DRIVER_TIMING_CONTROL_A);
	ili9341_send_byte(0x85);
	ili9341_send_byte(0x01);
	ili9341_send_byte(0x78);
	ili9341_wait_for_send_done();
	ili9341_deselect_chip();

	ili9341_send_command(ILI9341_CMD_DRIVER_TIMING_CONTROL_B);
	ili9341_send_byte(0x00);
	ili9341_send_byte(0x00);
	ili9341_wait_for_send_done();
	ili9341_deselect_chip();

	ili9341_send_command(ILI9341_CMD_COLMOD_PIXEL_FORMAT_SET);
	ili9341_send_byte(0x05);
	ili9341_wait_for_send_done();
	ili9341_deselect_chip();

	ili9341_set_orientation(0);
	ili9341_set_limits(0, 0, ILI9341_DEFAULT_WIDTH,
			ILI9341_DEFAULT_HEIGHT);
}

/**
 * \internal
 * \brief Send display commands to exit standby mode
 *
 * This function is used to exit the display standby mode, which is the default
 * mode after a reset signal to the display.
 */
static void ili9341_exit_standby(void)
{
	ili9341_send_command(ILI9341_CMD_SLEEP_OUT);
	ili9341_deselect_chip();
	delay_ms(150);
	ili9341_send_command(ILI9341_CMD_DISPLAY_ON);
	ili9341_deselect_chip();
}
/**
 * \brief Set a given number of pixels to the same color
 *
 * Use this function to write a certain number of pixels to the same color
 * within a set limit.
 *
 * Limits have to be set prior to calling this function, e.g.:
 * \code
 * ili9341_set_top_left_limit(0, 0);
 * ili9341_set_bottom_right_limit(320, 240);
 * ...
 * \endcode
 *
 * \param color The color to write to the display
 * \param count The number of pixels to write with this color
 */
void ili9341_duplicate_pixel(const ili9341_color_t color, uint32_t count)
{
	/* Sanity check to make sure that the pixel count is not zero */
	Assert(count > 0);

	ili9341_send_command(ILI9341_CMD_MEMORY_WRITE);

#if defined(ILI9341_DMA_ENABLED)
	ili9341_color_t chunk_buf[ILI9341_DMA_CHUNK_SIZE];
	uint32_t chunk_len;

#  if SAM
	Pdc *SPI_DMA = spi_get_pdc_base(CONF_ILI9341_SPI);
	pdc_packet_t spi_pdc_data;

	pdc_enable_transfer(SPI_DMA, PERIPH_PTCR_TXTEN);
	spi_pdc_data.ul_addr = (uint32_t)chunk_buf;
#  elif UC3
	pdca_set_transfer_size(CONF_ILI9341_PDCA_CHANNEL,
			PDCA_TRANSFER_SIZE_BYTE);
	pdca_set_peripheral_select(CONF_ILI9341_PDCA_CHANNEL,
			CONF_ILI9341_PDCA_PID);
#  endif

	for (uint32_t i = 0; i < ILI9341_DMA_CHUNK_SIZE; i++) {
		chunk_buf[i] = le16_to_cpu(color);
	}

	while (count)
	{
		chunk_len = min(ILI9341_DMA_CHUNK_SIZE, count);

		ili9341_wait_for_send_done();

#  if SAM
		spi_pdc_data.ul_size = (uint32_t)sizeof(ili9341_color_t) * chunk_len;
		pdc_tx_init(SPI_DMA, NULL, &spi_pdc_data);
#  elif UC3
		pdca_reload_channel(CONF_ILI9341_PDCA_CHANNEL, chunk_buf,
				(uint32_t)sizeof(ili9341_color_t) * chunk_len);
		pdca_enable(CONF_ILI9341_PDCA_CHANNEL);
#  endif

		count -= chunk_len;
	}

	ili9341_wait_for_send_done();
	ili9341_deselect_chip();

#  if SAM
	pdc_disable_transfer(SPI_DMA, PERIPH_PTCR_TXTEN);
#  elif UC3
	pdca_disable(CONF_ILI9341_PDCA_CHANNEL);
#  endif
#else
	while (count--) {
		ili9341_send_byte(color);
		ili9341_send_byte(color >> 8);
	}

	ili9341_wait_for_send_done();
	ili9341_deselect_chip();
#endif
}
/**
 * \brief Copy pixels from SRAM to the screen
 *
 * Used to copy a large quantitative of data to the screen in one go.
 *
 * Limits have to be set prior to calling this function, e.g.:
 * \code
 * ili9341_set_top_left_limit(0, 0);
 * ili9341_set_bottom_right_limit(320, 240);
 * ...
 * \endcode
 *
 * \param pixels Pointer to the pixel data
 * \param count Number of pixels to copy to the screen
 */
void ili9341_copy_pixels_to_screen(const ili9341_color_t *pixels, uint32_t count)
{
	const ili9341_color_t *pixel = pixels;

	/* Sanity check to make sure that the pixel count is not zero */
	Assert(count > 0);

	ili9341_send_command(ILI9341_CMD_MEMORY_WRITE);

#if defined(ILI9341_DMA_ENABLED)
	ili9341_color_t chunk_buf[ILI9341_DMA_CHUNK_SIZE];
	uint32_t chunk_len;

#  if SAM
	Pdc *SPI_DMA = spi_get_pdc_base(CONF_ILI9341_SPI);
	pdc_packet_t spi_pdc_data;

	pdc_enable_transfer(SPI_DMA, PERIPH_PTCR_TXTEN);
	spi_pdc_data.ul_addr = (uint32_t)chunk_buf;
#  elif UC3
	pdca_set_transfer_size(CONF_ILI9341_PDCA_CHANNEL,
			PDCA_TRANSFER_SIZE_BYTE);
	pdca_set_peripheral_select(CONF_ILI9341_PDCA_CHANNEL,
			CONF_ILI9341_PDCA_PID);
#  endif

	while (count)
	{
		/* We need to copy out the data to send in chunks into RAM, as the PDC
		 * does not allow FLASH->Peripheral transfers */
		chunk_len = min(ILI9341_DMA_CHUNK_SIZE, count);

		/* Wait for pending transfer to complete */
		ili9341_wait_for_send_done();

		for (uint32_t i = 0; i < chunk_len; i++) {
			chunk_buf[i] = le16_to_cpu(pixel[i]);
		}

#  if SAM
		spi_pdc_data.ul_size = (uint32_t)sizeof(ili9341_color_t) * chunk_len;
		pdc_tx_init(SPI_DMA, NULL, &spi_pdc_data);
#  elif UC3
		pdca_reload_channel(CONF_ILI9341_PDCA_CHANNEL, chunk_buf,
				(uint32_t)sizeof(ili9341_color_t) * chunk_len);
		pdca_enable(CONF_ILI9341_PDCA_CHANNEL);
#  endif

		pixel += chunk_len;
		count -= chunk_len;
	}

	ili9341_wait_for_send_done();
	ili9341_deselect_chip();

#  if SAM
	pdc_disable_transfer(SPI_DMA, PERIPH_PTCR_TXTEN);
#  elif UC3
	pdca_disable(CONF_ILI9341_PDCA_CHANNEL);
#  endif
#else
	while (count--) {
		ili9341_send_byte(*pixel);
		ili9341_send_byte(*pixel >> 8);

		pixel++;
	}

	ili9341_wait_for_send_done();
	ili9341_deselect_chip();
#endif
}
Esempio n. 5
0
/**
 * \internal
 * \brief Initialize the hardware interface to the controller
 *
 * This will initialize the module used for communication with the controller.
 * Currently supported interfaces by this component driver are the SPI
 * interface through either the SPI module in master mode or the USART in
 * Master SPI mode.  Configuration must be done in the associated
 * conf_ili9341.h file.
 */
static void ili9341_interface_init(void)
{
#if defined(CONF_ILI9341_USART_SPI) || defined(CONF_ILI9341_SPI)
	spi_flags_t spi_flags = SPI_MODE_0;
	board_spi_select_id_t spi_select_id = 0;
#else
	#error Interface for ILI9341 has not been selected or interface not\
	supported, please configure component driver using the conf_ili9341.h\
	file!
#endif

#if defined(CONF_ILI9341_USART_SPI)
	struct usart_spi_device device = {
		.id = 0,
	};

	usart_spi_init(CONF_ILI9341_USART_SPI);
	usart_spi_setup_device(CONF_ILI9341_USART_SPI, &device, spi_flags,
			CONF_ILI9341_CLOCK_SPEED, spi_select_id);

#elif defined(CONF_ILI9341_SPI)
	struct spi_device device = {
		.id = 0,
	};

	spi_master_init(CONF_ILI9341_SPI);
	spi_master_setup_device(CONF_ILI9341_SPI, &device, spi_flags,
			CONF_ILI9341_CLOCK_SPEED, spi_select_id);
	spi_enable(CONF_ILI9341_SPI);

#  if UC3
	spi_set_chipselect(CONF_ILI9341_SPI, ~(1 << 0));

#    if defined(ILI9341_DMA_ENABLED)
	sysclk_enable_peripheral_clock(&AVR32_PDCA);
#    endif
#  endif

	/* Send one dummy byte for the spi_is_tx_ok() to work as expected */
	spi_write_single(CONF_ILI9341_SPI, 0);
#endif
}

/**
 * \internal
 * \brief Initialize all the display registers
 *
 * This function will set up all the internal registers according the the
 * manufacturer's description.
 */
static void ili9341_controller_init_registers(void)
{
	ili9341_send_command(0xEF);
	ili9341_send_byte(0x03);
	ili9341_send_byte(0x80);
	ili9341_send_byte(0x02);
	ili9341_wait_for_send_done();
	ili9341_deselect_chip();

	ili9341_send_command(0xCF);
	ili9341_send_byte(0x00);
	ili9341_send_byte(0xC1);
	ili9341_send_byte(0x30);
	ili9341_wait_for_send_done();
	ili9341_deselect_chip();

	ili9341_send_command(0xED);
	ili9341_send_byte(0x64);
	ili9341_send_byte(0x03);
	ili9341_send_byte(0x12);
	ili9341_send_byte(0x81);
	ili9341_wait_for_send_done();
	ili9341_deselect_chip();

	ili9341_send_command(0xE8);
	ili9341_send_byte(0x85);
	ili9341_send_byte(0x00);
	ili9341_send_byte(0x78);
	ili9341_wait_for_send_done();
	ili9341_deselect_chip();

	ili9341_send_command(0xCB);
	ili9341_send_byte(0x39);
	ili9341_send_byte(0x2C);
	ili9341_send_byte(0x00);
	ili9341_send_byte(0x34);
	ili9341_send_byte(0x02);
	ili9341_wait_for_send_done();
	ili9341_deselect_chip();

	ili9341_send_command(0xF7);
	ili9341_send_byte(0x20);
	ili9341_wait_for_send_done();
	ili9341_deselect_chip();

	ili9341_send_command(0xEA);
	ili9341_send_byte(0x00);
	ili9341_send_byte(0x00);
	ili9341_wait_for_send_done();
	ili9341_deselect_chip();

	ili9341_send_command(0xC0);
	ili9341_send_byte(0x23);
	ili9341_wait_for_send_done();
	ili9341_deselect_chip();

	ili9341_send_command(0xC1);
	ili9341_send_byte(0x10);
	ili9341_wait_for_send_done();
	ili9341_deselect_chip();

	ili9341_send_command(0xC5);
	ili9341_send_byte(0x3E);
	ili9341_send_byte(0x28);
	ili9341_wait_for_send_done();
	ili9341_deselect_chip();

	ili9341_send_command(0xC7);
	ili9341_send_byte(0x86);
	ili9341_wait_for_send_done();
	ili9341_deselect_chip();

	ili9341_send_command(0x36);
	ili9341_send_byte(0x48);
	ili9341_wait_for_send_done();
	ili9341_deselect_chip();

	ili9341_send_command(0x3A);
	ili9341_send_byte(0x55);
	ili9341_wait_for_send_done();
	ili9341_deselect_chip();

	ili9341_send_command(0xB1);
	ili9341_send_byte(0x00);
	ili9341_send_byte(0x18);
	ili9341_wait_for_send_done();
	ili9341_deselect_chip();

	ili9341_send_command(0xB6);
	ili9341_send_byte(0x08);
	ili9341_send_byte(0x82);
	ili9341_send_byte(0x27);
	ili9341_wait_for_send_done();
	ili9341_deselect_chip();

	ili9341_send_command(0xF2);
	ili9341_send_byte(0x00);
	ili9341_wait_for_send_done();
	ili9341_deselect_chip();

	ili9341_send_command(0x26);
	ili9341_send_byte(0x01);
	ili9341_wait_for_send_done();
	ili9341_deselect_chip();

	ili9341_send_command(0xE0);
	ili9341_send_byte(0x0F);
	ili9341_send_byte(0x31);
	ili9341_send_byte(0x2B);
	ili9341_send_byte(0x0C);
	ili9341_send_byte(0x0E);
	ili9341_send_byte(0x08);
	ili9341_send_byte(0x4E);
	ili9341_send_byte(0xF1);
	ili9341_send_byte(0x37);
	ili9341_send_byte(0x07);
	ili9341_send_byte(0x10);
	ili9341_send_byte(0x03);
	ili9341_send_byte(0x0E);
	ili9341_send_byte(0x09);
	ili9341_send_byte(0x00);
	ili9341_wait_for_send_done();
	ili9341_deselect_chip();

	ili9341_send_command(0xE1);
	ili9341_send_byte(0x00);
	ili9341_send_byte(0x0E);
	ili9341_send_byte(0x14);
	ili9341_send_byte(0x03);
	ili9341_send_byte(0x11);
	ili9341_send_byte(0x07);
	ili9341_send_byte(0x31);
	ili9341_send_byte(0xC1);
	ili9341_send_byte(0x48);
	ili9341_send_byte(0x08);
	ili9341_send_byte(0x0F);
	ili9341_send_byte(0x0C);
	ili9341_send_byte(0x31);
	ili9341_send_byte(0x36);
	ili9341_send_byte(0x0F);
	ili9341_wait_for_send_done();
	ili9341_deselect_chip();




	// ili9341_send_command(ILI9341_CMD_POWER_CONTROL_A);
	// ili9341_send_byte(0x39);
	// ili9341_send_byte(0x2C);
	// ili9341_send_byte(0x00);
	// ili9341_send_byte(0x34);
	// ili9341_send_byte(0x02);
	// ili9341_wait_for_send_done();
	// ili9341_deselect_chip();

	// ili9341_send_command(ILI9341_CMD_POWER_CONTROL_B);
	// ili9341_send_byte(0x00);
	// ili9341_send_byte(0xAA);
	// ili9341_send_byte(0XB0);
	// ili9341_wait_for_send_done();
	// ili9341_deselect_chip();

	// ili9341_send_command(ILI9341_CMD_PUMP_RATIO_CONTROL);
	// ili9341_send_byte(0x30);
	// ili9341_wait_for_send_done();
	// ili9341_deselect_chip();

	// ili9341_send_command(ILI9341_CMD_POWER_CONTROL_1);
	// ili9341_send_byte(0x25);
	// ili9341_wait_for_send_done();
	// ili9341_deselect_chip();

	// ili9341_send_command(ILI9341_CMD_POWER_CONTROL_2);
	// ili9341_send_byte(0x11);
	// ili9341_wait_for_send_done();
	// ili9341_deselect_chip();

	// ili9341_send_command(ILI9341_CMD_VCOM_CONTROL_1);
	// ili9341_send_byte(0x5C);
	// ili9341_send_byte(0x4C);
	// ili9341_wait_for_send_done();
	// ili9341_deselect_chip();

	// ili9341_send_command(ILI9341_CMD_VCOM_CONTROL_2);
	// ili9341_send_byte(0x94);
	// ili9341_wait_for_send_done();
	// ili9341_deselect_chip();

	// ili9341_send_command(ILI9341_CMD_DRIVER_TIMING_CONTROL_A);
	// ili9341_send_byte(0x85);
	// ili9341_send_byte(0x01);
	// ili9341_send_byte(0x78);
	// ili9341_wait_for_send_done();
	// ili9341_deselect_chip();

	// ili9341_send_command(ILI9341_CMD_DRIVER_TIMING_CONTROL_B);
	// ili9341_send_byte(0x00);
	// ili9341_send_byte(0x00);
	// ili9341_wait_for_send_done();
	// ili9341_deselect_chip();

	// ili9341_send_command(ILI9341_CMD_COLMOD_PIXEL_FORMAT_SET);
	// ili9341_send_byte(0x05);
	// ili9341_wait_for_send_done();
	// ili9341_deselect_chip();

	ili9341_set_orientation(0);
	ili9341_set_limits(0, 0, ILI9341_DEFAULT_WIDTH,
			ILI9341_DEFAULT_HEIGHT);
}


void ili9341_enter_standby(void) {
	ili9341_send_command(ILI9341_CMD_ENTER_SLEEP_MODE);
	ili9341_deselect_chip();
} 
Esempio n. 6
0
File: ili9341.c Progetto: raphui/rnk
void ili9341_init_lcd(void)
{
	ili9341_send_data(0xC3);
	ili9341_send_data(0x08);
	ili9341_send_data(0x50);
	ili9341_send_command(ILI9341_POWERB);
	ili9341_send_data(0x00);
	ili9341_send_data(0xC1);
	ili9341_send_data(0x30);
	ili9341_send_command(ILI9341_POWER_SEQ);
	ili9341_send_data(0x64);
	ili9341_send_data(0x03);
	ili9341_send_data(0x12);
	ili9341_send_data(0x81);
	ili9341_send_command(ILI9341_DTCA);
	ili9341_send_data(0x85);
	ili9341_send_data(0x00);
	ili9341_send_data(0x78);
	ili9341_send_command(ILI9341_POWERA);
	ili9341_send_data(0x39);
	ili9341_send_data(0x2C);
	ili9341_send_data(0x00);
	ili9341_send_data(0x34);
	ili9341_send_data(0x02);
	ili9341_send_command(ILI9341_PRC);
	ili9341_send_data(0x20);
	ili9341_send_command(ILI9341_DTCB);
	ili9341_send_data(0x00);
	ili9341_send_data(0x00);
	ili9341_send_command(ILI9341_FRC);
	ili9341_send_data(0x00);
	ili9341_send_data(0x1B);
	ili9341_send_command(ILI9341_DFC);
	ili9341_send_data(0x0A);
	ili9341_send_data(0xA2);
	ili9341_send_command(ILI9341_POWER1);
	ili9341_send_data(0x10);
	ili9341_send_command(ILI9341_POWER2);
	ili9341_send_data(0x10);
	ili9341_send_command(ILI9341_VCOM1);
	ili9341_send_data(0x45);
	ili9341_send_data(0x15);
	ili9341_send_command(ILI9341_VCOM2);
	ili9341_send_data(0x90);
	ili9341_send_command(ILI9341_MAC);
	ili9341_send_data(0xC8);
	ili9341_send_command(ILI9341_3GAMMA_EN);
	ili9341_send_data(0x00);
	ili9341_send_command(ILI9341_RGB_INTERFACE);
	ili9341_send_data(0xC2);
	ili9341_send_command(ILI9341_DFC);
	ili9341_send_data(0x0A);
	ili9341_send_data(0xA7);
	ili9341_send_data(0x27);
	ili9341_send_data(0x04);

	ili9341_send_command(ILI9341_COLUMN_ADDR);
	ili9341_send_data(0x00);
	ili9341_send_data(0x00);
	ili9341_send_data(0x00);
	ili9341_send_data(0xEF);

	ili9341_send_command(ILI9341_PAGE_ADDR);
	ili9341_send_data(0x00);
	ili9341_send_data(0x00);
	ili9341_send_data(0x01);
	ili9341_send_data(0x3F);
	ili9341_send_command(ILI9341_INTERFACE);
	ili9341_send_data(0x01);
	ili9341_send_data(0x00);
	ili9341_send_data(0x06);

	ili9341_send_command(ILI9341_GRAM);
	usleep(1000000);
	ili9341_send_command(ILI9341_GAMMA);
	ili9341_send_data(0x01);

	ili9341_send_command(ILI9341_PGAMMA);
	ili9341_send_data(0x0F);
	ili9341_send_data(0x29);
	ili9341_send_data(0x24);
	ili9341_send_data(0x0C);
	ili9341_send_data(0x0E);
	ili9341_send_data(0x09);
	ili9341_send_data(0x4E);
	ili9341_send_data(0x78);
	ili9341_send_data(0x3C);
	ili9341_send_data(0x09);
	ili9341_send_data(0x13);
	ili9341_send_data(0x05);
	ili9341_send_data(0x17);
	ili9341_send_data(0x11);
	ili9341_send_data(0x00);
	ili9341_send_command(ILI9341_NGAMMA);
	ili9341_send_data(0x00);
	ili9341_send_data(0x16);
	ili9341_send_data(0x1B);
	ili9341_send_data(0x04);
	ili9341_send_data(0x11);
	ili9341_send_data(0x07);
	ili9341_send_data(0x31);
	ili9341_send_data(0x33);
	ili9341_send_data(0x42);
	ili9341_send_data(0x05);
	ili9341_send_data(0x0C);
	ili9341_send_data(0x0A);
	ili9341_send_data(0x28);
	ili9341_send_data(0x2F);
	ili9341_send_data(0x0F);

	ili9341_send_command(ILI9341_SLEEP_OUT);
	usleep(1000000);
	ili9341_send_command(ILI9341_DISPLAY_ON);

	ili9341_send_command(ILI9341_GRAM);
}
Esempio n. 7
0
static inline int ili9341_power_off(struct ili9341 *ili)
{
	ili9341_send_command(ili, ILI9341_DISPOFF); //Display on
	return 0;
}
Esempio n. 8
0
static inline int ili9341_init_chip(struct ili9341 *ili)
{
	int ret = 0;
#ifdef SCREEN_TEST
	int x,y;
#endif

	ili9341_reset(ili);

	ili9341_send_command(ili, 0xEF);
	ili9341_send_byte(ili, 0x03);
	ili9341_send_byte(ili, 0x80);
	ili9341_send_byte(ili, 0x02);
	ili9341_send_command(ili, 0xCF);
	ili9341_send_byte(ili, 0x00);
	ili9341_send_byte(ili, 0XC1);
	ili9341_send_byte(ili, 0X30);
	ili9341_send_command(ili, 0xED);
	ili9341_send_byte(ili, 0x64);
	ili9341_send_byte(ili, 0x03);
	ili9341_send_byte(ili, 0X12);
	ili9341_send_byte(ili, 0X81);
	ili9341_send_command(ili, 0xE8);
	ili9341_send_byte(ili, 0x85);
	ili9341_send_byte(ili, 0x00);
	ili9341_send_byte(ili, 0x78);
	ili9341_send_command(ili, 0xCB);
	ili9341_send_byte(ili, 0x39);
	ili9341_send_byte(ili, 0x2C);
	ili9341_send_byte(ili, 0x00);
	ili9341_send_byte(ili, 0x34);
	ili9341_send_byte(ili, 0x02);
	ili9341_send_command(ili, 0xF7);
	ili9341_send_byte(ili, 0x20);
	ili9341_send_command(ili, 0xEA);
	ili9341_send_byte(ili, 0x00);
	ili9341_send_byte(ili, 0x00);
	ili9341_send_command(ili, ILI9341_PWCTR1); //Power control
	ili9341_send_byte(ili, 0x23); //VRH[5:0]
	ili9341_send_command(ili, ILI9341_PWCTR2); //Power control
	ili9341_send_byte(ili, 0x10); //SAP[2:0];BT[3:0]
	ili9341_send_command(ili, ILI9341_VMCTR1); //VCM control
	ili9341_send_byte(ili, 0x3e); //¶Ô±È¶Èµ÷½Ú
	ili9341_send_byte(ili, 0x28);
	ili9341_send_command(ili, ILI9341_VMCTR2); //VCM control2
	ili9341_send_byte(ili, 0x86); //--
	ili9341_send_command(ili, ILI9341_MADCTL); // Memory Access Control
	ili9341_send_byte(ili, 0x48);
	ili9341_send_command(ili, ILI9341_PIXFMT);
	ili9341_send_byte(ili, 0x55);
	ili9341_send_command(ili, ILI9341_FRMCTR1);
	ili9341_send_byte(ili, 0x00);
	ili9341_send_byte(ili, 0x18);
	ili9341_send_command(ili, ILI9341_DFUNCTR); // Display Function Control
	ili9341_send_byte(ili, 0x08);
	ili9341_send_byte(ili, 0x82);
	ili9341_send_byte(ili, 0x27);
	ili9341_send_command(ili, 0xF2); // 3Gamma Function Disable
	ili9341_send_byte(ili, 0x00);
	ili9341_send_command(ili, ILI9341_GAMMASET); //Gamma curve selected
	ili9341_send_byte(ili, 0x01);
	ili9341_send_command(ili, ILI9341_GMCTRP1); //Set Gamma
	ili9341_send_byte(ili, 0x0F);
	ili9341_send_byte(ili, 0x31);
	ili9341_send_byte(ili, 0x2B);
	ili9341_send_byte(ili, 0x0C);
	ili9341_send_byte(ili, 0x0E);
	ili9341_send_byte(ili, 0x08);
	ili9341_send_byte(ili, 0x4E);
	ili9341_send_byte(ili, 0xF1);
	ili9341_send_byte(ili, 0x37);
	ili9341_send_byte(ili, 0x07);
	ili9341_send_byte(ili, 0x10);
	ili9341_send_byte(ili, 0x03);
	ili9341_send_byte(ili, 0x0E);
	ili9341_send_byte(ili, 0x09);
	ili9341_send_byte(ili, 0x00);
	ili9341_send_command(ili, ILI9341_GMCTRN1); //Set Gamma
	ili9341_send_byte(ili, 0x00);
	ili9341_send_byte(ili, 0x0E);
	ili9341_send_byte(ili, 0x14);
	ili9341_send_byte(ili, 0x03);
	ili9341_send_byte(ili, 0x11);
	ili9341_send_byte(ili, 0x07);
	ili9341_send_byte(ili, 0x31);
	ili9341_send_byte(ili, 0xC1);
	ili9341_send_byte(ili, 0x48);
	ili9341_send_byte(ili, 0x08);
	ili9341_send_byte(ili, 0x0F);
	ili9341_send_byte(ili, 0x0C);
	ili9341_send_byte(ili, 0x31);
	ili9341_send_byte(ili, 0x36);
	ili9341_send_byte(ili, 0x0F);
	ili9341_send_command(ili, ILI9341_SLPOUT); //Exit Sleep
	mdelay(120);
	
	ili9341_set_orientation(ili, ILI9341_SWITCH_XY | ILI9341_FLIP_X);
	ili9341_send_command(ili, ILI9341_DISPON); //Display on
	
#ifdef SCREEN_TEST
	ili9341_set_window(ili, 0, 0, ILI9341_TFTWIDTH, ILI9341_TFTHEIGHT);
	for(y=ILI9341_TFTHEIGHT; y>0; y--) {
		for(x=ILI9341_TFTWIDTH; x>0; x--) {
			ili9341_send_byte(ili, 0x55);
			ili9341_send_byte(ili, 0x55);
		}
	}
#endif
/*	if (ret != 0) {
		dev_err(ili->dev, "failed to initialise display\n");
		return ret;
	}*/

	ili->initialised = 1;
	return ret;
}