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_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)0x0078) |
81 ((xwu16_t)(addr >> 16U) & (xwu16_t)0x7));
83 msg.data = txdata;
84 msg.size = sizeof(txdata);
85 rc = xwds_i2cm_xfer(bus, &msg, 1U, to);
86 return rc;
87}
xwer_t xwds_i2cm_xfer(struct xwds_i2cm *i2cm, struct xwds_i2c_msg *msg, xwsz_t num, xwtm_t to)
XWDS API:传输I2C消息
Definition master.c:201
@ XWDS_I2C_F_START
Definition common.h:42
@ XWDS_I2C_F_STOP
Definition common.h:43
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:49
xwu8_t * data
Definition common.h:54
xwu16_t addr
Definition common.h:50
I2C主机
Definition master.h:53
xwu16_t addr
Definition peripheral.h:53
struct xwds_i2cm * bus
Definition peripheral.h:52
函数调用图:

◆ at24md_getc()

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

在文件 at24md.c90 行定义.

91{
92 struct xwds_i2cm * bus;
93 struct xwds_i2c_msg msg[2];
94 xwer_t rc;
95 xwu8_t txdata[2];
96 xwu16_t i2cpaddr;
97
98 i2cpaddr = eeprom->i2cp.addr;
99 bus = eeprom->i2cp.bus;
100 txdata[0] = (xwu8_t)((addr >> (xwsq_t)8) & (xwu8_t)0xFF);
101 txdata[1] = (xwu8_t)(addr & (xwu8_t)0xFF);
102 msg[0].addr = ((i2cpaddr & (xwu16_t)0x0078) |
103 ((xwu16_t)(addr >> 16U) & (xwu16_t)0x7));
104 msg[0].flag = (xwu16_t)XWDS_I2C_F_START;
105 msg[0].data = txdata;
106 msg[0].size = 2U;
107 msg[1].addr = msg[0].addr;
108 msg[1].flag = ((xwu16_t)XWDS_I2C_F_START | (xwu16_t)XWDS_I2C_F_RD |
110 msg[1].data = buf;
111 msg[1].size = 1U;
112 rc = xwds_i2cm_xfer(bus, msg, 2U, to);
113 return rc;
114}
@ XWDS_I2C_F_RD
Definition common.h:39
函数调用图:

◆ 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.c117 行定义.

120{
121 struct xwds_i2cm * bus;
122 const struct xwds_eeprom_parameter * parameter;
123 struct xwds_i2c_msg msg;
124 xwer_t rc;
125 xwu16_t i2cpaddr;
126 xwsq_t addr;
127 xwsz_t wrsz = *size;
128 xwu8_t txdata[wrsz + 2];
129
130 i2cpaddr = eeprom->i2cp.addr;
131 bus = eeprom->i2cp.bus;
132 parameter = &eeprom->parameter;
133 addr = ((pgidx * parameter->page_size) & (xwsq_t)0x7FFFF);
134 txdata[0] = (xwu8_t)((addr >> (xwsq_t)8) & (xwu8_t)0xFF);
135 txdata[1] = (xwu8_t)(addr & (xwu8_t)0xFF);
136 memcpy(&txdata[2], data, wrsz);
137 msg.addr = ((i2cpaddr & (xwu16_t)0x0078) |
138 ((xwu16_t)(addr >> 16U) & (xwu16_t)0x7));
140 msg.data = txdata;
141 msg.size = wrsz + 2U;
142 rc = xwds_i2cm_xfer(bus, &msg, 1U, to);
143 if (rc < 0) {
144 *size = 0;
145 }
146 return rc;
147}
unsigned long xwsz_t
Definition type.h:339
const struct xwds_eeprom_parameter parameter
Definition device.h:40
xwsz_t size
Definition common.h:55
函数调用图:

◆ 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

在文件 at24md.c150 行定义.

153{
154 struct xwds_i2cm * bus;
155 const struct xwds_eeprom_parameter * parameter;
156 struct xwds_i2c_msg msg[2];
157 xwer_t rc;
158 xwu16_t i2cpaddr;
159 xwsq_t addr;
160 xwsz_t rdsz = *size;
161 xwu8_t txdata[2];
162
163 i2cpaddr = eeprom->i2cp.addr;
164 bus = eeprom->i2cp.bus;
165 parameter = &eeprom->parameter;
166 addr = ((pgidx * parameter->page_size) & (xwsq_t)0x7FFFF);
167 txdata[0] = (xwu8_t)((addr >> (xwsq_t)8) & (xwu8_t)0xFF);
168 txdata[1] = (xwu8_t)(addr & (xwu8_t)0xFF);
169 msg[0].addr = ((i2cpaddr & (xwu16_t)0x0078) |
170 ((xwu16_t)(addr >> 16U) & (xwu16_t)0x7));
171 msg[0].flag = (xwu16_t)XWDS_I2C_F_START;
172 msg[0].data = txdata;
173 msg[0].size = 2U;
174 msg[1].addr = msg[0].addr;
175 msg[1].flag = ((xwu16_t)XWDS_I2C_F_START | (xwu16_t)XWDS_I2C_F_RD |
177 msg[1].data = buf;
178 msg[1].size = rdsz;
179 rc = xwds_i2cm_xfer(bus, msg, 2U, to);
180 if (XWOK == rc) {
181 *size = msg[1].size;
182 } else {
183 *size = 0;
184 }
185 return rc;
186}
#define XWOK
No error
Definition errno.h:182
函数调用图:

变量说明

◆ 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:150
static xwer_t at24md_pgwrite(struct xwds_eeprom *eeprom, xwu8_t *data, xwsz_t *size, xwsq_t pgidx, xwtm_t to)
Definition at24md.c:117
static xwer_t at24md_getc(struct xwds_eeprom *eeprom, xwu8_t *buf, xwsq_t addr, xwtm_t to)
Definition at24md.c:90
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 行定义.