Example #1
0
File: mci.c Project: BarryChen/RDA
UINT32 MCI_PlayBTStream (bt_a2dp_audio_cap_struct *audio_cap)
{
	INT32 result=0;
       mci_type_enum mediaType;
       
       hal_HstSendEvent(SYS_EVENT,0x10250010);
       hal_HstSendEvent(SYS_EVENT,audio_cap);
       hal_HstSendEvent(SYS_EVENT,audio_cap->codec_type);

       csw_SetResourceActivity(CSW_LP_RESOURCE_AUDIO_PLAYER, CSW_SYS_FREQ_104M);
       if(audio_cap->codec_type == AVDTP_MEDIA_CODEC_SBC)
            mediaType = MCI_TYPE_SBC;
       else if(audio_cap->codec_type == AVDTP_MEDIA_CODEC_MPEG1_2_AUDIO )
            mediaType = MCI_TYPE_DAF;
       else if(audio_cap->codec_type == AVDTP_MEDIA_CODEC_MPEG2_4_AAC)
	   	 mediaType = MCI_TYPE_AAC;
       else
            return MCI_ERR_BAD_FORMAT;
       
	g_mciAudioFinishedCallback=NULL;
       MCI_BTAudioCap = audio_cap;
       MCI_Play_BTStream = 1;
       MCI_Play_Stream_Buffer = 0;
	result     = LILY_AudioPlay(0, 0,mediaType, 0);
    hal_HstSendEvent(SYS_EVENT,0x10250100);
    hal_HstSendEvent(SYS_EVENT,result);
    return result;
}
Example #2
0
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;
    }
}
Example #3
0
File: mci.c Project: BarryChen/RDA
UINT32 MCI_StartBTSCO (UINT16 handle)
{
	INT32 result=0;
       mci_type_enum mediaType = MCI_TYPE_SCO;
       
       MCI_Play_BTStream = 1;
       MCI_Play_Stream_Buffer = 0;
	result     = LILY_AudioPlay(0, handle,mediaType, 0);
    
    hal_HstSendEvent(SYS_EVENT,0x10270100);
    hal_HstSendEvent(SYS_EVENT,result);
    return result;
}
Example #4
0
/********************************************************************************
* Description : Set the selected location which is specified by location.
*
* Arguments  :
*            location:     store drive name, path name, file name.
* Returns     :
*            TRUE:    Successful
*            FALSE:    Fail, detail information in fselError
* Notes       :  Should select path in the case of only file name is invalid
*
********************************************************************************/
UINT8 fselSetLocationC(file_location_t  *location)
{
	TCHAR name[12];
	UINT32 entry;
	INT32 ret;
	
	fselFileNo = 0;
	fselError  = 0;
	fselTotal  = 0;
	
	fselDiskLetter = location->disk;
	
	FS_GetShortName(location->subdir_entry, name);
	
	if(strcmp(name, location->subdir_name) != 0)
	{
		fselError = FSEL_ERR_SETDIR;
		return FALSE;
	}
	FS_ChangeSubDir(location->subdir_entry);
	
	if(location->file_entry != 0)
	{
		FS_GetShortName(location->file_entry, name);
		
		//modify by wuxiang
		//扩展名大小写会导致比较出问题,在此修改成不区分大小写的比较函数
		//if(strcmp(name, location->file_name) == 0)
		//modify end
		if(strnicmp(name, location->file_name, strlen(name)) == 0)
		{
			FS_SetCurDirEntry(location->file_entry);
			hal_HstSendEvent(SYS_EVENT, 0x19191919);
		}
		else
		{
			location->file_entry = 0;
		}
	}
	
	fselFileNo = 0;
	fselTotal  = 0;
	
	ret = FS_GetNextEntry(&entry, GetExtBuf(), FS_DIR_FILE);
	
	while(ret == ERR_SUCCESS)
	{
		fselTotal ++;
		if(entry == location->file_entry)
		{
			fselFileNo = fselTotal;
		}
		ret = FS_GetNextEntry(&entry, GetExtBuf(), FS_DIR_FILE_CONT);
	}
	
	FS_SetCurDirEntry(location->file_entry);
	
	return TRUE;
}
Example #5
0
/*********************************************************************************
* Description : 注册功能模块函数,提供外部调用
*
* Arguments   :
*
* Returns     :
*
* Notes       :
*
*********************************************************************************/
INT32 APP_ModCall(UINT8 mod, INT32 Param)
{
	hal_HstSendEvent(SYS_EVENT, 0x10140000 + mod);
	g_current_module = mod;
	if((mod < MAX_FUNCTION_MOD) && (currModFuncPtrs[mod] != NULL))
	{
		return currModFuncPtrs[mod](Param);
	}
	return -1;
}
Example #6
0
// =============================================================================
// memd_RamOpen
// -----------------------------------------------------------------------------
/// That function configures the RAM.
/// It must be called to configure the best settings for the RAM, thus enabling
/// the fatest access.
/// @param cfg Ram configuration used to open the RAM.
///
// =============================================================================
PUBLIC VOID memd_RamOpen(CONST MEMD_RAM_CONFIG_T* cfg)
{
	hal_HstSendEvent(0x854321);

#ifdef MEMD_RAM_IS_BURST
    hal_EbcSramOpen(&cfg->csConfig, memd_RamConfigureBurstMode);
#else //!MEMD_RAM_IS_BURST
    // Open External SRAM
    hal_EbcCsOpen(HAL_EBC_SRAM, &cfg->csConfig);
#endif //!MEMD_RAM_IS_BURST
   
}
Example #7
0
PRIVATE BOOL lcddp_CheckProductId()
{
    UINT16 productId=0;
    LCDD_CONFIG_T lcddReadConfig=LCDD_READ_CONFIG;

    hal_GoudaOpen(&lcddReadConfig.config, lcddReadConfig.timings, 0);
    sxr_Sleep(20 MS_WAITING);

    hal_GoudaReadReg(0x93, &productId);
    hal_GoudaClose();
    
    SXS_TRACE(TSTDOUT, "hx8340b(0x%x): lcd read id is 0x%x ", LCD_HX8340B_ID, productId);
    hal_HstSendEvent(0x1cd00004);
    hal_HstSendEvent(productId);

    if(productId == LCD_HX8340B_ID)
        return TRUE;
    else
        return FALSE;

}
Example #8
0
PRIVATE BOOL lcddp_CheckProductId()
{
    UINT16 productId=0;
    LCDD_CONFIG_T lcddReadConfig=LCDD_READ_CONFIG;

    hal_GoudaOpen(&lcddReadConfig.config, lcddReadConfig.timings, 0);
    sxr_Sleep(20 MS_WAITING);

    hal_GoudaReadReg(0xda, &productId);
#if 0	
	hal_HstSendEvent(0xff9163C1);
	hal_HstSendEvent((UINT32)productId);
	hal_HstSendEvent(0xff9163C1);	
#endif	
	hal_GoudaReadData(&productId);
#if 0	
	hal_HstSendEvent(0xff9163C2);
	hal_HstSendEvent((UINT32)productId);
	hal_HstSendEvent(0xff9163C2);	
#endif
	hal_GoudaClose();

    SXS_TRACE(TSTDOUT, "ili9163c(0x%x): lcd read id is 0x%x ", LCD_ILI9163C_ID, productId);

    if(productId == LCD_ILI9163C_ID)
        return TRUE;
    else
        return FALSE;
}
Example #9
0
void Rdabt_trap_write_r18(void)
{
//   extern BOOL  g_CalbClock;
   int32 i;
   
#if 0   
   if(g_CalbClock)
   {
       hal_HstSendEvent(1, 0x88888888);
       for(i=0;i<sizeof(rda_trap_calib_18)/sizeof(rda_trap_calib_18[0]);i++)
       {
          rdabt_wirte_memory(rda_trap_calib_18[i][0],&rda_trap_calib_18[i][1],1,0x0);
          RDABT_DELAY(1);
       }	
   }
   else
#endif   
   {
       for(i=0;i<sizeof(rda_trap_18)/sizeof(rda_trap_18[0]);i++)
       {
          rdabt_wirte_memory(rda_trap_18[i][0],&rda_trap_18[i][1],1,0);
          RDABT_DELAY(1);
       }	
#if 0
	   	rdabt_adp_uart_stop();
		rdabt_adp_uart_start();
		rdabt_adp_uart_configure(115200,FALSE);
		rdabt_uart_register_cb(); 
		rdabt_baudrate_ctrl();

		RDABT_DELAY(100);
	   for(i=0;i<sizeof(rda_trap_18_2)/sizeof(rda_trap_18_2[0]);i++)
       {
          rdabt_wirte_memory(rda_trap_18_2[i][0],&rda_trap_18_2[i][1],1,0);
          RDABT_DELAY(1);
       }
#endif	   
  }
}
Example #10
0
// =============================================================================
// memd_FlashOpen
// -----------------------------------------------------------------------------
/// That function configures the flash.
/// It must be called before using any other function of the MEMD API.
///
/// @param cfg Pointer to the configuration to use to open the flash.
/// This parameter is ignored by the romulator driver.
/// @return Pointer towards the structure describing the flash.
// =============================================================================
PUBLIC MEMD_FLASH_LAYOUT_T* memd_FlashOpen(CONST MEMD_FLASH_CONFIG_T* cfg)
{
    MEMD_ASSERT(cfg != NULL, "Opening flash with a NULL configuration");
    // Open EBC ? (not needed with new hardware, as the only option
    // is enable ...
hal_HstSendEvent(0x54388);

    // Open Flash, and store base address.
#ifdef MEMD_FLASH_IS_BURST
    g_memdFlashBaseAddress = (UINT32) hal_EbcFlashOpen(HAL_SYS_FREQ_13M,
                            &cfg->csConfig, memd_FlashConfigureBurstMode);
#else //!MEMD_FLASH_IS_BURST
#ifdef MEMD_RAM_IS_BURST
    g_memdFlashBaseAddress = (UINT32) hal_EbcFlashOpen(HAL_SYS_FREQ_13M,
                            &cfg->csConfig, NULL);
#else //!MEMD_RAM_IS_BURST
    g_memdFlashBaseAddress = (UINT32) hal_EbcFlashOpen(HAL_SYS_FREQ_39M,
                            &cfg->csConfig, NULL);
#endif //!MEMD_RAM_IS_BURST
#endif //!MEMD_FLASH_IS_BURST

    return ((MEMD_FLASH_LAYOUT_T*) &g_memdFlashLayout);
}
Example #11
0
uint32 ScsiReadCapacity(PSCSI_DEVICE pDevice, PDISK_INFO pDiskInfo, uint8 Lun)
{
	TRANSPORT_COMMAND tCommand;
	uint8             bCDB[MAX_CDB];

	TRANSPORT_DATA tData;
	uint8    bDataBlock[8];
	uint32 dwSizeDB = sizeof(bDataBlock);

	uint32 dwSizeDI = sizeof(DISK_INFO);
	uint32 dwErr    = ERROR_SUCCESS;
	
	memset(pDiskInfo, 0, dwSizeDI);

	tCommand.Flags   = DATA_IN;
	tCommand.Timeout = pDevice->Timeouts.ScsiCommandTimeout;
	tCommand.Length  = USBMSC_SUBCLASS_SCSI == pDevice->DiskSubClass ?SCSI_CDB_10 : UFI_CDB;
	tCommand.CommandBlock = bCDB;
	tCommand.dwLun=Lun;

	memset( bCDB, 0, sizeof(bCDB));
	bCDB[0] = SCSI_READ_CAPACITY;

	ASSERT(Lun <= 0x7);
	bCDB[1] = ((Lun & 0x7) << 5);

	// PMI & LBA support is TBD
	// It's useful in determining where longer access times occur

	memset( bDataBlock, 0, dwSizeDB);
	tData.TransferLength = 0;
	tData.RequestLength = dwSizeDB;
	tData.DataBlock = bDataBlock;

	dwErr = UsbsDataTransfer(pDevice->hUsbTransport, &tCommand, &tData );

	if ( dwErr != ERROR_SUCCESS ||(tData.TransferLength != tData.RequestLength) ) 
	{
		dwErr = ScsiGetSenseData( pDevice, Lun );	
	} 
	else
	{
		hal_HstSendEvent(SYS_EVENT,0x09100010);

		//memcpy(bDataBlock, bDataBlock, sizeof(bDataBlock));
		// Get total sectors from Last Logical Block Address
		pDiskInfo->di_total_sectors  = GetDWORD(&bDataBlock[0])+1; 
		// Block Length in bytes
		pDiskInfo->di_bytes_per_sect = GetDWORD(&bDataBlock[4]);
		pDiskInfo->di_flags |= DISK_INFO_FLAG_PAGEABLE | DISK_INFO_FLAG_CHS_UNCERTAIN;
	
		if ( pDiskInfo->di_bytes_per_sect && pDiskInfo->di_total_sectors)
		{
			// update our media info & flags
			pDevice->Flags.MediumPresent = TRUE;

			if ( 0 != memcmp(&pDevice->DiskInfo, pDiskInfo, dwSizeDI) ) 
			{
				memcpy(&pDevice->DiskInfo, pDiskInfo, dwSizeDI);
			}
		}

	}
	//sxr_Free(pDataBlock);

	return dwErr;
	
}
Example #12
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;
}
Example #13
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;
    }
