XWOS API  4.0
XWOS C/C++ API参考手册
载入中...
搜索中...
未找到
at24md.c 文件参考

中等密度(32Ki/64Ki/128Ki/256Ki/512Ki/1Mi/2Mi bits)EEPROM驱动 更多...

at24md.c 的引用(Include)关系图:

浏览源代码.

函数

static xwer_t at24md_putc (struct xwds_eeprom *eeprom, xwu8_t data, xwsq_t addr, xwtm_t to)
 
static xwer_t at24md_getc (struct xwds_eeprom *eeprom, xwu8_t *buf, xwsq_t addr, xwtm_t to)
 
static xwer_t at24md_pgwrite (struct xwds_eeprom *eeprom, xwu8_t *data, xwsz_t *size, xwsq_t pgidx, xwtm_t to)
 
static xwer_t at24md_pgread (struct xwds_eeprom *eeprom, xwu8_t *buf, xwsz_t *size, xwsq_t pgidx, xwtm_t to)
 

变量

const struct xwds_eeprom_driver at24md_drv
 

详细描述

中等密度(32Ki/64Ki/128Ki/256Ki/512Ki/1Mi/2Mi bits)EEPROM驱动

作者

在文件 at24md.c 中定义.

函数说明

◆ at24md_getc()

static xwer_t at24md_getc ( struct xwds_eeprom eeprom,
xwu8_t buf,
xwsq_t  addr,
xwtm_t  to 
)
static

<No error

在文件 at24md.c92 行定义.

