PRIVATE VOID camerap_InteruptHandler(HAL_CAMERA_IRQ_CAUSE_T cause)
{
    HAL_CAMERA_IRQ_CAUSE_T mask = {0,0,0,0};
    hal_HstSendEvent(0x01);
    hal_HstSendEvent(hal_TimGetUpTime());

    switch (gSensorInfo.cammode)
    {
        case CAM_MODE_PREP_IMG_CAPTURE:
            gIfcChan = hal_CameraStartXfer((gSensorInfo.npixels*2), (UINT8*)gSensorInfo.vidbuffer);
            //mask.vsync = 1;
            mask.fend = 1;
            hal_CameraIrqSetMask(mask);
            gSensorInfo.cammode = CAM_MODE_IMG_CAPTURE;
            gIsCameraStartXfer = TRUE;
            break;
        case CAM_MODE_IMG_CAPTURE:
            hal_CameraIrqSetMask(mask);
            gSensorInfo.cammode = CAM_MODE_IDLE;
            if(hal_CameraStopXfer(FALSE)==XFER_SUCCESS)
            {
                gSensorInfo.camirqhandler(0, gSensorInfo.currentbuf);
            }
            else
            {
                gSensorInfo.camirqhandler(1, gSensorInfo.currentbuf);
            }
            gIsCameraStartXfer = FALSE;
            break;
        default:
            gSensorInfo.camirqhandler(255, 255);
            break;
    }
}
Exemple #2
0
// ============================================================================
//  pal_EnableSimCard
// ----------------------------------------------------------------------------
// This is used to select  sim-card , it enables switching between SIM 0 and
//SIM 1 as well as setting parameters.
/// @paramsim_Index: the sim card index. 0 corresponding to sim card 0,
///and 1 corresponding to sim card 1.
// ============================================================================
PUBLIC BOOL pal_EnableSimCard(UINT8 sim_Index)
{
    BOOL flag = 0;

//	UINT32 Enable_status = 0x51aa0000;
    UINT32 startTime;

#ifdef USER_SIM_SWAP
    sim_Index = g_palSimList[sim_Index];
#endif

    PAL_TRACE(PAL_LEV(16), 0, "(pal_EnableSimCard) GALLITE_8806 sim ID = %d", sim_Index);
//	pal_HstSendEvent(Enable_status + sim_Index);

    pal_SetSimIndex(sim_Index);

    hal_SimSetEtuDuration(g_palEtuParaF[g_SimIndex], g_palEtuParaD[g_SimIndex], g_palEtuClkInvFlag[g_SimIndex]);
    hal_SimSetClockStopMode(g_palSimClkStopMode[g_SimIndex]);
    hal_SimSetDataConvFormat(g_TS[g_SimIndex]);


    startTime = hal_TimGetUpTime();

    while(hal_SimGetClkStatus() && hal_SimGetClkStopStatus())//wait for clock stop
    {
        if (hal_TimGetUpTime() - startTime > 16) // if time > 1ms; break
        {
            break;
        }
    }


    flag = foursim_SetSimEnable_8806(sim_Index);

    return (!flag);
}
PRIVATE VOID camerap_InteruptHandler(HAL_CAMERA_IRQ_CAUSE_T cause)
{
    //static uint8 captureCount=0xFF;
    HAL_CAMERA_IRQ_CAUSE_T mask = {0,0,0,0};

    SXS_TRACE(TSTDOUT, "[MMC_CAMERA]camerap_InteruptHandler tick: %d Cammode: %d",hal_TimGetUpTime(),gSensorInfo.cammode);
    
    switch (gSensorInfo.cammode)
    {
        case CAM_MODE_VIEWFINDER:
            if (cause.vsync)
            {
                gIfcChan = hal_CameraStartXfer((gSensorInfo.npixels*2), (UINT8*)gSensorInfo.vidbuffer);
                gIsCameraStartXfer = TRUE;
                mask.fend = 1;
                hal_CameraIrqSetMask(mask);
            }
            else if (cause.fend)
            {
                if (gIsCameraStartXfer)
                {
                    gIsCameraStartXfer = FALSE;
                    gSensorInfo.cammode = CAM_MODE_IDLE;
                    if(hal_CameraStopXfer(FALSE) == XFER_SUCCESS)
                    {
                        gSensorInfo.camirqhandler(0, gSensorInfo.currentbuf);
                    }
                    else
                    {	
                        gSensorInfo.camirqhandler(1, gSensorInfo.currentbuf);
                    }	
                }
            }
            break;

        case CAM_MODE_PREP_IMG_CAPTURE: 
            if (cause.vsync)
            {
                gIfcChan = hal_CameraStartXfer((gSensorInfo.npixels*2), (UINT8*)gSensorInfo.vidbuffer);
                gIsCameraStartXfer = TRUE;
                gSensorInfo.cammode = CAM_MODE_IMG_CAPTURE;
                mask.fend = 1;
                hal_CameraIrqSetMask(mask);
            }
            else if (cause.fend)
            {
                if (gIsCameraStartXfer)
                {
                    gIsCameraStartXfer = FALSE;
                    hal_CameraStopXfer(FALSE);
                }
                mask.vsync = 1;
                hal_CameraIrqSetMask(mask);
            }
            break;

        case CAM_MODE_IMG_CAPTURE:
            gIsCameraStartXfer=FALSE;
            if(hal_CameraStopXfer(FALSE)==XFER_SUCCESS)
            {
                gSensorInfo.cammode = CAM_MODE_IDLE;
                hal_CameraIrqSetMask(mask);
                gSensorInfo.camirqhandler(0, gSensorInfo.currentbuf);                 
            }
            else
            {
                mask.vsync = 1;
                hal_CameraIrqSetMask(mask);
                gSensorInfo.cammode = CAM_MODE_PREP_IMG_CAPTURE;
            }
            break;

        default:
            gSensorInfo.camirqhandler(255, 255);
            break;
    }
}
Exemple #4
0
// ============================================================================
//  pal_EnableSimCard
// ----------------------------------------------------------------------------
// This is used to select  sim-card , it enables switching between SIM 0 and
//SIM 1 as well as setting parameters.
/// @paramsim_Index: the sim card index. 0 corresponding to sim card 0,
///and 1 corresponding to sim card 1.
// ============================================================================
PUBLIC BOOL pal_EnableSimCard(UINT8 sim_Index)
{
    BOOL flag = 0;
//#if (NUMBER_OF_SIM==3)  || (NUMBER_OF_SIM==4)

#ifdef SIM_SWITCH_USED
    UINT8 SwitchNum ;
    UINT8 SimNum;
#endif

#ifdef USER_SIM_SWAP
    sim_Index = g_palSimList[sim_Index];
#endif

#ifdef SIM_SWITCH_USED

    SwitchNum = sim_Index & 0x02;
    SimNum     = sim_Index & 0x01;

    if(SwitchNum ==2)
        SwitchNum = 1;

    if(sim_Index > FOURSIM_SIM_SELECT_CARD_3)
        return FALSE;
#endif

    PAL_TRACE(PAL_LEV(16), 0, "(pal_EnableSimCard) sim ID = %d", sim_Index);

    pal_SetSimIndex(sim_Index);

    hal_SimSetEtuDuration(g_palEtuParaF[g_SimIndex], g_palEtuParaD[g_SimIndex], g_palEtuClkInvFlag[g_SimIndex]);
    hal_SimSetClockStopMode(g_palSimClkStopMode[g_SimIndex]);
    hal_SimSetDataConvFormat(g_TS[g_SimIndex]);

    {
        UINT32 startTime = hal_TimGetUpTime();

        while(hal_SimGetClkStatus() && hal_SimGetClkStopStatus())//wait for clock stop
        {
            if (hal_TimGetUpTime() - startTime > 16) // if time > 1ms; break
            {
                break;
            }
        }
    }

//#if (NUMBER_OF_SIM==3)  || (NUMBER_OF_SIM==4)
#ifdef SIM_SWITCH_USED

#ifdef TGT_THREE_SIM
//	PAL_TRACE(PAL_LEV(16)|TSTDOUT, 0, "(TGT_THREE_SIM) @ pal_EnableSimCard");

    if(SwitchNum == 0)
    {
        if(threesim_SelectSwitch(SwitchNum))	// select switch
            return FALSE;
        flag = threesim_SetSimEnable(SimNum);
    }
    else
        flag = threesim_SelectSwitch(SwitchNum);

#else
    if(foursim_SelectSwitch(SwitchNum))	// select switch
        return FALSE;
    flag = foursim_SetSimEnable(SimNum, SwitchNum);
#endif

#else
    flag = dualsim_SetSimEnable(sim_Index);
#endif

    return (!flag);
}
Exemple #5
0
UINT16  UART_PutBytes( PORT port, UINT8 *pBuff, UINT16 NumToWrite,UINT16 Owner)
{
 	UINT16 real_len,send_rel_len,Tx_fifo_avail;
	DEVICE * pDev=Uart_Dev[port-1];

	if(pDev==NULL || pDev->port!=port)
	{
			SXS_TRACE(TSTDOUT,"error! wrong uart %d",port);
			return 0;
	}

	 if(pDev->writeBuf.Buf==NULL)
	 	return 0;

//qiff add for check uart DMA status
	//while ( (!hal_UartTxFinished(pDev->port) )||(!hal_UartTxDmaDone( pDev->port ) )  );

        real_len=put_data_to_CircularBuffer(&pDev->writeBuf, pBuff,NumToWrite);
    
	if(pDev->TxUseDMA)
	{
                  while ( (!(hal_UartTxFinished(pDev->port)) )||(!(hal_UartTxDmaDone( pDev->port ) ))  );
              send_rel_len=get_data_from_CircularBuffer(&pDev->writeBuf, SRAM_BUF.tx_buf,STATIC_TX_BUF_LEN);
                 
              if(send_rel_len >0 )
                {
			NumToWrite=hal_UartSendData(pDev->port, SRAM_BUF.tx_buf, send_rel_len);
                       
                }
	}

	else
	{

                    UINT32 suspend_time = 0;
                    UINT32  send_timer_out=0;
         
                    send_timer_out = hal_TimGetUpTime();
         
			while(!Is_CircularBuffer_Empty(&pDev->writeBuf))
			{
		
				if (reset_in_process)
					return -1;
				while(!hal_UartTxFinished(pDev->port))
				{
					if ((reset_in_process))
					{

                                     SXS_TRACE(TSTDOUT,"Uart Tx failed,reset_in_process = %d, send_timer_out =%d  \n",reset_in_process,send_timer_out);
					
						return -1;
					}
                            	suspend_time = hal_TimGetUpTime();

                             if (suspend_time - send_timer_out > 2*16384) {
                                return -1;
                              }
                         
				   //sxr_Sleep(1);
				}			
				Tx_fifo_avail=hal_UartTxFifoAvailable(pDev->port);
				send_rel_len=get_data_from_CircularBuffer(&pDev->writeBuf, SRAM_BUF.tx_buf,Tx_fifo_avail);
				hal_UartSendData(pDev->port, SRAM_BUF.tx_buf, send_rel_len);
				/*SXS_TRACE(TSTDOUT,"tx laixf %x dir",send_rel_len);
				SXS_TRACE(TSTDOUT," %x,%x,%x", SRAM_BUF.tx_buf[0],SRAM_BUF.tx_buf[1],SRAM_BUF.tx_buf[2]);*/
			}

		     send_timer_out=0;		
	}
//#endif
       return NumToWrite;
 }
