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

小密度(1Ki/2Ki/4Ki/8Ki/16Ki bits)EEPROM驱动 更多...

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

浏览源代码.

函数

static xwer_t at24sd_putc (struct xwds_eeprom *eeprom, xwu8_t data, xwsq_t addr, xwtm_t to)
 
static xwer_t at24sd_getc (struct xwds_eeprom *eeprom, xwu8_t *buf, xwsq_t addr, xwtm_t to)
 
static xwer_t at24sd_pgwrite (struct xwds_eeprom *eeprom, xwu8_t data[], xwsz_t *size, xwsq_t pgidx, xwtm_t to)
 
static xwer_t at24sd_pgread (struct xwds_eeprom *eeprom, xwu8_t buf[], xwsz_t *size, xwsq_t pgidx, xwtm_t to)
 
static xwer_t at24sd_pgwrite (struct xwds_eeprom *eeprom, xwu8_t *data, xwsz_t *size, xwsq_t pgidx, xwtm_t to)
 
static xwer_t at24sd_pgread (struct xwds_eeprom *eeprom, xwu8_t *buf, xwsz_t *size, xwsq_t pgidx, xwtm_t to)
 

变量

const struct xwds_eeprom_driver at24sd_drv
 

详细描述

小密度(1Ki/2Ki/4Ki/8Ki/16Ki bits)EEPROM驱动

作者

在文件 at24sd.c 中定义.

函数说明

◆ at24sd_getc()

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

<No error

在文件 at24sd.c91 行定义.

92{
93 struct xwds_i2cm * bus;
94 struct xwds_i2c_msg msg;
95 xwer_t rc;
96 xwu8_t txdata;
97 xwu16_t i2cpaddr;
98
99 i2cpaddr = eeprom->i2cp.addr;
100 bus = eeprom->i2cp.bus;
101 txdata = (xwu8_t)(addr & (xwu8_t)0xFF);
102 msg.addr = ((i2cpaddr & (xwu16_t)0x00F0) |
103 (((addr >> (xwsq_t)8) & (xwu16_t)0x7) << (xwu16_t)1));
105 msg.data = &txdata;
106 msg.size = 1;
107 rc = xwds_i2cm_xfer(bus, &msg, to);
108 if (XWOK == rc) {
109 msg.addr = ((i2cpaddr & (xwu16_t)0x00F0) |
110 (((addr >> (xwsq_t)8) & (xwu16_t)0x7) << (xwu16_t)1));
111 msg.flag = ((xwu16_t)XWDS_I2C_F_START |
114 msg.data = buf;
115 msg.size = 1;
116 rc = xwds_i2cm_xfer(bus, &msg, to);
117 }
118 return rc;
119}
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
函数调用图:

◆ at24sd_pgread() [1/2]

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

<No error

<No error

在文件 at24sd.c157 行定义.

160{
161 struct xwds_i2cm * bus;
162 const struct xwds_eeprom_parameter * parameter;
163 struct xwds_i2c_msg msg;
164 xwer_t rc;
165 xwu16_t i2cpaddr;
166 xwsq_t addr;
167 xwu8_t txdata;
168
169 i2cpaddr = eeprom->i2cp.addr;
170 bus = eeprom->i2cp.bus;
171 parameter = &eeprom->parameter;
172 addr = ((pgidx * parameter->page_size) & (xwsq_t)0x7FF);
173 txdata = (xwu8_t)(addr & (xwu8_t)0xFF);
174 msg.addr = ((i2cpaddr & (xwu16_t)0x00F0) |
175 (((addr >> (xwsq_t)8) & (xwu16_t)0x7) << (xwu16_t)1));
177 msg.data = &txdata;
178 msg.size = 1;
179 rc = xwds_i2cm_xfer(bus, &msg, to);
180 if (XWOK == rc) {
181 msg.addr = ((i2cpaddr & (xwu16_t)0x00F0) |
182 (((addr >> (xwsq_t)8) & (xwu16_t)0x7) << (xwu16_t)1));
183 msg.flag = ((xwu16_t)XWDS_I2C_F_START |
186 msg.data = buf;
187 msg.size = *size;
188 rc = xwds_i2cm_xfer(bus, &msg, to);
189 if (XWOK == rc) {
190 *size = msg.size;
191 }
192 }
193 return rc;
194}
const struct xwds_eeprom_parameter parameter
Definition device.h:40
xwsz_t size
Definition common.h:68
函数调用图:

◆ at24sd_pgread() [2/2]

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

◆ at24sd_pgwrite() [1/2]

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

在文件 at24sd.c122 行定义.

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

◆ at24sd_pgwrite() [2/2]

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

◆ at24sd_putc()

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

在文件 at24sd.c67 行定义.

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

变量说明

◆ at24sd_drv

const struct xwds_eeprom_driver at24sd_drv
初始值:
= {
.i2cp = {
.base = {
.name = "xwds.eeprom",
.probe = ((void *)0) ,
.remove = ((void *)0) ,
},
},
.putc = at24sd_putc,
.getc = at24sd_getc,
.pgwrite = at24sd_pgwrite,
.pgread = at24sd_pgread,
}
static xwer_t at24sd_pgread(struct xwds_eeprom *eeprom, xwu8_t buf[], xwsz_t *size, xwsq_t pgidx, xwtm_t to)
static xwer_t at24sd_getc(struct xwds_eeprom *eeprom, xwu8_t *buf, xwsq_t addr, xwtm_t to)
Definition at24sd.c:91
static xwer_t at24sd_pgwrite(struct xwds_eeprom *eeprom, xwu8_t data[], xwsz_t *size, xwsq_t pgidx, xwtm_t to)
static xwer_t at24sd_putc(struct xwds_eeprom *eeprom, xwu8_t data, xwsq_t addr, xwtm_t to)
Definition at24sd.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

在文件 at24sd.c46 行定义.