Exemplo n.º 1
0
PRIVATE VOID lcdd_TransferData(CONST UINT16* pPixelData,UINT16 nPixelWrite, BOOL lastLine)
{
#if 1
            UINT32 i;
            UINT16 g_dmaBusy = 0;
            for(i = 0;i<nPixelWrite;i++)
            {
              g_buffer_data[i]=(pPixelData[i]>>8)|(pPixelData[i]<<8);
            }
            g_dmaBusy = hal_SpiSendData(HAL_SPI,HAL_SPI_CS0,(UINT8*)(g_buffer_data),nPixelWrite*2);
            if(g_dmaBusy == 0)
            {
             hal_DbgAssert("dma busy");
            }
            while (!hal_SpiTxDmaDone(HAL_SPI, HAL_SPI_CS0));
            if (lastLine)
            {
                lcdd_MutexFree();
            }

            #if 0
            HAL_DMA_CFG_T dmaCfg;
            dmaCfg.srcAddr = (UINT8*)(pPixelData); 
            dmaCfg.dstAddr = (UINT8*) &LCM_DAT;
            dmaCfg.alterDstAddr = 0;
            dmaCfg.pattern = 0;
            // Number of bytes to transfer. One pixel being 16 bits,
            // transfer size is number of pixel * 2 !
            dmaCfg.transferSize = nPixelWrite*2;

            // Write the color in the data register of the screen
            dmaCfg.mode = HAL_DMA_MODE_CONST_ADDR;
            
            if (lastLine)
            {
                dmaCfg.userHandler = lcdd_FreeLock;
            } 
            #endif
#else
            UINT32 x;
            
            for (x = 0; x < nPixelWrite; x++)
            {
                g_image[0]=(UINT8)((pPixelData[x]&0xff00)>>8);g_image[1]=(UINT8)(pPixelData[x]&0x00ff);
                Write_Data_Image;

               //  hal_SpiSendData(HAL_SPI,HAL_SPI_CS0,pPixelData[x],2);
              //   while(!hal_SpiTxFinished(HAL_SPI,HAL_SPI_CS0));
              //   while (!hal_SpiTxDmaDone(HAL_SPI, HAL_SPI_CS0);


                
            }
            if (lastLine)
            {
                lcdd_MutexFree();
            }

#endif
}
Exemplo n.º 2
0
UINT16 put_data_to_CircularBuffer(struct  CircularBuf *pCirBuff, UINT8 *pBuff,UINT16 uDataSize)
{
     UINT16 Block_Len, Remain_Len, real_Len, First_half, Second_half;
	
       UINT32 status = hal_SysEnterCriticalSection();
    	
    // do thing with uart breakint not happen
	Block_Len = GET_DATA_BLOCK_LEN(pCirBuff->Get, pCirBuff->Put, pCirBuff->Buf_len);

	if ((Block_Len == 0) && (pCirBuff->NotEmpty))
	{
		Block_Len = pCirBuff->Buf_len;
	}


	Remain_Len = pCirBuff->Buf_len - Block_Len;
      /*hal_HstSendEvent(SYS_EVENT, 0x07280100);
      hal_HstSendEvent(SYS_EVENT, Remain_Len);
      hal_HstSendEvent(SYS_EVENT, uDataSize);*/
	if(Remain_Len==0)
	{
        hal_HstSendEvent(SYS_EVENT, 0x01010000);
		hal_DbgAssert("%s buffer overflow, Remain_Len=0!!",pCirBuff->Name);
		return 0;
	}
	if (uDataSize > Remain_Len)
    {   
		hal_DbgAssert("%s  buffer overflow!! uDataSize=%d, Remain_Len=%d",pCirBuff->Name,uDataSize,Remain_Len);
        return 0;
    }
	real_Len = uDataSize;// (uDataSize < Remain_Len) ? uDataSize : Remain_Len;

	if (real_Len > 0)/*circular buffer not full*/
	{
		if (pCirBuff->Put < pCirBuff->Get)
		{
			memcpy(&pCirBuff->Buf[pCirBuff->Put], pBuff, real_Len);
			pCirBuff->Put = MOD_BUFF_LEN(pCirBuff->Put + real_Len,pCirBuff->Buf_len);
		}
		else
		{
			First_half = pCirBuff->Buf_len - pCirBuff->Put;

			if (real_Len < First_half)
			{
				memcpy(&pCirBuff->Buf[pCirBuff->Put], pBuff, real_Len);
				pCirBuff->Put = MOD_BUFF_LEN(pCirBuff->Put + real_Len, pCirBuff->Buf_len);
			}
			else
			{
				memcpy(&pCirBuff->Buf[pCirBuff->Put], pBuff , First_half);
				Second_half = real_Len - First_half;
				pCirBuff->Put = MOD_BUFF_LEN((pCirBuff->Put + First_half),pCirBuff->Buf_len);

				memcpy(&pCirBuff->Buf[pCirBuff->Put], &pBuff[First_half], Second_half);
				pCirBuff->Put = MOD_BUFF_LEN((pCirBuff->Put + Second_half),pCirBuff->Buf_len);

			}

		}
		
		pCirBuff->NotEmpty = 1;
		
	}
	else
	{
		SXS_TRACE(TSTDOUT,"warning put len %x",real_Len);

	}
	
  	hal_SysExitCriticalSection(status);
	return Remain_Len -real_Len;
}