musb 0.2.0

musb(Mentor USB) regs and `embassy-usb-driver`, `usb-device` impl
Documentation
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
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549

#[doc = "USB control and status registers for managing USB operations."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Usb {
    ptr: *mut u8,
}
unsafe impl Send for Usb {}
unsafe impl Sync for Usb {}
impl Usb {
    #[inline(always)]
    pub const unsafe fn from_ptr(ptr: *mut ()) -> Self {
        Self { ptr: ptr as _ }
    }
    #[inline(always)]
    pub const fn as_ptr(&self) -> *mut () {
        self.ptr as _
    }
    #[doc = "Function address register."]
    #[inline(always)]
    pub const fn faddr(self) -> crate::common::Reg<regs::Faddr, crate::common::RW> {
        unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x0usize) as _) }
    }
    #[doc = "Power management register."]
    #[inline(always)]
    pub const fn power(self) -> crate::common::Reg<regs::Power, crate::common::RW> {
        unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x01usize) as _) }
    }
    #[doc = "Interrupt register for Endpoint 0 plus TX Endpoints 1 to 15."]
    #[inline(always)]
    pub const fn intrtx(self) -> crate::common::Reg<regs::Intrtx, crate::common::RW> {
        unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x02usize) as _) }
    }
    #[doc = "Interrupt register for Rx Endpoints 1 to 15."]
    #[inline(always)]
    pub const fn intrrx(self) -> crate::common::Reg<regs::Intrrx, crate::common::RW> {
        unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x04usize) as _) }
    }
    #[doc = "Interrupt enable register for INTRTX."]
    #[inline(always)]
    pub const fn intrtxe(self) -> crate::common::Reg<regs::Intrtxe, crate::common::RW> {
        unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x06usize) as _) }
    }
    #[doc = "Interrupt enable register for INTRRX."]
    #[inline(always)]
    pub const fn intrrxe(self) -> crate::common::Reg<regs::Intrrxe, crate::common::RW> {
        unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x08usize) as _) }
    }
    #[doc = "Interrupt register for common USB interrupts."]
    #[inline(always)]
    pub const fn intrusb(self) -> crate::common::Reg<regs::Intrusb, crate::common::RW> {
        unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x0ausize) as _) }
    }
    #[doc = "Interrupt enable register for INTRUSB."]
    #[inline(always)]
    pub const fn intrusbe(self) -> crate::common::Reg<regs::Intrusbe, crate::common::RW> {
        unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x0busize) as _) }
    }
    #[doc = "Frame number."]
    #[inline(always)]
    pub const fn frame(self) -> crate::common::Reg<regs::Frame, crate::common::RW> {
        unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x0cusize) as _) }
    }
    #[doc = "Index register for selecting the endpoint status and control registers."]
    #[inline(always)]
    pub const fn index(self) -> crate::common::Reg<regs::Index, crate::common::RW> {
        unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x0eusize) as _) }
    }
    #[doc = "Enables the USB 2.0 test modes."]
    #[inline(always)]
    pub const fn testmode(self) -> crate::common::Reg<regs::Testmode, crate::common::RW> {
        unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x0fusize) as _) }
    }
    #[doc = "Maximum packet size for peripheral TX endpoint."]
    #[inline(always)]
    pub const fn txmaxp(self) -> crate::common::Reg<regs::Txmaxp, crate::common::RW> {
        unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x10usize) as _) }
    }
    #[doc = "Control Status register higher byte for Endpoint 0."]
    #[inline(always)]
    pub const fn csr0h(self) -> crate::common::Reg<regs::Csr0h, crate::common::RW> {
        unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x12usize) as _) }
    }
    #[doc = "Control Status register lower byte for Endpoint 0."]
    #[inline(always)]
    pub const fn csr0l(self) -> crate::common::Reg<regs::Csr0l, crate::common::RW> {
        unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x13usize) as _) }
    }
    #[doc = "Control Status register higher byte for peripheral TX endpoint."]
    #[inline(always)]
    pub const fn txcsrh(self) -> crate::common::Reg<regs::Txcsrh, crate::common::RW> {
        unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x14usize) as _) }
    }
    #[doc = "Control Status register lower byte for peripheral TX endpoint."]
    #[inline(always)]
    pub const fn txcsrl(self) -> crate::common::Reg<regs::Txcsrl, crate::common::RW> {
        unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x15usize) as _) }
    }
    #[doc = "Maximum packet size for peripheral Rx endpoint."]
    #[inline(always)]
    pub const fn rxmaxp(self) -> crate::common::Reg<regs::Rxmaxp, crate::common::RW> {
        unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x16usize) as _) }
    }
    #[doc = "Control Status register higher byte for peripheral Rx endpoint."]
    #[inline(always)]
    pub const fn rxcsrh(self) -> crate::common::Reg<regs::Rxcsrh, crate::common::RW> {
        unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x18usize) as _) }
    }
    #[doc = "Control Status register lower byte for peripheral Rx endpoint."]
    #[inline(always)]
    pub const fn rxcsrl(self) -> crate::common::Reg<regs::Rxcsrl, crate::common::RW> {
        unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x19usize) as _) }
    }
    #[doc = "Number of received bytes in Endpoint 0 FIFO."]
    #[inline(always)]
    pub const fn count0(self) -> crate::common::Reg<regs::Count0, crate::common::RW> {
        unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x1ausize) as _) }
    }
    #[doc = "Number of bytes to be read from peripheral Rx endpoint FIFO."]
    #[inline(always)]
    pub const fn rxcount(self) -> crate::common::Reg<regs::Rxcount, crate::common::RW> {
        unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x1cusize) as _) }
    }
    #[doc = "Returns details of core configuration."]
    #[inline(always)]
    pub const fn configdata(self) -> crate::common::Reg<regs::Configdata, crate::common::RW> {
        unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x1fusize) as _) }
    }
    #[doc = "FIFO for endpoints."]
    #[inline(always)]
    pub const fn fifo(self, n: usize) -> crate::common::Reg<regs::Fifo, crate::common::RW> {
        assert!(n < 16usize);
        unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x20usize + n * 4usize) as _) }
    }
}
pub mod regs {
    #[doc = "Core configuration information register"]
    #[repr(transparent)]
    #[derive(Copy, Clone, Eq, PartialEq)]
    pub struct Configdata(pub u8);
    impl Configdata {
        #[doc = "UTMI+ data width selection"]
        #[inline(always)]
        pub const fn utmi_data_width(&self) -> super::vals::UtmiWidth {
            let val = (self.0 >> 0usize) & 0x01;
            super::vals::UtmiWidth::from_bits(val as u8)
        }
        #[doc = "UTMI+ data width selection"]
        #[inline(always)]
        pub fn set_utmi_data_width(&mut self, val: super::vals::UtmiWidth) {
            self.0 = (self.0 & !(0x01 << 0usize)) | (((val.to_bits() as u8) & 0x01) << 0usize);
        }
        #[doc = "Soft Connect/Disconnect feature"]
        #[inline(always)]
        pub const fn soft_con_e(&self) -> bool {
            let val = (self.0 >> 1usize) & 0x01;
            val != 0
        }
        #[doc = "Soft Connect/Disconnect feature"]
        #[inline(always)]
        pub fn set_soft_con_e(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u8) & 0x01) << 1usize);
        }
        #[doc = "Dynamic FIFO Sizing option"]
        #[inline(always)]
        pub const fn dyn_fifo_sizing(&self) -> bool {
            let val = (self.0 >> 2usize) & 0x01;
            val != 0
        }
        #[doc = "Dynamic FIFO Sizing option"]
        #[inline(always)]
        pub fn set_dyn_fifo_sizing(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u8) & 0x01) << 2usize);
        }
        #[doc = "High-bandwidth TX ISO Endpoint Support"]
        #[inline(always)]
        pub const fn hb_tx_e(&self) -> bool {
            let val = (self.0 >> 3usize) & 0x01;
            val != 0
        }
        #[doc = "High-bandwidth TX ISO Endpoint Support"]
        #[inline(always)]
        pub fn set_hb_tx_e(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u8) & 0x01) << 3usize);
        }
        #[doc = "High-bandwidth Rx ISO Endpoint Support"]
        #[inline(always)]
        pub const fn hb_rx_e(&self) -> bool {
            let val = (self.0 >> 4usize) & 0x01;
            val != 0
        }
        #[doc = "High-bandwidth Rx ISO Endpoint Support"]
        #[inline(always)]
        pub fn set_hb_rx_e(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 4usize)) | (((val as u8) & 0x01) << 4usize);
        }
        #[doc = "Endian ordering indicator"]
        #[inline(always)]
        pub const fn big_endian(&self) -> bool {
            let val = (self.0 >> 5usize) & 0x01;
            val != 0
        }
        #[doc = "Endian ordering indicator"]
        #[inline(always)]
        pub fn set_big_endian(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 5usize)) | (((val as u8) & 0x01) << 5usize);
        }
        #[doc = "Automatic bulk packet splitting"]
        #[inline(always)]
        pub const fn mp_tx_e(&self) -> bool {
            let val = (self.0 >> 6usize) & 0x01;
            val != 0
        }
        #[doc = "Automatic bulk packet splitting"]
        #[inline(always)]
        pub fn set_mp_tx_e(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 6usize)) | (((val as u8) & 0x01) << 6usize);
        }
        #[doc = "Automatic bulk packet amalgamation"]
        #[inline(always)]
        pub const fn mp_rx_e(&self) -> bool {
            let val = (self.0 >> 7usize) & 0x01;
            val != 0
        }
        #[doc = "Automatic bulk packet amalgamation"]
        #[inline(always)]
        pub fn set_mp_rx_e(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 7usize)) | (((val as u8) & 0x01) << 7usize);
        }
    }
    impl Default for Configdata {
        #[inline(always)]
        fn default() -> Configdata {
            Configdata(0)
        }
    }
    #[doc = "USB Endpoint 0 Received Data Byte Count"]
    #[repr(transparent)]
    #[derive(Copy, Clone, Eq, PartialEq)]
    pub struct Count0(pub u8);
    impl Count0 {
        #[doc = "Number of received data bytes in FIFO"]
        #[inline(always)]
        pub const fn count(&self) -> u8 {
            let val = (self.0 >> 0usize) & 0x7f;
            val as u8
        }
        #[doc = "Number of received data bytes in FIFO"]
        #[inline(always)]
        pub fn set_count(&mut self, val: u8) {
            self.0 = (self.0 & !(0x7f << 0usize)) | (((val as u8) & 0x7f) << 0usize);
        }
    }
    impl Default for Count0 {
        #[inline(always)]
        fn default() -> Count0 {
            Count0(0)
        }
    }
    #[doc = "USB Endpoint 0 Control and Status Register High"]
    #[repr(transparent)]
    #[derive(Copy, Clone, Eq, PartialEq)]
    pub struct Csr0h(pub u8);
    impl Csr0h {
        #[doc = "Reset FIFO pointer and clear packet ready status"]
        #[inline(always)]
        pub const fn flush_fifo(&self) -> bool {
            let val = (self.0 >> 0usize) & 0x01;
            val != 0
        }
        #[doc = "Reset FIFO pointer and clear packet ready status"]
        #[inline(always)]
        pub fn set_flush_fifo(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u8) & 0x01) << 0usize);
        }
    }
    impl Default for Csr0h {
        #[inline(always)]
        fn default() -> Csr0h {
            Csr0h(0)
        }
    }
    #[doc = "USB Endpoint 0 Control and Status Register Low"]
    #[repr(transparent)]
    #[derive(Copy, Clone, Eq, PartialEq)]
    pub struct Csr0l(pub u8);
    impl Csr0l {
        #[doc = "Indicates received data packet ready for processing"]
        #[inline(always)]
        pub const fn rx_pkt_rdy(&self) -> bool {
            let val = (self.0 >> 0usize) & 0x01;
            val != 0
        }
        #[doc = "Indicates received data packet ready for processing"]
        #[inline(always)]
        pub fn set_rx_pkt_rdy(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u8) & 0x01) << 0usize);
        }
        #[doc = "Indicates data packet loaded in FIFO ready for transmission"]
        #[inline(always)]
        pub const fn tx_pkt_rdy(&self) -> bool {
            let val = (self.0 >> 1usize) & 0x01;
            val != 0
        }
        #[doc = "Indicates data packet loaded in FIFO ready for transmission"]
        #[inline(always)]
        pub fn set_tx_pkt_rdy(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u8) & 0x01) << 1usize);
        }
        #[doc = "Set when STALL handshake is transmitted"]
        #[inline(always)]
        pub const fn sent_stall(&self) -> bool {
            let val = (self.0 >> 2usize) & 0x01;
            val != 0
        }
        #[doc = "Set when STALL handshake is transmitted"]
        #[inline(always)]
        pub fn set_sent_stall(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u8) & 0x01) << 2usize);
        }
        #[doc = "Marks the end of data transfer"]
        #[inline(always)]
        pub const fn data_end(&self) -> bool {
            let val = (self.0 >> 3usize) & 0x01;
            val != 0
        }
        #[doc = "Marks the end of data transfer"]
        #[inline(always)]
        pub fn set_data_end(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u8) & 0x01) << 3usize);
        }
        #[doc = "Control transaction ended prematurely"]
        #[inline(always)]
        pub const fn setup_end(&self) -> bool {
            let val = (self.0 >> 4usize) & 0x01;
            val != 0
        }
        #[doc = "Control transaction ended prematurely"]
        #[inline(always)]
        pub fn set_setup_end(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 4usize)) | (((val as u8) & 0x01) << 4usize);
        }
        #[doc = "Terminate current transaction with STALL handshake"]
        #[inline(always)]
        pub const fn send_stall(&self) -> bool {
            let val = (self.0 >> 5usize) & 0x01;
            val != 0
        }
        #[doc = "Terminate current transaction with STALL handshake"]
        #[inline(always)]
        pub fn set_send_stall(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 5usize)) | (((val as u8) & 0x01) << 5usize);
        }
        #[doc = "Clear RxPktRdy bit"]
        #[inline(always)]
        pub const fn serviced_rx_pkt_rdy(&self) -> bool {
            let val = (self.0 >> 6usize) & 0x01;
            val != 0
        }
        #[doc = "Clear RxPktRdy bit"]
        #[inline(always)]
        pub fn set_serviced_rx_pkt_rdy(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 6usize)) | (((val as u8) & 0x01) << 6usize);
        }
        #[doc = "Clear SetupEnd bit"]
        #[inline(always)]
        pub const fn serviced_setup_end(&self) -> bool {
            let val = (self.0 >> 7usize) & 0x01;
            val != 0
        }
        #[doc = "Clear SetupEnd bit"]
        #[inline(always)]
        pub fn set_serviced_setup_end(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 7usize)) | (((val as u8) & 0x01) << 7usize);
        }
    }
    impl Default for Csr0l {
        #[inline(always)]
        fn default() -> Csr0l {
            Csr0l(0)
        }
    }
    #[doc = "Function Address Register for USB device addressing"]
    #[repr(transparent)]
    #[derive(Copy, Clone, Eq, PartialEq)]
    pub struct Faddr(pub u8);
    impl Faddr {
        #[doc = "USB device function address"]
        #[inline(always)]
        pub const fn func_addr(&self) -> u8 {
            let val = (self.0 >> 0usize) & 0x7f;
            val as u8
        }
        #[doc = "USB device function address"]
        #[inline(always)]
        pub fn set_func_addr(&mut self, val: u8) {
            self.0 = (self.0 & !(0x7f << 0usize)) | (((val as u8) & 0x7f) << 0usize);
        }
    }
    impl Default for Faddr {
        #[inline(always)]
        fn default() -> Faddr {
            Faddr(0)
        }
    }
    #[doc = "FIFO Data Access Register for Endpoints"]
    #[repr(transparent)]
    #[derive(Copy, Clone, Eq, PartialEq)]
    pub struct Fifo(pub u8);
    impl Fifo {
        #[doc = "Data byte for FIFO read/write operation"]
        #[inline(always)]
        pub const fn data(&self) -> u8 {
            let val = (self.0 >> 0usize) & 0xff;
            val as u8
        }
        #[doc = "Data byte for FIFO read/write operation"]
        #[inline(always)]
        pub fn set_data(&mut self, val: u8) {
            self.0 = (self.0 & !(0xff << 0usize)) | (((val as u8) & 0xff) << 0usize);
        }
    }
    impl Default for Fifo {
        #[inline(always)]
        fn default() -> Fifo {
            Fifo(0)
        }
    }
    #[doc = "Last received USB frame number"]
    #[repr(transparent)]
    #[derive(Copy, Clone, Eq, PartialEq)]
    pub struct Frame(pub u16);
    impl Frame {
        #[doc = "USB frame number"]
        #[inline(always)]
        pub const fn frame(&self) -> u16 {
            let val = (self.0 >> 0usize) & 0x07ff;
            val as u16
        }
        #[doc = "USB frame number"]
        #[inline(always)]
        pub fn set_frame(&mut self, val: u16) {
            self.0 = (self.0 & !(0x07ff << 0usize)) | (((val as u16) & 0x07ff) << 0usize);
        }
    }
    impl Default for Frame {
        #[inline(always)]
        fn default() -> Frame {
            Frame(0)
        }
    }
    #[doc = "Endpoint index selection register"]
    #[repr(transparent)]
    #[derive(Copy, Clone, Eq, PartialEq)]
    pub struct Index(pub u8);
    impl Index {
        #[doc = "Selects which endpoint control/status registers are accessed"]
        #[inline(always)]
        pub const fn index(&self) -> u8 {
            let val = (self.0 >> 0usize) & 0x0f;
            val as u8
        }
        #[doc = "Selects which endpoint control/status registers are accessed"]
        #[inline(always)]
        pub fn set_index(&mut self, val: u8) {
            self.0 = (self.0 & !(0x0f << 0usize)) | (((val as u8) & 0x0f) << 0usize);
        }
    }
    impl Default for Index {
        #[inline(always)]
        fn default() -> Index {
            Index(0)
        }
    }
    #[doc = "Receive Endpoint Interrupt Status Register"]
    #[repr(transparent)]
    #[derive(Copy, Clone, Eq, PartialEq)]
    pub struct Intrrx(pub u16);
    impl Intrrx {
        #[doc = "Endpoint transmit interrupt (except EP0)"]
        #[inline(always)]
        pub const fn ep_rx(&self, n: usize) -> bool {
            assert!(n < 16usize);
            let offs = 0usize + n * 1usize;
            let val = (self.0 >> offs) & 0x01;
            val != 0
        }
        #[doc = "Endpoint transmit interrupt (except EP0)"]
        #[inline(always)]
        pub fn set_ep_rx(&mut self, n: usize, val: bool) {
            assert!(n < 16usize);
            let offs = 0usize + n * 1usize;
            self.0 = (self.0 & !(0x01 << offs)) | (((val as u16) & 0x01) << offs);
        }
    }
    impl Default for Intrrx {
        #[inline(always)]
        fn default() -> Intrrx {
            Intrrx(0)
        }
    }
    #[doc = "Receive Endpoint Interrupt Enable Register"]
    #[repr(transparent)]
    #[derive(Copy, Clone, Eq, PartialEq)]
    pub struct Intrrxe(pub u16);
    impl Intrrxe {
        #[doc = "Endpoint transmit interrupt enable (except EP0)"]
        #[inline(always)]
        pub const fn ep_rxe(&self, n: usize) -> bool {
            assert!(n < 16usize);
            let offs = 0usize + n * 1usize;
            let val = (self.0 >> offs) & 0x01;
            val != 0
        }
        #[doc = "Endpoint transmit interrupt enable (except EP0)"]
        #[inline(always)]
        pub fn set_ep_rxe(&mut self, n: usize, val: bool) {
            assert!(n < 16usize);
            let offs = 0usize + n * 1usize;
            self.0 = (self.0 & !(0x01 << offs)) | (((val as u16) & 0x01) << offs);
        }
    }
    impl Default for Intrrxe {
        #[inline(always)]
        fn default() -> Intrrxe {
            Intrrxe(0)
        }
    }
    #[doc = "Transmit Endpoint Interrupt Status Register"]
    #[repr(transparent)]
    #[derive(Copy, Clone, Eq, PartialEq)]
    pub struct Intrtx(pub u16);
    impl Intrtx {
        #[doc = "Endpoint transmit interrupt (except EP0)"]
        #[inline(always)]
        pub const fn ep_tx(&self, n: usize) -> bool {
            assert!(n < 16usize);
            let offs = 0usize + n * 1usize;
            let val = (self.0 >> offs) & 0x01;
            val != 0
        }
        #[doc = "Endpoint transmit interrupt (except EP0)"]
        #[inline(always)]
        pub fn set_ep_tx(&mut self, n: usize, val: bool) {
            assert!(n < 16usize);
            let offs = 0usize + n * 1usize;
            self.0 = (self.0 & !(0x01 << offs)) | (((val as u16) & 0x01) << offs);
        }
    }
    impl Default for Intrtx {
        #[inline(always)]
        fn default() -> Intrtx {
            Intrtx(0)
        }
    }
    #[doc = "Transmit Endpoint Interrupt Enable Register"]
    #[repr(transparent)]
    #[derive(Copy, Clone, Eq, PartialEq)]
    pub struct Intrtxe(pub u16);
    impl Intrtxe {
        #[doc = "Endpoint transmit interrupt enable (EP0:TXE_RXE)"]
        #[inline(always)]
        pub const fn ep_txe(&self, n: usize) -> bool {
            assert!(n < 16usize);
            let offs = 0usize + n * 1usize;
            let val = (self.0 >> offs) & 0x01;
            val != 0
        }
        #[doc = "Endpoint transmit interrupt enable (EP0:TXE_RXE)"]
        #[inline(always)]
        pub fn set_ep_txe(&mut self, n: usize, val: bool) {
            assert!(n < 16usize);
            let offs = 0usize + n * 1usize;
            self.0 = (self.0 & !(0x01 << offs)) | (((val as u16) & 0x01) << offs);
        }
    }
    impl Default for Intrtxe {
        #[inline(always)]
        fn default() -> Intrtxe {
            Intrtxe(0)
        }
    }
    #[doc = "USB Interrupt Status Register"]
    #[repr(transparent)]
    #[derive(Copy, Clone, Eq, PartialEq)]
    pub struct Intrusb(pub u8);
    impl Intrusb {
        #[doc = "Suspend signaling detected"]
        #[inline(always)]
        pub const fn suspend(&self) -> bool {
            let val = (self.0 >> 0usize) & 0x01;
            val != 0
        }
        #[doc = "Suspend signaling detected"]
        #[inline(always)]
        pub fn set_suspend(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u8) & 0x01) << 0usize);
        }
        #[doc = "Resume signaling detected during Suspend"]
        #[inline(always)]
        pub const fn resume(&self) -> bool {
            let val = (self.0 >> 1usize) & 0x01;
            val != 0
        }
        #[doc = "Resume signaling detected during Suspend"]
        #[inline(always)]
        pub fn set_resume(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u8) & 0x01) << 1usize);
        }
        #[doc = "Reset signaling detected"]
        #[inline(always)]
        pub const fn reset(&self) -> bool {
            let val = (self.0 >> 2usize) & 0x01;
            val != 0
        }
        #[doc = "Reset signaling detected"]
        #[inline(always)]
        pub fn set_reset(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u8) & 0x01) << 2usize);
        }
        #[doc = "New frame start"]
        #[inline(always)]
        pub const fn sof(&self) -> bool {
            let val = (self.0 >> 3usize) & 0x01;
            val != 0
        }
        #[doc = "New frame start"]
        #[inline(always)]
        pub fn set_sof(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u8) & 0x01) << 3usize);
        }
        #[doc = "Device connection detected"]
        #[inline(always)]
        pub const fn conn(&self) -> bool {
            let val = (self.0 >> 4usize) & 0x01;
            val != 0
        }
        #[doc = "Device connection detected"]
        #[inline(always)]
        pub fn set_conn(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 4usize)) | (((val as u8) & 0x01) << 4usize);
        }
        #[doc = "Device disconnection detected"]
        #[inline(always)]
        pub const fn discon(&self) -> bool {
            let val = (self.0 >> 5usize) & 0x01;
            val != 0
        }
        #[doc = "Device disconnection detected"]
        #[inline(always)]
        pub fn set_discon(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 5usize)) | (((val as u8) & 0x01) << 5usize);
        }
        #[doc = "Session Request signaling detected"]
        #[inline(always)]
        pub const fn sess_req(&self) -> bool {
            let val = (self.0 >> 6usize) & 0x01;
            val != 0
        }
        #[doc = "Session Request signaling detected"]
        #[inline(always)]
        pub fn set_sess_req(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 6usize)) | (((val as u8) & 0x01) << 6usize);
        }
        #[doc = "VBus drops below valid threshold"]
        #[inline(always)]
        pub const fn vbus_error(&self) -> bool {
            let val = (self.0 >> 7usize) & 0x01;
            val != 0
        }
        #[doc = "VBus drops below valid threshold"]
        #[inline(always)]
        pub fn set_vbus_error(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 7usize)) | (((val as u8) & 0x01) << 7usize);
        }
    }
    impl Default for Intrusb {
        #[inline(always)]
        fn default() -> Intrusb {
            Intrusb(0)
        }
    }
    #[doc = "USB Interrupt Enable Register"]
    #[repr(transparent)]
    #[derive(Copy, Clone, Eq, PartialEq)]
    pub struct Intrusbe(pub u8);
    impl Intrusbe {
        #[doc = "Enable Suspend interrupt"]
        #[inline(always)]
        pub const fn suspend_enable(&self) -> bool {
            let val = (self.0 >> 0usize) & 0x01;
            val != 0
        }
        #[doc = "Enable Suspend interrupt"]
        #[inline(always)]
        pub fn set_suspend_enable(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u8) & 0x01) << 0usize);
        }
        #[doc = "Enable Resume interrupt"]
        #[inline(always)]
        pub const fn resume_enable(&self) -> bool {
            let val = (self.0 >> 1usize) & 0x01;
            val != 0
        }
        #[doc = "Enable Resume interrupt"]
        #[inline(always)]
        pub fn set_resume_enable(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u8) & 0x01) << 1usize);
        }
        #[doc = "Enable Reset interrupt"]
        #[inline(always)]
        pub const fn reset_enable(&self) -> bool {
            let val = (self.0 >> 2usize) & 0x01;
            val != 0
        }
        #[doc = "Enable Reset interrupt"]
        #[inline(always)]
        pub fn set_reset_enable(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u8) & 0x01) << 2usize);
        }
        #[doc = "Enable Start of Frame interrupt"]
        #[inline(always)]
        pub const fn sof_enable(&self) -> bool {
            let val = (self.0 >> 3usize) & 0x01;
            val != 0
        }
        #[doc = "Enable Start of Frame interrupt"]
        #[inline(always)]
        pub fn set_sof_enable(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u8) & 0x01) << 3usize);
        }
        #[doc = "Enable Connection interrupt"]
        #[inline(always)]
        pub const fn conn_enable(&self) -> bool {
            let val = (self.0 >> 4usize) & 0x01;
            val != 0
        }
        #[doc = "Enable Connection interrupt"]
        #[inline(always)]
        pub fn set_conn_enable(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 4usize)) | (((val as u8) & 0x01) << 4usize);
        }
        #[doc = "Enable Disconnection interrupt"]
        #[inline(always)]
        pub const fn discon_enable(&self) -> bool {
            let val = (self.0 >> 5usize) & 0x01;
            val != 0
        }
        #[doc = "Enable Disconnection interrupt"]
        #[inline(always)]
        pub fn set_discon_enable(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 5usize)) | (((val as u8) & 0x01) << 5usize);
        }
        #[doc = "Enable Session Request interrupt"]
        #[inline(always)]
        pub const fn sess_req_enable(&self) -> bool {
            let val = (self.0 >> 6usize) & 0x01;
            val != 0
        }
        #[doc = "Enable Session Request interrupt"]
        #[inline(always)]
        pub fn set_sess_req_enable(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 6usize)) | (((val as u8) & 0x01) << 6usize);
        }
        #[doc = "Enable VBus Error interrupt"]
        #[inline(always)]
        pub const fn vbus_error_enable(&self) -> bool {
            let val = (self.0 >> 7usize) & 0x01;
            val != 0
        }
        #[doc = "Enable VBus Error interrupt"]
        #[inline(always)]
        pub fn set_vbus_error_enable(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 7usize)) | (((val as u8) & 0x01) << 7usize);
        }
    }
    impl Default for Intrusbe {
        #[inline(always)]
        fn default() -> Intrusbe {
            Intrusbe(0)
        }
    }
    #[doc = "USB Power Control and Status Register"]
    #[repr(transparent)]
    #[derive(Copy, Clone, Eq, PartialEq)]
    pub struct Power(pub u8);
    impl Power {
        #[doc = "Enable SUSPENDM output"]
        #[inline(always)]
        pub const fn enable_suspend_m(&self) -> bool {
            let val = (self.0 >> 0usize) & 0x01;
            val != 0
        }
        #[doc = "Enable SUSPENDM output"]
        #[inline(always)]
        pub fn set_enable_suspend_m(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u8) & 0x01) << 0usize);
        }
        #[doc = "USB suspend mode control"]
        #[inline(always)]
        pub const fn suspend_mode(&self) -> bool {
            let val = (self.0 >> 1usize) & 0x01;
            val != 0
        }
        #[doc = "USB suspend mode control"]
        #[inline(always)]
        pub fn set_suspend_mode(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u8) & 0x01) << 1usize);
        }
        #[doc = "Generate resume signaling"]
        #[inline(always)]
        pub const fn resume(&self) -> bool {
            let val = (self.0 >> 2usize) & 0x01;
            val != 0
        }
        #[doc = "Generate resume signaling"]
        #[inline(always)]
        pub fn set_resume(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u8) & 0x01) << 2usize);
        }
        #[doc = "USB reset signaling status"]
        #[inline(always)]
        pub const fn reset(&self) -> bool {
            let val = (self.0 >> 3usize) & 0x01;
            val != 0
        }
        #[doc = "USB reset signaling status"]
        #[inline(always)]
        pub fn set_reset(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u8) & 0x01) << 3usize);
        }
        #[doc = "High-speed mode negotiation status"]
        #[inline(always)]
        pub const fn hs_mode(&self) -> super::vals::HsModeStatus {
            let val = (self.0 >> 4usize) & 0x01;
            super::vals::HsModeStatus::from_bits(val as u8)
        }
        #[doc = "High-speed mode negotiation status"]
        #[inline(always)]
        pub fn set_hs_mode(&mut self, val: super::vals::HsModeStatus) {
            self.0 = (self.0 & !(0x01 << 4usize)) | (((val.to_bits() as u8) & 0x01) << 4usize);
        }
        #[doc = "Enable High-speed mode negotiation"]
        #[inline(always)]
        pub const fn hs_enab(&self) -> bool {
            let val = (self.0 >> 5usize) & 0x01;
            val != 0
        }
        #[doc = "Enable High-speed mode negotiation"]
        #[inline(always)]
        pub fn set_hs_enab(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 5usize)) | (((val as u8) & 0x01) << 5usize);
        }
        #[doc = "Enable/disable USB D+/D- lines"]
        #[inline(always)]
        pub const fn soft_conn(&self) -> bool {
            let val = (self.0 >> 6usize) & 0x01;
            val != 0
        }
        #[doc = "Enable/disable USB D+/D- lines"]
        #[inline(always)]
        pub fn set_soft_conn(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 6usize)) | (((val as u8) & 0x01) << 6usize);
        }
        #[doc = "Control isochronous packet transmission timing"]
        #[inline(always)]
        pub const fn iso_update(&self) -> super::vals::IsoUpdateMode {
            let val = (self.0 >> 7usize) & 0x01;
            super::vals::IsoUpdateMode::from_bits(val as u8)
        }
        #[doc = "Control isochronous packet transmission timing"]
        #[inline(always)]
        pub fn set_iso_update(&mut self, val: super::vals::IsoUpdateMode) {
            self.0 = (self.0 & !(0x01 << 7usize)) | (((val.to_bits() as u8) & 0x01) << 7usize);
        }
    }
    impl Default for Power {
        #[inline(always)]
        fn default() -> Power {
            Power(0)
        }
    }
    #[doc = "USB Endpoint 0 Received Data Byte Count"]
    #[repr(transparent)]
    #[derive(Copy, Clone, Eq, PartialEq)]
    pub struct Rxcount(pub u16);
    impl Rxcount {
        #[doc = "Number of received data bytes in FIFO"]
        #[inline(always)]
        pub const fn count(&self) -> u16 {
            let val = (self.0 >> 0usize) & 0x1fff;
            val as u16
        }
        #[doc = "Number of received data bytes in FIFO"]
        #[inline(always)]
        pub fn set_count(&mut self, val: u16) {
            self.0 = (self.0 & !(0x1fff << 0usize)) | (((val as u16) & 0x1fff) << 0usize);
        }
    }
    impl Default for Rxcount {
        #[inline(always)]
        fn default() -> Rxcount {
            Rxcount(0)
        }
    }
    #[doc = "RX Control and Status Register High"]
    #[repr(transparent)]
    #[derive(Copy, Clone, Eq, PartialEq)]
    pub struct Rxcsrh(pub u8);
    impl Rxcsrh {
        #[doc = "Incomplete packet in high-bandwidth Isochronous/Interrupt transfer"]
        #[inline(always)]
        pub const fn incomp_rx(&self) -> bool {
            let val = (self.0 >> 0usize) & 0x01;
            val != 0
        }
        #[doc = "Incomplete packet in high-bandwidth Isochronous/Interrupt transfer"]
        #[inline(always)]
        pub fn set_incomp_rx(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u8) & 0x01) << 0usize);
        }
        #[doc = "Select DMA Request Mode"]
        #[inline(always)]
        pub const fn dma_req_mode(&self) -> bool {
            let val = (self.0 >> 3usize) & 0x01;
            val != 0
        }
        #[doc = "Select DMA Request Mode"]
        #[inline(always)]
        pub fn set_dma_req_mode(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u8) & 0x01) << 3usize);
        }
        #[doc = "Disable NYET handshakes or indicate PID error"]
        #[inline(always)]
        pub const fn dis_nyet_pid_error(&self) -> bool {
            let val = (self.0 >> 4usize) & 0x01;
            val != 0
        }
        #[doc = "Disable NYET handshakes or indicate PID error"]
        #[inline(always)]
        pub fn set_dis_nyet_pid_error(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 4usize)) | (((val as u8) & 0x01) << 4usize);
        }
        #[doc = "Enable DMA request for RX endpoint"]
        #[inline(always)]
        pub const fn dma_req_enab(&self) -> bool {
            let val = (self.0 >> 5usize) & 0x01;
            val != 0
        }
        #[doc = "Enable DMA request for RX endpoint"]
        #[inline(always)]
        pub fn set_dma_req_enab(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 5usize)) | (((val as u8) & 0x01) << 5usize);
        }
        #[doc = "ISO mode enable"]
        #[inline(always)]
        pub const fn iso(&self) -> bool {
            let val = (self.0 >> 6usize) & 0x01;
            val != 0
        }
        #[doc = "ISO mode enable"]
        #[inline(always)]
        pub fn set_iso(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 6usize)) | (((val as u8) & 0x01) << 6usize);
        }
        #[doc = "Automatically clear RxPktRdy when max packet size is unloaded"]
        #[inline(always)]
        pub const fn auto_clear(&self) -> bool {
            let val = (self.0 >> 7usize) & 0x01;
            val != 0
        }
        #[doc = "Automatically clear RxPktRdy when max packet size is unloaded"]
        #[inline(always)]
        pub fn set_auto_clear(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 7usize)) | (((val as u8) & 0x01) << 7usize);
        }
    }
    impl Default for Rxcsrh {
        #[inline(always)]
        fn default() -> Rxcsrh {
            Rxcsrh(0)
        }
    }
    #[doc = "RX Control and Status Register Low"]
    #[repr(transparent)]
    #[derive(Copy, Clone, Eq, PartialEq)]
    pub struct Rxcsrl(pub u8);
    impl Rxcsrl {
        #[doc = "Data packet received and ready to be unloaded"]
        #[inline(always)]
        pub const fn rx_pkt_rdy(&self) -> bool {
            let val = (self.0 >> 0usize) & 0x01;
            val != 0
        }
        #[doc = "Data packet received and ready to be unloaded"]
        #[inline(always)]
        pub fn set_rx_pkt_rdy(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u8) & 0x01) << 0usize);
        }
        #[doc = "No more packets can be loaded into Rx FIFO"]
        #[inline(always)]
        pub const fn fifo_full(&self) -> bool {
            let val = (self.0 >> 1usize) & 0x01;
            val != 0
        }
        #[doc = "No more packets can be loaded into Rx FIFO"]
        #[inline(always)]
        pub fn set_fifo_full(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u8) & 0x01) << 1usize);
        }
        #[doc = "OUT packet could not be loaded into Rx FIFO"]
        #[inline(always)]
        pub const fn over_run(&self) -> bool {
            let val = (self.0 >> 2usize) & 0x01;
            val != 0
        }
        #[doc = "OUT packet could not be loaded into Rx FIFO"]
        #[inline(always)]
        pub fn set_over_run(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u8) & 0x01) << 2usize);
        }
        #[doc = "CRC or bit-stuff error in data packet"]
        #[inline(always)]
        pub const fn data_error(&self) -> bool {
            let val = (self.0 >> 3usize) & 0x01;
            val != 0
        }
        #[doc = "CRC or bit-stuff error in data packet"]
        #[inline(always)]
        pub fn set_data_error(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u8) & 0x01) << 3usize);
        }
        #[doc = "Flush next packet from Rx FIFO"]
        #[inline(always)]
        pub const fn flush_fifo(&self) -> bool {
            let val = (self.0 >> 4usize) & 0x01;
            val != 0
        }
        #[doc = "Flush next packet from Rx FIFO"]
        #[inline(always)]
        pub fn set_flush_fifo(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 4usize)) | (((val as u8) & 0x01) << 4usize);
        }
        #[doc = "Issue or terminate STALL handshake"]
        #[inline(always)]
        pub const fn send_stall(&self) -> bool {
            let val = (self.0 >> 5usize) & 0x01;
            val != 0
        }
        #[doc = "Issue or terminate STALL handshake"]
        #[inline(always)]
        pub fn set_send_stall(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 5usize)) | (((val as u8) & 0x01) << 5usize);
        }
        #[doc = "STALL handshake transmission status"]
        #[inline(always)]
        pub const fn sent_stall(&self) -> bool {
            let val = (self.0 >> 6usize) & 0x01;
            val != 0
        }
        #[doc = "STALL handshake transmission status"]
        #[inline(always)]
        pub fn set_sent_stall(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 6usize)) | (((val as u8) & 0x01) << 6usize);
        }
        #[doc = "Reset endpoint data toggle to 0"]
        #[inline(always)]
        pub const fn clr_data_tog(&self) -> bool {
            let val = (self.0 >> 7usize) & 0x01;
            val != 0
        }
        #[doc = "Reset endpoint data toggle to 0"]
        #[inline(always)]
        pub fn set_clr_data_tog(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 7usize)) | (((val as u8) & 0x01) << 7usize);
        }
    }
    impl Default for Rxcsrl {
        #[inline(always)]
        fn default() -> Rxcsrl {
            Rxcsrl(0)
        }
    }
    #[doc = "Maximum payload size for RX endpoint"]
    #[repr(transparent)]
    #[derive(Copy, Clone, Eq, PartialEq)]
    pub struct Rxmaxp(pub u16);
    impl Rxmaxp {
        #[doc = "Maximum payload in bytes"]
        #[inline(always)]
        pub const fn maxp(&self) -> u16 {
            let val = (self.0 >> 0usize) & 0x07ff;
            val as u16
        }
        #[doc = "Maximum payload in bytes"]
        #[inline(always)]
        pub fn set_maxp(&mut self, val: u16) {
            self.0 = (self.0 & !(0x07ff << 0usize)) | (((val as u16) & 0x07ff) << 0usize);
        }
    }
    impl Default for Rxmaxp {
        #[inline(always)]
        fn default() -> Rxmaxp {
            Rxmaxp(0)
        }
    }
    #[doc = "USB test mode configuration register"]
    #[repr(transparent)]
    #[derive(Copy, Clone, Eq, PartialEq)]
    pub struct Testmode(pub u8);
    impl Testmode {
        #[doc = "Enter Test_SE0_NAK high-speed test mode"]
        #[inline(always)]
        pub const fn test_se0_nak(&self) -> bool {
            let val = (self.0 >> 0usize) & 0x01;
            val != 0
        }
        #[doc = "Enter Test_SE0_NAK high-speed test mode"]
        #[inline(always)]
        pub fn set_test_se0_nak(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u8) & 0x01) << 0usize);
        }
        #[doc = "Enter Test_J high-speed test mode"]
        #[inline(always)]
        pub const fn test_j(&self) -> bool {
            let val = (self.0 >> 1usize) & 0x01;
            val != 0
        }
        #[doc = "Enter Test_J high-speed test mode"]
        #[inline(always)]
        pub fn set_test_j(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u8) & 0x01) << 1usize);
        }
        #[doc = "Enter Test_K high-speed test mode"]
        #[inline(always)]
        pub const fn test_k(&self) -> bool {
            let val = (self.0 >> 2usize) & 0x01;
            val != 0
        }
        #[doc = "Enter Test_K high-speed test mode"]
        #[inline(always)]
        pub fn set_test_k(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u8) & 0x01) << 2usize);
        }
        #[doc = "Enter Test_Packet high-speed test mode"]
        #[inline(always)]
        pub const fn test_packet(&self) -> bool {
            let val = (self.0 >> 3usize) & 0x01;
            val != 0
        }
        #[doc = "Enter Test_Packet high-speed test mode"]
        #[inline(always)]
        pub fn set_test_packet(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u8) & 0x01) << 3usize);
        }
        #[doc = "Force High-speed mode on USB reset"]
        #[inline(always)]
        pub const fn force_hs(&self) -> bool {
            let val = (self.0 >> 4usize) & 0x01;
            val != 0
        }
        #[doc = "Force High-speed mode on USB reset"]
        #[inline(always)]
        pub fn set_force_hs(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 4usize)) | (((val as u8) & 0x01) << 4usize);
        }
        #[doc = "Force Full-speed mode on USB reset"]
        #[inline(always)]
        pub const fn force_fs(&self) -> bool {
            let val = (self.0 >> 5usize) & 0x01;
            val != 0
        }
        #[doc = "Force Full-speed mode on USB reset"]
        #[inline(always)]
        pub fn set_force_fs(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 5usize)) | (((val as u8) & 0x01) << 5usize);
        }
        #[doc = "Transfer packet from Endpoint 0 TX FIFO to Endpoint 0 Rx FIFO"]
        #[inline(always)]
        pub const fn fifo_access(&self) -> bool {
            let val = (self.0 >> 6usize) & 0x01;
            val != 0
        }
        #[doc = "Transfer packet from Endpoint 0 TX FIFO to Endpoint 0 Rx FIFO"]
        #[inline(always)]
        pub fn set_fifo_access(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 6usize)) | (((val as u8) & 0x01) << 6usize);
        }
        #[doc = "Force core to enter Host mode"]
        #[inline(always)]
        pub const fn force_host(&self) -> super::vals::ForceHostMode {
            let val = (self.0 >> 7usize) & 0x01;
            super::vals::ForceHostMode::from_bits(val as u8)
        }
        #[doc = "Force core to enter Host mode"]
        #[inline(always)]
        pub fn set_force_host(&mut self, val: super::vals::ForceHostMode) {
            self.0 = (self.0 & !(0x01 << 7usize)) | (((val.to_bits() as u8) & 0x01) << 7usize);
        }
    }
    impl Default for Testmode {
        #[inline(always)]
        fn default() -> Testmode {
            Testmode(0)
        }
    }
    #[doc = "Additional TX endpoint control register"]
    #[repr(transparent)]
    #[derive(Copy, Clone, Eq, PartialEq)]
    pub struct Txcsrh(pub u8);
    impl Txcsrh {
        #[doc = "Select DMA Request Mode"]
        #[inline(always)]
        pub const fn dma_req_mode(&self) -> bool {
            let val = (self.0 >> 2usize) & 0x01;
            val != 0
        }
        #[doc = "Select DMA Request Mode"]
        #[inline(always)]
        pub fn set_dma_req_mode(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u8) & 0x01) << 2usize);
        }
        #[doc = "Force endpoint data toggle switch"]
        #[inline(always)]
        pub const fn frc_data_tog(&self) -> bool {
            let val = (self.0 >> 3usize) & 0x01;
            val != 0
        }
        #[doc = "Force endpoint data toggle switch"]
        #[inline(always)]
        pub fn set_frc_data_tog(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u8) & 0x01) << 3usize);
        }
        #[doc = "Enable DMA request for TX endpoint"]
        #[inline(always)]
        pub const fn dmareq_enab(&self) -> bool {
            let val = (self.0 >> 4usize) & 0x01;
            val != 0
        }
        #[doc = "Enable DMA request for TX endpoint"]
        #[inline(always)]
        pub fn set_dmareq_enab(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 4usize)) | (((val as u8) & 0x01) << 4usize);
        }
        #[doc = "Endpoint direction control"]
        #[inline(always)]
        pub const fn mode(&self) -> super::vals::EndpointDirection {
            let val = (self.0 >> 5usize) & 0x01;
            super::vals::EndpointDirection::from_bits(val as u8)
        }
        #[doc = "Endpoint direction control"]
        #[inline(always)]
        pub fn set_mode(&mut self, val: super::vals::EndpointDirection) {
            self.0 = (self.0 & !(0x01 << 5usize)) | (((val.to_bits() as u8) & 0x01) << 5usize);
        }
        #[doc = "Enable Isochronous transfers"]
        #[inline(always)]
        pub const fn iso(&self) -> bool {
            let val = (self.0 >> 6usize) & 0x01;
            val != 0
        }
        #[doc = "Enable Isochronous transfers"]
        #[inline(always)]
        pub fn set_iso(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 6usize)) | (((val as u8) & 0x01) << 6usize);
        }
        #[doc = "Automatically set TxPktRdy for max packet size"]
        #[inline(always)]
        pub const fn auto_set(&self) -> bool {
            let val = (self.0 >> 7usize) & 0x01;
            val != 0
        }
        #[doc = "Automatically set TxPktRdy for max packet size"]
        #[inline(always)]
        pub fn set_auto_set(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 7usize)) | (((val as u8) & 0x01) << 7usize);
        }
    }
    impl Default for Txcsrh {
        #[inline(always)]
        fn default() -> Txcsrh {
            Txcsrh(0)
        }
    }
    #[doc = "TX endpoint control and status register"]
    #[repr(transparent)]
    #[derive(Copy, Clone, Eq, PartialEq)]
    pub struct Txcsrl(pub u8);
    impl Txcsrl {
        #[doc = "TX packet ready for transmission"]
        #[inline(always)]
        pub const fn tx_pkt_rdy(&self) -> bool {
            let val = (self.0 >> 0usize) & 0x01;
            val != 0
        }
        #[doc = "TX packet ready for transmission"]
        #[inline(always)]
        pub fn set_tx_pkt_rdy(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u8) & 0x01) << 0usize);
        }
        #[doc = "TX FIFO contains at least one packet"]
        #[inline(always)]
        pub const fn fifo_not_empty(&self) -> bool {
            let val = (self.0 >> 1usize) & 0x01;
            val != 0
        }
        #[doc = "TX FIFO contains at least one packet"]
        #[inline(always)]
        pub fn set_fifo_not_empty(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u8) & 0x01) << 1usize);
        }
        #[doc = "IN token received without TxPktRdy"]
        #[inline(always)]
        pub const fn under_run(&self) -> bool {
            let val = (self.0 >> 2usize) & 0x01;
            val != 0
        }
        #[doc = "IN token received without TxPktRdy"]
        #[inline(always)]
        pub fn set_under_run(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u8) & 0x01) << 2usize);
        }
        #[doc = "Flush TX FIFO"]
        #[inline(always)]
        pub const fn flush_fifo(&self) -> bool {
            let val = (self.0 >> 3usize) & 0x01;
            val != 0
        }
        #[doc = "Flush TX FIFO"]
        #[inline(always)]
        pub fn set_flush_fifo(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u8) & 0x01) << 3usize);
        }
        #[doc = "Issue STALL handshake to IN token"]
        #[inline(always)]
        pub const fn send_stall(&self) -> bool {
            let val = (self.0 >> 4usize) & 0x01;
            val != 0
        }
        #[doc = "Issue STALL handshake to IN token"]
        #[inline(always)]
        pub fn set_send_stall(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 4usize)) | (((val as u8) & 0x01) << 4usize);
        }
        #[doc = "STALL handshake transmission status"]
        #[inline(always)]
        pub const fn sent_stall(&self) -> bool {
            let val = (self.0 >> 5usize) & 0x01;
            val != 0
        }
        #[doc = "STALL handshake transmission status"]
        #[inline(always)]
        pub fn set_sent_stall(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 5usize)) | (((val as u8) & 0x01) << 5usize);
        }
        #[doc = "Reset endpoint data toggle"]
        #[inline(always)]
        pub const fn clr_data_tog(&self) -> bool {
            let val = (self.0 >> 6usize) & 0x01;
            val != 0
        }
        #[doc = "Reset endpoint data toggle"]
        #[inline(always)]
        pub fn set_clr_data_tog(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 6usize)) | (((val as u8) & 0x01) << 6usize);
        }
        #[doc = "Incomplete high-bandwidth Isochronous transfer"]
        #[inline(always)]
        pub const fn incomp_tx(&self) -> bool {
            let val = (self.0 >> 7usize) & 0x01;
            val != 0
        }
        #[doc = "Incomplete high-bandwidth Isochronous transfer"]
        #[inline(always)]
        pub fn set_incomp_tx(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 7usize)) | (((val as u8) & 0x01) << 7usize);
        }
    }
    impl Default for Txcsrl {
        #[inline(always)]
        fn default() -> Txcsrl {
            Txcsrl(0)
        }
    }
    #[doc = "Maximum payload size for TX endpoint"]
    #[repr(transparent)]
    #[derive(Copy, Clone, Eq, PartialEq)]
    pub struct Txmaxp(pub u16);
    impl Txmaxp {
        #[doc = "Maximum payload in bytes"]
        #[inline(always)]
        pub const fn maxp(&self) -> u16 {
            let val = (self.0 >> 0usize) & 0x07ff;
            val as u16
        }
        #[doc = "Maximum payload in bytes"]
        #[inline(always)]
        pub fn set_maxp(&mut self, val: u16) {
            self.0 = (self.0 & !(0x07ff << 0usize)) | (((val as u16) & 0x07ff) << 0usize);
        }
    }
    impl Default for Txmaxp {
        #[inline(always)]
        fn default() -> Txmaxp {
            Txmaxp(0)
        }
    }
}
pub mod vals {
    #[repr(u8)]
    #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
    pub enum EndpointDirection {
        RX = 0x0,
        TX = 0x01,
    }
    impl EndpointDirection {
        #[inline(always)]
        pub const fn from_bits(val: u8) -> EndpointDirection {
            unsafe { core::mem::transmute(val & 0x01) }
        }
        #[inline(always)]
        pub const fn to_bits(self) -> u8 {
            unsafe { core::mem::transmute(self) }
        }
    }
    impl From<u8> for EndpointDirection {
        #[inline(always)]
        fn from(val: u8) -> EndpointDirection {
            EndpointDirection::from_bits(val)
        }
    }
    impl From<EndpointDirection> for u8 {
        #[inline(always)]
        fn from(val: EndpointDirection) -> u8 {
            EndpointDirection::to_bits(val)
        }
    }
    #[repr(u8)]
    #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
    pub enum ForceHostMode {
        NORMAL = 0x0,
        FORCE = 0x01,
    }
    impl ForceHostMode {
        #[inline(always)]
        pub const fn from_bits(val: u8) -> ForceHostMode {
            unsafe { core::mem::transmute(val & 0x01) }
        }
        #[inline(always)]
        pub const fn to_bits(self) -> u8 {
            unsafe { core::mem::transmute(self) }
        }
    }
    impl From<u8> for ForceHostMode {
        #[inline(always)]
        fn from(val: u8) -> ForceHostMode {
            ForceHostMode::from_bits(val)
        }
    }
    impl From<ForceHostMode> for u8 {
        #[inline(always)]
        fn from(val: ForceHostMode) -> u8 {
            ForceHostMode::to_bits(val)
        }
    }
    #[repr(u8)]
    #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
    pub enum HsModeStatus {
        FULL_SPEED = 0x0,
        HIGH_SPEED = 0x01,
    }
    impl HsModeStatus {
        #[inline(always)]
        pub const fn from_bits(val: u8) -> HsModeStatus {
            unsafe { core::mem::transmute(val & 0x01) }
        }
        #[inline(always)]
        pub const fn to_bits(self) -> u8 {
            unsafe { core::mem::transmute(self) }
        }
    }
    impl From<u8> for HsModeStatus {
        #[inline(always)]
        fn from(val: u8) -> HsModeStatus {
            HsModeStatus::from_bits(val)
        }
    }
    impl From<HsModeStatus> for u8 {
        #[inline(always)]
        fn from(val: HsModeStatus) -> u8 {
            HsModeStatus::to_bits(val)
        }
    }
    #[repr(u8)]
    #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
    pub enum IsoUpdateMode {
        NORMAL = 0x0,
        WAIT_SOF = 0x01,
    }
    impl IsoUpdateMode {
        #[inline(always)]
        pub const fn from_bits(val: u8) -> IsoUpdateMode {
            unsafe { core::mem::transmute(val & 0x01) }
        }
        #[inline(always)]
        pub const fn to_bits(self) -> u8 {
            unsafe { core::mem::transmute(self) }
        }
    }
    impl From<u8> for IsoUpdateMode {
        #[inline(always)]
        fn from(val: u8) -> IsoUpdateMode {
            IsoUpdateMode::from_bits(val)
        }
    }
    impl From<IsoUpdateMode> for u8 {
        #[inline(always)]
        fn from(val: IsoUpdateMode) -> u8 {
            IsoUpdateMode::to_bits(val)
        }
    }
    #[repr(u8)]
    #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
    pub enum UtmiWidth {
        EIGHT_BIT = 0x0,
        SIXTEEN_BIT = 0x01,
    }
    impl UtmiWidth {
        #[inline(always)]
        pub const fn from_bits(val: u8) -> UtmiWidth {
            unsafe { core::mem::transmute(val & 0x01) }
        }
        #[inline(always)]
        pub const fn to_bits(self) -> u8 {
            unsafe { core::mem::transmute(self) }
        }
    }
    impl From<u8> for UtmiWidth {
        #[inline(always)]
        fn from(val: u8) -> UtmiWidth {
            UtmiWidth::from_bits(val)
        }
    }
    impl From<UtmiWidth> for u8 {
        #[inline(always)]
        fn from(val: UtmiWidth) -> u8 {
            UtmiWidth::to_bits(val)
        }
    }
}