forked from libdriver/w25qxx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
driver_w25qxx_advance.c
969 lines (914 loc) · 22 KB
/
driver_w25qxx_advance.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
/**
* Copyright (c) 2015 - present LibDriver All rights reserved
*
* The MIT License (MIT)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* @file driver_w25qxx_advance.c
* @brief driver w25qxx advance source file
* @version 1.0.0
* @author Shifeng Li
* @date 2021-07-15
*
* <h3>history</h3>
* <table>
* <tr><th>Date <th>Version <th>Author <th>Description
* <tr><td>2021/07/15 <td>1.0 <td>Shifeng Li <td>first upload
* </table>
*/
#include "driver_w25qxx_advance.h"
static w25qxx_handle_t gs_handle; /**< w25qxx handle */
/**
* @brief advance example init
* @param[in] type is the chip type
* @param[in] interface is the chip interface
* @param[in] dual_quad_spi_enable is a bool value
* @return status code
* - 0 success
* - 1 init failed
* @note none
*/
uint8_t w25qxx_advance_init(w25qxx_type_t type, w25qxx_interface_t interface, w25qxx_bool_t dual_quad_spi_enable)
{
volatile uint8_t res;
/* link interface function */
DRIVER_W25QXX_LINK_INIT(&gs_handle, w25qxx_handle_t);
DRIVER_W25QXX_LINK_SPI_QSPI_INIT(&gs_handle, w25qxx_interface_spi_qspi_init);
DRIVER_W25QXX_LINK_SPI_QSPI_DEINIT(&gs_handle, w25qxx_interface_spi_qspi_deinit);
DRIVER_W25QXX_LINK_SPI_QSPI_WRITE_READ(&gs_handle, w25qxx_interface_spi_qspi_write_read);
DRIVER_W25QXX_LINK_DELAY_MS(&gs_handle, w25qxx_interface_delay_ms);
DRIVER_W25QXX_LINK_DELAY_US(&gs_handle, w25qxx_interface_delay_us);
DRIVER_W25QXX_LINK_DEBUG_PRINT(&gs_handle, w25qxx_interface_debug_print);
/* set chip type */
res = w25qxx_set_type(&gs_handle, type);
if (res)
{
w25qxx_interface_debug_print("w25qxx: set type failed.\n");
return 1;
}
/* set chip interface */
res = w25qxx_set_interface(&gs_handle, interface);
if (res)
{
w25qxx_interface_debug_print("w25qxx: set interface failed.\n");
return 1;
}
/* set dual quad spi */
res = w25qxx_set_dual_quad_spi(&gs_handle, dual_quad_spi_enable);
if (res)
{
w25qxx_interface_debug_print("w25qxx: set dual quad spi failed.\n");
w25qxx_deinit(&gs_handle);
return 1;
}
/* chip init */
res = w25qxx_init(&gs_handle);
if (res)
{
w25qxx_interface_debug_print("w25qxx: init failed.\n");
return 1;
}
else
{
if (type >= W25Q256)
{
res = w25qxx_set_address_mode(&gs_handle, W25QXX_ADDRESS_MODE_4_BYTE);
if (res)
{
w25qxx_interface_debug_print("w25qxx: set address mode failed.\n");
w25qxx_deinit(&gs_handle);
return 1;
}
}
return 0;
}
}
/**
* @brief advance example deinit
* @return status code
* - 0 success
* - 1 deinit failed
* @note none
*/
uint8_t w25qxx_advance_deinit(void)
{
if (w25qxx_deinit(&gs_handle))
{
return 1;
}
else
{
return 0;
}
}
/**
* @brief advance example write
* @param[in] addr is the write address
* @param[in] *data points to a data buffer
* @param[in] len is the data length
* @return status code
* - 0 success
* - 1 write failed
* @note none
*/
uint8_t w25qxx_advance_write(uint32_t addr, uint8_t *data, uint32_t len)
{
if (w25qxx_write(&gs_handle, addr, data, len))
{
return 1;
}
else
{
return 0;
}
}
/**
* @brief advance example read
* @param[in] addr is the read address
* @param[out] *data points to a data buffer
* @param[in] len is the data length
* @return status code
* - 0 success
* - 1 read failed
* @note none
*/
uint8_t w25qxx_advance_read(uint32_t addr, uint8_t *data, uint32_t len)
{
if (w25qxx_read(&gs_handle, addr, data, len))
{
return 1;
}
else
{
return 0;
}
}
/**
* @brief advance example power down
* @return status code
* - 0 success
* - 1 power down failed
* @note none
*/
uint8_t w25qxx_advance_power_down(void)
{
if (w25qxx_power_down(&gs_handle))
{
return 1;
}
else
{
return 0;
}
}
/**
* @brief advance example wake up
* @return status code
* - 0 success
* - 1 wake up failed
* @note none
*/
uint8_t w25qxx_advance_wake_up(void)
{
if (w25qxx_release_power_down(&gs_handle))
{
return 1;
}
else
{
return 0;
}
}
/**
* @brief advance example chip erase
* @return status code
* - 0 success
* - 1 chip erase failed
* @note none
*/
uint8_t w25qxx_advance_chip_erase(void)
{
if (w25qxx_chip_erase(&gs_handle))
{
return 1;
}
else
{
return 0;
}
}
/**
* @brief advance example get the manufacturer && device id information
* @param[out] *manufacturer points to a manufacturer buffer
* @param[out] *device_id points to a device id buffer
* @return status code
* - 0 success
* - 1 get manufacturer device id failed
* @note none
*/
uint8_t w25qxx_advance_get_id(uint8_t *manufacturer, uint8_t *device_id)
{
if (w25qxx_get_manufacturer_device_id(&gs_handle, manufacturer, device_id))
{
return 1;
}
else
{
return 0;
}
}
/**
* @brief advance example page program
* @param[in] addr is the programming address
* @param[in] *data points to a data buffer
* @param[in] len is the data length
* @return status code
* - 0 success
* - 1 page program failed
* @note len <= 256
*/
uint8_t w25qxx_advance_page_program(uint32_t addr, uint8_t *data, uint16_t len)
{
if (w25qxx_page_program(&gs_handle, addr, data, len))
{
return 1;
}
else
{
return 0;
}
}
/**
* @brief advance example erase the 4k sector
* @param[in] addr is the erase address
* @return status code
* - 0 success
* - 1 sector erase 4k failed
* @note none
*/
uint8_t w25qxx_advance_sector_erase_4k(uint32_t addr)
{
if (w25qxx_sector_erase_4k(&gs_handle, addr))
{
return 1;
}
else
{
return 0;
}
}
/**
* @brief advance example erase the 32k block
* @param[in] addr is the erase address
* @return status code
* - 0 success
* - 1 block erase 32k failed
* @note none
*/
uint8_t w25qxx_advance_block_erase_32k(uint32_t addr)
{
if (w25qxx_block_erase_32k(&gs_handle, addr))
{
return 1;
}
else
{
return 0;
}
}
/**
* @brief advance example erase the 64k block
* @param[in] addr is the erase address
* @return status code
* - 0 success
* - 1 block erase 64k failed
* @note none
*/
uint8_t w25qxx_advance_block_erase_64k(uint32_t addr)
{
if (w25qxx_block_erase_64k(&gs_handle, addr))
{
return 1;
}
else
{
return 0;
}
}
/**
* @brief advance example read in the fast mode
* @param[in] addr is the read address
* @param[out] *data points to a data buffer
* @param[in] len is the data length
* @return status code
* - 0 success
* - 1 fast read failed
* @note none
*/
uint8_t w25qxx_advance_fast_read(uint32_t addr, uint8_t *data, uint32_t len)
{
if (w25qxx_fast_read(&gs_handle, addr, data, len))
{
return 1;
}
else
{
return 0;
}
}
/**
* @brief advance example read only in the spi interface
* @param[in] addr is the read address
* @param[out] *data points to a data buffer
* @param[in] len is the data length
* @return status code
* - 0 success
* - 1 only spi read failed
* @note none
*/
uint8_t w25qxx_advance_only_spi_read(uint32_t addr, uint8_t *data, uint32_t len)
{
if (w25qxx_only_spi_read(&gs_handle, addr, data, len))
{
return 1;
}
else
{
return 0;
}
}
/**
* @brief advance example fast read only in the spi dual output interface
* @param[in] addr is the read address
* @param[out] *data points to a data buffer
* @param[in] len is the data length
* @return status code
* - 0 success
* - 1 read failed
* @note none
*/
uint8_t w25qxx_advance_only_spi_fast_read_dual_output(uint32_t addr, uint8_t *data, uint32_t len)
{
if (w25qxx_fast_read_dual_output(&gs_handle, addr, data, len))
{
return 1;
}
else
{
return 0;
}
}
/**
* @brief advance example fast read only in the spi quad output interface
* @param[in] addr is the read address
* @param[out] *data points to a data buffer
* @param[in] len is the data length
* @return status code
* - 0 success
* - 1 read failed
* @note none
*/
uint8_t w25qxx_advance_only_spi_fast_read_quad_output(uint32_t addr, uint8_t *data, uint32_t len)
{
if (w25qxx_fast_read_quad_output(&gs_handle, addr, data, len))
{
return 1;
}
else
{
return 0;
}
}
/**
* @brief advance example fast read only in the spi dual io interface
* @param[in] addr is the read address
* @param[out] *data points to a data buffer
* @param[in] len is the data length
* @return status code
* - 0 success
* - 1 read failed
* @note none
*/
uint8_t w25qxx_advance_only_spi_fast_read_dual_io(uint32_t addr, uint8_t *data, uint32_t len)
{
if (w25qxx_fast_read_dual_io(&gs_handle, addr, data, len))
{
return 1;
}
else
{
return 0;
}
}
/**
* @brief advance example fast read only in the spi quad io interface
* @param[in] addr is the read address
* @param[out] *data points to a data buffer
* @param[in] len is the data length
* @return status code
* - 0 success
* - 1 read failed
* @note none
*/
uint8_t w25qxx_advance_only_spi_fast_read_quad_io(uint32_t addr, uint8_t *data, uint32_t len)
{
if (w25qxx_fast_read_quad_io(&gs_handle, addr, data, len))
{
return 1;
}
else
{
return 0;
}
}
/**
* @brief advance example word read only in the spi quad io interface
* @param[in] addr is the read address
* @param[out] *data points to a data buffer
* @param[in] len is the data length
* @return status code
* - 0 success
* - 1 read failed
* @note none
*/
uint8_t w25qxx_advance_only_spi_word_read_quad_io(uint32_t addr, uint8_t *data, uint32_t len)
{
if (w25qxx_word_read_quad_io(&gs_handle, addr, data, len))
{
return 1;
}
else
{
return 0;
}
}
/**
* @brief advance example octal word read only in the spi quad io interface
* @param[in] addr is the read address
* @param[out] *data points to a data buffer
* @param[in] len is the data length
* @return status code
* - 0 success
* - 1 read failed
* @note none
*/
uint8_t w25qxx_advance_only_spi_octal_word_read_quad_io(uint32_t addr, uint8_t *data, uint32_t len)
{
if (w25qxx_octal_word_read_quad_io(&gs_handle, addr, data, len))
{
return 1;
}
else
{
return 0;
}
}
/**
* @brief advance example quad page program only in the spi quad input interface
* @param[in] addr is the programming address
* @param[in] *data points to a data buffer
* @param[in] len is the data length
* @return status code
* - 0 success
* - 1 quad page program failed
* @note len <= 256
*/
uint8_t w25qxx_advance_only_spi_page_program_quad_input(uint32_t addr, uint8_t *data, uint16_t len)
{
if (w25qxx_page_program_quad_input(&gs_handle, addr, data, len))
{
return 1;
}
else
{
return 0;
}
}
/**
* @brief advance example get the status 1
* @param[out] *status points to a status buffer
* @return status code
* - 0 success
* - 1 get status 1 failed
* @note none
*/
uint8_t w25qxx_advance_get_status1(uint8_t *status)
{
if (w25qxx_get_status1(&gs_handle, status))
{
return 1;
}
else
{
return 0;
}
}
/**
* @brief advance example get the status 2
* @param[out] *status points to a status buffer
* @return status code
* - 0 success
* - 1 get status 2 failed
* @note none
*/
uint8_t w25qxx_advance_get_status2(uint8_t *status)
{
if (w25qxx_get_status2(&gs_handle, status))
{
return 1;
}
else
{
return 0;
}
}
/**
* @brief advance example get the status 3
* @param[out] *status points to a status buffer
* @return status code
* - 0 success
* - 1 get status 3 failed
* @note none
*/
uint8_t w25qxx_advance_get_status3(uint8_t *status)
{
if (w25qxx_get_status3(&gs_handle, status))
{
return 1;
}
else
{
return 0;
}
}
/**
* @brief advance example set the status 1
* @param[in] status is the set status
* @return status code
* - 0 success
* - 1 set status 1 failed
* @note none
*/
uint8_t w25qxx_advance_set_status1(uint8_t status)
{
if (w25qxx_set_status1(&gs_handle, status))
{
return 1;
}
else
{
return 0;
}
}
/**
* @brief advance example set the status 2
* @param[in] status is the set status
* @return status code
* - 0 success
* - 1 set status 2 failed
* @note none
*/
uint8_t w25qxx_advance_set_status2(uint8_t status)
{
if (w25qxx_set_status2(&gs_handle, status))
{
return 1;
}
else
{
return 0;
}
}
/**
* @brief advance example set the status 3
* @param[in] status is the set status
* @return status code
* - 0 success
* - 1 set status 3 failed
* @note none
*/
uint8_t w25qxx_advance_set_status3(uint8_t status)
{
if (w25qxx_set_status3(&gs_handle, status))
{
return 1;
}
else
{
return 0;
}
}
/**
* @brief advance example get the manufacturer && device id information only in the spi dual io interface
* @param[out] *manufacturer points to a manufacturer buffer
* @param[out] *device_id points to a device id buffer
* @return status code
* - 0 success
* - 1 get manufacturer device id dual io failed
* @note none
*/
uint8_t w25qxx_advance_only_spi_get_manufacturer_device_id_dual_io(uint8_t *manufacturer, uint8_t *device_id)
{
if (w25qxx_get_manufacturer_device_id_dual_io(&gs_handle, manufacturer, device_id))
{
return 1;
}
else
{
return 0;
}
}
/**
* @brief advance example get the manufacturer && device id information only in the spi quad io interface
* @param[out] *manufacturer points to a manufacturer buffer
* @param[out] *device_id points to a device id buffer
* @return status code
* - 0 success
* - 1 get manufacturer device id quad io failed
* @note none
*/
uint8_t w25qxx_advance_only_spi_get_manufacturer_device_id_quad_io(uint8_t *manufacturer, uint8_t *device_id)
{
if (w25qxx_get_manufacturer_device_id_quad_io(&gs_handle, manufacturer, device_id))
{
return 1;
}
else
{
return 0;
}
}
/**
* @brief advance example get the jedec id information
* @param[out] *manufacturer points to a manufacturer buffer
* @param[out] *device_id points to a device id buffer
* @return status code
* - 0 success
* - 1 get jedec id failed
* @note none
*/
uint8_t w25qxx_advance_get_get_jedec_id(uint8_t *manufacturer, uint8_t device_id[2])
{
if (w25qxx_get_jedec_id(&gs_handle, manufacturer, device_id))
{
return 1;
}
else
{
return 0;
}
}
/**
* @brief advance example global block lock
* @return status code
* - 0 success
* - 1 global block lock failed
* @note none
*/
uint8_t w25qxx_advance_global_block_lock(void)
{
if (w25qxx_global_block_lock(&gs_handle))
{
return 1;
}
else
{
return 0;
}
}
/**
* @brief advance example global block unlock
* @return status code
* - 0 success
* - 1 global block unlock failed
* @note none
*/
uint8_t w25qxx_advance_global_block_unlock(void)
{
if (w25qxx_global_block_unlock(&gs_handle))
{
return 1;
}
else
{
return 0;
}
}
/**
* @brief advance example lock the individual block
* @param[in] addr is the block address
* @return status code
* - 0 success
* - 1 individual block lock failed
* @note none
*/
uint8_t w25qxx_advance_individual_block_lock(uint32_t addr)
{
if (w25qxx_individual_block_lock(&gs_handle, addr))
{
return 1;
}
else
{
return 0;
}
}
/**
* @brief advance example unlock the individual block
* @param[in] addr is the block address
* @return status code
* - 0 success
* - 1 individual block unlock failed
* @note none
*/
uint8_t w25qxx_advance_individual_block_unlock(uint32_t addr)
{
if (w25qxx_individual_block_unlock(&gs_handle, addr))
{
return 1;
}
else
{
return 0;
}
}
/**
* @brief advance example read the block lock
* @param[in] addr is the block address
* @param[out] *value points to a value buffer
* @return status code
* - 0 success
* - 1 read block lock failed
* @note none
*/
uint8_t w25qxx_advance_read_block_lock(uint32_t addr, uint8_t *value)
{
if (w25qxx_read_block_lock(&gs_handle, addr, value))
{
return 1;
}
else
{
return 0;
}
}
/**
* @brief advance example reset
* @return status code
* - 0 success
* - 1 reset failed
* @note none
*/
uint8_t w25qxx_advance_reset(void)
{
if (w25qxx_enable_reset(&gs_handle))
{
return 1;
}
if (w25qxx_reset_device(&gs_handle))
{
return 1;
}
else
{
return 0;
}
}
/**
* @brief advance example set the read parameters only in the qspi interface
* @param[in] dummy is the qspi read dummy
* @param[in] length is the qspi read wrap length
* @return status code
* - 0 success
* - 1 set read parameters failed
* @note none
*/
uint8_t w25qxx_advance_only_qspi_set_read_parameters(w25qxx_qspi_read_dummy_t dummy, w25qxx_qspi_read_wrap_length_t length)
{
if (w25qxx_set_read_parameters(&gs_handle, dummy, length))
{
return 1;
}
else
{
return 0;
}
}
/**
* @brief advance example get the unique id only in the spi interface
* @param[out] *id points to a id buffer
* @return status code
* - 0 success
* - 1 get the unique id failed
* @note none
*/
uint8_t w25qxx_advance_only_spi_get_unique_id(uint8_t id[8])
{
if (w25qxx_get_unique_id(&gs_handle, id))
{
return 1;
}
else
{
return 0;
}
}
/**
* @brief advance example get the sfdp only in the spi interface
* @param[out] *sfdp points to a sfdp buffer
* @return status code
* - 0 success
* - 1 get the sfdp failed
* @note none
*/
uint8_t w25qxx_advance_only_spi_get_sfdp(uint8_t sfdp[256])
{
if (w25qxx_get_sfdp(&gs_handle, sfdp))
{
return 1;
}
else
{
return 0;
}
}
/**
* @brief advance example write the security register only in the spi interface
* @param[in] num is the security register number
* @param[in] *data points to a data buffer
* @return status code
* - 0 success
* - 1 write security register failed
* @note none
*/
uint8_t w25qxx_advance_only_spi_write_security_register(w25qxx_security_register_t num, uint8_t data[256])
{
if (w25qxx_erase_security_register(&gs_handle, num))
{
return 1;
}
if (w25qxx_program_security_register(&gs_handle, num, data))
{
return 1;
}
else
{
return 0;
}
}
/**
* @brief advance example read the security register only in the spi interface
* @param[in] num is the security register number
* @param[out] *data points to a data buffer
* @return status code
* - 0 success
* - 1 read security register failed
* @note none
*/
uint8_t w25qxx_advance_only_spi_read_security_register(w25qxx_security_register_t num, uint8_t data[256])
{
if (w25qxx_read_security_register(&gs_handle, num, data))
{
return 1;
}
else
{
return 0;
}
}
/**
* @brief advance example set the burst with wrap only in the spi interface
* @param[in] wrap is the burst wrap
* @return status code
* - 0 success
* - 1 set burst with wrap failed
* @note none
*/
uint8_t w25qxx_advance_only_spi_set_burst_with_wrap(w25qxx_burst_wrap_t wrap)
{
if (w25qxx_set_burst_with_wrap(&gs_handle, wrap))
{
return 1;
}
else
{
return 0;
}
}