⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hal80110c.lst

📁 威望公司MP3 + USB MCU 的参考软件
💻 LST
字号:
C51 COMPILER V8.01   HAL80110C                                                             04/17/2008 09:55:00 PAGE 1   


C51 COMPILER V8.01, COMPILATION OF MODULE HAL80110C
OBJECT MODULE PLACED IN .\Debug\hal80110c.obj
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE fmtx\hal80110c.c LARGE OPTIMIZE(9,SIZE) REGFILE(.\Debug\VA4010_SDK_V2.ORC) 
                    -BROWSE NOINTPROMOTE INCDIR(.\common;.\e2prom;.\file;.\fmtx;.\ir;.\keyboard;.\lcm;.\led;.\main;.\matrixkey;.\mp3ctrl;.\sd
                    -;.\usbhost;.\include;.\lib) DEBUG OBJECTEXTEND PRINT(.\Debug\hal80110c.lst) OBJECT(.\Debug\hal80110c.obj)

line level    source

   1          
   2          #include "utiltypedef.h"
   3          #include "common.h"
   4          #include "hal80110c.h"
   5          /*
   6          The 80110C device is a low cost and low power stereo FM radio frequency transmitter
   7          IC for global FM radio band.
   8          
   9          Write Access Timing:
  10          1.      The state of the Data is changed at the falling edge of each clock.
  11          2.      8 data bits (D7~D0) are sent immediately after the 8 address bits (A7~A0) with the same timing.
  12                  The bit of 0 between A5 and A4 indicate a Write access.
  13          3.      En line is taken HIGH after the last data bit (D0) to indicate the arrival of the final data bit. Then
  14                  the CLK line pulses one more pulse and then is held at 0 for at least one cycle before a new
  15                  access is started. There for EN line is held HIGH for at least two cycles.
  16          
  17          Read Access Timing:
  18          1.      The bit of 1 between A5 and A4 indicate a Read access.
  19          2.      During a read access, the addressed device generates data on the Data to be read by the controlling de
             -vice.
  20          3.      Following the 8 address bits, there is a turn around bit which lasts for half a clock cycle as
  21                  depicted with black in the figure, has the effect of realigning the Data timing such that now the
  22                  addressed device will load bits onto the Data at the rising edge of the CLK. Therefore the bits
  23                  are read at falling edge of the CLK.
  24          4.      After the final data bit, the CLK is again held at 0 for at least one cycle before the next access.
  25          
  26          Transaction: ADDR[7:5] + R/W0 + ADDR[4:0] + DATA[7:0]
  27          */
  28          
  29          #if (FM_TRANS_MODULE == FM_TRANS_80110C)
              
              #if 1
              void halSPIInit(void)
              {
                      //set gpio direction, value
                      SPI_CLK = 0;
                      SPI_EN0 = 1;
                      SPI_CLK_OUT();
                      SPI_EN0_OUT();
                      
                      return;
              }
              #endif
              #if 0
              void _halSPISend0(void){
                      //SPI_EN should be setup before this function
              
                      SPI_DAT_OUT();
                      SPI_CLK = 0;            //Here is the falling edge
                      SPI_DAT = 0;
                      DelayUs(SPI_CLK_TIME);
                      SPI_CLK = 1;            // the raising edge
                      DelayUs(SPI_CLK_TIME);
C51 COMPILER V8.01   HAL80110C                                                             04/17/2008 09:55:00 PAGE 2   

              
                      return;
              }
              
              void _halSPISend1(void){
                      //SPI_EN should be setup before this function
              
                      SPI_DAT_OUT();
                      SPI_CLK = 0;            //Here is the falling edge
                      SPI_DAT = 1;
                      DelayUs(SPI_CLK_TIME);
                      SPI_CLK = 1;            // the raising edge
                      DelayUs(SPI_CLK_TIME);
              
                      return;
              }
              #endif
              void _halSPIWrite(BYTE regaddr, BYTE regval)
              {
                      BYTE data i;
                      WORD data u16Resp;
                      SPI_CLK = 0;    
                      SPI_DAT = 0;
                      SPI_EN0 = 0;
                      
                      DelayUs(500);
                      SPI_CLK = 1;
                      SPI_CLK = 0;
              
                      u16Resp=((((WORD)regaddr)<<8)&0xff00 |((WORD)regval)&0x00ff);
                      for(i=0; i<16; i++)
                      {
                              if(u16Resp&0x8000)
                              {
                                      SPI_DAT=1;
                              }else{
                                      SPI_DAT=0;
                              }
              
                              u16Resp<<=1;
                              SPI_CLK = 1;
                              SPI_CLK = 0;
                      }               
              #if 0
                      //Register address
                      for(i=0;i<8;i++){
                              if(regaddr&0x80){
                                      _halSPISend1();
                              }else{
                                      _halSPISend0();
                              }
                              regaddr <<= 1;
              
                              if(i == 2)
                                      _halSPISend0(); //R/W0
                      }
              
                      //Register value
                      for(i=0;i<8;i++){
                              if(regval&0x80){
                                      _halSPISend1();
                              }else{
C51 COMPILER V8.01   HAL80110C                                                             04/17/2008 09:55:00 PAGE 3   

                                      _halSPISend0();
                              }
                              regval <<= 1;
                      }
              #endif
              
                      SPI_EN0 = 1;
              //      _halSPISend0(); //Used to generate 2 cycle
              //      _halSPISend0();
                      SPI_CLK = 0;
                      SPI_CLK = 1;
                      SPI_CLK = 0;
                      
                      return;
              }
              
              #if 0
              BYTE _halSPIRead(BYTE regaddr)
              {
                      SBYTE i;
                      BYTE regval;
              
                      SPI_EN0 = 0;
                      //Register address
                      for(i=0;i<8;i++){
                              if(regaddr&0x80){
                                      _halSPISend1();
                              }else{
                                      _halSPISend0();
                              }
                              regaddr <<= 1;
              
                              if(i == 2)
                                      _halSPISend1(); //R/W0
                      }
              
                      //Register value
                      SPI_DAT_IN();
                      for(i=0;i<8;i++){
                              SPI_CLK = 0;            //Here is the falling edge
                              DelayUs(SPI_CLK_TIME);
                              SPI_CLK = 1;            // the raising edge
                              DelayUs(SPI_CLK_TIME);  
                              
                              regval <<= 1;
                              if(SPI_DAT)
                                      regval |= 0x01;
                      }
                      SPI_EN0 = 1;
              
                      for(i=0;i<2;i++){
                              SPI_CLK = 0;            //Here is the falling edge
                              DelayUs(SPI_CLK_TIME);
                              SPI_CLK = 1;            // the raising edge
                              DelayUs(SPI_CLK_TIME);  
                      }
                      SPI_CLK = 0;
                      
                      return regval;
              }
              #endif
              