Exemple #6
0
PUBLIC MEMD_ERR_T memd_FlashErase_Continue(UINT8 *startFlashAddress, UINT8 *endFlashAddress,UINT32 time)
{
    UINT32 status;
    VOLATILE UINT16 * ptr;
    VOLATILE UINT16 *BankAddr;
    UINT32 phy_Start;
    UINT32 phy_End;
    UINT32 phys_end_add;
    UINT32 phys_start_add;
    MEMD_ERR_T errorcode=MEMD_ERR_NO;
    BOOL isLocked;
    UINT16 rdstatus;
    UINT32 suspend_time = 0,max_time = 0;
    max_time = time MILLI_SECONDS;

    UINT32 now = hal_TimGetUpTime();
    phys_start_add = (UINT32)startFlashAddress;

    MEMD_ASSERT((phys_start_add & 0xe0000000) == 0, 
        "flash_address is expected to be a byte offset within the flash chip, not an absolute address");
    // Check that start & end addresses are aligned
    if (endFlashAddress == NULL)
    {
        memd_FlashGetSectorLimits(phys_start_add, &phy_Start, &phy_End);
        phys_end_add = phy_End;
    } else
    {
        phys_end_add = (UINT32)endFlashAddress;
        MEMD_ASSERT((phys_end_add & 0xe0000000) == 0, 
            "flash_address is expected to be a byte offset within the flash chip, not an absolute address")
        if (phys_end_add != FLASH_SIZE)
        {
            memd_FlashGetSectorLimits(phys_end_add , &phy_Start, &phy_End);
            if (phys_end_add != phy_Start)
            {
                return MEMD_ERR_ALIGN;
            }
        }
    }

    memd_FlashGetSectorLimits(phys_start_add, &phy_Start, &phy_End);
    if (phys_start_add != phy_Start)
    {
        return MEMD_ERR_ALIGN;
    }

    hal_EbcFlashWriteEnable(TRUE);

    BankAddr = NULL;
    while (phy_Start != phys_end_add)
    {
        BankAddr = (VOLATILE UINT16 *)(g_memdFlashBaseAddress + (phy_Start&FLASHBANK_MASK));
        // phy_Start should already be aligned to sector boundary, so shouldn't need any more masking
        ptr = (VOLATILE UINT16 *)(g_memdFlashBaseAddress + phy_Start);

       
        memd_FlashGetLockStatus((UINT8*)((UINT32)ptr & MY_MASK),&isLocked);
	 // Re-enable EBC write
        hal_EbcFlashWriteEnable(TRUE);


        if(isLocked == TRUE)
        {
           memd_BlockLock((UINT8*)((UINT32)ptr & MY_MASK),NULL,FALSE);
           	  
        }
  
        status = hal_SysEnterCriticalSection();		
        // Sector Erase command
        *(BankAddr) = CMD_EEASE_RESUME;

        //*(BankAddr) = CMD_ERASE_SUSPEND;
        hal_SysExitCriticalSection(status);


        // pooling
        // Wait for Ready, then check status
        do{

                 suspend_time =  hal_TimGetUpTime();
                 if (suspend_time - now > max_time) 
                 {
         
                            status = hal_SysEnterCriticalSection();		
                            *(BankAddr) = CMD_ERASE_SUSPEND;
                            *(BankAddr) = CMD_READ_STATUS;
                            do{
                             rdstatus = *BankAddr;
           
                            }while((rdstatus & SR7) != SR7);
                            
                             rdstatus = *BankAddr;
           
                            if((rdstatus & SR6) == SR6)
                            {
           
                              *BankAddr = CMD_READ_ARRAY;
                              hal_SysExitCriticalSection(status);
                              hal_EbcFlashWriteEnable(FALSE);
                              return MEMD_ERR_SUSPEND;
                            }
                            else
                            {
                              *BankAddr = CMD_READ_ARRAY;
                               hal_SysExitCriticalSection(status);
                              hal_EbcFlashWriteEnable(FALSE);
                              return MEMD_ERR_NO;

                            }

                 }
                 
     
             rdstatus = *BankAddr;
        }while((rdstatus & SR7) != SR7);   // Any address in the bank may be used

        // Should probably fix this scheme for reporting errors more cleanly.
        // For now, just prioritize the errors with the most significant error returned
        // in errorcode (order this list from least to most significant)
        if ((rdstatus & SR3) != 0)
        {
          	 
            // Vpp Invalid Error
            errorcode=MEMD_ERR_ERASE;
        }
        else if (((rdstatus & SR5) != 0) && ((rdstatus & SR4) != 0))
        {
            // Command Sequence Error
            errorcode=MEMD_ERR_ERASE; while(1){;};
        }
        else if ((rdstatus & SR5) != 0)
        {
            // Erase Error
            errorcode=MEMD_ERR_ERASE; while(1){;};
        }
        else if ((rdstatus & SR1) != 0)
        {
            errorcode=MEMD_ERR_PROTECT; while(1){;};
        }
        
        // Reset to read array mode when every block erase operation is finished.
	      status = hal_SysEnterCriticalSection();
        *BankAddr = CMD_READ_ARRAY;
        hal_SysExitCriticalSection(status);

      	// Clear status register if any error 
      	if(errorcode != MEMD_ERR_NO)
      	{
      	    status = hal_SysEnterCriticalSection();
            *BankAddr = CMD_CLR_STATUS_REG;
            hal_SysExitCriticalSection(status);
      	    hal_EbcFlashWriteEnable(FALSE);
            return errorcode;
      	}
      
        if (phy_End != FLASH_SIZE)
        {
            memd_FlashGetSectorLimits(phy_End, &phy_Start, &phy_End);
        } else
        {
            phy_Start = phy_End;
        }
    }
    if (BankAddr != NULL)
    {
        // Return to Read Array mode
        status = hal_SysEnterCriticalSection();
        *BankAddr = CMD_READ_ARRAY;
        hal_SysExitCriticalSection(status);
    }

    // erase done
    hal_EbcFlashWriteEnable(FALSE);

    return errorcode;
}
Exemple #7
0
PUBLIC MEMD_ERR_T memd_FlashErase_Continue(UINT8 *startFlashAddress, UINT8 *endFlashAddress,UINT32 time)
{
    UINT8 rdstatus, rdstatus_old;
    UINT32 status;
    VOLATILE UINT8 * ptr;
    VOLATILE UINT16 *flashaddr;
    UINT32 Start, End;
    UINT32 phys_end_add, phys_start_add;
    UINT32 suspend_time = 0,max_time = 0;
    max_time = time MILLI_SECONDS;
    UINT32 now = hal_TimGetUpTime();

    phys_start_add = (UINT32)startFlashAddress;
    MEMD_ASSERT((phys_start_add & 0xe0000000) == 0, 
        "flash_address is expected to be a byte offset within the flash chip, not an absolute adresse");
    
    // Check that start & end addresses are aligned
    if (endFlashAddress == NULL)
    {
        memd_FlashGetSectorLimits(phys_start_add, &Start, &End);
        phys_end_add = End;
    } else
    {
        phys_end_add = (UINT32)endFlashAddress;
        MEMD_ASSERT((phys_end_add & 0xe0000000) == 0, 
            "flash_address is expected to be a byte offset within the flash chip, not an absolute adresse")
        if (phys_end_add != FLASH_SIZE)
        {
            memd_FlashGetSectorLimits(phys_end_add , &Start, &End);
            if (phys_end_add != Start)
            {
                return MEMD_ERR_ALIGN;
            }
        }
    }

    memd_FlashGetSectorLimits(phys_start_add, &Start, &End);
    if (phys_start_add != Start)
    {
        return MEMD_ERR_ALIGN;
    }
    hal_EbcFlashWriteEnable(TRUE);

    while (Start != phys_end_add)
    {
        flashaddr = (VOLATILE UINT16 *)(g_memdFlashBaseAddress + (Start&FLASHBANK_MASK));
        ptr = (VOLATILE UINT8 *)(g_memdFlashBaseAddress + (Start&~0xfff));

        if (!g_memdDybOverride)
        {
            if (memd_DYBCheck(flashaddr, (UINT16*)ptr))
            {
                hal_EbcFlashWriteEnable(FALSE);hal_HstSendEvent(0x654314); 
                return MEMD_ERR_PROTECT;
            }
        }

        status = hal_SysEnterCriticalSection();
        *(ptr) = 0x30;
        hal_SysExitCriticalSection(status);

        // note the pooling could be done on data == 0xff also
    
        // pooling
        rdstatus = (*ptr);
        while(1){
                suspend_time = hal_TimGetUpTime();
                 if (suspend_time - now > max_time) 
                  {
                      status = hal_SysEnterCriticalSection();
                      *(ptr) = 0xb0;
                      hal_SysExitCriticalSection(status);
                      do
                      {
                         rdstatus_old = (*ptr);
                         rdstatus = (*ptr);
                         rdstatus_old &= 0x80;
                         rdstatus &= 0x80;
                        
                      }while (!(rdstatus_old == 0x80 && rdstatus == 0x80));	// Wait for suspend active
                      (*flashaddr) = 0xf0;
                      hal_EbcFlashWriteEnable(FALSE);

                      return MEMD_ERR_SUSPEND;

                  }

          
            rdstatus_old = rdstatus;
            rdstatus = (*ptr);
            // DQ6 & DQ2 not toggling? => done
            if (((rdstatus ^ rdstatus_old) & 0x44) == 0)
            break;
            // DQ5 = 1
            if ((rdstatus & 0x20) == 0x20) {
                rdstatus_old = (*ptr);
                rdstatus = (*ptr);
                // DQ6 & DQ2 not toggling? => done
                if (((rdstatus ^ rdstatus_old) & 0x44) == 0)
                    break;
                // reset
                (*flashaddr) = 0xf0;
                hal_EbcFlashWriteEnable(FALSE);hal_HstSendEvent(0x654312); 
                return MEMD_ERR_ERASE;
            }
        }
        if (End != FLASH_SIZE)
        {
            memd_FlashGetSectorLimits(End, &Start, &End);
        } else
        {
            Start = End;
        }
    }
    // erase done
    hal_EbcFlashWriteEnable(FALSE);
     hal_HstSendEvent(0x653333);
    return MEMD_ERR_NO;
}
Exemple #8
0
// ============================================================================
// lcddp_Blit16
// ----------------------------------------------------------------------------
/// This function provides the basic bit-block transfer capabilities. 
/// This function copies the data (such as characters/bmp) on the LCD directly
/// as a (rectangular) block. The data is drawn in the active window.
/// The buffer has to be properly aligned (@todo define properly 'properly')
///
/// @param pPixelData Pointer to the buffer holding the data to be displayed
/// as a block. The dimension of this block are the one of the #pDestRect 
/// parameter
/// @return #LCDD_ERR_NO, #LCDD_ERR_RESOURCE_BUSY or #LCDD_ERR_NOT_OPENED. 
// ============================================================================
PRIVATE LCDD_ERR_T lcddp_Blit16(CONST LCDD_FBW_T* frameBufferWin, UINT16 startX, UINT16 startY)
{
    LCDD_ASSERT((frameBufferWin->fb.width&1) == 0, "LCDD: FBW must have an even number "
            "of pixels per line. Odd support is possible at the price of a huge "
            "performance lost");
    // Active window coordinates.
    HAL_GOUDA_WINDOW_T inputWin;
    HAL_GOUDA_WINDOW_T activeWin;
    hal_HstSendEvent(0x88855516);
    UINT32 now = hal_TimGetUpTime();

    if (0 == lcdd_MutexGet())
    {
        return LCDD_ERR_RESOURCE_BUSY;
    }
    else
    {   
        if (g_lcddInSleep)
        {
            lcdd_MutexFree();
            return LCDD_ERR_NO;
        }

        // Set Input window
        inputWin.tlPX = frameBufferWin->roi.x;
        inputWin.brPX = frameBufferWin->roi.x + frameBufferWin->roi.width - 1;
        inputWin.tlPY = frameBufferWin->roi.y;
        inputWin.brPY = frameBufferWin->roi.y + frameBufferWin->roi.height - 1;

        // Set Active window
        activeWin.tlPX = startX;
        activeWin.brPX = startX + frameBufferWin->roi.width - 1;
        activeWin.tlPY = startY;
        activeWin.brPY = startY + frameBufferWin->roi.height - 1;

        // Check parameters
        // ROI must be within the screen boundary
        // ROI must be within the Frame buffer
        // Color format must be 16 bits
        BOOL badParam = FALSE;
        if (g_lcddRotate)
        {
            if (    (activeWin.tlPX >= LCDD_DISP_Y) ||
                    (activeWin.brPX >= LCDD_DISP_Y) ||
                    (activeWin.tlPY >= LCDD_DISP_X) ||
                    (activeWin.brPY >= LCDD_DISP_X)
               )
            {
                badParam = TRUE;
            }
        }
        else
        {
            if (    (activeWin.tlPX >= LCDD_DISP_X) ||
                    (activeWin.brPX >= LCDD_DISP_X) ||
                    (activeWin.tlPY >= LCDD_DISP_Y) ||
                    (activeWin.brPY >= LCDD_DISP_Y)
               )
            {
                badParam = TRUE;
            }
        }
        if (!badParam)
        {
            if (    (frameBufferWin->roi.width > frameBufferWin->fb.width) ||
                    (frameBufferWin->roi.height > frameBufferWin->fb.height) ||
                    (frameBufferWin->fb.colorFormat != LCDD_COLOR_FORMAT_RGB_565)
                )
            {
                badParam = TRUE;;
            }
        }
        if (badParam)
        {
            lcdd_MutexFree();  
            return LCDD_ERR_INVALID_PARAMETER;
        }
        // this will allow to keep LCDD interface for blit while using gouda
        // directly for configuring layers
        if (frameBufferWin->fb.buffer != NULL)
        {
            g_lcddAutoCloseLayer = FALSE;
            WriteCommand_Addr(0x2a);WriteCommand_Data(0x00);WriteCommand_Data(activeWin.tlPX);
            WriteCommand_Data(0x00);WriteCommand_Data(activeWin.brPX);
            WriteCommand_Addr(0x2b);WriteCommand_Data(0x00);WriteCommand_Data(activeWin.tlPY );
            WriteCommand_Data(0x00);WriteCommand_Data(activeWin.brPY);
           #if 0
       			LCM_WR_REG(0x0002,(hsa>>8)&0x00ff); // Column address start2
       			LCM_WR_REG(0x0003,hsa&0x00ff); // Column address start1
       			LCM_WR_REG(0x0004,(hea>>8)&0x00ff); // Column address end2
       			LCM_WR_REG(0x0005,hea&0x00ff); // Column address end1
       			LCM_WR_REG(0x0006,(vsa>>8)&0x00ff); // Row address start2
       			LCM_WR_REG(0x0007,vsa&0x00ff); // Row address start1
       			LCM_WR_REG(0x0008,(vea>>8)&0x00ff); // Row address end2
       			LCM_WR_REG(0x0009,vea&0x00ff); // Row address end1
           #endif
           WriteCommand_Addr(0x2c);
           hal_GpioSet(g_slcd_a0);
        }

          if (frameBufferWin->roi.width == frameBufferWin->fb.width)
          {
              // The source buffer and the roi have the same width, we can
              // do a single linear transfer
              lcdd_TransferData(frameBufferWin->fb.buffer+frameBufferWin->roi.y*frameBufferWin->roi.width
                      ,frameBufferWin->roi.width*frameBufferWin->roi.height,TRUE);
              hal_HstSendEvent(0x88855528);  

          }
          else
          {
              // The source buffer is wider than the roi 
              // we have to do a 2D transfer
              UINT16 curLine=0;
              UINT16 startLine = frameBufferWin->roi.y;
              UINT16 endLine = frameBufferWin->roi.y+frameBufferWin->roi.height-1;
              // Start at the base of the buffer
              // add the number of pixels corresponding to the start line
              // add the number of pixel corresponding to the startx
              UINT16* curBuf = frameBufferWin->fb.buffer
                  +(frameBufferWin->roi.y*frameBufferWin->fb.width)
                  +(frameBufferWin->roi.x);
                          
              for (curLine=startLine; curLine<=endLine; curLine++)
              {   

                  // transfer one line
                  if (curLine == endLine)
                  {
                      lcdd_TransferData(curBuf, frameBufferWin->roi.width, TRUE);hal_HstSendEvent(0x88855521);
                  }
                  else
                  {
                      lcdd_TransferData(curBuf, frameBufferWin->roi.width, FALSE);
                  }
                  // goto next line
                  curBuf+=frameBufferWin->fb.width;
              }
          }
         UINT32 now2 = hal_TimGetUpTime();
         SXS_TRACE(TSTDOUT, "lcd speed on frame %d ms ",(now2-now)*1000/16384);


        return LCDD_ERR_NO;
    }