summaryrefslogtreecommitdiff
path: root/lib/ili9341.h
diff options
context:
space:
mode:
authorPhysick <96335032+DegustatorPonos@users.noreply.github.com>2026-01-02 22:41:25 +0500
committerPhysick <96335032+DegustatorPonos@users.noreply.github.com>2026-01-02 22:41:25 +0500
commit9477bf2b6cce08f648b1d9b3c37a2bf697854e70 (patch)
tree7c94f575961e41e50d65052d473735b6daa11f0e /lib/ili9341.h
Not working version
Diffstat (limited to 'lib/ili9341.h')
-rw-r--r--lib/ili9341.h73
1 files changed, 73 insertions, 0 deletions
diff --git a/lib/ili9341.h b/lib/ili9341.h
new file mode 100644
index 0000000..af1d3ee
--- /dev/null
+++ b/lib/ili9341.h
@@ -0,0 +1,73 @@
+#include <stdint.h>
+#define STM32F1
+#include <libopencm3/stm32/gpio.h>
+
+#ifndef ili9341
+#define ili9341
+
+#define PALET_16BIT
+
+#define SCREEN_HEIGHT 240
+#define SCREEN_WIDTH 320
+
+#define SPI_ADDR SPI1
+
+#define ILI9341_DC GPIO2
+#define ILI9341_RES GPIO3
+#define ILI9341_CS GPIO1
+#define ILI9341_CLK GPIO5
+#define ILI9341_MISO GPIO6
+#define ILI9341_MOSI GPIO7
+
+// Init comands
+#define ILI9341_SOFTRESET 0x01
+#define ILI9341_POWERCONTROL_A 0xCB
+#define ILI9341_POWERCONTROL_B 0xCF
+#define ILI9341_DRIVER_TIMINGS_A 0xE8
+#define ILI9341_DRIVER_TIMINGS_B 0xEA
+#define ILI9341_POS_CONTROL 0xEA
+#define ILI9341_PUMP_RATIO_CONTROL 0xF7
+#define ILI9341_POWERCONTROL1 0xC0
+#define ILI9341_POWERCONTROL2 0xC1
+#define ILI9341_VCOM_CONTROL1 0xC5
+#define ILI9341_VCOM_CONTROL2 0xC7
+#define ILI9341_MEM_ACCESS_CONTROL 0x36
+#define ILI9341_PIXEL_FORMAT_CONTROL 0x3A
+#define ILI9341_FRAME_RATIO_CONTROL 0xB1
+#define ILI9341_DISPLAY_RATIO_CONTROL 0xB6
+#define ILI9341_3G_SETUP 0xF2
+#define ILI9341_GAMMA_CURVE_SELECTED 0x26
+#define ILI9341_SET_POS_GAMMA 0x0F
+#define ILI9341_SET_NEG_GAMMA 0xE1
+
+#define ILI9341_DISPLAYOFF 0x28
+#define ILI9341_PIXELFORMAT 0x3A
+#define ILI9341_MEMCONTROL 0x36
+#define ILI9341_SLEEPOUT 0x11
+#define ILI9341_DISPLAYON 0x29
+
+#define ILI9341_SET_COLUMN 0x2A
+#define ILI9341_SET_ROW 0x2B
+#define ILI9341_WRITE_TO_RAM 0x2C
+
+#define ILI9341_PIXEL_FORMAT_16BIT 0x55
+
+// Sets up GPIO for peripherals
+void ILI_SetupGPIO(void);
+// Starts up an initialization sequence
+void ILI_Setup(void);
+// Hard resets the screen
+void ILI_hard_reset(void);
+
+// Sends a comand to display
+void ILI_sendComand(uint8_t cmd);
+// Writes a bit to SPI
+void ILI_sendData(uint8_t data);
+
+// Set position to write to
+void ILI_setAddrWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1);
+
+#endif // ili9341
+
+// Performs a goven amount of NOPs
+void delayCycles(uint32_t nops);