FreeCalypso > hg > freecalypso-hwlab
changeset 65:cdf2c99e5025
lunalcd project started
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 19 Mar 2020 01:31:05 +0000 |
parents | 6d02f30e35ad |
children | 09d26f19a2c2 |
files | .hgignore lunalcd/Makefile lunalcd/common.c lunalcd/init-regs lunalcd/initmain.c lunalcd/startek.c |
diffstat | 6 files changed, 185 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/.hgignore Sat Jun 29 22:45:18 2019 +0000 +++ b/.hgignore Thu Mar 19 01:31:05 2020 +0000 @@ -16,3 +16,5 @@ ^lcdtest/lcdphone$ ^lcdtest/lcdtest$ + +^lunalcd/gen-st-init$
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lunalcd/Makefile Thu Mar 19 01:31:05 2020 +0000 @@ -0,0 +1,13 @@ +CC= gcc +CFLAGS= -O2 +PROGS= gen-st-init + +STINIT_OBJS= common.o initmain.o startek.o + +all: ${PROGS} + +gen-st-init: ${STINIT_OBJS} + ${CC} -o $@ ${STINIT_OBJS} + +clean: + rm -f ${PROGS} *.o
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lunalcd/common.c Thu Mar 19 01:31:05 2020 +0000 @@ -0,0 +1,98 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <strings.h> + +static enum { + MODE_L8, + MODE_U8, + MODE_16, + MODE_USB +} mode; + +set_output_mode(kw) + char *kw; +{ + if (!strcmp(kw, "l8")) + mode = MODE_L8; + else if (!strcmp(kw, "u8")) + mode = MODE_U8; + else if (!strcmp(kw, "16")) + mode = MODE_16; + else if (!strcmp(kw, "usb")) + mode = MODE_USB; + else { + fprintf(stderr, "error: mode \"%s\" not understood\n", kw); + exit(1); + } +} + +write_ir(val16) + unsigned val16; +{ + if (mode != MODE_USB) + printf("w16 fffe4802 200\n"); + switch (mode) { + case MODE_L8: + printf("w16 02000000 %02x\n", val16 >> 8); + printf("w16 02000000 %02x\n", val16 & 0xFF); + break; + case MODE_U8: + printf("w16 02000000 %02x00\n", val16 >> 8); + printf("w16 02000000 %02x00\n", val16 & 0xFF); + break; + case MODE_16: + printf("w16 02000000 %04x\n", val16); + break; + case MODE_USB: + printf("wi %04x\n", val16); + } +} + +write_dr(val16) + unsigned val16; +{ + if (mode != MODE_USB) + printf("w16 fffe4802 600\n"); + switch (mode) { + case MODE_L8: + printf("w16 02000002 %02x\n", val16 >> 8); + printf("w16 02000002 %02x\n", val16 & 0xFF); + break; + case MODE_U8: + printf("w16 02000002 %02x00\n", val16 >> 8); + printf("w16 02000002 %02x00\n", val16 & 0xFF); + break; + case MODE_16: + printf("w16 02000002 %04x\n", val16); + break; + case MODE_USB: + printf("wd %04x\n", val16); + } +} + +bulk_wd_prep() +{ + if (mode != MODE_USB) + printf("w16 fffe4802 600\n"); +} + +bulk_wd(val16) + unsigned val16; +{ + switch (mode) { + case MODE_L8: + printf("w16 02000002 %02x\n", val16 >> 8); + printf("w16 02000002 %02x\n", val16 & 0xFF); + break; + case MODE_U8: + printf("w16 02000002 %02x00\n", val16 >> 8); + printf("w16 02000002 %02x00\n", val16 & 0xFF); + break; + case MODE_16: + printf("w16 02000002 %04x\n", val16); + break; + case MODE_USB: + printf("wd %04x\n", val16); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lunalcd/init-regs Thu Mar 19 01:31:05 2020 +0000 @@ -0,0 +1,9 @@ +# This file is a command script for fc-loadtool to be run on the Caramel board; +# it initializes a few Calypso registers for controlling an LCD connected to +# the expansion interface. + +w16 fffffb06 02A5 +w16 fffef00a 01E0 +w16 fffe4802 0200 +w16 fffe4804 F9FF +w16 fffffd04 FFF3
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lunalcd/initmain.c Thu Mar 19 01:31:05 2020 +0000 @@ -0,0 +1,14 @@ +#include <stdio.h> +#include <stdlib.h> + +main(argc, argv) + char **argv; +{ + if (argc != 2) { + fprintf(stderr, "usage: %s output-mode\n", argv[0]); + exit(1); + } + set_output_mode(argv[1]); + lcd_init_seq(); + exit(0); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lunalcd/startek.c Thu Mar 19 01:31:05 2020 +0000 @@ -0,0 +1,49 @@ +/* + * ST7775R register init for Startek LCDs KD020C-1 V2 and KD020C-2A, + * the former of which is also sold by Crystalfontz as CFAF176220U-020T. + */ + +lcd_init_seq() +{ + /* basic settings */ + write_ir(0x01); + write_dr(0x011C); + write_ir(0x02); + write_dr(0x0100); + write_ir(0x03); + write_dr(0x1030); + write_ir(0x0F); + write_dr(0x0001); + write_ir(0x10); + write_dr(0x0000); + write_ir(0x11); + write_dr(0x1000); + /* gamma control registers */ + write_ir(0x50); + write_dr(0x0203); + write_ir(0x51); + write_dr(0x0A09); + write_ir(0x52); + write_dr(0x0005); + write_ir(0x53); + write_dr(0x1021); + write_ir(0x54); + write_dr(0x0602); + write_ir(0x55); + write_dr(0x0003); + write_ir(0x56); + write_dr(0x0703); + write_ir(0x57); + write_dr(0x0507); + write_ir(0x58); + write_dr(0x1021); + write_ir(0x59); + write_dr(0x0703); + /* VCOM */ + write_ir(0xB0); + write_dr(0x2501); + /* turn it on! */ + write_ir(0x07); + write_dr(0x1017); + return(0); +}