亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? f360_cc1100.c

?? 使用C8051F360高速單片機加無線收發芯片CC1100實現的無線語音通信的源代碼
?? C
?? 第 1 頁 / 共 5 頁
字號:
// P1.3 - Audio Input
// P1.4 - Test Point
// P1.5 - LED1
// P1.6 - LED2
// P1.7 - Switch

void PORT_Init (void)
{

   P0SKIP  = 0xFF;                     // skip all port 0 pins
   P1SKIP = 0x08;                      // skip ADC input P1.3
   P1MDIN &= ~0x08;                    // set P0.0 to analog input
   P0MDOUT |= 0x4C;                    // set P0.2, P0.3, P0.6 to push-pull
   P1MDOUT |= 0x68;                    // Audio input, debug pins
   RouteSPI();                         // routes SPI pins to port pins
   XBR1   |= 0x40;                     // Enable crossbar, CEX0 at port pin
}

//-----------------------------------------------------------------------------
// SPI_Init
//-----------------------------------------------------------------------------
//
// Set SPI to master, CKPHA = 0, CKPOL = 1.  Set SPI to 3 wire mode, and
// enable SPI.  SPI0CKR = 11, SCLK = 24.5Mhz / 12 = 1.021 MHz.
//
void SPI_Init(void)
{
   SPI0CFG = 0x00;                     // Master disable, CKPOL = 0
   SPI0CN  = 0;                        // clear all flags
   IE |= 0x40;                         // enable SPI interrupts
   SPIEN = 0;                          // leave SPI disabled
   IP |= 0x40;                         // make SPI ISR high priority
}


//-----------------------------------------------------------------------------
// IDAC0_Init
//-----------------------------------------------------------------------------
//
// Configure IDAC to update with every Timer 3 overflow, using 2.0 mA
// full-scale output current.
//

void IDAC0_Init(void)
{
   IDA0CN &= ~0x70;                    // Clear Update Source Select Bits
   IDA0CN |=  0x30;                    // Set DAC to update on Tmr 3 Overflows
   IDA0CN |=  0x80;                    // Enable DAC

}


//
//-----------------------------------------------------------------------------
// PCA0_Init
//-----------------------------------------------------------------------------
//
// The PCA is used to watch for the edges of the Sync Word at the SPI MOSI pin.
// Module 0 is configured for edge-triggered captures, and count sysclocks.
// PCA interrupts are enabled.  Leaves PCA disabled.
//
void PCA0_Init(void)
{
   PCA0CPM0 = 0x42;                    // set PCA0 to edge-triggered capture
                                       // mode
   PCA0MD |= 4<<1;                     // Set PCA0 to count sys clocks
   CR = 1;                             // enable PCA0 timer
}

//----------------------------------------------------------------------------
// Timer2_Init
//----------------------------------------------------------------------------
//
// Timer 2 is used as the start of conversion clock source for the ADC,
// and controls the audio sampling rate.
//
void Timer2_Init(unsigned int counts)
{
   TMR2CN = 0x00;                      // resets Timer 2, sets to 16 bit mode
   CKCON |= 0x10;                      // use system clock
   TMR2RL = -counts;                   // Initial reload value
   TMR2 = -counts;                     // init timer
   ET2 = 0;                            // disable Timer 2 interrupts
   TR2 = 1;                            // start Timer 2
}



//-----------------------------------------------------------------------------
// Timer3_Init
//-----------------------------------------------------------------------------
//
// Configure Timer3 to auto-reload at interval specified by <counts>
// using SYSCLK as its time base.  Interrupts are enabled.  Timer 3 controls
// the DAC output rate.
//
void Timer3_Init(unsigned int counts)
{
   TMR3CN  = 0x00;                     // resets Timer 3, sets to 16 bit mode
   CKCON  |= 0x40;                     // use system clock
   TMR3RL  = -counts;                  // Initial reload value

   TMR3    = -counts;                  // init timer
   EIE1   |= 0x80;                     // enable Timer 3 interrupts
   TMR3CN  = 0x04;                     // start Timer 3
}


