This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| en:software:arm-can:drivers:nokia6610 [2010/02/23 13:07] – created mikk.leini | en:software:arm-can:drivers:nokia6610 [2020/07/20 09:00] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 200: | Line 200: | ||
| unsigned long ulTemp; | unsigned long ulTemp; | ||
| - | | + | // |
| - | // Write the byte to the controller. | + | // Write the byte to the controller. |
| - | // | + | // |
| - | SSIDataPut(SSI0_BASE, | + | SSIDataPut(SSI0_BASE, |
| - | + | ||
| - | // | + | // |
| - | // Dummy read to drain the FIFO and time the GPIO signal. | + | // Dummy read to drain the FIFO and time the GPIO signal. |
| - | // | + | // |
| - | SSIDataGet(SSI0_BASE, | + | SSIDataGet(SSI0_BASE, |
| } | } | ||
| Line 225: | Line 225: | ||
| unsigned long ulTemp; | unsigned long ulTemp; | ||
| - | | + | // |
| - | // Write the byte to the controller. | + | // Write the byte to the controller. |
| - | // | + | // |
| - | SSIDataPut(SSI0_BASE, | + | SSIDataPut(SSI0_BASE, |
| - | + | ||
| - | // | + | // |
| - | // Dummy read to drain the FIFO and time the GPIO signal. | + | // Dummy read to drain the FIFO and time the GPIO signal. |
| - | // | + | // |
| - | SSIDataGet(SSI0_BASE, | + | SSIDataGet(SSI0_BASE, |
| } | } | ||
| Line 252: | Line 252: | ||
| { | { | ||
| unsigned long ulTemp; | unsigned long ulTemp; | ||
| - | + | ||
| - | // | + | // |
| - | // Enable the SSI0 and GPIO port blocks as they are needed by this driver. | + | // Enable the SSI0 and GPIO port blocks as they are needed by this driver. |
| - | // | + | // |
| - | SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI0); | + | SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI0); |
| - | SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); | + | SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); |
| - | + | ||
| - | // | + | // |
| - | // Configure the SSI0CLK and SSIOTX pins for SSI operation. | + | // Configure the SSI0CLK and SSIOTX pins for SSI operation. |
| - | // | + | // |
| - | GPIOPinTypeSSI(GPIO_PORTA_BASE, | + | GPIOPinTypeSSI(GPIO_PORTA_BASE, |
| - | GPIOPadConfigSet(GPIO_PORTA_BASE, | + | GPIOPadConfigSet(GPIO_PORTA_BASE, |
| - | | + | GPIO_STRENGTH_8MA, |
| - | | + | // |
| - | // Configure the SSI0 port for master mode. | + | // Configure the SSI0 port for master mode. |
| - | // | + | // |
| - | SSIConfigSetExpClk(SSI0_BASE, | + | SSIConfigSetExpClk(SSI0_BASE, |
| - | | + | SSI_MODE_MASTER, |
| - | + | | |
| - | // | + | // |
| - | // Enable the SSI port. | + | // Enable the SSI port. |
| - | // | + | // |
| - | SSIEnable(SSI0_BASE); | + | SSIEnable(SSI0_BASE); |
| - | + | ||
| - | // | + | // |
| - | // Drain the receive fifo. | + | // Drain the receive fifo. |
| - | // | + | // |
| - | while(SSIDataGetNonBlocking(SSI0_BASE, | + | while(SSIDataGetNonBlocking(SSI0_BASE, |
| - | { | + | { |
| - | } | + | } |
| - | + | ||
| - | // | + | // |
| - | // Configure the GPIO port pin used as a D/Cn signal for LCD device, | + | // Configure the GPIO port pin used as a D/Cn signal for LCD device, |
| - | // and the port pin used to enable power to the LCD panel. | + | // and the port pin used to enable power to the LCD panel. |
| - | // | + | // |
| - | GPIOPinTypeGPIOOutput(GPIO_LCD_BASE, | + | GPIOPinTypeGPIOOutput(GPIO_LCD_BASE, |
| - | GPIOPadConfigSet(GPIO_LCD_BASE, | + | GPIOPadConfigSet(GPIO_LCD_BASE, |
| - | | + | GPIO_STRENGTH_8MA, |
| - | GPIOPinWrite(GPIO_LCD_BASE, | + | GPIOPinWrite(GPIO_LCD_BASE, |
| - | + | ||
| - | // | + | // |
| - | // Initialize the display controller. | + | // Initialize the display controller. |
| - | // | + | // |
| DelayMS(100); | DelayMS(100); | ||
| + | |||
| // | // | ||
| // Display control. | // Display control. | ||
| Line 306: | Line 306: | ||
| WriteData(0x20); | WriteData(0x20); | ||
| WriteData(0x0A); | WriteData(0x0A); | ||
| + | |||
| // | // | ||
| // COM scan 1-80. | // COM scan 1-80. | ||
| Line 373: | Line 373: | ||
| WriteData(0x00); | WriteData(0x00); | ||
| WriteData(0x02); | WriteData(0x02); | ||
| + | |||
| // | // | ||
| // Turn on the display. | // Turn on the display. | ||
| Line 420: | Line 420: | ||
| WriteData(lX + SCREEN_OFFSET_X); | WriteData(lX + SCREEN_OFFSET_X); | ||
| WriteData(lX + SCREEN_OFFSET_X); | WriteData(lX + SCREEN_OFFSET_X); | ||
| + | |||
| // | // | ||
| // Page address (Y) set. | // Page address (Y) set. | ||
| Line 427: | Line 427: | ||
| WriteData(lY + SCREEN_OFFSET_Y); | WriteData(lY + SCREEN_OFFSET_Y); | ||
| WriteData(lY + SCREEN_OFFSET_Y); | WriteData(lY + SCREEN_OFFSET_Y); | ||
| + | |||
| // | // | ||
| // Write memory. | // Write memory. | ||
| // | // | ||
| WriteCommand(RAMWR); | WriteCommand(RAMWR); | ||
| + | |||
| + | // | ||
| + | // Write the pixel value. | ||
| // | // | ||
| - | // Write the pixel value. | ||
| - | // | ||
| WriteData(ulValue >> 4); | WriteData(ulValue >> 4); | ||
| WriteData((ulValue << 4) | (ulValue >> 8)); | WriteData((ulValue << 4) | (ulValue >> 8)); | ||
| Line 472: | Line 472: | ||
| const unsigned char *pucPalette) | const unsigned char *pucPalette) | ||
| { | { | ||
| - | | + | unsigned long ulByte; |
| unsigned long ucNextByte = 0; | unsigned long ucNextByte = 0; | ||
| + | |||
| // | // | ||
| // Page column (X) set. | // Page column (X) set. | ||
| Line 481: | Line 481: | ||
| WriteData(lX + SCREEN_OFFSET_X); | WriteData(lX + SCREEN_OFFSET_X); | ||
| WriteData(lX + SCREEN_OFFSET_X + lCount - 1); | WriteData(lX + SCREEN_OFFSET_X + lCount - 1); | ||
| + | |||
| // | // | ||
| // Page address (Y) set. | // Page address (Y) set. | ||
| Line 488: | Line 488: | ||
| WriteData(lY + SCREEN_OFFSET_Y); | WriteData(lY + SCREEN_OFFSET_Y); | ||
| WriteData(lY + SCREEN_OFFSET_Y); | WriteData(lY + SCREEN_OFFSET_Y); | ||
| - | + | ||
| - | // | + | // |
| // Write memory. | // Write memory. | ||
| // | // | ||
| WriteCommand(RAMWR); | WriteCommand(RAMWR); | ||
| - | + | ||
| - | // | + | // |
| - | // Determine how to interpret the pixel data based on the number of bits | + | // Determine how to interpret the pixel data based on the number of bits |
| - | // per pixel. | + | // per pixel. |
| - | // | + | // |
| - | switch(lBPP) | + | switch(lBPP) |
| - | { | + | { |
| - | // | + | // |
| - | // The pixel data is in 1 bit per pixel format. | + | // The pixel data is in 1 bit per pixel format. |
| // | // | ||
| // NB! Not tested! | // NB! Not tested! | ||
| - | | + | // |
| - | case 1: | + | case 1: |
| - | { | + | { |
| - | // | + | // |
| - | // Loop while there are more pixels to draw. | + | // Loop while there are more pixels to draw. |
| - | // | + | // |
| - | while(lCount) | + | while(lCount) |
| - | { | + | { |
| - | // | + | // |
| - | // Get the next byte of image data. | + | // Get the next byte of image data. |
| - | // | + | // |
| - | ulByte = *pucData++; | + | ulByte = *pucData++; |
| - | + | ||
| - | // | + | // |
| - | // Loop through the pixels in this byte of image data. | + | // Loop through the pixels in this byte of image data. |
| - | // | + | // |
| - | while((lX0 < 8) && lCount) | + | while((lX0 < 8) && lCount) |
| - | { | + | { |
| - | // | + | // |
| - | // Draw this pixel in the appropriate color. | + | // Draw this pixel in the appropriate color. |
| - | // | + | // |
| - | lBPP = ((unsigned long *)pucPalette)[(ulByte >> | + | lBPP = ((unsigned long *)pucPalette)[(ulByte >> |
| - | (7 - lX0)) & 1]; | + | |
| - | WriteData(lBPP >> 4); | + | WriteData(lBPP >> 4); |
| ucNextByte = lBPP << 4; | ucNextByte = lBPP << 4; | ||
| + | |||
| + | // | ||
| + | // Decrement the count of pixels to draw. | ||
| // | // | ||
| - | // Decrement the count of pixels to draw. | + | lCount--; |
| - | // | + | |
| - | | + | |
| lX0++; | lX0++; | ||
| // | // | ||
| - | | + | // See if there is another pixel to draw. |
| - | | + | // |
| if((lX0 < 8) && lCount) | if((lX0 < 8) && lCount) | ||
| { | { | ||
| // | // | ||
| - | | + | // Draw this pixel in the appropriate color. |
| - | | + | // |
| lBPP = ((unsigned long *)pucPalette)[(ulByte >> | lBPP = ((unsigned long *)pucPalette)[(ulByte >> | ||
| - | | + | |
| WriteData(ucNextByte | (lBPP >> 8)); | WriteData(ucNextByte | (lBPP >> 8)); | ||
| WriteData(lBPP); | WriteData(lBPP); | ||
| + | |||
| // | // | ||
| - | | + | // Decrement the count of pixels to draw. |
| - | | + | // |
| - | | + | lCount--; |
| lX0++; | lX0++; | ||
| - | | + | } |
| else | else | ||
| { | { | ||
| Line 563: | Line 563: | ||
| } | } | ||
| } | } | ||
| - | + | ||
| - | // | + | |
| - | // Start at the beginning of the next byte of image data. | + | |
| - | // | + | |
| - | lX0 = 0; | + | |
| - | } | + | } |
| - | + | ||
| - | // | + | // |
| - | // The image data has been drawn. | + | // The image data has been drawn. |
| - | // | + | // |
| - | break; | + | break; |
| - | } | + | } |
| - | + | ||
| - | // | + | // |
| - | // The pixel data is in 4 bit per pixel format. | + | // The pixel data is in 4 bit per pixel format. |
| - | // | + | // |
| - | case 4: | + | case 4: |
| - | { | + | { |
| - | // | + | // |
| - | // Loop while there are more pixels to draw. " | + | // Loop while there are more pixels to draw. " |
| - | // used to jump into the middle of the loop if the first nibble of | + | // used to jump into the middle of the loop if the first nibble of |
| - | // the pixel data should not be used. Duff's device makes use of | + | // the pixel data should not be used. Duff's device makes use of |
| - | // the fact that a case statement is legal anywhere within a | + | // the fact that a case statement is legal anywhere within a |
| - | // sub-block of a switch statement. | + | // sub-block of a switch statement. |
| - | // http:// | + | // http:// |
| - | // information about Duff's device. | + | // information about Duff's device. |
| - | // | + | // |
| - | switch(lX0 & 1) | + | switch(lX0 & 1) |
| - | { | + | { |
| - | case 0: | + | |
| - | while(lCount) | + | |
| - | { | + | |
| - | // | + | |
| - | // Get the upper nibble of the next byte of pixel data | + | |
| - | // and extract the corresponding entry from the | + | |
| - | // palette. | + | |
| - | // | + | |
| - | ulByte = (*pucData >> 4) * 3; | + | |
| - | ulByte = (*(unsigned long *)(pucPalette + ulByte) & | + | |
| - | 0x00ffffff); | + | |
| - | + | ||
| - | // | + | |
| - | // Translate this palette entry and write it to the | + | |
| - | // screen. | + | |
| - | // | + | |
| - | ulByte = DPYCOLORTRANSLATE(ulByte); | + | |
| WriteData(ulByte >> 4); | WriteData(ulByte >> 4); | ||
| ucNextByte = ulByte << 4; | ucNextByte = ulByte << 4; | ||
| - | + | ||
| - | // | + | |
| - | // Decrement the count of pixels to draw. | + | |
| - | // | + | |
| - | lCount--; | + | |
| - | + | ||
| - | // | + | |
| - | // See if there is another pixel to draw. | + | |
| - | // | + | |
| - | if(lCount) | + | |
| - | { | + | |
| - | case 1: | + | |
| - | // | + | |
| - | // Get the lower nibble of the next byte of pixel | + | |
| - | // data and extract the corresponding entry from | + | |
| - | // the palette. | + | |
| - | // | + | |
| - | ulByte = (*pucData++ & 15) * 3; | + | |
| - | ulByte = (*(unsigned long *)(pucPalette + ulByte) & | + | |
| - | 0x00ffffff); | + | |
| - | + | ||
| - | // | + | |
| - | // Translate this palette entry and write it to the | + | |
| - | // screen. | + | |
| - | // | + | |
| - | ulByte = DPYCOLORTRANSLATE(ulByte); | + | |
| - | WriteData(ucNextByte | (ulByte >> 8)); | + | |
| - | WriteData(ulByte); | + | |
| - | + | ||
| - | // | + | |
| - | // Decrement the count of pixels to draw. | + | |
| - | // | + | |
| - | lCount--; | + | |
| - | } | + | |
| else | else | ||
| { | { | ||
| Line 652: | Line 652: | ||
| WriteData(ucNextByte); | WriteData(ucNextByte); | ||
| } | } | ||
| - | | + | |
| - | } | + | } |
| - | + | ||
| - | // | + | |
| - | // The image data has been drawn. | + | |
| - | // | + | |
| - | break; | + | |
| - | } | + | } |
| - | + | ||
| - | // | + | // |
| - | // The pixel data is in 8 bit per pixel format. | + | // The pixel data is in 8 bit per pixel format. |
| // | // | ||
| // NB! Not tested! | // NB! Not tested! | ||
| - | | + | // |
| - | case 8: | + | case 8: |
| - | { | + | { |
| - | // | + | |
| - | // Loop while there are more pixels to draw. | + | |
| - | // | + | |
| - | while(lCount) | + | |
| - | { | + | |
| - | // | + | |
| - | // Get the next byte of pixel data and extract the | + | |
| - | // corresponding entry from the palette. | + | |
| - | // | + | |
| - | ulByte = *pucData++ * 3; | + | |
| - | ulByte = *(unsigned long *)(pucPalette + ulByte) & 0x00ffffff; | + | |
| - | + | ||
| - | // | + | |
| - | // Translate this palette entry and write it to the screen. | + | |
| - | // | + | |
| - | ulByte = DPYCOLORTRANSLATE(ulByte); | + | |
| - | WriteData(ulByte >> 4); | + | |
| ucNextByte = ulByte << 4; | ucNextByte = ulByte << 4; | ||
| + | |||
| // | // | ||
| - | | + | |
| - | // | + | |
| - | lCount--; | + | |
| // | // | ||
| - | | + | |
| - | // | + | |
| if(lCount) | if(lCount) | ||
| { | { | ||
| // | // | ||
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | + | ||
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| WriteData(ucNextByte | (ulByte >> 8)); | WriteData(ucNextByte | (ulByte >> 8)); | ||
| WriteData(ulByte); | WriteData(ulByte); | ||
| + | |||
| // | // | ||
| - | | + | |
| - | // | + | |
| - | lCount--; | + | |
| } | } | ||
| else | else | ||
| Line 723: | Line 723: | ||
| WriteData(ucNextByte); | WriteData(ucNextByte); | ||
| } | } | ||
| - | | + | |
| - | + | ||
| - | // | + | |
| - | // The image data has been drawn. | + | |
| - | // | + | |
| - | break; | + | |
| - | } | + | } |
| - | } | + | } |
| } | } | ||