Example #14
0
/*********************************************************************************
* Description : 初始化系统设置变量
*
* Arguments   :
*
* Returns     :
*
* Notes       :
*
*********************************************************************************/
void APP_ReadComPara(void)
{
	//DSM_ReadUserData();
	
	//NVRAMRead(g_comval, VM_SYSTEM, sizeof(g_comval));
	g_comval = (comval_t*)NVRAMGetData(VM_SYSTEM, sizeof(comval_t));
	hal_HstSendEvent(SYS_EVENT, 0x19880900);
	if(g_comval->magic != MAGIC_COMVAL)
	{
		hal_HstSendEvent(SYS_EVENT, 0x19880901);
		if(!LoadFactorySetting(g_comval, sizeof(g_comval)))
		{
			g_comval->DisplayContrast = 5;
			g_comval->langid    = GUI_LANG_SM_CHINESE;
			g_comval->LightTime = 3;
			//g_comval->ReplayMode = 0;
			//g_comval->SleepTime = 0;
			g_comval->StandbyTime = 30;
			//g_comval->BatteryType = BATT_TYPE_ALKALINE;
			//g_comval->FMBuildInFlag = 0;
			//g_comval->RecordType = 0;
			//g_comval->BLightColor = 3;
			g_comval->BackLight = 5;
			g_comval->Volume = 8; // default volume
			
			g_comval->music_cfg.loop_mode = 0;
			g_comval->music_cfg.eq_mode = 0;
			g_comval->music_cfg.repeat_count = 3;
			g_comval->music_cfg.repeat_time = 30;
			
#if APP_SUPPORT_FM==1           /*Surport fm*/
			g_comval->fm_value.fm_band = 0;
			g_comval->fm_value.fm_sendfreq = 1000;
#endif
		}
		hal_HstSendEvent(SYS_EVENT, 0x19880902);
		g_comval->magic     = MAGIC_COMVAL;
		// no need save data
		//NVRAMWrite(g_comval, VM_SYSTEM,sizeof(g_comval));
		
		//g_test_mode = 1;
	}
	
	if(!ReadConfigData(&g_sysconfig, CFG_SYSTEM, sizeof(g_sysconfig)))
	{
		g_sysconfig.AppSupportFlag = AP_SUPPORT_RECORD | (AP_SUPPORT_FM * APP_SUPPORT_FM) | (AP_SUPPORT_FMREC * APP_SUPPORT_FM_RECORD) | (AP_SUPPORT_LCD * APP_SUPPORT_LCD) | (AP_SUPPORT_MENU * APP_SUPPORT_MENU) | (AP_SUPPORT_LED * APP_SUPPORT_LED);
	}
#if APP_SUPPORT_RGBLCD==1
	if(AP_Support_LCD() && !ReadConfigData(&g_displayconfig, CFG_DISPLAY, sizeof(g_displayconfig)))
	{
		g_displayconfig.lcd_heigth = 128;
		g_displayconfig.lcd_width = 160;
		//g_displayconfig.log_x = 0;
		//g_displayconfig.log_y = 8;
		//g_displayconfig.usb_x = 0;
		//g_displayconfig.usb_y = 16;
		
		g_displayconfig.big_num_width = 16;
		g_displayconfig.big_colon_width = 9;
		g_displayconfig.small_num_width = 6;
		g_displayconfig.small_colon_width = 4;
		
		//g_displayconfig.num_key_img = GUI_IMG_BIG_NUM;
		//g_displayconfig.num_key_x = 32;
		//g_displayconfig.num_key_y = 16;
		
		g_displayconfig.position_batt = POSITION_BATT;
		g_displayconfig.message_y = 48;
	}
#elif APP_SUPPORT_LCD==1
	if(AP_Support_LCD() && !ReadConfigData(&g_displayconfig, CFG_DISPLAY, sizeof(g_displayconfig)))
	{
		g_displayconfig.lcd_heigth = 64;
		g_displayconfig.lcd_width = 128;
		//g_displayconfig.log_x = 0;
		//g_displayconfig.log_y = 8;
		//g_displayconfig.usb_x = 0;
		//g_displayconfig.usb_y = 16;
	
		g_displayconfig.big_num_width = 16;
		g_displayconfig.big_colon_width = 9;
		g_displayconfig.small_num_width = 6;
		g_displayconfig.small_colon_width = 4;
	
		//g_displayconfig.num_key_img = GUI_IMG_BIG_NUM;
		//g_displayconfig.num_key_x = 32;
		//g_displayconfig.num_key_y = 16;
	
		g_displayconfig.position_batt = POSITION_BATT;
		g_displayconfig.message_y = 24;
	}
#endif
#if APP_SUPPORT_BLUETOOTH==1     /*Surport bt*/
	if(!ReadConfigData(&g_btconfig, CFG_BLUETOOTH, sizeof(g_btconfig)))
	{
		strcpy(g_btconfig.local_name, "RDA MP3 BT"); // bluetooth name
		strcpy(g_btconfig.password, "0000");         // bluetooth password
	}
#endif
	//SetBackLightColor(g_comval->BLightColor);        //设置背光颜色。
	
	SetBackLight(g_comval->BackLight);
	
	SetContrast(g_comval->DisplayContrast);           //设置屏幕的对比度
	
	MESSAGE_Initial(g_comval);
	
}
Example #15
0
TASK_ENTRY BAL_MainTaskEntry(void *pData)
{
	INT8   IsUDisk = 0;
	BOOL   need_draw = TRUE;
	INT32  active = 0;   //当前活动的项目
	INT32  result = APP_DEFAULT_RESULT;
	INT32  ret    = RESULT_NULL;
	INT32  bt_active_ret = RESULT_NULL;
	TM_SYSTEMTIME systime;
	extern BOOL g_usb_connected;
	
	// dump version and date
	//hal_HstSendEvent(SYS_EVENT,0x11223344);
	//hal_HstSendEvent(SYS_EVENT,GetPlatformVersion());
	//hal_HstSendEvent(SYS_EVENT,GetPlatformRevision());
	//hal_HstSendEvent(SYS_EVENT,GetPlatformBuildDate());
	//hal_HstSendEvent(SYS_EVENT,AP_GetVersion());
	//hal_HstSendEvent(SYS_EVENT,AP_GetBuildDate());
	
	APP_ReadComPara();	//读取系统的全局变量。可以放在os初始化的过程中做
#if XDL_APP_SUPPORT_LOWBAT_DETECT==1//warkey 2.1
	StartBatTimer();
#endif
	gui_load_resource(g_comval->langid);
	
	LED_SetPattern(GUI_LED_POWERON, 1);
	
#if APP_SUPPORT_LCD==1
	if(AP_Support_LCD())
	{
		lcdd_Open();
		GUI_Initialise(g_displayconfig.lcd_width, g_displayconfig.lcd_heigth);
		GUI_SetTextColor(g_displayconfig.font_color);
		GUI_SetBackColor(g_displayconfig.back_color);
	}
#endif
	
	if(g_test_mode)
	{
		NVRAMWriteData();
		APP_Test_Mode();
	}
	
	APP_DisplaySysLogo(FALSE);
	AP_GetBuildDate();//force link date time functions.
	
	// check systemtime
	TM_GetSystemTime(&systime);
	if(systime.uHour >= 24 || systime.uDay == 0 || systime.uYear > 2050) // invalid date time
	{
		systime.uYear = 2012;
		systime.uMonth = 8;
		systime.uDay = 15;
		systime.uHour = 12;
		systime.uMinute = 30;
		TM_SetSystemTime(&systime);
	}
#if APP_SUPPORT_LCD==1
	TIMER_SetAlarm(1);
#endif
	
	hal_HstSendEvent(SYS_EVENT, 0x09250001);
	
	APP_InitialFunPtr(); //初始化各个模块的回调函数,最后通过宏定义来实现开关
	
	APP_Read_Sys_Config();
	LED_SetPattern(GUI_LED_NONE, 1);
	
	hal_HstSendEvent(BOOT_EVENT, 0x09558000);
	
#if APP_SUPPORT_LCD==0  //added for T_card update without LCD. Search TF card, if there is a file with the name "tflash_update.bin", then do the update.
#ifdef MCD_TFCARD_SUPPORT
	{
		INT32 file = -1, card_ok = -1;
		UINT32 cur_data = AP_GetBuildDate();
		UINT32 cur_time = AP_GetBuildTime();
		boolean needupdate = FALSE;
		
		hal_HstSendEvent(BOOT_EVENT, 0x98880001);
		hal_HstSendEvent(BOOT_EVENT, cur_data);
		hal_HstSendEvent(BOOT_EVENT, cur_time);
		hal_HstSendEvent(BOOT_EVENT, 0x98880001);
		
		
		card_ok = FS_MountDevice(FS_DEV_TYPE_TFLASH);
		hal_HstSendEvent(BOOT_EVENT, card_ok);
		if(card_ok == ERR_SUCCESS)
		{
			FS_FILE_ATTR file_attr;
			TM_FILETIME sFileTime;
			TM_SYSTEMTIME sSysTm;
			UINT32 bin_createDate = 0;
			UINT32 bin_createTime = 0;
			UINT32 offset = 0;
			
			file = FS_Open(UPDATE_TFLASH_BIN_NAME, FS_O_RDWR, 0);
			
			hal_HstSendEvent(BOOT_EVENT, 0x09550000);
			hal_HstSendEvent(BOOT_EVENT, file);
			hal_HstSendEvent(BOOT_EVENT, 0x09550000);
			
#if 1
			FS_Seek(file, 0xc, FS_SEEK_SET);
			FS_Read(file, &offset, 4);
			FS_Seek(file, ((offset & 0x00ffffff)) - 0x10, FS_SEEK_SET);
			FS_Read(file, &bin_createDate, 4);
			FS_Read(file, &bin_createTime, 4);
			
			hal_HstSendEvent(BOOT_EVENT, 0x98880002);
			hal_HstSendEvent(BOOT_EVENT, bin_createDate);
			hal_HstSendEvent(BOOT_EVENT, bin_createTime);
			hal_HstSendEvent(BOOT_EVENT, 0x98880002);
#else
			if(FS_GetFileAttrByHandle(file, &file_attr) == 0)
			{
				sFileTime.DateTime = file_attr.i_mtime;
			
				TM_FileTimeToSystemTime(sFileTime, &sSysTm);
				bin_createDate = ((sSysTm.uYear) * 10000 + ((sSysTm.uMonth) * 100) + sSysTm.uDay);
				bin_createTime = sSysTm.uHour * 10000 + sSysTm.uMinute * 100 + sSysTm.uSecond;
			
				hal_HstSendEvent(BOOT_EVENT, 0x98880002);
				hal_HstSendEvent(BOOT_EVENT, bin_createDate);
				hal_HstSendEvent(BOOT_EVENT, bin_createTime);
				hal_HstSendEvent(BOOT_EVENT, 0x98880002);
			}
#endif
			
			//if((cur_data<bin_createDate) ||
			//(cur_data==bin_createDate && cur_time<bin_createTime))
			if((cur_data != bin_createDate) || (cur_time != bin_createTime)) //只要不是同一软件就允许升级
			{
				needupdate = TRUE;
			}
			
			hal_HstSendEvent(BOOT_EVENT, needupdate);
			hal_HstSendEvent(BOOT_EVENT, 0x98880008);
			
			if(file >= 0 && needupdate)
			{
				Upgrade_Flash(file);
				
				RestartSystem();
			}
			else
			{
				FS_Close(file);
			}
		}
	}
#endif
#endif
	
	
	g_last_reslt = result;
	if(GetUsbCableStatus())
	{
		hal_HstSendEvent(APP_EVENT, 0x13113001);
		result = RESULT_UDISK;
	}
	if(gpio_detect_linein() == GPIO_DETECTED)
	{
		hal_HstSendEvent(APP_EVENT, 0x13113002);
		result = RESULT_LINE_IN;
	}
	//    IsUDisk = g_comval->Onlinedev;
	
#ifdef SUPPORT_POWERON_ENTER_CHARGE_AP//warkey 2.1 
	app_trace(APP_MAIN_TRC, "GetBattery:%d", GetBattery());
	if(-1 == GetBattery() && g_usb_connected == 0)
	{
		//                  hal_HstSendEvent(SYS_EVENT, 0x13062707);
		hal_HstSendEvent(APP_EVENT, 0x13113003);
		result = Charging_Entry();
	}
#endif
	while(1)
	{
		if(result==RESULT_STANDBY)
		{
			LED_SetPattern(GUI_LED_NONE, 0xde);
		}
		else
		{
			LED_SetPattern(GUI_LED_NONE, 1);
		}
		
		hal_HstSendEvent(SYS_EVENT, 0x09250002);
		hal_HstSendEvent(SYS_EVENT, result);
		
		if(result == RESULT_NULL || result == RESULT_MAIN)
		{
#if APP_SUPPORT_MENU==1
			if(AP_Support_MENU())
			{
				ui_auto_select = FALSE;
				result = GUI_Display_Menu(GUI_MENU_MAIN, main_menu_callback);
				
				g_last_reslt        = RESULT_NULL;
				if(result == RESULT_TIMEOUT || result == RESULT_IGNORE || result == RESULT_NULL)
				{
					result = RESULT_IDLE; // RESULT_CALENDAR;
				}
			}
			else
#endif
			{
				if(RESULT_STANDBY != result)
				{
					result = g_last_reslt;
				}
				switch(result)
				{
				case RESULT_STANDBY:
					break;
				case RESULT_BT:
#if APP_SUPPORT_MUSIC==1
					result = RESULT_MUSIC;
					break;
				case RESULT_MUSIC:
#endif
#if APP_SUPPORT_FM || APP_SUPPORT_LINEIN
					//没有Line in时才进入FM 2012-9-27
					if(gpio_detect_linein() == GPIO_DETECTED)
					{
				#if APP_SUPPORT_LINEIN ==1	
						result = RESULT_LINE_IN;
						break;
				#else
						result = RESULT_RADIO;
						break;						
				#endif
					}
					else
					{
				#if APP_SUPPORT_FM==1
						result = RESULT_RADIO;
						break;
				#endif
					}
				case RESULT_LINE_IN:
				case RESULT_RADIO:
#endif
				
#if APP_SUPPORT_RECORD
					if(AP_Support_RECORD())
					{
						result = RESULT_RECORD_NOSTART;
						break;
					}
				case RESULT_RECORD_NOSTART:
#endif
#if APP_SUPPORT_BLUETOOTH
					result = RESULT_BT;
					break;
#endif
				default:
					result = APP_DEFAULT_RESULT;
					break;
				}
			}
		}
		else if(result == RESULT_POWERON)
		{
			if(AP_Support_LCD())
			{
				GUI_ClearScreen(NULL);
				GUI_UpdateScreen(NULL);
			}
			LED_SetPattern(GUI_LED_POWERON, 1);
			
			APP_DisplaySysLogo(TRUE);
			LED_SetPattern(GUI_LED_NONE, 1);
			
			if (g_comval->LightTime == 0)            //每次开机判断一次!解决Bug Report:27
			{
				CloseBacklight();
			}
			else
			{
				OpenBacklight();
			}
			
			//APP_DUMP("g_last_reslt:", g_last_reslt);
			
			result = g_last_reslt;
			if(GetUsbCableStatus())
			{
				hal_HstSendEvent(APP_EVENT, 0x07021549);
				result = RESULT_UDISK;
			}
			if(gpio_detect_linein() == GPIO_DETECTED)
			{
				hal_HstSendEvent(APP_EVENT, 0x07021550);
				result = RESULT_LINE_IN;
			}
			need_draw = TRUE;
		}
		else        //boot with param or result != 0
		{
			switch( result)
			{
#if APP_SUPPORT_MUSIC==1
			case RESULT_MUSIC:
				hal_HstSendEvent(SYS_EVENT, 0x20120000);
				ret = APP_ModCall(FUN_MUSIC, 0);
				g_last_reslt = result;
				result = ret;
#if APP_SUPPORT_FADE_INOUT==1
				if(g_fade_volume_backup != -1)
				{
					//                    hal_HstSendEvent(SYS_EVENT, 0x13101701);
					//                    hal_HstSendEvent(SYS_EVENT, g_fade_volume_backup);
					SetPAVolume(g_fade_volume_backup);
					g_fade_volume_backup = -1;
				}
#endif
				if(g_usb_audio_tcard&&GetUsbCableStatus())//plug in tcard when usb audio is running
				{
					result = RESULT_UDISK;
				}
				hal_HstSendEvent(SYS_EVENT, 0x20124444);
				hal_HstSendEvent(SYS_EVENT, g_last_reslt);
				hal_HstSendEvent(SYS_EVENT, result);
				break;
#endif
			case RESULT_RADIO:
				hal_HstSendEvent(SYS_EVENT, 0x20120033);
				ret = APP_ModCall(FUN_FM, 0);
				hal_HstSendEvent(SYS_EVENT, 0x20120044);
				g_last_reslt = result;
				result = ret;
				hal_HstSendEvent(SYS_EVENT, 0x20123001);
				break;
				
			case RESULT_RECORD_START:    //进入录音
			case RESULT_RECORD_NOSTART:
			case RESULT_FMREC_START:
			case RESULT_FMREC_NOSTART:
				ret = APP_ModCall(FUN_RECORD, result); //传入result,以判断是否直接开始FM录音?
				g_last_reslt = result;
				result = ret;
				break;
				
			case RESULT_RECORD_SWITCH:
				if(g_last_reslt == RESULT_RECORD_START || g_last_reslt == RESULT_RECORD_NOSTART)
				{
					result = RESULT_FMREC_NOSTART;
				}
				else if(g_last_reslt == RESULT_FMREC_START || g_last_reslt == RESULT_FMREC_NOSTART)
				{
					result = RESULT_RECORD_NOSTART;
				}
				ret = APP_ModCall(FUN_RECORD, result); //传入result,以判断是否直接开始FM录音?
				g_last_reslt = result;
				result = ret;
				break;
			case RESULT_CHARGING:
				result = APP_ModCall(FUN_CHARGING, 0);
				break;
			case RESULT_IDLE:
				//APP_DUMP("g_last_reslt:", g_last_reslt);
				result = APP_ModCall(FUN_IDLE, 0);
				break;
			case RESULT_LINE_IN:
				hal_HstSendEvent(SYS_EVENT, 0x20128888);
				
				if(event_detected_displaying_log == RESULT_LINE_IN)
				{
					event_detected_displaying_log = 0;
				}
				
				result = APP_ModCall(FUN_LINEIN, 0);
				hal_HstSendEvent(SYS_EVENT, 0x20129999);
				hal_HstSendEvent(SYS_EVENT, g_last_reslt);
				hal_HstSendEvent(SYS_EVENT, result);
				//                if(result == RESULT_NULL || result == RESULT_MAIN)
				if(g_linein_out_event == 1)//line-in was removed
				{
					result = g_last_reslt;
					if(result == RESULT_LINE_IN)
					{
						result = APP_DEFAULT_RESULT;
					}
					g_linein_out_event = 0;
					
					if(g_usb_audio_linein&&GetUsbCableStatus())//plug in line-in when usb audio is running, so return usb audio again
					{
						result = RESULT_UDISK;
						hal_HstSendEvent(SYS_EVENT, 0x13071801);
					}
				}
				else
				{
					g_last_reslt = RESULT_LINE_IN;
				}
				break;
			case RESULT_STANDBY:
				{
					extern UINT8 g_light_time;
			#ifdef SUPPORT_POWERON_ENTER_CHARGE_AP//warkey 2.1
					if(-1 == GetBattery())
					{
						result = Charging_Entry();
					}
					else
			#endif
					{
						g_light_time = 0;
						result = APP_StandBy();
						
						if(g_comval->LightTime != 0)
						{
							g_light_time   = g_comval->LightTime * 2;
							OpenBacklight();
						}
					}
				}
				break;
#if APP_SUPPORT_CALIB_KEY==1
			case RESULT_KEYCALIB:
				result = APP_CalibKey();
				break;
#endif
			case RESULT_SYSTEM:
				ret = APP_ModCall(FUN_SYSTEM_SETTING, 0);
				g_last_reslt = result;
				result = ret;
				break;
			case RESULT_ALARM:
				ret = APP_ModCall(FUN_TIMER, 1);
				g_last_reslt = result;
				result = ret;
				break;
			case RESULT_TIMER:
				ret = APP_ModCall(FUN_TIMER, 0);
				g_last_reslt = result;
				result = ret;
				break;
			case RESULT_UDISK:
				//IsUDisk=1;
				//if(IsUDisk)
				{
					if(g_usb_active_after_bt != 0)
					{
						g_usb_active_after_bt = 0;
					}
					
					if(event_detected_displaying_log == RESULT_UDISK)
					{
						event_detected_displaying_log = 0;
					}
					hal_HstSendEvent(SYS_EVENT, 0x09250003);
					result = APP_ModCall(FUN_USB, 0);
					hal_HstSendEvent(SYS_EVENT, 0x09250004);
				}
				if(result == RESULT_NULL)
				{
					result = g_last_reslt;
					if(result == RESULT_UDISK)
					{
						result = APP_DEFAULT_RESULT;
					}
				}
				if(result == RESULT_BT_ACTIVE)
				{
					bt_active_ret = RESULT_UDISK;
				}
				//fix udisk return, drop key up
				//result = RESULT_MUSIC;
				hal_HstSendEvent(SYS_EVENT, result);
				break;
#if APP_SUPPORT_BLUETOOTH==1
			case RESULT_BT:
				hal_HstSendEvent(SYS_EVENT, 0x20120001);
				ret = APP_ModCall(FUN_BT, -1);
				g_last_reslt = result;
				result = ret;
				if(musicplay_timer)
				{
					COS_KillTimer(musicplay_timer);
					musicplay_timer = 0;
				}
				hal_HstSendEvent(SYS_EVENT, 0x20127777);
				hal_HstSendEvent(SYS_EVENT, g_last_reslt);
				hal_HstSendEvent(SYS_EVENT, result);
				break;
			case RESULT_BT_ACTIVE:
				hal_HstSendEvent(SYS_EVENT, 0x20120002);
				if(bt_active_ret != RESULT_NULL)
				{
					result = APP_ModCall(FUN_BT, bt_active_ret);
				}
				else
				{
					result = APP_ModCall(FUN_BT, g_last_reslt);
				}
				//add by wuxiang
				call_status = 0;
				g_bt_call_time = 0;
				bt_active_ret = RESULT_NULL;
				if(musicplay_timer)
				{
					COS_KillTimer(musicplay_timer);
					musicplay_timer = 0;
				}
				//add end
				hal_HstSendEvent(SYS_EVENT, 0x20126666);
				if(g_last_reslt == RESULT_ALARM)
				{
					result = RESULT_IDLE;
				}
				break;
#endif
			case RESULT_CALENDAR:
				ret = APP_ModCall(FUN_CALENDAR, 0);
				g_last_reslt = result;
				result = ret;
				break;
				
			default:
				//APP_DUMP("never run here: ", result);
				hal_HstSendEvent(SYS_EVENT, 0x20125555);
				hal_HstSendEvent(SYS_EVENT, result);
				result = RESULT_MAIN;
				break;
			}//switch(reault)
			
			//APP_ReadComPara();
			//IsUDisk = 1;      //更新Onlinedev
			need_draw = TRUE;
		}
	}//while never exit
	
}
Example #16
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;
}
Example #17
0
/*********************************************************************************
* Description : 显示系统开机动画
*
* Arguments   : wait_key_up, 是否要等待按键
*
* Returns     : TRUE, 正常
        FALSE, enter testmode
*
* Notes       :
*
*********************************************************************************/
BOOL APP_DisplaySysLogo(BOOL wait_key_up)
{
	INT32 i, j;
	BOOL keydown = FALSE;
	UINT32 key;
	UINT32 prekey = 0;
	hal_HstSendEvent(SYS_EVENT, 0x19884501);
	hal_HstSendEvent(SYS_EVENT, g_displayconfig.log_image_time);
	hal_HstSendEvent(SYS_EVENT, g_displayconfig.log_image_count);
	if(g_displayconfig.log_image_count == 0 && g_displayconfig.log_image_time == 0)
	{
		for(i = 0; i < 1; i++)
			for(j = 0; j < 1;)
			{
				key = MESSAGE_Wait();
				//app_trace(APP_MAIN_TRC, "Display Log receive event 0x%x,prekey=0x%x, keydown=%d", key, prekey, keydown);
				switch(key)
				{
				case AP_MSG_RTC:
				case AP_MSG_CHARGING:
					j++;
					break;
				default:
					if((key & 0xffff) == AP_KEY_DOWN)
					{
						if(prekey != 0 || key != (AP_KEY_DOWN | AP_KEY_POWER))
						{
							keydown = TRUE;
						}
						prekey = key;
					}
					if(keydown && (key & 0xffff) == AP_KEY_UP)
					{
						return TRUE;
					}
					
					key = MESSAGE_HandleHotkey(key);//handle unusual usb/t-card/line-in pluging event
					if(key != 0)
					{
						event_detected_displaying_log = key;
						hal_HstSendEvent(SYS_EVENT, 0x13063002);
						hal_HstSendEvent(SYS_EVENT, key);
					}
					
					break;
				}
			}
	}
	
	for(i = 0; i < g_displayconfig.log_image_count; i++)
	{
#if APP_SUPPORT_RGBLCD==1
		if(AP_Support_LCD())
		{
			GUI_ClearScreen(NULL);//清全屏幕
			GUI_ResShowImage(GUI_IMG_LOGO, i, 0, 40); //g_displayconfig.log_x, g_displayconfig.log_y);/*BootLogo*/
			GUI_UpdateScreen(NULL);
		}
#elif APP_SUPPORT_LCD==1
		if(AP_Support_LCD())
		{
			GUI_ClearScreen(NULL);//清全屏幕
			GUI_ResShowImage(GUI_IMG_LOGO, i, 0, 8); //g_displayconfig.log_x, g_displayconfig.log_y);/*BootLogo*/
			GUI_UpdateScreen(NULL);
		}
#elif APP_SUPPORT_LED8S==1
		GUI_ClearScreen(NULL);
		GUI_ResShowPic(0xffff, 0, 0);
		GUI_DisplayText(0, 0, "8888");
		GUI_UpdateScreen(NULL);
#endif
		hal_HstSendEvent(SYS_EVENT, 0x19884500);
		hal_HstSendEvent(SYS_EVENT, g_displayconfig.log_image_time);
		for(j = 0; j < g_displayconfig.log_image_time; )
		{
			key = MESSAGE_Wait();
			//app_trace(APP_MAIN_TRC, "Display Log receive event 0x%x,prekey=0x%x, keydown=%d", key, prekey, keydown);
			switch(key)
			{
			case AP_MSG_RTC:
			case AP_MSG_CHARGING:
				j++;
				break;
			default:
				if((key & 0xffff) == AP_KEY_DOWN)
				{
					if(prekey != 0 || key != (AP_KEY_DOWN | AP_KEY_POWER))
					{
						keydown = TRUE;
					}
					prekey = key;
				}
				if(keydown && (key & 0xffff) == AP_KEY_UP)
				{
					return TRUE;
				}
				break;
			}
		}
	}
	
	return TRUE;
}
Example #18
0
// ============================================================================
// lcddp_FillRect16
// ----------------------------------------------------------------------------
/// This function performs a fill of the active window  with some color.
/// @param bgColor Color with which to fill the rectangle. It is a 16-bit
/// data, as the one of #lcddp_SetPixel16
/// @return #LCDD_ERR_NO, #LCDD_ERR_RESOURCE_BUSY or #LCDD_ERR_NOT_OPENED.
// ============================================================================
PRIVATE LCDD_ERR_T lcddp_FillRect16(CONST LCDD_ROI_T* regionOfInterrest, UINT16 bgColor)
{
    // Active window coordinates.
    HAL_GOUDA_WINDOW_T activeWin;
    hal_HstSendEvent(0x88855506);

    if (0 == lcdd_MutexGet())
    {    hal_HstSendEvent(0x88855507);

        return LCDD_ERR_RESOURCE_BUSY;
    }
    else
    {   
        if (g_lcddInSleep)
        {
            lcdd_MutexFree();
            return LCDD_ERR_NO;
        }
        hal_HstSendEvent(0x88855508);

        // Set Active window
        activeWin.tlPX = regionOfInterrest->x;
        activeWin.brPX = regionOfInterrest->x + regionOfInterrest->width - 1;
        activeWin.tlPY = regionOfInterrest->y;
        activeWin.brPY = regionOfInterrest->y + regionOfInterrest->height - 1;

        // Check parameters
        // ROI must be within the screen boundary
        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)
        {
            lcdd_MutexFree();               
            return LCDD_ERR_INVALID_PARAMETER;
        }

       // hal_GoudaSetBgColor(bgColor);
        lcddp_BlitRoi2Win(&activeWin,&activeWin,bgColor);

        return LCDD_ERR_NO;
    }
}
Example #19
0
// =============================================================================
// memd_FlashErase
// -----------------------------------------------------------------------------
/// This function erases contiguous flash sectors. 
/// Addresses <B> must be aligned on sectors</B>:
/// - The \c startFlashAddress is the address of the first sector to erase.
/// - The \c endFlashAddress is the address of the first sector NOT to erase.
///   If \c endFlashAddress is \c NULL, only one sector will be erased.
/// .
/// Care must be taken not to erase the code present at the beginning of the flash.
///
/// @param start_flashAddress The address of the first sector to erase
/// @param end_flashAddress The address of the first sector NOT to erase.
///   If \c NULL, only one sector will be erased 
/// @return #MEMD_ERR_NO, #MEMD_ERR_ERASE, #MEMD_ERR_ALIGN or #MEMD_ERR_PROTECT
/// whether the operation succeeded or failed
///
// =============================================================================
PUBLIC MEMD_ERR_T memd_FlashErase(UINT8 *startFlashAddress, UINT8 *endFlashAddress)
{
    UINT8 rdstatus, rdstatus_old;
    UINT32 status;
    VOLATILE UINT8 * ptr;
    VOLATILE UINT16 *flashaddr;
    UINT32 Start, End;
    UINT32 phys_end_add, phys_start_add;

    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");
    hal_HstSendEvent(0x654300); hal_HstSendEvent(phys_start_add); hal_HstSendEvent(0x654301); 
    // 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_HstSendEvent(0x654311); 
    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();
        // Sector Erase command
        *(flashaddr+0x555) = 0xaa;
        *(flashaddr+0x2aa) = 0x55;
        *(flashaddr+0x555) = 0x80;
        *(flashaddr+0x555) = 0xaa;
        *(flashaddr+0x2aa) = 0x55;
        *(ptr) = 0x30;
        hal_SysExitCriticalSection(status);

        // note the pooling could be done on data == 0xff also
    
        // pooling
        rdstatus = (*ptr);
        while(1){
            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(0x654399);
    return MEMD_ERR_NO;
}
Example #20
0
// =============================================================================
// memd_FlashWrite
// -----------------------------------------------------------------------------
/// This function writes data in the flash. It gets its data from \c buffer, copies 
/// \c byteSize bytes to the flash location designed by \c flashAddress. \c 
/// pWrittenbyteSize is filled with the actual number of written bytes (Equal 
/// to size, or less in case of error).
/// 
/// @param  flashAddress The byte offset within the flash chip. (Take care not 
/// to overwrite the code present at the beginning of the flash)
/// @param  byteSize Number of bytes to write in flash
/// @param  pWrittenbyteSize Number of bytes actually written in flash
/// @param  buffer Buffer where to get the data to write in the flash
/// @return #MEMD_ERR_NO, #MEMD_ERR_WRITE or #MEMD_ERR_PROTECT
/// whether the operation succeeded or failed.
// =============================================================================
PUBLIC MEMD_ERR_T memd_FlashWrite(UINT8 *flashAddress,
        UINT32 byteSize, 
        UINT32 * pWrittenbyteSize, 
        CONST UINT8* buffer)
{
    VOLATILE UINT16 * flashaddr;
    VOLATILE UINT16 * ptr;
    UINT16 rdstatus, data;
    UINT32 bsize=0, wsize=0, owsize=0;
    MEMD_ERR_T errorcode=MEMD_ERR_NO;
    UINT32 status;
    UINT32 phys_add;


    *pWrittenbyteSize=0;
    if (byteSize==0)
    {
        return MEMD_ERR_NO;
    }

    hal_EbcFlashWriteEnable(TRUE);

    phys_add = (UINT32)flashAddress;
    hal_HstSendEvent(0x555500);
    hal_HstSendEvent(phys_add); 
    
    MEMD_ASSERT((phys_add & 0xe0000000) == 0,
        "flash_address is expected to be a byte offset within the flash chip, not an absolute adresse")

    flashaddr = (VOLATILE UINT16 *)(g_memdFlashBaseAddress + (phys_add&FLASHBANK_MASK));

    if (!g_memdDybOverride)
    {
        ptr = (VOLATILE UINT16 *)(g_memdFlashBaseAddress + (phys_add&~0xfff));
        if (memd_DYBCheck(flashaddr, (UINT16*)ptr))
        {
            hal_EbcFlashWriteEnable(FALSE);
            return MEMD_ERR_PROTECT;
        }
    }

    ptr = (VOLATILE UINT16 *)(g_memdFlashBaseAddress + (phys_add&~1));

    // Unlock Bypass Entry
    status = hal_SysEnterCriticalSection();
    *(flashaddr+0x555) = 0xaa;
    *(flashaddr+0x2aa) = 0x55;
    *(flashaddr+0x555) = 0x20;
    hal_SysExitCriticalSection(status);

    if ((phys_add&1) == 1)
    {
        data = *(ptr);
    } else {
        data = (*buffer) | ~0x00ff;
        buffer ++;
        bsize ++;
    }
    if (bsize<byteSize)
    {
        data = data & (((*buffer) << 8) | 0x00ff);
        buffer ++;
        bsize ++;
    }

    if (bsize==byteSize)
    {
        // last byte
        data = data & *(ptr);
    }
    // first byte is prepared
    /* 16b data ready write it to flash*/
    status = hal_SysEnterCriticalSection();
    *(flashaddr) = 0xa0;
    *(ptr)=data;
    hal_SysExitCriticalSection(status);

    while(bsize<byteSize) {
        UINT16 tdata;
        VOLATILE UINT16 * tptr;

        // do the next data preparation before the pooling so we are ready to do a new programming just after pooling is OK.
        tdata = data;
        tptr = ptr;

        owsize = wsize;

        wsize = bsize;
        ptr+=1;


        if (bsize<byteSize) {
            data = (*buffer) | ~0x00ff;
            buffer ++;
            bsize ++;
        }
        if(bsize<byteSize) {
            data = data & (((*buffer) << 8) | 0x00ff);
            buffer ++;
            bsize ++;
        }

        // pooling
        while(1)
        {
            rdstatus = (*tptr);
            // DQ7 = prog value ? ok done
            if (((rdstatus ^ tdata) & 0x80) == 0)
                break;
            // DQ5 = 1
            if ((rdstatus & 0x20) == 0x20)
            {
                rdstatus = (*tptr);
                // DQ7 = prog value ? ok done
                if (((rdstatus ^ tdata) & 0x80) == 0)
                    break;
                errorcode=MEMD_ERR_WRITE;
                break;
            }
        }
        if (errorcode!=MEMD_ERR_NO) break;
        if(bsize==byteSize) {
            /* last byte */
            data = data & *(ptr);
        }
        /* 16b data ready write it to flash*/
        status = hal_SysEnterCriticalSection();
        *(flashaddr) = 0xa0;
        *(ptr)=data;
        hal_SysExitCriticalSection(status);
    }
    if (errorcode!=MEMD_ERR_NO)
    {
        wsize = owsize;
    } else
    {
        // last data pooling
        while(1)
        {
            rdstatus = (*ptr);
            // DQ7 = prog value ? ok done
            if (((rdstatus ^ data) & 0x80) == 0)
                break;
            // DQ5 = 1
            if ((rdstatus & 0x20) == 0x20)
            {
                rdstatus = (*ptr);
                // DQ7 = prog value ? ok done
                if (((rdstatus ^ data) & 0x80) == 0)
                    break;
                errorcode=MEMD_ERR_WRITE;
                break;
            }
        }
        wsize = bsize;
    }
    
    *pWrittenbyteSize = wsize;
    // Unlock Bypass Exit
    status = hal_SysEnterCriticalSection();
    *(flashaddr) = 0x90;
    *(flashaddr) = 0x00;
    hal_SysExitCriticalSection(status);

    hal_EbcFlashWriteEnable(FALSE);
    hal_HstSendEvent(0x555504);
    return errorcode;
}
Example #21
0
PUBLIC MEMD_ERR_T memd_FlashWrite(UINT8 *flashAddress,
        UINT32 byteSize, 
        UINT32 * pWrittenbyteSize, 
        CONST UINT8* buffer)
{
    VOLATILE UINT16 * BankAddr;
    VOLATILE UINT16 * ptr;
    UINT16 data;
    UINT32 bsize=0;
    UINT32 wsize=0;
    UINT32 owsize=0;
    MEMD_ERR_T errorcode=MEMD_ERR_NO;
    UINT32 status;
    UINT32 phys_add;
    UINT32 phy_SectAddr;
    UINT32 phy_End;
    BOOL isLocked;
    UINT16 rdstatus;
hal_HstSendEvent(0x5477);

    *pWrittenbyteSize=0;
    if (byteSize==0)
    {
        return MEMD_ERR_NO;
    }

    hal_EbcFlashWriteEnable(TRUE);

    phys_add = (UINT32)flashAddress;
    MEMD_ASSERT((phys_add & 0xe0000000) == 0,
        "flash_address is expected to be a byte offset within the flash chip, not an absolute address")

    memd_FlashGetSectorLimits((UINT32)flashAddress, &phy_SectAddr, &phy_End);
    BankAddr = (VOLATILE UINT16 *)(g_memdFlashBaseAddress + (phys_add&FLASHBANK_MASK));
    ptr = (VOLATILE UINT16 *)(g_memdFlashBaseAddress + (phys_add&~1));

    // Unlock block
    memd_FlashGetLockStatus((UINT8*)((UINT32)phy_SectAddr & MY_MASK),&isLocked);
	hal_EbcFlashWriteEnable(TRUE);
    if(isLocked == TRUE)
        memd_BlockLock((UINT8*)((UINT32)phy_SectAddr & MY_MASK),NULL,FALSE);

    if ((phys_add&1) == 1)
    {
        data = *(ptr);
    } else {
        data = (*buffer) | ~0x00ff;
        buffer ++;
        bsize ++;
    }
    if (bsize<byteSize)
    {
        data = data & (((*buffer) << 8) | 0x00ff);
        buffer ++;
        bsize ++;
    }

    if (bsize==byteSize)
    {
        // last byte
        data = data & *(ptr);
    }
    // first byte is prepared
    /* 16b data ready write it to flash*/
    status = hal_SysEnterCriticalSection();
    *(BankAddr) = CMD_PROG;
    *(ptr)=data;
    hal_SysExitCriticalSection(status);

    while(bsize<byteSize) {
        UINT16 tdata;
        VOLATILE UINT16 * tptr;

        // do the next data preparation before the pooling so we are ready to do a new programming just after pooling is OK.
        tdata = data;
        tptr = ptr;

        owsize = wsize;

        wsize = bsize;
        ptr+=1;


        if (bsize<byteSize) {
            data = (*buffer) | ~0x00ff;
            buffer ++;
            bsize ++;
        }
        if(bsize<byteSize) {
            data = data & (((*buffer) << 8) | 0x00ff);
            buffer ++;
            bsize ++;
        }

        // pooling
        // 

	do{
           rdstatus = *BankAddr;
	}while((rdstatus & SR7) != SR7);
        
        // 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 & SR4) != 0)
        {
            // Some other programming error, should be decoded, but maybe do it later
            errorcode=MEMD_ERR_WRITE;
        }
        else if ((rdstatus & SR1) != 0)
        {
            errorcode=MEMD_ERR_PROTECT;
        }

        if (errorcode!=MEMD_ERR_NO) break;
        if(bsize==byteSize) {
            /* last byte */
            *BankAddr = CMD_READ_ARRAY;
            data = data & *(ptr);
        }
        /* 16b data ready write it to flash*/
        status = hal_SysEnterCriticalSection();
        *(BankAddr) = CMD_PROG;
        *(ptr)=data;
        hal_SysExitCriticalSection(status);
    }
    if (errorcode!=MEMD_ERR_NO)
    {
        wsize = owsize;
    } else
    {
    	// last data pooling
        do{
           rdstatus = *BankAddr;
	}while((rdstatus & SR7) != SR7);
     
        if ((rdstatus & SR4) != 0)
        {
            // Some other programming error, should be decoded, but maybe do it later
            errorcode=MEMD_ERR_WRITE;
        }
        else if ((rdstatus & SR1) != 0)
        {
            errorcode=MEMD_ERR_PROTECT;
        }

        wsize = bsize;
    }
		
    *pWrittenbyteSize = wsize;
  
    // return to Read Array mode
    status = hal_SysEnterCriticalSection();
    *BankAddr = CMD_READ_ARRAY;
    hal_SysExitCriticalSection(status);
       
    if(errorcode != MEMD_ERR_NO)
    {
    	status = hal_SysEnterCriticalSection();
        *BankAddr = CMD_CLR_STATUS_REG;          
        hal_SysExitCriticalSection(status);
    }

    hal_EbcFlashWriteEnable(FALSE);
    return errorcode;
}
Example #22
0
static void play_finished( void )
{
	hal_HstSendEvent(SYS_EVENT, 0x11111111);
	play_end = TRUE;
}
Example #23
0
File: mci.c Project: BarryChen/RDA
UINT32 MCI_AudioPlay (INT32 OutputPath,HANDLE fileHandle, mci_type_enum fielType,MCI_AUDIO_PLAY_CALLBACK_T callback,INT32 PlayProgress)   //  MCI_MEDIA_PLAY_REQ,         
{
	INT32 result=MCI_ERR_NO;
	diag_printf( "***********OutputPath:%d*****file_name_p:%d, PlayProgress :%d ,fielType :%d ",OutputPath,fileHandle,PlayProgress,fielType);
	g_mciAudioFinishedCallback=callback;
    MCI_Play_Stream_Buffer = 0;
#ifdef BT_SUPPORT
        MCI_Play_BTStream = 0;
#endif    
    hal_HstSendEvent(SYS_EVENT, 0x20131203);
    csw_SetResourceActivity(CSW_LP_RESOURCE_AUDIO_PLAYER, CSW_SYS_FREQ_104M);

     audio_mode = fielType;

#ifdef VIDEO_PLAYER_SUPPORT
      if((audio_mode >=MCI_TYPE_3GP)&&(audio_mode <=MCI_TYPE_MJPG))
        {

          if(PlayProgress ==0)
            {
            result=  MCI_VideoOpenFile(2,2, fileHandle, 0, 0, fielType, MCI_vid_play_finish_ind,NULL);
			
	    if (result !=ISOM_ERR_OK)   
	    	{
	        result = MCI_VideoClose();
                 return MCI_ERR_ERROR;
	    	}
                  MCI_VideoPlay (0,0)  ;
            }
          else
            {
        	 INT16 img_width = 0;
        	 INT16 img_height = 0;
        	 INT32 totaltime = 0;

                UINT16  aud_channel;
                UINT16  aud_sample_rate;
                UINT16  track;
               UINT16  audio_type;
              INT64  current_Progress;
	            
              result=MCI_VideoOpenFile(2,2, fileHandle, 0, 0, fielType, MCI_vid_play_finish_ind,NULL);
               audio_type = MCI_VideoGetInfo(&img_width,&img_height, &totaltime,&aud_channel,&aud_sample_rate,& track);

              current_Progress= (((INT64)PlayProgress*(INT64)totaltime)/10000);
              
             MCI_VideoSeek (current_Progress, SEEK_TIME_MODE_ABSOLUTE, 0, 0) ; 
              MCI_VideoPlay (0,0)  ;
            }
             
        }
    else
#endif
	result = LILY_AudioPlay(OutputPath, fileHandle,fielType, PlayProgress);
    if (result != MCI_ERR_NO)
    {
        csw_SetResourceActivity(CSW_LP_RESOURCE_AUDIO_PLAYER, CSW_SYS_FREQ_32K);
    }

    return result;
}
Example #24
0
void APP_Test_Mode(void)
{
	UINT32 key;
	
	g_test_mode = TRUE;
	
	// test leds
	MESSAGE_Sleep(1);
	LED_SetPattern(GUI_LED_TEST_PATTERN1, 1);
	MESSAGE_Sleep(1);
	LED_SetPattern(GUI_LED_TEST_PATTERN2, 1);
	SetPAVolume(0);
	
	hal_HstSendEvent(BOOT_EVENT, 0x7e570100); // 10%
	
	// test lcd
#if APP_SUPPORT_RGBLCD==1
	if(AP_Support_LCD())
	{
		GUI_ClearScreen(NULL);
		GUI_InvertRegion(NULL);
		GUI_UpdateScreen(NULL);
		MESSAGE_Sleep(1);
		GUI_InvertRegion(NULL);
		GUI_UpdateScreen(NULL);
		MESSAGE_Sleep(1);
	}
#elif APP_SUPPORT_LCD==1
	if(AP_Support_LCD())
	{
		GUI_ClearScreen(NULL);
		GUI_InvertRegion(NULL);
		GUI_UpdateScreen(NULL);
		MESSAGE_Sleep(1);
		GUI_InvertRegion(NULL);
		GUI_UpdateScreen(NULL);
		MESSAGE_Sleep(1);
	}
#elif APP_SUPPORT_LED8S==1
	GUI_ClearScreen(NULL);
	GUI_ResShowPic(0xffff, 0, 0);
	GUI_UpdateScreen(NULL);
	COS_Sleep(200);
	GUI_DisplayText(0, 0, "8");
	GUI_UpdateScreen(NULL);
	COS_Sleep(200);
	GUI_DisplayText(1, 0, "8");
	GUI_UpdateScreen(NULL);
	COS_Sleep(200);
	GUI_DisplayText(2, 0, "8");
	GUI_UpdateScreen(NULL);
	COS_Sleep(200);
	GUI_DisplayText(3, 0, "8");
	GUI_UpdateScreen(NULL);
	COS_Sleep(200);
#endif
	
	hal_HstSendEvent(BOOT_EVENT, 0x7e570300); // 30%
	
	// test fm
#if APP_SUPPORT_FM
	hal_HstSendEvent(SYS_EVENT, 0x11220010);
	{
		extern FM_play_status_t    *FMStatus;
		FMStatus = (FM_play_status_t*)NVRAMGetData(VM_AP_RADIO, sizeof(FM_play_status_t));
		FM_SendCommand(MC_OPEN, 0);
		FMStatus->freq = AP_TEST_FM_FREQ1;
		FM_SendCommand(MC_PLAY, 0);
		if(!fmd_ValidStop(FMStatus->freq))
		{
			FMStatus->freq = AP_TEST_FM_FREQ2;
			if(!fmd_ValidStop(FMStatus->freq))
			{
				FMStatus->freq = AP_TEST_FM_FREQ3;
				if(!fmd_ValidStop(FMStatus->freq))
				{
					goto test_fail;
				}
			}
		}
		SetPAVolume(0);
		FM_SendCommand(MC_CLOSE, 0);
	}
#endif
	
	hal_HstSendEvent(BOOT_EVENT, 0x7e570500); // 50%
	
	// test bluetooth
#if APP_SUPPORT_BLUETOOTH==1
	hal_HstSendEvent(SYS_EVENT, 0x11220020);
	{
		extern bt_vars_t *g_pBT_vars;
		extern INT8 g_bt_cur_device;
		g_bt_cur_device = -1;
		g_pBT_vars = (bt_vars_t*)NVRAMGetData(VM_AP_BLUETOOTH, sizeof(bt_vars_t));
		if(BT_Active_Bluetooth() != 0)
		{
			goto test_fail;    // test_fail
		}
	}
#endif
	
	
	hal_HstSendEvent(BOOT_EVENT, 0x7e570800); // 80%
	// test audio
#if APP_SUPPORT_MUSIC==1
	{
		hal_HstSendEvent(SYS_EVENT, 0x11220030);
		if(!MountDisk(FS_DEV_TYPE_TFLASH))
		{
			goto test_fail;    // test_fail
		}
		
		hal_HstSendEvent(SYS_EVENT, 0x11220040);
		if(!fselInit(FSEL_TYPE_MUSIC, FSEL_ALL_SEQUENCE, FSEL_TYPE_COMMONDIR, FS_DEV_TYPE_TFLASH))
		{
			goto test_fail;    // test_fail
		}
		if(!fselGetNextFile(&g_testfile_entry))
		{
			goto test_fail;    // test_fail
		}
		hal_HstSendEvent(SYS_EVENT, 0x11220042);
		hal_HstSendEvent(SYS_EVENT, g_testfile_entry);
		g_current_fd = FS_OpenDirect(g_testfile_entry, FS_O_RDONLY, 0);
		hal_HstSendEvent(SYS_EVENT, g_current_fd);
		if(g_current_fd < 0)
		{
			goto test_fail;    // test_fail
		}
		
		hal_HstSendEvent(SYS_EVENT, 0x11220050);
		if(MCI_ERR_NO != MCI_AudioPlay(0, g_current_fd, MCI_TYPE_DAF, play_finished, 0))
		{
			goto test_fail;
		}
		SetPAVolume(0);
		play_end = FALSE;
		GUI_DisplayMessage(0, 0, "Test Sucess!", GUI_MSG_FLAG_DISPLAY);
		hal_HstSendEvent(SYS_EVENT, 0x11220060);
		hal_HstSendEvent(BOOT_EVENT, 0x7e570a00); // 100%
		hal_HstSendEvent(BOOT_EVENT, 0x7e5752cc); // test success
		LED_SetPattern(GUI_LED_TEST_SUCESS, LED_LOOP_INFINITE);
		
		while(1)
		{
			key =  MESSAGE_Wait();
			if(play_end)
			{
				play_end = FALSE;
				MCI_AudioStop();
				MCI_AudioPlay(0, g_current_fd, MCI_TYPE_DAF, play_finished, 0);
			}
#if 1//warkey //按任意键打开音量播放音乐,MODE键退出并重启
			if(key == (AP_KEY_MODE | AP_KEY_DOWN))
			{
				MCI_AudioStop();
				FS_Close(g_current_fd);
				RestartSystem();
			}
			else if(((key >> 16) > 0) && ((key >> 16) < MAX_KEYS))
			{
				if((key & 0xffff) == AP_KEY_DOWN)
				{
					SetPAVolume(7);
				}
				else if((key & 0xffff) == AP_KEY_UP)
				{
					SetPAVolume(0);
					
					g_test_mode = FALSE;
				}
			}
#else//原始
			if(key == (AP_KEY_PLAY | AP_KEY_DOWN))
			{
				SetPAVolume(7);
			}
			else if(key == (AP_KEY_PLAY | AP_KEY_UP))
			{
				SetPAVolume(0);
				hal_HstSendEvent(BOOT_EVENT, 0x7e5752cc); // test success
				g_test_mode = FALSE;
			}
			else if(key == (AP_KEY_MODE | AP_KEY_DOWN))
			{
				MCI_AudioStop();
				FS_Close(g_current_fd);
				RestartSystem();
			}
#endif
		};
	}
#else
	hal_HstSendEvent(BOOT_EVENT, 0x7e570a00); // 100%
	
	LED_SetPattern(GUI_LED_TEST_SUCESS, LED_LOOP_INFINITE);
	
	hal_HstSendEvent(BOOT_EVENT, 0x7e5752cc); // test success
	g_test_mode = FALSE;
	while(1)
	{
		key =  MESSAGE_Wait();
		if(key == (AP_KEY_MODE | AP_KEY_DOWN))
		{
			RestartSystem();
		}
		if(key == (AP_KEY_POWER | AP_KEY_DOWN))
		{
			DM_DeviceSwithOff();
		}
	};
#endif
	
test_fail:
	GUI_DisplayMessage(0, 0, "Test Fail!", GUI_MSG_FLAG_DISPLAY);
	LED_SetPattern(GUI_LED_TEST_FAIL, LED_LOOP_INFINITE);
	hal_HstSendEvent(BOOT_EVENT, 0x7e57fa11); // test fail
	g_test_mode = FALSE;
	
	while(1)
	{
		key =  MESSAGE_Wait();
		if(key == (AP_KEY_MODE | AP_KEY_DOWN))
		{
			RestartSystem();
		}
		if(key == (AP_KEY_POWER | AP_KEY_DOWN))
		{
			DM_DeviceSwithOff();
		}
	}
}
Example #25
0
// =============================================================================
// memd_FlashErase
// -----------------------------------------------------------------------------
/// This function erases contiguous flash sectors. 
/// Addresses <B> must be aligned on sectors</B>:
/// - The \c startFlashAddress is the address of the first sector to erase.
/// - The \c endFlashAddress is the address of the first sector NOT to erase.
///   If \c endFlashAddress is \c NULL, only one sector will be erased.
/// .
/// Care must be taken not to erase the code present at the beginning of the flash.
///
/// @param start_flashAddress The address of the first sector to erase.  Must
/// be a _physical_ address (byte offset from start of Flash)
/// @param end_flashAddress The address of the first sector NOT to erase.
///   If \c NULL, only one sector will be erased 
/// @return #MEMD_ERR_NO, #MEMD_ERR_ERASE, #MEMD_ERR_ALIGN or #MEMD_ERR_PROTECT
/// whether the operation succeeded or failed
///
// =============================================================================
PUBLIC MEMD_ERR_T memd_FlashErase(UINT8 *startFlashAddress, UINT8 *endFlashAddress)
{
    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;
hal_HstSendEvent(0x5555);

    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_BLOCK_ERASE_1;
        *(ptr) = CMD_BLOCK_ERASE_2;
        hal_SysExitCriticalSection(status);


        // pooling
        // Wait for Ready, then check status
        do{
             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;
        }
        else if ((rdstatus & SR5) != 0)
        {
            // Erase Error
            errorcode=MEMD_ERR_ERASE;
        }
        else if ((rdstatus & SR1) != 0)
        {
            errorcode=MEMD_ERR_PROTECT;
        }
        
        // 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;
}
Example #26
0
uint32 ScsiModeSense6(PSCSI_DEVICE pDevice, uint8 Lun)
{
	TRANSPORT_DATA    tData;
	TRANSPORT_COMMAND tCommand;
	uint8             bCDB[SCSI_CDB_6];
	uint8             bDataBlock[MAX_LIST_LENGTH] = {0}; // standard header + mode pages
	uint16            usPageLength = 8;                  // standard header size
	uint32             dwErr = ERROR_SUCCESS;

	ASSERT(SCSI_DEVICE_DIRECT_ACCESS == pDevice->DeviceType || SCSI_DEVICE_CDROM == pDevice->DeviceType);

	memset(bCDB, 0, sizeof(bCDB));
	tCommand.Flags = DATA_IN;
	tCommand.Timeout = pDevice->Timeouts.ScsiCommandTimeout;
	tCommand.Length = USBMSC_SUBCLASS_SCSI == pDevice->DiskSubClass ? SCSI_CDB_6 : UFI_CDB;
	tCommand.CommandBlock = bCDB;
	tCommand.dwLun = Lun;

	bCDB[0] = SCSI_MODE_SENSE6;
	bCDB[1] = ((Lun & 0x7) << 5);
	bCDB[2] = 0x3f;

	switch (pDevice->DeviceType)
	{
	case SCSI_DEVICE_DIRECT_ACCESS:
		if (pDevice->DiskSubClass == USBMSC_SUBCLASS_UFI) 
		{
			bCDB[2] = MODE_PAGE_FLEXIBLE_DISK;
			usPageLength += 32;
		}
		else 
		{
			usPageLength = sizeof(bDataBlock);
		}
		break;
	default:
		usPageLength = sizeof(bDataBlock);
		break;
	}
	usPageLength = 8;

	memset(bDataBlock, 0, sizeof(bDataBlock));

	// a device may fail this command if the header request length is only 8 bytes;
	// if this is the case, then the device should recover with extra buffer space

	tData.TransferLength = 0;
	tData.RequestLength = usPageLength;
	tData.DataBlock = bDataBlock;

	dwErr = UsbsDataTransfer(pDevice->hUsbTransport, &tCommand, &tData);

	if (dwErr != ERROR_SUCCESS || tData.TransferLength < 8 ) 
	{ // we want at least the header
		hal_HstSendEvent(SYS_EVENT,0x09090023);
		dwErr = ScsiGetSenseData(pDevice, Lun);
	}
	else 
	{
		hal_HstSendEvent(SYS_EVENT,0x09090020);
		pDevice->MediumType = bDataBlock[2];
		pDevice->Flags.WriteProtect = bDataBlock[3] & 0x80; // inspect WP bit
	}
	return dwErr;
}
Example #27
0
// The camera will be powered on in a particular mode specified here
// Later, when the video capture or image capture is 'prepared', the frame buffer size
// must correspond to the size here unless the format is changed.
PRIVATE void camerap_PowerOn(CAM_SIZE_T CamOutSize, UINT16 IspOutWidth, UINT16 IspOutHeight, CAM_FORMAT_T Format)
{
    // Turn on any power required for camera
    // Enable the Camera Interface Module
    // Turn on the Camera
    // Reset & initialize the Camera
    HAL_CAMERA_CFG_T CamConfig = {0,};
    HAL_CAMERA_IRQ_CAUSE_T mask = {0,0,0,0};
    UINT16 camOutWidth = 0, camOutHeight = 0;    
    
    if (CamOutSize == CAM_NPIX_VGA)
    {
        camOutWidth = 640;
        camOutHeight = 480;
    }
    else if (CamOutSize == CAM_NPIX_QVGA)
    {
        camOutWidth = 320;
        camOutHeight = 240;
    }
    else if (CamOutSize == CAM_NPIX_QQVGA)
    {
        camOutWidth = 160;
        camOutHeight = 120;    
    }
    else
    {
        SXS_TRACE(TSTDOUT,"DRV_CAM: Unsupported CAM Out Size");  
        return;
    }
    if ((camOutWidth < IspOutWidth) || (camOutHeight < IspOutHeight))
    {
        SXS_TRACE(TSTDOUT,"DRV_CAM: ISP out is larger than Cam Out");    
        return;
    }
    
    s_camOpened = FALSE;
#ifdef I2C_BASED_ON_GPIO
    gpio_i2c_open();
#else
    g_camdI2cBusId = tgt_GetCamdConfig()->i2cBusId;
    hal_I2cOpen(g_camdI2cBusId);
#endif
    CamConfig.rstActiveH = FALSE;
    CamConfig.pdnActiveH = TRUE;
    CamConfig.dropFrame = FALSE;
    CamConfig.camClkDiv = 10;
    CamConfig.endianess = NO_SWAP;
    CamConfig.camId = camera_GetCameraID();
    CamConfig.cropEnable = FALSE;
#if CAM_ISP_FUNC
    if ((camOutWidth > IspOutWidth) || (camOutHeight > IspOutHeight))
    {
        CamConfig.dstWinColStart = ((camOutWidth - IspOutWidth)/2)&0xFFF;
        CamConfig.dstWinColEnd = (CamConfig.dstWinColStart + IspOutWidth - 1)&0xFFF;
        CamConfig.dstWinRowStart = ((camOutHeight - IspOutHeight)/2)&0xFFF;
        CamConfig.dstWinRowEnd = (CamConfig.dstWinRowStart + IspOutHeight - 1)&0xFFF;        
        CamConfig.cropEnable = TRUE;
    }
    CamConfig.colRatio= COL_RATIO_1_1;
    CamConfig.rowRatio= ROW_RATIO_1_1;    
#else
    UINT32 ratioCol = camOutWidth / IspOutWidth;
    UINT32 ratioRow = camOutHeight / IspOutHeight;
    if ((ratioCol*IspOutWidth == camOutWidth) && (ratioRow*IspOutHeight == camOutHeight))
    {
        CamConfig.colRatio= ratioCol - 1;
        CamConfig.rowRatio= ratioRow - 1;
        if (ratioCol != 1 && ratioRow != 1)
        	CamConfig.reOrder = 4;
    }
    else
    {
        SXS_TRACE(TSTDOUT, "DRV_CAM: failed to set decimation, %d, %d, %d, %d", camOutWidth, IspOutWidth, camOutHeight, IspOutHeight);
        hal_HstSendEvent(0x20);
        return;        
    }
#endif

    // Enable Camera LDO
    pmd_EnablePower(PMD_POWER_CAMERA, TRUE); 
    hal_CameraOpen(&CamConfig);
    s_camOpened = TRUE;
    
    hal_CameraIrqSetMask(mask);
    hal_CameraPowerDown(FALSE);
    if (gSensorInfo.snrrst)
    {
        // Toggle the reset bit
    }
    else
    {
        // Just bring the sensor out of reset
       // hal_CameraReset(TRUE, FALSE);
         hal_CameraReset(FALSE);
    }

    // Should use FrameSize and Format to decide which sequence to use
    // FrameSize and Format may be changed later but the camera and IFC need
    // to be stopped and the IFC and camera re-enabled in the correct order
    // Power On seq
    // After this, the camera will start sending data to the camera module.  The IFC will
    // need to be started at the correct time (typically after the end of frame interrupt
    // so the data will be properly synchronized in the buffer
    if (CamOutSize == CAM_NPIX_VGA)
    {
        camerap_SendRgSeq(RG_InitPowerOnVga,  (sizeof(RG_InitPowerOnVga) / sizeof(CAM_REG_T)));
		SXS_TRACE(TSTDOUT,"hi704 CAM_NPIX_VGA");
    }
    else if(CamOutSize == CAM_NPIX_QVGA)
    {
        camerap_SendRgSeq(RG_InitPowerOnQvga,  (sizeof(RG_InitPowerOnQvga) / sizeof(CAM_REG_T)));
		SXS_TRACE(TSTDOUT,"hi704 CAM_NPIX_QVGA");
    }
    else
    {
	   camerap_SendRgSeq(RG_InitPowerOnQqvga,  (sizeof(RG_InitPowerOnQqvga) / sizeof(CAM_REG_T)));
              SXS_TRACE(TSTDOUT,"hi704 CAM_NPIX_QQVGA");
    }
#if 1	
	if(CamConfig.camId == 0)
	{
		camerap_WriteOneReg(0x03,0x00);
		camerap_WriteOneReg(0x11,0x94);	
		//camerap_WriteOneReg(0x03,0x02);
		//camerap_WriteOneReg(0x1a,0x21);
	}
        else
	{
		camerap_WriteOneReg(0x03,0x00);
		camerap_WriteOneReg(0x11,0x95);

		//camerap_WriteOneReg(0x03,0x02);
		//camerap_WriteOneReg(0x1a,0x31);
    }
#endif		

SXS_TRACE(TSTDOUT,"hi704 F/W Id is %x", CamConfig.camId);
    // Sensor Init seq
}
Example #28
0
uint32 GetMediumInfo(PSCSI_DEVICE pDevice, uint8 Lun)
{
	uint32 dwErr = ERROR_SUCCESS;

	do 
	{
		if (SCSI_DEVICE_UNKNOWN == pDevice->DeviceType || SCSI_MEDIUM_UNKNOWN == pDevice->MediumType ) 
		{
			dwErr = ScsiUnitAttention(pDevice, Lun);
			if (ERROR_SUCCESS != dwErr)
				break;
		}
			
		// determine device type
		if (SCSI_DEVICE_UNKNOWN == pDevice->DeviceType) 
		{
			hal_HstSendEvent(SYS_EVENT,0x08290012);
			dwErr = ScsiInquiry(pDevice, Lun);
			if (ERROR_SUCCESS != dwErr)
			{
				break;
			}	
		}

		// now that mode sense 6 and mode sense 10 is not mandatory, we don't execute this command
		/*
		if (SCSI_DEVICE_UNKNOWN != pDevice->DeviceType && SCSI_MEDIUM_UNKNOWN == pDevice->MediumType )
		{
			dwErr = ScsiModeSense6(pDevice, Lun);
			hal_HstSendEvent(SYS_EVENT,0x09060001);
			if (ERROR_SUCCESS != dwErr) 
			{
				TRANSPORT_DATA tData;
				uint8 senseData[18];

				tData.TransferLength = 0;
				tData.RequestLength = sizeof(senseData);
				tData.DataBlock = senseData;
				memset(senseData,0,sizeof(senseData));

				hal_HstSendEvent(SYS_EVENT,0x09060002);
				dwErr = ScsiRequestSense(pDevice, &tData, Lun);

				dwErr = ScsiModeSense10(pDevice, Lun);
				if (ERROR_SUCCESS != dwErr) 
				{
					break;
				}
			}
		}
		*/
		pDevice->Flags.MediumPresent = FALSE;
		// determine disk information
		if (!pDevice->Flags.MediumPresent) 
		{
			DISK_INFO di = {0};

			dwErr = ScsiReadCapacity(pDevice, &di, Lun);
			hal_HstSendEvent(SYS_EVENT,0x09090024);
			hal_HstSendEvent(SYS_EVENT,dwErr);
			if (ERROR_SUCCESS != dwErr)
			{	
				break;
			}	
		}

	} while (0);

	dwErr = ERROR_SUCCESS;

	return dwErr;
}
Example #29
0
//=============================================================================
// vpp_AudioJpegDecOpen function
//-----------------------------------------------------------------------------
HAL_ERR_T vpp_AudioJpegDecOpen(HAL_VOC_IRQ_HANDLER_T vocIrqHandler) 
{
    HAL_VOC_CFG_T cfg;
    vpp_AudioJpeg_DEC_IN_T * pDecIn;
    vpp_AudioJpeg_DEC_OUT_T *pDecStatus;
    INT32 * *pDMA;
    INT16 *pFilter;

    CALIB_BUFFER_T* calibPtr = tgt_GetCalibConfig();
	
   diag_printf("[vpp_AudioJpeg_DEC]Opening VPP AUDIO_DEC\n"); 

    if(calibPtr->aud.vocItfMap[audioItf]>=0)
        pFilter = &(calibPtr->aud.vocFilters[calibPtr->aud.vocItfMap[audioItf]].sdfFilter[0]);
    else
    {
        pFilter = mmc_MemMalloc(sizeof(CALIB_AUDIO_VOC_FILTERS_T));
        memset(pFilter, 0, sizeof(CALIB_AUDIO_VOC_FILTERS_T));
    }  
    cfg.vocCode              = G_VppCommonDecCode;
    cfg.vocCodeSize        = vpp_AudioJpeg_DEC_CODE_SIZE;
    cfg.pcVal                   = vpp_AudioJpeg_DEC_CODE_ENTRY;
    cfg.pcValCriticalSecMin  = vpp_AudioJpeg_DEC_CRITICAL_SECTION_MIN;
    cfg.pcValCriticalSecMax  = vpp_AudioJpeg_DEC_CRITICAL_SECTION_MAX;
    cfg.needOpenDoneIrq      = FALSE;
    cfg.irqMask.voc          = (vocIrqHandler) ? 1 : 0;
    cfg.irqMask.dmaVoc       = 0;
    cfg.vocIrqHandler        = vocIrqHandler;
    
    cfg.eventMask.wakeupIfc0 = 0;
    cfg.eventMask.wakeupIfc1 = 0;
    cfg.eventMask.wakeupDmae = 0;
    cfg.eventMask.wakeupDmai = 0;
    cfg.eventMask.wakeupSof0 = 0;
    cfg.eventMask.wakeupSof1 = 0;
    
    // load the VPP AUDIO_DEC  code and configure the VoC resource        
    switch (hal_VocOpen(&cfg))
    {
        // error opening the resource
        case HAL_ERR_RESOURCE_BUSY:                 
            diag_printf("[vpp_AudioJpeg_DEC]##WARNING##Error opening VoC resource\n"); 
            return HAL_ERR_RESOURCE_BUSY;
                                        
        // first open, load the constant tables                            
        case HAL_ERR_RESOURCE_RESET:              
            diag_printf("[vpp_AudioJpeg_DEC]First open.\n");			
            break;

        default:           
            diag_printf("[vpp_AudioJpeg_DEC]No first open.\n"); 
            break;
    }                          

   diag_printf("[vpp_AudioJpeg_DEC]Initializing the DMA addr.\n");
      //mp3
   	pDMA = hal_VocGetPointer(VPP_MP3_Code_ExternalAddr_addr);
	*pDMA=hal_VocGetDmaiPointer((INT32*)G_VppMp3DecCode,  HAL_VOC_DMA_READ,HAL_VOC_DMA_BURST,HAL_VOC_DMA_B2S_NO);
	pDMA=pDMA+1;
	*pDMA=hal_VocGetDmaiPointer((INT32*)G_VppMp3DecConstX,  HAL_VOC_DMA_READ,HAL_VOC_DMA_BURST,HAL_VOC_DMA_B2S_NO);
	pDMA=pDMA+1;
	*pDMA=hal_VocGetDmaiPointer((INT32*)G_VppMp3DecConstY,  HAL_VOC_DMA_READ,HAL_VOC_DMA_BURST,HAL_VOC_DMA_B2S_NO);
   *((INT32*)hal_VocGetPointer(VPP_AUDIO_MIXING_MP3_ADDR))=FALSE;
	//aac
	pDMA = hal_VocGetPointer(VPP_AAC_Code_ExternalAddr_addr);

	*pDMA=hal_VocGetDmaiPointer((INT32*)G_VppAacDecCode,  HAL_VOC_DMA_READ,HAL_VOC_DMA_BURST,HAL_VOC_DMA_B2S_NO);
	pDMA=pDMA+1;
	*pDMA=hal_VocGetDmaiPointer((INT32*)G_VppMp3Layer12Dec_DMA_ConstY,  HAL_VOC_DMA_READ,HAL_VOC_DMA_BURST,HAL_VOC_DMA_B2S_NO);	
	pDMA=pDMA+1;
	*pDMA=hal_VocGetDmaiPointer((INT32*)G_VppAacDecConstY,  HAL_VOC_DMA_READ,HAL_VOC_DMA_BURST,HAL_VOC_DMA_B2S_NO);

	//amr
	pDMA = hal_VocGetPointer(VPP_AMR_Code_ExternalAddr_addr);

	*pDMA=hal_VocGetDmaiPointer((INT32*)G_VppAmrDecCode,  HAL_VOC_DMA_READ,HAL_VOC_DMA_BURST,HAL_VOC_DMA_B2S_NO);
	pDMA=pDMA+1;
	*pDMA=hal_VocGetDmaiPointer((INT32*)G_VppMp3Dec_EQ_DMA_ConstY,  HAL_VOC_DMA_READ,HAL_VOC_DMA_BURST,HAL_VOC_DMA_B2S_NO);
	pDMA=pDMA+1;
	*pDMA=hal_VocGetDmaiPointer((INT32*)G_VppAmrDecConstY,  HAL_VOC_DMA_READ,HAL_VOC_DMA_BURST,HAL_VOC_DMA_B2S_NO);

#ifndef TARGET_AAC_SUPPORT_OFF
    pDMA= hal_VocGetPointer(VPP_AAC_Tab_huffTabSpec_START_addr);
	*pDMA=hal_VocGetDmaiPointer((INT32*)G_VppAacDecHuffTabSpec,  HAL_VOC_DMA_READ,HAL_VOC_DMA_BURST,HAL_VOC_DMA_B2S_NO);
	pDMA=pDMA+1;
	*pDMA=hal_VocGetDmaiPointer((INT32*)G_VppAacDecCos4sin4tab,  HAL_VOC_DMA_READ,HAL_VOC_DMA_BURST,HAL_VOC_DMA_B2S_NO);
	pDMA=pDMA+1;
	*pDMA=hal_VocGetDmaiPointer((INT32*)G_VppAacDecTwidTabOdd,  HAL_VOC_DMA_READ,HAL_VOC_DMA_BURST,HAL_VOC_DMA_B2S_NO);
	pDMA=pDMA+1;
	*pDMA=hal_VocGetDmaiPointer((INT32*)G_VppAacDecSinWindow,  HAL_VOC_DMA_READ,HAL_VOC_DMA_BURST,HAL_VOC_DMA_B2S_NO);
#endif

 *((INT16*)hal_VocGetPointer( VPP_GLOBAL_NON_CLIP_BUFFER_MP3_CLEAR_FLAG))=1;

#ifdef VIDEO_PLAYER_SUPPORT
	//jpeg
	pDMA = hal_VocGetPointer(VPP_JPEG_Code_ExternalAddr_addr);

	*pDMA=hal_VocGetDmaiPointer((INT32*)G_VppJpegDecCode,  HAL_VOC_DMA_READ,HAL_VOC_DMA_BURST,HAL_VOC_DMA_B2S_NO);
	pDMA=pDMA+1;
	*pDMA=hal_VocGetDmaiPointer((INT32*)G_VppJpegDecConstY,  HAL_VOC_DMA_READ,HAL_VOC_DMA_BURST,HAL_VOC_DMA_B2S_NO);


	
	pDMA = hal_VocGetPointer(VPP_AAC_Tab_huffTabSpec_START_addr);
	*pDMA=hal_VocGetDmaiPointer((INT32*)G_VppAacDecHuffTabSpec,  HAL_VOC_DMA_READ,HAL_VOC_DMA_BURST,HAL_VOC_DMA_B2S_NO);
	pDMA=pDMA+1;
	*pDMA=hal_VocGetDmaiPointer((INT32*)G_VppAacDecCos4sin4tab,  HAL_VOC_DMA_READ,HAL_VOC_DMA_BURST,HAL_VOC_DMA_B2S_NO);
	pDMA=pDMA+1;
	*pDMA=hal_VocGetDmaiPointer((INT32*)G_VppAacDecTwidTabOdd,  HAL_VOC_DMA_READ,HAL_VOC_DMA_BURST,HAL_VOC_DMA_B2S_NO);
	pDMA=pDMA+1;
	*pDMA=hal_VocGetDmaiPointer((INT32*)G_VppAacDecSinWindow,  HAL_VOC_DMA_READ,HAL_VOC_DMA_BURST,HAL_VOC_DMA_B2S_NO);

      //h263 zoom
	pDMA = hal_VocGetPointer(VPP_H263_Zoom_Code_ExternalAddr_addr);
     *pDMA=hal_VocGetDmaiPointer((INT32*)G_VppH263ZoomCode,  HAL_VOC_DMA_READ,HAL_VOC_DMA_BURST,HAL_VOC_DMA_B2S_NO);
	 pDMA=pDMA+1;
     *pDMA=hal_VocGetDmaiPointer((INT32*)G_VppH263ZoomConstX,  HAL_VOC_DMA_READ,HAL_VOC_DMA_BURST,HAL_VOC_DMA_B2S_NO);
#endif

#ifdef bt_support
       //sbc encode
	pDMA = hal_VocGetPointer(VPP_SBC_ENC_Code_ExternalAddr_addr);
     *pDMA=hal_VocGetDmaiPointer((INT32*)G_VppSBCCode,  HAL_VOC_DMA_READ,HAL_VOC_DMA_BURST,HAL_VOC_DMA_B2S_NO);
#endif

	pDMA = hal_VocGetPointer(VPP_Speak_AntiDistortion_Filter_Coef_addr);
   //  *pDMA=hal_VocGetDmaiPointer((INT32*)(&(calibPtr->bb->audio[4].vocFilters.sdfFilter[0])),  HAL_VOC_DMA_READ,HAL_VOC_DMA_BURST,HAL_VOC_DMA_B2S_NO);
    *pDMA=hal_VocGetDmaiPointer((INT32*)pFilter,  HAL_VOC_DMA_READ,HAL_VOC_DMA_BURST,HAL_VOC_DMA_B2S_NO);
     
	pDMA = hal_VocGetPointer(VPP_GLOBAL_NON_CLIP_HISTORYDATA_L_MP3_ADDR);

#ifdef SMALL_BSS_RAM_SIZE

	G_Mp3NonCliPLBuf_alloc                     = (UINT8*)mmc_MemMalloc_BssRam(G_Mp3NonCliPLBuf_Len+3);
	//G_Mp3NonCliPRBuf_alloc                     = (UINT8*)mmc_MemMalloc_BssRam(G_Mp3NonCliPRBuf_Len+3);
	G_Mp3NonCliPLBuf =(UINT32*) ((UINT32)(G_Mp3NonCliPLBuf_alloc +3) & ~0x3);
	//G_Mp3NonCliPRBuf =(UINT32*) ((UINT32)(G_Mp3NonCliPRBuf_alloc+3) & ~0x3);

	hal_HstSendEvent(SYS_EVENT,0xaccccccc);
	hal_HstSendEvent(SYS_EVENT,G_Mp3NonCliPLBuf_alloc);
	hal_HstSendEvent(SYS_EVENT,G_Mp3NonCliPLBuf);
	//hal_HstSendEvent(SYS_EVENT,G_Mp3NonCliPRBuf_alloc);
	//hal_HstSendEvent(SYS_EVENT,G_Mp3NonCliPRBuf);

#endif


     *pDMA=hal_VocGetDmaiPointer((INT32*)G_Mp3NonCliPLBuf,  HAL_VOC_DMA_READ,HAL_VOC_DMA_BURST,HAL_VOC_DMA_B2S_NO);
     
	//pDMA = hal_VocGetPointer(VPP_GLOBAL_NON_CLIP_HISTORYDATA_R_MP3_ADDR);
    // *pDMA=hal_VocGetDmaiPointer((INT32*)G_Mp3NonCliPRBuf,  HAL_VOC_DMA_READ,HAL_VOC_DMA_BURST,HAL_VOC_DMA_B2S_NO);
     
	pDMA = hal_VocGetPointer(VPP_GLOBAL_DIGITAL_GAIN_MP3_ADDR);

     *pDMA=(INT32 *)(((32767)<<16)|(0x10));

     for(INT32 i=0;i<30;i++)
     {
        //calibPtr->bb->audio[4].vocFilters.sdfFilter[32+i]=f_sbc_persition[i];
        pFilter[32+i]=f_sbc_persition[i];
     }

     for(INT32 i=0;i<288;i++)
     {
        G_Mp3NonCliPLBuf[i]=0;
           
     }

	pDecIn = hal_VocGetPointer(vpp_AudioJpeg_DEC_IN_STRUCT);
	pDecIn->reset=1;
	pDecIn->EQ_Type = -1;  	


    
	 pDecStatus = (vpp_AudioJpeg_DEC_OUT_T *)hal_VocGetPointer(vpp_AudioJpeg_DEC_OUT_STRUCT);
	 pDecStatus->ErrorStatus=0;
	 pDecStatus->mode=-1;//not 0~9;
 

    // move to STALL location (VoC irq generated)

      vpp_AudioJpegDecVocOpen_status=TRUE;

    return  hal_VocWakeup(HAL_VOC_START);
            
}
Example #30
0
// ============================================================================
// lcddp_BlitRoi2Win
// ----------------------------------------------------------------------------
// Private function to transfer data to the LCD
// ============================================================================
PRIVATE VOID lcddp_BlitRoi2Win(CONST HAL_GOUDA_WINDOW_T* pRoi, CONST HAL_GOUDA_WINDOW_T* pActiveWin, UINT16 bgColor)
{
    hal_HstSendEvent(0x88855509);
    HAL_GOUDA_LCD_CMD_T cmd[13];
    UINT32 j = 0,k =0;

    if(!((pRoi->tlPX < pRoi->brPX) && (pRoi->tlPY < pRoi->brPY)))
    {
        LCDD_TRACE(LCDD_WARN_TRC,0,"lcddp_BlitRoi2Win: Invalid Roi x:%d < %d, y:%d < %d",pRoi->tlPX, pRoi->brPX, pRoi->tlPY, pRoi->brPY);
        lcddp_GoudaBlitHandler();
        return;
    }

    // building set roi sequence:

#if 1
    if(g_lcddRotate)
    {
        //Window Horizontal RAM Address Start
        LCDD_BUILD_CMD_WR_REG(cmd,0,0x0050,pActiveWin->tlPY);
        //Window Horizontal RAM Address End
        LCDD_BUILD_CMD_WR_REG(cmd,2,0x0051,pActiveWin->brPY);
        //Window Vertical RAM Address Start
        LCDD_BUILD_CMD_WR_REG(cmd,4,0x0052,LCDD_DISP_Y-1-pActiveWin->brPX);
        //Window Vertical RAM Address End
        LCDD_BUILD_CMD_WR_REG(cmd,6,0x0053,LCDD_DISP_Y-1-pActiveWin->tlPX);

        //Start point
        LCDD_BUILD_CMD_WR_REG(cmd,8,0x0020,pActiveWin->tlPY);
        LCDD_BUILD_CMD_WR_REG(cmd,10,0x0021,LCDD_DISP_Y-1-pActiveWin->tlPX);
    }
    else
    {  hal_HstSendEvent(0x88855510);
        //Window Horizontal RAM Address Start
       // LCDD_BUILD_CMD_WR_REG(cmd,0,0x0050,pActiveWin->tlPX);
        WriteCommand_Addr(0x2a);WriteCommand_Data(0x00);WriteCommand_Data(pActiveWin->tlPX);
        WriteCommand_Data(0x00);WriteCommand_Data(pActiveWin->brPX);
        //Window Horizontal RAM Address End
       // LCDD_BUILD_CMD_WR_REG(cmd,2,0x0051,pActiveWin->brPX);
        //Window Vertical RAM Address Start
       // LCDD_BUILD_CMD_WR_REG(cmd,4,0x0052,pActiveWin->tlPY);
        //Window Vertical RAM Address End
       // LCDD_BUILD_CMD_WR_REG(cmd,6,0x0053,pActiveWin->brPY);
        WriteCommand_Addr(0x2b);WriteCommand_Data(0x00);WriteCommand_Data(pActiveWin->tlPY);
        WriteCommand_Data(0x00);WriteCommand_Data(pActiveWin->brPY);

        //Start point
      //  LCDD_BUILD_CMD_WR_REG(cmd,8,0x0020,pActiveWin->tlPX);
      //  LCDD_BUILD_CMD_WR_REG(cmd,10,0x0021,pActiveWin->tlPY);
    }
    k = ((pActiveWin->brPX-pActiveWin->tlPX)+1)*(1+(pActiveWin->brPY-pActiveWin->tlPY));
        hal_HstSendEvent(0x88855511);

    hal_HstSendEvent(k);

    // Send command after which the data we sent
    // are recognized as pixels.
     WriteCommand_Addr(0x2c);
     hal_GpioSet(g_slcd_a0);
  //   g_image[0]=0xf8 ;
 //    g_image[1]= 0x00;

     g_image[0]=(UINT8)((bgColor&0xff00)>>8);g_image[1]=(UINT8)(bgColor&0x00ff);   
     for( j =0; j<k; j++ ) 
     { 
      Write_Data_Image; // red 
     } 

      lcdd_MutexFree();
#else

    LCM_WR_REG(0x0050,pActiveWin->tlPX);//Window Horizontal RAM Address Start
    LCM_WR_REG(0x0051,pActiveWin->brPX);//Window Horizontal RAM Address End
    LCM_WR_REG(0x0052,pActiveWin->tlPY);//Window Vertical RAM Address Start
    LCM_WR_REG(0x0053,pActiveWin->brPY);//Window Vertical RAM Address End

    LCM_WR_REG(0x0020,pActiveWin->tlPX);
    LCM_WR_REG(0x0021,pActiveWin->tlPY);

    LCDD_BUILD_CMD_WR_CMD(cmd,0,0x0022);

    while(HAL_ERR_NO != hal_GoudaBlitRoi(pRoi, 1, cmd, lcddp_GoudaBlitHandler));
#endif
}