1 //*****************************************************************************
3 // osram128x64x4.c - Driver for the OSRAM 128x64x4 graphical OLED display.
5 // Copyright (c) 2006-2007 Luminary Micro, Inc. All rights reserved.
7 // Software License Agreement
9 // Luminary Micro, Inc. (LMI) is supplying this software for use solely and
10 // exclusively on LMI's microcontroller products.
12 // The software is owned by LMI and/or its suppliers, and is protected under
13 // applicable copyright laws. All rights are reserved. Any use in violation
14 // of the foregoing restrictions may subject the user to criminal sanctions
15 // under applicable laws, as well as to civil liability for the breach of the
16 // terms and conditions of this license.
18 // THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
19 // OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
20 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
21 // LMI SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
22 // CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
24 // This is part of revision 1408 of the Stellaris Peripheral Driver Library.
26 //*****************************************************************************
28 //*****************************************************************************
30 //! \addtogroup ek_lm3sx965_api
33 //*****************************************************************************
36 #include "hw_memmap.h"
37 #include "hw_sysctl.h"
43 #include "osram128x64x4.h"
45 //*****************************************************************************
47 // Flag to indicate if SSI port is enabled for OSRAM usage.
49 //*****************************************************************************
50 static volatile tBoolean g_bSSIEnabled = false;
52 //*****************************************************************************
54 // Define the OSRAM 128x64x4 Remap Setting(s). This will be used in
55 // several places in the code to switch between vertical and horizontal
56 // address incrementing.
58 // The Remap Command (0xA0) takes one 8-bit parameter. The parameter is
59 // defined as follows.
62 // Bit 6: Disable(0)/Enable(1) COM Split Odd Even
63 // When enabled, the COM signals are split Odd on one side, even on
64 // the other. Otherwise, they are split 0-39 on one side, 40-79 on
67 // Bit 4: Disable(0)/Enable(1) COM Remap
68 // When Enabled, ROW 0-79 map to COM 79-0 (i.e. reverse row order)
70 // Bit 2: Horizontal(0)/Vertical(1) Address Increment
71 // When set, data RAM address will increment along the column rather
72 // than along the row.
73 // Bit 1: Disable(0)/Enable(1) Nibble Remap
74 // When enabled, the upper and lower nibbles in the DATA bus for access
75 // to the data RAM are swapped.
76 // Bit 0: Disable(0)/Enable(1) Column Address Remap
77 // When enabled, DATA RAM columns 0-63 are remapped to Segment Columns
80 //*****************************************************************************
81 #define OSRAM_INIT_REMAP 0x52
82 #define OSRAM_INIT_OFFSET 0x4C
83 static const unsigned char g_pucOSRAM128x64x4VerticalInc[] = { 0xA0, 0x56 };
84 static const unsigned char g_pucOSRAM128x64x4HorizontalInc[] = { 0xA0, 0x52 };
86 //*****************************************************************************
88 // A 5x7 font (in a 6x8 cell, where the sixth column is omitted from this
89 // table) for displaying text on the OLED display. The data is organized as
90 // bytes from the left column to the right column, with each byte containing
91 // the top row in the LSB and the bottom row in the MSB.
93 // Note: This is the same font data that is used in the EK-LM3S811
94 // osram96x16x1 driver. The single bit-per-pixel is expaned in the StringDraw
95 // function to the appropriate four bit-per-pixel gray scale format.
97 //*****************************************************************************
98 static const unsigned char g_pucFont[96][5] =
100 { 0x00, 0x00, 0x00, 0x00, 0x00 }, // " "
101 { 0x00, 0x00, 0x4f, 0x00, 0x00 }, // !
102 { 0x00, 0x07, 0x00, 0x07, 0x00 }, // "
103 { 0x14, 0x7f, 0x14, 0x7f, 0x14 }, // #
104 { 0x24, 0x2a, 0x7f, 0x2a, 0x12 }, // $
105 { 0x23, 0x13, 0x08, 0x64, 0x62 }, // %
106 { 0x36, 0x49, 0x55, 0x22, 0x50 }, // &
107 { 0x00, 0x05, 0x03, 0x00, 0x00 }, // '
108 { 0x00, 0x1c, 0x22, 0x41, 0x00 }, // (
109 { 0x00, 0x41, 0x22, 0x1c, 0x00 }, // )
110 { 0x14, 0x08, 0x3e, 0x08, 0x14 }, // *
111 { 0x08, 0x08, 0x3e, 0x08, 0x08 }, // +
112 { 0x00, 0x50, 0x30, 0x00, 0x00 }, // ,
113 { 0x08, 0x08, 0x08, 0x08, 0x08 }, // -
114 { 0x00, 0x60, 0x60, 0x00, 0x00 }, // .
115 { 0x20, 0x10, 0x08, 0x04, 0x02 }, // /
116 { 0x3e, 0x51, 0x49, 0x45, 0x3e }, // 0
117 { 0x00, 0x42, 0x7f, 0x40, 0x00 }, // 1
118 { 0x42, 0x61, 0x51, 0x49, 0x46 }, // 2
119 { 0x21, 0x41, 0x45, 0x4b, 0x31 }, // 3
120 { 0x18, 0x14, 0x12, 0x7f, 0x10 }, // 4
121 { 0x27, 0x45, 0x45, 0x45, 0x39 }, // 5
122 { 0x3c, 0x4a, 0x49, 0x49, 0x30 }, // 6
123 { 0x01, 0x71, 0x09, 0x05, 0x03 }, // 7
124 { 0x36, 0x49, 0x49, 0x49, 0x36 }, // 8
125 { 0x06, 0x49, 0x49, 0x29, 0x1e }, // 9
126 { 0x00, 0x36, 0x36, 0x00, 0x00 }, // :
127 { 0x00, 0x56, 0x36, 0x00, 0x00 }, // ;
128 { 0x08, 0x14, 0x22, 0x41, 0x00 }, // <
129 { 0x14, 0x14, 0x14, 0x14, 0x14 }, // =
130 { 0x00, 0x41, 0x22, 0x14, 0x08 }, // >
131 { 0x02, 0x01, 0x51, 0x09, 0x06 }, // ?
132 { 0x32, 0x49, 0x79, 0x41, 0x3e }, // @
133 { 0x7e, 0x11, 0x11, 0x11, 0x7e }, // A
134 { 0x7f, 0x49, 0x49, 0x49, 0x36 }, // B
135 { 0x3e, 0x41, 0x41, 0x41, 0x22 }, // C
136 { 0x7f, 0x41, 0x41, 0x22, 0x1c }, // D
137 { 0x7f, 0x49, 0x49, 0x49, 0x41 }, // E
138 { 0x7f, 0x09, 0x09, 0x09, 0x01 }, // F
139 { 0x3e, 0x41, 0x49, 0x49, 0x7a }, // G
140 { 0x7f, 0x08, 0x08, 0x08, 0x7f }, // H
141 { 0x00, 0x41, 0x7f, 0x41, 0x00 }, // I
142 { 0x20, 0x40, 0x41, 0x3f, 0x01 }, // J
143 { 0x7f, 0x08, 0x14, 0x22, 0x41 }, // K
144 { 0x7f, 0x40, 0x40, 0x40, 0x40 }, // L
145 { 0x7f, 0x02, 0x0c, 0x02, 0x7f }, // M
146 { 0x7f, 0x04, 0x08, 0x10, 0x7f }, // N
147 { 0x3e, 0x41, 0x41, 0x41, 0x3e }, // O
148 { 0x7f, 0x09, 0x09, 0x09, 0x06 }, // P
149 { 0x3e, 0x41, 0x51, 0x21, 0x5e }, // Q
150 { 0x7f, 0x09, 0x19, 0x29, 0x46 }, // R
151 { 0x46, 0x49, 0x49, 0x49, 0x31 }, // S
152 { 0x01, 0x01, 0x7f, 0x01, 0x01 }, // T
153 { 0x3f, 0x40, 0x40, 0x40, 0x3f }, // U
154 { 0x1f, 0x20, 0x40, 0x20, 0x1f }, // V
155 { 0x3f, 0x40, 0x38, 0x40, 0x3f }, // W
156 { 0x63, 0x14, 0x08, 0x14, 0x63 }, // X
157 { 0x07, 0x08, 0x70, 0x08, 0x07 }, // Y
158 { 0x61, 0x51, 0x49, 0x45, 0x43 }, // Z
159 { 0x00, 0x7f, 0x41, 0x41, 0x00 }, // [
160 { 0x02, 0x04, 0x08, 0x10, 0x20 }, // "\"
161 { 0x00, 0x41, 0x41, 0x7f, 0x00 }, // ]
162 { 0x04, 0x02, 0x01, 0x02, 0x04 }, // ^
163 { 0x40, 0x40, 0x40, 0x40, 0x40 }, // _
164 { 0x00, 0x01, 0x02, 0x04, 0x00 }, // `
165 { 0x20, 0x54, 0x54, 0x54, 0x78 }, // a
166 { 0x7f, 0x48, 0x44, 0x44, 0x38 }, // b
167 { 0x38, 0x44, 0x44, 0x44, 0x20 }, // c
168 { 0x38, 0x44, 0x44, 0x48, 0x7f }, // d
169 { 0x38, 0x54, 0x54, 0x54, 0x18 }, // e
170 { 0x08, 0x7e, 0x09, 0x01, 0x02 }, // f
171 { 0x0c, 0x52, 0x52, 0x52, 0x3e }, // g
172 { 0x7f, 0x08, 0x04, 0x04, 0x78 }, // h
173 { 0x00, 0x44, 0x7d, 0x40, 0x00 }, // i
174 { 0x20, 0x40, 0x44, 0x3d, 0x00 }, // j
175 { 0x7f, 0x10, 0x28, 0x44, 0x00 }, // k
176 { 0x00, 0x41, 0x7f, 0x40, 0x00 }, // l
177 { 0x7c, 0x04, 0x18, 0x04, 0x78 }, // m
178 { 0x7c, 0x08, 0x04, 0x04, 0x78 }, // n
179 { 0x38, 0x44, 0x44, 0x44, 0x38 }, // o
180 { 0x7c, 0x14, 0x14, 0x14, 0x08 }, // p
181 { 0x08, 0x14, 0x14, 0x18, 0x7c }, // q
182 { 0x7c, 0x08, 0x04, 0x04, 0x08 }, // r
183 { 0x48, 0x54, 0x54, 0x54, 0x20 }, // s
184 { 0x04, 0x3f, 0x44, 0x40, 0x20 }, // t
185 { 0x3c, 0x40, 0x40, 0x20, 0x7c }, // u
186 { 0x1c, 0x20, 0x40, 0x20, 0x1c }, // v
187 { 0x3c, 0x40, 0x30, 0x40, 0x3c }, // w
188 { 0x44, 0x28, 0x10, 0x28, 0x44 }, // x
189 { 0x0c, 0x50, 0x50, 0x50, 0x3c }, // y
190 { 0x44, 0x64, 0x54, 0x4c, 0x44 }, // z
191 { 0x00, 0x08, 0x36, 0x41, 0x00 }, // {
192 { 0x00, 0x00, 0x7f, 0x00, 0x00 }, // |
193 { 0x00, 0x41, 0x36, 0x08, 0x00 }, // }
194 { 0x02, 0x01, 0x02, 0x04, 0x02 }, // ~
195 { 0x02, 0x01, 0x02, 0x04, 0x02 }, // ~
198 //*****************************************************************************
200 // The sequence of commands used to initialize the SSD0303 controller. Each
201 // command is described as follows: there is a byte specifying the number of
202 // bytes in the command sequence, followed by that many bytes of command data.
203 // Note: This initialization sequence is derived from OSRAM App Note AN018.
205 //*****************************************************************************
206 static const unsigned char g_pucOSRAM128x64x4Init[] =
211 4, 0x15, 0, 63, 0xe3,
216 4, 0x75, 0, 63, 0xe3,
224 // Half Current Range
231 3, 0xA0, OSRAM_INIT_REMAP, 0xe3,
234 // Display Start Line
241 3, 0xA2, OSRAM_INIT_OFFSET, 0xe3,
244 // Display Mode Normal
264 // Display Clock Divide
286 10, 0xB8, 0x01, 0x11, 0x22, 0x32, 0x43, 0x54, 0x65, 0x76, 0xe3,
298 //*****************************************************************************
302 //! Write a sequence of command bytes to the SSD0323 controller.
304 //! The data is written in a polled fashion; this function will not return
305 //! until the entire byte sequence has been written to the controller.
309 //*****************************************************************************
311 OSRAMWriteCommand(const unsigned char *pucBuffer, unsigned long ulCount)
313 unsigned long ulTemp;
316 // Return iff SSI port is not enabled for OSRAM.
324 // Clear the command/control bit to enable command mode.
326 GPIOPinWrite(GPIO_PORTC_BASE, GPIO_PIN_7, 0);
329 // Loop while there are more bytes left to be transferred.
334 // Write the next byte to the controller.
336 SSIDataPut(SSI0_BASE, *pucBuffer++);
339 // Dummy read to drain the fifo and time the GPIO signal.
341 SSIDataGet(SSI0_BASE, &ulTemp);
344 // Decrement the BYTE counter.
350 //*****************************************************************************
354 //! Write a sequence of data bytes to the SSD0323 controller.
356 //! The data is written in a polled fashion; this function will not return
357 //! until the entire byte sequence has been written to the controller.
361 //*****************************************************************************
363 OSRAMWriteData(const unsigned char *pucBuffer, unsigned long ulCount)
365 unsigned long ulTemp;
368 // Return iff SSI port is not enabled for OSRAM.
376 // Set the command/control bit to enable data mode.
378 GPIOPinWrite(GPIO_PORTC_BASE, GPIO_PIN_7, GPIO_PIN_7);
381 // Loop while there are more bytes left to be transferred.
386 // Write the next byte to the controller.
388 SSIDataPut(SSI0_BASE, *pucBuffer++);
391 // Dummy read to drain the fifo and time the GPIO signal.
393 SSIDataGet(SSI0_BASE, &ulTemp);
396 // Decrement the BYTE counter.
402 //*****************************************************************************
404 //! Clears the OLED display.
406 //! This function will clear the display RAM. All pixels in the display will
409 //! This function is contained in <tt>osram128x64x4.c</tt>, with
410 //! <tt>osram128x64x4.h</tt> containing the API definition for use by
415 //*****************************************************************************
417 OSRAM128x64x4Clear(void)
419 static const unsigned char pucCommand1[] = { 0x15, 0, 63 };
420 static const unsigned char pucCommand2[] = { 0x75, 0, 79 };
421 unsigned long ulRow, ulColumn;
422 static unsigned char pucZeroBuffer[8] = { 0, 0, 0, 0, 0, 0, 0, 0};
425 // Set the window to fill the entire display.
427 OSRAMWriteCommand(pucCommand1, sizeof(pucCommand1));
428 OSRAMWriteCommand(pucCommand2, sizeof(pucCommand2));
429 OSRAMWriteCommand(g_pucOSRAM128x64x4VerticalInc,
430 sizeof(g_pucOSRAM128x64x4VerticalInc));
433 // In vertical address increment mode, loop through each column, filling
436 for(ulColumn = 0; ulColumn < (128/2); ulColumn++)
439 // 8 rows (bytes) per row of text.
441 for(ulRow = 0; ulRow < 80; ulRow += 8)
443 OSRAMWriteData(pucZeroBuffer, sizeof(pucZeroBuffer));
448 //*****************************************************************************
450 //! Displays a string on the OLED display.
452 //! \param pcStr is a pointer to the string to display.
453 //! \param ulX is the horizontal position to display the string, specified in
454 //! columns from the left edge of the display.
455 //! \param ulY is the vertical position to display the string, specified in
456 //! rows from the top edge of the display.
457 //! \param ucLevel is the 4-bit grey scale value to be used for displayed text.
459 //! This function will draw a string on the display. Only the ASCII characters
460 //! between 32 (space) and 126 (tilde) are supported; other characters will
461 //! result in random data being draw on the display (based on whatever appears
462 //! before/after the font in memory). The font is mono-spaced, so characters
463 //! such as "i" and "l" have more white space around them than characters such
466 //! If the drawing of the string reaches the right edge of the display, no more
467 //! characters will be drawn. Therefore, special care is not required to avoid
468 //! supplying a string that is "too long" to display.
470 //! This function is contained in <tt>osram128x64x4.c</tt>, with
471 //! <tt>osram128x64x4.h</tt> containing the API definition for use by
474 //! \note Because the OLED display packs 2 pixels of data in a single byte, the
475 //! parameter \e ulX must be an even column number (e.g. 0, 2, 4, etc).
479 //*****************************************************************************
481 OSRAM128x64x4StringDraw(const char *pcStr, unsigned long ulX,
482 unsigned long ulY, unsigned char ucLevel)
484 static unsigned char pucBuffer[8];
485 unsigned long ulIdx1, ulIdx2;
486 unsigned char ucTemp;
489 // Check the arguments.
492 ASSERT((ulX & 1) == 0);
494 ASSERT(ucLevel < 16);
497 // Setup a window starting at the specified column and row, ending
498 // at the right edge of the display and 8 rows down (single character row).
501 pucBuffer[1] = ulX / 2;
503 OSRAMWriteCommand(pucBuffer, 3);
506 pucBuffer[2] = ulY + 7;
507 OSRAMWriteCommand(pucBuffer, 3);
508 OSRAMWriteCommand(g_pucOSRAM128x64x4VerticalInc,
509 sizeof(g_pucOSRAM128x64x4VerticalInc));
512 // Loop while there are more characters in the string.
517 // Get a working copy of the current character and convert to an
518 // index into the character bit-map array.
532 // Build and display the character buffer.
534 for(ulIdx1 = 0; ulIdx1 < 3; ulIdx1++)
537 // Convert two columns of 1-bit font data into a single data
538 // byte column of 4-bit font data.
540 for(ulIdx2 = 0; ulIdx2 < 8; ulIdx2++)
542 pucBuffer[ulIdx2] = 0;
543 if(g_pucFont[ucTemp][ulIdx1*2] & (1 << ulIdx2))
545 pucBuffer[ulIdx2] = ((ucLevel << 4) & 0xf0);
548 (g_pucFont[ucTemp][ulIdx1*2+1] & (1 << ulIdx2)))
550 pucBuffer[ulIdx2] |= ((ucLevel << 0) & 0x0f);
555 // If there is room, dump the single data byte column to the
556 // display. Otherwise, bail out.
560 OSRAMWriteData(pucBuffer, 8);
570 // Advance to the next character.
576 //*****************************************************************************
578 //! Displays an image on the OLED display.
580 //! \param pucImage is a pointer to the image data.
581 //! \param ulX is the horizontal position to display this image, specified in
582 //! columns from the left edge of the display.
583 //! \param ulY is the vertical position to display this image, specified in
584 //! rows from the top of the display.
585 //! \param ulWidth is the width of the image, specified in columns.
586 //! \param ulHeight is the height of the image, specified in rows.
588 //! This function will display a bitmap graphic on the display. Because of the
589 //! format of the display RAM, the starting column (/e ulX) and the number of
590 //! columns (/e ulWidth) must be an integer multiple of two.
592 //! The image data is organized with the first row of image data appearing left
593 //! to right, followed immediately by the second row of image data. Each byte
594 //! contains the data for two columns in the current row, with the leftmost
595 //! column being contained in bits 7:4 and the rightmost column being contained
598 //! For example, an image six columns wide and seven scan lines tall would
599 //! be arranged as follows (showing how the twenty one bytes of the image would
600 //! appear on the display):
603 //! +-------------------+-------------------+-------------------+
604 //! | Byte 0 | Byte 1 | Byte 2 |
605 //! +---------+---------+---------+---------+---------+---------+
606 //! | 7 6 5 4 | 3 2 1 0 | 7 6 5 4 | 3 2 1 0 | 7 6 5 4 | 3 2 1 0 |
607 //! +---------+---------+---------+---------+---------+---------+
608 //! | Byte 3 | Byte 4 | Byte 5 |
609 //! +---------+---------+---------+---------+---------+---------+
610 //! | 7 6 5 4 | 3 2 1 0 | 7 6 5 4 | 3 2 1 0 | 7 6 5 4 | 3 2 1 0 |
611 //! +---------+---------+---------+---------+---------+---------+
612 //! | Byte 6 | Byte 7 | Byte 8 |
613 //! +---------+---------+---------+---------+---------+---------+
614 //! | 7 6 5 4 | 3 2 1 0 | 7 6 5 4 | 3 2 1 0 | 7 6 5 4 | 3 2 1 0 |
615 //! +---------+---------+---------+---------+---------+---------+
616 //! | Byte 9 | Byte 10 | Byte 11 |
617 //! +---------+---------+---------+---------+---------+---------+
618 //! | 7 6 5 4 | 3 2 1 0 | 7 6 5 4 | 3 2 1 0 | 7 6 5 4 | 3 2 1 0 |
619 //! +---------+---------+---------+---------+---------+---------+
620 //! | Byte 12 | Byte 13 | Byte 14 |
621 //! +---------+---------+---------+--3------+---------+---------+
622 //! | 7 6 5 4 | 3 2 1 0 | 7 6 5 4 | 3 2 1 0 | 7 6 5 4 | 3 2 1 0 |
623 //! +---------+---------+---------+---------+---------+---------+
624 //! | Byte 15 | Byte 16 | Byte 17 |
625 //! +---------+---------+---------+---------+---------+---------+
626 //! | 7 6 5 4 | 3 2 1 0 | 7 6 5 4 | 3 2 1 0 | 7 6 5 4 | 3 2 1 0 |
627 //! +---------+---------+---------+---------+---------+---------+
628 //! | Byte 18 | Byte 19 | Byte 20 |
629 //! +---------+---------+---------+---------+---------+---------+
630 //! | 7 6 5 4 | 3 2 1 0 | 7 6 5 4 | 3 2 1 0 | 7 6 5 4 | 3 2 1 0 |
631 //! +---------+---------+---------+---------+---------+---------+
634 //! This function is contained in <tt>osram128x64x4.c</tt>, with
635 //! <tt>osram128x64x4.h</tt> containing the API definition for use by`
640 //*****************************************************************************
642 OSRAM128x64x4ImageDraw(const unsigned char *pucImage, unsigned long ulX,
643 unsigned long ulY, unsigned long ulWidth,
644 unsigned long ulHeight)
646 static unsigned char pucBuffer[8];
649 // Check the arguments.
652 ASSERT((ulX & 1) == 0);
654 ASSERT((ulX + ulWidth) <= 128);
655 ASSERT((ulY + ulHeight) <= 64);
656 ASSERT((ulWidth & 1) == 0);
659 // Setup a window starting at the specified column and row, and ending
660 // at the column + width and row+height.
663 pucBuffer[1] = ulX / 2;
664 pucBuffer[2] = (ulX + ulWidth - 2) / 2;
665 OSRAMWriteCommand(pucBuffer, 3);
668 pucBuffer[2] = ulY + ulHeight - 1;
669 OSRAMWriteCommand(pucBuffer, 3);
670 OSRAMWriteCommand(g_pucOSRAM128x64x4HorizontalInc,
671 sizeof(g_pucOSRAM128x64x4HorizontalInc));
674 // Loop while there are more rows to display.
679 // Write this row of image data.
681 OSRAMWriteData(pucImage, (ulWidth / 2));
684 // Advance to the next row of the image.
686 pucImage += (ulWidth / 2);
690 //*****************************************************************************
692 //! Enable the SSI component of the OLED display driver.
694 //! \param ulFrequency specifies the SSI Clock Frequency to be used.
696 //! This function initializes the SSI interface to the OLED display.
698 //! This function is contained in <tt>osram128x64x4.c</tt>, with
699 //! <tt>osram128x64x4.h</tt> containing the API definition for use by
704 //*****************************************************************************
706 OSRAM128x64x4Enable(unsigned long ulFrequency)
708 unsigned long ulTemp;
711 // Disable the SSI port.
713 SSIDisable(SSI0_BASE);
716 // Configure the SSI0 port for master mode.
718 SSIConfig(SSI0_BASE, SSI_FRF_MOTO_MODE_2, SSI_MODE_MASTER, ulFrequency, 8);
721 // (Re)Enable SSI control of the FSS pin.
723 GPIOPinTypeSSI(GPIO_PORTA_BASE, GPIO_PIN_3);
724 GPIOPadConfigSet(GPIO_PORTA_BASE, GPIO_PIN_3, GPIO_STRENGTH_8MA,
725 GPIO_PIN_TYPE_STD_WPU);
728 // Enable the SSI port.
730 SSIEnable(SSI0_BASE);
733 // Drain the receive fifo.
735 while(SSIDataNonBlockingGet(SSI0_BASE, &ulTemp) != 0)
740 // Indicate that the OSRAM driver can use the SSI Port.
742 g_bSSIEnabled = true;
745 //*****************************************************************************
747 //! Enable the SSI component of the OLED display driver.
749 //! \param ulFrequency specifies the SSI Clock Frequency to be used.
751 //! This function initializes the SSI interface to the OLED display.
753 //! This function is contained in <tt>osram128x64x4.c</tt>, with
754 //! <tt>osram128x64x4.h</tt> containing the API definition for use by
759 //*****************************************************************************
761 OSRAM128x64x4Disable(void)
763 unsigned long ulTemp;
766 // Indicate that the OSRAM driver can no longer use the SSI Port.
768 g_bSSIEnabled = false;
771 // Drain the receive fifo.
773 while(SSIDataNonBlockingGet(SSI0_BASE, &ulTemp) != 0)
778 // Disable the SSI port.
780 SSIDisable(SSI0_BASE);
783 // Disable SSI control of the FSS pin.
785 GPIODirModeSet(GPIO_PORTA_BASE, GPIO_PIN_3, GPIO_DIR_MODE_OUT);
786 GPIOPadConfigSet(GPIO_PORTA_BASE, GPIO_PIN_3, GPIO_STRENGTH_8MA,
787 GPIO_PIN_TYPE_STD_WPU);
788 GPIOPinWrite(GPIO_PORTA_BASE, GPIO_PIN_3, GPIO_PIN_3);
792 //*****************************************************************************
794 //! Initialize the OLED display.
796 //! \param ulFrequency specifies the SSI Clock Frequency to be used.
798 //! This function initializes the SSI interface to the OLED display and
799 //! configures the SSD0323 controller on the panel.
801 //! This function is contained in <tt>osram128x64x4.c</tt>, with
802 //! <tt>osram128x64x4.h</tt> containing the API definition for use by
807 //*****************************************************************************
809 OSRAM128x64x4Init(unsigned long ulFrequency)
814 // Enable the SSI0 and GPIO port blocks as they are needed by this driver.
816 SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI0);
817 SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
818 SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);
821 // Configure the SSI0CLK and SSIOTX pins for SSI operation.
823 GPIOPinTypeSSI(GPIO_PORTA_BASE, GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_5);
824 GPIOPadConfigSet(GPIO_PORTA_BASE, GPIO_PIN_2, GPIO_STRENGTH_8MA,
825 GPIO_PIN_TYPE_STD_WPU);
826 GPIOPadConfigSet(GPIO_PORTA_BASE, GPIO_PIN_3, GPIO_STRENGTH_8MA,
827 GPIO_PIN_TYPE_STD_WPU);
828 GPIOPadConfigSet(GPIO_PORTA_BASE, GPIO_PIN_5, GPIO_STRENGTH_8MA,
829 GPIO_PIN_TYPE_STD_WPU);
832 // Configure the PC7 pin as a D/Cn signal for OLED device.
834 GPIODirModeSet(GPIO_PORTC_BASE, GPIO_PIN_7, GPIO_DIR_MODE_OUT);
835 GPIOPadConfigSet(GPIO_PORTC_BASE, GPIO_PIN_7, GPIO_STRENGTH_8MA,
837 GPIOPinWrite(GPIO_PORTC_BASE, GPIO_PIN_7, GPIO_PIN_7);
840 // Configure and enable the SSI0 port for master mode.
842 OSRAM128x64x4Enable(ulFrequency);
845 // Clear the frame buffer.
847 OSRAM128x64x4Clear();
850 // Initialize the SSD0323 controller. Loop through the initialization
851 // sequence array, sending each command "string" to the controller.
853 for(ulIdx = 0; ulIdx < sizeof(g_pucOSRAM128x64x4Init);
854 ulIdx += g_pucOSRAM128x64x4Init[ulIdx] + 1)
857 // Send this command.
859 OSRAMWriteCommand(g_pucOSRAM128x64x4Init + ulIdx + 1,
860 g_pucOSRAM128x64x4Init[ulIdx] - 1);
864 //*****************************************************************************
866 //! Turns on the OLED display.
868 //! This function will turn on the OLED display, causing it to display the
869 //! contents of its internal frame buffer.
871 //! This function is contained in <tt>osram128x64x4.c</tt>, with
872 //! <tt>osram128x64x4.h</tt> containing the API definition for use by
877 //*****************************************************************************
879 OSRAM128x64x4DisplayOn(void)
884 // Initialize the SSD0323 controller. Loop through the initialization
885 // sequence array, sending each command "string" to the controller.
887 for(ulIdx = 0; ulIdx < sizeof(g_pucOSRAM128x64x4Init);
888 ulIdx += g_pucOSRAM128x64x4Init[ulIdx] + 1)
891 // Send this command.
893 OSRAMWriteCommand(g_pucOSRAM128x64x4Init + ulIdx + 1,
894 g_pucOSRAM128x64x4Init[ulIdx] - 1);
898 //*****************************************************************************
900 //! Turns off the OLED display.
902 //! This function will turn off the OLED display. This will stop the scanning
903 //! of the panel and turn off the on-chip DC-DC converter, preventing damage to
904 //! the panel due to burn-in (it has similar characters to a CRT in this
907 //! This function is contained in <tt>osram128x64x4.c</tt>, with
908 //! <tt>osram128x64x4.h</tt> containing the API definition for use by
913 //*****************************************************************************
915 OSRAM128x64x4DisplayOff(void)
917 static const unsigned char pucCommand1[] =
923 // Turn off the DC-DC converter and the display.
925 OSRAMWriteCommand(pucCommand1, sizeof(pucCommand1));
928 //*****************************************************************************
930 // Close the Doxygen group.
933 //*****************************************************************************