C51 COMPILER V8.01   HAL80110C                                                             04/17/2008 09:55:00 PAGE 4   

              static BYTE data s_FMIdx;
              void halFMSet(BYTE byChIdx)     //byChIdx: 0-> 203
              {
                      WORD wProgCnt;
                      
                      if(byChIdx > FM_CHIDX_MAX)
                              s_FMIdx = FM_CHIDX_DEFAULT;
                      else
                              s_FMIdx = byChIdx;
                      
                      wProgCnt = (FM_FREQ_BASE + (WORD)byChIdx)<<1;
              
                      UartOutText("-I-: FM Idx 0x");UartOutValue(byChIdx, 2);
                      
                      halSPIInit();
                      
                      _halSPIWrite(0x14, (wProgCnt >> 8) & 0x7F);
                      _halSPIWrite(0x15, wProgCnt & 0xFF);
                      _halSPIWrite(0x16, 0x00);
                      _halSPIWrite(0x17, 0x80);
                      _halSPIWrite(0x18, 0x01);
                      _halSPIWrite(0x19, 0x00);
                      return;
              }
              
              void halFMUp(void)      //byChIdx: 0-> 203
              {
                      s_FMIdx++;
                      if(s_FMIdx > FM_CHIDX_MAX){//Over Max
                              s_FMIdx = FM_CHIDX_MIN;         
                      }       
              
                      halFMSet(s_FMIdx);      
                      
                      return;
              }
              
              void halFMDown(void)    //byChIdx: 0-> 203
              {
                      if(s_FMIdx == 0){//Minmal
                              s_FMIdx = FM_CHIDX_MAX;//turn around            
                      }else
                              s_FMIdx--;
              
                      halFMSet(s_FMIdx);      
                      
                      return;
              }
              
              void halStepAddFM()
              {
                      if(s_FMIdx == FM_CHIDX_MAX)
                              s_FMIdx = FM_CHIDX_DEFAULT;
                      else if((s_FMIdx + FM_STEP_1M) > FM_CHIDX_MAX)
                              s_FMIdx -= 200;
                      else
                              s_FMIdx += FM_STEP_1M;
              
                      //UartOutText("s_FMIdx \t");UartOutValue(s_FMIdx, 2);
                      
                      halFMSet(s_FMIdx);
                      return;
C51 COMPILER V8.01   HAL80110C                                                             04/17/2008 09:55:00 PAGE 5   

              }
              
              void halStepSubFM()
              {
                      if(s_FMIdx == 0)
                              s_FMIdx = FM_CHIDX_MAX;
                      else if(s_FMIdx < FM_STEP_1M)
                              s_FMIdx += 200;
                      else
                              s_FMIdx -= FM_STEP_1M;  
                      
                      //UartOutText("s_FMIdx \t");UartOutValue(s_FMIdx, 2);
                      
                      halFMSet(s_FMIdx);
                      return;
              }
              
              WORD halFMGetFreq(void)
              {
              //      FMDigital = FM_FREQ_BASE+FMLevel;
                      WORD wTmp = FM_FREQ_BASE + (WORD)s_FMIdx;
              
                      //UartOutText("-I-: halFMGetFreq 0x");UartOutValue(wTmp, 4);
                      return wTmp;
              }
              
              BYTE halFMGetIdx(void)
              {
              //      FMDigital = FM_FREQ_BASE+FMLevel;
                      //WORD wTmp = FM_FREQ_BASE + s_FMIdx;
              
                      return s_FMIdx;
              }
              
              BYTE halFMFreq2Idx(WORD wFreq)
              {
                      WORD wTmp = wFreq;
              
                      //Checking parameter validation
                      if((wFreq>=FM_FREQ_BASE) && (wFreq<=FM_FREQ_MAX)){
                              wTmp = wTmp - FM_FREQ_BASE; 
                      }else{
                              wTmp = FM_CHIDX_INVALID;
                      }               
                      
                      return (BYTE)wTmp;
              }
              
              #if 0
              void halSPITest(void)
              {
                      static BYTE invert = 0;
                      BYTE regval;
              
                      halSPIInit();
              
                      if(invert == 0){
                              invert = 1;
                              UartOutText("-I-: _halSPIWrite(0xaa, 0x55) \r\n");
                              _halSPIWrite(0xaa, 0x55);
                      }else{
                              invert = 0;
C51 COMPILER V8.01   HAL80110C                                                             04/17/2008 09:55:00 PAGE 6   

                              regval = _halSPIRead(0x55);
                              UartOutText("-I-: _halSPIRead(0x55)=");UartOutValue(regval, 2);
                      }
                      
                      return;
              }
              #endif
              
              #endif
 310          


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =   ----    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =   ----    ----
   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----    ----
END OF MODULE INFORMATION.


C51 COMPILATION COMPLETE.  0 WARNING(S),  0 ERROR(S)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -