Skip to content

Commit 3ce4cce

Browse files
Codetector1374Dummyc0m
authored andcommitted
peripheral(usbhs): various fixes and enhancements
This change is a companion change for the usbhs driver of ch32-hal. It mainly contains the following changes: - renmae usb_v3hs to usbhs_v3 - remove endpoint DMA register field definition - fix the stride of `UEPn_T_LEN`, `UEPn_TX_CTRL` and `UEPn_RX_CTRL`
1 parent 340c5ee commit 3ce4cce

File tree

2 files changed

+94
-18
lines changed

2 files changed

+94
-18
lines changed

data/peripherals/FV2x_V3x_USBHS.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
- name: USBHS
33
address: 0x40023400
44
registers:
5-
kind: usb
6-
version: v3hs
5+
kind: usbhs
6+
version: v3
77
block: USB
88
rcc:
99
bus_clock: HCLK
Lines changed: 92 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -78,23 +78,20 @@ block/USBD:
7878
description: endpoint 0 DMA buffer address.
7979
byte_offset: 0x1C
8080
bit_size: 32
81-
fieldset: EP_DMA
8281
- name: EP_RX_DMA
8382
description: endpoint n (n=1-15) DMA RX buffer address.
8483
byte_offset: 0x20
8584
bit_size: 32
8685
array:
8786
len: 15
8887
stride: 4
89-
fieldset: EP_DMA
9088
- name: EP_TX_DMA
9189
description: endpoint n (n=1-15) DMA TX buffer address.
9290
byte_offset: 0x5C
9391
bit_size: 32
9492
array:
9593
len: 15
9694
stride: 4
97-
fieldset: EP_DMA
9895
- name: EP_MAX_LEN
9996
description: endpoint n (n=0-15) max acceptable length.
10097
byte_offset: 0x98
@@ -109,23 +106,23 @@ block/USBD:
109106
bit_size: 16
110107
array:
111108
len: 16
112-
stride: 12
109+
stride: 4
113110
fieldset: EP_LEN
114111
- name: EP_TX_CTRL
115112
description: endpoint n (n=0-15) send control.
116113
byte_offset: 0xDA
117114
bit_size: 8
118115
array:
119116
len: 16
120-
stride: 12
117+
stride: 4
121118
fieldset: EP_TX_CTRL
122119
- name: EP_RX_CTRL
123120
description: endpoint n (n=0-15) receive control.
124121
byte_offset: 0xDB
125122
bit_size: 8
126123
array:
127124
len: 16
128-
stride: 12
125+
stride: 4
129126
fieldset: EP_RX_CTRL
130127

131128
block/USBH:
@@ -149,12 +146,10 @@ block/USBH:
149146
description: USB host receive buffer start address
150147
byte_offset: 0x24
151148
bit_size: 32
152-
fieldset: EP_DMA
153149
- name: TX_DMA
154150
description: USB host transmit buffer start address
155151
byte_offset: 0x28
156152
bit_size: 32
157-
fieldset: EP_DMA
158153
- name: RX_MAX_LEN
159154
description: USB host receive maximum length packet register
160155
byte_offset: 0xA0
@@ -215,6 +210,7 @@ fieldset/CTRL:
215210
description: "enable USB low speed: 00=full speed, 01=high speed, 10 =low speed."
216211
bit_offset: 5
217212
bit_size: 2
213+
enum: SPEED_TYPE
218214
- name: HOST_MODE
219215
description: "enable USB host mode: 0=device mode, 1=host mode."
220216
bit_offset: 7
@@ -331,6 +327,7 @@ fieldset/INT_ST:
331327
description: RO, bit mask of current token PID code received for USB device mode.
332328
bit_offset: 4
333329
bit_size: 2
330+
enum: USB_TOKEN
334331
- name: TOG_OK
335332
description: RO, indicate current USB transfer toggle is OK.
336333
bit_offset: 6
@@ -383,6 +380,7 @@ fieldset/SPEED_TYPE:
383380
description: in host mode, it indicates the speed type of the currently connected device; in device mode, it indicates the speed type of the current device.
384381
bit_offset: 0
385382
bit_size: 2
383+
enum: SPEED_TYPE
386384
fieldset/SUSPEND:
387385
description: indicate USB suspend status.
388386
bit_size: 8
@@ -428,13 +426,15 @@ fieldset/EP_TYPE:
428426
description: Endpoint 1 to 15 receive type, 1 means synchronous transmission
429427
bit_offset: 17
430428
bit_size: 1
429+
enum: ENDPOINT_TYPE
431430
array:
432431
len: 15
433432
stride: 1
434433
- name: T_TYPE
435434
description: Endpoint 1 to 15 transmit type, 1 means synchronous transmission
436435
bit_offset: 1
437436
bit_size: 1
437+
enum: ENDPOINT_TYPE
438438
array:
439439
len: 15
440440
stride: 1
@@ -468,10 +468,12 @@ fieldset/EP_TX_CTRL:
468468
description: MASK_UEP_T_TOG
469469
bit_offset: 3
470470
bit_size: 2
471+
enum: EP_TOG
471472
- name: MASK_UEP_T_RES
472473
description: MASK_UEP_T_RES
473474
bit_offset: 0
474475
bit_size: 2
476+
enum: EP_TX_RESPONSE
475477
fieldset/EP_RX_CTRL:
476478
description: endpoint n receive control.
477479
bit_size: 8
@@ -484,10 +486,12 @@ fieldset/EP_RX_CTRL:
484486
description: MASK_UEP_R_TOG
485487
bit_offset: 3
486488
bit_size: 2
489+
enum: EP_TOG
487490
- name: MASK_UEP_R_RES
488491
description: MASK_UEP_R_RES
489492
bit_offset: 0
490493
bit_size: 2
494+
enum: EP_RX_RESPONSE
491495

