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
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
/*
****************************************************************************
PROJECT : HYPB driver
FILE : $Id: r_hypb_api.h 15479 2018-01-11 14:04:31Z florian.zimmermann $
============================================================================
DESCRIPTION
Driver for the HYPB(HyperBus Controller) macro
============================================================================
C O P Y R I G H T
============================================================================
Copyright (c) 2016
by
Renesas Electronics (Europe) GmbH.
Arcadiastrasse 10
D-40472 Duesseldorf
Germany
All rights reserved.
============================================================================
DISCLAIMER
LICENSEE has read, understood and accepted the terms and conditions defined in
the license agreement, especially the usage rights. In any case, it is
LICENSEE's responsibility to make sure that any user of the software complies
with the terms and conditions of the signed license agreement.
****************************************************************************
*/
/***************************************************************************
Title: HYPB Driver API
HYPB (HyperBus Controller) driver API.
HYPB driver controls HYPB H/W macro and accesses only register of HYPB H/W macro.
An application using HYPB driver should include the following header files.
* r_typedefs.h
* r_hypb_api.h
*/
/***************************************************************************
Section: Definition of a term
*/
/***************************************************************************
Topics: xxxx(@ yyyy)
It means the xxxx is the member of the structure yyyy.
Topics: Word
1 word is 16bits. Word-address is 16bit address. Word-size is 16bit size.
WordSize=1 means 2Byte. WordSize=2 means 4Byte.
*/
#ifndef R_HYPB_API_H
#define R_HYPB_API_H
#ifdef __cplusplus
extern "C" {
#endif
/***************************************************************************
Section: Global defines
*/
/***************************************************************************
Group: Constants
*/
/***************************************************************************
Constants: API Version
Description:
This constant is the value which shows the version information of the HYPB driver.
It refers at the <R_HYPB_VersionStringGet> function.
Values:
R_HYPB_VERSION_HI - This constant is the high byte of the version information.
It is major version information.
R_HYPB_VERSION_LO - This constant is the low byte of the version information.
It is minor version information.
*/
#define R_HYPB_VERSION_HI (1)
#define R_HYPB_VERSION_LO (1)
/***************************************************************************
Constants: Internal definition for Command Option
Description:
These flags are used to <Command Option>.
Values:
R_HYPB_CMD_WRITE - Use Write transaction.
R_HYPB_CMD_READ - Use Read transaction.
R_HYPB_CMD_SIZE_16 - Size is 16 bit.
R_HYPB_CMD_SIZE_32 - Size is 32 bit.
R_HYPB_CMD_SIZE_64 - Size is 64 bit.
R_HYPB_CMD_SIZE_MASK - Mask for size get.
R_HYPB_CMD_APPROPRIATE - Size is appropriate (16/32/64) bit.
*/
#define R_HYPB_CMD_WRITE (0x0000uL)
#define R_HYPB_CMD_READ (0x8000uL)
#define R_HYPB_CMD_SIZE_16 (0x0000uL)
#define R_HYPB_CMD_SIZE_32 (0x0001uL)
#define R_HYPB_CMD_SIZE_64 (0x0002uL)
#define R_HYPB_CMD_SIZE_MASK (0x0003uL)
#define R_HYPB_CMD_APPROPRIATE (0x0004uL)
/***************************************************************************
Constants: Command Option
Description:
HYPB command option flags. These flags are used to OpeFlags(@ <r_hypb_CmdTransaction_t>).
Values:
R_HYPB_CMD_WRITE16 - Use Write transaction. Write size is 16 bit. It is default behavior.
R_HYPB_CMD_WRITE_A - Use Write transaction. Write size is appropriate (16/32/64) bit.
This flag can be set with R_HYPB_CMD_SET_DATA.
R_HYPB_CMD_READ16 - Use Read transaction. Read size is 16 bit.
R_HYPB_CMD_READ32 - Use Read transaction. Read size is 32 bit.
R_HYPB_CMD_READ64 - Use Read transaction. Read size is 64 bit.
R_HYPB_CMD_SET_ADDR - Update Address member to word-address.
R_HYPB_CMD_SET_SA - Update Address member to sector address.
This flag can be set when SectorSize(@ <r_hypb_Config_t>) is not 0.
R_HYPB_CMD_SET_DATA - Update WriteData member to write data.
R_HYPB_CMD_SET_COUNT - Update WriteData member to loop count.
R_HYPB_CMD_LOOP - The transaction is executed repeatedly.
*/
#define R_HYPB_CMD_WRITE16 (R_HYPB_CMD_WRITE | R_HYPB_CMD_SIZE_16)
#define R_HYPB_CMD_WRITE_A (R_HYPB_CMD_WRITE | R_HYPB_CMD_APPROPRIATE)
#define R_HYPB_CMD_READ16 (R_HYPB_CMD_READ | R_HYPB_CMD_SIZE_16)
#define R_HYPB_CMD_READ32 (R_HYPB_CMD_READ | R_HYPB_CMD_SIZE_32)
#define R_HYPB_CMD_READ64 (R_HYPB_CMD_READ | R_HYPB_CMD_SIZE_64)
#define R_HYPB_CMD_SET_ADDR (0x0010uL)
#define R_HYPB_CMD_SET_SA (0x0020uL)
#define R_HYPB_CMD_SET_DATA (0x0040uL)
#define R_HYPB_CMD_SET_COUNT (0x0080uL)
#define R_HYPB_CMD_LOOP (0x0100uL)
/***************************************************************************
Section: Global Types
*/
/***************************************************************************
Group: Enumerations and Types
*/
/***************************************************************************
Enum: r_hypb_Error_t
Description:
HYPB driver error code.
If an error occurs, these enumerations give information about the reason.
Values:
R_HYPB_ERR_OK - No error has occurred.
R_HYPB_ERR_NG - An error has occurred, but no specific error code
is defined for it.
R_HYPB_ERR_PARAM_INCORRECT - A parameter is incorrect.
R_HYPB_ERR_RANGE_UNIT - Unit number is out of range.
R_HYPB_ERR_RANGE_PARAM - A parameter is out of range.
R_HYPB_ERR_NOT_ACCEPTABLE - A function was called in an incorrect state.
R_HYPB_ERR_DEVICE - HYPB driver is not applicable to target d1x device.
R_HYPB_ERR_FATAL_OS - Fatal error has occurred at OS interface.
R_HYPB_ERR_FATAL_HW - Fatal error has occurred at H/W.
R_HYPB_ERR_COMMAND - A command is not supported.
R_HYPB_ERR_LATENCY - A latency value is invalid.
R_HYPB_ERR_PROTECTED - A process is aborted because of memory protection.
R_HYPB_ERR_ABORTED - A process is aborted because of other reason.
R_HYPB_ERR_TIMEOUT - Status polling is timeout.
*/
typedef enum
{
R_HYPB_ERR_OK = 0,
R_HYPB_ERR_NG,
R_HYPB_ERR_PARAM_INCORRECT,
R_HYPB_ERR_RANGE_UNIT,
R_HYPB_ERR_RANGE_PARAM,
R_HYPB_ERR_NOT_ACCEPTABLE,
R_HYPB_ERR_DEVICE,
R_HYPB_ERR_FATAL_OS,
R_HYPB_ERR_FATAL_HW,
R_HYPB_ERR_COMMAND,
R_HYPB_ERR_LATENCY,
R_HYPB_ERR_PROTECTED,
R_HYPB_ERR_ABORTED,
R_HYPB_ERR_TIMEOUT
} r_hypb_Error_t;
/***************************************************************************
Enum: r_hypb_DeviceType_t
Description:
This type describes the control device type.
Values:
R_HYPB_DEVICE_FLASH - Hyper Flash.
R_HYPB_DEVICE_RAM - Hyper RAM.
Note: Hyper RAM should consist of single die.
*/
typedef enum
{
R_HYPB_DEVICE_FLASH = 0,
R_HYPB_DEVICE_RAM
} r_hypb_DeviceType_t;
/***************************************************************************
Enum: r_hypb_OperatingMode_t
Description:
This type describes the operating mode.
Values:
R_HYPB_MODE_EX_SPACE - External address space mode.
In case of Hyper Flash, only Read memory access is possible.
In case of Hyper RAM, Read/Write memory access is possible.
R_HYPB_MODE_MANUAL - Manual mode.
In case of Hyper Flash, Read/Write access to register/memory area
is possible.
In case of Hyper RAM, Read/Write access to register area is
possible.
*/
typedef enum
{
R_HYPB_MODE_EX_SPACE = 0,
R_HYPB_MODE_MANUAL
} r_hypb_OperatingMode_t;
/***************************************************************************
Enum: r_hypb_ParamSecPos_t
Description:
This type describes the position of parameter-sector.
Values:
R_HYPB_PARAM_SEC_TOP - Parameter-sector is mapped into the top of the first sector
of Hyper RAM/flash memory.
R_HYPB_PARAM_SEC_BOTTOM - Parameter-sector is mapped into the bottom of the last sector
of Hyper RAM/flash memory.
*/
typedef enum
{
R_HYPB_PARAM_SEC_TOP = 0,
R_HYPB_PARAM_SEC_BOTTOM
} r_hypb_ParamSecPos_t;
/***************************************************************************
Enum: r_hypb_ProtectionMode_t
Description:
This type describes the protection mode of the hyper RAM/flash memory.
Values:
R_HYPB_MODE_PROTECT - Set to the protection mode.
R_HYPB_MODE_UNPROTECT - Set to the un-protection mode.
*/
typedef enum
{
R_HYPB_MODE_PROTECT = 0,
R_HYPB_MODE_UNPROTECT
} r_hypb_ProtectionMode_t;
/***************************************************************************
Enum: r_hypb_CmdType_t
Description:
This type describes the command type that is defined <r_hypb_Command_t>.
Values:
R_HYPB_CMD_TYPE_OPEN - Command of Open.
R_HYPB_CMD_TYPE_CLOSE - Command of Close.
R_HYPB_CMD_TYPE_READ - Command of Read.
R_HYPB_CMD_TYPE_WRITE - Command of Write.
R_HYPB_CMD_TYPE_WRITE_BUF_FLASH - Command of WriteBufFlash.
R_HYPB_CMD_TYPE_ERASE - Command of Erase.
R_HYPB_CMD_TYPE_PROTECT - Command of Protect.
R_HYPB_CMD_TYPE_READ_CFG_1 - Command of ReadCfg1.
R_HYPB_CMD_TYPE_READ_CFG_2 - Command of ReadCfg2.
R_HYPB_CMD_TYPE_WRITE_CFG_1 - Command of WriteCfg1.
R_HYPB_CMD_TYPE_WRITE_CFG_2 - Command of WriteCfg2.
R_HYPB_CMD_TYPE_READ_STS - Command of ReadSts.
R_HYPB_CMD_TYPE_USER - Command of user defined.
R_HYPB_CMD_TYPE_MAX - The number of defined Command.
*/
typedef enum
{
R_HYPB_CMD_TYPE_OPEN,
R_HYPB_CMD_TYPE_CLOSE,
R_HYPB_CMD_TYPE_READ,
R_HYPB_CMD_TYPE_WRITE,
R_HYPB_CMD_TYPE_WRITE_BUF_FLASH,
R_HYPB_CMD_TYPE_ERASE,
R_HYPB_CMD_TYPE_PROTECT,
R_HYPB_CMD_TYPE_READ_CFG_1,
R_HYPB_CMD_TYPE_READ_CFG_2,
R_HYPB_CMD_TYPE_WRITE_CFG_1,
R_HYPB_CMD_TYPE_WRITE_CFG_2,
R_HYPB_CMD_TYPE_READ_STS,
R_HYPB_CMD_TYPE_USER,
R_HYPB_CMD_TYPE_MAX
} r_hypb_CmdType_t;
/***************************************************************************
typedef: r_hypb_ParamSec_t
Description:
This type describes the parameter-sector information.
Struct members:
Size - Size of one parameter-sector (Byte).
This size must be power-of-two value (2^n).
If parameter sector is not defined or not used, please set to 0.
Num - The number of parameter-sectors.
The total size of parameter-sector (Size * Num) must be less than
SectorSize(@ <r_hypb_Config_t>).
If parameter sector is not defined or not used, please set to 0.
Pos - Position of parameter-sectors. See <r_hypb_ParamSecPos_t>.
Example:
MemorySize(@ <r_hypb_Config_t>)=16*1024*1024,
SectorSize(@ <r_hypb_Config_t>)=256*1024
(1)Size=4096, Num=8, Pos=R_HYPB_PARAM_SEC_TOP
> Word-Address Sector Number
> ---------------------------------------
> 00000000h~000007FFh - Parameter-Sector #0
> 00000800h~00000FFFh - Parameter-Sector #1
> : - :
> 00003800h~00003FFFh - Parameter-Sector #7
> 00004000h~0001FFFFh - Normal Sector #0
> 00020000h~0003FFFFh - Normal Sector #1
> : - :
(2)Size=4096, Num=8, Pos=R_HYPB_PARAM_SEC_BOTTOM
> Word-Address Sector Number
> ---------------------------------------
> : - :
> 007C0000h~007DFFFFh - Normal Sector #62
> 007E0000h~007FBFFFh - Normal Sector #63
> 007FC000h~007FC7FFh - Parameter-Sector #0
> 007FC800h~007FCFFFh - Parameter-Sector #1
> : - :
> 007FF800h~007FFFFFh - Parameter-Sector #7
(3)ParamSec(@ <r_hypb_Config_t>)=R_NULL
> Word-Address Sector Number
> ---------------------------------------
> 00000000h~0001FFFFh - Normal Sector #0
> 00020000h~0003FFFFh - Normal Sector #1
> : - :
> 007C0000h~007DFFFFh - Normal Sector #62
> 007E0000h~007FFFFFh - Normal Sector #63
*/
typedef struct
{
uint32_t Size;
uint32_t Num;
r_hypb_ParamSecPos_t Pos;
} r_hypb_ParamSec_t;
/***************************************************************************
typedef: r_hypb_CmdTransaction_t
Description:
This type describes the hyper RAM/flash commands.
Struct members:
Address - Address data to set CA[44:16] and CA[02:00].
WriteData - Write data (only supports a single write transaction of 16 bits.)
CmdFlags - Flags data to set CA[47:45]. Please set to MSB 3bit.
Latency - Latency in units of clock cycles.
Latency is from CA[23:16] access timing to data Read/Write timing.
If latency is needed, the range is 3 to 20.
If no latency is needed, please set to 0.
OpeFlags - Operation Flags. Multiple flags can be set with '|'.
See definition of <Command Option>.
Note:
CA means Command-Address. Please see data sheet for detail.
*/
typedef struct
{
uint32_t Address;
uint16_t WriteData;
uint8_t CmdFlags;
uint8_t Latency;
uint32_t OpeFlags;
} r_hypb_CmdTransaction_t;
/***************************************************************************
typedef: r_hypb_CmdSequence_t
Description:
This type describes the hyper RAM/flash commands.
Struct members:
Transaction - Pointer to Command Transaction Array.
This memory must be kept allocating till <R_HYPB_Close> is finished.
If the command is not supported, please set to R_NULL.
Cycle - Number of Command Transaction Array.
If the command is not supported, please set to 0.
*/
typedef struct
{
r_hypb_CmdTransaction_t* Transaction;
uint8_t Cycle;
} r_hypb_CmdSequence_t;
/***************************************************************************
typedef: r_hypb_Latency_t
Description:
This type describes the latency.
Struct members:
Code - Initial latency code to set to Configuration register.
ClkDelay - Sets the period from MCS pin assertion to MCK oscillation.
Range is 1 to 8 (clock).
(e.g. It is described as tCSS in data sheet of IS26KL128S.)
NagDelay - Sets the period from the time the last MCK edge is sent
of a transfer to MCS pin negation.
Range is 1 to 8. Actual Delay is set value + 0.5 clk.
If NegDelay=3 is set, actual delay is 3.5 clock.
(e.g. It is described as tCSH in data sheet of IS26KL128S.)
NextAcc - Sets the period from transaction end to next transaction start.
Range is 1 to 8 (clock).
(e.g. It is described as tCSHI in data sheet of IS26KL128S.)
*/
typedef struct
{
uint8_t Code;
uint8_t ClkDelay;
uint8_t NagDelay;
uint8_t NextAcc;
} r_hypb_Latency_t;
/***************************************************************************
typedef: r_hypb_Command_t
Description:
This type describes the hyper RAM/flash commands.
Struct members:
Latency - Latency setting. See <r_hypb_Latency_t>.
Open - Command sequence of Open. See <r_hypb_CmdSequence_t>.
Following Operation Flags are available.
R_HYPB_CMD_WRITE16
Close - Command sequence of Close. See <r_hypb_CmdSequence_t>.
This command is used in case of manual mode.
Following Operation Flags are available.
R_HYPB_CMD_WRITE16
Read - Command sequence of Read. See <r_hypb_CmdSequence_t>.
Following Operation Flags are available.
R_HYPB_CMD_WRITE16 /
R_HYPB_CMD_READ16 /
R_HYPB_CMD_READ32 /
R_HYPB_CMD_READ64 /
R_HYPB_CMD_SET_ADDR
Write - Command sequence of Write directly. See <r_hypb_CmdSequence_t>.
This command is used in case of manual mode.
Following Operation Flags are available.
R_HYPB_CMD_WRITE16 /
R_HYPB_CMD_WRITE_A /
R_HYPB_CMD_SET_ADDR /
R_HYPB_CMD_SET_DATA
WriteBufFlash - Command sequence of Write via write Buffer. See <r_hypb_CmdSequence_t>.
This command is used in case of manual mode.
Following Operation Flags are available.
R_HYPB_CMD_WRITE16 /
R_HYPB_CMD_SET_ADDR /
R_HYPB_CMD_SET_SA /
R_HYPB_CMD_SET_DATA /
R_HYPB_CMD_SET_COUNT /
R_HYPB_CMD_LOOP
Erase - Command sequence of Sector Erase. See <r_hypb_CmdSequence_t>.
This command is used in case of manual mode.
Following Operation Flags are available.
R_HYPB_CMD_WRITE16 /
R_HYPB_CMD_SET_ADDR /
R_HYPB_CMD_SET_SA
Protect - Command sequence of Sector Protect. See <r_hypb_CmdSequence_t>.
This command is used in case of manual mode.
Following Operation Flags are available.
R_HYPB_CMD_WRITE16 /
R_HYPB_CMD_SET_ADDR /
R_HYPB_CMD_SET_SA /
R_HYPB_CMD_SET_DATA
ReadCfg1 - Command sequence of Read Configuration Register at the first time.
This command is used before initial latency code is set.
Please take care in latency setting.
(e.g. Latency is wrote in Non-Volatile Configuration register
in case of IS26KL128S.)
See <r_hypb_CmdSequence_t>.
Following Operation Flags are available.
R_HYPB_CMD_WRITE16 /
R_HYPB_CMD_READ16
ReadCfg2 - Command sequence of Read Configuration Register after the second time.
This command is used after initial latency code is set.
See <r_hypb_CmdSequence_t>.
Following Operation Flags are available.
R_HYPB_CMD_WRITE16 /
R_HYPB_CMD_READ16
WriteCfg1 - Command sequence of Write Configuration Register at the first time.
This command is used when initial latency code is set.
See <r_hypb_CmdSequence_t>.
Following Operation Flags are available.
R_HYPB_CMD_WRITE16 /
R_HYPB_CMD_SET_DATA
WriteCfg2 - Command sequence of Write Configuration Register after the second time.
This command is used after initial latency code is set.
See <r_hypb_CmdSequence_t>.
Following Operation Flags are available.
R_HYPB_CMD_WRITE16 /
R_HYPB_CMD_SET_DATA
ReadSts - Command sequence of Read status Register. See <r_hypb_CmdSequence_t>.
This command is used in case of manual mode.
Following Operation Flags are available.
R_HYPB_CMD_WRITE16 /
R_HYPB_CMD_READ16
*/
typedef struct
{
r_hypb_Latency_t Latency;
r_hypb_CmdSequence_t Open;
r_hypb_CmdSequence_t Close;
r_hypb_CmdSequence_t Read;
r_hypb_CmdSequence_t Write;
r_hypb_CmdSequence_t WriteBufFlash;
r_hypb_CmdSequence_t Erase;
r_hypb_CmdSequence_t Protect;
r_hypb_CmdSequence_t ReadCfg1;
r_hypb_CmdSequence_t ReadCfg2;
r_hypb_CmdSequence_t WriteCfg1;
r_hypb_CmdSequence_t WriteCfg2;
r_hypb_CmdSequence_t ReadSts;
} r_hypb_Command_t;
/***************************************************************************
typedef: r_hypb_Config_t
Description:
This type describes the configuration of the unit.
Struct members:
DeviceType - Control device type. See <r_hypb_DeviceType_t>.
OpeMode - Operating mode. See <r_hypb_OperatingMode_t>.
MemorySize - Total memory byte-size of connected hyper RAM/flash memory.
RH850/D1M1A supports up to 16 Mbytes.
MemorySize should be multiple of SectorSize if SectorSize is defined.
(e.g. This size is 16 MBytes (16*1024*1024), when IS26KL128S
is connected.)
SectorSize - Sector byte-size of connected hyper RAM/flash memory.
Sector size must be power-of-two value (2^n).
This size is used in case of manual mode.
This size is used when R_HYPB_CMD_SET_SA flag is included in the command.
If Sector is not defined, please set to 0.
(e.g. This size is 256 Kbytes when IS26KL128S is connected.)
WriteAlign - Alignment byte-address for WriteBufFlash command.
Write align size must be power-of-two value (2^n). The range is 8 to 2048.
This alignment is used in case of manual mode and it is used by <R_HYPB_DataWrite>.
WriteBufFlash command sequence is closed in units of this alignment.
If not required, please set to 0.
(e.g. This size is 512 bytes (Write buffer line size) when IS26KL128S
is connected.)
RelaxSize - Relax byte-size. Relax size must be multiple of 8-byte.
This size is used in case of manual mode.
Some APIs call <R_HYPB_Sys_Relax> in units of this size.
If not required, please set to 0.
ParamSec - Parameter sector information. See <r_hypb_ParamSec_t>.
This information is used in case of manual mode.
Command - Command setting. See <r_hypb_Command_t>.
This memory must be kept allocating till <R_HYPB_Close> is finished.
*/
typedef struct
{
r_hypb_DeviceType_t DeviceType;
r_hypb_OperatingMode_t OpeMode;
uint32_t MemorySize;
uint32_t SectorSize;
uint32_t WriteAlign;
uint32_t RelaxSize;
r_hypb_ParamSec_t ParamSec;
r_hypb_Command_t* Command;
} r_hypb_Config_t;
/***************************************************************************
Section: Global API functions
*/
/***************************************************************************
Function: R_HYPB_Init
Description:
This function initializes the HYPB driver.
This function calls <R_HYPB_Sys_Init> to initialize environment-dependent
setting.
This function calls <R_HYPB_Sys_Lock> and <R_HYPB_Sys_Unlock> internally.
If this function is executed from the interrupt handler, please be careful of
specification of <R_HYPB_Sys_Lock> and <R_HYPB_Sys_Unlock>.
Parameter:
Unit - Instance number.
Return value:
R_HYPB_ERR_OK - No error has occurred.
R_HYPB_ERR_RANGE_UNIT - Unit number is out of range.
R_HYPB_ERR_NOT_ACCEPTABLE - A function was called in an incorrect state.
R_HYPB_ERR_DEVICE - HYPB driver is not applicable to target device.
R_HYPB_ERR_FATAL_OS - Fatal error has occurred at OS interface.
See <r_hypb_Error_t>.
Executable Status:
Uninitialized - OK (Status will be changed to *Initialized*.)
Initialized - NG
Idle - NG
Executing - NG
Executable Connected Device:
Hyper Flash - OK
Hyper RAM - OK
*/
r_hypb_Error_t R_HYPB_Init(const uint32_t Unit);
/***************************************************************************
Function: R_HYPB_DeInit
Description:
This function de-initializes the HYPB driver.
This function calls <R_HYPB_Sys_DeInit> to de-initialize environment-dependent
setting.
This function calls <R_HYPB_Sys_Lock> and <R_HYPB_Sys_Unlock> internally.
If this function is executed from the interrupt handler, please be careful of
specification of <R_HYPB_Sys_Lock> and <R_HYPB_Sys_Unlock>.
Parameter:
Unit - Instance number.
Return value:
R_HYPB_ERR_OK - No error has occurred.
R_HYPB_ERR_RANGE_UNIT - Unit number is out of range.
R_HYPB_ERR_NOT_ACCEPTABLE - A function was called in an incorrect state.
R_HYPB_ERR_FATAL_OS - Fatal error has occurred at OS interface.
See <r_hypb_Error_t>.
Executable Status:
Uninitialized - NG
Initialized - OK (Status will be changed to *Uninitialized*.)
Idle - NG
Executing - NG
Executable Connected Device:
Hyper Flash - OK
Hyper RAM - OK
*/
r_hypb_Error_t R_HYPB_DeInit(const uint32_t Unit);
/***************************************************************************
Function: R_HYPB_Open
Description:
This function opens the HYPB driver.
This function will access the Configuration register to set latency code and
parameter-sector information. This process is dependent on <R_HYPB_Sys_ConfigRegSet>.
At the first access, ReadCfg1(@ <r_hypb_Command_t>) and WriteCfg1(@ <r_hypb_Command_t>)
are used to access to Configuration register.
After the second time, ReadCfg2(@ <r_hypb_Command_t>) and WriteCfg2(@ <r_hypb_Command_t>)
are used.
If ReadCfg1/ReadCfg2 or WriteCfg1/WriteCfg2 is not supported, this function dose
not update the Configuration register. In this case, this function assumes that latency
code and parameter-sector set by argument have already set to register.
After Configuration register is updated, in case of manual mode, this function executes
Open(@ <r_hypb_Command_t>) command if it is supported.
In case of external address space mode, Read(@ r_hypb_Command_t) command is set to H/W
and it enables access from external address space.
When R_HYPB_MODE_EX_SPACE is specified, this function will fail and return R_HYPB_ERR_COMMAND
or R_HYPB_ERR_LATENCY under following conditions.
- Read(@ <r_hypb_Command_t>) command is not supported.
- Read(@ <r_hypb_Command_t>) transaction cycle is not 1.
- Read(@ <r_hypb_Command_t>) latency cycles are less than 8.
- Read(@ <r_hypb_Command_t>) latency cycles are not even value.
This function calls <R_HYPB_Sys_Lock> and <R_HYPB_Sys_Unlock> internally.
If this function is executed from the interrupt handler, please be careful of
specification of <R_HYPB_Sys_Lock> and <R_HYPB_Sys_Unlock>.
Parameter:
Unit - Instance number.
Config - Pointer to the <r_hypb_Config_t> structure.
Return value:
R_HYPB_ERR_OK - No error has occurred.
R_HYPB_ERR_PARAM_INCORRECT - A parameter is incorrect.
R_HYPB_ERR_RANGE_UNIT - Unit number is out of range.
R_HYPB_ERR_RANGE_PARAM - A parameter is out of range.
R_HYPB_ERR_NOT_ACCEPTABLE - A function was called in an incorrect state.
R_HYPB_ERR_FATAL_OS - Fatal error has occurred at OS interface.
R_HYPB_ERR_FATAL_HW - Fatal error has occurred at H/W.
R_HYPB_ERR_COMMAND - A command is not supported.
R_HYPB_ERR_LATENCY - A latency value is invalid.
See <r_hypb_Error_t>.
Executable Status:
Uninitialized - NG
Initialized - OK (Status will be changed to *Idle* or *Executing*.)
Idle - NG
Executing - NG
Status will be changed to *Idle* if R_HYPB_MODE_MANUAL is specified.
Status will be changed to *Executing* if R_HYPB_MODE_EX_SPACE is specified.
Executable Connected Device:
Hyper Flash - OK
Hyper RAM - OK
*/
r_hypb_Error_t R_HYPB_Open(const uint32_t Unit,
const r_hypb_Config_t * const Config);
/***************************************************************************
Function: R_HYPB_Close
Description:
This function closes the HYPB driver.
In case of manual mode, this function executes Close(@ <r_hypb_Command_t>)
command if it is supported.
In case of external address space mode, this function disables access from
the external space.
This function calls <R_HYPB_Sys_Lock> and <R_HYPB_Sys_Unlock> internally.
If this function is executed from the interrupt handler, please be careful of
specification of <R_HYPB_Sys_Lock> and <R_HYPB_Sys_Unlock>.
Parameter:
Unit - Instance number.
Return value:
R_HYPB_ERR_OK - No error has occurred.
R_HYPB_ERR_RANGE_UNIT - Unit number is out of range.
R_HYPB_ERR_NOT_ACCEPTABLE - A function was called in an incorrect state.
R_HYPB_ERR_FATAL_OS - Fatal error has occurred at OS interface.
R_HYPB_ERR_FATAL_HW - Fatal error has occurred at H/W.
See <r_hypb_Error_t>.
Executable Status:
Uninitialized - NG
Initialized - NG
Idle - OK (Status will be changed to *Initialized*.)
Executing - OK (Status will be changed to *Initialized*.)
Executable Connected Device:
Hyper Flash - OK
Hyper RAM - OK
*/
r_hypb_Error_t R_HYPB_Close(const uint32_t Unit);
/***************************************************************************
Function: R_HYPB_DataProtect
Description:
This function sets the protection mode of the hyper flash memory.
This function executes Protect(@ <r_hypb_Command_t>) command.
This function assumes that Protect command can be set protection mode for each
sector (or parameter-sector).
This function controls sectors in following range.
Start sector - Sector (or parameter-sector) that WordAddr is belonged.
End sector - Sector (or parameter-sector) that (WordAddr + WordSize - 1) is belonged.
This function executes Protect command without checking the protecting status of sector.
The write or erase command to hyper flash memory will fail if target sector
is protected.
This function will fail and return R_HYPB_ERR_COMMAND under following conditions.
- SectorSize(@ <r_hypb_Config_t>) = 0.
- Protect(@ <r_hypb_Command_t>) command is not supported.
This function calls <R_HYPB_Sys_Lock> and <R_HYPB_Sys_Unlock> internally.
If this function is executed from the interrupt handler, please be careful of
specification of <R_HYPB_Sys_Lock> and <R_HYPB_Sys_Unlock>.
Parameter:
Unit - Instance number.
WordAddr - Protect control start word-address of the hyper flash memory.
WordSize - Data word-size to protect.
Mode - Protection mode. See <r_hypb_ProtectionMode_t>.
Return value:
R_HYPB_ERR_OK - No error has occurred.
R_HYPB_ERR_PARAM_INCORRECT - A parameter is incorrect.
R_HYPB_ERR_RANGE_UNIT - Unit number is out of range.
R_HYPB_ERR_RANGE_PARAM - A parameter is out of range.
R_HYPB_ERR_NOT_ACCEPTABLE - A function was called in an incorrect state.
R_HYPB_ERR_FATAL_OS - Fatal error has occurred at OS interface.
R_HYPB_ERR_FATAL_HW - Fatal error has occurred at H/W.
R_HYPB_ERR_COMMAND - A command is not supported.
See <r_hypb_Error_t>.
Executable Status:
Uninitialized - NG
Initialized - NG
Idle - OK
Executing - NG
Executable Connected Device:
Hyper Flash - OK
Hyper RAM - NG
*/
r_hypb_Error_t R_HYPB_DataProtect(const uint32_t Unit,
const uint32_t WordAddr,
const uint32_t WordSize,
const r_hypb_ProtectionMode_t Mode);
/***************************************************************************
Function: R_HYPB_DataErase
Description:
This function erases the data in the hyper flash memory.
This function executes Erase(@ <r_hypb_Command_t>) command.
This function assumes that Erase command can be erased in a unit of sector (or
parameter-sector).
This function erases the sectors in following range.
Start sector - Sector (or parameter-sector) that WordAddr is belonged.
End sector - Sector (or parameter-sector) that (WordAddr + WordSize - 1) is belonged.
This function will fail and return R_HYPB_ERR_COMMAND under following conditions.
- SectorSize(@ <r_hypb_Config_t>) = 0.
- Erase(@ <r_hypb_Command_t>) command is not supported.
- Multiple sectors are specified and ReadSts(@ <r_hypb_Command_t>) command is
not supported.
This function calls <R_HYPB_Sys_Lock> and <R_HYPB_Sys_Unlock> internally.
If this function is executed from the interrupt handler, please be careful of
specification of <R_HYPB_Sys_Lock> and <R_HYPB_Sys_Unlock>.
*[Wait mode]*
If ReadSts(@ <r_hypb_Command_t>) command is supported, this function waits to finish the
erasing process and checks the result.
Actual erased size is stored to ResultSize.
Result check process is dependent on <R_HYPB_Sys_StatusRegCheck>.
*[No-Wait mode]*
If ReadSts(@ <r_hypb_Command_t>) command is not supported, this function does not wait to
finish the erasing process and dose not check the result.
After one Erase command sequence is finished, this function will return R_HYPB_ERR_OK
and the size that is set to command is stored to ResultSize.
Parameter:
Unit - Instance number.
WordAddr - Erase start word-address of the hyper flash memory.
WordSize - Data word-size to erase.
ResultSize - Pointer to variable that receives the word-size erased by this function.
If not required, please set to R_NULL.
Return value:
R_HYPB_ERR_OK - No error has occurred.
R_HYPB_ERR_PARAM_INCORRECT - A parameter is incorrect.
R_HYPB_ERR_RANGE_UNIT - Unit number is out of range.
R_HYPB_ERR_RANGE_PARAM - A parameter is out of range.
R_HYPB_ERR_NOT_ACCEPTABLE - A function was called in an incorrect state.
R_HYPB_ERR_FATAL_OS - Fatal error has occurred at OS interface.
R_HYPB_ERR_FATAL_HW - Fatal error has occurred at H/W.
R_HYPB_ERR_COMMAND - A command is not supported.
R_HYPB_ERR_PROTECTED - A process is aborted because of memory protection.
R_HYPB_ERR_ABORTED - A process is aborted because of other reason.
R_HYPB_ERR_TIMEOUT - Status polling is timeout.
See <r_hypb_Error_t>.
Executable Status:
Uninitialized - NG
Initialized - NG
Idle - OK
Executing - NG
Executable Connected Device:
Hyper Flash - OK
Hyper RAM - NG
*/
r_hypb_Error_t R_HYPB_DataErase(const uint32_t Unit,
const uint32_t WordAddr,
const uint32_t WordSize,
uint32_t* const ResultSize );
/***************************************************************************
Function: R_HYPB_DataWrite
Description:
This function writes data to the hyper flash memory.
In order to write data to Hyper Flash, the data of the sector must have been
erased previously.
This function executes WriteBufFlash(@ <r_hypb_Command_t>) or Write(@ <r_hypb_Command_t>)
command under following condiion.
- If Write command is supported, Write command is used only.
- If Write command is not supported, WriteBufFlash command is used only.
- If both commands are not supported, this function will fail and return R_HYPB_ERR_COMMAND.
When Write command is used and Write command doesn't have R_HYPB_CMD_WRITE_A option,
this function has the possibility that the processing takes time.
Therefore, <R_HYPB_Sys_Relax> is executed in units of RelaxSize(@ r_hypb_Config_t).
This function calls <R_HYPB_Sys_Lock> and <R_HYPB_Sys_Unlock> internally.
If this function is executed from the interrupt handler, please be careful of
specification of <R_HYPB_Sys_Lock> and <R_HYPB_Sys_Unlock>.
*[Wait mode]*
If ReadSts(@ <r_hypb_Command_t>) command is supported, this function waits to finish the
writing process and checks the result.
Actual written size is stored to ResultSize.
Result check process is dependent on <R_HYPB_Sys_StatusRegCheck>.
*[No-Wait mode]*
If ReadSts(@ <r_hypb_Command_t>) command is not supported, this function does not wait to
finish the writing process and dose not check the result.
If WriteBufFlash command is used, this function will return R_HYPB_ERR_OK after only one
WriteBufFlash command sequence is issued.
If Write command is used and Write command has R_HYPB_CMD_WRITE_A option,
this function will return R_HYPB_ERR_OK after only one Write command sequence is issued.
If Write command is used and Write command doesn't have R_HYPB_CMD_WRITE_A option,
Write command is executed continuously without status check.
The size that is set to command is stored to ResultSize.
Parameter:
Unit - Instance number.
WordAddr - The parameter specifies the write word-address of the hyper flash memory.
Buf - This is a pointer to the buffer stored write data.
WordSize - The parameter specifies the data word-size to write.
ResultSize - Pointer to variable that receives the word-size written by this function.
If not required, please set to R_NULL.
Return value:
R_HYPB_ERR_OK - No error has occurred.
R_HYPB_ERR_PARAM_INCORRECT - A parameter is incorrect.
R_HYPB_ERR_RANGE_UNIT - Unit number is out of range.
R_HYPB_ERR_RANGE_PARAM - A parameter is out of range.
R_HYPB_ERR_NOT_ACCEPTABLE - A function was called in an incorrect state.
R_HYPB_ERR_FATAL_OS - Fatal error has occurred at OS interface.
R_HYPB_ERR_FATAL_HW - Fatal error has occurred at H/W.
R_HYPB_ERR_COMMAND - A command is not supported.
R_HYPB_ERR_PROTECTED - A process is aborted because of memory protection.
R_HYPB_ERR_ABORTED - A process is aborted because of other reason.
R_HYPB_ERR_TIMEOUT - Status polling is timeout.
See <r_hypb_Error_t>.
Executable Status:
Uninitialized - NG
Initialized - NG
Idle - OK
Executing - NG
Executable Connected Device:
Hyper Flash - OK
Hyper RAM - NG
*/
r_hypb_Error_t R_HYPB_DataWrite(const uint32_t Unit,
const uint32_t WordAddr,
const uint8_t* Buf,
const uint32_t WordSize,
uint32_t* const ResultSize);
/***************************************************************************
Function: R_HYPB_DataRead
Description:
This function reads data from the hyper flash memory.
This function will fail and return R_HYPB_ERR_COMMAND under following conditions.
- Read(@ <r_hypb_Command_t>) command is not supported.
This function has the possibility that the processing takes time.
Therefore, <R_HYPB_Sys_Relax> is executed in units of RelaxSize(@ r_hypb_Config_t).
This function calls <R_HYPB_Sys_Lock> and <R_HYPB_Sys_Unlock> internally.
If this function is executed from the interrupt handler, please be careful of
specification of <R_HYPB_Sys_Lock> and <R_HYPB_Sys_Unlock>.
Parameter:
Unit - Instance number.
WordAddr - The parameter specifies the read word-address of the hyper flash memory.
Buf - This is a pointer to the buffer to store the read data.
WordSize - The parameter specifies the data word-size to read.
Return value:
R_HYPB_ERR_OK - No error has occurred.
R_HYPB_ERR_PARAM_INCORRECT - A parameter is incorrect.
R_HYPB_ERR_RANGE_UNIT - Unit number is out of range.
R_HYPB_ERR_RANGE_PARAM - A parameter is out of range.
R_HYPB_ERR_NOT_ACCEPTABLE - A function was called in an incorrect state.
R_HYPB_ERR_FATAL_OS - Fatal error has occurred at OS interface.
R_HYPB_ERR_FATAL_HW - Fatal error has occurred at H/W.
R_HYPB_ERR_COMMAND - A command is not supported.
See <r_hypb_Error_t>.
Executable Status:
Uninitialized - NG
Initialized - NG
Idle - OK
Executing - NG
Executable Connected Device:
Hyper Flash - OK
Hyper RAM - NG
*/
r_hypb_Error_t R_HYPB_DataRead(const uint32_t Unit,
const uint32_t WordAddr,
uint8_t* const Buf,
const uint32_t WordSize);
/***************************************************************************
Function: R_HYPB_UserCmdIssue
Description:
This function executes user command sequence.
Following <Command Option> are available.
- R_HYPB_CMD_WRITE16
- R_HYPB_CMD_READ16
- R_HYPB_CMD_READ32
- R_HYPB_CMD_READ64
If read transaction is existed in command sequence, read data will be stored to
Buf. Read size is 16bit, 32bit or 64bit. It depends on <Command Option>.
If BufSize is less than Read size, specified size by BufSize is stored to Buf.
e.g. When R_HYPB_CMD_READ64 is specified and BufSize = 8, stored data is as follows.
> Buf[0] = 1st WordData[15:08]
> Buf[1] = 1st WordData[07:00]
> : :
> Buf[6] = 4th WordData[15:08]
> Buf[7] = 4th WordData[07:00]
This function calls <R_HYPB_Sys_Lock> and <R_HYPB_Sys_Unlock> internally.
If this function is executed from the interrupt handler, please be careful of
specification of <R_HYPB_Sys_Lock> and <R_HYPB_Sys_Unlock>.
Parameter:
Unit - Instance number.
CmdSequence - Command sequence. See <r_hypb_CmdSequence_t>.
Buf - This is a pointer to the Buffer to store the read data.
If read transaction is not existed in command sequence,
please set to R_NULL.
BufSize - Byte-size of data that can be stored to Buf.
Return value:
R_HYPB_ERR_OK - No error has occurred.
R_HYPB_ERR_PARAM_INCORRECT - A parameter is incorrect.
R_HYPB_ERR_RANGE_UNIT - Unit number is out of range.
R_HYPB_ERR_RANGE_PARAM - A parameter is out of range.
R_HYPB_ERR_NOT_ACCEPTABLE - A function was called in an incorrect state.
R_HYPB_ERR_FATAL_OS - Fatal error has occurred at OS interface.
R_HYPB_ERR_FATAL_HW - Fatal error has occurred at H/W.
R_HYPB_ERR_COMMAND - A command is not supported.
See <r_hypb_Error_t>.
Executable Status:
Uninitialized - NG
Initialized - NG
Idle - OK
Executing - NG
Executable Connected Device:
Hyper Flash - OK
Hyper RAM - OK
*/
r_hypb_Error_t R_HYPB_UserCmdIssue(const uint32_t Unit,
const r_hypb_CmdSequence_t* const CmdSequence,
uint8_t * const Buf,
const uint32_t BufSize);
/***************************************************************************
Function: R_HYPB_VersionStringGet
Description:
This function returns the version string of this HYPB driver.
Parameter:
None
Return value:
Pointer of string.
Executable Status:
Uninitialized - OK
Initialized - OK
Idle - OK
Executing - OK
Executable Connected Device:
Hyper Flash - OK
Hyper RAM - OK
*/
const uint8_t* R_HYPB_VersionStringGet(void);
/***************************************************************************
Function: R_HYPB_MacroVersionGet
Description:
This function returns the major and minor version of the H/W macro.
Parameter:
Major - Pointer to store the major version.
Minor - Pointer to store the minor version.
Return value:
R_HYPB_ERR_OK - No error has occurred.
R_HYPB_ERR_PARAM_INCORRECT - A parameter is incorrect.
See <r_hypb_Error_t>.
Executable Status:
Uninitialized - OK
Initialized - OK
Idle - OK
Executing - OK
Executable Connected Device:
Hyper Flash - OK
Hyper RAM - OK
*/
r_hypb_Error_t R_HYPB_MacroVersionGet(uint32_t * const Major,
uint32_t * const Minor);
#ifdef __cplusplus
}
#endif
#endif /* R_HYPB_API_H */