DM12832-01A / IST3080 单色 LCD —— 8 位 8080 并口 GPIO bit-bang 驱动(HPM6750 + NuttX)
一份在 HPMicro HPM6750(双核 RISC-V)+ NuttX 10.3 上从零写的 DM12832-01A 128×32 单色 LCD 裸机驱动记录。
控制器 IST3080,接口 8 位 8080 并行,纯 GPIO bit-bang(无硬件 LCD 控制器)。
驱动分两层:裸机 C API(便于 bring-up 逐步点屏)+ NuttX lcd_dev_s 标准设备封装(/dev/lcd0,供上层 GUI 走 putrun/putarea)。
1. 背景
板上 LCD 是 DM12832-01A(128×32 点阵单色屏,IST3080 控制器),走 8080 8-bit 并行总线。SoC(HPM6750)没有专用 LCD 控制器外设接这块小屏,于是直接用 GPIO 软件时序(bit-bang) 驱动:8 根数据线 + /WR /RD A0 /RST /CS 控制线 + 电源/背光使能。
驱动目标:
2. 硬件接线
| D0…D7 | PA00 PA04 PA08 PA16 PA03 PA09 PA02 PF05 | 8 位数据总线(注意 D7 在 PF 口,其余在 PA 口) |
| /WR(LCD_WD) | PA01 | 写选通,下降沿锁存 |
| /RD | PY11 | 读选通(本驱动只写不读) |
| A0(cmd/data) | PY10 | 高=数据,低=命令 |
| /RST | PY09 | 复位,低有效 |
| /CS | PY08 | 片选,低有效 |
| PWR_CTR(5V 使能) | PF03 | 经 Q11 控制 LCD 5V 电源轨 |
| BL(背光) | PF04 | 背光使能(经 R343/R344 + Q11) |
HPM6750 GPIO 特点:所有 GPIO 口都挂在 HPM_GPIO0,通过 GPIO_DO_GPIOx 索引选 A/F/Y 口。
PY 口在 always-on(常开)域,除了设 IOC pad func,还必须额外写 HPM_PIOC 的 ALT_SELECT_SET(3),IOC 路由才真正生效——否则 /RST /CS /A0 /RD 推不动。这是本驱动第一个坑。
3. 软件架构
┌─────────────────────────────────────────────┐
│ 上层:vendor GUI / lcdtest builtin │
└───────────────┬───────────────┬──────────────┘
│ C API │ NuttX lcd_dev_s (/dev/lcd0)
▼ ▼
hpm6750_lcd_* dm12832_putrun/putarea
(pwr/bl/cmd/ + shadow framebuffer
data/fill/…) (FB_FMT_Y1 ↔ page 格式转换)
└───────┬───────┘
▼
lcd_write_byte() ── 8080 写时序
▼
GPIO bit-bang (HPM_GPIO0)
- 底层总线:lcd_write_byte() 实现 8080 写时序(置 A0 → 摆数据 → /CS 拉低 → /WR 低→高锁存 → /CS 拉高)。
- 裸机 C API:hpm6750_lcd_pwr/bl/reset_pulse/cmd/data/set_pos/fill + 测试图案 pattern_checker/hbars/vbars/border + draw_test_text。
- NuttX 封装(#ifdef CONFIG_LCD):实现 lcd_dev_s + lcd_planeinfo_s 回调,维护一块 shadow framebuffer,把 NuttX 的行优先 FB_FMT_Y1 转成 IST3080 的 page(按页,每字节 8 个垂直像素) 格式,只刷被改动的 page。
4. 关键实现点
4.1 8080 写时序
static void lcd_write_byte(uint8_t b, bool is_data)
{
lcd_gpio_set(LCD_A0_PORT, LCD_A0_PIN, is_data ? 1 : 0); /* A0: H=数据 L=命令 */
lcd_put_data(b); /* 摆 8 位数据 */
lcd_gpio_set(LCD_CS_PORT, LCD_CS_PIN, 0); /* /CS 拉低 */
lcd_gpio_set(LCD_WR_PORT, LCD_WR_PIN, 0); /* /WR 低 */
lcd_delay_ns(20); /* >100ns @640MHz */
lcd_gpio_set(LCD_WR_PORT, LCD_WR_PIN, 1); /* /WR 高 → 锁存 */
lcd_delay_ns(10);
lcd_gpio_set(LCD_CS_PORT, LCD_CS_PIN, 1); /* /CS 拉高 */
}
延时用 nop 软件循环——HPM6750 ~640MHz 下一个 nop ≈ 1.5ns,几十个 nop 足够满足 8080 的 WR 脉宽(~100ns)。
4.2 IST3080 初始化序列
| 0xE2 | 软件复位 |
| 0xA2 | bias = 1/6(配 DM12832 1/33 duty) |
| 0xA0 | SEG 方向正常(左→右) |
| 0xC8 | COM 方向反转(适配 6 点钟视角) |
| 0x40 | 显示起始行 = 0 |
| 0x2F | 电源:V_BOOST + V_REG + V_FOLL 全开 |
| 0xF8 0x00 | 升压倍率 4x |
| 0x27 | 调压比 = 7 |
| 0x81 0x20 | 对比度 EV = 32/63 |
| 0xA4 | 全亮关(正常显存) |
| 0xA6 | 非反显 |
| 0xAF | 显示 ON |
4.3 页寻址
128×32 屏 = 4 个 page × 128 列,每字节 = 8 个垂直像素(bit0=page 顶,bit7=page 底):
void hpm6750_lcd_set_pos(int page, int col)
{
hpm6750_lcd_cmd(0xB0 | (page & 0x0f)); /* page 地址 */
hpm6750_lcd_cmd(0x10 | ((col >> 4) & 0x0f)); /* 列高 4 位 */
hpm6750_lcd_cmd(0x00 | (col & 0x0f)); /* 列低 4 位 */
}
4.4 NuttX lcd_dev_s 封装与坐标转换
NuttX framebuffer 是 行优先、FB_FMT_Y1(1bpp)、MSB-first(字节 bit7 = 该 8 像素组最左);
IST3080 硬件是 page 格式、每字节 8 个垂直像素。两者不一致,所以维护一块 shadow framebuffer 做转换:
/* 1 像素写进 shadow(行优先坐标 → page 格式) */
static inline void dm12832_set_pixel(int row, int col, bool on)
{
int page = row >> 3; /* row / 8 */
uint8_t bit = 1U << (row & 7); /* row % 8 */
if (on) g_dm12832_shadow[page][col] |= bit;
else g_dm12832_shadow[page][col] &= ~bit;
}
坑:NuttX 1bpp LCD 的 putarea 里 col_start/col_end 是字节单位(不是像素)!
vendor 写 col_end = xres/8 – 1 = 15(128 宽),印证了字节单位的解释。一开始按像素单位算会整屏错位。
putrun/putarea 改完 shadow 后,只 dm12832_flush_page() 刷被影响到的 page,省总线时间。
4.5 字库 row-major → LCD 列格式转置
测试文字位图按行优先存(byte[row*strips + strip]),而 LCD 要列格式,lcd_render_strip() 里实时转置:逐列取每行的对应 bit,拼成 LCD 的"垂直 8 像素"字节。
同样的 col-major/row-major 转置坑,在集成 vendor HZK12/ASC16 字库时也踩过——读字库时方向不对就是整片乱码。
5. 踩坑与经验
6. 使用方法
裸机 C API(NSH lcdtest builtin 调用):
hpm6750_lcd_dm12832_init(); /* 上电 + 复位 + IST3080 init + 清屏 */
hpm6750_lcd_pattern_checker(); /* 棋盘格 */
hpm6750_lcd_draw_test_text(); /* 画测试文字 */
hpm6750_lcd_bl(1); /* 开背光 */
NuttX 标准设备(上层 GUI):
struct lcd_dev_s *lcd = board_lcd_getdev(0); /* 拿 /dev/lcd0 设备 */
/* 之后走 NuttX LCD/NX 框架的 putrun/putarea */
Kconfig 开关:CONFIG_HPM_LCD_DM12832(驱动本体)+ CONFIG_LCD(NuttX 标准封装层)。
7. 完整源码 hpm6750_lcd_dm12832.c
路径:boards/risc-v/hpmicro/<board>/src/hpm6750_lcd_dm12832.c
依赖:HPMicro SDK 的 hpm_gpio_drv.h / hpm_soc.h(GPIO + IOC 寄存器)、NuttX nuttx/lcd/lcd.h 等。
/****************************************************************************
* Bare-metal driver for the DM12832-01A 128×32 mono LCD
* (IST3080 controller, 8-bit 8080 parallel interface).
*
* Wiring:
* D0..D7 = PA00 PA04 PA08 PA16 PA03 PA09 PA02 PF05
* /WR = PA01 /RD = PY11 A0 (cmd/data) = PY10
* /RST = PY09 /CS = PY08
* PWR_CTR (5V enb) = PF03 BL (backlight) = PF04
****************************************************************************/
#include <nuttx/config.h>
#include <stdio.h>
#include <stdbool.h>
#include <stdint.h>
#include <sched.h>
#include <unistd.h>
#include "hpm_soc.h"
#include "hpm_gpio_drv.h"
#include "hpm_clock_drv.h"
#ifdef CONFIG_HPM_LCD_DM12832
/* —- GPIO routing macros (all ports live in HPM_GPIO0) —- */
#define LCD_PORT_A GPIO_DO_GPIOA
#define LCD_PORT_F GPIO_DO_GPIOF
#define LCD_PORT_Y GPIO_DO_GPIOY
struct lcd_data_pin { uint8_t port; uint8_t pin; };
static const struct lcd_data_pin g_lcd_data[8] =
{
{ LCD_PORT_A, 0 }, { LCD_PORT_A, 4 }, { LCD_PORT_A, 8 }, { LCD_PORT_A, 16 },
{ LCD_PORT_A, 3 }, { LCD_PORT_A, 9 }, { LCD_PORT_A, 2 }, { LCD_PORT_F, 5 },
};
#define LCD_WR_PORT LCD_PORT_A
#define LCD_WR_PIN 1
#define LCD_RD_PORT LCD_PORT_Y
#define LCD_RD_PIN 11
#define LCD_A0_PORT LCD_PORT_Y
#define LCD_A0_PIN 10
#define LCD_RST_PORT LCD_PORT_Y
#define LCD_RST_PIN 9
#define LCD_CS_PORT LCD_PORT_Y
#define LCD_CS_PIN 8
#define LCD_PWR_PORT LCD_PORT_F
#define LCD_PWR_PIN 3
#define LCD_BL_PORT LCD_PORT_F
#define LCD_BL_PIN 4
/* —- Low-level GPIO helpers —- */
static inline void lcd_gpio_set(uint8_t port, uint8_t pin, uint8_t val)
{
gpio_write_pin(HPM_GPIO0, port, pin, val);
}
static inline void lcd_delay_ns(unsigned n)
{
for (unsigned i = 0; i < n; i++) __asm__ __volatile__ ("nop");
}
/* —- Pinmux + GPIO direction init —- */
static void hpm6750_lcd_pinmux_init(void)
{
/* Data bus + WR + PWR/BL as GPIO func */
HPM_IOC->PAD[IOC_PAD_PA00].FUNC_CTL = IOC_PA00_FUNC_CTL_GPIO_A_00;
HPM_IOC->PAD[IOC_PAD_PA04].FUNC_CTL = IOC_PA04_FUNC_CTL_GPIO_A_04;
HPM_IOC->PAD[IOC_PAD_PA08].FUNC_CTL = IOC_PA08_FUNC_CTL_GPIO_A_08;
HPM_IOC->PAD[IOC_PAD_PA16].FUNC_CTL = IOC_PA16_FUNC_CTL_GPIO_A_16;
HPM_IOC->PAD[IOC_PAD_PA03].FUNC_CTL = IOC_PA03_FUNC_CTL_GPIO_A_03;
HPM_IOC->PAD[IOC_PAD_PA09].FUNC_CTL = IOC_PA09_FUNC_CTL_GPIO_A_09;
HPM_IOC->PAD[IOC_PAD_PA02].FUNC_CTL = IOC_PA02_FUNC_CTL_GPIO_A_02;
HPM_IOC->PAD[IOC_PAD_PF05].FUNC_CTL = IOC_PF05_FUNC_CTL_GPIO_F_05;
HPM_IOC->PAD[IOC_PAD_PA01].FUNC_CTL = IOC_PA01_FUNC_CTL_GPIO_A_01;
HPM_IOC->PAD[IOC_PAD_PF03].FUNC_CTL = IOC_PF03_FUNC_CTL_GPIO_F_03;
HPM_IOC->PAD[IOC_PAD_PF04].FUNC_CTL = IOC_PF04_FUNC_CTL_GPIO_F_04;
/* PY pins (always-on domain): IOC func + PIOC alt-select=3 */
HPM_IOC->PAD[IOC_PAD_PY08].FUNC_CTL = IOC_PY08_FUNC_CTL_GPIO_Y_08;
HPM_IOC->PAD[IOC_PAD_PY09].FUNC_CTL = IOC_PY09_FUNC_CTL_GPIO_Y_09;
HPM_IOC->PAD[IOC_PAD_PY10].FUNC_CTL = IOC_PY10_FUNC_CTL_GPIO_Y_10;
HPM_IOC->PAD[IOC_PAD_PY11].FUNC_CTL = IOC_PY11_FUNC_CTL_GPIO_Y_11;
HPM_PIOC->PAD[IOC_PAD_PY08].FUNC_CTL = IOC_PAD_FUNC_CTL_ALT_SELECT_SET(3);
HPM_PIOC->PAD[IOC_PAD_PY09].FUNC_CTL = IOC_PAD_FUNC_CTL_ALT_SELECT_SET(3);
HPM_PIOC->PAD[IOC_PAD_PY10].FUNC_CTL = IOC_PAD_FUNC_CTL_ALT_SELECT_SET(3);
HPM_PIOC->PAD[IOC_PAD_PY11].FUNC_CTL = IOC_PAD_FUNC_CTL_ALT_SELECT_SET(3);
/* Drive all as outputs with idle/safe initial values */
for (int i = 0; i < 8; i++)
gpio_set_pin_output_with_initial(HPM_GPIO0, g_lcd_data[i].port, g_lcd_data[i].pin, 0);
gpio_set_pin_output_with_initial(HPM_GPIO0, LCD_WR_PORT, LCD_WR_PIN, 1);
gpio_set_pin_output_with_initial(HPM_GPIO0, LCD_RD_PORT, LCD_RD_PIN, 1);
gpio_set_pin_output_with_initial(HPM_GPIO0, LCD_A0_PORT, LCD_A0_PIN, 0);
gpio_set_pin_output_with_initial(HPM_GPIO0, LCD_CS_PORT, LCD_CS_PIN, 1);
gpio_set_pin_output_with_initial(HPM_GPIO0, LCD_RST_PORT, LCD_RST_PIN, 0);
gpio_set_pin_output_with_initial(HPM_GPIO0, LCD_PWR_PORT, LCD_PWR_PIN, 0);
gpio_set_pin_output_with_initial(HPM_GPIO0, LCD_BL_PORT, LCD_BL_PIN, 0);
}
/* Lazy first-call pinmux so `bl on` / `pwr on` work without explicit init */
static bool g_lcd_pinmux_done;
static void lcd_ensure_pinmux(void)
{
if (!g_lcd_pinmux_done) { hpm6750_lcd_pinmux_init(); g_lcd_pinmux_done = true; }
}
/* —- Bus helpers —- */
static void lcd_put_data(uint8_t b)
{
for (int i = 0; i < 8; i++)
lcd_gpio_set(g_lcd_data[i].port, g_lcd_data[i].pin, (b >> i) & 1);
}
static void lcd_write_byte(uint8_t b, bool is_data)
{
lcd_gpio_set(LCD_A0_PORT, LCD_A0_PIN, is_data ? 1 : 0);
lcd_put_data(b);
lcd_gpio_set(LCD_CS_PORT, LCD_CS_PIN, 0);
lcd_gpio_set(LCD_WR_PORT, LCD_WR_PIN, 0);
lcd_delay_ns(20);
lcd_gpio_set(LCD_WR_PORT, LCD_WR_PIN, 1);
lcd_delay_ns(10);
lcd_gpio_set(LCD_CS_PORT, LCD_CS_PIN, 1);
}
/* —- Public C API —- */
void hpm6750_lcd_pwr(int on)
{
lcd_ensure_pinmux();
lcd_gpio_set(LCD_PWR_PORT, LCD_PWR_PIN, on ? 1 : 0);
}
void hpm6750_lcd_bl(int on)
{
lcd_ensure_pinmux();
lcd_gpio_set(LCD_BL_PORT, LCD_BL_PIN, on ? 1 : 0);
}
void hpm6750_lcd_reset_pulse(void)
{
lcd_ensure_pinmux();
lcd_gpio_set(LCD_RST_PORT, LCD_RST_PIN, 0);
lcd_delay_ns(50000); /* >= 1 us low */
lcd_gpio_set(LCD_RST_PORT, LCD_RST_PIN, 1);
lcd_delay_ns(500000); /* settle */
}
void hpm6750_lcd_cmd(uint8_t cmd) { lcd_ensure_pinmux(); lcd_write_byte(cmd, false); }
void hpm6750_lcd_data(uint8_t d) { lcd_ensure_pinmux(); lcd_write_byte(d, true); }
void hpm6750_lcd_set_pos(int page, int col)
{
hpm6750_lcd_cmd(0xB0 | (page & 0x0f)); /* page addr */
hpm6750_lcd_cmd(0x10 | ((col >> 4) & 0x0f)); /* col high */
hpm6750_lcd_cmd(0x00 | (col & 0x0f)); /* col low */
}
void hpm6750_lcd_fill(uint8_t byte)
{
for (int page = 0; page < 4; page++)
{
hpm6750_lcd_set_pos(page, 0);
for (int col = 0; col < 128; col++) hpm6750_lcd_data(byte);
}
}
/* IST3080 init sequence for 128×32, 1/33 duty, 1/6 bias */
void hpm6750_lcd_ist3080_init_seq(void)
{
hpm6750_lcd_cmd(0xE2); lcd_delay_ns(100000); /* software reset */
hpm6750_lcd_cmd(0xA2); /* bias 1/6 */
hpm6750_lcd_cmd(0xA0); /* SEG normal */
hpm6750_lcd_cmd(0xC8); /* COM reverse */
hpm6750_lcd_cmd(0x40); /* start line 0 */
hpm6750_lcd_cmd(0x2F); lcd_delay_ns(100000); /* power on */
hpm6750_lcd_cmd(0xF8); hpm6750_lcd_cmd(0x00); /* booster 4x */
hpm6750_lcd_cmd(0x27); /* regulator ratio 7 */
hpm6750_lcd_cmd(0x81); hpm6750_lcd_cmd(0x20); /* contrast EV 32 */
hpm6750_lcd_cmd(0xA4); /* all-on off */
hpm6750_lcd_cmd(0xA6); /* non-inverted */
hpm6750_lcd_cmd(0xAF); /* display ON */
}
/* —- Test patterns —- */
void hpm6750_lcd_pattern_checker(void)
{
for (int page = 0; page < 4; page++)
{
hpm6750_lcd_set_pos(page, 0);
int row_bit = page & 1;
for (int col = 0; col < 128; col++)
{
int col_bit = (col / 8) & 1;
hpm6750_lcd_data((col_bit ^ row_bit) ? 0xff : 0x00);
}
}
}
void hpm6750_lcd_pattern_hbars(void)
{
for (int page = 0; page < 4; page++)
{
hpm6750_lcd_set_pos(page, 0);
for (int col = 0; col < 128; col++) hpm6750_lcd_data(0x0f);
}
}
void hpm6750_lcd_pattern_vbars(void)
{
for (int page = 0; page < 4; page++)
{
hpm6750_lcd_set_pos(page, 0);
for (int col = 0; col < 128; col++) hpm6750_lcd_data((col & 4) ? 0xff : 0x00);
}
}
void hpm6750_lcd_pattern_border(void)
{
for (int page = 0; page < 4; page++)
{
hpm6750_lcd_set_pos(page, 0);
for (int col = 0; col < 128; col++)
{
uint8_t b = 0x00;
if (col == 0 || col == 127) b = 0xff;
if (page == 0) b |= 0x01;
if (page == 3) b |= 0x80;
hpm6750_lcd_data(b);
}
}
}
/* —- Top-level hardware init (call once in board bringup) —- */
int hpm6750_lcd_dm12832_init(void)
{
hpm6750_lcd_pinmux_init();
g_lcd_pinmux_done = true;
hpm6750_lcd_pwr(1);
lcd_delay_ns(2000000); /* let 5V rail settle */
hpm6750_lcd_reset_pulse();
hpm6750_lcd_ist3080_init_seq();
hpm6750_lcd_fill(0x00); /* clear RAM */
/* NOTE: do NOT task_create() a background cycle task here — this runs in
* board late init, before NSH main task; spawning a task here breaks NSH's
* ability to posix_spawn() builtins afterwards. Trigger cycle manually. */
return 0;
}
/****************************************************************************
* NuttX lcd_dev_s wrapper:
* NuttX framebuffer: row-major, FB_FMT_Y1 (1bpp), MSB-first
* DM12832 hardware: page-based, 4 pages x 128 cols, byte = 8 vert pixels
* Keep a shadow framebuffer, convert on the fly, flush only touched pages.
****************************************************************************/
#ifdef CONFIG_LCD
#include <string.h>
#include <errno.h>
#include <nuttx/lcd/lcd.h>
#include <nuttx/video/fb.h>
#define DM12832_XRES 128
#define DM12832_YRES 32
#define DM12832_BPP 1
#define DM12832_PAGES 4
#define DM12832_STRIDE 16 /* 128 / 8 */
static uint8_t g_dm12832_shadow[DM12832_PAGES][DM12832_XRES];
static uint8_t g_dm12832_runbuffer[DM12832_STRIDE];
static int g_dm12832_power = 1;
static inline void dm12832_set_pixel(int row, int col, bool on)
{
if (row < 0 || row >= DM12832_YRES || col < 0 || col >= DM12832_XRES) return;
int page = row >> 3;
uint8_t bit = 1U << (row & 7);
if (on) g_dm12832_shadow[page][col] |= bit;
else g_dm12832_shadow[page][col] &= ~bit;
}
static void dm12832_flush_page(int page)
{
if (page < 0 || page >= DM12832_PAGES) return;
hpm6750_lcd_set_pos(page, 0);
for (int col = 0; col < DM12832_XRES; col++)
hpm6750_lcd_data(g_dm12832_shadow[page][col]);
}
static int dm12832_putrun(FAR struct lcd_dev_s *dev, fb_coord_t row,
fb_coord_t col, FAR const uint8_t *buffer, size_t npixels)
{
for (size_t i = 0; i < npixels; i++)
{
bool on = (buffer[i >> 3] >> (7 – (i & 7))) & 1U; /* FB_FMT_Y1 MSB-first */
dm12832_set_pixel(row, col + i, on);
}
dm12832_flush_page(row >> 3);
return OK;
}
/* NOTE: for 1bpp NuttX LCD, col_start/col_end are in BYTE units, not pixels. */
static int dm12832_putarea(FAR struct lcd_dev_s *dev, fb_coord_t row_start,
fb_coord_t row_end, fb_coord_t col_start,
fb_coord_t col_end, FAR const uint8_t *buffer)
{
int byte_w = col_end – col_start + 1; /* bytes per row (e.g. 16) */
int rows = row_end – row_start + 1;
for (int r = 0; r < rows; r++)
{
const uint8_t *line = buffer + r * byte_w;
int abs_row = row_start + r;
for (int bx = 0; bx < byte_w; bx++)
{
uint8_t byte = line[bx];
int abs_col_base = (col_start + bx) * 8;
for (int bit = 0; bit < 8; bit++)
dm12832_set_pixel(abs_row, abs_col_base + bit, (byte >> (7 – bit)) & 1U);
}
}
for (int p = row_start >> 3; p <= row_end >> 3; p++) dm12832_flush_page(p);
return OK;
}
static int dm12832_getvideoinfo(FAR struct lcd_dev_s *dev,
FAR struct fb_videoinfo_s *vinfo)
{
vinfo->fmt = FB_FMT_Y1; vinfo->xres = DM12832_XRES;
vinfo->yres = DM12832_YRES; vinfo->nplanes = 1;
return OK;
}
static int dm12832_getplaneinfo(FAR struct lcd_dev_s *dev, unsigned int planeno,
FAR struct lcd_planeinfo_s *pinfo)
{
if (planeno != 0) return –EINVAL;
memset(pinfo, 0, sizeof(*pinfo));
pinfo->putrun = dm12832_putrun;
pinfo->putarea = dm12832_putarea;
pinfo->buffer = g_dm12832_runbuffer;
pinfo->bpp = DM12832_BPP;
pinfo->dev = dev;
return OK;
}
static int dm12832_getpower(FAR struct lcd_dev_s *dev) { return g_dm12832_power; }
static int dm12832_setpower(FAR struct lcd_dev_s *dev, int power)
{
g_dm12832_power = power ? 1 : 0;
hpm6750_lcd_bl(g_dm12832_power);
return OK;
}
static struct lcd_dev_s g_dm12832_lcddev =
{
.getvideoinfo = dm12832_getvideoinfo,
.getplaneinfo = dm12832_getplaneinfo,
.getpower = dm12832_getpower,
.setpower = dm12832_setpower,
};
FAR struct lcd_dev_s *board_lcd_getdev(int devno)
{
return (devno == 0) ? &g_dm12832_lcddev : NULL;
}
int board_lcd_initialize(void) { return OK; } /* HW already init in bringup */
void board_lcd_uninitialize(void)
{
hpm6750_lcd_bl(0);
hpm6750_lcd_pwr(0);
}
#endif /* CONFIG_LCD */
#endif /* CONFIG_HPM_LCD_DM12832 */
注:为便于阅读,上面省略了测试文字位图表 g_lcd_fontmap[](16 行 × 34 strip 的点阵数据)与 lcd_render_strip()/hpm6750_lcd_draw_test_text() 文字渲染部分;它们演示 row-major→列格式转置,但与驱动核心解耦,需要时可单独附上。
8. 适用与移植
- 直接可用:HPM6750 + DM12832-01A/IST3080,改 g_lcd_data[] 与控制线宏到你的实际接线即可。
- 换控制器(ST7565/UC1701 等兼容芯片):多数 8080 单色控制器命令集相近,改 hpm6750_lcd_ist3080_init_seq() 的初始化序列即可,总线时序与 NuttX 封装层不用动。
- 换 SoC:只需替换 lcd_gpio_set() / pinmux 两处的寄存器访问,其余逻辑与平台无关。
记录用途:嵌入式裸机 LCD 驱动(8080 并口 bit-bang)+ NuttX lcd_dev 封装实践。