//-----------------------------------------------------------------------------
// Variables_Init
//-----------------------------------------------------------------------------
//
void Variables_Init(void)
{
   Audio_LocalState = Audio_Quiet;
   Audio_RemoteState = Audio_Quiet;

   CLEAR_FIFOS();
}


//-----------------------------------------------------------------------------
// Interrupt Service Routines
//-----------------------------------------------------------------------------

//-----------------------------------------------------------------------------
// ADC0_ISR
//-----------------------------------------------------------------------------
// This routine captures and saves an audio input sample, and then
// compares it to past samples to find out whether or not the audio
// stream is quiet.  The ISR also acts as a timer to measure the 250us
// delay when issuing an RX->TX or TX->RX command to the RF transceiver.
//

void ADC0_ISR(void) interrupt 10
{
   signed short SampleDifference;      // stores difference between current
                                       // and previous ADC0 values
   static short OldADCValue;           // previous ADC value
   static short NewADCValue;           // newest ADC value
   static unsigned short  AudioStateThreshold;
                                       // stores number of consecutive audio
                                       // bytes that have fallen outside
                                       // the defined threshold used to
                                       // determine if the audio state should
                                       // switch from "quiet" to "loud" or
                                       // "loud" to "quiet"
   static unsigned char TableIndex = 0;// index into sine table

   AD0INT = 0;                         // acknowledge end-of-conversion
                                       // interrupt

   OldADCValue = NewADCValue;          // save old ADC value
   NewADCValue = ADC0 - 512;           // add bias to new ADC value

   // if the button on AN147's PCB has been pressed, add a sine wave to the
   // the audio input signal
   if(!SW2)
   {
      TableIndex += 1;                 // increment sine table index value
      if(TableIndex >= 32) TableIndex = 0;
                                       // step through 16-element 1/2 period
                                       // sine table twice to produce a sine
                                       // wave's complete period

      // conditional adjusts the sine wave so that the first cycle
      // through the sine table produces the half of the period with values
      // higher than 0, and the second cycle produces values less than 0
      // Also, amplifies the sine wave by shifting the index value to the
      // left, which is equivalent to a gain of 2
      if(TableIndex < 16)
         NewADCValue += (unsigned char)(Audio_SineTable[TableIndex] << 1);
      else
         NewADCValue -= (unsigned char)(Audio_SineTable[TableIndex - 16]) << 1;
   }


   // This section of the ADC0 ISR determines whether the signal present at the
   // audio input should be considered "loud" or "quiet"
   SampleDifference = (signed)OldADCValue - (signed)NewADCValue;

   // measure whether difference between the current sample and the
   // last sample is greater than the threshold value <Audio_QuietThreshold>
   if( (SampleDifference > (signed)Audio_QuietThreshold) ||
      (SampleDifference < (-(signed)Audio_QuietThreshold)) )
   {
      if(Audio_LocalState == Audio_Quiet)
      {
         // add one to accumulator and check to see if
         // the critical accumulator value has been reached
         if(AudioStateThreshold++ == AudioStateQuietToLoud)
         {
            Audio_LocalState = Audio_Loud;
            AudioStateThreshold = 0;
         }
      }
      else if(Audio_LocalState == Audio_Loud)
      {
         // reset accumulator
         AudioStateThreshold = 0;
      }
   }

   // else <SampleDifference> is below the threshold value
   else
   {
      if(Audio_LocalState == Audio_Quiet)
      {
         if(AudioStateThreshold > 0)
         {
            AudioStateThreshold--;
         }
      }
      else if(Audio_LocalState == Audio_Loud)
      {
         // add one to accumulator and check to see if
         // the critical accumulator value has been reached
         if(AudioStateThreshold++ == AudioStateLoudToQuiet)
         {
            Audio_LocalState = Audio_Quiet;
            AudioStateThreshold = 0;
         }
      }
   }

   ADCRXFIFO_Push(NewADCValue);        // save ADC value for compression


}



