📄 at24c256.lst
字号:
C51 COMPILER V8.02 AT24C256 03/26/2007 19:14:28 PAGE 1
C51 COMPILER V8.02, COMPILATION OF MODULE AT24C256
OBJECT MODULE PLACED IN ..\Output\AT24C256.obj
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE ..\app\AT24C256.c LARGE BROWSE INCDIR(..\app;..\Main;..\Port;..\SOURCE) DEB
-UG OBJECTEXTEND PRINT(..\Output\AT24C256.lst) OBJECT(..\Output\AT24C256.obj)
line level source
1 #include "IIC.h"
2 #include "at24c256.h"
3
4 unsigned char AT24C256_ReadBlock(unsigned int blockAddress,unsigned char *recBuf);
5 unsigned char AT24C256_WriteBlock(unsigned int blockAddress,unsigned char *SendBuf);
6 unsigned char AT24C256_ReadMultiBlock(unsigned int blockAddress,unsigned int blockNum,unsigned char *recBu
-f);
7 unsigned char AT24C256_WriteMultiBlock(unsigned int blockAddress,unsigned int blockNum,unsigned char *send
-Buf);
8
9
10 unsigned char AT24C256_ReadBlock(unsigned int blockAddress,unsigned char *recBuf)
11 {
12 1 unsigned char slaveAddress;
13 1 unsigned int tmp;
14 1 unsigned char subAddress[2];
15 1 if(blockAddress>=(AT24C256_BLOCK_SIZE*4))
16 1 return 0;
17 1 if(blockAddress<AT24C256_BLOCK_SIZE)
18 1 {
19 2 slaveAddress = AT24C256_ADDRESS +0x00;
20 2 tmp = blockAddress*AT24C256_BYTE_SIZE;
21 2 subAddress[0] = (unsigned char) (tmp>>8);
22 2 subAddress[1] = (unsigned char) (tmp);
23 2 }
24 1 if((blockAddress>=AT24C256_BLOCK_SIZE)&&(blockAddress<(AT24C256_BLOCK_SIZE*2)))
25 1 {
26 2 slaveAddress = AT24C256_ADDRESS +0x01;
27 2 tmp = (blockAddress-AT24C256_BLOCK_SIZE);
28 2 tmp *= (AT24C256_BYTE_SIZE);
29 2 subAddress[0] = (unsigned char) (tmp>>8);
30 2 subAddress[1] = (unsigned char) tmp;
31 2 }
32 1 if(blockAddress>=AT24C256_BLOCK_SIZE*2&blockAddress<AT24C256_BLOCK_SIZE*3)
33 1 {
34 2 slaveAddress = AT24C256_ADDRESS +0x02;
35 2 tmp = (blockAddress-AT24C256_BLOCK_SIZE*2);
36 2 tmp *= AT24C256_BYTE_SIZE;
37 2 subAddress[0] = (unsigned char) (tmp>>8);
38 2 subAddress[1] = (unsigned char) (tmp);
39 2 }
40 1 if(blockAddress>=AT24C256_BLOCK_SIZE*3&blockAddress<AT24C256_BLOCK_SIZE*4)
41 1 {
42 2 slaveAddress = AT24C256_ADDRESS +0x03;
43 2 tmp = (blockAddress-AT24C256_BLOCK_SIZE*3);
44 2 tmp *= AT24C256_BYTE_SIZE;
45 2 subAddress[0] = (unsigned char) (tmp>>8);
46 2 subAddress[1] = (unsigned char) (tmp);
47 2 }
48 1 return SmbRec(slaveAddress,subAddress,TWO_BYTE_SUBA,AT24C256_BYTE_SIZE,recBuf);
49 1
50 1 }
51
52 unsigned char AT24C256_WriteBlock(unsigned int blockAddress,unsigned char *SendBuf)
C51 COMPILER V8.02 AT24C256 03/26/2007 19:14:28 PAGE 2
53 {
54 1 unsigned char slaveAddress;
55 1 unsigned int tmp;
56 1 unsigned char subAddress[2];
57 1 if(blockAddress>=AT24C256_BLOCK_SIZE*4)
58 1 return 0;
59 1 if(blockAddress<AT24C256_BLOCK_SIZE)
60 1 {
61 2 slaveAddress = AT24C256_ADDRESS +0x00;
62 2 tmp = blockAddress*AT24C256_BYTE_SIZE;
63 2 subAddress[0] = (unsigned char) (tmp>>8);
64 2 subAddress[1] = (unsigned char) (tmp);
65 2 }
66 1 if(blockAddress>=AT24C256_BLOCK_SIZE&blockAddress<AT24C256_BLOCK_SIZE*2)
67 1 {
68 2 slaveAddress = AT24C256_ADDRESS +0x01;
69 2 tmp = (blockAddress-AT24C256_BLOCK_SIZE);
70 2 tmp *= AT24C256_BYTE_SIZE;
71 2 subAddress[0] = (unsigned char) (tmp>>8);
72 2 subAddress[1] = (unsigned char) (tmp);
73 2 }
74 1 if(blockAddress>=AT24C256_BLOCK_SIZE*2&blockAddress<AT24C256_BLOCK_SIZE*3)
75 1 {
76 2 slaveAddress = AT24C256_ADDRESS +0x02;
77 2 tmp = (blockAddress-AT24C256_BLOCK_SIZE*2);
78 2 tmp *= AT24C256_BYTE_SIZE;
79 2 subAddress[0] = (unsigned char) (tmp>>8);
80 2 subAddress[1] = (unsigned char) (tmp);
81 2 }
82 1 if(blockAddress>=AT24C256_BLOCK_SIZE*3&blockAddress<AT24C256_BLOCK_SIZE*4)
83 1 {
84 2 slaveAddress = AT24C256_ADDRESS +0x03;
85 2 tmp = (blockAddress-AT24C256_BLOCK_SIZE*3);
86 2 tmp *= AT24C256_BYTE_SIZE;
87 2 subAddress[0] = (unsigned char) (tmp>>8);
88 2 subAddress[1] = (unsigned char) (tmp);
89 2 }
90 1 return SmbSend(slaveAddress,subAddress,TWO_BYTE_SUBA,AT24C256_BYTE_SIZE,SendBuf);
91 1 }
92
93 unsigned char AT24C256_ReadMultiBlock(unsigned int blockAddress,unsigned int blockNum,unsigned char *recBu
-f)
94 {
95 1 unsigned char tmp;
96 1 unsigned char tmp1;
97 1 for(tmp=0;tmp<blockNum;tmp++)
98 1 {
99 2 tmp1 = AT24C256_ReadBlock(blockAddress,(recBuf+AT24C256_BYTE_SIZE*tmp));
100 2 if(tmp1== 0)
101 2 {
102 3 return 0;
103 3 }
104 2 blockAddress++;
105 2 }
106 1 return 1;
107 1 }
108 unsigned char AT24C256_WriteMultiBlock(unsigned int blockAddress,unsigned int blockNum,unsigned char *send
-Buf)
109 {
110 1 unsigned char tmp;
111 1 unsigned char tmp1;
112 1 for(tmp=0;tmp<blockNum;tmp++)
C51 COMPILER V8.02 AT24C256 03/26/2007 19:14:28 PAGE 3
113 1 {
114 2 tmp1 = AT24C256_WriteBlock(blockAddress,sendBuf+AT24C256_BYTE_SIZE*tmp);
115 2 if(tmp1 == 0)
116 2 {
117 3 return 0;
118 3 }
119 2
120 2 blockAddress++;
121 2 }
122 1 return 1;
123 1 }
124
125
126
127
128
129
130
131
132
133
134
135
136
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 903 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- 32
PDATA SIZE = ---- ----
DATA SIZE = ---- ----
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -