picofuse

Data Structures | Macros | Typedefs
ILI9341

This module provides a device-level API for ILI9341-driven TFT displays over the 4-wire serial (SPI) interface: SCK/MOSI/MISO/CS carried by the SPI bus itself, plus a separate /DC (data/command select) GPIO this driver toggles around each command, and an optional /RESET GPIO for boards that don't generate reset on their own. More...

Collaboration diagram for ILI9341:

Data Structures

struct  dev_ili9341_config_t
 Optional ILI9341 initialization options. More...
 

Macros

#define DEV_ILI9341_WIDTH   240u
 Native panel width in pixels, at rotation 0.
 
#define DEV_ILI9341_HEIGHT   320u
 Native panel height in pixels, at rotation 0.
 

Typedefs

typedef struct dev_ili9341_t dev_ili9341_t
 Opaque ILI9341 handle.
 

Lifecycle

void dev_ili9341_default_config (dev_ili9341_config_t *config)
 Fill an ILI9341 config struct with safe defaults. More...
 
dev_ili9341_tdev_ili9341_init (hw_deviceio_t *device, hw_gpio_t *dc_pin, hw_gpio_t *rst_pin, const dev_ili9341_config_t *config)
 Initialize an ILI9341-driven display over SPI. More...
 
void dev_ili9341_deinit (dev_ili9341_t *ili9341)
 Deinitialize an ILI9341 handle. More...
 

Properties

void dev_ili9341_size (const dev_ili9341_t *ili9341, pix_size_t *out_size)
 Get the display size at the configured rotation. More...
 

Methods

bool dev_ili9341_write (dev_ili9341_t *ili9341, pix_point_t origin, const pix_bitmap_t *bitmap)
 Write a rectangular block of pixels. More...
 

Detailed Description

This module provides a device-level API for ILI9341-driven TFT displays over the 4-wire serial (SPI) interface: SCK/MOSI/MISO/CS carried by the SPI bus itself, plus a separate /DC (data/command select) GPIO this driver toggles around each command, and an optional /RESET GPIO for boards that don't generate reset on their own.

Note
The device handle passed to dev_ili9341_init() must already be open at the controller's required SPI mode. This driver only issues transfers on it; it does not open or configure the bus itself.

Function Documentation

◆ dev_ili9341_default_config()

void dev_ili9341_default_config ( dev_ili9341_config_t config)

Fill an ILI9341 config struct with safe defaults.

Parameters
configConfig structure to initialize.

◆ dev_ili9341_deinit()

void dev_ili9341_deinit ( dev_ili9341_t ili9341)

Deinitialize an ILI9341 handle.

Parameters
ili9341ILI9341 handle.

Passing NULL is safe and is a no-op.

◆ dev_ili9341_init()

dev_ili9341_t* dev_ili9341_init ( hw_deviceio_t device,
hw_gpio_t dc_pin,
hw_gpio_t rst_pin,
const dev_ili9341_config_t config 
)

Initialize an ILI9341-driven display over SPI.

Parameters
deviceSPI device handle from hw_spi_init() / hw_spi_init_default() / hw_spi_init_device(), already open at hw_spi_mode_3.
dc_pinGPIO handle for /DC (data/command select). Required - the 4-wire serial protocol has no way to convey this otherwise.
rst_pinOptional GPIO handle for /RESET. Pass NULL on boards that generate reset on their own (see the module-level note above); the panel is then reset via its software-reset command instead.
configOptional pointer to initialization options. Pass NULL to use default values.
Returns
ILI9341 handle, or NULL on failure - including an config->rotation other than 0, 90, 180, or 270.

◆ dev_ili9341_size()

void dev_ili9341_size ( const dev_ili9341_t ili9341,
pix_size_t out_size 
)

Get the display size at the configured rotation.

Parameters
ili9341ILI9341 handle.
out_sizeOutput destination for the display size. Left unmodified if ili9341 is invalid.

◆ dev_ili9341_write()

bool dev_ili9341_write ( dev_ili9341_t ili9341,
pix_point_t  origin,
const pix_bitmap_t bitmap 
)

Write a rectangular block of pixels.

Parameters
ili9341ILI9341 handle.
originTop-left corner to write to, within the current rotation's bounds.
bitmapSource bitmap. Must be PIX_FMT_RGB565, with each pixel already stored big-endian (MSB first) - the byte order the wire protocol itself requires. This function sends bitmap->data as-is with no per-pixel conversion, so a bitmap built with native multi-byte writes (e.g. uint16_t pixels[i] = 0xF800) on a little-endian host must be byte-swapped by the caller first. bitmap->stride is honored, so the source need not be tightly packed.
Return values
trueWrite succeeded.
falseThe handle is invalid, bitmap is NULL or not PIX_FMT_RGB565, or the rectangle falls outside the current rotation's bounds.