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_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)0x0078) |
80 (((addr >> (xwsq_t)8) & (xwu16_t)0x7)));
82 msg.data = txdata;
83 msg.size = sizeof(txdata);
84 rc = xwds_i2cm_xfer(bus, &msg, 1U, to);
85 return rc;
86}
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
函数调用图:

◆ at24sd_getc()

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

在文件 at24sd.c89 行定义.

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

◆ 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_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

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

118{
119 struct xwds_i2cm * bus;
120 const struct xwds_eeprom_parameter * parameter;
121 struct xwds_i2c_msg msg;
122 xwer_t rc;
123 xwu16_t i2cpaddr;
124 xwsq_t addr;
125 xwsz_t wrsz = *size;
126 xwu8_t txdata[wrsz + 1];
127
128 i2cpaddr = eeprom->i2cp.addr;
129 bus = eeprom->i2cp.bus;
130 parameter = &eeprom->parameter;
131 addr = ((pgidx * parameter->page_size) & (xwsq_t)0x7FF);
132 txdata[0] = (xwu8_t)(addr & (xwu8_t)0xFF);
133 memcpy(&txdata[1], data, wrsz);
134 msg.addr = ((i2cpaddr & (xwu16_t)0x0078) |
135 (((addr >> (xwsq_t)8) & (xwu16_t)0x7)));
137 msg.data = txdata;
138 msg.size = wrsz + 1U;
139 rc = xwds_i2cm_xfer(bus, &msg, 1U, to);
140 if (rc < 0) {
141 *size = 0;
142 }
143
144 return rc;
145}
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
函数调用图:

◆ 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

<No error

在文件 at24sd.c148 行定义.

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

变量说明

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