![](/media/cache/profiles/f93486bfff38ca69d76d85c089569a09.50x50_q85.jpg)
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
mcp_lcd.h@2:9071445a6895, 2010-12-06 (annotated)
- Committer:
- gertk
- Date:
- Mon Dec 06 20:45:00 2010 +0000
- Revision:
- 2:9071445a6895
- Parent:
- 1:e98e29ea2d03
0.0003
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
gertk | 1:e98e29ea2d03 | 1 | /* MCP23S17 - Microchip MCP23S17 16-bit Port Extender using SPI |
gertk | 1:e98e29ea2d03 | 2 | * Copyright (c) 2010 Gert van der Knokke |
gertk | 1:e98e29ea2d03 | 3 | */ |
gertk | 1:e98e29ea2d03 | 4 | #include "mbed.h" |
gertk | 1:e98e29ea2d03 | 5 | |
gertk | 1:e98e29ea2d03 | 6 | #define IODIRA 0x00 |
gertk | 1:e98e29ea2d03 | 7 | #define IODIRB 0x01 |
gertk | 1:e98e29ea2d03 | 8 | #define IPOLA 0x02 |
gertk | 1:e98e29ea2d03 | 9 | #define IPOLB 0x03 |
gertk | 1:e98e29ea2d03 | 10 | #define GPINTENA 0x04 |
gertk | 1:e98e29ea2d03 | 11 | #define GPINTENB 0x05 |
gertk | 1:e98e29ea2d03 | 12 | #define DEFVALA 0x06 |
gertk | 1:e98e29ea2d03 | 13 | #define DEFVALB 0x07 |
gertk | 1:e98e29ea2d03 | 14 | #define INTCONA 0x08 |
gertk | 1:e98e29ea2d03 | 15 | #define INTCONB 0x09 |
gertk | 1:e98e29ea2d03 | 16 | #define IOCONA 0x0A |
gertk | 1:e98e29ea2d03 | 17 | #define IOCONB 0x0B |
gertk | 1:e98e29ea2d03 | 18 | #define GPPUA 0x0C |
gertk | 1:e98e29ea2d03 | 19 | #define GPPUB 0x0D |
gertk | 1:e98e29ea2d03 | 20 | #define INTFA 0x0E |
gertk | 1:e98e29ea2d03 | 21 | #define INTFB 0x0F |
gertk | 1:e98e29ea2d03 | 22 | #define INTCAPA 0x10 |
gertk | 1:e98e29ea2d03 | 23 | #define INTCAPB 0x11 |
gertk | 1:e98e29ea2d03 | 24 | #define GPIOA 0x12 |
gertk | 1:e98e29ea2d03 | 25 | #define GPIOB 0x13 |
gertk | 1:e98e29ea2d03 | 26 | #define OLATA 0x14 |
gertk | 1:e98e29ea2d03 | 27 | #define OLATB 0x15 |
gertk | 1:e98e29ea2d03 | 28 | |
gertk | 1:e98e29ea2d03 | 29 | // LCD pin connections/bit numbers |
gertk | 1:e98e29ea2d03 | 30 | #define LCD_HALT 0x80 |
gertk | 1:e98e29ea2d03 | 31 | #define LCD_FS 0x20 |
gertk | 1:e98e29ea2d03 | 32 | #define LCD_RST 0x10 |
gertk | 1:e98e29ea2d03 | 33 | #define LCD_CD 0x08 |
gertk | 1:e98e29ea2d03 | 34 | #define LCD_CE 0x04 |
gertk | 1:e98e29ea2d03 | 35 | #define LCD_RD 0x02 |
gertk | 1:e98e29ea2d03 | 36 | #define LCD_WR 0x01 |
gertk | 1:e98e29ea2d03 | 37 | |
gertk | 1:e98e29ea2d03 | 38 | // T6963C OPCODES |
gertk | 2:9071445a6895 | 39 | #define TXHOME 0x40 // SET TXT HOME ADDRESS |
gertk | 1:e98e29ea2d03 | 40 | #define TXAREA 0x41 // SET TXT AREA |
gertk | 1:e98e29ea2d03 | 41 | #define GRHOME 0x42 // SET GRAPHIC HOME ADDRESS |
gertk | 1:e98e29ea2d03 | 42 | #define GRAREA 0x43 // SET GRAPHIC AREA |
gertk | 1:e98e29ea2d03 | 43 | #define OFFSET 0x22 // SET OFFSET ADDRESS |
gertk | 1:e98e29ea2d03 | 44 | #define ADPSET 0x24 // SET ADDRESS POINTER |
gertk | 1:e98e29ea2d03 | 45 | #define AWRON 0xB0 // SET AUTO WRITE MODE |
gertk | 1:e98e29ea2d03 | 46 | #define AWROFF 0xB2 // RESET AUTO WRITE MODE |
gertk | 2:9071445a6895 | 47 | |
gertk | 2:9071445a6895 | 48 | |
gertk | 2:9071445a6895 | 49 | /* This file contains definitions for all of the commands in a t6963. */ |
gertk | 2:9071445a6895 | 50 | /********************************************************************/ |
gertk | 2:9071445a6895 | 51 | /* Register set */ |
gertk | 2:9071445a6895 | 52 | #define CPS 0x21 //Cursor pointer set |
gertk | 2:9071445a6895 | 53 | #define ORS 0x22 //Offset register set |
gertk | 2:9071445a6895 | 54 | #define APS 0x24 //Address pointer set |
gertk | 2:9071445a6895 | 55 | #define THAS 0x40 //Text home address set |
gertk | 2:9071445a6895 | 56 | #define TAS 0x41 //Text area set |
gertk | 2:9071445a6895 | 57 | #define GHAS 0x42 //Graphic home address set |
gertk | 2:9071445a6895 | 58 | #define GAS 0x43 //Graphic area set |
gertk | 2:9071445a6895 | 59 | #define OM 0x80 //OR mode |
gertk | 2:9071445a6895 | 60 | #define EM 0x81 //EXOR mode |
gertk | 2:9071445a6895 | 61 | #define AM 0x83 //AND mode |
gertk | 2:9071445a6895 | 62 | #define TAM 0x84 //TEXT ATTRIBUTE mode |
gertk | 2:9071445a6895 | 63 | #define DOF 0x90 //Display OFF |
gertk | 2:9071445a6895 | 64 | #define CONBOF 0x92 //Cursor ON, Blink OFF |
gertk | 2:9071445a6895 | 65 | #define CONBON 0x93 //Cursor ON, Blink ON |
gertk | 2:9071445a6895 | 66 | #define TONGOF 0x94 //Text ON, Graphic OFF |
gertk | 2:9071445a6895 | 67 | #define TOFGON 0x98 //Text OFF, Graphic ON |
gertk | 2:9071445a6895 | 68 | #define TONGON 0x9C //Text ON, Graphic ON |
gertk | 2:9071445a6895 | 69 | #define LC1 0xA0 //1 Line cursor |
gertk | 2:9071445a6895 | 70 | #define LC2 0xA1 //2 Line cursor |
gertk | 2:9071445a6895 | 71 | #define LC3 0xA2 //3 Line cursor |
gertk | 2:9071445a6895 | 72 | #define LC4 0xA3 //4 Line cursor |
gertk | 2:9071445a6895 | 73 | #define LC5 0xA4 //5 Line cursor |
gertk | 2:9071445a6895 | 74 | #define LC6 0xA5 //6 Line cursor |
gertk | 2:9071445a6895 | 75 | #define LC7 0xA6 //7 Line cursor |
gertk | 2:9071445a6895 | 76 | #define LC8 0xA7 //8 Line cursor |
gertk | 2:9071445a6895 | 77 | #define DAWS 0xB0 //Data auto write set |
gertk | 2:9071445a6895 | 78 | #define DARS 0xB1 //Data auto read set |
gertk | 2:9071445a6895 | 79 | #define AR 0xB2 //Auto reset |
gertk | 2:9071445a6895 | 80 | #define DWAAI 0xC0 //Data write and ADP increment |
gertk | 2:9071445a6895 | 81 | #define DRAAI 0xC1 //Data read and ADP increment |
gertk | 2:9071445a6895 | 82 | #define DWAAD 0xC2 //Data write and ADP decrement |
gertk | 2:9071445a6895 | 83 | #define DRAAD 0xC3 //Data read and ADP decrement |
gertk | 2:9071445a6895 | 84 | #define DWAAN 0xC4 //Data write and ADP nonvariable |
gertk | 2:9071445a6895 | 85 | #define DRAAN 0xC5 //Data read and ADP nonvariable |
gertk | 2:9071445a6895 | 86 | #define SP 0xE0 //Screen PEEK |
gertk | 2:9071445a6895 | 87 | #define SC 0xE8 //Screen COPY |
gertk | 2:9071445a6895 | 88 | #define BR 0xF0 //Bit RESET |
gertk | 2:9071445a6895 | 89 | #define BS 0xF8 //Bit SET |
gertk | 2:9071445a6895 | 90 | //add 3 bit data to these |
gertk | 2:9071445a6895 | 91 | //commands to select bit |