C51 COMPILER V9.59.0.0 STC8A_I2C_ISR 06/10/2021 10:06:08 PAGE 1 C51 COMPILER V9.59.0.0, COMPILATION OF MODULE STC8A_I2C_ISR OBJECT MODULE PLACED IN .\list\STC8A_I2C_Isr.obj COMPILER INVOKED BY: C:\Keil_v5\C51\BIN\C51.EXE STC8A_I2C_Isr.c OMF2 OPTIMIZE(8,SPEED) BROWSE DEBUG PRINT(.\list\STC8A_I -2C_Isr.lst) TABS(2) OBJECT(.\list\STC8A_I2C_Isr.obj) line level source 1 /*---------------------------------------------------------------------*/ 2 /* --- STC MCU Limited ------------------------------------------------*/ 3 /* --- STC 1T Series MCU Demo Programme -------------------------------*/ 4 /* --- Mobile: (86)13922805190 ----------------------------------------*/ 5 /* --- Fax: 86-0513-55012956,55012947,55012969 ------------------------*/ 6 /* --- Tel: 86-0513-55012928,55012929,55012966 ------------------------*/ 7 /* --- Web: www.STCMCU.com --------------------------------------------*/ 8 /* --- Web: www.STCMCUDATA.com ---------------------------------------*/ 9 /* --- QQ: 800003751 -------------------------------------------------*/ 10 /* 如果要在程序中使用此代码,请在程序中注明使用了STC的资料及程序 */ 11 /*---------------------------------------------------------------------*/ 12 13 #include "STC8A_I2C.h" 14 15 //======================================================================== 16 // 本地变量声明 17 //======================================================================== 18 19 I2C_IsrTypeDef I2CIsr; 20 21 //======================================================================== 22 // 外部函数和变量声明 23 //======================================================================== 24 25 26 //======================================================================== 27 // 函数: I2C_ISR_Handler 28 // 描述: I2C中断函数. 29 // 参数: none. 30 // 返回: none. 31 // 版本: V1.0, 2020-09-23 32 //======================================================================== 33 void I2C_ISR_Handler() interrupt I2C_VECTOR 34 { 35 1 char store; 36 1 37 1 store = P_SW2; 38 1 P_SW2 |= 0x80; 39 1 40 1 // TODO: 在此处添加用户代码 41 1 if (I2CSLST & 0x40) 42 1 { 43 2 I2CSLST &= ~0x40; //处理START事件 44 2 } 45 1 else if (I2CSLST & 0x20) 46 1 { 47 2 I2CSLST &= ~0x20; //处理RECV事件,SLACKO设置为0 48 2 if (I2CIsr.isda) 49 2 { 50 3 I2CIsr.isda = 0; //处理RECV事件(RECV DEVICE ADDR) 51 3 } 52 2 else if (I2CIsr.isma) 53 2 { 54 3 I2CIsr.isma = 0; //处理RECV事件(RECV MEMORY ADDR) C51 COMPILER V9.59.0.0 STC8A_I2C_ISR 06/10/2021 10:06:08 PAGE 2 55 3 I2CIsr.addr = I2CRXD; 56 3 I2CTXD = I2C_Buffer[I2CIsr.addr]; 57 3 } 58 2 else 59 2 { 60 3 I2C_Buffer[I2CIsr.addr++] = I2CRXD; //处理RECV事件(RECV DATA) 61 3 } 62 2 } 63 1 else if (I2CSLST & 0x10) 64 1 { 65 2 I2CSLST &= ~0x10; //处理SEND事件 66 2 if (I2CSLST & 0x02) 67 2 { 68 3 I2CTXD = 0xff; 69 3 } 70 2 else 71 2 { 72 3 I2CTXD = I2C_Buffer[++I2CIsr.addr]; 73 3 } 74 2 } 75 1 else if (I2CSLST & 0x08) 76 1 { 77 2 I2CSLST &= ~0x08; //处理STOP事件 78 2 I2CIsr.isda = 1; 79 2 I2CIsr.isma = 1; 80 2 DisplayFlag = 1; 81 2 } 82 1 83 1 P_SW2 = store; 84 1 } 85 MODULE INFORMATION: STATIC OVERLAYABLE CODE SIZE = 177 ---- CONSTANT SIZE = ---- ---- XDATA SIZE = ---- ---- PDATA SIZE = ---- ---- DATA SIZE = 3 ---- 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)