//-----------------------------------------------------------------------------
// Timer3_ISR
//-----------------------------------------------------------------------------
// This ISR updates the DAC output at a rate of DACUPDATERATE.  It also
// fetches the most recently captured local ADC sample, attenuates the sample,
// and adds the signal to the DAC output for a loop back.
//

void TIMER3_ISR(void) interrupt 14
{
      static unsigned short new_value;
      USHORT tempvalue;
      TMR3CN &= ~0xC0;                 // acknowledge interrupt

      if (!DACTXFIFO_EMPTY)            // if new DAC data is available,
      {                                // update output information
         new_value = DACTXFIFO_Pull();

         // only play received audio if the remote endpoint as determined
         // that the audio is of audible amplitude
         if(Audio_RemoteState == Audio_Loud)
         {

            // DAC output must be left-justified, and loaded
            // low byte first
            tempvalue.S = new_value;
//            tempvalue.S = tempvalue.S + ADCRXFIFO_Newest()>>4;
            tempvalue.S = tempvalue.S << 6;

            IDA0L = tempvalue.C[1];
            IDA0H = tempvalue.C[0];

         }
      }

}

//-----------------------------------------------------------------------------
// PCA0_ISR
//-----------------------------------------------------------------------------
//
//  The PCA ISR is used to synchronize with the data stream from
//  the CC1100 along byte boundaries using the Sync Word 0xFFFFEE.
//  The PCA is set to interrupt on the falling edge of the DIO line.
//  When the interrupt gets requested, the PCA ISR will spin while it
//  looks for another rising edge.  Upon finding the second rising edge,
//  the PCA will disable itself, route SPI back to the port pins, and
//  enable the SPI interface.
//
void PCA0_ISR(void) interrupt 11
{


   if(CCF0)
   {
      // acknowledge interrupt
      CCF0 = 0;

      // wait until rising edge after first received '0' in Sync Word stream
      while(!DIO);
      _nop_();

      // wait until falling edge of second '0' in stream
      while(DIO);
      _nop_();

      // wait for rising edge in DCLK
      while(!DCLK);
      _nop_();

      // wait for falling edge
      while(DCLK);

      // route SPI back to port pins
      RouteSPI();

      EIE1 &= ~0x10;                   // Disable PCA0 interrupts
      PCA0CPM0 = 0x42;                 // set to 8-bit PWM output

      SPIF = 0;                        // clear pending interrupt flag
      SPIEN = 1;                       // re-enable SPI

   }
   else if(CCF1)
   {
   }
   else if(CCF2)
   {
   }

}


