C51 COMPILER V9.60.0.0   APP                                                               03/02/2021 17:25:34 PAGE 1   


C51 COMPILER V9.60.0.0, COMPILATION OF MODULE APP
OBJECT MODULE PLACED IN .\Out_Files\app.obj
COMPILER INVOKED BY: D:\keilc51\C51\BIN\C51.EXE APP\app.c COMPACT OMF2 OPTIMIZE(8,SIZE) BROWSE MOD517(NOAU) INCDIR(.\APP
                    -;.\Common;.\UM800x\driver;.\UM800x\system) DEBUG PRINT(.\Out_Files\app.lst) OBJECT(.\Out_Files\app.obj)

line level    source

   1          /***********************************************************************
   2           * Copyright (c)  2017 - 2020, Unicmicro Co.,Ltd .
   3           * All rights reserved.
   4           * Filename    : app.c
   5           * Description : app driver source file
   6           * Author(s)   : wanyi
   7           * version     : V1.0
   8           * Modify date : 2020-07-27
   9           ***********************************************************************/
  10          #include  "system_um800x.h"
  11          #include  "app.h"
  12          #include  "config.h"
  13          #include  "common.h"
  14          #include  "uart0.h"
  15          #include  "i2c.h"
  16          
  17          volatile uint8_t rx_flag ;
  18          volatile uint8_t uart0_rx_buf[32];
  19          volatile uint8_t uart0_tx_buf[32];
  20          volatile uint16_t rx_count = 0;
  21          volatile uint16_t tx_count = 0;
  22          /************************************************************************
  23           * function   : uart0_rec_pro
  24           * Description: uart0_rec_pro 串口接收处理回调函数
  25           * input : none
  26           * return: none
  27           ************************************************************************/
  28          void uart0_rec_pro(void)
  29          {
  30   1              uart0_rx_buf[rx_count++]= uart0_recv_byte();
  31   1              rx_flag = 1;    
  32   1      }
  33          /************************************************************************
  34           * function   : uart0_send_pro
  35           * Description: uart0_send_pro 串口发送处理回调函数
  36           * input : none
  37           * return: none
  38           ************************************************************************/
  39          void uart0_send_pro(void)
  40          {
  41   1              tx_flag = 1;
  42   1      }
  43          
  44          /************************************************************************
  45           * function   : uart_init
  46           * Description: uart_init 串口初始化
  47           * input : none
  48           * return: none
  49           ************************************************************************/
  50          void uart_init(void)
  51          {
  52   1              rx_flag = 0;
  53   1              uart0_init(UART0_BAUD_RATE);
  54   1          uart0_irq_init(UART0_IRQ_ENABLE,uart0_rec_pro,uart0_send_pro);
C51 COMPILER V9.60.0.0   APP                                                               03/02/2021 17:25:34 PAGE 2   

  55   1      }
  56          
  57          void i2c_test(void)
  58          {
  59   1              i2c_slave_test();
  60   1      }
  61          
  62          void i2c_slave_test(void)
  63          {
  64   1              i2c_slave_read_test();
  65   1      //      i2c_slave_write_test();
  66   1      }
  67          
  68          void i2c_slave_write_test(void)
  69          {
  70   1              uint8_t xdata i;
  71   1              uint8_t xdata len;
  72   1              uint8_t xdata i2c_slave_send_data[20];
  73   1              for(i=0 ; i<8; i++)
  74   1              {
  75   2                      i2c_slave_send_data[i] = i+0xa0;
  76   2              
  77   2              }
  78   1              
  79   1              printfS("i2c slave write test start\r\n");
  80   1              i2c_slave_init();                                               //从机初始化
  81   1              i2c_set_slave_addr1(I2C_SLAVE_ADDR);    //设置从机地址
  82   1              
  83   1              while(1)
  84   1              {       
  85   2                      if((REG_I2C_SR0 & MAAS1) == MAAS1) //maas1匹配
  86   2                      {                               
  87   3                                      REG_I2C_SR0 = MAAS1;            //清空地址匹配状态                      
  88   3                                      if((REG_I2C_SR0 & SRW))         //作为从发送器
  89   3                                      {
  90   4                                              len = i2c_slave_write(i2c_slave_send_data);
  91   4                                              printfS("write len:%bd\n", len);
  92   4                                              printfS("match addr1,i2c slave send\n");
  93   4                                              
  94   4                                      }
  95   3                      
  96   3                      }
  97   2                      if((REG_I2C_SR0 & MAAS2) == MAAS2) //maas2匹配
  98   2                      {                               
  99   3                                      REG_I2C_SR0 = MAAS2;       //清空地址匹配状态                   
 100   3                                      if((REG_I2C_SR0 & SRW))    //作为从发送器
 101   3                                      {
 102   4                                              len = i2c_slave_write(i2c_slave_send_data);
 103   4                                              printfS("write len:%bd\n", len);
 104   4                                              printfS("match addr2,i2c slave send\n");
 105   4                                      }
 106   3                      }
 107   2              }
 108   1      
 109   1      
 110   1      }
 111          
 112          
 113          void i2c_slave_read_test(void)
 114          {
 115   1              uint8_t xdata len;
 116   1              uint8_t xdata i2c_slave_recv_data[20];
C51 COMPILER V9.60.0.0   APP                                                               03/02/2021 17:25:34 PAGE 3   

 117   1              
 118   1              printfS("i2c slave read test start\r\n");
 119   1              
 120   1              i2c_slave_init();                                                       //从机初始化
 121   1              i2c_set_slave_addr1(I2C_SLAVE_ADDR);            //设置从机地址
 122   1              i2c_ack();                                                                      //使能应答ACK
 123   1              while(1)
 124   1              {       
 125   2                      if((REG_I2C_SR0 & MAAS1) == MAAS1)              //maas1匹配
 126   2                      {                               
 127   3                                      REG_I2C_SR0 = MAAS1;                    //清空地址匹配状态
 128   3                                      if(!(REG_I2C_SR0 & SRW))                //作为从接收器
 129   3                                      {
 130   4                                              len = i2c_slave_read(i2c_slave_recv_data);
 131   4                                              printfB8(i2c_slave_recv_data,len);
 132   4                                              printfS("match addr1,i2c slave receive\n");
 133   4                                      }
 134   3                      }
 135   2                      if((REG_I2C_SR0 & MAAS2) == MAAS2)              //maas2匹配
 136   2                      {                               
 137   3                                      REG_I2C_SR0 = MAAS2;                    //清空地址匹配状态
 138   3                                      if(!(REG_I2C_SR0 & SRW))                //作为从接收器
 139   3                                      {
 140   4                                              len = i2c_slave_read(i2c_slave_recv_data);
 141   4                                              printfB8(i2c_slave_recv_data,len);
 142   4                                              printfS("match addr2,i2c slave receive\n");
 143   4                                      }
 144   3                      }
 145   2              }
 146   1      
 147   1      }


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    361    ----
   CONSTANT SIZE    =    190    ----
   XDATA SIZE       =   ----      43
   PDATA SIZE       =     69    ----
   DATA SIZE        =   ----    ----
   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----    ----
   EDATA SIZE       =   ----    ----
   HDATA SIZE       =   ----    ----
   XDATA CONST SIZE =   ----    ----
   FAR CONST SIZE   =   ----    ----
END OF MODULE INFORMATION.


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