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

📄 bitek.lst

📁 Bitek 公司 bit1611b模拟屏驱动芯片外接MCU驱动DEMO源码
💻 LST
📖 第 1 页 / 共 3 页
字号:
 249   1      
 250   1      
 251   1          /* --------------------------------
 252   1              Read Data
 253   1             -------------------------------- */
 254   1          // Reading last one without ACK !
 255   1          bDATA = BITEK_RxData();
 256   1      
 257   1      
 258   1          BITEK_Stop();
 259   1      
 260   1          return( bDATA );
 261   1      } /* BITEK_RxByte */
 262          #endif
 263          
 264          
 265          /* -------------------------------------------------------------------
 266              Name: BITEK_RxData -
 267              Purpose:
 268                  To do BITEK parallel/serial conversion for reception.
 269              Passed: None.
 270              Returns:
 271              Notes:
 272            ------------------------------------------------------------------- */
 273          UB8 BITEK_RxData (void)
 274          {
 275   1          UB8     bResult;
 276   1          UB8     bMask;
 277   1      
 278   1      
 279   1          bResult = 0x00;
 280   1      
 281   1          BITEK_SET_SDAT(HIGH);
 282   1      
 283   1      
 284   1          /* MSB is read first */
 285   1          for (bMask = 0x80; bMask; bMask >>= 1)
 286   1          {
 287   2              BITEK_SET_SCLK(HIGH);
 288   2              HI_PULSE;
 289   2      
 290   2              if ( BITEK_GET_SDAT_HIGH )
 291   2                  bResult |= bMask;
 292   2      
 293   2              BITEK_SET_SCLK(LOW);
 294   2              LO_PULSE;
 295   2          } /* for */
C51 COMPILER V7.50   BITEK                                                                 02/05/2007 16:33:24 PAGE 6   

 296   1      
 297   1          return( bResult );
 298   1      } /* BITEK_RxData */
 299          
 300          
 301          
 302          #if (BITEK_RX_WORD)
              /* -------------------------------------------------------------------
                  Name: BITEK_RxWord -
                  Purpose: To receive one WORD data from BITEK slave device.
                  Passed:
                      UB8     bSLA    = BITEK slave address
                      UW16    wREG    = BITEK register address
                  Returns: One word received data.
                  Notes:
                 ------------------------------------------------------------------- */
              UW16 BITEK_RxWord (
              UB8     bSLA,               /* BITEK slave address */
              UW16    wREG                /* BITEK register address */
              )
              {
                  UW16    wDATA;
              
              
                  BITEK_Start();
              
                  BITEK_TxData(bSLA);
              
                  BITEK_GetACK();
              
                  // If Extension = 1 !
                  if (bSLA & 0x01)
                  {
                      // MSB Slave Address [14:7]
                      BITEK_TxData(wREG >> 7);
                      BITEK_GetACK();
                  }
              
                  // LSB Slave Address [6:0]
                  BITEK_TxData((wREG << 1) | 0x01);
                  BITEK_GetACK();
              
              
                  /* --------------------------------
                      Read Data
                     -------------------------------- */
                  // LSB Data
                  wDATA = BITEK_RxData();                 /* Low byte */
                  BITEK_SetACK();
              
                  // Reading last one without ACK !
                  wDATA = (BITEK_RxData() << 8) + wDATA;
              
              
                  BITEK_Stop();
              
                  return( wDATA );
              } /* BITEK_RxWord */
              #endif
 355          
 356          
 357          #if (BITEK_SET_ACK)
