// Copyright 2020 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#pragma once
#include <stdint.h>
#include "soc/soc.h"
#ifdef __cplusplus
extern "C" {
#endif
/** Control/Status registers */
/** USB_GOTGCTL_REG register
* OTG Control and Status Register
*/
#define USB_GOTGCTL_REG (SOC_DPORT_USB_BASE + 0x0)
/** USB_SESREQSCS : RO; bitpos: [0]; default: 0;
* Session Request Success.The core sets this bit when a session request initiation is
* successful
*/
#define USB_SESREQSCS (BIT(0))
#define USB_SESREQSCS_M (USB_SESREQSCS_V << USB_SESREQSCS_S)
#define USB_SESREQSCS_V 0x00000001
#define USB_SESREQSCS_S 0
/** USB_SESREQ : R/W; bitpos: [1]; default: 0;
* Session Request.The application sets this bit to initiate a session request on the
* USB. The application can clear this bit by writing a 0 when the Host Negotiation
* Success Status Change bit in the OTG Interrupt register
* (GOTGINT_REG.USB_HSTNEGSUCSTSCHNG) is SET. The core clears this bit when the
* USB_HSTNEGSUCSTSCHNG bit is cleared
*/
#define USB_SESREQ (BIT(1))
#define USB_SESREQ_M (USB_SESREQ_V << USB_SESREQ_S)
#define USB_SESREQ_V 0x00000001
#define USB_SESREQ_S 1
/** USB_VBVALIDOVEN : R/W; bitpos: [2]; default: 0;
* VBUS Valid Override Enable
* 1'b1 : Internally Bvalid received from the PHY is overridden with
* GOTGCTL_REG.REG_VBVALIDOVVAl
* 1'b0 : Override is disabled and bvalid signal from the respective PHY selected is
* used internally by the controller
*/
#define USB_VBVALIDOVEN (BIT(2))
#define USB_VBVALIDOVEN_M (USB_VBVALIDOVEN_V << USB_VBVALIDOVEN_S)
#define USB_VBVALIDOVEN_V 0x00000001
#define USB_VBVALIDOVEN_S 2
/** USB_VBVALIDOVVAL : R/W; bitpos: [3]; default: 0;
* VBUS Valid OverrideValue
* 1'b0 : vbusvalid value is 1'b0 when GOTGCTL_REG.USB_VBVALIDOVEN =1
* 1'b1 : vbusvalid value is 1'b1 when GOTGCTL_REG.USB_VBVALIDOVEN =1
*/
#define USB_VBVALIDOVVAL (BIT(3))
#define USB_VBVALIDOVVAL_M (USB_VBVALIDOVVAL_V << USB_VBVALIDOVVAL_S)
#define USB_VBVALIDOVVAL_V 0x00000001
#define USB_VBVALIDOVVAL_S 3
/** USB_AVALIDOVEN : R/W; bitpos: [4]; default: 0;
* This bit is used to enable/disable the software to override the Avalid signal using
* the GOTGCTL.AVALIDOVVAL
* 1'b1: Internally Avalid received from the PHY is overridden with
* GOTGCTL_REG.REG_AVALIDOVVAL
* 1'b0: Override is disabled and avalid signal from the respective PHY selected is
* used internally by the core
*/
#define USB_AVALIDOVEN (BIT(4))
#define USB_AVALIDOVEN_M (USB_AVALIDOVEN_V << USB_AVALIDOVEN_S)
#define USB_AVALIDOVEN_V 0x00000001
#define USB_AVALIDOVEN_S 4
/** USB_AVALIDOVVAL : R/W; bitpos: [5]; default: 0;
* A-Peripheral Session Valid OverrideValue
* 1'b0 : Avalid value is 1'b0 when GOTGCTL_REG.USB_AVALIDOVEN =1
* 1'b1 : Avalid value is 1'b1 when GOTGCTL_REG.USB_AVALIDOVEN =1
*/
#define USB_AVALIDOVVAL (BIT(5))
#define USB_AVALIDOVVAL_M (USB_AVALIDOVVAL_V << USB_AVALIDOVVAL_S)
#define USB_AVALIDOVVAL_V 0x00000001
#define USB_AVALIDOVVAL_S 5
/** USB_BVALIDOVEN : R/W; bitpos: [6]; default: 0;
* This bit is used to enable/disable the software to override the Bvalid signal using
* the GOTGCTLREG.BVALIDOVVAL
* 1'b1 : Internally Bvalid received from the PHY is overridden with
* GOTGCTL_REG.USB_BVALIDOVVAL
* 1'b0 : Override is disabled and bvalid signal from the respective PHY selected is
* used internally by the force
*/
#define USB_BVALIDOVEN (BIT(6))
#define USB_BVALIDOVEN_M (USB_BVALIDOVEN_V << USB_BVALIDOVEN_S)
#define USB_BVALIDOVEN_V 0x00000001
#define USB_BVALIDOVEN_S 6
/** USB_BVALIDOVVAL : R/W; bitpos: [7]; default: 0;
* B-Peripheral Session Valid OverrideValue
* 1'b0 : Bvalid value is 1'b0 when GOTGCTL_REG.USB_BVALIDOVEN =1
* 1'b1 : Bvalid value is 1'b1 when GOTGCTL_REG.USB_BVALIDOVEN =1
*/
#define USB_BVALIDOVVAL (BIT(7))
#define USB_BVALIDOVVAL_M (USB_BVALIDOVVAL_V << USB_BVALIDOVVAL_S)
#define USB_BVALIDOVVAL_V 0x00000001
#define USB_BVALIDOVVAL_S 7
/** USB_HSTNEGSCS : RO; bitpos: [8]; default: 0;
* Host Negotiation Success.The controller sets this bit when host negotiation is
* successful. The controller clears this bit when the HNP Request (HNPReq) bit in
* this register is set.
*/
#define USB_HSTNEGSCS (BIT(8))
#define USB_HSTNEGSCS_M (USB_HSTNEGSCS_V << USB_HSTNEGSCS_S)
#define USB_HSTNEGSCS_V 0x00000001
#define USB_HSTNEGSCS_S 8
/** USB_HNPREQ : R/W; bitpos: [9]; default: 0;
* HNP Request .The application sets this bit to initiate an HNP request to the
* Connected USB host. The application can clear this bit by writing a 0 when the Host
* Negotiation Success Status Change bit in the OTG Interrupt register
* (GOTGINT_REG.HSTNEGSUCSTSCHNG) is SET. The controller clears this bit when the
* HSTNEGSUCSTSCHNG bit is cleared.
*/
#define USB_HNPREQ (BIT(9))
#define USB_HNPREQ_M (USB_HNPREQ_V << USB_HNPREQ_S)
#define USB_HNPREQ_V 0x00000001
#define USB_HNPREQ_S 9
/** USB_HSTSETHNPEN : R/W; bitpos: [10]; default: 0;
* Host Set HNP Enable.The application sets this bit when it has successfully enabled
* HNP (using the SetFeature.SetHNPEnable command) on the connected device
* 1'b0: Host Set HNP is not enabled
* 1'b1: Host Set HNP is enabled
*/
#define USB_HSTSETHNPEN (BIT(10))
#define USB_HSTSETHNPEN_M (USB_HSTSETHNPEN_V << USB_HSTSETHNPEN_S)
#define USB_HSTSETHNPEN_V 0x00000001
#define USB_HSTSETHNPEN_S 10
/** USB_DEVHNPEN : R/W; bitpos: [11]; default: 0;
* Device HNP Enabled.The application sets this bit when it successfully receives a
* SetFeature.SetHNPEnable command from the connected USB host
* 1'b0: HNP is not enabled in the application
* 1'b1: HNP is enabled in the application
*/
#define USB_DEVHNPEN (BIT(11))
#define USB_DEVHNPEN_M (USB_DEVHNPEN_V << USB_DEVHNPEN_S)
#define USB_DEVHNPEN_V 0x00000001
#define USB_DEVHNPEN_S 11
/** USB_EHEN : R/W; bitpos: [12]; default: 0;
* Embedded Host Enable.It is used to select between OTG A Device state Machine and
* Embedded Host state machine
* 1'b0: OTG A Device state machine is selected
* 1'b1: Embedded Host State Machine is selected
*/
#define USB_EHEN (BIT(12))
#define USB_EHEN_M (USB_EHEN_V << USB_EHEN_S)
#define USB_EHEN_V 0x00000001
#define USB_EHEN_S 12
/** USB_DBNCEFLTRBYPASS : R/W; bitpos: [15]; default: 0;
* Bypass Debounce filters for avalid, bvalid, vbusvalid, sessend, iddig signals when
* enabled
* 1'b0: Disabled
* 1'b1: Enabled
*/
#define USB_DBNCEFLTRBYPASS (BIT(15))
#define USB_DBNCEFLTRBYPASS_M (USB_DBNCEFLTRBYPASS_V << USB_DBNCEFLTRBYPASS_S)
#define USB_DBNCEFLTRBYPASS_V 0x00000001
#define USB_DBNCEFLTRBYPASS_S 15
/** USB_CONIDSTS : RO; bitpos: [16]; default: 0;
* Connector ID Status. Indicates the connector ID status on a connect event
* 1'b0: The core is in A-Device mode
* 1'b1: The core is in B-Device mode
*/
#define USB_CONIDSTS (BIT(16))
#define USB_CONIDSTS_M (USB_CONIDSTS_V << USB_CONIDSTS_S)
#define USB_CONIDSTS_V 0x00000001
#define USB_CONIDSTS_S 16
/** USB_DBNCTIME : RO; bitpos: [17]; default: 0;
* Long/Short Debounce Time. Indicates the debounce time of a detected connection
* 1'b0: Long debounce time, used for physical connections (100ms + 2.5 micro-sec)
* 1'b1: Short debounce time, used for soft connections (2.5 micro-sec)
*/
#define USB_DBNCTIME (BIT(17))
#define USB_DBNCTIME_M (USB_DBNCTIME_V << USB_DBNCTIME_S)
#define USB_DBNCTIME_V 0x00000001
#define USB_DBN