492496
# --------
493497
# UH
@@ -617,14 +621,6 @@ fieldset/UH_SPLIT_DATA:
617621
bit_size: 12
618622

619623
# shared
620-
fieldset/EP_DMA:
621-
description: USB endpoint DMA buffer address.
622-
bit_size: 32
623-
fields:
624-
- name: ADDR
625-
description: USB endpoint DMA buffer address. 4byte aligned.
626-
bit_offset: 0
627-
bit_size: 17
628624
fieldset/EP_LEN:
629625
description: endpoint n acceptable length.
630626
bit_size: 16
@@ -633,3 +629,83 @@ fieldset/EP_LEN:
633629
description: endpoint n acceptable length.
634630
bit_offset: 0
635631
bit_size: 11
632+
633+
enum/SPEED_TYPE:
634+
bit_size: 2
635+
variants:
636+
- name: FullSpeed
637+
description: USB Full Speed (12Mbps)
638+
value: 0
639+
- name: HighSpeed
640+
description: USB High Speed (480Mbps)
641+
value: 1
642+
- name: LowSpeed
643+
description: USB Low Speed (1.5Mbps)
644+
value: 2
645+
646+
enum/USB_TOKEN:
647+
bit_size: 2
648+
variants:
649+
- name: OUT
650+
description: OUT Packet
651+
value: 0
652+
- name: SOF
653+
description: Start of Frame
654+
value: 1
655+
- name: IN
656+
description: IN Packet
657+
value: 2
658+
- name: SETUP
659+
description: SETUP Packet
660+
value: 3
661+
662+
enum/ENDPOINT_TYPE:
663+
bit_size: 1
664+
variants:
665+
- name: NISO
666+
description: Non Isochronous (Interrupt/Bulk)
667+
value: 0
668+
- name: ISO
669+
description: Isochronous Transfer
670+
value: 1
671+
672+
enum/EP_TOG:
673+
bit_size: 2
674+
variants:
675+
- name: DATA0
676+
value: 0
677+
- name: DATA1
678+
value: 1
679+
- name: DATA2
680+
value: 2
681+
- name: MDATA
682+
value: 3
683+
684+
enum/EP_TX_RESPONSE:
685+
bit_size: 2
686+
variants:
687+
- name: ACK
688+
description: Respond with DATA0/DATA1 and expect ACK
689+
value: 0
690+
- name: NAK
691+
description: Respond with NAK or Busy
692+
value: 2
693+
- name: STALL
694+
description: Respond with STALL or Error
695+
value: 3
696+
697+
enum/EP_RX_RESPONSE:
698+
bit_size: 2
699+
variants:
700+
- name: ACK
701+
description: Respond with ACK
702+
value: 0
703+
- name: NYET
704+
description: Respond NYET
705+
value: 1
706+
- name: NAK
707+
description: Respond with NAK(Busy)
708+
value: 2
709+
- name: STALL
710+
description: Respond with STALL(Error)
711+
value: 3

0 commit comments

Comments
 (0)