From 6107d5a72ed9041548943c071c2933df516e17b6 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Sat, 9 Apr 2022 00:28:44 +0200 Subject: [PATCH] Add USB --- data/registers/usb_v1.yaml | 272 +++++++++++++++++++++++++++ data/registers/usb_v2.yaml | 370 +++++++++++++++++++++++++++++++++++++ stm32data/__main__.py | 4 + 3 files changed, 646 insertions(+) create mode 100644 data/registers/usb_v1.yaml create mode 100644 data/registers/usb_v2.yaml diff --git a/data/registers/usb_v1.yaml b/data/registers/usb_v1.yaml new file mode 100644 index 0000000..259b17f --- /dev/null +++ b/data/registers/usb_v1.yaml @@ -0,0 +1,272 @@ +--- +block/USB: + description: Universal serial bus full-speed device interface + items: + - name: EPR + description: endpoint register + array: + len: 8 + stride: 4 + byte_offset: 0 + fieldset: EPR + - name: CNTR + description: control register + byte_offset: 64 + fieldset: CNTR + - name: ISTR + description: interrupt status register + byte_offset: 68 + fieldset: ISTR + - name: FNR + description: frame number register + byte_offset: 72 + access: Read + fieldset: FNR + - name: DADDR + description: device address + byte_offset: 76 + fieldset: DADDR + - name: BTABLE + description: Buffer table address + byte_offset: 80 + fieldset: BTABLE +fieldset/BTABLE: + description: Buffer table address + fields: + - name: BTABLE + description: BTABLE + bit_offset: 3 + bit_size: 13 +fieldset/CNTR: + description: control register + fields: + - name: FRES + description: "Force a reset of the USB peripheral, exactly like a RESET signaling on the USB" + bit_offset: 0 + bit_size: 1 + - name: PDWN + description: Enter power down mode + bit_offset: 1 + bit_size: 1 + - name: LPMODE + description: Enter low-power mode + bit_offset: 2 + bit_size: 1 + - name: FSUSP + description: Enter suspend mode. Clocks and static power dissipation in the analog transceiver are left unaffected + bit_offset: 3 + bit_size: 1 + - name: RESUME + description: Resume request + bit_offset: 4 + bit_size: 1 + - name: ESOFM + description: "ESOF Interrupt enabled, an interrupt request is generated when the corresponding bit in the USB_ISTR register is set" + bit_offset: 8 + bit_size: 1 + - name: SOFM + description: "SOF Interrupt enabled, an interrupt request is generated when the corresponding bit in the USB_ISTR register is set" + bit_offset: 9 + bit_size: 1 + - name: RESETM + description: "RESET Interrupt enabled, an interrupt request is generated when the corresponding bit in the USB_ISTR register is set" + bit_offset: 10 + bit_size: 1 + - name: SUSPM + description: "SUSP Interrupt enabled, an interrupt request is generated when the corresponding bit in the USB_ISTR register is set" + bit_offset: 11 + bit_size: 1 + - name: WKUPM + description: "WKUP Interrupt enabled, an interrupt request is generated when the corresponding bit in the USB_ISTR register is set" + bit_offset: 12 + bit_size: 1 + - name: ERRM + description: "ERR Interrupt enabled, an interrupt request is generated when the corresponding bit in the USB_ISTR register is set" + bit_offset: 13 + bit_size: 1 + - name: PMAOVRM + description: "PMAOVR Interrupt enabled, an interrupt request is generated when the corresponding bit in the USB_ISTR register is set" + bit_offset: 14 + bit_size: 1 + - name: CTRM + description: "CTR Interrupt enabled, an interrupt request is generated when the corresponding bit in the USB_ISTR register is set" + bit_offset: 15 + bit_size: 1 +fieldset/DADDR: + description: device address + fields: + - name: ADD + description: device address + bit_offset: 0 + bit_size: 7 + - name: EF + description: USB device enabled + bit_offset: 7 + bit_size: 1 +fieldset/EPR: + description: endpoint register + fields: + - name: EA + description: EA + bit_offset: 0 + bit_size: 4 + - name: STAT_TX + description: STAT_TX + bit_offset: 4 + bit_size: 2 + enum: STAT_TX + - name: DTOG_TX + description: DTOG_TX + bit_offset: 6 + bit_size: 1 + - name: CTR_TX + description: CTR_TX + bit_offset: 7 + bit_size: 1 + - name: EP_KIND + description: EP_KIND + bit_offset: 8 + bit_size: 1 + - name: EP_TYPE + description: EPTYPE + bit_offset: 9 + bit_size: 2 + enum: EP_TYPE + - name: SETUP + description: SETUP + bit_offset: 11 + bit_size: 1 + - name: STAT_RX + description: STAT_RX + bit_offset: 12 + bit_size: 2 + enum: STAT_RX + - name: DTOG_RX + description: DTOG_RX + bit_offset: 14 + bit_size: 1 + - name: CTR_RX + description: CTR_RX + bit_offset: 15 + bit_size: 1 +fieldset/FNR: + description: frame number register + fields: + - name: FN + description: FN + bit_offset: 0 + bit_size: 11 + - name: LSOF + description: LSOF + bit_offset: 11 + bit_size: 2 + - name: LCK + description: the frame timer remains in this state until an USB reset or USB suspend event occurs + bit_offset: 13 + bit_size: 1 + - name: RXDM + description: received data minus upstream port data line + bit_offset: 14 + bit_size: 1 + - name: RXDP + description: received data plus upstream port data line + bit_offset: 15 + bit_size: 1 +fieldset/ISTR: + description: interrupt status register + fields: + - name: EP_ID + description: EP_ID + bit_offset: 0 + bit_size: 4 + - name: DIR + description: DIR + bit_offset: 4 + bit_size: 1 + enum: DIR + - name: ESOF + description: an SOF packet is expected but not received + bit_offset: 8 + bit_size: 1 + - name: SOF + description: beginning of a new USB frame and it is set when a SOF packet arrives through the USB bus + bit_offset: 9 + bit_size: 1 + - name: RESET + description: peripheral detects an active USB RESET signal at its inputs + bit_offset: 10 + bit_size: 1 + - name: SUSP + description: "no traffic has been received for 3 ms, indicating a suspend mode request from the USB bus" + bit_offset: 11 + bit_size: 1 + - name: WKUP + description: activity is detected that wakes up the USB peripheral + bit_offset: 12 + bit_size: 1 + - name: ERR + description: "One of No ANSwer, Cyclic Redundancy Check, Bit Stuffing or Framing format Violation error occurred" + bit_offset: 13 + bit_size: 1 + - name: PMAOVR + description: microcontroller has not been able to respond in time to an USB memory request + bit_offset: 14 + bit_size: 1 + - name: CTR + description: endpoint has successfully completed a transaction + bit_offset: 15 + bit_size: 1 +enum/DIR: + bit_size: 1 + variants: + - name: To + description: data transmitted by the USB peripheral to the host PC + value: 0 + - name: From + description: data received by the USB peripheral from the host PC + value: 1 +enum/EP_TYPE: + bit_size: 2 + variants: + - name: Bulk + description: Bulk endpoint + value: 0 + - name: Control + description: Control endpoint + value: 1 + - name: Iso + description: Iso endpoint + value: 2 + - name: Interrupt + description: Interrupt endpoint + value: 3 +enum/STAT_RX: + bit_size: 2 + variants: + - name: Disabled + description: all reception requests addressed to this endpoint are ignored + value: 0 + - name: Stall + description: the endpoint is stalled and all reception requests result in a STALL handshake + value: 1 + - name: Nak + description: the endpoint is naked and all reception requests result in a NAK handshake + value: 2 + - name: Valid + description: this endpoint is enabled for reception + value: 3 +enum/STAT_TX: + bit_size: 2 + variants: + - name: Disabled + description: all transmission requests addressed to this endpoint are ignored + value: 0 + - name: Stall + description: the endpoint is stalled and all transmission requests result in a STALL handshake + value: 1 + - name: Nak + description: the endpoint is naked and all transmission requests result in a NAK handshake + value: 2 + - name: Valid + description: this endpoint is enabled for transmission + value: 3 diff --git a/data/registers/usb_v2.yaml b/data/registers/usb_v2.yaml new file mode 100644 index 0000000..f5d20de --- /dev/null +++ b/data/registers/usb_v2.yaml @@ -0,0 +1,370 @@ +--- +block/USB: + description: Universal serial bus full-speed device interface + items: + - name: EPR + description: endpoint register + array: + len: 8 + stride: 4 + byte_offset: 0 + fieldset: EPR + - name: CNTR + description: control register + byte_offset: 64 + fieldset: CNTR + - name: ISTR + description: interrupt status register + byte_offset: 68 + fieldset: ISTR + - name: FNR + description: frame number register + byte_offset: 72 + access: Read + fieldset: FNR + - name: DADDR + description: device address + byte_offset: 76 + fieldset: DADDR + - name: BTABLE + description: Buffer table address + byte_offset: 80 + fieldset: BTABLE + - name: LPMCSR + description: LPM control and status register + byte_offset: 84 + fieldset: LPMCSR + - name: BCDR + description: Battery Charging Detector + byte_offset: 88 + fieldset: BCDR +fieldset/BCDR: + description: Battery Charging Detector + fields: + - name: BCDEN + description: Battery charging detector mode enable + bit_offset: 0 + bit_size: 1 + - name: DCDEN + description: Data contact detection mode enable + bit_offset: 1 + bit_size: 1 + - name: PDEN + description: Primary detection mode enable + bit_offset: 2 + bit_size: 1 + - name: SDEN + description: Secondary detection mode enable + bit_offset: 3 + bit_size: 1 + - name: DCDET + description: Data contact detection status + bit_offset: 4 + bit_size: 1 + - name: PDET + description: Primary detection status + bit_offset: 5 + bit_size: 1 + - name: SDET + description: Secondary detection status + bit_offset: 6 + bit_size: 1 + enum: SDET + - name: PS2DET + description: DM pull-up detection status + bit_offset: 7 + bit_size: 1 + - name: DPPU + description: DP pull-up control + bit_offset: 15 + bit_size: 1 +fieldset/BTABLE: + description: Buffer table address + fields: + - name: BTABLE + description: BTABLE + bit_offset: 3 + bit_size: 13 +fieldset/CNTR: + description: control register + fields: + - name: FRES + description: "Force a reset of the USB peripheral, exactly like a RESET signaling on the USB" + bit_offset: 0 + bit_size: 1 + - name: PDWN + description: Enter power down mode + bit_offset: 1 + bit_size: 1 + - name: LPMODE + description: Enter low-power mode + bit_offset: 2 + bit_size: 1 + - name: FSUSP + description: Enter suspend mode. Clocks and static power dissipation in the analog transceiver are left unaffected + bit_offset: 3 + bit_size: 1 + - name: RESUME + description: Resume request + bit_offset: 4 + bit_size: 1 + - name: L1RESUME + description: LPM L1 request request + bit_offset: 5 + bit_size: 1 + - name: L1REQM + description: "L1REQ Interrupt enabled, an interrupt request is generated when the corresponding bit in the USB_ISTR register is set" + bit_offset: 7 + bit_size: 1 + - name: ESOFM + description: "ESOF Interrupt enabled, an interrupt request is generated when the corresponding bit in the USB_ISTR register is set" + bit_offset: 8 + bit_size: 1 + - name: SOFM + description: "SOF Interrupt enabled, an interrupt request is generated when the corresponding bit in the USB_ISTR register is set" + bit_offset: 9 + bit_size: 1 + - name: RESETM + description: "RESET Interrupt enabled, an interrupt request is generated when the corresponding bit in the USB_ISTR register is set" + bit_offset: 10 + bit_size: 1 + - name: SUSPM + description: "SUSP Interrupt enabled, an interrupt request is generated when the corresponding bit in the USB_ISTR register is set" + bit_offset: 11 + bit_size: 1 + - name: WKUPM + description: "WKUP Interrupt enabled, an interrupt request is generated when the corresponding bit in the USB_ISTR register is set" + bit_offset: 12 + bit_size: 1 + - name: ERRM + description: "ERR Interrupt enabled, an interrupt request is generated when the corresponding bit in the USB_ISTR register is set" + bit_offset: 13 + bit_size: 1 + - name: PMAOVRM + description: "PMAOVR Interrupt enabled, an interrupt request is generated when the corresponding bit in the USB_ISTR register is set" + bit_offset: 14 + bit_size: 1 + - name: CTRM + description: "CTR Interrupt enabled, an interrupt request is generated when the corresponding bit in the USB_ISTR register is set" + bit_offset: 15 + bit_size: 1 +fieldset/DADDR: + description: device address + fields: + - name: ADD + description: device address + bit_offset: 0 + bit_size: 7 + - name: EF + description: USB device enabled + bit_offset: 7 + bit_size: 1 +fieldset/EPR: + description: endpoint register + fields: + - name: EA + description: EA + bit_offset: 0 + bit_size: 4 + - name: STAT_TX + description: STAT_TX + bit_offset: 4 + bit_size: 2 + enum: STAT_TX + - name: DTOG_TX + description: DTOG_TX + bit_offset: 6 + bit_size: 1 + - name: CTR_TX + description: CTR_TX + bit_offset: 7 + bit_size: 1 + - name: EP_KIND + description: EP_KIND + bit_offset: 8 + bit_size: 1 + - name: EP_TYPE + description: EPTYPE + bit_offset: 9 + bit_size: 2 + enum: EP_TYPE + - name: SETUP + description: SETUP + bit_offset: 11 + bit_size: 1 + - name: STAT_RX + description: STAT_RX + bit_offset: 12 + bit_size: 2 + enum: STAT_RX + - name: DTOG_RX + description: DTOG_RX + bit_offset: 14 + bit_size: 1 + - name: CTR_RX + description: CTR_RX + bit_offset: 15 + bit_size: 1 +fieldset/FNR: + description: frame number register + fields: + - name: FN + description: FN + bit_offset: 0 + bit_size: 11 + - name: LSOF + description: LSOF + bit_offset: 11 + bit_size: 2 + - name: LCK + description: the frame timer remains in this state until an USB reset or USB suspend event occurs + bit_offset: 13 + bit_size: 1 + - name: RXDM + description: received data minus upstream port data line + bit_offset: 14 + bit_size: 1 + - name: RXDP + description: received data plus upstream port data line + bit_offset: 15 + bit_size: 1 +fieldset/ISTR: + description: interrupt status register + fields: + - name: EP_ID + description: EP_ID + bit_offset: 0 + bit_size: 4 + - name: DIR + description: DIR + bit_offset: 4 + bit_size: 1 + enum: DIR + - name: L1REQ + description: LPM command to enter the L1 state is successfully received and acknowledged + bit_offset: 7 + bit_size: 1 + - name: ESOF + description: an SOF packet is expected but not received + bit_offset: 8 + bit_size: 1 + - name: SOF + description: beginning of a new USB frame and it is set when a SOF packet arrives through the USB bus + bit_offset: 9 + bit_size: 1 + - name: RESET + description: peripheral detects an active USB RESET signal at its inputs + bit_offset: 10 + bit_size: 1 + - name: SUSP + description: "no traffic has been received for 3 ms, indicating a suspend mode request from the USB bus" + bit_offset: 11 + bit_size: 1 + - name: WKUP + description: activity is detected that wakes up the USB peripheral + bit_offset: 12 + bit_size: 1 + - name: ERR + description: "One of No ANSwer, Cyclic Redundancy Check, Bit Stuffing or Framing format Violation error occurred" + bit_offset: 13 + bit_size: 1 + - name: PMAOVR + description: microcontroller has not been able to respond in time to an USB memory request + bit_offset: 14 + bit_size: 1 + - name: CTR + description: endpoint has successfully completed a transaction + bit_offset: 15 + bit_size: 1 +fieldset/LPMCSR: + description: LPM control and status register + fields: + - name: LPMEN + description: enable the LPM support within the USB device + bit_offset: 0 + bit_size: 1 + - name: LPMACK + description: LPMACK + bit_offset: 1 + bit_size: 1 + enum: LPMACK + - name: REMWAKE + description: REMWAKE + bit_offset: 3 + bit_size: 1 + - name: BESL + description: BESL + bit_offset: 4 + bit_size: 4 +enum/DIR: + bit_size: 1 + variants: + - name: To + description: data transmitted by the USB peripheral to the host PC + value: 0 + - name: From + description: data received by the USB peripheral from the host PC + value: 1 +enum/EP_TYPE: + bit_size: 2 + variants: + - name: Bulk + description: Bulk endpoint + value: 0 + - name: Control + description: Control endpoint + value: 1 + - name: Iso + description: Iso endpoint + value: 2 + - name: Interrupt + description: Interrupt endpoint + value: 3 +enum/LPMACK: + bit_size: 1 + variants: + - name: Nyet + description: the valid LPM Token will be NYET + value: 0 + - name: Ack + description: the valid LPM Token will be ACK + value: 1 +enum/SDET: + bit_size: 1 + variants: + - name: CDP + description: CDP detected + value: 0 + - name: DCP + description: DCP detected + value: 1 +enum/STAT_RX: + bit_size: 2 + variants: + - name: Disabled + description: all reception requests addressed to this endpoint are ignored + value: 0 + - name: Stall + description: the endpoint is stalled and all reception requests result in a STALL handshake + value: 1 + - name: Nak + description: the endpoint is naked and all reception requests result in a NAK handshake + value: 2 + - name: Valid + description: this endpoint is enabled for reception + value: 3 +enum/STAT_TX: + bit_size: 2 + variants: + - name: Disabled + description: all transmission requests addressed to this endpoint are ignored + value: 0 + - name: Stall + description: the endpoint is stalled and all transmission requests result in a STALL handshake + value: 1 + - name: Nak + description: the endpoint is naked and all transmission requests result in a NAK handshake + value: 2 + - name: Valid + description: this endpoint is enabled for transmission + value: 3 diff --git a/stm32data/__main__.py b/stm32data/__main__.py index d7d21c2..3d31e96 100755 --- a/stm32data/__main__.py +++ b/stm32data/__main__.py @@ -159,6 +159,10 @@ perimap = [ ('.*:SDIO:sdmmc_v1_2', ('sdmmc', 'v1', 'SDMMC')), ('.*:SDMMC:sdmmc_v1_3', ('sdmmc', 'v1', 'SDMMC')), ('.*:SPDIFRX:spdifrx1_v1_0', ('spdifrx', 'v1', 'SPDIFRX')), + + # USB + ('STM32(F1|L1|F3).*:USB:.*', ('usb', 'v1', 'USB')), + ('.*:USB:.*', ('usb', 'v2', 'USB')), ('.*:USB_OTG_FS:otgfs1_v1_.*', ('otgfs', 'v1', 'OTG_FS')), ('.*:USB_OTG_FS:otgfs1_v3_.*', ('otgfs', 'v1', 'OTG_FS')), ('.*:USB_OTG_HS:otghs1_v1_.*', ('otghs', 'v1', 'OTG_HS')),