Add st7789 lcd driver
This commit is contained in:
4430
include/application/sdk_config.h
Normal file
4430
include/application/sdk_config.h
Normal file
File diff suppressed because it is too large
Load Diff
12
include/framebuffer.h
Normal file
12
include/framebuffer.h
Normal file
@@ -0,0 +1,12 @@
|
||||
#ifndef __INCLUDE_FRAMEBUFFER_H__
|
||||
#define __INCLUDE_FRAMEBUFFER_H__
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
void fb_draw_pixel(uint16_t *image, uint16_t x, uint16_t y, uint16_t color);
|
||||
void fb_draw_line(uint16_t *image, int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color);
|
||||
|
||||
void fb_load_image(uint16_t *dst, uint16_t *src, uint32_t length);
|
||||
void fb_set_image(uint16_t *dst, uint16_t value, uint32_t length);
|
||||
|
||||
#endif
|
@@ -5,6 +5,7 @@
|
||||
|
||||
#include "gpio.h"
|
||||
#include "spi.h"
|
||||
#include "st7789.h"
|
||||
|
||||
// LED 1
|
||||
const struct gpio nrf_led_1 = {
|
||||
@@ -50,6 +51,8 @@ const struct driver led_4 = {
|
||||
.dev = &nrf_led_4
|
||||
};
|
||||
|
||||
// LCD
|
||||
// SPI 0
|
||||
const struct spi nrf_spi_0 = {
|
||||
.sck_pin = 2,
|
||||
.mosi_pin = 3,
|
||||
@@ -60,5 +63,55 @@ const struct driver spi_0 = {
|
||||
.fp = &spi_fp,
|
||||
.dev = &nrf_spi_0
|
||||
};
|
||||
const struct gpio nrf_dc_pin = {
|
||||
.pin = 18,
|
||||
.dir = OUT
|
||||
};
|
||||
const struct driver dc_pin = {
|
||||
.name = "DC",
|
||||
.fp = &gpio_fp,
|
||||
.dev = &nrf_dc_pin
|
||||
};
|
||||
const struct gpio nrf_bl_pin = {
|
||||
.pin = 23,
|
||||
.dir = OUT
|
||||
};
|
||||
const struct driver bl_pin = {
|
||||
.name = "BACKLIGHT",
|
||||
.fp = &gpio_fp,
|
||||
.dev = &nrf_bl_pin
|
||||
};
|
||||
const struct gpio nrf_rst_pin = {
|
||||
.pin = 26,
|
||||
.dir = OUT
|
||||
};
|
||||
const struct driver rst_pin = {
|
||||
.name = "RESET",
|
||||
.fp = &gpio_fp,
|
||||
.dev = &nrf_rst_pin
|
||||
};
|
||||
const struct gpio nrf_select_pin = {
|
||||
.pin = 25,
|
||||
.dir = OUT
|
||||
};
|
||||
const struct driver select_pin = {
|
||||
.name = "SELECT",
|
||||
.fp = &gpio_fp,
|
||||
.dev = &nrf_select_pin
|
||||
};
|
||||
struct st7789 nrf_lcd = {
|
||||
.spi = &spi_0,
|
||||
.dc = &dc_pin,
|
||||
.bl = &bl_pin,
|
||||
.rst = &rst_pin,
|
||||
.select = &select_pin,
|
||||
.height = 240,
|
||||
.width = 240,
|
||||
};
|
||||
const struct driver lcd = {
|
||||
.name = "LCD",
|
||||
.fp = &st7789_fp,
|
||||
.dev = &nrf_lcd
|
||||
};
|
||||
|
||||
#endif
|
||||
|
30
include/st7789.h
Normal file
30
include/st7789.h
Normal file
@@ -0,0 +1,30 @@
|
||||
#ifndef __ST7789_H__
|
||||
#define __ST7789_H__
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include "driver.h"
|
||||
|
||||
int st7789_open(const struct driver *drv);
|
||||
int st7789_close(const struct driver *drv);
|
||||
int st7789_write(const struct driver *drv, const char *buffer, unsigned int len);
|
||||
|
||||
struct st7789 {
|
||||
const struct driver *spi;
|
||||
const struct driver *dc;
|
||||
const struct driver *bl;
|
||||
const struct driver *rst;
|
||||
const struct driver *select;
|
||||
unsigned int height;
|
||||
unsigned int width;
|
||||
};
|
||||
|
||||
static const struct driver_fp st7789_fp = {
|
||||
.open = st7789_open,
|
||||
.close = st7789_close,
|
||||
.read = NULL,
|
||||
.write = st7789_write,
|
||||
.ioctl = NULL,
|
||||
};
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user