C51 COMPILER V9.53.0.0   MAIN                                                              08/10/2021 09:49:54 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 LARGE OPTIMIZE(8,SPEED) BROWSE INCDIR(..\Peripheral
                    -s\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          Keil: MDK5.10.0.2
   7          MCU:stm32f103c8
   8          GY-tof---STM32
   9          1,通过电脑配置好模块波特率9600，连续输出，起始寄存器0x08,数据量5，保存设置
  10          硬件接法：
  11          GY-614---STM32
  12          1、GY-614_RX---STM32_TX
  13          2、STM32_TX---FT232,STM32将数据上传给上位机
  14          3、GY-614_TX---STM32_RX，接收模块数据
  15          软件说明:
  16          该程序采用串口方式获取模块数据，波特率9600行以上操作：
  17          注：中断函数位于stc_it.c
  18          联系方式：
  19          http://shop62474960.taobao.com/?spm=a230r.7195193.1997079397.2.9qa3Ky&v=1
  20          */
  21          char putchar (char c)   
  22          {        
  23   1          ES=0;        
  24   1          SBUF = c;        
  25   1          while(TI==0);        
  26   1          TI=0;        
  27   1          ES=1;        
  28   1          return 0;
  29   1      }
  30          typedef struct
  31          {
  32              float distance;
  33              uint16_t amp;
  34              uint16_t temp;
  35          } gytof;
  36          int main(void)
  37          {
  38   1      
  39   1          u8 sum=0,i=0;
  40   1        gytof my_tof={0,0,0};
  41   1        Usart_Int(9600);
  42   1        while(1)
  43   1        {
  44   2           if(Receive_ok)//串口接收完毕
  45   2              {
  46   3                   
  47   3                  for(sum=0,i=0; i<(usart_rx_data[3]+4); i++) //rgb_data[3]=3
  48   3                      sum+=usart_rx_data[i];
  49   3                  if(sum==usart_rx_data[i])//校验和判断
  50   3                  {
  51   4                      my_tof.distance=(usart_rx_data[4]<<8)|usart_rx_data[5];
  52   4                      my_tof.amp=(usart_rx_data[6]<<8)|usart_rx_data[7];
  53   4                      my_tof.temp=usart_rx_data[8];
  54   4                      
C51 COMPILER V9.53.0.0   MAIN                                                              08/10/2021 09:49:54 PAGE 2   

  55   4                      printf("distance: %.1f",my_tof.distance/10);
  56   4                      printf(" cm, amp: %d,",my_tof.amp);
  57   4                      printf("  temp: %d\r\n ",my_tof.temp);
  58   4              
  59   4                  }
  60   3                  else
  61   3                  {
  62   4                    printf(" sum %d\r\n ",sum);
  63   4                    printf(" count %d\r\n ",usart_rx_data[3]+4);
  64   4                  }
  65   3                  Receive_ok=0;//处理数据完毕标志
  66   3              }
  67   2          
  68   2        }
  69   1      }


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


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