TI E2E support forums
TI E2E support forums
  • User
  • Site
  • Search
  • User
  • E2E™ design support >
  • Forums
    • Amplifiers
    • API solutions
    • Audio
    • Clock & timing
    • Data converters
    • DLP® products
    • Interface
    • Isolation
    • Logic
    • Microcontrollers
    • Motor drivers
    • Power management
    • Processors
    • RF & microwave
    • Sensors
    • Site support
    • Switches & multiplexers
    • Tools
    • Wireless connectivity
    • Archived forums
    • Archived groups
  • Technical articles
  • TI training
    • Tech days
    • Online training
    • Live events
    • Power Supply Design Seminar
  • Getting started
  • 简体中文
  • More
  • Cancel
Processors

Processors

Processors forum

  • Mentions
  • Tags
  • More
  • Cancel
  • Ask a related question
    What is a related question?
    A related question is a question created from another question. When the related question is created, it will be automatically linked to the original question.
  • Ask a new question
  • Ask a new question
  • Cancel
  • State
  • Locked Locked
  • Replies 4 replies
  • Subscribers 99 subscribers
  • Views 974 views
  • Users 0 members are here
Support feedback
Options
  • Tags
  • More
  • Cancel
Options
  • Share
  • More
  • Cancel
Related

This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Configuration of raster to display text and video

Anouini mustapha
Anouini mustapha
Expert 1350 points
Other Parts Discussed in Thread: SYSBIOS

Hello ,

I'm using the function of grlib given in usb keyboard example to display text on the screen. The example work, Now i would like to write on video, I mixed the project  that display video running in sys/bios. I would know how to display the video and the text at the some time.

To display text i use this function :

RasterDMAFBConfig(SOC_LCDC_0_REGS,
(unsigned int)(g_pucBuffer+PALETTE_OFFSET),
(unsigned int)(g_pucBuffer+PALETTE_OFFSET) + sizeof(g_pucBuffer) - 2 - PALETTE_OFFSET,
0);

RasterDMAFBConfig(SOC_LCDC_0_REGS,
(unsigned int)(g_pucBuffer+PALETTE_OFFSET),
(unsigned int)(g_pucBuffer+PALETTE_OFFSET) + sizeof(g_pucBuffer) - 2 - PALETTE_OFFSET,
1);

To display video i use the function given in the video loopbacj example: 

if (display_buff_1)
{
if (status & RASTER_END_OF_FRAME0_INT_STAT)
{
RasterDMAFBConfig(SOC_LCDC_0_REGS, (unsigned int) Rgb_buffer1,
(unsigned int) (Rgb_buffer1 + DISPLAY_IMAGE_WIDTH * DISPLAY_IMAGE_HEIGHT + 15), 0);
updated = updated | 0x1;
}
if (status & RASTER_END_OF_FRAME1_INT_STAT)
{
RasterDMAFBConfig(SOC_LCDC_0_REGS, (unsigned int) Rgb_buffer1,
(unsigned int) (Rgb_buffer1 + DISPLAY_IMAGE_WIDTH * DISPLAY_IMAGE_HEIGHT + 15), 1);
updated = updated | 0x2;
}
}
else
{
if (status & RASTER_END_OF_FRAME0_INT_STAT)
{
RasterDMAFBConfig(SOC_LCDC_0_REGS, (unsigned int) Rgb_buffer2,
(unsigned int) (Rgb_buffer2 + DISPLAY_IMAGE_WIDTH * DISPLAY_IMAGE_HEIGHT + 15), 0);
updated = updated | 0x1;
}
if (status & RASTER_END_OF_FRAME1_INT_STAT)
{
RasterDMAFBConfig(SOC_LCDC_0_REGS, (unsigned int) Rgb_buffer2,
(unsigned int) (Rgb_buffer2 + DISPLAY_IMAGE_WIDTH * DISPLAY_IMAGE_HEIGHT + 15), 1);
updated = updated | 0x2;
}
}

I tried this but i have the both the text and video. But video flashes and not run correctly :

if (display_buff_1)
{
if (status & RASTER_END_OF_FRAME0_INT_STAT)
{
RasterDMAFBConfig(SOC_LCDC_0_REGS, (unsigned int) Rgb_buffer1,
(unsigned int) (Rgb_buffer1 + DISPLAY_IMAGE_WIDTH * DISPLAY_IMAGE_HEIGHT + 15), 0);

RasterDMAFBConfig(SOC_LCDC_0_REGS,
(unsigned int)(g_pucBuffer+PALETTE_OFFSET),
(unsigned int)(g_pucBuffer+PALETTE_OFFSET) + sizeof(g_pucBuffer) - 2 - PALETTE_OFFSET,
0);


updated = updated | 0x1;
}
if (status & RASTER_END_OF_FRAME1_INT_STAT)
{
RasterDMAFBConfig(SOC_LCDC_0_REGS, (unsigned int) Rgb_buffer1,
(unsigned int) (Rgb_buffer1 + DISPLAY_IMAGE_WIDTH * DISPLAY_IMAGE_HEIGHT + 15), 1);

RasterDMAFBConfig(SOC_LCDC_0_REGS,
(unsigned int)(g_pucBuffer+PALETTE_OFFSET),
(unsigned int)(g_pucBuffer+PALETTE_OFFSET) + sizeof(g_pucBuffer) - 2 - PALETTE_OFFSET,
1);
updated = updated | 0x2;
}
}
else
{
if (status & RASTER_END_OF_FRAME0_INT_STAT)
{
RasterDMAFBConfig(SOC_LCDC_0_REGS, (unsigned int) Rgb_buffer2,
(unsigned int) (Rgb_buffer2 + DISPLAY_IMAGE_WIDTH * DISPLAY_IMAGE_HEIGHT + 15), 0);

RasterDMAFBConfig(SOC_LCDC_0_REGS,
(unsigned int)(g_pucBuffer+PALETTE_OFFSET),
(unsigned int)(g_pucBuffer+PALETTE_OFFSET) + sizeof(g_pucBuffer) - 2 - PALETTE_OFFSET,
0);


updated = updated | 0x1;
}
if (status & RASTER_END_OF_FRAME1_INT_STAT)
{
RasterDMAFBConfig(SOC_LCDC_0_REGS, (unsigned int) Rgb_buffer2,
(unsigned int) (Rgb_buffer2 + DISPLAY_IMAGE_WIDTH * DISPLAY_IMAGE_HEIGHT + 15), 1);

RasterDMAFBConfig(SOC_LCDC_0_REGS,
(unsigned int)(g_pucBuffer+PALETTE_OFFSET),
(unsigned int)(g_pucBuffer+PALETTE_OFFSET) + sizeof(g_pucBuffer) - 2 - PALETTE_OFFSET,
1);


updated = updated | 0x2;
}
}

Thank you very much for your help !!

