I am not able to clear the screen of the LCD.I am using sitara AM3352 ARMcortex A8 family.
I have interfaced STN(LCD) screen with AM3352 processor.
I have written the code for sending string on LCD using graphics library in CCScode composer studio IDE on windows platform.
But i am not able to clear string the LCD.It is overwriting when i write on the same location.
Please can you help me?
I am sending you the code below
#include <string.h>
#include "ff.h"
#include "hw_types.h"
#include "interrupt.h"
#include "soc_AM335x.h"
#include "evmAM335x.h"
#include "raster.h"
#include "grlib.h"
#include "usblib.h"
#include "usbhid.h"
#include "usbhhidmouse.h"
#include "usbmsc.h"
#include "usbhost.h"
#include "usbhhid.h"
#include "usbhmsc.h"
#include "delay.h"
#include "cmdline.h"
#include "cppi41dma.h"
#include "cache.h"
#include "mmu.h"
#include "uart_irda_cir.h"
#include "uartStdio.h"
#include "consoleUtils.h"
#include "hw_control_AM335x.h"
#include "gpio_v2.h"
#include "pin_mux.h"
#include "ehrpwm.h"
//*****************************************************************************
//
// Graphics context used to show text on the CSTN display.
//
//*****************************************************************************
tContext g_sContext;
//#define LCD_SIZE (800*480*4)
#define LCD_SIZE (1024*768*4)
#define PALETTE_SIZE 32
//#define LCD_WIDTH 800
//#define LCD_HEIGHT 480
#define LCD_WIDTH 1024
#define LCD_HEIGHT 768
#define PALETTE_OFFSET 4
#define FRAME_BUFFER_0 0
#define FRAME_BUFFER_1 1
#define PIXEL_24_BPP_PACKED (0x0)
#define PIXEL_24_BPP_UNPACKED (0x1)
#if defined(__IAR_SYSTEMS_ICC__)
#pragma data_alignment=(16*1024)
static volatile unsigned int pageTable[4*1024];
#else
static volatile unsigned int pageTable[4*1024]__attribute__((aligned(16*1024)));
#endif
// Memory that is used as the local frame buffer.
#if defined(__IAR_SYSTEMS_ICC__)
#pragma data_alignment=4
unsigned char g_pucBuffer[GrOffScreen24BPPSize(LCD_WIDTH, LCD_HEIGHT, PIXEL_24_BPP_UNPACKED)];
#elif defined __TMS470__ || defined _TMS320C6X
#pragma DATA_ALIGN(g_pucBuffer, 4);
unsigned char g_pucBuffer[GrOffScreen24BPPSize(LCD_WIDTH, LCD_HEIGHT, PIXEL_24_BPP_UNPACKED)];
#else
unsigned char g_pucBuffer[GrOffScreen24BPPSize(LCD_WIDTH, LCD_HEIGHT, PIXEL_24_BPP_UNPACKED)] __attribute__ ((aligned (4)));
#endif
// The graphics library display structure.
tDisplay g_s35_800x480x24Display;
// 32 byte Palette.
unsigned int palette_32b[PALETTE_SIZE/sizeof(unsigned int)] =
{0x4000u, 0x0000u, 0x0000u, 0x0000u, 0x0000u, 0x0000u, 0x0000u, 0x0000u};
#define START_ADDR_DDR (0x80000000)
#define START_ADDR_DEV (0x44000000)
#define START_ADDR_OCMC (0x40300000)
#define NUM_SECTIONS_DDR (512)
#define NUM_SECTIONS_DEV (960)
#define NUM_SECTIONS_OCMC (1)
#define GPIO_INSTANCE_ADDRESS (SOC_GPIO_1_REGS)
#define GPIO_INSTANCE_PIN_NUMBER (30)
#define LCDC_INSTANCE SOC_LCDC_0_REGS
#define CLOCK_DIV_VAL (10000)
#define SOC_EHRPWM_2_MODULE_FREQ (100000000)
#define SOC_EHRPWM_0_MODULE_FREQ (100000000)
static void EHRPWMConfigure0(void);
static void MMUConfigAndEnable(void);
//*****************************************************************************
//
// The number of SysTick ticks per second.
//
//*****************************************************************************
#define TICKS_PER_SECOND 100
#define MS_PER_SYSTICK (1000 / TICKS_PER_SECOND)
//*****************************************************************************
//
// Our running system tick counter and a global used to determine the time
// elapsed since last call to GetTickms().
//
//*****************************************************************************
unsigned int g_ulSysTickCount;
unsigned int g_ulLastTick;
//*****************************************************************************
//
// Defines the size of the buffers that hold the path, or temporary data from
// the memory card. There are two buffers allocated of this size. The buffer
// size must be large enough to hold the longest expected full path name,
// including the file name, and a trailing null character.
//
//*****************************************************************************
//*****************************************************************************
//
// These defines are used to define the screen constraints to the application./////////
//
//*****************************************************************************
//#define DISPLAY_BANNER_HEIGHT 23
#define DISPLAY_BANNER_HEIGHT 80
//#define DISPLAY_BANNER_BG ClrDarkBlue
#define DISPLAY_BANNER_BG ClrBlue
//#define DISPLAY_BANNER_FG ClrWhite
#define DISPLAY_BANNER_FG ClrDarkGoldenrod
//#define DISPLAY_MOUSE_BG ClrBlack
#define DISPLAY_MOUSE_BG ClrDarkBlue
#define DISPLAY_MOUSE_FG ClrWhite
#define DISPLAY_MOUSE_SIZE 7
char Name[100]="Aurora_Team:SUMANT,SANDIP,PRAVAT,MITESH";
char Name1[100]="A";
char Name2[100]="B";
char Name3[100]="C";
int iStatus;
tRectangle sRect;
unsigned int i,j;
unsigned char *src, *dest;// tRectangle sRect;
static int USBState = -1;// tRectangle sRect;
int iButton;
//extern unsigned int userCalendar ;
//extern unsigned int userTime ;
//*****************************************************************************
//
// This function updates the cursor position based on deltas received from
// the mouse device.
//
// \param iXDelta is the signed movement in the X direction.
// \param iYDelta is the signed movement in the Y direction.
//
// This function is called by the mouse handler code when it detects a change
// in the position of the mouse. It will take the inputs and force them
// to be constrained to the display area of the screen. If the left mouse
// button is pressed then the mouse will draw on the screen and if it is not
// it will move around normally. A side effect of not being able to read the
// current state of the screen is that the cursor will erase anything it moves
// over while the left mouse button is not pressed.
//
// \return None.
//
//*****************************************************************************
//void rtcClock(void);
/*
** For each end of frame interrupt base and ceiling is reconfigured
*/
void LCD_CLEAR_SCREEN();
static void LCDIsr(void)
{
unsigned int status;
status = RasterIntStatus(SOC_LCDC_0_REGS,RASTER_END_OF_FRAME0_INT_STAT |
RASTER_END_OF_FRAME1_INT_STAT );
status = RasterClearGetIntStatus(SOC_LCDC_0_REGS, status);
}
/*
** Configures raster to display image
*/
static void SetUpLCD(void)
{
/* Enable clock for LCD Module */
LCDModuleClkConfig();
LCDPinMuxSetup();
/*
**Clock for DMA,LIDD and for Core(which encompasses
** Raster Active Matrix and Passive Matrix logic)
** enabled.
*/
RasterClocksEnable(SOC_LCDC_0_REGS);
/* Disable raster */
RasterDisable(SOC_LCDC_0_REGS);
/* Configure the pclk for NEC display*/ //Mitesh
RasterClkConfig(LCDC_INSTANCE, 64000000, 192000000);
/* Configuring DMA of LCD controller */
RasterDMAConfig(LCDC_INSTANCE, RASTER_DOUBLE_FRAME_BUFFER,
RASTER_BURST_SIZE_16, RASTER_FIFO_THRESHOLD_8,
RASTER_BIG_ENDIAN_DISABLE);
/* Configuring modes(ex:tft or stn,color or monochrome etc) for raster controller */ // Mitesh -> RASTER_DATA
RasterModeConfig(LCDC_INSTANCE, RASTER_DISPLAY_MODE_TFT_UNPACKED,
RASTER_DATA, RASTER_COLOR, RASTER_RIGHT_ALIGNED);
/* Configuring the polarity of timing parameters of raster controller */
RasterTiming2Configure(LCDC_INSTANCE, RASTER_FRAME_CLOCK_LOW |
RASTER_LINE_CLOCK_LOW |
RASTER_PIXEL_CLOCK_HIGH|
RASTER_SYNC_EDGE_RISING|
RASTER_SYNC_CTRL_ACTIVE|
RASTER_AC_BIAS_HIGH , 0, 255);
/* Configuring horizontal timing parameter */
RasterHparamConfig(LCDC_INSTANCE, 1024, 4, 0, 320);
//RasterHparamConfig(LCDC_INSTANCE, 480, 4, 0, 864);
/* Configuring vertical timing parameters */
RasterVparamConfig(LCDC_INSTANCE, 768, 10, 38, 0);
//RasterVparamConfig(LCDC_INSTANCE, 368, 10, 38, 400);
RasterFIFODMADelayConfig(LCDC_INSTANCE, 128);
//Mitesh Changes Start commented code
/* Configure the pclk */
//RasterClkConfig(SOC_LCDC_0_REGS, 23040000, 192000000);
/* Configuring DMA of LCD controller */
//RasterDMAConfig(SOC_LCDC_0_REGS, RASTER_DOUBLE_FRAME_BUFFER,
// RASTER_BURST_SIZE_16, RASTER_FIFO_THRESHOLD_8,
// RASTER_BIG_ENDIAN_DISABLE);
/* Configuring modes(ex:tft or stn,color or monochrome etc) for raster controller */
//RasterModeConfig(SOC_LCDC_0_REGS, RASTER_DISPLAY_MODE_TFT_UNPACKED,
// RASTER_PALETTE_DATA, RASTER_COLOR, RASTER_RIGHT_ALIGNED);
/* Configuring the polarity of timing parameters of raster controller */
//RasterTiming2Configure(SOC_LCDC_0_REGS, RASTER_FRAME_CLOCK_LOW |
// RASTER_LINE_CLOCK_LOW |
// RASTER_PIXEL_CLOCK_HIGH|
// RASTER_SYNC_EDGE_RISING|
// RASTER_SYNC_CTRL_ACTIVE|
// RASTER_AC_BIAS_HIGH , 0, 255);
/* Configuring horizontal timing parameter */
//RasterHparamConfig(SOC_LCDC_0_REGS, 800, 48, 40, 40);
/* Configuring vertical timing parameters */
//RasterVparamConfig(SOC_LCDC_0_REGS, 480, 3, 13, 29);
//RasterFIFODMADelayConfig(SOC_LCDC_0_REGS, 128); //Mitesh changes end
}
//*****************************************************************************
//
// This is the handler for this SysTick interrupt.
//
//*****************************************************************************
void SysTickIntHandler(void)
{
//
// Update our tick counter.
//
g_ulSysTickCount++;
}
//*****************************************************************************
//
// This function returns the number of ticks since the last time this function
// was called.
//
//*****************************************************************************
unsigned int GetTickms(void)
{
unsigned int ulRetVal;
unsigned int ulSaved;
ulRetVal = g_ulSysTickCount;
ulSaved = ulRetVal;
if(ulSaved > g_ulLastTick)
{
ulRetVal = ulSaved - g_ulLastTick;
}
else
{
ulRetVal = g_ulLastTick - ulSaved;
}
//
// This could miss a few milliseconds but the timings here are on a
// much larger scale.
//
g_ulLastTick = ulSaved;
//
// Return the number of milliseconds since the last time this was called.
//
return(ulRetVal * MS_PER_SYSTICK);
}
static void LCDAINTCConfigure(void)
{
/* Registering the Interrupt Service Routine(ISR). */
IntRegister(SYS_INT_LCDCINT, LCDIsr);
/* Setting the priority for the system interrupt in AINTC. */
IntPrioritySet(SYS_INT_LCDCINT, 0, AINTC_HOSTINT_ROUTE_IRQ);
/* Enabling the system interrupt in AINTC. */
IntSystemEnable(SYS_INT_LCDCINT);
}
/*
** Function to setup MMU. This function Maps three regions (1. DDR
** 2. OCMC and 3. Device memory) and enables MMU.
*/
void MMUConfigAndEnable(void)
{
REGION regionDdr = {
MMU_PGTYPE_SECTION, START_ADDR_DDR, NUM_SECTIONS_DDR,
MMU_MEMTYPE_NORMAL_NON_SHAREABLE(MMU_CACHE_WT_NOWA,
MMU_CACHE_WB_WA),
MMU_REGION_NON_SECURE, MMU_AP_PRV_RW_USR_RW,
(unsigned int*)pageTable
};
/*
** Define OCMC RAM region of AM335x. Same Attributes of DDR region given.
*/
REGION regionOcmc = {
MMU_PGTYPE_SECTION, START_ADDR_OCMC, NUM_SECTIONS_OCMC,
MMU_MEMTYPE_NORMAL_NON_SHAREABLE(MMU_CACHE_WT_NOWA,
MMU_CACHE_WB_WA),
MMU_REGION_NON_SECURE, MMU_AP_PRV_RW_USR_RW,
(unsigned int*)pageTable
};
/*
** Define Device Memory Region. The region between OCMC and DDR is
** configured as device memory, with R/W access in user/privileged modes.
** Also, the region is marked 'Execute Never'.
*/
REGION regionDev = {
MMU_PGTYPE_SECTION, START_ADDR_DEV, NUM_SECTIONS_DEV,
MMU_MEMTYPE_DEVICE_SHAREABLE,
MMU_REGION_NON_SECURE,
MMU_AP_PRV_RW_USR_RW | MMU_SECTION_EXEC_NEVER,
(unsigned int*)pageTable
};
/* Initialize the page table and MMU */
MMUInit((unsigned int*)pageTable);
/* Map the defined regions */
MMUMemRegionMap(®ionDdr);
MMUMemRegionMap(®ionOcmc);
MMUMemRegionMap(®ionDev);
/* Now Safe to enable MMU */
MMUEnable((unsigned int*)pageTable);
}
//*****************************************************************************
//
// This is the main loop that runs the application.
//
//*****************************************************************************
int main(void)
{
MMUConfigAndEnable();
ConsoleUtilsPrintf("StarterWare AM335x RTC Application1232.\r\n");
//rtcClock();
//Mitesh Added
/* Enabling functional clocks for GPIO0 instance. */
GPIO0ModuleClkConfig();
/* Enabling functional clocks for GPIO1 instance. */
GPIO1ModuleClkConfig();
/* Enabling functional clocks for GPIO2 instance. */
GPIO2ModuleClkConfig();
/* Enabling functional clocks for GPIO1 instance. */
GPIO3ModuleClkConfig();
/* Selecting GPIO1[23] pin for use. LED1*/
GpioPinMuxSetup(GPIO_1_30,15);
/* Selecting GPIO1[30] pin for use.LED2 */
GpioPinMuxSetup(GPIO_2_0,15);
/* Selecting GPIO1[25] pin for use.LCD_PWR_EN */
GpioPinMuxSetup(GPIO_1_25,15);
/* Selecting GPIO2[22] pin for use.LCD_CLKSEL */
GpioPinMuxSetup(GPIO_2_22,15);
/* Selecting GPIO1[22] pin for use.LCD_DPS */
GpioPinMuxSetup(GPIO_1_22,15);
/* Selecting GPIO1[23] pin for use.LCD_FRC */
GpioPinMuxSetup(GPIO_1_23,15);
/* Selecting GPIO1[23] pin for use.LCD_SHTDN- */
GpioPinMuxSetup(GPIO_2_23,15);
/* Resetting the GPIO module. */
GPIOModuleReset(SOC_GPIO_0_REGS);
/* Resetting the GPIO module. */
GPIOModuleReset(SOC_GPIO_1_REGS);
/* Resetting the GPIO module. */
GPIOModuleReset(SOC_GPIO_2_REGS);
/* Resetting the GPIO module. */
GPIOModuleReset(SOC_GPIO_3_REGS);
/* Enabling the GPIO module. */
GPIOModuleEnable(SOC_GPIO_0_REGS);
/* Enabling the GPIO module. */
GPIOModuleEnable(SOC_GPIO_1_REGS);
/* Enabling the GPIO module. */
GPIOModuleEnable(SOC_GPIO_2_REGS);
/* Enabling the GPIO module. */
GPIOModuleEnable(SOC_GPIO_3_REGS);
/* Setting the GPIO pin as an output pin.LED2 */
GPIODirModeSet(SOC_GPIO_2_REGS,
0,
GPIO_DIR_OUTPUT);
/* Setting the GPIO pin as an output pin.RMII1_RST- */
GPIODirModeSet(SOC_GPIO_3_REGS,
9,
GPIO_DIR_OUTPUT);
/* Setting the GPIO pin as an output pin.RMII2_RST- */
GPIODirModeSet(SOC_GPIO_1_REGS,
18,
GPIO_DIR_OUTPUT);
/* Setting the GPIO pin as an output pin.LED1 */
GPIODirModeSet(SOC_GPIO_1_REGS,
GPIO_INSTANCE_PIN_NUMBER,
GPIO_DIR_OUTPUT);
/* Setting the GPIO pin as an output pin.LCD_PWR_EN */
GPIODirModeSet(SOC_GPIO_1_REGS,
25,
GPIO_DIR_OUTPUT);
/* Setting the GPIO pin as an output pin.LCD_CLKSEL */
GPIODirModeSet(SOC_GPIO_2_REGS,
22,
GPIO_DIR_OUTPUT);
/* Setting the GPIO pin as an output pin.LCD_DPS */
GPIODirModeSet(SOC_GPIO_1_REGS,
22,
GPIO_DIR_OUTPUT);
/* Setting the GPIO pin as an output pin.LCD_FRC */
GPIODirModeSet(SOC_GPIO_1_REGS,
23,
GPIO_DIR_OUTPUT);
/* Setting the GPIO pin as an output pin.LCD_SHTDN- */
GPIODirModeSet(SOC_GPIO_2_REGS,
23,
GPIO_DIR_OUTPUT);
/* Driving a logic HIGH on the GPIO pin.RMII1_RST- */
GPIOPinWrite(SOC_GPIO_3_REGS,
9,
GPIO_PIN_HIGH);
/* Driving a logic HIGH on the GPIO pin.RMII2_RST- */
GPIOPinWrite(SOC_GPIO_1_REGS,
18,
GPIO_PIN_HIGH);
/* Driving a logic HIGH on the GPIO pin.LCD_PWR_EN- */
GPIOPinWrite(SOC_GPIO_1_REGS,
25,
GPIO_PIN_HIGH);
/* Driving a logic HIGH on the GPIO pin.LCD_CLKSEL */
GPIOPinWrite(SOC_GPIO_2_REGS,
22,
GPIO_PIN_HIGH);
/* Driving a logic LOW on the GPIO pin.LCD_DPS - NORMAL SCAN */
GPIOPinWrite(SOC_GPIO_1_REGS,
22,
GPIO_PIN_LOW);
/* Driving a logic HIGH on the GPIO pin.LCD_FRC */
GPIOPinWrite(SOC_GPIO_1_REGS,
23,
GPIO_PIN_HIGH);
/* Driving a logic HIGH on the GPIO pin.LCD_SHTDN-*/
GPIOPinWrite(SOC_GPIO_2_REGS,
23,
GPIO_PIN_HIGH);
PWMSSModuleClkConfig(0);
j = EPWM2PinMuxSetup();
/* Enable Clock for EHRPWM in PWM sub system */
EHRPWMClockEnable(SOC_PWMSS0_REGS);
/* Enable Timer Base Module Clock in control module */
PWMSSTBClkEnable(0);
/* EHRPWM is configured to generate PWM waveform on EPWMAxA Pin*/
EHRPWMConfigure0();
//Code from Haptics_END
/* Enable Data Cache */
CacheEnable(CACHE_ALL);
ConsoleUtilsSetType(CONSOLE_UART);
ConsoleUtilsPrintf("\n\nUSB Mass Storage Host program\n");
ConsoleUtilsPrintf("Type \'help\' for help.\n\n");
DelayTimerSetup();
SetUpLCD();
/* configuring the base ceiling */
RasterDMAFBConfig(SOC_LCDC_0_REGS,
(unsigned int)(g_pucBuffer+PALETTE_OFFSET),
(unsigned int)(g_pucBuffer+PALETTE_OFFSET) + sizeof(g_pucBuffer) - 2 -
PALETTE_OFFSET, FRAME_BUFFER_0);
RasterDMAFBConfig(SOC_LCDC_0_REGS,
(unsigned int)(g_pucBuffer+PALETTE_OFFSET),
(unsigned int)(g_pucBuffer+PALETTE_OFFSET) + sizeof(g_pucBuffer) - 2 -
PALETTE_OFFSET, FRAME_BUFFER_1);
src = (unsigned char *) palette_32b;
dest = (unsigned char *) (g_pucBuffer+PALETTE_OFFSET);
// Copy palette info into buffer
for( i = PALETTE_OFFSET; i < (PALETTE_SIZE+PALETTE_OFFSET); i++)
{
*dest++ = *src++;
}
GrOffScreen24BPPInit(&g_s35_800x480x24Display, g_pucBuffer, LCD_WIDTH, LCD_HEIGHT);
// GrOffScreen24BPPInit(&g_s35_800x480x24Display, g_pucBuffer, LCD_WIDTH, LCD_HEIGHT);
// Initialize a drawing context.
GrContextInit(&g_sContext, &g_s35_800x480x24Display);
/* enable End of frame interrupt */
RasterEndOfFrameIntEnable(SOC_LCDC_0_REGS);
/* enable raster */
RasterEnable(SOC_LCDC_0_REGS);
GrContextForegroundSet(&g_sContext, DISPLAY_BANNER_FG );
GrRectFill(&g_sContext, &sRect);
GrContextFontSet(&g_sContext, &g_sFontCm30b);
ConsoleUtilsPrintf("Start.\n\n");
i=j=0;
GrStringDraw(&g_sContext,&Name1,-1,j,i,0);
CacheDataCleanBuff((unsigned int) &g_pucBuffer[0]+PALETTE_OFFSET,
GrOffScreen24BPPSize(LCD_WIDTH, LCD_HEIGHT, PIXEL_24_BPP_UNPACKED));
CacheDataCleanBuff((unsigned int) &g_pucBuffer[1]+PALETTE_OFFSET,
GrOffScreen24BPPSize(LCD_WIDTH, LCD_HEIGHT, PIXEL_24_BPP_UNPACKED));
LCD_CLEAR_SCREEN();
GrStringDraw(&g_sContext,&Name2,-1,j,i,0);
CacheDataCleanBuff((unsigned int) &g_pucBuffer[0]+PALETTE_OFFSET,
GrOffScreen24BPPSize(LCD_WIDTH, LCD_HEIGHT, PIXEL_24_BPP_UNPACKED));
CacheDataCleanBuff((unsigned int) &g_pucBuffer[1]+PALETTE_OFFSET,
GrOffScreen24BPPSize(LCD_WIDTH, LCD_HEIGHT, PIXEL_24_BPP_UNPACKED));
ConsoleUtilsPrintf("After B clear\n\n");
// }
/*
for(j=0,i=0;i<760;j=j+20)
{
if(j==1000)
{
i=i+30;
j=0;
}
// GrFlush(&g_sContext);
GrStringDraw(&g_sContext,&Name1,-1,j,i,0);
CacheDataCleanBuff((unsigned int) &g_pucBuffer[0]+PALETTE_OFFSET,
GrOffScreen24BPPSize(LCD_WIDTH, LCD_HEIGHT, PIXEL_24_BPP_UNPACKED));
CacheDataCleanBuff((unsigned int) &g_pucBuffer[1]+PALETTE_OFFSET,
GrOffScreen24BPPSize(LCD_WIDTH, LCD_HEIGHT, PIXEL_24_BPP_UNPACKED));
}
*/
while(1);
}
void LCD_CLEAR_SCREEN()
{
ConsoleUtilsPrintf("LCD_CLEAR_SCREEN function.\r\n");
GrFlush(&g_sContext);
ConsoleUtilsPrintf("code stuck.\r\n");
CacheDataCleanBuff((unsigned int) &g_pucBuffer[0]+PALETTE_OFFSET,
GrOffScreen24BPPSize(LCD_WIDTH, LCD_HEIGHT, PIXEL_24_BPP_UNPACKED));
CacheDataCleanBuff((unsigned int) &g_pucBuffer[1]+PALETTE_OFFSET,
GrOffScreen24BPPSize(LCD_WIDTH, LCD_HEIGHT, PIXEL_24_BPP_UNPACKED));
MMUConfigAndEnable();
ConsoleUtilsPrintf("StarterWare AM335x RTC Application1232.\r\n");
//rtcClock();
//Mitesh Added
/* Enabling functional clocks for GPIO0 instance. */
GPIO0ModuleClkConfig();
/* Enabling functional clocks for GPIO1 instance. */
GPIO1ModuleClkConfig();
/* Enabling functional clocks for GPIO2 instance. */
GPIO2ModuleClkConfig();
/* Enabling functional clocks for GPIO1 instance. */
GPIO3ModuleClkConfig();
/* Selecting GPIO1[23] pin for use. LED1*/
GpioPinMuxSetup(GPIO_1_30,15);
/* Selecting GPIO1[30] pin for use.LED2 */
GpioPinMuxSetup(GPIO_2_0,15);
/* Selecting GPIO1[25] pin for use.LCD_PWR_EN */
GpioPinMuxSetup(GPIO_1_25,15);
/* Selecting GPIO2[22] pin for use.LCD_CLKSEL */
GpioPinMuxSetup(GPIO_2_22,15);
/* Selecting GPIO1[22] pin for use.LCD_DPS */
GpioPinMuxSetup(GPIO_1_22,15);
/* Selecting GPIO1[23] pin for use.LCD_FRC */
GpioPinMuxSetup(GPIO_1_23,15);
/* Selecting GPIO1[23] pin for use.LCD_SHTDN- */
GpioPinMuxSetup(GPIO_2_23,15);
/* Resetting the GPIO module. */
GPIOModuleReset(SOC_GPIO_0_REGS);
/* Resetting the GPIO module. */
GPIOModuleReset(SOC_GPIO_1_REGS);
/* Resetting the GPIO module. */
GPIOModuleReset(SOC_GPIO_2_REGS);
/* Resetting the GPIO module. */
GPIOModuleReset(SOC_GPIO_3_REGS);
/* Enabling the GPIO module. */
GPIOModuleEnable(SOC_GPIO_0_REGS);
/* Enabling the GPIO module. */
GPIOModuleEnable(SOC_GPIO_1_REGS);
/* Enabling the GPIO module. */
GPIOModuleEnable(SOC_GPIO_2_REGS);
/* Enabling the GPIO module. */
GPIOModuleEnable(SOC_GPIO_3_REGS);
/* Setting the GPIO pin as an output pin.LED2 */
GPIODirModeSet(SOC_GPIO_2_REGS,
0,
GPIO_DIR_OUTPUT);
/* Setting the GPIO pin as an output pin.RMII1_RST- */
GPIODirModeSet(SOC_GPIO_3_REGS,
9,
GPIO_DIR_OUTPUT);
/* Setting the GPIO pin as an output pin.RMII2_RST- */
GPIODirModeSet(SOC_GPIO_1_REGS,
18,
GPIO_DIR_OUTPUT);
/* Setting the GPIO pin as an output pin.LED1 */
GPIODirModeSet(SOC_GPIO_1_REGS,
GPIO_INSTANCE_PIN_NUMBER,
GPIO_DIR_OUTPUT);
/* Setting the GPIO pin as an output pin.LCD_PWR_EN */
GPIODirModeSet(SOC_GPIO_1_REGS,
25,
GPIO_DIR_OUTPUT);
/* Setting the GPIO pin as an output pin.LCD_CLKSEL */
GPIODirModeSet(SOC_GPIO_2_REGS,
22,
GPIO_DIR_OUTPUT);
/* Setting the GPIO pin as an output pin.LCD_DPS */
GPIODirModeSet(SOC_GPIO_1_REGS,
22,
GPIO_DIR_OUTPUT);
/* Setting the GPIO pin as an output pin.LCD_FRC */
GPIODirModeSet(SOC_GPIO_1_REGS,
23,
GPIO_DIR_OUTPUT);
/* Setting the GPIO pin as an output pin.LCD_SHTDN- */
GPIODirModeSet(SOC_GPIO_2_REGS,
23,
GPIO_DIR_OUTPUT);
/* Driving a logic HIGH on the GPIO pin.RMII1_RST- */
GPIOPinWrite(SOC_GPIO_3_REGS,
9,
GPIO_PIN_HIGH);
/* Driving a logic HIGH on the GPIO pin.RMII2_RST- */
GPIOPinWrite(SOC_GPIO_1_REGS,
18,
GPIO_PIN_HIGH);
/* Driving a logic HIGH on the GPIO pin.LCD_PWR_EN- */
GPIOPinWrite(SOC_GPIO_1_REGS,
25,
GPIO_PIN_HIGH);
/* Driving a logic HIGH on the GPIO pin.LCD_CLKSEL */
GPIOPinWrite(SOC_GPIO_2_REGS,
22,
GPIO_PIN_HIGH);
/* Driving a logic LOW on the GPIO pin.LCD_DPS - NORMAL SCAN */
GPIOPinWrite(SOC_GPIO_1_REGS,
22,
GPIO_PIN_LOW);
/* Driving a logic HIGH on the GPIO pin.LCD_FRC */
GPIOPinWrite(SOC_GPIO_1_REGS,
23,
GPIO_PIN_HIGH);
/* Driving a logic HIGH on the GPIO pin.LCD_SHTDN-*/
GPIOPinWrite(SOC_GPIO_2_REGS,
23,
GPIO_PIN_HIGH);
PWMSSModuleClkConfig(0);
j = EPWM2PinMuxSetup();
/* Enable Clock for EHRPWM in PWM sub system */
EHRPWMClockEnable(SOC_PWMSS0_REGS);
/* Enable Timer Base Module Clock in control module */
PWMSSTBClkEnable(0);
/* EHRPWM is configured to generate PWM waveform on EPWMAxA Pin*/
EHRPWMConfigure0();
//Code from Haptics_END
/* Enable Data Cache */
CacheEnable(CACHE_ALL);
ConsoleUtilsSetType(CONSOLE_UART);
ConsoleUtilsPrintf("\n\nUSB Mass Storage Host program\n");
ConsoleUtilsPrintf("Type \'help\' for help.\n\n");
DelayTimerSetup();
SetUpLCD();
/* configuring the base ceiling */
RasterDMAFBConfig(SOC_LCDC_0_REGS,
(unsigned int)(g_pucBuffer+PALETTE_OFFSET),
(unsigned int)(g_pucBuffer+PALETTE_OFFSET) + sizeof(g_pucBuffer) - 2 -
PALETTE_OFFSET, FRAME_BUFFER_0);
RasterDMAFBConfig(SOC_LCDC_0_REGS,
(unsigned int)(g_pucBuffer+PALETTE_OFFSET),
(unsigned int)(g_pucBuffer+PALETTE_OFFSET) + sizeof(g_pucBuffer) - 2 -
PALETTE_OFFSET, FRAME_BUFFER_1);
src = (unsigned char *) palette_32b;
dest = (unsigned char *) (g_pucBuffer+PALETTE_OFFSET);
// Copy palette info into buffer
for( i = PALETTE_OFFSET; i < (PALETTE_SIZE+PALETTE_OFFSET); i++)
{
*dest++ = *src++;
}
GrOffScreen24BPPInit(&g_s35_800x480x24Display, g_pucBuffer, LCD_WIDTH, LCD_HEIGHT);
// GrOffScreen24BPPInit(&g_s35_800x480x24Display, g_pucBuffer, LCD_WIDTH, LCD_HEIGHT);
// Initialize a drawing context.
GrContextInit(&g_sContext, &g_s35_800x480x24Display);
/* enable End of frame interrupt */
RasterEndOfFrameIntEnable(SOC_LCDC_0_REGS);
/* enable raster */
RasterEnable(SOC_LCDC_0_REGS);
GrContextForegroundSet(&g_sContext, DISPLAY_BANNER_BG);
GrRectFill(&g_sContext, &sRect);
GrContextFontSet(&g_sContext, &g_sFontCm30b);
}
static void EHRPWMConfigure0(void)
{
/* TimeBase configuration */
/* Configure the clock frequency */
EHRPWMTimebaseClkConfig(SOC_EPWM_0_REGS,
SOC_EHRPWM_0_MODULE_FREQ/CLOCK_DIV_VAL,
SOC_EHRPWM_0_MODULE_FREQ);
/* Configure the period of the output waveform */
EHRPWMPWMOpFreqSet(SOC_EPWM_0_REGS,
SOC_EHRPWM_0_MODULE_FREQ/CLOCK_DIV_VAL,
(unsigned int)(SOC_EHRPWM_0_MODULE_FREQ/CLOCK_DIV_VAL)/0xFF,
(unsigned int)EHRPWM_COUNT_UP,
(bool)EHRPWM_SHADOW_WRITE_DISABLE);
/* Disable synchronization*/
EHRPWMTimebaseSyncDisable(SOC_EPWM_0_REGS);
/* Disable syncout*/
EHRPWMSyncOutModeSet(SOC_EPWM_0_REGS, EHRPWM_SYNCOUT_DISABLE);
/* Configure the emulation behaviour*/
EHRPWMTBEmulationModeSet(SOC_EPWM_0_REGS, EHRPWM_STOP_AFTER_NEXT_TB_INCREMENT);
/* Configure Counter compare cub-module */
/* Load Compare A value */
EHRPWMLoadCMPA(SOC_EPWM_0_REGS,
0,
(bool)EHRPWM_SHADOW_WRITE_DISABLE,
(unsigned int)EHRPWM_COMPA_NO_LOAD,
(bool)EHRPWM_CMPCTL_OVERWR_SH_FL);
/* Load Compare B value */
EHRPWMLoadCMPB(SOC_EPWM_0_REGS,
0,
(bool)EHRPWM_SHADOW_WRITE_DISABLE,
(unsigned int) EHRPWM_COMPB_NO_LOAD,
(bool)EHRPWM_CMPCTL_OVERWR_SH_FL);
/* Configure Action qualifier */
/* Toggle when CTR = CMPA */
EHRPWMConfigureAQActionOnA(SOC_EPWM_0_REGS,
EHRPWM_AQCTLB_ZRO_DONOTHING,
EHRPWM_AQCTLB_PRD_DONOTHING,
EHRPWM_AQCTLB_CAU_EPWMXBTOGGLE,
EHRPWM_AQCTLB_CAD_DONOTHING,
EHRPWM_AQCTLB_CBU_DONOTHING,
EHRPWM_AQCTLB_CBD_DONOTHING,
EHRPWM_AQSFRC_ACTSFB_DONOTHING);
/* Bypass dead band sub-module */
EHRPWMDBOutput(SOC_EPWM_0_REGS, EHRPWM_DBCTL_OUT_MODE_BYPASS);
/* Disable Chopper sub-module */
EHRPWMChopperDisable(SOC_EPWM_0_REGS);
/* Disable trip events */
EHRPWMTZTripEventDisable(SOC_EPWM_0_REGS,(bool)EHRPWM_TZ_ONESHOT);
EHRPWMTZTripEventDisable(SOC_EPWM_0_REGS,(bool)EHRPWM_TZ_CYCLEBYCYCLE);
/* Event trigger */
/* Generate interrupt every 3rd occurance of the event */
EHRPWMETIntPrescale(SOC_EPWM_0_REGS, EHRPWM_ETPS_INTPRD_THIRDEVENT);
/* Generate event when CTR = CMPA */
EHRPWMETIntSourceSelect(SOC_EPWM_0_REGS, EHRPWM_ETSEL_INTSEL_TBCTREQUCMPAINC);
/* Disable High resolution capability */
EHRPWMHRDisable(SOC_EPWM_0_REGS);
}