XWOS API  4.0
XWOS C/C++ API参考手册
载入中...
搜索中...
未找到
driver.c
浏览该文件的文档.
1
21#include <xwos/standard.h>
22#include <string.h>
23#include <xwos/osal/thd.h>
27
28/******** ******** base driver ******** ********/
31{
32 struct xwds_w25qxx * w25qxx;
33 const struct xwds_w25qxx_driver * drv;
34 const struct xwds_w25qxx_cmd * cmdtbl;
35 xwer_t rc;
36
37 w25qxx = xwds_cast(struct xwds_w25qxx *, dev);
38 drv = xwds_cast(struct xwds_w25qxx_driver *, dev->drv);
39 cmdtbl = w25qxx->cmdtbl;
40 if ((NULL == drv) || (NULL == drv->io) ||
41 (NULL == cmdtbl) || (NULL == w25qxx->spip.bus)) {
42 rc = -EINVAL;
43 goto err_desc_err;
44 }
45 memset(w25qxx->txq, 0, sizeof(w25qxx->txq));
46 memset(w25qxx->rxq, 0, sizeof(w25qxx->rxq));
47 return XWOK;
48
49err_desc_err:
50 return rc;
51}
52
55{
56 XWOS_UNUSED(dev);
57 return XWOK;
58}
59
60#if defined(XWCDCFG_ds_PM) && (1 == XWCDCFG_ds_PM)
63{
64 return xwds_w25qxx_drv_start(dev);
65}
66
69{
70 return xwds_w25qxx_drv_stop(dev);
71}
72#endif
73
74/******** ******** ******** APIs ******** ******** ********/
80 const xwu8_t txd[], xwu8_t * rxb, xwsz_t size,
81 xwtm_t to)
82{
83 const struct xwds_w25qxx_driver * drv;
84 xwsz_t i, j, idx, rxofs, xfersize;
85 xwer_t rc;
86
87 XWDS_VALIDATE(w25qxx, "nullptr", -EFAULT);
88
89 rc = xwds_w25qxx_grab(w25qxx);
90 if (__xwcc_unlikely(rc < 0)) {
91 goto err_w25qxx_grab;
92 }
93 drv = xwds_cast(struct xwds_w25qxx_driver *, w25qxx->spip.dev.drv);
94 idx = 0;
95 w25qxx->txq[idx] = instruction;
96 idx++;
97 if (address_size) {
98 for (i = 0, j = (xwsz_t)(address_size - 1);
99 i < address_size;
100 i++, j--) {
101 w25qxx->txq[idx] = (xwu8_t)(address >> (j * 8));
102 idx++;
103 }
104 }
105 if (dummy_cycles) {
106 for (i = 0; i < (dummy_cycles / 8); i++) {
107 w25qxx->txq[idx] = 0;
108 idx++;
109 }
110 }
111 rxofs = idx;
112 for (i = 0; i < size; i++) {
113 if (txd) {
114 w25qxx->txq[idx] = txd[i];
115 } else {
116 w25qxx->txq[idx] = 0;
117 }
118 idx++;
119 }
120 xfersize = idx;
121 rc = drv->io(w25qxx,
122 w25qxx->txq, w25qxx->rxq, &xfersize,
123 to);
124 if (rc < 0) {
125 goto err_spim_xfer;
126 }
127 if (rxb) {
128 for (i = 0; i < size; i++) {
129 rxb[i] = w25qxx->rxq[rxofs + i];
130 }
131 }
132 xwds_w25qxx_put(w25qxx);
133 return XWOK;
134
135err_spim_xfer:
136 xwds_w25qxx_put(w25qxx);
137err_w25qxx_grab:
138 return rc;
139}
140
143{
144 struct xwds_w25qxx_cmd cmd;
145 xwer_t rc;
146
147 XWDS_VALIDATE(w25qxx, "nullptr", -EFAULT);
148
150 if (cmd.existing) {
151 rc = xwds_w25qxx_ctrl(w25qxx,
152 cmd.instruction,
153 cmd.address_size, cmd.address,
154 cmd.dummy_cycles,
155 NULL, NULL, 0, to);
156 if (rc < 0) {
157 goto err_w25qxx_ctrl;
158 }
159 }
160 cmd = w25qxx->cmdtbl[XWDS_W25QXX_CMD_RESET];
161 if (cmd.existing) {
162 rc = xwds_w25qxx_ctrl(w25qxx,
163 cmd.instruction,
164 cmd.address_size, cmd.address,
165 cmd.dummy_cycles,
166 NULL, NULL, 0, to);
167 if (rc < 0) {
168 goto err_w25qxx_ctrl;
169 }
170 }
171 return XWOK;
172
173err_w25qxx_ctrl:
174 return rc;
175}
176
179{
180 xwu64_t uid;
181 xwu32_t jid;
182 xwu16_t mid;
183 xwer_t rc;
184
185 rc = xwds_w25qxx_read_uid(w25qxx, &uid, to);
186 if (rc < 0) {
187 goto err_read_uid;
188 }
189 rc = xwds_w25qxx_read_mid(w25qxx, &mid, to);
190 if (rc < 0) {
191 goto err_read_mid;
192 }
193 rc = xwds_w25qxx_read_jid(w25qxx, &jid, to);
194 if (rc < 0) {
195 goto err_read_jid;
196 }
197 switch (w25qxx->parameter.mid) {
198 case XWDS_W25Q80_MID:
199 w25qxx->parameter.size = 1 * 1024 * 1024;
200 break;
201 case XWDS_W25Q16_MID:
202 w25qxx->parameter.size = 2 * 1024 * 1024;
203 break;
204 case XWDS_W25Q32_MID:
205 w25qxx->parameter.size = 4 * 1024 * 1024;
206 break;
207 case XWDS_W25Q64_MID:
208 w25qxx->parameter.size = 8 * 1024 * 1024;
209 break;
210 case XWDS_W25Q128_MID:
211 w25qxx->parameter.size = 16 * 1024 * 1024;
212 break;
213 case XWDS_W25Q256_MID:
214 w25qxx->parameter.size = 32 * 1024 * 1024;
215 break;
216 default:
217 break;
218 }
219 return XWOK;
220
221err_read_jid:
222err_read_mid:
223err_read_uid:
224 return rc;
225}
226
229{
230 struct xwds_w25qxx_cmd cmd;
231 xwer_t rc;
232 xwu8_t sr1;
233
234 XWDS_VALIDATE(w25qxx, "nullptr", -EFAULT);
235
237 if (1 != cmd.existing) {
238 rc = -ENOTSUP;
239 goto err_not_support;
240 }
241 rc = xwds_w25qxx_ctrl(w25qxx,
242 cmd.instruction,
243 cmd.address_size, cmd.address,
244 cmd.dummy_cycles,
245 NULL, NULL, 0, to);
246 if (rc < 0) {
247 goto err_w25qxx_ctrl;
248 }
249 rc = xwds_w25qxx_read_sr(w25qxx,
250 XWDS_W25QXX_SR_1, &sr1,
251 to);
252 if (rc < 0) {
253 goto err_chk_wel;
254 }
255 if (!(sr1 & XWDS_W25QXX_SR1_WEL)) {
256 rc = -EACCES;
257 goto err_chk_wel;
258 }
259 return XWOK;
260
261err_chk_wel:
262err_w25qxx_ctrl:
263err_not_support:
264 return rc;
265}
266
269{
270 struct xwds_w25qxx_cmd cmd;
271 xwer_t rc;
272
273 XWDS_VALIDATE(w25qxx, "nullptr", -EFAULT);
274
276 if (cmd.existing) {
277 rc = -ENOTSUP;
278 goto err_not_support;
279 }
280 rc = xwds_w25qxx_ctrl(w25qxx,
281 cmd.instruction,
282 cmd.address_size, cmd.address,
283 cmd.dummy_cycles,
284 NULL, NULL, 0, to);
285 if (rc < 0) {
286 goto err_w25qxx_ctrl;
287 }
288 return XWOK;
289
290err_w25qxx_ctrl:
291err_not_support:
292 return rc;
293}
294
297 xwu32_t sridx, xwu8_t * srbuf,
298 xwtm_t to)
299{
300 struct xwds_w25qxx_cmd cmd;
301 xwer_t rc;
302
303 XWDS_VALIDATE(w25qxx, "nullptr", -EFAULT);
304 XWDS_VALIDATE((sridx < XWDS_W25QXX_SR_NUM), "out-of-range", -ECHRNG);
305
306 switch (sridx) {
307 case XWDS_W25QXX_SR_2:
309 break;
310 case XWDS_W25QXX_SR_3:
312 break;
313 case XWDS_W25QXX_SR_1:
314 default:
316 break;
317 }
318 if (1 != cmd.existing) {
319 rc = -ENOTSUP;
320 goto err_not_support;
321 }
322 rc = xwds_w25qxx_ctrl(w25qxx,
323 cmd.instruction,
324 cmd.address_size, cmd.address,
325 cmd.dummy_cycles,
326 NULL, srbuf, 1, to);
327 if (rc < 0) {
328 goto err_w25qxx_ctrl;
329 }
330 return XWOK;
331
332err_w25qxx_ctrl:
333err_not_support:
334 return rc;
335}
336
339{
340 xwer_t rc;
341 xwu8_t sr1;
342
343 rc = xwds_w25qxx_read_sr(w25qxx,
344 XWDS_W25QXX_SR_1, &sr1,
345 to);
346 if (XWOK == rc) {
347 if (sr1 & XWDS_W25QXX_SR1_BUSY) {
348 rc = -EBUSY;
349 }
350 }
351 return rc;
352}
353
356{
357 xwer_t rc;
358 xwtm_t from, sleepto;
359
360 rc = xwds_w25qxx_check_idle(w25qxx, to);
361 from = xwtm_now();
362 while ((-EBUSY == rc) && (xwtm_cmp(to, from) > 0)) {
363 sleepto = xwtm_add_safely(from, period);
364 sleepto = xwtm_cmp(sleepto, to) > 0 ? to : sleepto;
365 rc = xwos_cthd_sleep_to(sleepto);
366 if (XWOK == rc) {
367 rc = xwds_w25qxx_check_idle(w25qxx, to);
368 from = xwtm_now();
369 }
370 }
371 return rc;
372}
373
376{
377 struct xwds_w25qxx_cmd cmd;
378 xwer_t rc;
379
380 XWDS_VALIDATE(w25qxx, "nullptr", -EFAULT);
381
382 cmd = w25qxx->cmdtbl[XWDS_W25QXX_CMD_UNIQUE_ID];
383 if (1 != cmd.existing) {
384 rc = -ENOTSUP;
385 goto err_not_support;
386 }
387 rc = xwds_w25qxx_ctrl(w25qxx,
388 cmd.instruction,
389 cmd.address_size, cmd.address,
390 cmd.dummy_cycles,
391 NULL, (xwu8_t *)uidbuf, 8, to);
392 if (rc < 0) {
393 goto err_w25qxx_ctrl;
394 }
395 *uidbuf = xwbop_re(xwu64_t, *uidbuf);
396 w25qxx->parameter.uid = *uidbuf;
397 return XWOK;
398
399err_w25qxx_ctrl:
400err_not_support:
401 return rc;
402}
403
406{
407 struct xwds_w25qxx_cmd cmd;
408 xwer_t rc;
409
410 XWDS_VALIDATE(w25qxx, "nullptr", -EFAULT);
411
413 if (1 != cmd.existing) {
414 rc = -ENOTSUP;
415 goto err_not_support;
416 }
417 rc = xwds_w25qxx_ctrl(w25qxx,
418 cmd.instruction,
419 cmd.address_size, cmd.address,
420 cmd.dummy_cycles,
421 NULL, (xwu8_t *)midbuf, 2, to);
422 if (rc < 0) {
423 goto err_w25qxx_ctrl;
424 }
425 *midbuf = xwbop_re(xwu16_t, *midbuf);
426 w25qxx->parameter.mid = *midbuf;
427 return XWOK;
428
429err_w25qxx_ctrl:
430err_not_support:
431 return rc;
432}
433
436{
437 struct xwds_w25qxx_cmd cmd;
438 xwer_t rc;
439
440 XWDS_VALIDATE(w25qxx, "nullptr", -EFAULT);
441
443 if (1 != cmd.existing) {
444 rc = -ENOTSUP;
445 goto err_not_support;
446 }
447 rc = xwds_w25qxx_ctrl(w25qxx,
448 cmd.instruction,
449 cmd.address_size, cmd.address,
450 cmd.dummy_cycles,
451 NULL, (xwu8_t *)jidbuf, 3, to);
452 if (rc < 0) {
453 goto err_w25qxx_ctrl;
454 }
455 *jidbuf = xwbop_re(xwu32_t, *jidbuf);
456 *jidbuf >>= 8;
457 w25qxx->parameter.jid = *jidbuf;
458 return XWOK;
459
460err_w25qxx_ctrl:
461err_not_support:
462 return rc;
463}
464
467 xwu8_t * rxb, xwsz_t * size, xwtm_t to)
468{
469 struct xwds_w25qxx_cmd cmd;
470 xwsz_t xfsize;
471 xwer_t rc;
472
473 XWDS_VALIDATE(w25qxx, "nullptr", -EFAULT);
474 XWDS_VALIDATE(rxb, "nullptr", -EFAULT);
475 XWDS_VALIDATE(size, "nullptr", -EFAULT);
476
477 xfsize = *size;
479 if (1 != cmd.existing) {
480 rc = -ENOTSUP;
481 goto err_not_support;
482 }
483 rc = xwds_w25qxx_ctrl(w25qxx,
484 cmd.instruction,
486 cmd.dummy_cycles,
487 NULL, rxb, xfsize, to);
488 if (rc < 0) {
489 goto err_w25qxx_ctrl;
490 }
491 *size = xfsize;
492 return XWOK;
493
494err_w25qxx_ctrl:
495err_not_support:
496 return rc;
497}
498
501 xwu8_t * txb, xwsz_t * size, xwtm_t to)
502{
503 struct xwds_w25qxx_cmd cmd;
504 xwsz_t xfsize;
505 xwer_t rc;
506
507 XWDS_VALIDATE(w25qxx, "nullptr", -EFAULT);
508 XWDS_VALIDATE(txb, "nullptr", -EFAULT);
509 XWDS_VALIDATE(size, "nullptr", -EFAULT);
510
511 rc = xwds_w25qxx_write_enable(w25qxx, to);
512 if (rc < 0) {
513 goto err_we;
514 }
515 rc = xwds_w25qxx_wait_idle(w25qxx, XWTM_MS(1), to);
516 if (rc < 0) {
517 goto err_wait_idle;
518 }
519 xfsize = *size;
521 if (1 != cmd.existing) {
522 rc = -ENOTSUP;
523 goto err_not_support;
524 }
525 rc = xwds_w25qxx_ctrl(w25qxx,
526 cmd.instruction,
528 cmd.dummy_cycles,
529 txb, NULL, xfsize, to);
530 if (rc < 0) {
531 goto err_w25qxx_ctrl;
532 }
533 *size = xfsize;
534 return XWOK;
535
536err_w25qxx_ctrl:
537err_not_support:
538err_wait_idle:
539 xwds_w25qxx_write_disable(w25qxx, to);
540err_we:
541 return rc;
542}
543
546{
547 struct xwds_w25qxx_cmd cmd;
548 xwer_t rc;
549
550 XWDS_VALIDATE(w25qxx, "nullptr", -EFAULT);
551
552 rc = xwds_w25qxx_write_enable(w25qxx, to);
553 if (rc < 0) {
554 goto err_we;
555 }
557 if (1 != cmd.existing) {
558 rc = -ENOTSUP;
559 goto err_not_support;
560 }
561 rc = xwds_w25qxx_ctrl(w25qxx,
562 cmd.instruction,
564 cmd.dummy_cycles,
565 NULL, NULL, 0, to);
566 if (rc < 0) {
567 goto err_w25qxx_ctrl;
568 }
569 rc = xwds_w25qxx_wait_idle(w25qxx, XWTM_MS(400), to);
570 if (rc < 0) {
571 goto err_chk_idle;
572 }
573 return XWOK;
574
575err_chk_idle:
576err_w25qxx_ctrl:
577err_not_support:
578 xwds_w25qxx_write_disable(w25qxx, to);
579err_we:
580 return rc;
581}
582
585{
586 struct xwds_w25qxx_cmd cmd;
587 xwer_t rc;
588
589 XWDS_VALIDATE(w25qxx, "nullptr", -EFAULT);
590
591 rc = xwds_w25qxx_write_enable(w25qxx, to);
592 if (rc < 0) {
593 goto err_we;
594 }
596 if (1 != cmd.existing) {
597 rc = -ENOTSUP;
598 goto err_not_support;
599 }
600 rc = xwds_w25qxx_ctrl(w25qxx,
601 cmd.instruction,
603 cmd.dummy_cycles,
604 NULL, NULL, 0, to);
605 if (rc < 0) {
606 goto err_w25qxx_ctrl;
607 }
608 rc = xwds_w25qxx_wait_idle(w25qxx, XWTM_MS(1600), to);
609 if (rc < 0) {
610 goto err_chk_idle;
611 }
612 return XWOK;
613
614err_chk_idle:
615err_w25qxx_ctrl:
616err_not_support:
617 xwds_w25qxx_write_disable(w25qxx, to);
618err_we:
619 return rc;
620}
621
624{
625 struct xwds_w25qxx_cmd cmd;
626 xwer_t rc;
627
628 XWDS_VALIDATE(w25qxx, "nullptr", -EFAULT);
629
630 rc = xwds_w25qxx_write_enable(w25qxx, to);
631 if (rc < 0) {
632 goto err_we;
633 }
635 if (1 != cmd.existing) {
636 rc = -ENOTSUP;
637 goto err_not_support;
638 }
639 rc = xwds_w25qxx_ctrl(w25qxx,
640 cmd.instruction,
642 cmd.dummy_cycles,
643 NULL, NULL, 0, to);
644 if (rc < 0) {
645 goto err_w25qxx_ctrl;
646 }
647 rc = xwds_w25qxx_wait_idle(w25qxx, XWTM_MS(2000), to);
648 if (rc < 0) {
649 goto err_chk_idle;
650 }
651 return XWOK;
652
653err_chk_idle:
654err_w25qxx_ctrl:
655err_not_support:
656 xwds_w25qxx_write_disable(w25qxx, to);
657err_we:
658 return rc;
659}
660
663{
664 struct xwds_w25qxx_cmd cmd;
665 xwer_t rc;
666
667 XWDS_VALIDATE(w25qxx, "nullptr", -EFAULT);
668
669 rc = xwds_w25qxx_write_enable(w25qxx, to);
670 if (rc < 0) {
671 goto err_we;
672 }
673 cmd = w25qxx->cmdtbl[XWDS_W25QXX_CMD_CHIP_ERASE];
674 if (1 != cmd.existing) {
675 rc = -ENOTSUP;
676 goto err_not_support;
677 }
678 rc = xwds_w25qxx_ctrl(w25qxx,
679 cmd.instruction,
680 cmd.address_size, cmd.address,
681 cmd.dummy_cycles,
682 NULL, NULL, 0, to);
683 if (rc < 0) {
684 goto err_w25qxx_ctrl;
685 }
686 rc = xwds_w25qxx_wait_idle(w25qxx, XWTM_MS(2000), to);
687 if (rc < 0) {
688 goto err_chk_idle;
689 }
690 return XWOK;
691
692err_chk_idle:
693err_w25qxx_ctrl:
694err_not_support:
695 xwds_w25qxx_write_disable(w25qxx, to);
696err_we:
697 return rc;
698}
#define xwds_cast(type, dev)
Definition standard.h:40
#define XWDS_VALIDATE(exp, errstr,...)
Definition standard.h:51
static xwer_t xwds_w25qxx_grab(struct xwds_w25qxx *w25qxx)
W25QXX API:增加对象的引用计数
Definition device.h:194
static xwer_t xwds_w25qxx_put(struct xwds_w25qxx *w25qxx)
W25QXX API:减少对象的引用计数
Definition device.h:206
@ XWDS_W25QXX_SR_2
Definition device.h:102
@ XWDS_W25QXX_SR_3
Definition device.h:103
@ XWDS_W25QXX_SR_NUM
Definition device.h:104
@ XWDS_W25QXX_SR_1
Definition device.h:101
@ XWDS_W25QXX_SR1_WEL
Definition device.h:112
@ XWDS_W25QXX_SR1_BUSY
Definition device.h:111
@ XWDS_W25QXX_CMD_64KBLOCK_ERASE
Definition device.h:62
@ XWDS_W25QXX_CMD_READ_STATUS_REG_2
Definition device.h:49
@ XWDS_W25QXX_CMD_CHIP_ERASE
Definition device.h:64
@ XWDS_W25QXX_CMD_UNIQUE_ID
Definition device.h:69
@ XWDS_W25QXX_CMD_RESET
Definition device.h:80
@ XWDS_W25QXX_CMD_ENABLE_RESET
Definition device.h:79
@ XWDS_W25QXX_CMD_PAGE_PROGRAM
Definition device.h:59
@ XWDS_W25QXX_CMD_WRITE_DISABLE
Definition device.h:45
@ XWDS_W25QXX_CMD_MANUFACTURER_DEVICE_ID
Definition device.h:70
@ XWDS_W25QXX_CMD_READ_STATUS_REG_1
Definition device.h:48
@ XWDS_W25QXX_CMD_READ_STATUS_REG_3
Definition device.h:50
@ XWDS_W25QXX_CMD_32KBLOCK_ERASE
Definition device.h:61
@ XWDS_W25QXX_CMD_SECTOR_ERASE
Definition device.h:63
@ XWDS_W25QXX_CMD_WRITE_ENABLE
Definition device.h:46
@ XWDS_W25QXX_CMD_JEDEC_DEVICE_ID
Definition device.h:71
@ XWDS_W25QXX_CMD_FAST_READ_DATA
Definition device.h:56
@ XWDS_W25Q128_MID
Definition device.h:93
@ XWDS_W25Q64_MID
Definition device.h:92
@ XWDS_W25Q80_MID
Definition device.h:89
@ XWDS_W25Q32_MID
Definition device.h:91
@ XWDS_W25Q256_MID
Definition device.h:94
@ XWDS_W25Q16_MID
Definition device.h:90
#define __xwbsp_code
Definition compiler.h:231
#define __xwbsp_api
Definition compiler.h:235
#define __xwcc_unlikely(x)
Definition compiler.h:119
#define ECHRNG
Channel number out of range
Definition errno.h:67
#define EINVAL
Invalid argument
Definition errno.h:52
#define EFAULT
Bad address
Definition errno.h:44
#define XWOK
No error
Definition errno.h:182
#define EBUSY
Device or resource busy
Definition errno.h:46
#define ENOTSUP
Not supported
Definition errno.h:147
#define EACCES
Permission denied
Definition errno.h:43
static __xwcc_inline xwtm_t xwtm_add_safely(const xwtm_t a, const xwtm_t b)
将两个系统时间相加,并检查溢出
Definition type.h:822
xws64_t xwtm_t
XWOS系统时间 (有符号)
Definition type.h:742
static __xwcc_inline xwer_t xwtm_cmp(const xwtm_t a, const xwtm_t b)
比较两个系统时间
Definition type.h:867
#define XWTM_MS(ms)
系统时间的单位:毫秒
Definition type.h:786
signed long xwer_t
Definition type.h:554
#define NULL
Definition type.h:28
unsigned long xwsz_t
Definition type.h:339
uint8_t xwu8_t
Definition type.h:194
uint64_t xwu64_t
Definition type.h:303
uint16_t xwu16_t
Definition type.h:230
uint32_t xwu32_t
Definition type.h:266
#define xwbop_re(type, data)
XWOS BOPLIB:将数据的大小端翻转
Definition xwbop.h:145
#define XWOS_UNUSED(x)
Definition standard.h:66
static xwer_t xwos_cthd_sleep_to(xwtm_t to)
XWOS API:线程睡眠到一个时间点
Definition thd.h:716
static xwtm_t xwtm_now(void)
XWOS API:获取当前CPU的系统时间点
Definition time.h:57
SPI Flash W25Qxx Device
xwer_t xwds_w25qxx_read_uid(struct xwds_w25qxx *w25qxx, xwu64_t *uidbuf, xwtm_t to)
W25QXX API:读取W25QXX的UID
Definition driver.c:375
xwer_t xwds_w25qxx_write(struct xwds_w25qxx *w25qxx, xwu32_t address, xwu8_t *txb, xwsz_t *size, xwtm_t to)
W25QXX API:向W25QXX写入数据
Definition driver.c:500
xwer_t xwds_w25qxx_ctrl(struct xwds_w25qxx *w25qxx, xwu8_t instruction, xwu8_t address_size, xwu32_t address, xwu32_t dummy_cycles, const xwu8_t txd[], xwu8_t *rxb, xwsz_t size, xwtm_t to)
W25QXX API:向W25QXX发送指令
Definition driver.c:76
xwer_t xwds_w25qxx_read_mid(struct xwds_w25qxx *w25qxx, xwu16_t *midbuf, xwtm_t to)
W25QXX API:读取W25QXX的MID
Definition driver.c:405
xwer_t xwds_w25qxx_wait_idle(struct xwds_w25qxx *w25qxx, xwtm_t period, xwtm_t to)
W25QXX API:等待W25QXX是否空闲
Definition driver.c:355
xwer_t xwds_w25qxx_reset(struct xwds_w25qxx *w25qxx, xwtm_t to)
W25QXX API:向W25QXX发送复位命令
Definition driver.c:142
xwer_t xwds_w25qxx_write_disable(struct xwds_w25qxx *w25qxx, xwtm_t to)
W25QXX API:关闭W25QXX的写操作
Definition driver.c:268
xwer_t xwds_w25qxx_read(struct xwds_w25qxx *w25qxx, xwu32_t address, xwu8_t *rxb, xwsz_t *size, xwtm_t to)
W25QXX API:向W25QXX读取数据
Definition driver.c:466
xwer_t xwds_w25qxx_check_idle(struct xwds_w25qxx *w25qxx, xwtm_t to)
W25QXX API:检测W25QXX是否空闲
Definition driver.c:338
xwer_t xwds_w25qxx_write_enable(struct xwds_w25qxx *w25qxx, xwtm_t to)
W25QXX API:开启W25QXX的写操作
Definition driver.c:228
xwer_t xwds_w25qxx_erase_32kblk(struct xwds_w25qxx *w25qxx, xwu32_t address, xwtm_t to)
W25QXX API:擦除W25QXX的32KiB的块
Definition driver.c:584
xwer_t xwds_w25qxx_drv_start(struct xwds_device *dev)
W25QXX基本驱动:启动设备
Definition driver.c:30
xwer_t xwds_w25qxx_read_jid(struct xwds_w25qxx *w25qxx, xwu32_t *jidbuf, xwtm_t to)
W25QXX API:读取W25QXX的JID
Definition driver.c:435
xwer_t xwds_w25qxx_erase_64kblk(struct xwds_w25qxx *w25qxx, xwu32_t address, xwtm_t to)
W25QXX API:擦除W25QXX的64KiB的块
Definition driver.c:623
xwer_t xwds_w25qxx_drv_suspend(struct xwds_device *dev)
W25QXX基本驱动:继续设备
Definition driver.c:68
xwer_t xwds_w25qxx_read_sr(struct xwds_w25qxx *w25qxx, xwu32_t sridx, xwu8_t *srbuf, xwtm_t to)
W25QXX API:读取W25QXX的SR寄存器
Definition driver.c:296
xwer_t xwds_w25qxx_drv_stop(struct xwds_device *dev)
W25QXX基本驱动:停止设备
Definition driver.c:54
xwer_t xwds_w25qxx_erase_sector(struct xwds_w25qxx *w25qxx, xwu32_t address, xwtm_t to)
W25QXX API:擦除W25QXX的sector
Definition driver.c:545
xwer_t xwds_w25qxx_init_parameter(struct xwds_w25qxx *w25qxx, xwtm_t to)
W25QXX API:初始化W25QXX的参数
Definition driver.c:178
xwer_t xwds_w25qxx_drv_resume(struct xwds_device *dev)
W25QXX基本驱动:暂停设备
Definition driver.c:62
xwer_t xwds_w25qxx_erase_chip(struct xwds_w25qxx *w25qxx, xwtm_t to)
W25QXX API:擦除W25QXX的全部数据
Definition driver.c:662
SPI Flash W25Qxx Driver
玄武设备栈:SPI:外设
设备(所有设备的基类)
Definition device.h:127
const struct xwds_driver * drv
Definition device.h:133
struct xwds_device dev
Definition peripheral.h:48
struct xwds_spim * bus
Definition peripheral.h:51
W25QXX Flash 命令
Definition device.h:151
xwu32_t dummy_cycles
Definition device.h:156
xwu32_t address
Definition device.h:155
xwu8_t existing
Definition device.h:152
xwu8_t instruction
Definition device.h:153
xwu8_t address_size
Definition device.h:154
W25QXX驱动函数表
Definition driver.h:37
xwer_t(* io)(struct xwds_w25qxx *, xwu8_t *, xwu8_t *, xwsz_t *, xwtm_t)
Definition driver.h:39
W25QXX Flash 设备
Definition device.h:172
struct xwds_spip spip
Definition device.h:173
struct xwds_w25qxx_parameter parameter
Definition device.h:176
xwu8_t rxq[256U+16]
Definition device.h:181
const struct xwds_w25qxx_cmd * cmdtbl
Definition device.h:177
xwu8_t txq[256U+16]
Definition device.h:180
操作系统抽象层:线程
XWOS的标准头文件