\r
//*****************************************************************************\r
//\r
-// The sequence of commands used to initialize the SSD0303 controller.\r
+// The sequence of commands used to initialize the SSD0303 controller. Each\r
+// command is described as follows: there is a byte specifying the number of\r
+// bytes in the I2C transfer, followed by that many bytes of command data.\r
//\r
//*****************************************************************************\r
static const unsigned char g_pucOSRAMInit[] =\r
//\r
// Turn off the panel\r
//\r
- 0x80, 0xae,\r
+ 0x02, 0x80, 0xae,\r
\r
//\r
// Set lower column address\r
//\r
- 0x80, 0x04,\r
+ 0x02, 0x80, 0x04,\r
\r
//\r
// Set higher column address\r
//\r
- 0x80, 0x12,\r
+ 0x02, 0x80, 0x12,\r
\r
//\r
// Set contrast control register\r
//\r
- 0x80, 0x81, 0x80, 0x2b,\r
+ 0x04, 0x80, 0x81, 0x80, 0x2b,\r
\r
//\r
// Set segment re-map\r
//\r
- 0x80, 0xa1,\r
+ 0x02, 0x80, 0xa1,\r
\r
//\r
// Set display start line\r
//\r
- 0x80, 0x40,\r
+ 0x02, 0x80, 0x40,\r
\r
//\r
// Set display offset\r
//\r
- 0x80, 0xd3, 0x80, 0x00,\r
+ 0x04, 0x80, 0xd3, 0x80, 0x00,\r
\r
//\r
// Set multiplex ratio\r
//\r
- 0x80, 0xa8, 0x80, 0x0f,\r
+ 0x04, 0x80, 0xa8, 0x80, 0x0f,\r
\r
//\r
// Set the display to normal mode\r
//\r
- 0x80, 0xa4,\r
+ 0x02, 0x80, 0xa4,\r
\r
//\r
// Non-inverted display\r
//\r
- 0x80, 0xa6,\r
+ 0x02, 0x80, 0xa6,\r
\r
//\r
// Set the page address\r
//\r
- 0x80, 0xb0,\r
+ 0x02, 0x80, 0xb0,\r
\r
//\r
// Set COM output scan direction\r
//\r
- 0x80, 0xc8,\r
+ 0x02, 0x80, 0xc8,\r
\r
//\r
// Set display clock divide ratio/oscillator frequency\r
//\r
- 0x80, 0xd5, 0x80, 0x72,\r
+ 0x04, 0x80, 0xd5, 0x80, 0x72,\r
\r
//\r
// Enable mono mode\r
//\r
- 0x80, 0xd8, 0x80, 0x00,\r
+ 0x04, 0x80, 0xd8, 0x80, 0x00,\r
\r
//\r
// Set pre-charge period\r
//\r
- 0x80, 0xd9, 0x80, 0x22,\r
+ 0x04, 0x80, 0xd9, 0x80, 0x22,\r
\r
//\r
// Set COM pins hardware configuration\r
//\r
- 0x80, 0xda, 0x80, 0x12,\r
+ 0x04, 0x80, 0xda, 0x80, 0x12,\r
\r
//\r
// Set VCOM deslect level\r
//\r
- 0x80, 0xdb, 0x80, 0x0f,\r
+ 0x04, 0x80, 0xdb, 0x80, 0x0f,\r
\r
//\r
// Set DC-DC on\r
//\r
- 0x80, 0xad, 0x80, 0x8b,\r
+ 0x04, 0x80, 0xad, 0x80, 0x8b,\r
\r
//\r
// Turn on the panel\r
//\r
- 0x80, 0xaf,\r
+ 0x02, 0x80, 0xaf,\r
};\r
\r
//*****************************************************************************\r
//! This function will clear the display. All pixels in the display will be\r
//! turned off.\r
//!\r
-//! This function is contained in <tt>osram96x16.c</tt>, with\r
-//! <tt>osram96x16.h</tt> containing the API definition for use by\r
-//! applications.\r
-//!\r
//! \return None.\r
//\r
//*****************************************************************************\r
//! characters will be drawn. Therefore, special care is not required to avoid\r
//! supplying a string that is "too long" to display.\r
//!\r
-//! This function is contained in <tt>osram96x16.c</tt>, with\r
-//! <tt>osram96x16.h</tt> containing the API definition for use by\r
-//! applications.\r
-//!\r
//! \return None.\r
//\r
//*****************************************************************************\r
//! to right, followed immediately by the second row of image data. Each byte\r
//! contains the data for the eight scan lines of the column, with the top scan\r
//! line being in the least significant bit of the byte and the bottom scan\r
-//! line being in the most significat bit of the byte.\r
+//! line being in the most significant bit of the byte.\r
//!\r
//! For example, an image four columns wide and sixteen scan lines tall would\r
//! be arranged as follows (showing how the eight bytes of the image would\r
//! +-------+ +-------+ +-------+ +-------+\r
//! \endverbatim\r
//!\r
-//! This function is contained in <tt>osram96x16.c</tt>, with\r
-//! <tt>osram96x16.h</tt> containing the API definition for use by\r
-//! applications.\r
-//!\r
//! \return None.\r
//\r
//*****************************************************************************\r
//! This function initializes the I2C interface to the OLED display and\r
//! configures the SSD0303 controller on the panel.\r
//!\r
-//! This function is contained in <tt>osram96x16.c</tt>, with\r
-//! <tt>osram96x16.h</tt> containing the API definition for use by\r
-//! applications.\r
-//!\r
//! \return None.\r
//\r
//*****************************************************************************\r
void\r
OSRAMInit(tBoolean bFast)\r
{\r
+ unsigned long ulIdx;\r
+\r
//\r
// Enable the I2C and GPIO port B blocks as they are needed by this driver.\r
//\r
// the delay required.\r
//\r
// The derivation of this formula is based on a measured delay of\r
- // OSRAMDelay(1640) for a 100 kHz I2C bus with the CPU running at 50 MHz\r
+ // OSRAMDelay(1700) for a 100 kHz I2C bus with the CPU running at 50 MHz\r
// (referred to as C). To scale this to the delay for a different CPU\r
// speed (since this is just a CPU-based delay loop) is:\r
//\r
// Reducing the constants gives:\r
//\r
// TPR TPR TPR\r
- // C * --- = 1640 * --- = 328 * ---\r
+ // C * --- = 1700 * --- = 340 * ---\r
// 25 25 5\r
//\r
// Note that the constant C is actually a bit larger than it needs to be in\r
// order to provide some safety margin.\r
//\r
- g_ulDelay = (328 * (HWREG(I2C_MASTER_BASE + I2C_MASTER_O_TPR) + 1)) / 5;\r
+ // When the panel is being initialized, the value of C actually needs to be\r
+ // a bit longer (3200 instead of 1700). So, set the larger value for now.\r
+ //\r
+ g_ulDelay = (640 * (HWREG(I2C_MASTER_BASE + I2C_MASTER_O_TPR) + 1)) / 5;\r
+\r
+ //\r
+ // Initialize the SSD0303 controller. Loop through the initialization\r
+ // sequence doing a single I2C transfer for each command.\r
+ //\r
+ for(ulIdx = 0; ulIdx < sizeof(g_pucOSRAMInit);\r
+ ulIdx += g_pucOSRAMInit[ulIdx] + 1)\r
+ {\r
+ //\r
+ // Send this command.\r
+ //\r
+ OSRAMWriteFirst(g_pucOSRAMInit[ulIdx + 1]);\r
+ OSRAMWriteArray(g_pucOSRAMInit + ulIdx + 2, g_pucOSRAMInit[ulIdx] - 2);\r
+ OSRAMWriteFinal(g_pucOSRAMInit[ulIdx + g_pucOSRAMInit[ulIdx]]);\r
+ }\r
\r
//\r
- // Initialize the SSD0303 controller.\r
+ // Now, switch to the actual value of C.\r
//\r
- OSRAMWriteFirst(g_pucOSRAMInit[0]);\r
- OSRAMWriteArray(g_pucOSRAMInit + 1, sizeof(g_pucOSRAMInit) - 2);\r
- OSRAMWriteFinal(g_pucOSRAMInit[sizeof(g_pucOSRAMInit) - 1]);\r
+ g_ulDelay = (340 * (HWREG(I2C_MASTER_BASE + I2C_MASTER_O_TPR) + 1)) / 5;\r
\r
//\r
// Clear the frame buffer.\r
//! This function will turn on the OLED display, causing it to display the\r
//! contents of its internal frame buffer.\r
//!\r
-//! This function is contained in <tt>osram96x16.c</tt>, with\r
-//! <tt>osram96x16.h</tt> containing the API definition for use by\r
-//! applications.\r
-//!\r
//! \return None.\r
//\r
//*****************************************************************************\r
//! the panel due to burn-in (it has similar characters to a CRT in this\r
//! respect).\r
//!\r
-//! This function is contained in <tt>osram96x16.c</tt>, with\r
-//! <tt>osram96x16.h</tt> containing the API definition for use by\r
-//! applications.\r
-//!\r
//! \return None.\r
//\r
//*****************************************************************************\r