bug fixes
[hackover2013-badge-firmware.git] / drivers / lcd / tft / hw / ssd1331.h
1 /**************************************************************************/
2 /*!
3 @file ssd1331.h
4 @author K. Townsend (microBuilder.eu)
5
6 @section LICENSE
7
8 Software License Agreement (BSD License)
9
10 Copyright (c) 2010, microBuilder SARL
11 All rights reserved.
12
13 Redistribution and use in source and binary forms, with or without
14 modification, are permitted provided that the following conditions are met:
15 1. Redistributions of source code must retain the above copyright
16 notice, this list of conditions and the following disclaimer.
17 2. Redistributions in binary form must reproduce the above copyright
18 notice, this list of conditions and the following disclaimer in the
19 documentation and/or other materials provided with the distribution.
20 3. Neither the name of the copyright holders nor the
21 names of its contributors may be used to endorse or promote products
22 derived from this software without specific prior written permission.
23
24 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
25 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
28 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 */
35 /**************************************************************************/
36 #ifndef __SSD1331_H__
37 #define __SSD1331_H__
38
39 #include "projectconfig.h"
40
41 #include "drivers/lcd/tft/lcd.h"
42 #include "core/gpio/gpio.h"
43
44 // Control pins
45 #define SSD1331_SID_PORT 2 // DAT
46 #define SSD1331_SID_PIN 1
47 #define SSD1331_SCK_PORT 2 // SCK
48 #define SSD1331_SCK_PIN 2
49 #define SSD1331_DC_PORT 2 // D/C
50 #define SSD1331_DC_PIN 3
51 #define SSD1331_RST_PORT 2 // RST
52 #define SSD1331_RST_PIN 4
53 #define SSD1331_CS_PORT 2 // OLEDCS
54 #define SSD1331_CS_PIN 5
55
56 // Placed here to try to keep all pin specific values in header file
57 #define SSD1331_DISABLEPULLUPS() do { gpioSetPullup(&IOCON_PIO2_1, gpioPullupMode_Inactive); \
58 gpioSetPullup(&IOCON_PIO2_2, gpioPullupMode_Inactive); \
59 gpioSetPullup(&IOCON_PIO2_3, gpioPullupMode_Inactive); \
60 gpioSetPullup(&IOCON_PIO2_4, gpioPullupMode_Inactive); \
61 gpioSetPullup(&IOCON_PIO2_5, gpioPullupMode_Inactive); } while (0)
62
63 // These registers allow fast single operation clear+set of bits (see section 8.5.1 of LPC1343 UM)
64 #define SSD1331_GPIO2DATA_SID (*(pREG32 (GPIO_GPIO2_BASE + ((1 << SSD1331_SID_PIN) << 2))))
65 #define SSD1331_GPIO2DATA_SCK (*(pREG32 (GPIO_GPIO2_BASE + ((1 << SSD1331_SCK_PIN) << 2))))
66 #define SSD1331_GPIO2DATA_DC (*(pREG32 (GPIO_GPIO2_BASE + ((1 << SSD1331_DC_PIN) << 2))))
67 #define SSD1331_GPIO2DATA_RST (*(pREG32 (GPIO_GPIO2_BASE + ((1 << SSD1331_RST_PIN) << 2))))
68 #define SSD1331_GPIO2DATA_CS (*(pREG32 (GPIO_GPIO2_BASE + ((1 << SSD1331_CS_PIN) << 2))))
69
70 // Macros for control line state
71 #define CLR_DC SSD1331_GPIO2DATA_DC = (0)
72 #define SET_DC SSD1331_GPIO2DATA_DC = (1 << SSD1331_DC_PIN)
73 #define CLR_RST SSD1331_GPIO2DATA_RST = (0)
74 #define SET_RST SSD1331_GPIO2DATA_RST = (1 << SSD1331_RST_PIN)
75 #define CLR_CS SSD1331_GPIO2DATA_CS = (0)
76 #define SET_CS SSD1331_GPIO2DATA_CS = (1 << SSD1331_CS_PIN)
77 #define CLR_SCK SSD1331_GPIO2DATA_SCK = (0)
78 #define SET_SCK SSD1331_GPIO2DATA_SCK = (1 << SSD1331_SCK_PIN)
79 #define CLR_SID SSD1331_GPIO2DATA_SID = (0)
80 #define SET_SID SSD1331_GPIO2DATA_SID = (1 << SSD1331_SID_PIN)
81
82 enum
83 {
84 SSD1331_CMD_DRAWLINE = 0x21,
85 SSD1331_CMD_DRAWRECT = 0x22,
86 SSD1331_CMD_FILL = 0x26,
87 SSD1331_CMD_SETCOLUMN = 0x15,
88 SSD1331_CMD_SETROW = 0x75,
89 SSD1331_CMD_CONTRASTA = 0x81,
90 SSD1331_CMD_CONTRASTB = 0x82,
91 SSD1331_CMD_CONTRASTC = 0x83,
92 SSD1331_CMD_MASTERCURRENT = 0x87,
93 SSD1331_CMD_SETREMAP = 0xA0,
94 SSD1331_CMD_STARTLINE = 0xA1,
95 SSD1331_CMD_DISPLAYOFFSET = 0xA2,
96 SSD1331_CMD_NORMALDISPLAY = 0xA4,
97 SSD1331_CMD_DISPLAYALLON = 0xA5,
98 SSD1331_CMD_DISPLAYALLOFF = 0xA6,
99 SSD1331_CMD_INVERTDISPLAY = 0xA7,
100 SSD1331_CMD_SETMULTIPLEX = 0xA8,
101 SSD1331_CMD_SETMASTER = 0xAD,
102 SSD1331_CMD_DISPLAYOFF = 0xAE,
103 SSD1331_CMD_DISPLAYON = 0xAF,
104 SSD1331_CMD_POWERMODE = 0xB0,
105 SSD1331_CMD_PRECHARGE = 0xB1,
106 SSD1331_CMD_CLOCKDIV = 0xB3,
107 SSD1331_CMD_PRECHARGEA = 0x8A,
108 SSD1331_CMD_PRECHARGEB = 0x8B,
109 SSD1331_CMD_PRECHARGEC = 0x8C,
110 SSD1331_CMD_PRECHARGELEVEL = 0xBB,
111 SSD1331_CMD_VCOMH = 0xBE
112 };
113
114 #endif
This page took 0.04766 seconds and 5 git commands to generate.