文件路径:https://github.com/espressif/esp-idf/bl ... /usbh_ll.h
疑问代码:
- volatile usb_hprt_reg_t hprt_reg; //0x0440
- typedef union {
- struct {
- uint32_t prtconnsts: 1;
- uint32_t prtconndet: 1;
- uint32_t prtena: 1;
- uint32_t prtenchng: 1;
- uint32_t prtovrcurract: 1;
- uint32_t prtovrcurrchng: 1;
- uint32_t prtres: 1;
- uint32_t prtsusp: 1;
- uint32_t prtrst: 1;
- uint32_t reserved1: 1;
- uint32_t prtlnsts: 2;
- uint32_t prtpwr: 1;
- uint32_t prttstctl: 4;
- uint32_t prtspd: 2;
- uint32_t reserved13: 13;
- };
- uint32_t val;
- } usb_hprt_reg_t;
- #define USBH_LL_HPRT_W1C_MSK (0x2E)
- #define USBH_LL_HPRT_ENA_MSK (0x04)
- static inline void usbh_ll_hprt_port_dis(usbh_dev_t *hw)
- {
- usb_hprt_reg_t hprt;
- hprt.val = hw->hprt_reg.val;
- hprt.prtena = 1; //W1C to disable
- //we want to W1C ENA but not W1C the interrupt bits
- hw->hprt_reg.val = hprt.val & ((~USBH_LL_HPRT_W1C_MSK) | USBH_LL_HPRT_ENA_MSK);
- }
疑问语句第29行:hprt.prtena = 1; //W1C to disable
疑问:
1.hprt.prtena 寄存器位由硬件模块置位,使能端口;软件置 0 才清除位,禁用端口。
2.如果第一点正确,那么同文件的下面函数都会把 hprt.prtena 寄存器位置 0,禁用端口:
static inline void usbh_ll_hprt_set_test_ctl(usbh_dev_t *hw, uint32_t test_mode);
static inline void usbh_ll_hprt_en_pwr(usbh_dev_t *hw);
static inline void usbh_ll_hprt_dis_pwr(usbh_dev_t *hw);
static inline void usbh_ll_hprt_set_port_reset(usbh_dev_t *hw, bool reset);
static inline void usbh_ll_hprt_set_port_suspend(usbh_dev_t *hw);
static inline void usbh_ll_hprt_set_port_resume(usbh_dev_t *hw);
static inline void usbh_ll_hprt_clr_port_resume(usbh_dev_t *hw);
static inline uint32_t usbh_ll_hprt_intr_read_and_clear(usbh_dev_t *hw);
static inline void usbh_ll_hprt_intr_clear(usbh_dev_t *hw, uint32_t intr_mask);