Exemple #1
0
///////////////////////////////////////////////////////////////////////////////////////////////////////////
//用户任务2
void task2(void)
{
	OS_ERR      err;
	unsigned int add=0;
	Time1_Config();//定时器1输出测试频率
	Time2_Config();//计时单元,用于测量频率
	Time3_Config();	//用于激发振弦	
	Time4_Config();//tim4 外部引脚做为外部时钟出发计数
	Nvic_Config();//优先级
	while(1)
	{
//			//TranPulse(15000,3);//发射10个500hz的脉冲 
//			if(IsPulseOn() == 1)//传感器是否起振
//				{TranPulse(Measure(),7);}//测量频率,并且输出到pwm

//		TranPulse(8000+add,10);
//		OSTimeDlyHMSM(0,0,0,10,OS_OPT_TIME_DLY,&err);
//		TranPulse(6000+add,10);
//		OSTimeDlyHMSM(0,0,0,10,OS_OPT_TIME_DLY,&err);
//		TranPulse(4000+add,10);
//		OSTimeDlyHMSM(0,0,0,10,OS_OPT_TIME_DLY,&err);
//		TranPulse(2400+add,10);
		GetFreq();
		//OSTimeDlyHMSM(0,0,1,0,OS_OPT_TIME_DLY,&err);
//		add += 200;
//		if(add == 2000)
//		{add = 0;}
	
		
	}
}
bool
libname::COggStreamSample::Load( const char *szFilename )
{

  vorbis_info * pInfo;
  if ( !m_pFile )
    m_pFile = fopen( szFilename, "rb");
  
  if( ov_open_callbacks( m_pFile , &m_OggFile, NULL, 0, OV_CALLBACKS_DEFAULT) < 0) 
  {
    cerr << "Input does not appear to be an Ogg bitstream." << endl;
    return false;
  }
  
  pInfo = ov_info(&m_OggFile,-1);

  SetNumChannels( pInfo->channels);  // number of channels
  SetFreq( pInfo->rate);             // The frequency of the sampling rate
  
  // Check the number of channels... always use 16-bit samples
  if (GetNumChannels() == 1)
    SetFormat( AL_FORMAT_MONO16 );
  else
    SetFormat( AL_FORMAT_STEREO16 );
  cerr << "Freq: "     << GetFreq() << endl;
  cerr << "Channels: " << GetNumChannels() << endl;
  cerr << "Encoded: "  << ov_comment(&m_OggFile,-1)->vendor << endl;
  
  m_lFileSize = ov_raw_total( &m_OggFile, -1);

  return true;
}
Exemple #3
0
void DspOscillator::_BuildLookup()
{
    float posFrac = _lookupLength <= 0 ? 0 : (float)_lastPos / (float)_lookupLength;
    float angleInc = TWOPI * GetFreq() / GetSampleRate();

    _lookupLength = (int)((float)GetSampleRate() / GetFreq());

    _signal.resize(GetBufferSize());
    _signalLookup.resize(_lookupLength);

    for (int i = 0; i < _lookupLength; i++)
    {
        _signalLookup[i] = sin(angleInc * i) * GetAmpl();
    }

    _lastPos = (int)(posFrac * (float)_lookupLength + 0.5f);  // calculate new position (round up)
}
Exemple #4
0
sU32 RangeCoder::DecodePlain(sU32 max)
{
  sU32 v;

  v = GetFreq(max);
  Decode(v,1);

  return v;
}
bool
libname::COggStreamSample::Stream( ALuint buffer )
{
  
  if ( !m_pFile ) return false;

  bool done = false;
  int current_section;
  long readBytes = 0;
  while( readBytes < BUFFER_SIZE )
  {
    long ret=ov_read(&m_OggFile, m_pBufferData+readBytes, BUFFER_SIZE-readBytes, 
		     OGG_LITTLE_ENDIAN, PCM_SAMPLE_16BIT, SIGNED_DATA, &current_section);
    
    if (ret == 0)  done=1;
    else if (ret < 0) 
    {     
      throw std::string( "error in stream");
    } 
    else 
    {
      readBytes+=ret;
    }
  }
  //cerr << "read from stream :" << readBytes << endl;
  // if there was no more data to be read, stop.
  

  if ( ov_raw_tell(&m_OggFile) >= m_lFileSize-1 )
  {
    m_bHasEnded = true;
  }

  if ( readBytes == 0 )
  { 
    return false;
  }

  // Upload sound data to buffer
  alBufferData( buffer, GetFormat(), m_pBufferData, readBytes, GetFreq());

  ALenum error = alGetError();
  if ( error != AL_NO_ERROR )
  {
    cerr << __FUNCTION__ << GetOpenALErrorString(error) << endl;
    return false;
  }
  return true;
}
Exemple #6
0
void task3(void)
{
	OS_ERR      err;
	BoardGPIOConfig();//IO口
	UsartConfig();//串口设置配置
	Nvic_Config();
	SW_12V(1);//电源
	SW_5V(1);//正负电源,用于检测回波Z
	FreqModuleInit();//测频率模块初始化
	GetFreq(1);

	while(1)
	{			
		
//		OSTimeDlyHMSM(0,0,500,0,OS_OPT_TIME_DLY,&err);
//		printf("SCT200T15002-Channel: 1  FREQUENCY:%f\r\n",GetFreq(1));
//		printf("SCT200T15002-Channel: 2  FREQUENCY:%f\r\n",GetFreq(2));
//		printf("SCT200T15002-Channel: 3  FREQUENCY:%f\r\n",GetFreq(3));
//		printf("SCT200T15002-Channel: 4  FREQUENCY:%f\r\n",GetFreq(4));
		OSTimeDlyHMSM(0,0,0,10,OS_OPT_TIME_DLY,&err);
		if(UploadFlag == 1)//确认需要上传数据了
		{
			
			FreqModuleInit();//测频率模块初始化
			GetFreq(1);
			printf("%s",aaa);
			printf("SCT200T15003-2015/7/8/Wednesday-15-36-9\r\n");
			printf("SCT200T15003-ID=0x87031923 53578748 66eff48\r\n");
			printf("SCT200T15003-Mode = 10 minutes Internal\r\n");
			printf("SCT200T15003-Current voltage = 10.90V\r\n");
			printf("SCT200T15003-Channel: 1  Temperature :34.47\r\n");
			printf("SCT200T15003-Channel: 2  Temperature :34.43\r\n");
			printf("SCT200T15003-Channel: 3  Temperature :30.40\r\n");
			printf("SCT200T15003-Channel: 4  Temperature :25.90\r\n");
			printf("SCT200T15003-Channel: 1  FREQUENCY:%f\r\n",GetFreq(1));
			printf("SCT200T15003-Channel: 2  FREQUENCY:%f\r\n",GetFreq(2));
			printf("SCT200T15003-Channel: 3  FREQUENCY:%f\r\n",GetFreq(3));
			printf("SCT200T15003-Channel: 4  FREQUENCY:%f\r\n",GetFreq(4));
			printf("%s",bbb);

			UploadFlag = 0;
			SW_12V(0);//电源
			SW_5V(0);//正负电源,用于检测回波
			OSTimeDlyHMSM(0,0,0,500,OS_OPT_TIME_DLY,&err);
			ConfigPINToListen();
			PWR_EnterSTOPMode(PWR_Regulator_ON,PWR_STOPEntry_WFI);
			SetClock();//配置各级CPU时钟
			BoardGPIOConfig();//IO口
			SW_12V(1);//电源
			SW_5V(1);//正负电源,用于检测回波
			OSTimeDlyHMSM(0,0,0,500,OS_OPT_TIME_DLY,&err);
			UsartConfig();//串口设置配置
			Nvic_Config();
		}
	}
}
Exemple #7
0
u64 Timer::GetTimeUs()
{
#ifdef _WIN32
  LARGE_INTEGER time;
  static double freq = GetFreq();
  QueryPerformanceCounter(&time);
  return u64(double(time.QuadPart) * freq);
#elif defined __APPLE__
  struct timeval t;
  (void)gettimeofday(&t, nullptr);
  return ((u64)(t.tv_sec * 1000000 + t.tv_usec));
#else
  struct timespec t;
  (void)clock_gettime(CLOCK_MONOTONIC, &t);
  return ((u64)(t.tv_sec * 1000000 + t.tv_nsec / 1000));
#endif
}
int WINAPI WinMain(HINSTANCE hInstance,      // handle to current instance
                   HINSTANCE hPrevInstance,  // handle to previous instance
                   LPWSTR lpCmdLine,          // pointer to command line
                   int nCmdShow)             // show state of window
{
    DWORD VerMaj, VerMin, Build;
    DWORD coreFreqMHz, coreFreq;
    MULTCFG mcfg;

    FRQTEGClocks tegClocks;
    DWORD dfsState;

    FRQGetLibVersion(&VerMaj, &VerMin, &Build);
    printf("FreqLibDemo Application. FreqLibVersion: %d.%d.%d\r\n", VerMaj, VerMin, Build);
    printf("**********************************************\r\n\r\n");

    if (GetSoCType() == PXA)
    {
        mcfg = GetFreq();

        CalcSystemFreq(mcfg, &coreFreq, NULL, NULL, NULL, NULL, NULL, NULL);

        printf("CPU running @ %dMHz\r\n", coreFreq / 1000000);

        printf("Enter new speed in MHz (104 - 806): ");
        scanf("%d", &coreFreqMHz);

        if (coreFreqMHz < 208)
        { // set to 104MHz
            mcfg.l = 8;
            mcfg.n = 1;
        }
        else if (coreFreqMHz < 416)
        { // set to 208MHz
            mcfg.l = 16;
            mcfg.n = 1;
        }
        else if (coreFreqMHz < 624)
        { // set to 416MHz
            mcfg.l = 16;
            mcfg.n = 2;
        }
        else if (coreFreqMHz < 806)
        { // set to 624MHz
            mcfg.l = 24;
            mcfg.n = 2;
        }
        else
        { // set to 806MHz
            mcfg.l = 31;
            mcfg.n = 2;
        }

        SetFreq(mcfg);

        printf("Changed CPU Speed to %dMHz\r\n\r\n", 13 * mcfg.l * mcfg.n);
    }
    else
    {
        FRQInit();
        
        // print intial clock frequencies
        Sleep(1000); // idle, will cause the system to throttle clocks down
        printf ("-- Initial Clock Frequencies --\r\n");
        FRQGetTEGClocks(&tegClocks);
        dfsState = FRQGetTEGDFSState();
        Tegra_PrintClocks(tegClocks, dfsState);
        
        // boost frequencies and print the new values
        printf ("\r\n-- Clock Frequencies With Boost Active --\r\n");
        TegFrq_Boost(busyHints, 4, TegDfsBusyHintSyncMode_Sync);
        Sleep(1000);    // idle, system clocks still remain at the boosted frequencies.
        FRQGetTEGClocks(&tegClocks);
        dfsState = FRQGetTEGDFSState();
        Tegra_PrintClocks(tegClocks, dfsState);

        // turn boosting off and print clocks again
        printf ("\r\n-- Clock Frequencies After Turning Boost Off --\r\n");
        TegFrq_Boost(busyHintsOff, 4, TegDfsBusyHintSyncMode_Sync);
        Sleep(1000); // Give the system some time to throttle down the clock
        FRQGetTEGClocks(&tegClocks);
        dfsState = FRQGetTEGDFSState();
        Tegra_PrintClocks(tegClocks, dfsState);


        FRQDeInit();
    }

    // done...
    printf("Press Enter to close.\r\n");
    getchar();
    return(TRUE);
}