//-----------------------------------------------------------------------------
// SPI_ISR
//-----------------------------------------------------------------------------
//
//  SPI ISR contains the RF state machine.  An interrupt will be requested
//  after 8 bits of data have been shifted out to or in from the RF
//  transceiver.  Progress through the state machine is gated by byte counters
//  that increment once per interrupt servicing.
//
void SPI0_ISR(void) interrupt 6
{
   static unsigned char PreambleByte;  // counts Preamble bytes transmitted
   static unsigned char SyncWordByte;  // counts Sync Word bytes transmitted
   unsigned char SPI_Input;            // saves the received byte acquired
                                       // from SPI0DAT

   SPI_Input = SPI0DAT;

   // test for all SPI error conditions
   if(SPI0CN & 0x70)
   {
      SPI0CN &= ~0x70;                 // acknowledge error conditions, clear
                                       // flags
   }

   // bit is set inside RF state machine initialization routines
   if(RXTX_ResetVariables)
   {
      RXTX_ResetVariables = FALSE;     // clear flag
      RXTX_NoPreambleCount = 0;        // reset all counters
      PreambleByte = 0;
      SyncWordByte = 0;
   }

   if(SPIF)
   {
      SPIF = 0;                        // acknowledge interrupt

      switch(RXTX_StateMachine)
      {

         case(RX_SearchForMaster):

            // if received byte is Preamble, take appropriate action
            if((SPI0DAT == 0x55) || (SPI0DAT == 0xAA))
            {
               if(++PreambleByte == RX_MinBytesInitPreamble)
               {
                  RXTX_StateMachine = RX_SyncWord;

                  // timer will synchronize with master's at the end
                  // of the first received data packet
                  SPI_TimerEnable = TRUE;
                  SPI_Timer = SPI_SlopTimeOut + TX_NumBytesPreamble;

                  RXTX_MasterSelect = RXTX_Slave;

                  // reset counter
                  PreambleByte = 0;
               }
            }
            else // received byte was not Preamble
            {
               // reset counter
               PreambleByte = 0;
            }

         break;

         case(RX_Preamble):
         {

            if(!SPI_TimeOutEvent)
            {
               // of byte received is Preamble, increment counter
               if((SPI0DAT == 0x55) || (SPI0DAT == 0xAA))

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩视频在线一区二区| 亚洲欧洲成人自拍| 亚洲国产精品国自产拍av| 亚洲成av人综合在线观看| 成人av在线播放网站| 欧美一区二区成人| 亚洲一区二区三区中文字幕| 成人av资源站| 久久久影视传媒| 全部av―极品视觉盛宴亚洲| 欧美午夜免费电影| 亚洲视频图片小说| 成人app下载| 中文字幕第一区二区| 韩国欧美国产1区| 91精品国产全国免费观看| 一区二区三区在线观看国产 | www.在线成人| 日韩欧美成人一区| 丝袜美腿成人在线| 欧美日韩国产精品自在自线| 亚洲精品日日夜夜| 91视频免费观看| 亚洲人成网站在线| 色婷婷国产精品久久包臀| 中文字幕亚洲电影| 91麻豆国产精品久久| 亚洲欧美国产77777| 91蜜桃免费观看视频| 亚洲人午夜精品天堂一二香蕉| 成人看片黄a免费看在线| 日本一区二区不卡视频| 菠萝蜜视频在线观看一区| 亚洲国产电影在线观看| 本田岬高潮一区二区三区| 亚洲欧美激情在线| 欧美在线一区二区三区| 午夜a成v人精品| 欧美一区二区在线看| 精品写真视频在线观看| 久久久91精品国产一区二区精品| 国产乱对白刺激视频不卡| 国产欧美日韩在线观看| 99久久精品免费看国产| 亚洲激情图片一区| 8x福利精品第一导航| 久久国产精品99精品国产| 久久久一区二区| 97精品电影院| 亚洲1区2区3区视频| 欧美成人乱码一区二区三区| 国产成人午夜视频| 一区二区三区国产| 日韩午夜激情av| 成人在线视频一区| 亚洲成av人片在www色猫咪| 日韩欧美不卡一区| 不卡一区二区中文字幕| 亚洲国产wwwccc36天堂| 精品三级av在线| eeuss鲁片一区二区三区在线看| 亚洲蜜臀av乱码久久精品| 在线不卡欧美精品一区二区三区| 精品一区二区三区久久| 亚洲欧美日韩小说| 日韩欧美在线不卡| 成人国产精品免费观看动漫| 亚洲成人精品影院| 久久精品水蜜桃av综合天堂| 日本韩国欧美一区| 国产乱一区二区| 亚洲综合男人的天堂| 精品国产露脸精彩对白| 一本久道中文字幕精品亚洲嫩| 男女激情视频一区| 曰韩精品一区二区| 久久久美女毛片| 欧美精品v国产精品v日韩精品| 国产丶欧美丶日本不卡视频| 婷婷综合在线观看| 亚洲丝袜精品丝袜在线| 久久久久国产精品麻豆| 在线综合+亚洲+欧美中文字幕| 99这里只有精品| 国内精品免费在线观看| 丝袜美腿高跟呻吟高潮一区| 亚洲视频一区在线| 国产欧美一区二区三区沐欲| 欧美一二三区精品| 精品污污网站免费看| 91蝌蚪国产九色| 成人免费视频视频| 国产一区二区电影| 麻豆成人av在线| 免费成人在线观看视频| 午夜视频一区二区| 亚洲亚洲精品在线观看| 亚洲免费伊人电影| 综合久久久久久| 国产精品不卡一区二区三区| 久久久久久久性| 久久久久综合网| 国产人妖乱国产精品人妖| 欧美一区二区私人影院日本| 91成人免费在线视频| 成年人午夜久久久| 99re亚洲国产精品| 99久久久久久| 91影院在线观看| www.日韩精品| 97精品国产97久久久久久久久久久久| 国产成人精品亚洲日本在线桃色| 国产一二三精品| 丁香婷婷综合色啪| 99久久精品国产导航| 99久久精品国产麻豆演员表| 99久久精品情趣| 在线免费一区三区| 欧美三区免费完整视频在线观看| 欧美无砖专区一中文字| 欧美三级日韩三级| 欧美精品v国产精品v日韩精品| 91精品国产综合久久香蕉麻豆| 9191久久久久久久久久久| 精品嫩草影院久久| 久久久久久电影| 亚洲精品国产品国语在线app| 亚洲制服丝袜av| 日韩极品在线观看| 国产盗摄一区二区| 91香蕉视频mp4| 欧美精选一区二区| 久久综合色鬼综合色| 国产精品福利一区| 调教+趴+乳夹+国产+精品| 久久电影网站中文字幕| 国产91精品免费| 欧美日韩在线免费视频| 日韩美女在线视频 | 欧美日韩在线播放| 日韩欧美国产一二三区| 国产亚洲一区二区三区在线观看| 国产精品久久久久永久免费观看 | 综合分类小说区另类春色亚洲小说欧美 | 欧美无乱码久久久免费午夜一区 | 欧美日韩精品一区二区三区 | 欧美精品一区二区三区在线| 欧美国产一区视频在线观看| 亚洲一线二线三线久久久| 蜜桃av噜噜一区| 91美女在线视频| 欧美v日韩v国产v| 亚洲日本在线观看| 久久av资源网| 色久综合一二码| 久久免费美女视频| 丝袜诱惑制服诱惑色一区在线观看| 激情小说欧美图片| 欧美三区免费完整视频在线观看| 国产农村妇女毛片精品久久麻豆 | 欧美日韩国产一区| 久久精品一区二区| 午夜久久久久久久久| 成人精品国产福利| 欧美一二三区在线观看| 亚洲综合在线视频| 国产不卡视频在线播放| 欧美一区二区性放荡片| 夜夜精品浪潮av一区二区三区| 国产一级精品在线| 日韩视频在线你懂得| 亚洲aaa精品| 色婷婷综合久久久久中文 | 亚洲国产三级在线| 成人avav影音| 国产亚洲综合色| 久久成人免费日本黄色| 欧美老年两性高潮| 亚洲女女做受ⅹxx高潮| 成人三级伦理片| 国产欧美日本一区视频| 久久99国产精品麻豆| 欧美精品久久久久久久多人混战| 一区二区三区在线观看网站| av一二三不卡影片| 国产精品―色哟哟| 国产精品影视网| 久久久久久久久久久电影| 黄色日韩三级电影| 精品国产一区二区三区av性色 | 亚洲男人的天堂网| 97se狠狠狠综合亚洲狠狠| 国产日韩欧美高清| 国产99精品国产| 国产精品美女久久久久高潮| 成人性生交大片| 成人免费视频在线观看| 97久久精品人人做人人爽| 亚洲久本草在线中文字幕| 一本色道久久综合亚洲精品按摩|