C51 COMPILER V7.50   BITEK                                                                 02/05/2007 16:33:24 PAGE 7   

              /* -------------------------------------------------------------------
                  Name: BITEK_SetACK -
                  Purpose: .
                  Passed: None.
                  Returns: None.
                  Notes:
                 ------------------------------------------------------------------- */
              void BITEK_SetACK (void)
              {
                  BITEK_SET_SDAT(LOW);
              
                  BITEK_SET_SCLK(HIGH);
                  HI_PULSE;
              
                  BITEK_SET_SCLK(LOW);
                  LO_PULSE;
              
              } /* BITEK_SetACK */
              #endif
 377          
 378          
 379          /* -------------------------------------------------------------------
 380              Name: BITEK_Start - START condition (SDAT falling edge).
 381              Purpose: .
 382              Passed: None.
 383              Returns: None.
 384              Notes:
 385              Reference:
 386             ------------------------------------------------------------------- */
 387          void BITEK_Start (void)
 388          {
 389   1      
 390   1          BITEK_SET_SDAT(HIGH);
 391   1      
 392   1          BITEK_SET_SCLK(HIGH);
 393   1      
 394   1          HI_PULSE;
 395   1          HI_PULSE;
 396   1          HI_PULSE;
 397   1      
 398   1          BITEK_SET_SDAT(LOW);
 399   1          LO_PULSE;
 400   1          LO_PULSE;
 401   1      
 402   1          BITEK_SET_SCLK(LOW);
 403   1          LO_PULSE;
 404   1      } /* BITEK_Start */
 405          
 406          
 407          /* -------------------------------------------------------------------
 408              Name: BITEK_Stop - STOP condition (SDAT rising edge).
 409              Purpose: .
 410              Passed: None.
 411              Returns: None.
 412              Notes:
 413              Reference:
 414            ------------------------------------------------------------------- */
 415          void BITEK_Stop (void)
 416          {
 417   1          BITEK_SET_SDAT(LOW);
 418   1          LO_PULSE;
 419   1      
C51 COMPILER V7.50   BITEK                                                                 02/05/2007 16:33:24 PAGE 8   

 420   1          BITEK_SET_SCLK(HIGH);
 421   1          HI_PULSE;
 422   1          HI_PULSE;
 423   1          HI_PULSE;
 424   1      
 425   1          BITEK_SET_SDAT(HIGH);
 426   1          HI_PULSE;
 427   1          HI_PULSE;
 428   1          HI_PULSE;
 429   1      } /* BITEK_Stop */
 430          
 431          
 432          
 433          #if (BITEK_TX_BURST)
 434          /* -------------------------------------------------------------------
 435              Name: BITEK_TxBurst -
 436              Purpose: To transmit bulk data to BiTEKbus slave device.
 437              Passed:
 438                  UB8  bSLA       = BiTEKbus slave address
 439                  UW16 wREG       = BiTEKbus register address
 440                  UB8  bCNT       = The number of data which will be transmitted
 441                      excluding slave and register address (bCNT: 1..255).
 442                  UB8  *pbDATA    = The pointer which points to the first data item.
 443              Returns: None.
 444              Notes:
 445             ------------------------------------------------------------------- */
 446          void BITEK_TxBurst (
 447          UB8  bSLA,          /* BITEK slave address */
 448          UW16 wREG,          /* BITEK register address */
 449          UB8  bCNT,          /* The number of data which will be transmitted */
 450          UB8  *pbDATA        /* Point to the first DATA item */
 451          )
 452          {
 453   1          UB8 bIdx;
 454   1      
 455   1      
 456   1          BITEK_Start();
 457   1      
 458   1          BITEK_TxData(bSLA);
 459   1      
 460   1          BITEK_GetACK();
 461   1      
 462   1      
 463   1          // If Extension = 1 !
 464   1          if (bSLA & 0x01)
 465   1          {
 466   2              // MSB Slave Address [14:7]
 467   2              BITEK_TxData(wREG >> 7);
 468   2              BITEK_GetACK();
 469   2          }
 470   1      
 471   1          // LSB Slave Address [6:0]
 472   1          BITEK_TxData(wREG << 1);
 473   1          BITEK_GetACK();
 474   1      
 475   1      
 476   1          /* --------------------------------
 477   1              Write Data
 478   1             -------------------------------- */
 479   1          for (bIdx = bCNT; bIdx; bIdx--)
 480   1          {
 481   2              bData = *pbDATA++;
C51 COMPILER V7.50   BITEK                                                                 02/05/2007 16:33:24 PAGE 9   

 482   2              BITEK_TxData(bData);
 483   2              BITEK_GetACK();
 484   2          } /* for */
 485   1      
 486   1      
 487   1          BITEK_Stop();
 488   1      } /* BITEK_TxBurst */
 489          #endif
 490          
 491          
 492          #if (BITEK_TX_BYTE)
 493          /* -------------------------------------------------------------------
 494              Name: BITEK_TxByte -
 495              Purpose: To transmit one byte data to BiTEKbus slave device.
 496              Passed:
 497                  UB8  bSLA   = BiTEKbus slave address.
 498                  UW16 wREG   = BiTEKbus register address.
 499                  UB8  bDATA  = One byte transmitted data.
 500              Returns: None.
 501              Notes:
 502             ------------------------------------------------------------------- */
 503          void BITEK_TxByte (
 504          UB8  bSLA,          /* BITEK slave address */
 505          UW16 wREG,          /* BITEK register address */
 506          UB8  bDATA          /* DATA item */
 507          )
 508          {
 509   1          BITEK_Start();
 510   1      
 511   1          BITEK_TxData(bSLA);
 512   1      
 513   1          BITEK_GetACK();

⌨️ 快捷键说明

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