C51 COMPILER V9.53.0.0   MAIN                                                              08/10/2021 11:06:01 PAGE 1   


C51 COMPILER V9.53.0.0, COMPILATION OF MODULE MAIN
OBJECT MODULE PLACED IN ..\output\main.obj
COMPILER INVOKED BY: D:\Program Files\Keil_c5\C51\BIN\C51.EXE main.c OPTIMIZE(8,SPEED) BROWSE INCDIR(..\PERIPHERALS\INC\
                    -) DEBUG OBJECTEXTEND PRINT(..\lis\main.lst) TABS(2) OBJECT(..\output\main.obj)

line level    source

   1          #include <reg52.h>
   2          #include "usart.h"
   3          #include "iic.h"  
   4           #include "stdio.h"
   5          /*
   6          硬件接法：
   7          GY-33----C51
   8          SCL---P3^6
   9          SDA---P3^7
  10          C51---FT232
  11          TX ---RX
  12          RX ---TX
  13          软件说明：
  14          
  15          注：
  16            中断函数位于stc_it.c
  17          联系方式：
  18          http://shop62474960.taobao.com/?spm=a230r.7195193.1997079397.2.9qa3Ky&v=1
  19          */
  20          char putchar (char c)   
  21          {        
  22   1          ES=0;        
  23   1          SBUF = c;        
  24   1          while(TI==0);        
  25   1          TI=0;        
  26   1          ES=1;        
  27   1          return 0;
  28   1      }
  29          typedef struct
  30          {
  31              uint16_t distance;
  32             unsigned short int amp;
  33              int temp;
  34          } gytof;
  35          void delay_ms(unsigned int x)
  36          {
  37   1        while(x--);
  38   1      }short
  39          int main(void)
  40          {
  41   1        u8  raw_data[9]={0};
  42   1        uint16_t datas[4]={0},delay_t;
  43   1      
  44   1        gytof my_tof;
  45   1      
  46   1        u8 td=0;
  47   1      
  48   1        Usart_Int(9600);
  49   1        delay_ms(300);//等待模块初始化完成
  50   1        td=2;
  51   1        Single_WriteI2C_byte(0xa4,0x02,2);//设置更新频率50hz
  52   1          switch(td)
  53   1          {
  54   2          case 0:
C51 COMPILER V9.53.0.0   MAIN                                                              08/10/2021 11:06:01 PAGE 2   

  55   2              delay_t=995;
  56   2              break;
  57   2          case 1:
  58   2              delay_t=95;
  59   2              break;
  60   2          case 2:
  61   2              delay_t=18;
  62   2              break;
  63   2          case 3:
  64   2              delay_t=4;
  65   2              break;
  66   2          }
  67   1       
  68   1      
  69   1          delay_ms(1);
  70   1        while(1)
  71   1        {
  72   2          
  73   2           if (read_pin==0)
  74   2             {  delay_ms(3); //等待更新
  75   3              if(Single_ReadI2C(0xa4,0x08,raw_data,5))
  76   3              {
  77   4                  my_tof.distance=(raw_data[0]<<8)|raw_data[1];
  78   4                  my_tof.amp=((short int)raw_data[2]<<8)|raw_data[3];
  79   4                  my_tof.temp=raw_data[4];
  80   4      
  81   4                  printf("distance: %.1f",(float)my_tof.distance/10);
  82   4                  printf(" cm, amp: %ud,",my_tof.amp);
  83   4                  printf("  temp: %d\r\n ",my_tof.temp);
  84   4              }
  85   3              
  86   3        
  87   3          
  88   3          
  89   3        }
  90   2      }
  91   1      }


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


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