This is a sample program to drive a 128x128 LCD with t6963 controller through SPI by means of an MCP23S17 16-Bit I/O Expander with Serial Interface
Revision 1:e98e29ea2d03, committed 2010-12-05
- Comitter:
- gertk
- Date:
- Sun Dec 05 14:38:10 2010 +0000
- Parent:
- 0:bf72877f77ab
- Child:
- 2:9071445a6895
- Commit message:
- 0.0002
Changed in this revision
--- a/MCP23S17.h Sun Dec 05 14:31:49 2010 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,54 +0,0 @@ -/* MCP23S17 - drive the Microchip MCP23S17 16-bit Port Extender using SPI -* Copyright (c) 2010 Romilly Cocking -* Released under the MIT License: http://mbed.org/license/mit -* -* version 0.4 -*/ -#include "mbed.h" - - -#define INTERRUPT_POLARITY_BIT 0x02 -#define INTERRUPT_MIRROR_BIT 0x40 - -// all register addresses assume IOCON.BANK = 0 (POR default) - -#define IODIRA 0x00 -#define IODIRB 0x01 -#define IPOLA 0x02 -#define IPOLB 0x03 -#define GPINTENA 0x04 -#define GPINTENB 0x05 -#define DEFVALA 0x06 -#define DEFVALB 0x07 -#define INTCONA 0x08 -#define INTCONB 0x09 -#define IOCONA 0x0A -#define IOCONB 0x0B -#define GPPUA 0x0C -#define GPPUB 0x0D -#define INTFA 0x0E -#define INTFB 0x0F -#define INTCAPA 0x10 -#define INTCAPB 0x11 -#define GPIOA 0x12 -#define GPIOB 0x13 -#define OLATA 0x14 -#define OLATB 0x15 - -#define LCD_HALT 0x80 -#define LCD_FS 0x20 -#define LCD_RST 0x10 -#define LCD_CD 0x08 -#define LCD_CE 0x04 -#define LCD_RD 0x02 -#define LCD_WR 0x01 - -// T6963C OPCODES -#define TXHOME 0x40 // SET TXT HM ADD -#define TXAREA 0x41 // SET TXT AREA -#define GRHOME 0x42 // SET GRAPHIC HOME ADDRESS -#define GRAREA 0x43 // SET GRAPHIC AREA -#define OFFSET 0x22 // SET OFFSET ADDRESS -#define ADPSET 0x24 // SET ADDRESS POINTER -#define AWRON 0xB0 // SET AUTO WRITE MODE -#define AWROFF 0xB2 // RESET AUTO WRITE MODE
--- a/main.cpp Sun Dec 05 14:31:49 2010 +0000 +++ b/main.cpp Sun Dec 05 14:38:10 2010 +0000 @@ -1,5 +1,5 @@ #include "mbed.h" -#include "MCP23S17.h" +#include "mcp_lcd.h" #define LCDFONTSEL 0xFF DigitalOut myled(LED1); @@ -98,6 +98,7 @@ { while (s[0]) { + // convert from ascii to t6963 lcd_data(s[0]-32); s++; }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mcp_lcd.h Sun Dec 05 14:38:10 2010 +0000 @@ -0,0 +1,46 @@ +/* MCP23S17 - Microchip MCP23S17 16-bit Port Extender using SPI +* Copyright (c) 2010 Gert van der Knokke +*/ +#include "mbed.h" + +#define IODIRA 0x00 +#define IODIRB 0x01 +#define IPOLA 0x02 +#define IPOLB 0x03 +#define GPINTENA 0x04 +#define GPINTENB 0x05 +#define DEFVALA 0x06 +#define DEFVALB 0x07 +#define INTCONA 0x08 +#define INTCONB 0x09 +#define IOCONA 0x0A +#define IOCONB 0x0B +#define GPPUA 0x0C +#define GPPUB 0x0D +#define INTFA 0x0E +#define INTFB 0x0F +#define INTCAPA 0x10 +#define INTCAPB 0x11 +#define GPIOA 0x12 +#define GPIOB 0x13 +#define OLATA 0x14 +#define OLATB 0x15 + +// LCD pin connections/bit numbers +#define LCD_HALT 0x80 +#define LCD_FS 0x20 +#define LCD_RST 0x10 +#define LCD_CD 0x08 +#define LCD_CE 0x04 +#define LCD_RD 0x02 +#define LCD_WR 0x01 + +// T6963C OPCODES +#define TXHOME 0x40 // SET TXT HM ADD +#define TXAREA 0x41 // SET TXT AREA +#define GRHOME 0x42 // SET GRAPHIC HOME ADDRESS +#define GRAREA 0x43 // SET GRAPHIC AREA +#define OFFSET 0x22 // SET OFFSET ADDRESS +#define ADPSET 0x24 // SET ADDRESS POINTER +#define AWRON 0xB0 // SET AUTO WRITE MODE +#define AWROFF 0xB2 // RESET AUTO WRITE MODE