//***************************************************************************** // // This function initializes the display task. It should be called from the // application initialization code. // //***************************************************************************** void DisplayTaskInit(void *pvParam) { // // Initialize the display driver and turn the display on. // Display96x16x1Init(false); Display96x16x1DisplayOn(); }
//***************************************************************************** // //! Initialize the OLED display. //! //! \param bFast is a boolean that is \e true if the I2C interface should be //! run at 400 kbps and \e false if it should be run at 100 kbps. //! //! This function initializes the I2C interface to the OLED display and //! configures the SSD0303 or SSD1300 controller on the panel. //! //! \return None. // //***************************************************************************** void Display96x16x1Init(tBoolean bFast) { unsigned long ulIdx; // // The power supply for the OLED display comes from the motor power // supply, which must be turned on. If the application is using the // motor then this is taken care of when the motor driver is initialized. // But if the motor driver is not used, then the motor power supply needs // to be turned on here so the OLED works properly. // SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD); GPIOPinTypeGPIOOutput(GPIO_PORTD_BASE, GPIO_PIN_5); GPIOPinWrite(GPIO_PORTD_BASE, GPIO_PIN_5, GPIO_PIN_5); // // Enable the I2C and GPIO peripherals needed for the display. // SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C1); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG); // // Deassert the display controller reset signal (active low) // GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_0); GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_0, GPIO_PIN_0); // // Wait a short delay, then drive the pin low to reset the controller // SysCtlDelay(32); GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_0, 0); // // Leave it is reset for a short delay, then drive it high to deassert // reset. Then the controller should be out of reset. // SysCtlDelay(32); GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_0, GPIO_PIN_0); // // Configure the GPIO pins needed for the display as I2C // GPIOPinConfigure(GPIO_PG0_I2C1SCL); GPIOPinConfigure(GPIO_PG1_I2C1SDA); GPIOPinTypeI2C(GPIO_PORTG_BASE, GPIO_PIN_0 | GPIO_PIN_1); // // Reset the I2C1 peripheral. // SysCtlPeripheralReset(SYSCTL_PERIPH_I2C1); // // Initialize the I2C master. // I2CMasterInitExpClk(I2C1_MASTER_BASE, SysCtlClockGet(), bFast); // // Initialize the display controller. Loop through the initialization // sequence doing a single I2C transfer for each command. // for(ulIdx = 0; ulIdx < sizeof(g_pucRITInit); ulIdx += g_pucRITInit[ulIdx] + 1) { // // Send this command. // Display96x16x1WriteFirst(g_pucRITInit[ulIdx + 1]); Display96x16x1WriteArray(g_pucRITInit + ulIdx + 2, g_pucRITInit[ulIdx] - 2); Display96x16x1WriteFinal(g_pucRITInit[ulIdx + g_pucRITInit[ulIdx]]); } // // Clear the frame buffer. // Display96x16x1Clear(); // // Turn the display on. // Display96x16x1DisplayOn(); }