93{
94 struct xwds_i2cm * bus;
95 struct xwds_i2c_msg msg;
96 xwer_t rc;
97 xwu8_t txdata[2];
98 xwu16_t i2cpaddr;
99
100 i2cpaddr = eeprom->i2cp.addr;
101 bus = eeprom->i2cp.bus;
102 txdata[0] = (xwu8_t)((addr >> (xwsq_t)8) & (xwu8_t)0xFF);
103 txdata[1] = (xwu8_t)(addr & (xwu8_t)0xFF);
104 msg.addr = ((i2cpaddr & (xwu16_t)0x00F0) |
105 (((addr >> (xwsq_t)16) & (xwu16_t)0x7) << (xwu16_t)1));
107 msg.data = txdata;
108 msg.size = 2;
109 rc = xwds_i2cm_xfer(bus, &msg, to);
110 if (XWOK == rc) {
111 msg.addr = ((i2cpaddr & (xwu16_t)0x00F0) |
112 (((addr >> (xwsq_t)16) & (xwu16_t)0x7) << (xwu16_t)1));
113 msg.flag = ((xwu16_t)XWDS_I2C_F_START |
116 msg.data = buf;
117 msg.size = 1;
118 rc = xwds_i2cm_xfer(bus, &msg, to);
119 }
120 return rc;
121}
xwer_t xwds_i2cm_xfer(struct xwds_i2cm *i2cm, struct xwds_i2c_msg *msg, xwtm_t to)
XWDS API:传输I2C消息
Definition master.c:201
@ XWDS_I2C_F_WR
Definition common.h:43
@ XWDS_I2C_F_START
Definition common.h:46
@ XWDS_I2C_F_RD
Definition common.h:42
@ XWDS_I2C_F_STOP
Definition common.h:56
#define XWOK
No error
Definition errno.h:182
signed long xwer_t
Definition type.h:554
uint8_t xwu8_t
Definition type.h:194
unsigned long xwsq_t
Definition type.h:445
uint16_t xwu16_t
Definition type.h:230
struct xwds_i2cp i2cp
Definition device.h:39
I2C消息
Definition common.h:62
xwu16_t addr
Definition common.h:63
I2C主机
Definition master.h:53
xwu16_t addr
Definition peripheral.h:53
struct xwds_i2cm * bus
Definition peripheral.h:52
函数调用图:

◆ at24md_pgread()

static xwer_t at24md_pgread ( struct xwds_eeprom eeprom,
xwu8_t buf,
xwsz_t size,
xwsq_t  pgidx,
xwtm_t  to 
)
static

<No error

<No error

在文件 at24md.c159 行定义.

162{
163 struct xwds_i2cm * bus;
164 const struct xwds_eeprom_parameter * parameter;
165 struct xwds_i2c_msg msg;
166 xwer_t rc;
167 xwu16_t i2cpaddr;
168 xwsq_t addr;
169 xwsz_t rdsz = *size;
170 xwu8_t txdata[2];
171
172 i2cpaddr = eeprom->i2cp.addr;
173 bus = eeprom->i2cp.bus;
174 parameter = &eeprom->parameter;
175 addr = ((pgidx * parameter->page_size) & (xwsq_t)0x7FFFF);
176 txdata[0] = (xwu8_t)((addr >> (xwsq_t)8) & (xwu8_t)0xFF);
177 txdata[1] = (xwu8_t)(addr & (xwu8_t)0xFF);
178 msg.addr = ((i2cpaddr & (xwu16_t)0x00F0) |
179 (((addr >> (xwsq_t)16) & (xwu16_t)0x7) << (xwu16_t)1));
181 msg.data = txdata;
182 msg.size = 2;
183 rc = xwds_i2cm_xfer(bus, &msg, to);
184 if (XWOK == rc) {
185 msg.addr = ((i2cpaddr & (xwu16_t)0x00F0) |
186 (((addr >> (xwsq_t)16) & (xwu16_t)0x7) << (xwu16_t)1));
187 msg.flag = ((xwu16_t)XWDS_I2C_F_START |
190 msg.data = buf;
191 msg.size = rdsz;
192 rc = xwds_i2cm_xfer(bus, &msg, to);
193 if (XWOK == rc) {
194 *size = msg.size;
195 } else {
196 *size = 0;
197 }
198 } else {
199 *size = 0;
200 }
201 return rc;
202}
unsigned long xwsz_t
Definition type.h:339
const struct xwds_eeprom_parameter parameter
Definition device.h:40
xwsz_t size
Definition common.h:68
函数调用图:

◆ at24md_pgwrite()

static xwer_t at24md_pgwrite ( struct xwds_eeprom eeprom,
xwu8_t data,
xwsz_t size,
xwsq_t  pgidx,
xwtm_t  to 
)
static

在文件 at24md.c124 行定义.

127{
128 struct xwds_i2cm * bus;
129 const struct xwds_eeprom_parameter * parameter;
130 struct xwds_i2c_msg msg;
131 xwer_t rc;
132 xwu16_t i2cpaddr;
133 xwsq_t addr;
134 xwsz_t wrsz = *size;
135 xwu8_t txdata[wrsz + 2];
136
137 i2cpaddr = eeprom->i2cp.addr;
138 bus = eeprom->i2cp.bus;
139 parameter = &eeprom->parameter;
140 addr = ((pgidx * parameter->page_size) & (xwsq_t)0x7FFFF);
141 txdata[0] = (xwu8_t)((addr >> (xwsq_t)8) & (xwu8_t)0xFF);
142 txdata[1] = (xwu8_t)(addr & (xwu8_t)0xFF);
143 memcpy(&txdata[2], data, wrsz);
144 msg.addr = ((i2cpaddr & (xwu16_t)0x00F0) |
145 (((addr >> (xwsq_t)16) & (xwu16_t)0x7) << (xwu16_t)1));
146 msg.flag = ((xwu16_t)XWDS_I2C_F_START |
149 msg.data = txdata;
150 msg.size = wrsz + 2;
151 rc = xwds_i2cm_xfer(bus, &msg, to);
152 if (rc < 0) {
153 *size = 0;
154 }
155 return rc;
156}
xwu8_t * data
Definition common.h:67
函数调用图:

◆ at24md_putc()

static xwer_t at24md_putc ( struct xwds_eeprom eeprom,
xwu8_t  data,
xwsq_t  addr,
xwtm_t  to 
)
static

在文件 at24md.c67 行定义.

68{
69 struct xwds_i2cm * bus;
70 struct xwds_i2c_msg msg;
71 xwer_t rc;
72 xwu8_t txdata[3];
73 xwu16_t i2cpaddr;
74
75 i2cpaddr = eeprom->i2cp.addr;
76 bus = eeprom->i2cp.bus;
77 txdata[0] = (xwu8_t)((addr >> (xwsq_t)8) & (xwu8_t)0xFF);
78 txdata[1] = (xwu8_t)(addr & (xwu8_t)0xFF);
79 txdata[2] = data;
80 msg.addr = ((i2cpaddr & (xwu16_t)0x00F0) |
81 (((addr >> (xwsq_t)16) & (xwu16_t)0x7) << (xwu16_t)1));
82 msg.flag = ((xwu16_t)XWDS_I2C_F_START |
85 msg.data = txdata;
86 msg.size = sizeof(txdata);
87 rc = xwds_i2cm_xfer(bus, &msg, to);
88 return rc;
89}
函数调用图:

变量说明

◆ at24md_drv

const struct xwds_eeprom_driver at24md_drv
初始值:
= {
.i2cp = {
.base = {
.name = "xwds.eeprom",
.probe = ((void *)0) ,
.remove = ((void *)0) ,
},
},
.putc = at24md_putc,
.getc = at24md_getc,
.pgwrite = at24md_pgwrite,
.pgread = at24md_pgread,
}
static xwer_t at24md_pgread(struct xwds_eeprom *eeprom, xwu8_t *buf, xwsz_t *size, xwsq_t pgidx, xwtm_t to)
Definition at24md.c:159
static xwer_t at24md_pgwrite(struct xwds_eeprom *eeprom, xwu8_t *data, xwsz_t *size, xwsq_t pgidx, xwtm_t to)
Definition at24md.c:124
static xwer_t at24md_getc(struct xwds_eeprom *eeprom, xwu8_t *buf, xwsq_t addr, xwtm_t to)
Definition at24md.c:92
static xwer_t at24md_putc(struct xwds_eeprom *eeprom, xwu8_t data, xwsq_t addr, xwtm_t to)
Definition at24md.c:67
xwer_t xwds_eeprom_drv_start(struct xwds_device *dev)
EEPROM基本驱动:启动设备
Definition driver.c:48
xwer_t xwds_eeprom_drv_suspend(struct xwds_device *dev)
EEPROM基本驱动:继续设备
Definition driver.c:108
xwer_t xwds_eeprom_drv_stop(struct xwds_device *dev)
EEPROM基本驱动:停止设备
Definition driver.c:87
xwer_t xwds_eeprom_drv_resume(struct xwds_device *dev)
EEPROM基本驱动:暂停设备
Definition driver.c:114

在文件 at24md.c46 行定义.