over 11 years ago
  • Cancel
  • Sivaraj Kuppuraj
    0 Sivaraj Kuppuraj over 11 years ago
    TI__Mastermind 35645 points

    Hi,

    Thanks for your post.

    As we have already addressed that, LIDD mode configuration examples would work for character display devices and Raster mode configuration in LCD controller would work to display image/video through VGA port. Again, it is mentioned clearly in the TRM that, two modes (LIDD & raster modes) will work independantly in the LCD controller but only one mode will be active at a time. So, it is not possible to display the video and text at the same time since two modes will not work simultaneously. Even, if you configure both LIDD & raster mode & mix in your SysBios application, it won;t work.

    Note in TRM:

    "The LCD controller consists of two independent controllers, the Raster Controller and the LCD Interface
    Display Driver (LIDD) controller. Each controller operates independently from the other and only one of
    them is active at any given time"

    Thanks & regards,
    Sivaraj K

    ------------------------------------------------------------------------------------------------------

    Please click the Verify Answer button on this post if it answers your question

    -------------------------------------------------------------------------------------------------------

     

    • Cancel
    • Up 0 True Down
    • Cancel
  • Anouini mustapha
    0 Anouini mustapha over 11 years ago in reply to Sivaraj Kuppuraj
    Expert 1350 points

    I did it the text and video but as i said, the video flashes. That it possible to write texte but in a part on the screen and the other part to display video :

    Think you !!

    • Cancel
    • Up 0 True Down
    • Cancel
  • Titusrathinaraj Stalin
    0 Titusrathinaraj Stalin over 11 years ago in reply to Anouini mustapha
    TI__Guru** 116100 points

    Hi,

    As TRM says,

    You can't access the LCDC in different modes at the same time.

    I think, It was unexpected behavior due to misconfiguration in LCDC.

    Could you please tell us that what is your requirement.

    Your requirement seems to be OSD (on screen display) configuration.

    • Cancel
    • Up 0 True Down
    • Cancel
  • Anouini mustapha
    0 Anouini mustapha over 11 years ago in reply to Titusrathinaraj Stalin
    Expert 1350 points

    I would at write on video. The video continue and i can write on it. so i have the prorlem to diplay the text and the video.

    I attached the main program

    Fullscreen 0602.write_on_lcd.c Download
    
    /* ========================================================================== */
    /*                          INCLUDE FILES                                     */
    /* ========================================================================== */
    #include <xdc/std.h>
    #include <xdc/runtime/Error.h>
    #include <xdc/runtime/System.h>
    #include <ti/sysbios/BIOS.h>
    #include <ti/sysbios/knl/Clock.h>
    #include <ti/sysbios/knl/Task.h>
    #include <ti/sysbios/knl/Semaphore.h>
    #include <ti/sysbios/family/c64p/Hwi.h>
    
    #include <stdio.h>
    #include "psc.h"
    #include "vpif.h"
    #include "raster.h"
    #include "interrupt.h"
    #include "lcdkC6748.h"
    #include "soc_C6748.h"
    #include "hw_psc_C6748.h"
    #include "adv7343.h"
    #include "tvp5147.h"
    #include "cdce913.h"
    #include "codecif.h"
    #include "i2cgpio.h"
    #include "string.h"
    #include "uartStdio.h"
    #include "uart.h"
    #include "rtc.h"
    #include "image.h"
    #include "grlib.h"
    /******************************************************************************
    **                      INTERNAL MACROS
    *******************************************************************************/
    #define MSTPRI1									(0x01C14114)
    #define MSTPRI2									(0x01C14118)
    
    #define CAPTURE_IMAGE_WIDTH					 	(720)
    #define CAPTURE_IMAGE_HEIGHT				 	(576)
    #define DISPLAY_IMAGE_WIDTH						(640)
    #define DISPLAY_IMAGE_HEIGHT					(480)
    #define CLASSIFIER_CASCADE_SIZE      			(52519)
    #define REFERENCE_LOCATION_1         			(0xC30011B0)
    #define REFERENCE_LOCATION_2		 			(0xC303464B)
    #define CV_DEFAULT_IMAGE_ROW_ALIGN   			(8)
    
    #define I2C_SLAVE_CODEC_ADV7343                 (0x2Au)
    #define I2C_SLAVE_CODEC_TVP5147_1_SVIDEO    	(0x5Cu)
    #define I2C_SLAVE_CODEC_TVP5147_2_COMPOSITE    	(0x5Du)
    #define I2C_SLAVE_CDCE913      					(0x65u)
    #define I2C_SLAVE_UI_EXPANDER	      			(0x20u)
    
    #define INT_CHANNEL_I2C                       	(0x2u)
    
    #define OFFSET1									((CAPTURE_IMAGE_HEIGHT - DISPLAY_IMAGE_HEIGHT)/2)
    #define OFFSET2									((CAPTURE_IMAGE_WIDTH - DISPLAY_IMAGE_WIDTH)/2)
    #define OFFSET 									(CAPTURE_IMAGE_WIDTH * OFFSET1 + OFFSET2)
    
    #define MASK_HOUR            					(0xFF000000u)
    #define MASK_MINUTE          					(0x00FF0000u)
    #define MASK_SECOND          					(0x0000FF00u)
    #define MASK_MERIDIEM        					(0x000000FFu)
    
    #define HOUR_SHIFT           					(24)
    #define MINUTE_SHIFT         					(16)
    #define SECOND_SHIFT         					(8)
    
    #define MASK_DAY             					(0xFF000000u)
    #define MASK_MONTH           					(0x00FF0000u)
    #define MASK_YEAR            					(0x0000FF00u)
    #define MASK_DOTW            					(0x000000FFu)
    
    #define DAY_SHIFT            					(24)
    #define MONTH_SHIFT          					(16)
    #define YEAR_SHIFT           					(8)
    
    #define LCD_SIZE 614400
    #define LCD_CLK  150000000
    #define PALETTE_SIZE 32
    #define LCD_WIDTH 640
    #define LCD_HEIGHT 480
    #define PALETTE_OFFSET    4
    
    
    #define DISPLAY_BANNER_HEIGHT   23
    #define DISPLAY_BANNER_BG       ClrDarkBlue
    #define DISPLAY_BANNER_FG       ClrWhite
    #define DISPLAY_TEXT_BORDER     2
    #define DISPLAY_TEXT_BG         ClrBlack
    #define DISPLAY_TEXT_FG         ClrWhite
    
    /******************************************************************************
    **                      GLOBAL FUNCTION PROTOTYPES
    *******************************************************************************/
    extern void cbcr422sp_to_rgb565_c(const unsigned char * restrict, unsigned int,
    									unsigned int, const short*, const unsigned char *restrict,
    									unsigned int, unsigned short *restrict, unsigned int, unsigned,
    									unsigned int,unsigned int, unsigned int,unsigned int,unsigned int,
    									unsigned int,unsigned int,unsigned int,unsigned int,unsigned int, unsigned int,
    									unsigned int,unsigned int,unsigned int,unsigned int);
    
    
    // Memory that is used as the local frame buffer.
    #if defined(__IAR_SYSTEMS_ICC__)
    #pragma data_alignment=4
    unsigned char g_pucBuffer[GrOffScreen16BPPSize(LCD_WIDTH, LCD_HEIGHT)];
    #elif defined __TMS470__ || defined _TMS320C6X
    #pragma DATA_ALIGN(g_pucBuffer, 4);
    unsigned char g_pucBuffer[GrOffScreen16BPPSize(LCD_WIDTH, LCD_HEIGHT)];
    #else
    unsigned char g_pucBuffer[GrOffScreen16BPPSize(LCD_WIDTH, LCD_HEIGHT)]__attribute__ ((aligned (4)));
    #endif
    
    // The graphics library display structure.
    tContext g_sContext;
    tDisplay g_sVGA480x480x16Display;
    
    // 32 byte Palette.
    unsigned short palette_32b[PALETTE_SIZE/2] =
                {0x4000u, 0x0000u, 0x0000u, 0x0000u, 0x0000u, 0x0000u, 0x0000u, 0x0000u,
                 0x0000u, 0x0000u, 0x0000u, 0x0000u, 0x0000u, 0x0000u, 0x0000u, 0x0000u};
    
    
    /******************************************************************************
    **                      INTERNAL FUNCTION PROTOTYPES
    *******************************************************************************/
    static void SetUpVPIFRx(void);
    static void SetUpLCD(void);
    static void CalendarResolve(unsigned int calendarValue);
    static unsigned char ASCIIToInt(unsigned char byte);
    static unsigned int intToASCII(unsigned char byte);
    static void TimeResolve(unsigned int timeValue);
    static void Delay(volatile unsigned int count);
    static unsigned int UserCalendarInfoGet(void);
    static unsigned int UserTimeInfoGet(void);
    void PrintChar(const char ucChar);
    
    Void RTCIsr(UArg arg);
    Void VPIFIsr(UArg arg);
    Void LCDIsr(UArg arg);
    
    Void colorconvertTask(UArg arg0, UArg arg1);
    Void facedetectTask(UArg arg0, UArg arg1);
    Void clockHandler(UArg arg);
    
    /******************************************************************************
    **                      INTERNAL VARIABLE DEFINITIONS
    *******************************************************************************/
    unsigned int            i,pingpong=1, buffcount=0, buffcount2, display_buff_1=0;
    int 					facedetect_complete=1, buffer_ready=0;
    volatile unsigned int   changed=1, updated=3, processed=1;
    unsigned char 			*buff_luma[2], *buff_chroma[2];
    unsigned char			buff_luma1[CAPTURE_IMAGE_WIDTH * CAPTURE_IMAGE_HEIGHT];
    unsigned char			buff_luma2[CAPTURE_IMAGE_WIDTH * CAPTURE_IMAGE_HEIGHT];
    unsigned char			buff_chroma1[CAPTURE_IMAGE_WIDTH * CAPTURE_IMAGE_HEIGHT];
    unsigned char			buff_chroma2[CAPTURE_IMAGE_WIDTH * CAPTURE_IMAGE_HEIGHT];
    unsigned char			proc_buff_luma[DISPLAY_IMAGE_WIDTH * DISPLAY_IMAGE_HEIGHT];
    unsigned char           *videoTopY, *videoTopC, *proc_buff_ptr;
    unsigned short          *videoTopRgb1, *videoTopRgb2;
    unsigned short          Rgb_buffer1[DISPLAY_IMAGE_WIDTH*DISPLAY_IMAGE_HEIGHT + 16];
    unsigned short			Rgb_buffer2[DISPLAY_IMAGE_WIDTH*DISPLAY_IMAGE_HEIGHT + 16];
    const short             ccCoeff[5] = {0x2000, 0x2BDD, -0x0AC5, -0x1658, 0x3770};
    unsigned int 			flip_mode=0,flip_mode2=0;
    unsigned int			seconde=0,seconde1=0,minute=0,minute1=0,hour=0,hour1=0;
    unsigned int			day=0,day1=0,month=0,month1=0,year=0,year1=0;
    unsigned int			image_enable=1,video_enable=0,image_finished=0;
    unsigned char			flip;
    unsigned int			isr_rtc=0;
    unsigned int g_ulModifiers = 0;
    unsigned int g_ulCharsPerLine;
    unsigned int g_ulLinesPerScreen;
    unsigned int g_ulLine = 0;
    unsigned int g_ulColumn = 0;
    
    Semaphore_Handle 			sem1;
    Semaphore_Handle 			sem2;
    
    /******************************************************************************
    **                       FUNCTION DEFINITIONS
    *******************************************************************************/
    Void main()
    {
    	Hwi_Params 		params;
    	Hwi_Handle 		Hwi1, Hwi2, Hwi3;
    	Task_Params 	taskParams;
    	Task_Handle 	task1, task2;
    	Clock_Params 	clockParams;
    	Clock_Handle 	Clk;
    	Error_Block 	eb;
    
        /* Create a Semaphore object to be use as a resource lock */
        sem1 = Semaphore_create(0, NULL, NULL);
        sem2 = Semaphore_create(0, NULL, NULL);
    
    	/* Create the Color Convert Task */
        Error_init(&eb);
    	Task_Params_init(&taskParams);
    	taskParams.priority = 1;
    	taskParams.stackSize = 10000;
    	task1 = Task_create(colorconvertTask, &taskParams, &eb);
    	if (task1 == NULL)
    	{
    		System_printf("Task_create() failed for Color Conversion!\n");
    		BIOS_exit(0);
    	}
    
    	/* Create the FaceDetect Task*/
    	task2 = Task_create(facedetectTask, &taskParams, &eb);
    	if (task2 == NULL)
    	{
    		System_printf("Task_create() failed for Face Detection!\n");
    		BIOS_exit(0);
    	}
    
    	/* Create the VPIF Interrupt*/
    	Hwi_Params_init(&params);
    	params.eventId = 95;
    	params.enableInt = FALSE;
    	Hwi1 = Hwi_create(8, &VPIFIsr, &params, &eb);
    	if (Hwi1 == NULL)
    	{
    		System_printf("Hwi_create() failed for VPIF!\n");
    		BIOS_exit(0);
    	}
    
    	/* Create the LCDC Interrupt*/
    	Hwi_Params_init(&params);
    	params.eventId = 73;
    	params.enableInt = FALSE;
    	Hwi2 = Hwi_create(9, &LCDIsr, &params, &eb);
    	if (Hwi2 == NULL)
    	{
    		System_printf("Hwi_create() failed for LCDC!\n");
    		BIOS_exit(0);
    	}
    
    
    	/* Create the RTC Interrupt*/
    		Hwi_Params_init(&params);
    		params.eventId = 63;
    		params.enableInt = FALSE;
    		Hwi3 = Hwi_create(10, &RTCIsr, &params, &eb);
    		if (Hwi3 == NULL)
    		{
    		    System_printf("Hwi_create() failed for RTC!\n");
    		    BIOS_exit(0);
    		}
    
    	/* Create a clock that would go off every 1 Clock tick*/
    	Clock_Params_init(&clockParams);
    	clockParams.period = 1;
    	clockParams.startFlag = TRUE;
    	Clk = Clock_create((Clock_FuncPtr)clockHandler, 4, &clockParams, &eb);
    	if (Clk == NULL) {
    	System_abort("Clock0 create failed");
    	}
    
    	/* Setting the Master priority for LCD DMA controller to highest level */
    	*((volatile uint32_t *) MSTPRI2) = *((volatile uint32_t *) MSTPRI2) & 0x0FFFFFFF;
    
    	BIOS_start(); /* enable interrupts and start SYS/BIOS */
    }
    
    /*
    ** ClockHandler
    */
    Void clockHandler(UArg arg)
    {
    	/* Call Task_yield every 1 ms */
    	Task_yield();
    }
    
    /*
    ** ColorconvertTask - This would color convert the captured frames and make it available for the LCDC display.
    ** Also, if the facedetect algorithm has finished working on the frame provided, it would provide a new frame.
    */
    Void colorconvertTask(UArg a0, UArg a1)
    {
    
    	/* Allocate pointers to buffers */
    	buff_luma[0] = buff_luma1;
    	buff_luma[1] = buff_luma2;
    	buff_chroma[0] = buff_chroma1;
    	buff_chroma[1] = buff_chroma2;
    	proc_buff_ptr = proc_buff_luma;
    
    	/* Initializing palette for first buffer */
    	*Rgb_buffer1 = 0x4000;
    	for (i = 1; i < 16; i++)
    		*(Rgb_buffer1 +i) = 0x0000;
    	videoTopRgb1 = Rgb_buffer1 + i;
    
    	/* Initializing palette for second buffer */
    	*Rgb_buffer2 = 0x4000;
    	for (i = 1; i < 16; i++)
    		*(Rgb_buffer2 + i) = 0x0000;
    	videoTopRgb2 = Rgb_buffer2 + i;
    
    	/* Power on VPIF */
    	PSCModuleControl(SOC_PSC_1_REGS, HW_PSC_VPIF, PSC_POWERDOMAIN_ALWAYS_ON,
    			PSC_MDCTL_NEXT_ENABLE);
    
    	/* Initialize I2C and program UI GPIO expander, TVP5147, and ADV7343 via I2C */
    	I2CPinMuxSetup(0);
    
    	/*Initialize the TVP5147 to accept composite video */
    	I2CCodecIfInit(SOC_I2C_0_REGS, INT_CHANNEL_I2C,
    			I2C_SLAVE_CODEC_TVP5147_2_COMPOSITE);
    	TVP5147CompositeInit(SOC_I2C_0_REGS);
    
    	/* Setup VPIF pinmux */
    	VPIFPinMuxSetup();
    
    	/* Setup LCD */
    	SetUpLCD();
    
    	/* Initialize VPIF */
    	SetUpVPIFRx();
    	VPIFDMARequestSizeConfig(SOC_VPIF_0_REGS, VPIF_REQSIZE_ONE_TWENTY_EIGHT);
    	VPIFEmulationControlSet(SOC_VPIF_0_REGS, VPIF_HALT);
    
    	/* Initialize buffer addresses for 1st frame*/
    	VPIFCaptureFBConfig(SOC_VPIF_0_REGS, VPIF_CHANNEL_0, VPIF_TOP_FIELD,
    			VPIF_LUMA, (unsigned int) buff_luma[0], CAPTURE_IMAGE_WIDTH*2);
    	VPIFCaptureFBConfig(SOC_VPIF_0_REGS, VPIF_CHANNEL_0, VPIF_TOP_FIELD,
    			VPIF_CHROMA, (unsigned int) buff_chroma[0], CAPTURE_IMAGE_WIDTH*2);
    	VPIFCaptureFBConfig(SOC_VPIF_0_REGS, VPIF_CHANNEL_0, VPIF_BOTTOM_FIELD,
    			VPIF_LUMA, (unsigned int) (buff_luma[0] + CAPTURE_IMAGE_WIDTH), CAPTURE_IMAGE_WIDTH*2);
    	VPIFCaptureFBConfig(SOC_VPIF_0_REGS, VPIF_CHANNEL_0, VPIF_BOTTOM_FIELD,
    			VPIF_CHROMA, (unsigned int) (buff_chroma[0] + CAPTURE_IMAGE_WIDTH), CAPTURE_IMAGE_WIDTH*2);
    
    	/* configuring the base ceiling for image*/
    
    	/* 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,
    	                      0);
    
    	    RasterDMAFBConfig(SOC_LCDC_0_REGS,
    	                      (unsigned int)(g_pucBuffer+PALETTE_OFFSET),
    	                      (unsigned int)(g_pucBuffer+PALETTE_OFFSET) + sizeof(g_pucBuffer) - 2 - PALETTE_OFFSET,
    	                      1);
    /*
    	RasterDMAFBConfig(SOC_LCDC_0_REGS, (unsigned int) Rgb_buffer2,
    			(unsigned int) (Rgb_buffer2 + DISPLAY_IMAGE_WIDTH * DISPLAY_IMAGE_HEIGHT + 15), 0);
    	RasterDMAFBConfig(SOC_LCDC_0_REGS, (unsigned int) Rgb_buffer2,
    			(unsigned int) (Rgb_buffer2 + DISPLAY_IMAGE_WIDTH * DISPLAY_IMAGE_HEIGHT + 15), 1);
    
    */
    	/* Enable interrupts */
    	Hwi_enable();
    	Hwi_enableInterrupt(8);
    	Hwi_enableInterrupt(9);
    
    	/* Enable capture */
    	VPIFCaptureChanenEnable(SOC_VPIF_0_REGS, VPIF_CHANNEL_0);
    
    	/* Enable VPIF interrupt */
    	VPIFInterruptEnable(SOC_VPIF_0_REGS, VPIF_FRAMEINT_CH0);
    	VPIFInterruptEnableSet(SOC_VPIF_0_REGS, VPIF_FRAMEINT_CH0);
    
    	/* Enable End of frame interrupt */
    	RasterEndOfFrameIntEnable(SOC_LCDC_0_REGS);
    
    	/* Enable raster */
    	RasterEnable(SOC_LCDC_0_REGS);
    
    	buffcount++;
    	buffcount2 = buffcount - 1;
    
    	/* Run forever */
    
    	while (1)
    	  {
    
    		/* Wait here till a new frame is not captured */
    		Semaphore_pend(sem1, BIOS_WAIT_FOREVER);
    
    		/* Process the next buffer only when both the raster buffers
    		 * are pointing to the current buffer to avoid jitter effect
    		 */
    		Semaphore_pend(sem2, BIOS_WAIT_FOREVER);
    		processed = 0;
    		changed = 0;
    		updated = 0;
    
    
    
    	    /* Convert the buffer from CBCR422 semi-planar to RGB565,
    	     *  Set the flag for the buffer to be displayed on the LCD (which would be the processed buffer)
    	     *  and notify the LCD of availability of a processed buffer.
    	     *  The output buffers are ping-ponged each time.
    	     */
    
    
    		if (pingpong)
    		     	 	 {
    		                cbcr422sp_to_rgb565_c(
    		                        (const unsigned char *) (videoTopC + OFFSET),
    		                        DISPLAY_IMAGE_HEIGHT, CAPTURE_IMAGE_WIDTH, ccCoeff,
    		                        (const unsigned char *) (videoTopY + OFFSET),
    		                        CAPTURE_IMAGE_WIDTH, videoTopRgb1, DISPLAY_IMAGE_WIDTH, DISPLAY_IMAGE_WIDTH,flip_mode,flip_mode2,seconde,seconde1,minute,minute1,hour,hour1,day,day1,month,month1,year,year1,isr_rtc);
    
    		                display_buff_1 = 1;
    		                changed = 1;
    		            }
    		            else
    		            {
    		                cbcr422sp_to_rgb565_c(
    		                        (const unsigned char *) (videoTopC + OFFSET),
    		                        DISPLAY_IMAGE_HEIGHT, CAPTURE_IMAGE_WIDTH, ccCoeff,
    		                        (const unsigned char *) (videoTopY + OFFSET),
    		                        CAPTURE_IMAGE_WIDTH, videoTopRgb2, DISPLAY_IMAGE_WIDTH, DISPLAY_IMAGE_WIDTH,flip_mode,flip_mode2,seconde,seconde1,minute,minute1,hour,hour1,day,day1,month,month1,year,year1,isr_rtc);
    
    		                display_buff_1 = 0;
    		                changed = 1;
    		            }
    		pingpong = !pingpong;
    		processed = 1;
    		changed = 1;
    	  }
    }
    
    
    /*
    ** FacedetectTask - Runs the Face Detection Algorithm on the frame provided to it
    */
    Void facedetectTask(UArg a0, UArg a1)
    {
    	    tRectangle sRect;
    	    unsigned int i;
    	    unsigned char *src, *dest;
    	    UARTStdioInit();
    
    	    //
    	    //configures arm interrupt controller to generate raster interrupt
    	    //
    
    	    //
    	    //Configures raster to display image
    	    //
    
    	    /* 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,
    	                      0);
    
    	    RasterDMAFBConfig(SOC_LCDC_0_REGS,
    	                      (unsigned int)(g_pucBuffer+PALETTE_OFFSET),
    	                      (unsigned int)(g_pucBuffer+PALETTE_OFFSET) + sizeof(g_pucBuffer) - 2 - PALETTE_OFFSET,
    	                      1);
    
    	    // Copy palette info into buffer
    	    src = (unsigned char *) palette_32b;
    	    dest = (unsigned char *) (g_pucBuffer+PALETTE_OFFSET);
    
    	    for( i = 4; i < (PALETTE_SIZE+4); i++)
    	    {
    	        *dest++ = *src++;
    	    }
    
    	    GrOffScreen16BPPInit(&g_sVGA480x480x16Display, g_pucBuffer, LCD_WIDTH, LCD_HEIGHT);
    	    GrContextInit(&g_sContext, &g_sVGA480x480x16Display);
    
    	    /* enable End of frame interrupt */
    	    RasterEndOfFrameIntEnable(SOC_LCDC_0_REGS);
    
    	    /* enable raster */
    	    RasterEnable(SOC_LCDC_0_REGS);
    
    	    //
    	    // Fill the top 15 rows of the screen with blue to create the banner.
    	    //
    	    sRect.sXMin = 0;
    	    sRect.sYMin = 0;
    	    sRect.sXMax = GrContextDpyWidthGet(&g_sContext) - 1;
    	    sRect.sYMax = DISPLAY_BANNER_HEIGHT;
    
    	    //
    	    // Set the banner background.
    	    //
    	    GrContextForegroundSet(&g_sContext, DISPLAY_BANNER_BG);
    	    GrRectFill(&g_sContext, &sRect);
    
    	    //
    	    // Put a white box around the banner.
    	    //
    	    GrContextForegroundSet(&g_sContext, ClrWhite);
    	    GrRectDraw(&g_sContext, &sRect);
    
    	    //
    	    // Put the application name in the middle of the banner.
    	    //
    	    GrContextFontSet(&g_sContext, &g_sFontCm20);
    	    GrStringDrawCentered(&g_sContext, "usb host keyboard", -1,
    	                         GrContextDpyWidthGet(&g_sContext) / 2, 10, 0);
    
    	    //
    	    // Calculate the number of characters that will fit on a line.
    	    // Make sure to leave a small border for the text box.
    	    //
    	    g_ulCharsPerLine = (GrContextDpyWidthGet(&g_sContext) - 4) /
    	                        GrFontMaxWidthGet(&g_sFontCm20);
    
    	    //
    	    // Calculate the number of lines per usable text screen.  This requires
    	    // taking off space for the top and bottom banners and adding a small bit
    	    // for a border.
    	    //
    	    g_ulLinesPerScreen = (GrContextDpyHeightGet(&g_sContext) -
    	                          (2*(DISPLAY_BANNER_HEIGHT + 1)))/
    	                          GrFontHeightGet(&g_sFontCm20);
    
    
    	    while(1)
    	    {
    	     flip= UARTGetc();
    		 UARTPutc(flip);
    		 PrintChar(flip);
    	    }
    }
    
    /*
     * Initialize capture
     */
    static void SetUpVPIFRx(void)
    {
    	/* Disable interrupts */
    	VPIFInterruptDisable(SOC_VPIF_0_REGS, VPIF_FRAMEINT_CH1);
    	VPIFInterruptDisable(SOC_VPIF_0_REGS, VPIF_FRAMEINT_CH0);
    
    	/* Disable capture ports */
    	VPIFCaptureChanenDisable(SOC_VPIF_0_REGS, VPIF_CHANNEL_1);
    	VPIFCaptureChanenDisable(SOC_VPIF_0_REGS, VPIF_CHANNEL_0);
    
    	/* Interrupt after capturing the bottom field of every frame */
    	VPIFCaptureIntframeConfig(SOC_VPIF_0_REGS, VPIF_CHANNEL_0, VPIF_FRAME_INTERRUPT_BOTTOM);
    
    	/* Y/C interleaved capture over 8-bit bus */
    	VPIFCaptureYcmuxModeSelect(SOC_VPIF_0_REGS, VPIF_CHANNEL_0, VPIF_YC_MUXED);
    
    	/* Capturing 480I (SD NTSC) */
    	//VPIFCaptureModeConfig(SOC_VPIF_0_REGS, VPIF_480I, VPIF_CHANNEL_0, 0, (struct vbufParam *) 0);
    	VPIFCaptureModeConfig(SOC_VPIF_0_REGS, VPIF_PAL, VPIF_CHANNEL_0, 0, (struct vbufParam *) 0);
    }
    
    /*
     * Configures raster to display image
     */
    static void SetUpLCD(void)
    {
        PSCModuleControl(SOC_PSC_1_REGS, HW_PSC_LCDC, PSC_POWERDOMAIN_ALWAYS_ON,
    		     PSC_MDCTL_NEXT_ENABLE);
    
        LCDPinMuxSetup();
    
        /* disable raster */
        RasterDisable(SOC_LCDC_0_REGS);
    
        /* configure the pclk */
        RasterClkConfig(SOC_LCDC_0_REGS, 25000000, 150000000);
    
        /* 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,
                         RASTER_PALETTE_DATA, RASTER_COLOR, RASTER_RIGHT_ALIGNED);
    
        /* frame buffer data is ordered from least to Most significant bye */
        RasterLSBDataOrderSelect(SOC_LCDC_0_REGS);
    
        /* disable nibble mode */
        RasterNibbleModeDisable(SOC_LCDC_0_REGS);
    
         /* 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_LOW |
                                                RASTER_SYNC_EDGE_RISING|
                                                RASTER_SYNC_CTRL_ACTIVE|
                                                RASTER_AC_BIAS_HIGH     , 0, 255);
    
        /* configuring horizontal timing parameter */
       RasterHparamConfig(SOC_LCDC_0_REGS, DISPLAY_IMAGE_WIDTH, 64, 48, 48);
    
        /* configuring vertical timing parameters */
       RasterVparamConfig(SOC_LCDC_0_REGS, DISPLAY_IMAGE_HEIGHT, 2, 11, 31);
    
       /* configuring fifo delay to */
       RasterFIFODMADelayConfig(SOC_LCDC_0_REGS, 2);
    }
    
    /*
    ** VPIF Interrupt service routine.
    */
    Void VPIFIsr(UArg arg)
    {
    #ifdef _TMS320C6X
    	IntEventClear(SYS_INT_VPIF_INT);
    #endif
    
    	/* If previously captured frame is not processed, clear this interrupt and return */
    	if (!processed)
    	{
    		VPIFInterruptStatusClear(SOC_VPIF_0_REGS, VPIF_FRAMEINT_CH0);
    		return;
    	}
    
    	/* buffcount represents buffer to be given to capture driver and
    	 * buffcount2 represents the newly captured buffer to be processed
    	 */
    	processed = 0;
    	buffcount++;
    	buffcount2 = buffcount - 1;
    	// Currently only two buffers are being used for capture
    	if (buffcount == 2)
    		buffcount = 0;
    
    	/* Initialize buffer addresses for a new frame*/
    	VPIFCaptureFBConfig(SOC_VPIF_0_REGS, VPIF_CHANNEL_0, VPIF_TOP_FIELD,
    			VPIF_LUMA, (unsigned int) buff_luma[buffcount], CAPTURE_IMAGE_WIDTH*2);
    	VPIFCaptureFBConfig(SOC_VPIF_0_REGS, VPIF_CHANNEL_0, VPIF_TOP_FIELD,
    			VPIF_CHROMA, (unsigned int) buff_chroma[buffcount], CAPTURE_IMAGE_WIDTH*2);
    	VPIFCaptureFBConfig(SOC_VPIF_0_REGS, VPIF_CHANNEL_0, VPIF_BOTTOM_FIELD,
    			VPIF_LUMA, (unsigned int) (buff_luma[buffcount] + CAPTURE_IMAGE_WIDTH), CAPTURE_IMAGE_WIDTH*2);
    	VPIFCaptureFBConfig(SOC_VPIF_0_REGS, VPIF_CHANNEL_0, VPIF_BOTTOM_FIELD,
    			VPIF_CHROMA, (unsigned int) (buff_chroma[buffcount] + CAPTURE_IMAGE_WIDTH), CAPTURE_IMAGE_WIDTH*2);
    
    	/* Initialize buffer addresses with the captured frame ready to be processed */
    	videoTopC = buff_chroma[buffcount2];
    	videoTopY = buff_luma[buffcount2];
    
    	/* clear interrupt */
    	VPIFInterruptStatusClear(SOC_VPIF_0_REGS, VPIF_FRAMEINT_CH0);
    
    	Semaphore_post(sem1);
    }
    
    /*
    ** For each end of frame interrupt base and ceiling is reconfigured
    */
    Void LCDIsr(UArg arg)
    {
    	unsigned int status;
    	IntEventClear(SYS_INT_LCDC_INT);
    
    	/* Find which interrupt occurred and clear it */
    	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);
    
    	if(!changed)
    		return;
    
    
    
    	/* Display the appropriate output buffer on the appropriate raster buffer
    	 * and if a new processed buffer is available, let the DSP know that
    	 * it has configured the raster buffer to point to the new output buffer
    	 * by updating the 'updated' flag
    	 */
    
    
    	if (display_buff_1)
    	{
    		if (status & RASTER_END_OF_FRAME0_INT_STAT)
    		{
    			RasterDMAFBConfig(SOC_LCDC_0_REGS, (unsigned int) Rgb_buffer1,
    					(unsigned int) (Rgb_buffer1 + DISPLAY_IMAGE_WIDTH * DISPLAY_IMAGE_HEIGHT + 15), 0);
    				updated = updated | 0x1;
    		}
    		if (status & RASTER_END_OF_FRAME1_INT_STAT)
    		{
    			RasterDMAFBConfig(SOC_LCDC_0_REGS, (unsigned int) Rgb_buffer1,
    					(unsigned int) (Rgb_buffer1 + DISPLAY_IMAGE_WIDTH * DISPLAY_IMAGE_HEIGHT + 15), 1);
    				updated = updated | 0x2;
    		}
    	}
    	else
    	{
    		if (status & RASTER_END_OF_FRAME0_INT_STAT)
    		{
    			RasterDMAFBConfig(SOC_LCDC_0_REGS, (unsigned int) Rgb_buffer2,
    					(unsigned int) (Rgb_buffer2 + DISPLAY_IMAGE_WIDTH * DISPLAY_IMAGE_HEIGHT + 15), 0);
    				updated = updated | 0x1;
    		}
    		if (status & RASTER_END_OF_FRAME1_INT_STAT)
    		{
    			RasterDMAFBConfig(SOC_LCDC_0_REGS, (unsigned int) Rgb_buffer2,
    					(unsigned int) (Rgb_buffer2 + DISPLAY_IMAGE_WIDTH * DISPLAY_IMAGE_HEIGHT + 15), 1);
    				updated = updated | 0x2;
    		}
    	}
    
    
    
    	if(updated==3)
    	{
    		changed=0;
    		Semaphore_post(sem2);
    	}
    
    
    /*
    	RasterDMAFBConfig(SOC_LCDC_0_REGS,
    	                      (unsigned int)(g_pucBuffer+PALETTE_OFFSET),
    	                      (unsigned int)(g_pucBuffer+PALETTE_OFFSET) + sizeof(g_pucBuffer) - 2 - PALETTE_OFFSET,
    	                      0);
    
    	    RasterDMAFBConfig(SOC_LCDC_0_REGS,
    	                      (unsigned int)(g_pucBuffer+PALETTE_OFFSET),
    	                      (unsigned int)(g_pucBuffer+PALETTE_OFFSET) + sizeof(g_pucBuffer) - 2 - PALETTE_OFFSET,
    	                      1);
    */
    }
    
    static unsigned int UserTimeInfoGet()
    {
        unsigned char hour[2] = {0}, minute[2] = {0}, second[2] = {0};
        unsigned int hourTime = 0, minTime = 0, secTime = 0;
        unsigned int time = 0;
        int i = 0;
    
        UARTPuts("\n\nEnter the time in 24 hour format.\r\n", -1);
        UARTPuts("Example (hh:mm:ss) 20:15:09\r\n", -1);
    
        UARTPuts("\r\nEnter Hours: \r\n", -2);
    
        do
        {
            hour[i] = UARTGetc();
            UARTPutc(hour[i]);
            i++;
        }while((i < 2) && (hour[i-1] != '\r'));
    
        UARTPuts("\r\nEnter Minutes:\r\n", -2);
        i = 0;
    
        do
        {
            minute[i] = UARTGetc();
            UARTPutc(minute[i]);
            i++;
        }while((i < 2) && (minute[i-1] != '\r'));
    
        UARTPuts("\r\nEnter Seconds:\r\n", -1);
        i = 0;
    
        do
        {
            second[i] = UARTGetc();
            UARTPutc(second[i]);
            i++;
        }while((i < 2) && (second[i-1] != '\r'));
    
    
        if(hour[0] != '\r')
        {
            hourTime = (ASCIIToInt(hour[0]) << 0x04);
            if(hour[1] != '\r')
            {
                hourTime |= ASCIIToInt(hour[1]);
            }
            else
            {
                hourTime = hourTime >> 0x04;
            }
        }
    
        if(minute[0] != '\r')
        {
            minTime = (ASCIIToInt(minute[0]) << 0x04);
            if(minute[1] != '\r')
            {
                minTime |= ASCIIToInt(minute[1]);
            }
            else
            {
                minTime = minTime >> 0x04;
            }
        }
    
        if(second[0] != '\r')
        {
            secTime = (ASCIIToInt(second[0]) << 0x04);
            if(second[1] != '\r')
            {
                secTime |= ASCIIToInt(second[1]);
            }
            else
            {
                secTime = secTime >> 0x04;
            }
        }
    
        time = (hourTime << HOUR_SHIFT);
        time |= (minTime << MINUTE_SHIFT);
        time |= (secTime << SECOND_SHIFT);
    
        return time;
    
    }
    
    /*
    ** This function receives calendar related information from the user.
    */
    
    static unsigned int UserCalendarInfoGet()
    {
        unsigned int calendar = 0;
        unsigned char dayOfMonth[2] = {0}, monthArr[2] = {0}, yearArr[2] = {0};
        unsigned char dotwArr[2] = {0};
        unsigned int dom = 0, month = 0, year = 0, dotw = 0;
        int j = 0;
    
        UARTPuts("\r\n\r\nEnter the calendar information.\r\n", -2);
        UARTPuts("Example (DD:MM:YY) 31:03:73\r\n", -2);
    
        UARTPuts("\r\nEnter the day of the month: \r\n", -2);
    
        do
        {
            dayOfMonth[j] = UARTGetc();
            UARTPutc(dayOfMonth[j]);
            j++;
        }while((j < 2) && (dayOfMonth[j-1] != '\r'));
    
        j = 0;
        UARTPuts("\r\nEnter the month (Jan=01, Dec=12):\r\n", -2);
    
        do
        {
            monthArr[j] = UARTGetc();
            UARTPutc(monthArr[j]);
            j++;
        }while((j < 2) && (monthArr[j-1] != '\r'));
    
        j = 0;
        UARTPuts("\r\nEnter the year (Ex: 2010=10, 1987=87:):\r\n", -1);
    
        do
        {
            yearArr[j] = UARTGetc();
            UARTPutc(yearArr[j]);
            j++;
        }while((j < 2) && (yearArr[j-1] != '\r'));
    
    
        if(dayOfMonth[0] != '\r')
        {
            dom = (ASCIIToInt(dayOfMonth[0]) << 0x04);
            if(dayOfMonth[1] != '\r')
            {
                dom |= ASCIIToInt(dayOfMonth[1]);
            }
            else
            {
                dom = dom  >> 0x04;
            }
    
        }
    
        if(monthArr[0] != '\r')
        {
            month = (ASCIIToInt(monthArr[0]) << 0x04);
            if(monthArr[1] != '\r')
            {
                month |= ASCIIToInt(monthArr[1]);
            }
            else
            {
                month = month >> 0x04;
            }
        }
    
        if(yearArr[0] != '\r')
        {
            year = (ASCIIToInt(yearArr[0]) << 0x04);
            if(yearArr[1] != '\r')
            {
                year |= ASCIIToInt(yearArr[1]);
            }
            else
            {
                year = year >> 0x04;
            }
        }
    
        if(dotwArr[0] != '\r')
        {
            dotw = (ASCIIToInt(dotwArr[0]) << 0x04);
            if(dotwArr[1] != '\r')
            {
                dotw |= ASCIIToInt(dotwArr[1]);
            }
            else
            {
                dotw = dotw >> 0x04;
            }
        }
    
        calendar =  dom << DAY_SHIFT;
        calendar |= month << MONTH_SHIFT;
        calendar |= year << YEAR_SHIFT;
    
        return calendar;
    }
    
    /*
    ** This function prints the current time read from the RTC registers.
    */
    
    static void TimeResolve(unsigned int timeValue)
    {
        unsigned char timeArray[3] = {0};
        unsigned char bytePrint[2] = {0};
        unsigned int	i=0;
        unsigned int asciiTime = 0;
    
        timeArray[0] = (unsigned char)((timeValue & MASK_HOUR) >> HOUR_SHIFT);
        timeArray[1] = (unsigned char)((timeValue & MASK_MINUTE) >> MINUTE_SHIFT);
        timeArray[2] = (unsigned char)((timeValue & MASK_SECOND) >> SECOND_SHIFT);
    
    
        while(i <3)
          {
          		  asciiTime = intToASCII(timeArray[i]);
                    bytePrint[0] = ASCIIToInt((unsigned int)((asciiTime & 0x0000FF00) >> 0x08));
                    bytePrint[1] = ASCIIToInt((unsigned int)(asciiTime & 0x000000FF));
    
    
             switch (i)
             {
             case 0 :
            	 hour1=bytePrint[0];
            	 hour=bytePrint[1];
             break;
    
             case 1 :
            	 minute1=bytePrint[0];
            	 minute=bytePrint[1];
              break;
    
    
             case 2 :
            	seconde1=bytePrint[0];
            	seconde=bytePrint[1];
          	break;
             }
             i++;
            }
    }
    
    /*
    ** This function prints the calendar information read from the RTC registers.
    */
    
    static void CalendarResolve(unsigned int calendarValue)
    {
        unsigned char calendarArray[3] = {0};
        unsigned int asciiCalendar = 0;
        unsigned int  j = 0;
        char bytePrint[2] = {0};
    
        calendarArray[0] = (unsigned char)((calendarValue & MASK_DAY) >> DAY_SHIFT);
        calendarArray[1] = (unsigned char)((calendarValue & MASK_MONTH) >> MONTH_SHIFT);
        calendarArray[2] = (unsigned char)((calendarValue & MASK_YEAR) >> YEAR_SHIFT);
    
    
        while(j < 3)
        {
            asciiCalendar = intToASCII(calendarArray[j]);
            bytePrint[0] = ASCIIToInt((char)((asciiCalendar & 0x0000FF00) >> 0x08));
            bytePrint[1] = ASCIIToInt((char)(asciiCalendar & 0x000000FF));
    
            switch (j)
                     {
                     case 0 :
                    	 day1=bytePrint[0];
                    	 day=bytePrint[1];
                     break;
                     case 1 :
                    	 month1=bytePrint[0];
                    	 month=bytePrint[1];
                      break;
                     case 2 :
                    	year1=bytePrint[0];
                    	year=bytePrint[1];
                  	break;
                     }
                     j++;
        }
    
    }
    
    
    /*
    ** This function converts a 8 bit number to its ASCII equivalent value.
    ** The 8 bit number is passed as a parameter to this function.
    */
    
    static unsigned int intToASCII(unsigned char byte)
    {
        unsigned int retVal = 0;
        unsigned char lsn = 0, msn = 0;
        lsn = (byte & 0x0F);
        msn = (byte & 0xF0) >> 0x04;
    
        retVal = (lsn + 0x30);
        retVal |= ((msn + 0x30) << 0x08);
    
        return retVal;
    }
    
    /*
    ** This function converts the ASCII value of a hexadecimal number to its
    ** equivalent hexadecimal value.
    */
    
    static unsigned char ASCIIToInt(unsigned char byte)
    {
        unsigned char retVal = 0;
    
        /* For numbers from 0x0 to 0x9.*/
        if((byte >= 0x30) && (byte <= 0x39))
        {
            retVal = byte - 0x30;
        }
        /* For alphabets from A to Z.*/
        else if((byte >= 0x41) && (byte <= 0x46))
        {
            retVal = byte - 0x37;
        }
    
        return retVal;
    }
    
    
    /* This is the Interrupt Service Routine(ISR) for RTC.*/
    
    Void RTCIsr(UArg arg)
    {
        unsigned int timeValue = 0, calendarValue = 0;
    
        IntEventClear(SYS_INT_RTC_IRQS);
    
        /* Read the current time from RTC time registers. */
        timeValue = RTCTimeGet(SOC_RTC_0_REGS);
    
        /* Decode the time in 'timeValue' and display it on console.*/
        TimeResolve(timeValue);
    
        /* Read the current date from the RTC calendar registers. */
        calendarValue = RTCCalendarGet(SOC_RTC_0_REGS);
    
        /* Decode  the date in 'calendarValue' and display it on console.*/
        CalendarResolve(calendarValue);
        isr_rtc=1;
    }
    
    /*
    ** Delay routine.
    */
    
    void Delay(volatile unsigned int count)
    {
        while(count--);
    }
    void PrintChar(const char ucChar)
    {
        tRectangle sRect;
    
        //
        // If both the line and column have gone to zero then clear the screen.
        //
        if((g_ulLine == 0) && (g_ulColumn == 0))
        {
            //
            // Form the rectangle that makes up the text box.
            //
            sRect.sXMin = 0;
            sRect.sYMin = DISPLAY_BANNER_HEIGHT + DISPLAY_TEXT_BORDER;
            sRect.sXMax = GrContextDpyWidthGet(&g_sContext) - DISPLAY_TEXT_BORDER;
            sRect.sYMax = GrContextDpyHeightGet(&g_sContext) -
                          DISPLAY_BANNER_HEIGHT - DISPLAY_TEXT_BORDER;
    
            //
            // Change the foreground color to black and draw black rectangle to
            // clear the screen.
            //
            GrContextForegroundSet(&g_sContext, DISPLAY_TEXT_BG);
            GrRectFill(&g_sContext, &sRect);
    
            //
            // Reset the foreground color to the text color.
            //
            GrContextForegroundSet(&g_sContext, DISPLAY_TEXT_FG);
        }
    
        //
        // Send the character to the UART.
        //
        // UARTprintf("%c", ucChar);
    
        //
        // Allow new lines to cause the column to go back to zero.
        //
        if(ucChar != '\n')
        {
            //
            // Print the character to the screen.
            //
            GrStringDraw(&g_sContext, &ucChar, 1,
                         GrFontMaxWidthGet(&g_sFontCm20) * g_ulColumn,
                         DISPLAY_BANNER_HEIGHT + DISPLAY_TEXT_BORDER +
                         (g_ulLine * GrFontHeightGet(&g_sFontCm20)), 0);
        }
        else
        {
            //
            // This will allow the code below to properly handle the new line.
            //
            g_ulColumn = g_ulCharsPerLine;
        }
    
        //
        // Update the text row and column that the next character will use.
        //
        if(g_ulColumn < g_ulCharsPerLine)
        {
            //
            // No line wrap yet so move one column over.
            //
            g_ulColumn++;
        }
        else
        {
            //
            // Line wrapped so go back to the first column and update the line.
            //
            g_ulColumn = 0;
            g_ulLine++;
    
            //
            // The line has gone past the end so go back to the first line.
            //
            if(g_ulLine >= g_ulLinesPerScreen)
            {
                g_ulLine = 0;
            }
        }
    }
    /****************************** End of file **********************************/
    
    
    /***************************** End Of File ************************************/
    

    Think you very much

    • Cancel
    • Up 0 True Down
    • Cancel