📄 i2c.lst
字号:
C51 COMPILER V7.10 I2C 09/03/2007 16:49:16 PAGE 1
C51 COMPILER V7.10, COMPILATION OF MODULE I2C
OBJECT MODULE PLACED IN i2c.OBJ
COMPILER INVOKED BY: D:\silabs\IDEfiles\C51\BIN\C51.exe i2c.c DB OE
line level source
1 /*------------------------------------------------------------
2 File Name: i2c.c
3 Auther: Samuel
4 Revision: R1
5 History: R1 Jul.05, 2007 Creation
6 ------------------------------------------------------------*/
7
8
9 #include "i2c.h"
10
11 // SMBus byte write function-----------------------------------------------------
12 // Writes a single byte at the specified memory location.
13 //
14 // out_byte = data byte to be written
15 // byte_address = memory location to be written into (2 bytes)
16 // chip_select = device address of EEPROM chip to be written to
17 void EEPROM_Send (char chip_select, unsigned int byte_address, char out_byte)
18 {
19 1
20 1 I2C_Device=EEPROM; // To tell the interrupt service routine what the I2C device is!
21 1
22 1 while (SM_BUSY); // Wait for SMBus to be free.
23 1 SM_BUSY = 1; // Occupy SMBus (set to busy)
24 1 SMB0CN = 0x44; // SMBus enabled,
25 1 // ACK on acknowledge cycle
26 1
27 1 BYTE_NUMBER = 2; // 2 address bytes.
28 1 COMMAND = (chip_select | WRITE); // Chip select + WRITE
29 1
30 1 HIGH_ADD = ((byte_address >> 8) & 0x00FF);// Upper 8 address bits
31 1 LOW_ADD = (byte_address & 0x00FF); // Lower 8 address bits
32 1
33 1 WORD = out_byte; // Data to be writen
34 1
35 1 STO = 0;
36 1 STA = 1; // Start transfer
37 1
38 1 }
39
40 // SMBus random read function------------------------------------------------------
41 // Reads 1 byte from the specified memory location.
42 //
43 // byte_address = memory address of byte to read
44 // chip_select = device address of EEPROM to be read from
45 char EEPROM_Receive (char chip_select, unsigned int byte_address)
46 {
47 1
48 1 I2C_Device=EEPROM; // To tell the interrupt service routine what the I2C device is!
49 1
50 1 while (SM_BUSY); // Wait for bus to be free.
51 1 SM_BUSY = 1; // Occupy SMBus (set to busy)
52 1 SMB0CN = 0x44; // SMBus enabled, ACK on acknowledge cycle
53 1
54 1 BYTE_NUMBER = 2; // 2 address bytes
55 1 COMMAND = (chip_select | READ); // Chip select + READ
C51 COMPILER V7.10 I2C 09/03/2007 16:49:16 PAGE 2
56 1
57 1 HIGH_ADD = ((byte_address >> 8) & 0x00FF);// Upper 8 address bits
58 1 LOW_ADD = (byte_address & 0x00FF); // Lower 8 address bits
59 1
60 1 STO = 0;
61 1 STA = 1; // Start transfer
62 1 while (SM_BUSY); // Wait for transfer to finish
63 1 return WORD;
64 1 }
65
66
67 ///////////////////////////////////////////////
68 void TEA5777_Send (void)
69 {
70 1 I2C_Device=TEA5777; // To tell the interrupt service routine what the I2C device is!
71 1 while (SM_BUSY); // Wait for bus to be free.
72 1 SM_BUSY = 1; // Occupy SMBus (set to busy)
73 1 SMB0CN = 0x44; // SMBus enabled, ACK on acknowledge cycle
74 1
75 1 COMMAND = 0xC0; // TEA5777 address + WRITE
76 1 BYTE_NUMBER=6;
77 1 STO = 0;
78 1 STA = 1;
79 1 while (SM_BUSY); // 发起始条件
80 1
81 1 }
82
83 ///////////////////////////////////////////////
84 void TEA5777_Receive (void)
85 {
86 1 I2C_Device=TEA5777; // To tell the interrupt service routine what the I2C device is!
87 1 while (SM_BUSY); // Wait for bus to be free.
88 1 SM_BUSY = 1; // Occupy SMBus (set to busy)
89 1 SMB0CN = 0x44; // SMBus enabled, ACK on acknowledge cycle
90 1
91 1 COMMAND = 0xC1; // TEA5777 address + READ
92 1
93 1 STO = 0;
94 1 STA = 1; // 发起始条件
95 1
96 1 while (SM_BUSY); // Wait for transfer to finish
97 1 TEA5777_receive_buffer[0]= WORD;
98 1 SM_BUSY = 1;
99 1
100 1 while (SM_BUSY); // Wait for transfer to finish
101 1 TEA5777_receive_buffer[1]= WORD;
102 1 SM_BUSY = 1;
103 1
104 1 AA=0;
105 1 while (SM_BUSY); // Wait for transfer to finish
106 1 TEA5777_receive_buffer[2]= WORD;
107 1
108 1 //STO=1;
109 1 }
110
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 132 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
C51 COMPILER V7.10 I2C 09/03/2007 16:49:16 PAGE 3
DATA SIZE = 22 ----
IDATA SIZE = ---- ----
BIT SIZE = 2 ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -