forked for unsupported target
Dependents: stm32-disco-example DISCO-F469NI_BD_SD_Card_Control
Fork of USBHOST by
USBHost/TARGET_RENESAS/TARGET_RZ_A1H/ohci_wrapp_RZ_A1.c@7:75f3e275934b, 2017-08-08 (annotated)
- Committer:
- bcjun@aname.co.kr
- Date:
- Tue Aug 08 16:20:39 2017 +0900
- Revision:
- 7:75f3e275934b
- Parent:
- 1:ab240722d7ef
change usbhost library that forked in my account
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1 | /* Copyright (c) 2010-2011 mbed.org, MIT License |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2 | * |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 4 | * and associated documentation files (the "Software"), to deal in the Software without |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 5 | * restriction, including without limitation the rights to use, copy, modify, merge, publish, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 6 | * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 7 | * Software is furnished to do so, subject to the following conditions: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 8 | * |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 9 | * The above copyright notice and this permission notice shall be included in all copies or |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 10 | * substantial portions of the Software. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 11 | * |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 13 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 14 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 15 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 16 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 17 | */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 18 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 19 | #include <string.h> |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 20 | #include "cmsis.h" |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 21 | #include "cmsis_os.h" |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 22 | #include "ohci_wrapp_RZ_A1.h" |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 23 | #include "ohci_wrapp_RZ_A1_local.h" |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 24 | #include "rza_io_regrw.h" |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 25 | #include "usb_host_setting.h" |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 26 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 27 | /* ------------------ HcControl Register --------------------- */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 28 | #define OR_CONTROL_PLE (0x00000004) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 29 | #define OR_CONTROL_IE (0x00000008) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 30 | #define OR_CONTROL_CLE (0x00000010) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 31 | #define OR_CONTROL_BLE (0x00000020) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 32 | /* ----------------- HcCommandStatus Register ----------------- */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 33 | #define OR_CMD_STATUS_HCR (0x00000001) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 34 | #define OR_CMD_STATUS_CLF (0x00000002) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 35 | #define OR_CMD_STATUS_BLF (0x00000004) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 36 | #define OR_CMD_STATUS_OCR (0x00000008) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 37 | /* --------------- HcInterruptStatus Register ----------------- */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 38 | #define OR_INTR_STATUS_WDH (0x00000002) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 39 | #define OR_INTR_STATUS_RHSC (0x00000040) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 40 | /* --------------- HcInterruptEnable Register ----------------- */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 41 | #define OR_INTR_ENABLE_WDH (0x00000002) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 42 | #define OR_INTR_ENABLE_RHSC (0x00000040) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 43 | /* -------------- HcRhPortStatus[1:NDP] Register -------------- */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 44 | #define OR_RH_PORT_CSC (0x00010000) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 45 | #define OR_RH_PORT_LSDA (0x00000200) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 46 | #define OR_RH_PORT_PRS (0x00000010) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 47 | #define OR_RH_PORT_POCI (0x00000008) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 48 | #define OR_RH_PORT_CCS (0x00000001) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 49 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 50 | #define ED_FORMAT (0x00008000) /* Format */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 51 | #define ED_SKIP (0x00004000) /* Skip this ep in queue */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 52 | #define ED_TOGLE_CARRY (0x00000002) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 53 | #define ED_HALTED (0x00000001) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 54 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 55 | #define TD_SETUP (0x00000000) /* Direction of Setup Packet */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 56 | #define TD_OUT (0x00080000) /* Direction Out */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 57 | #define TD_TOGGLE_0 (0x02000000) /* Toggle 0 */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 58 | #define TD_TOGGLE_1 (0x03000000) /* Toggle 1 */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 59 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 60 | /* -------------- USB Standard Requests -------------- */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 61 | #define GET_STATUS (0x00) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 62 | #define SET_FEATURE (0x03) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 63 | #define SET_ADDRESS (0x05) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 64 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 65 | #define TD_CTL_MSK_DP (0x00180000) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 66 | #define TD_CTL_MSK_T (0x03000000) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 67 | #define TD_CTL_MSK_CC (0xF0000000) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 68 | #define TD_CTL_MSK_EC (0x0C000000) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 69 | #define TD_CTL_SHFT_CC (28) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 70 | #define TD_CTL_SHFT_EC (26) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 71 | #define TD_CTL_SHFT_T (24) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 72 | #define ED_SHFT_TOGLE_CARRY (1) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 73 | #define SIG_GEN_LIST_REQ (1) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 74 | #if (ISO_TRANS_MAX_NUM > 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 75 | #define TD_PSW_MSK_CC (0xF000) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 76 | #define TD_PSW_SHFT_CC (12) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 77 | #define TD_CTL_MSK_FC (0x07000000) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 78 | #define TD_CTL_SHFT_FC (24) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 79 | #endif |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 80 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 81 | #define CTL_TRANS_TIMEOUT (1000) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 82 | #define BLK_TRANS_TIMEOUT (5) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 83 | #define TOTAL_SEM_NUM (5 + (2 * INT_TRANS_MAX_NUM) + (2 * ISO_TRANS_MAX_NUM)) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 84 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 85 | #define PORT_LOW_SPEED (0x00000200) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 86 | #define PORT_HIGH_SPEED (0x00000400) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 87 | #define PORT_NUM (16 + 1) /* num + root(1) */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 88 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 89 | typedef struct tag_hctd { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 90 | uint32_t control; /* Transfer descriptor control */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 91 | uint8_t *currBufPtr; /* Physical address of current buffer pointer */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 92 | struct tag_hctd *nextTD; /* Physical pointer to next Transfer Descriptor */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 93 | uint8_t *bufEnd; /* Physical address of end of buffer */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 94 | } hctd_t; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 95 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 96 | #if (ISO_TRANS_MAX_NUM > 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 97 | #define PSW_NUM (8) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 98 | typedef struct tag_hcisotd { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 99 | uint32_t control; /* Transfer descriptor control */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 100 | uint8_t *bufferPage0; /* Buffer Page 0 */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 101 | struct tag_hcisotd *nextTD; /* Physical pointer to next Transfer Descriptor */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 102 | uint8_t *bufEnd; /* Physical address of end of buffer */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 103 | uint16_t offsetPSW[PSW_NUM]; /* Offset/PSW */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 104 | } hcisotd_t; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 105 | #endif |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 106 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 107 | typedef struct tag_hced { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 108 | uint32_t control; /* Endpoint descriptor control */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 109 | uint32_t tailTD; /* Physical address of tail in Transfer descriptor list */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 110 | uint32_t headTD; /* Physcial address of head in Transfer descriptor list */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 111 | struct tag_hced *nextED; /* Physical address of next Endpoint descriptor */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 112 | } hced_t; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 113 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 114 | typedef struct tag_hcca { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 115 | uint32_t IntTable[32]; /* Interrupt Table */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 116 | uint32_t FrameNumber; /* Frame Number */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 117 | uint32_t DoneHead; /* Done Head */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 118 | volatile uint8_t Reserved[116]; /* Reserved for future use */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 119 | volatile uint8_t Unknown[4]; /* Unused */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 120 | } hcca_t; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 121 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 122 | typedef struct tag_usb_ohci_reg { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 123 | volatile uint32_t HcRevision; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 124 | volatile uint32_t HcControl; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 125 | volatile uint32_t HcCommandStatus; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 126 | volatile uint32_t HcInterruptStatus; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 127 | volatile uint32_t HcInterruptEnable; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 128 | volatile uint32_t HcInterruptDisable; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 129 | volatile uint32_t HcHCCA; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 130 | volatile uint32_t HcPeriodCurrentED; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 131 | volatile uint32_t HcControlHeadED; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 132 | volatile uint32_t HcControlCurrentED; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 133 | volatile uint32_t HcBulkHeadED; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 134 | volatile uint32_t HcBulkCurrentED; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 135 | volatile uint32_t HcDoneHead; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 136 | volatile uint32_t HcFmInterval; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 137 | volatile uint32_t HcFmRemaining; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 138 | volatile uint32_t HcFmNumber; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 139 | volatile uint32_t HcPeriodicStart; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 140 | volatile uint32_t HcLSThreshold; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 141 | volatile uint32_t HcRhDescriptorA; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 142 | volatile uint32_t HcRhDescriptorB; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 143 | volatile uint32_t HcRhStatus; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 144 | volatile uint32_t HcRhPortStatus1; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 145 | } usb_ohci_reg_t; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 146 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 147 | typedef struct tag_genelal_ed { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 148 | osThreadId tskid; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 149 | osSemaphoreId semid_wait; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 150 | osSemaphoreId semid_list; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 151 | void *p_curr_td; /* pointer of hctd_t or hcisotd_t */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 152 | hced_t *p_curr_ed; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 153 | uint32_t pipe_no; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 154 | uint32_t trans_wait; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 155 | uint32_t cycle_time; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 156 | uint8_t *p_start_buf; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 157 | #if (ISO_TRANS_MAX_NUM > 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 158 | uint32_t psw_idx; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 159 | #endif |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 160 | } genelal_ed_t; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 161 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 162 | typedef struct tag_tdinfo { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 163 | uint32_t count; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 164 | uint32_t direction; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 165 | uint32_t msp; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 166 | uint16_t devadr; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 167 | uint16_t speed; /* 1:Speed = Low */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 168 | uint8_t endpoint_no; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 169 | } tdinfo_t; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 170 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 171 | typedef struct tag_split_trans { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 172 | uint16_t root_devadr; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 173 | uint16_t get_port; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 174 | uint16_t port_speed; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 175 | uint16_t reset_port; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 176 | uint32_t seq_cnt; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 177 | uint32_t port_sts_bits[PORT_NUM]; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 178 | } split_trans_t; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 179 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 180 | static void callback_task(void const * argument); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 181 | static void control_ed_task(void const * argument); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 182 | static void bulk_ed_task(void const * argument); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 183 | static void int_ed_task(void const * argument); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 184 | static int32_t int_trans_doing(hced_t *p_ed, uint32_t index); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 185 | static int32_t chk_genelal_ed(genelal_ed_t *p_g_ed); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 186 | static void chk_genelal_td_done(genelal_ed_t *p_g_ed); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 187 | static void chk_split_trans_setting(genelal_ed_t *p_g_ed); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 188 | static void set_split_trans_setting(void); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 189 | static void control_trans(genelal_ed_t *p_g_ed); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 190 | static void bulk_trans(genelal_ed_t *p_g_ed); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 191 | static void int_trans_setting(genelal_ed_t *p_g_ed, uint32_t index); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 192 | static uint32_t chk_cycle(hced_t *p_ed); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 193 | static void int_trans(genelal_ed_t *p_g_ed); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 194 | static void get_td_info(genelal_ed_t *p_g_ed, tdinfo_t *p_td_info); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 195 | static void set_togle(uint32_t pipe, hctd_t *p_td, hced_t *p_ed); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 196 | #if (ISO_TRANS_MAX_NUM > 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 197 | static void iso_ed_task(void const * argument); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 198 | static int32_t iso_trans_doing(hced_t *p_ed, uint32_t index); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 199 | static void chk_iso_td_done(genelal_ed_t *p_g_ed); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 200 | static int32_t chk_iso_ed(genelal_ed_t *p_g_ed); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 201 | static void iso_trans_setting(genelal_ed_t *p_g_ed, uint32_t index); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 202 | static void iso_trans(genelal_ed_t *p_g_ed); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 203 | #endif |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 204 | static void connect_check(void); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 205 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 206 | extern USB_HOST_CFG_PIPETBL_t usb_host_blk_ep_tbl1[]; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 207 | extern USB_HOST_CFG_PIPETBL_t usb_host_int_ep_tbl1[]; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 208 | #if (ISO_TRANS_MAX_NUM > 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 209 | extern USB_HOST_CFG_PIPETBL_t usb_host_iso_ep_tbl1[]; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 210 | #endif |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 211 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 212 | static usb_ohci_reg_t usb_reg; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 213 | static usb_ohci_reg_t *p_usb_reg = &usb_reg; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 214 | static usbisr_fnc_t *p_usbisr_cb = NULL; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 215 | static osSemaphoreId semid_cb = NULL; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 216 | static uint32_t connect_change = 0xFFFFFFFF; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 217 | static uint32_t connect_status = 0; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 218 | static uint32_t init_end = 0; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 219 | static genelal_ed_t ctl_ed; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 220 | static genelal_ed_t blk_ed; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 221 | static genelal_ed_t int_ed[INT_TRANS_MAX_NUM]; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 222 | static split_trans_t split_ctl; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 223 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 224 | #if (ISO_TRANS_MAX_NUM > 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 225 | static genelal_ed_t iso_ed[ISO_TRANS_MAX_NUM]; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 226 | #endif |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 227 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 228 | osSemaphoreDef(ohciwrapp_sem_01); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 229 | osSemaphoreDef(ohciwrapp_sem_02); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 230 | osSemaphoreDef(ohciwrapp_sem_03); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 231 | osSemaphoreDef(ohciwrapp_sem_04); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 232 | osSemaphoreDef(ohciwrapp_sem_05); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 233 | osSemaphoreDef(ohciwrapp_sem_06); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 234 | osSemaphoreDef(ohciwrapp_sem_07); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 235 | #if (INT_TRANS_MAX_NUM >= 2) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 236 | osSemaphoreDef(ohciwrapp_sem_08); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 237 | osSemaphoreDef(ohciwrapp_sem_09); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 238 | #endif |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 239 | #if (INT_TRANS_MAX_NUM >= 3) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 240 | osSemaphoreDef(ohciwrapp_sem_10); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 241 | osSemaphoreDef(ohciwrapp_sem_11); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 242 | #endif |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 243 | #if (INT_TRANS_MAX_NUM >= 4) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 244 | osSemaphoreDef(ohciwrapp_sem_12); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 245 | osSemaphoreDef(ohciwrapp_sem_13); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 246 | #endif |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 247 | #if (ISO_TRANS_MAX_NUM >= 1) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 248 | osSemaphoreDef(ohciwrapp_sem_14); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 249 | osSemaphoreDef(ohciwrapp_sem_15); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 250 | #endif |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 251 | #if (ISO_TRANS_MAX_NUM >= 2) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 252 | osSemaphoreDef(ohciwrapp_sem_16); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 253 | osSemaphoreDef(ohciwrapp_sem_17); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 254 | #endif |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 255 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 256 | osThreadDef(callback_task, osPriorityHigh, 512); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 257 | osThreadDef(control_ed_task, osPriorityNormal, 512); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 258 | osThreadDef(bulk_ed_task, osPriorityNormal, 512); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 259 | static void int_ed_task_1(void const * argument) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 260 | int_ed_task(argument); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 261 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 262 | osThreadDef(int_ed_task_1, osPriorityNormal, 512); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 263 | #if (INT_TRANS_MAX_NUM >= 2) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 264 | static void int_ed_task_2(void const * argument) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 265 | int_ed_task(argument); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 266 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 267 | osThreadDef(int_ed_task_2, osPriorityNormal, 512); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 268 | #endif |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 269 | #if (INT_TRANS_MAX_NUM >= 3) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 270 | static void int_ed_task_3(void const * argument) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 271 | int_ed_task(argument); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 272 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 273 | osThreadDef(int_ed_task_3, osPriorityNormal, 512); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 274 | #endif |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 275 | #if (INT_TRANS_MAX_NUM >= 4) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 276 | static void int_ed_task_4(void const * argument) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 277 | int_ed_task(argument); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 278 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 279 | osThreadDef(int_ed_task_4, osPriorityNormal, 512); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 280 | #endif |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 281 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 282 | #if (ISO_TRANS_MAX_NUM >= 1) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 283 | static void iso_ed_task_1(void const * argument) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 284 | iso_ed_task(argument); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 285 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 286 | osThreadDef(iso_ed_task_1, osPriorityAboveNormal, 512); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 287 | #endif |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 288 | #if (ISO_TRANS_MAX_NUM >= 2) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 289 | static void iso_ed_task_2(void const * argument) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 290 | iso_ed_task(argument); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 291 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 292 | osThreadDef(iso_ed_task_2, osPriorityAboveNormal, 512); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 293 | #endif |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 294 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 295 | void ohciwrapp_init(usbisr_fnc_t *p_usbisr_fnc) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 296 | static const osSemaphoreDef_t * const sem_def_tbl[TOTAL_SEM_NUM] = { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 297 | osSemaphore(ohciwrapp_sem_01), osSemaphore(ohciwrapp_sem_02), osSemaphore(ohciwrapp_sem_03) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 298 | , osSemaphore(ohciwrapp_sem_04), osSemaphore(ohciwrapp_sem_05), osSemaphore(ohciwrapp_sem_06) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 299 | , osSemaphore(ohciwrapp_sem_07) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 300 | #if (INT_TRANS_MAX_NUM >= 2) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 301 | , osSemaphore(ohciwrapp_sem_08), osSemaphore(ohciwrapp_sem_09) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 302 | #endif |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 303 | #if (INT_TRANS_MAX_NUM >= 3) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 304 | , osSemaphore(ohciwrapp_sem_10), osSemaphore(ohciwrapp_sem_11) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 305 | #endif |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 306 | #if (INT_TRANS_MAX_NUM >= 4) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 307 | , osSemaphore(ohciwrapp_sem_12), osSemaphore(ohciwrapp_sem_13) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 308 | #endif |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 309 | #if (ISO_TRANS_MAX_NUM >= 1) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 310 | , osSemaphore(ohciwrapp_sem_14), osSemaphore(ohciwrapp_sem_15) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 311 | #endif |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 312 | #if (ISO_TRANS_MAX_NUM >= 2) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 313 | , osSemaphore(ohciwrapp_sem_16), osSemaphore(ohciwrapp_sem_17) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 314 | #endif |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 315 | }; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 316 | static const osThreadDef_t * const int_tsk_def_tbl[INT_TRANS_MAX_NUM] = { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 317 | osThread(int_ed_task_1) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 318 | #if (INT_TRANS_MAX_NUM >= 2) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 319 | , osThread(int_ed_task_2) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 320 | #endif |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 321 | #if (INT_TRANS_MAX_NUM >= 3) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 322 | , osThread(int_ed_task_3) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 323 | #endif |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 324 | #if (INT_TRANS_MAX_NUM >= 4) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 325 | , osThread(int_ed_task_4) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 326 | #endif |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 327 | }; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 328 | #if (ISO_TRANS_MAX_NUM > 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 329 | static const osThreadDef_t * const iso_tsk_def_tbl[ISO_TRANS_MAX_NUM] = { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 330 | osThread(iso_ed_task_1) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 331 | #if (ISO_TRANS_MAX_NUM >= 2) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 332 | , osThread(iso_ed_task_2) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 333 | #endif |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 334 | }; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 335 | #endif |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 336 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 337 | uint32_t cnt; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 338 | uint32_t index = 0; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 339 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 340 | /* Disables interrupt for usb */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 341 | GIC_DisableIRQ(USBIXUSBIX); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 342 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 343 | #if (USB_HOST_CH == 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 344 | /* P4_1(USB0_EN) */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 345 | GPIOP4 &= ~0x0002; /* Outputs low level */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 346 | GPIOPMC4 &= ~0x0002; /* Port mode */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 347 | GPIOPM4 &= ~0x0002; /* Output mode */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 348 | #endif |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 349 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 350 | p_usbisr_cb = p_usbisr_fnc; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 351 | #if (USB_HOST_HISPEED == 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 352 | g_usbx_host_SupportUsbDeviceSpeed = USB_HOST_FULL_SPEED; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 353 | #else |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 354 | g_usbx_host_SupportUsbDeviceSpeed = USB_HOST_HIGH_SPEED; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 355 | #endif |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 356 | p_usb_reg->HcRevision = 0x00000010; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 357 | p_usb_reg->HcControl = 0x00000000; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 358 | p_usb_reg->HcCommandStatus = 0x00000000; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 359 | p_usb_reg->HcInterruptStatus = 0x00000000; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 360 | p_usb_reg->HcInterruptEnable = 0x00000000; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 361 | p_usb_reg->HcInterruptDisable = 0x00000000; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 362 | p_usb_reg->HcHCCA = 0x00000000; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 363 | p_usb_reg->HcPeriodCurrentED = 0x00000000; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 364 | p_usb_reg->HcControlHeadED = 0x00000000; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 365 | p_usb_reg->HcControlCurrentED = 0x00000000; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 366 | p_usb_reg->HcBulkHeadED = 0x00000000; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 367 | p_usb_reg->HcBulkCurrentED = 0x00000000; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 368 | p_usb_reg->HcDoneHead = 0x00000000; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 369 | p_usb_reg->HcFmInterval = 0x00002EDF; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 370 | p_usb_reg->HcFmRemaining = 0x00002EDF; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 371 | p_usb_reg->HcFmNumber = 0x00000000; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 372 | p_usb_reg->HcPeriodicStart = 0x00000000; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 373 | p_usb_reg->HcLSThreshold = 0x00000628; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 374 | p_usb_reg->HcRhDescriptorA = 0xFF000901; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 375 | p_usb_reg->HcRhDescriptorB = 0x00020000; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 376 | p_usb_reg->HcRhStatus = 0x00000000; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 377 | p_usb_reg->HcRhPortStatus1 = 0x00000000; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 378 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 379 | #if (USB_HOST_CH == 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 380 | GPIOP4 |= 0x0002; /* P4_1 Outputs high level */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 381 | osDelay(5); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 382 | GPIOP4 &= ~0x0002; /* P4_1 Outputs low level */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 383 | osDelay(10); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 384 | #else |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 385 | osDelay(15); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 386 | #endif |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 387 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 388 | if (init_end == 0) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 389 | (void)memset(&ctl_ed, 0, sizeof(ctl_ed)); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 390 | (void)memset(&blk_ed, 0, sizeof(blk_ed)); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 391 | (void)memset(&int_ed[0], 0, sizeof(int_ed)); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 392 | #if (ISO_TRANS_MAX_NUM > 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 393 | (void)memset(&iso_ed[0], 0, sizeof(iso_ed)); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 394 | #endif |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 395 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 396 | /* callback */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 397 | semid_cb = osSemaphoreCreate(sem_def_tbl[index], 0); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 398 | index++; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 399 | (void)osThreadCreate(osThread(callback_task), 0); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 400 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 401 | /* control transfer */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 402 | ctl_ed.semid_wait = osSemaphoreCreate(sem_def_tbl[index], 0); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 403 | index++; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 404 | ctl_ed.semid_list = osSemaphoreCreate(sem_def_tbl[index], 0); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 405 | index++; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 406 | ctl_ed.tskid = osThreadCreate(osThread(control_ed_task), 0); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 407 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 408 | /* bulk transfer */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 409 | blk_ed.semid_wait = osSemaphoreCreate(sem_def_tbl[index], 0); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 410 | index++; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 411 | blk_ed.semid_list = osSemaphoreCreate(sem_def_tbl[index], 0); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 412 | index++; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 413 | blk_ed.tskid = osThreadCreate(osThread(bulk_ed_task), 0); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 414 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 415 | /* interrupt transfer */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 416 | for (cnt = 0; cnt < INT_TRANS_MAX_NUM; cnt++) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 417 | int_ed[cnt].semid_wait = osSemaphoreCreate(sem_def_tbl[index], 0); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 418 | index++; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 419 | int_ed[cnt].semid_list = osSemaphoreCreate(sem_def_tbl[index], 0); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 420 | index++; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 421 | int_ed[cnt].tskid = osThreadCreate(int_tsk_def_tbl[cnt], (void *)cnt); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 422 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 423 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 424 | #if (ISO_TRANS_MAX_NUM > 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 425 | /* isochronous transfer */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 426 | for (cnt = 0; cnt < ISO_TRANS_MAX_NUM; cnt++) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 427 | iso_ed[cnt].semid_wait = osSemaphoreCreate(sem_def_tbl[index], 0); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 428 | index++; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 429 | iso_ed[cnt].semid_list = osSemaphoreCreate(sem_def_tbl[index], 0); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 430 | index++; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 431 | iso_ed[cnt].tskid = osThreadCreate(iso_tsk_def_tbl[cnt], (void *)cnt); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 432 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 433 | #endif |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 434 | init_end = 1; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 435 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 436 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 437 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 438 | uint32_t ohciwrapp_reg_r(uint32_t reg_ofs) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 439 | if (init_end == 0) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 440 | return 0; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 441 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 442 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 443 | return *(uint32_t *)((uint8_t *)p_usb_reg + reg_ofs); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 444 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 445 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 446 | void ohciwrapp_reg_w(uint32_t reg_ofs, uint32_t set_data) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 447 | uint32_t cnt; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 448 | uint32_t last_data; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 449 | hcca_t *p_hcca; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 450 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 451 | if (init_end == 0) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 452 | return; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 453 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 454 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 455 | switch (reg_ofs) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 456 | case OHCI_REG_CONTROL: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 457 | last_data = p_usb_reg->HcControl; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 458 | p_usb_reg->HcControl = (set_data & 0x000007FF); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 459 | if ((last_data & OR_CONTROL_CLE) != (set_data & OR_CONTROL_CLE)) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 460 | /* change CLE */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 461 | if ((set_data & OR_CONTROL_CLE) != 0) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 462 | (void)osSemaphoreRelease(ctl_ed.semid_list); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 463 | } else { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 464 | if (ctl_ed.trans_wait == 1) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 465 | ctl_ed.trans_wait = 0; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 466 | (void)osSemaphoreRelease(ctl_ed.semid_wait); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 467 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 468 | (void)osSemaphoreWait(ctl_ed.semid_list, osWaitForever); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 469 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 470 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 471 | if ((last_data & OR_CONTROL_BLE) != (set_data & OR_CONTROL_BLE)) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 472 | /* change BLE */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 473 | if ((set_data & OR_CONTROL_BLE) != 0) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 474 | (void)osSemaphoreRelease(blk_ed.semid_list); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 475 | } else { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 476 | if (blk_ed.trans_wait == 1) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 477 | blk_ed.trans_wait = 0; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 478 | (void)osSemaphoreRelease(blk_ed.semid_wait); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 479 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 480 | (void)osSemaphoreWait(blk_ed.semid_list, osWaitForever); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 481 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 482 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 483 | #if (ISO_TRANS_MAX_NUM > 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 484 | if ((last_data & OR_CONTROL_IE) != (set_data & OR_CONTROL_IE)) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 485 | /* change IE */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 486 | for (cnt = 0; cnt < ISO_TRANS_MAX_NUM; cnt++) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 487 | if ((set_data & OR_CONTROL_IE) != 0) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 488 | (void)osSemaphoreRelease(iso_ed[cnt].semid_list); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 489 | } else { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 490 | if (iso_ed[cnt].trans_wait == 1) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 491 | iso_ed[cnt].trans_wait = 0; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 492 | (void)osSemaphoreRelease(iso_ed[cnt].semid_wait); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 493 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 494 | (void)osSemaphoreWait(iso_ed[cnt].semid_list, osWaitForever); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 495 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 496 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 497 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 498 | #endif |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 499 | if ((last_data & OR_CONTROL_PLE) != (set_data & OR_CONTROL_PLE)) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 500 | /* change PLE */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 501 | for (cnt = 0; cnt < INT_TRANS_MAX_NUM; cnt++) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 502 | if ((set_data & OR_CONTROL_PLE) != 0) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 503 | (void)osSemaphoreRelease(int_ed[cnt].semid_list); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 504 | } else { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 505 | if (int_ed[cnt].trans_wait == 1) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 506 | int_ed[cnt].trans_wait = 0; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 507 | (void)osSemaphoreRelease(int_ed[cnt].semid_wait); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 508 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 509 | (void)osSemaphoreWait(int_ed[cnt].semid_list, osWaitForever); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 510 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 511 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 512 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 513 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 514 | case OHCI_REG_COMMANDSTATUS: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 515 | if ((set_data & OR_CMD_STATUS_HCR) != 0) { /* HostController Reset */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 516 | p_usb_reg->HcCommandStatus |= OR_CMD_STATUS_HCR; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 517 | if (usbx_api_host_init(16, g_usbx_host_SupportUsbDeviceSpeed, USBHCLOCK_X1_48MHZ) == USB_HOST_ATTACH) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 518 | ohciwrapp_loc_Connect(1); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 519 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 520 | p_usb_reg->HcCommandStatus &= ~OR_CMD_STATUS_HCR; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 521 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 522 | if ((set_data & OR_CMD_STATUS_CLF) != 0) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 523 | p_usb_reg->HcCommandStatus |= OR_CMD_STATUS_CLF; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 524 | osSignalSet(ctl_ed.tskid, SIG_GEN_LIST_REQ); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 525 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 526 | if ((set_data & OR_CMD_STATUS_BLF) != 0) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 527 | p_usb_reg->HcCommandStatus |= OR_CMD_STATUS_BLF; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 528 | osSignalSet(blk_ed.tskid, SIG_GEN_LIST_REQ); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 529 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 530 | if ((set_data & OR_CMD_STATUS_OCR) != 0) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 531 | p_usb_reg->HcCommandStatus |= OR_CMD_STATUS_OCR; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 532 | } else { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 533 | p_usb_reg->HcCommandStatus &= ~OR_CMD_STATUS_OCR; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 534 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 535 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 536 | case OHCI_REG_INTERRUPTSTATUS: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 537 | if (((p_usb_reg->HcInterruptStatus & OR_INTR_STATUS_WDH) != 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 538 | && ((set_data & OR_INTR_STATUS_WDH) != 0)) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 539 | if (p_usb_reg->HcDoneHead != 0x00000000) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 540 | p_hcca = (hcca_t *)p_usb_reg->HcHCCA; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 541 | p_hcca->DoneHead = p_usb_reg->HcDoneHead; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 542 | p_usb_reg->HcDoneHead = 0x00000000; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 543 | p_usb_reg->HcInterruptStatus |= OR_INTR_STATUS_WDH; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 544 | (void)osSemaphoreRelease(semid_cb); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 545 | } else { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 546 | p_usb_reg->HcInterruptStatus &= ~OR_INTR_STATUS_WDH; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 547 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 548 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 549 | if ((set_data & OR_INTR_STATUS_RHSC) != 0) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 550 | p_usb_reg->HcInterruptStatus &= ~OR_INTR_STATUS_RHSC; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 551 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 552 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 553 | case OHCI_REG_INTERRUPTENABLE: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 554 | case OHCI_REG_INTERRUPTDISABLE: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 555 | case OHCI_REG_HCCA: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 556 | case OHCI_REG_CONTROLHEADED: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 557 | case OHCI_REG_CONTROLCURRENTED: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 558 | case OHCI_REG_BULKHEADED: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 559 | case OHCI_REG_BULKCURRENTED: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 560 | case OHCI_REG_FMINTERVAL: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 561 | case OHCI_REG_FMREMAINING: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 562 | case OHCI_REG_PERIODICSTART: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 563 | case OHCI_REG_LSTHRESHOLD: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 564 | case OHCI_REG_RHDESCRIPTORA: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 565 | case OHCI_REG_RHDESCRIPTORB: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 566 | case OHCI_REG_RHSTATUS: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 567 | *(uint32_t *)((uint8_t *)p_usb_reg + reg_ofs) = set_data; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 568 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 569 | case OHCI_REG_RHPORTSTATUS1: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 570 | p_usb_reg->HcRhPortStatus1 &= ~(set_data & 0xFFFF0000); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 571 | if ((set_data & OR_RH_PORT_PRS) != 0) { /* Set Port Reset */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 572 | p_usb_reg->HcRhPortStatus1 |= OR_RH_PORT_PRS; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 573 | usbx_host_UsbBusReset(); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 574 | p_usb_reg->HcRhPortStatus1 &= ~OR_RH_PORT_PRS; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 575 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 576 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 577 | case OHCI_REG_REVISION: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 578 | case OHCI_REG_PERIODCURRENTED: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 579 | case OHCI_REG_DONEHEADED: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 580 | case OHCI_REG_FMNUMBER: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 581 | default: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 582 | /* Do Nothing */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 583 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 584 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 585 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 586 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 587 | static void callback_task(void const * argument) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 588 | usbisr_fnc_t *p_wk_cb = p_usbisr_cb; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 589 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 590 | if (p_wk_cb == NULL) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 591 | return; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 592 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 593 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 594 | while (1) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 595 | osSemaphoreWait(semid_cb, osWaitForever); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 596 | if (connect_change != 0xFFFFFFFF) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 597 | connect_change = 0xFFFFFFFF; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 598 | connect_check(); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 599 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 600 | p_wk_cb(); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 601 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 602 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 603 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 604 | static void control_ed_task(void const * argument) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 605 | while (1) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 606 | osSignalWait(SIG_GEN_LIST_REQ, osWaitForever); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 607 | (void)osSemaphoreWait(ctl_ed.semid_list, osWaitForever); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 608 | while ((p_usb_reg->HcControl & OR_CONTROL_CLE) != 0) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 609 | if ((p_usb_reg->HcControlCurrentED == 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 610 | && ((p_usb_reg->HcCommandStatus & OR_CMD_STATUS_CLF) != 0)) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 611 | p_usb_reg->HcControlCurrentED = p_usb_reg->HcControlHeadED; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 612 | p_usb_reg->HcCommandStatus &= ~OR_CMD_STATUS_CLF; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 613 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 614 | if (p_usb_reg->HcControlCurrentED != 0) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 615 | ctl_ed.p_curr_ed = (hced_t *)p_usb_reg->HcControlCurrentED; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 616 | if (chk_genelal_ed(&ctl_ed) != 0) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 617 | control_trans(&ctl_ed); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 618 | p_usb_reg->HcCommandStatus |= OR_CMD_STATUS_CLF; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 619 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 620 | p_usb_reg->HcControlCurrentED = (uint32_t)ctl_ed.p_curr_ed->nextED; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 621 | } else { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 622 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 623 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 624 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 625 | if ((p_usb_reg->HcCommandStatus & OR_CMD_STATUS_CLF) != 0) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 626 | osSignalSet(ctl_ed.tskid, SIG_GEN_LIST_REQ); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 627 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 628 | (void)osSemaphoreRelease(ctl_ed.semid_list); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 629 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 630 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 631 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 632 | static void bulk_ed_task(void const * argument) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 633 | while (1) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 634 | osSignalWait(SIG_GEN_LIST_REQ, osWaitForever); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 635 | (void)osSemaphoreWait(blk_ed.semid_list, osWaitForever); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 636 | while ((p_usb_reg->HcControl & OR_CONTROL_BLE) != 0) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 637 | if ((p_usb_reg->HcBulkCurrentED == 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 638 | && ((p_usb_reg->HcCommandStatus & OR_CMD_STATUS_BLF) != 0)) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 639 | p_usb_reg->HcBulkCurrentED = p_usb_reg->HcBulkHeadED; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 640 | p_usb_reg->HcCommandStatus &= ~OR_CMD_STATUS_BLF; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 641 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 642 | if (p_usb_reg->HcBulkCurrentED != 0) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 643 | blk_ed.p_curr_ed = (hced_t *)p_usb_reg->HcBulkCurrentED; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 644 | if (chk_genelal_ed(&blk_ed) != 0) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 645 | bulk_trans(&blk_ed); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 646 | p_usb_reg->HcCommandStatus |= OR_CMD_STATUS_BLF; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 647 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 648 | p_usb_reg->HcBulkCurrentED = (uint32_t)blk_ed.p_curr_ed->nextED; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 649 | } else { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 650 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 651 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 652 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 653 | if ((p_usb_reg->HcCommandStatus & OR_CMD_STATUS_BLF) != 0) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 654 | osSignalSet(blk_ed.tskid, SIG_GEN_LIST_REQ); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 655 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 656 | (void)osSemaphoreRelease(blk_ed.semid_list); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 657 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 658 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 659 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 660 | static void int_ed_task(void const * argument) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 661 | genelal_ed_t *p_int_ed = &int_ed[(uint32_t)argument]; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 662 | uint32_t cnt; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 663 | uint32_t wait_cnt = 0; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 664 | hcca_t *p_hcca; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 665 | hced_t *p_ed; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 666 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 667 | while (1) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 668 | (void)osSemaphoreWait(p_int_ed->semid_list, osWaitForever); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 669 | if (p_int_ed->p_curr_ed == NULL) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 670 | for (cnt = 0; (cnt < 32) && ((p_usb_reg->HcControl & OR_CONTROL_PLE) != 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 671 | && (p_int_ed->p_curr_ed == NULL); cnt++) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 672 | p_hcca = (hcca_t *)p_usb_reg->HcHCCA; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 673 | p_ed = (hced_t *)p_hcca->IntTable[cnt]; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 674 | while ((p_ed != NULL) && ((p_usb_reg->HcControl & OR_CONTROL_PLE) != 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 675 | && (p_int_ed->p_curr_ed == NULL)) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 676 | if (int_trans_doing(p_ed, (uint32_t)argument) == 0) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 677 | p_int_ed->p_curr_ed = p_ed; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 678 | if (chk_genelal_ed(p_int_ed) != 0) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 679 | int_trans_setting(p_int_ed, (uint32_t)argument); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 680 | } else { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 681 | p_int_ed->p_curr_ed = NULL; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 682 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 683 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 684 | p_ed = p_ed->nextED; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 685 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 686 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 687 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 688 | if (p_int_ed->p_curr_ed != NULL) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 689 | while ((p_usb_reg->HcControl & OR_CONTROL_PLE) != 0) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 690 | if (chk_genelal_ed(p_int_ed) != 0) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 691 | int_trans(p_int_ed); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 692 | (void)osSemaphoreWait(p_int_ed->semid_wait, osWaitForever); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 693 | usbx_host_stop_transfer(p_int_ed->pipe_no); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 694 | wait_cnt = p_int_ed->cycle_time; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 695 | } else { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 696 | if (wait_cnt > 0) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 697 | wait_cnt--; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 698 | } else { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 699 | p_int_ed->p_curr_ed = NULL; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 700 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 701 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 702 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 703 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 704 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 705 | (void)osSemaphoreRelease(p_int_ed->semid_list); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 706 | if (p_int_ed->p_curr_ed == NULL) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 707 | osDelay(10); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 708 | } else { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 709 | osDelay(1); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 710 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 711 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 712 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 713 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 714 | static int32_t int_trans_doing(hced_t *p_ed, uint32_t index) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 715 | uint32_t cnt; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 716 | int32_t ret = 0; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 717 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 718 | for (cnt = 0; cnt < INT_TRANS_MAX_NUM; cnt++) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 719 | if ((index != cnt) && (int_ed[cnt].p_curr_ed == p_ed)) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 720 | ret = 1; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 721 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 722 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 723 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 724 | return ret; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 725 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 726 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 727 | static int32_t chk_genelal_ed(genelal_ed_t *p_g_ed){ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 728 | int32_t ret = 0; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 729 | hced_t *p_ed = p_g_ed->p_curr_ed; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 730 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 731 | if (((p_ed->control & ED_SKIP) != 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 732 | || ((p_ed->control & ED_FORMAT) != 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 733 | || ((p_ed->headTD & ED_HALTED) != 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 734 | || ((p_ed->tailTD & 0xFFFFFFF0) == (p_ed->headTD & 0xFFFFFFF0))) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 735 | /* Do Nothing */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 736 | } else if ((p_ed->control & 0x0000007F) > 10) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 737 | p_ed->headTD |= ED_HALTED; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 738 | } else { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 739 | p_g_ed->p_curr_td = (void *)(p_ed->headTD & 0xFFFFFFF0); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 740 | if (p_g_ed->p_curr_td == NULL) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 741 | p_ed->headTD |= ED_HALTED; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 742 | } else { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 743 | hctd_t *p_td = (hctd_t *)p_g_ed->p_curr_td; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 744 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 745 | p_g_ed->p_start_buf = p_td->currBufPtr; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 746 | ret = 1; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 747 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 748 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 749 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 750 | return ret; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 751 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 752 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 753 | static void chk_genelal_td_done(genelal_ed_t *p_g_ed) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 754 | hcca_t *p_hcca; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 755 | hctd_t *p_td = (hctd_t *)p_g_ed->p_curr_td; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 756 | uint32_t ConditionCode = RZA_IO_RegRead_32(&p_td->control, TD_CTL_SHFT_CC, TD_CTL_MSK_CC); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 757 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 758 | if ((ConditionCode != TD_CC_NOT_ACCESSED_1) && (ConditionCode != TD_CC_NOT_ACCESSED_2)) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 759 | p_g_ed->p_curr_ed->headTD = ((uint32_t)p_td->nextTD & 0xFFFFFFF0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 760 | | (p_g_ed->p_curr_ed->headTD & 0x0000000F); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 761 | p_td->nextTD = (hctd_t *)p_usb_reg->HcDoneHead; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 762 | p_usb_reg->HcDoneHead = (uint32_t)p_g_ed->p_curr_td; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 763 | if ((p_usb_reg->HcInterruptStatus & OR_INTR_STATUS_WDH) == 0) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 764 | p_hcca = (hcca_t *)p_usb_reg->HcHCCA; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 765 | p_hcca->DoneHead = p_usb_reg->HcDoneHead; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 766 | p_usb_reg->HcDoneHead = 0x00000000; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 767 | p_usb_reg->HcInterruptStatus |= OR_INTR_STATUS_WDH; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 768 | (void)osSemaphoreRelease(semid_cb); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 769 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 770 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 771 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 772 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 773 | static void chk_split_trans_setting(genelal_ed_t *p_g_ed) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 774 | uint8_t *p_buf; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 775 | tdinfo_t td_info; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 776 | hctd_t *p_td = (hctd_t *)p_g_ed->p_curr_td; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 777 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 778 | /* Hi-Speed mode only */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 779 | if (g_usbx_host_UsbDeviceSpeed != USB_HOST_HIGH_SPEED) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 780 | return; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 781 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 782 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 783 | if (RZA_IO_RegRead_32(&p_td->control, TD_CTL_SHFT_CC, TD_CTL_MSK_CC) != TD_CC_NOERROR) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 784 | return; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 785 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 786 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 787 | get_td_info(p_g_ed, &td_info); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 788 | p_buf = p_g_ed->p_start_buf; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 789 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 790 | if (td_info.direction == 0) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 791 | uint8_t bRequest = p_buf[1]; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 792 | uint16_t wValue = (p_buf[3] << 8) + p_buf[2]; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 793 | uint16_t wIndx = (p_buf[5] << 8) + p_buf[4]; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 794 | uint16_t devadd; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 795 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 796 | if ((td_info.devadr == 0) && (bRequest == SET_ADDRESS)) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 797 | /* SET_ADDRESS */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 798 | usbx_host_get_devadd(USB_HOST_DEVICE_0, &devadd); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 799 | usbx_host_set_devadd(wValue, &devadd); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 800 | if (split_ctl.root_devadr == 0) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 801 | split_ctl.root_devadr = wValue; /* New Address */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 802 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 803 | } else if ((td_info.devadr == split_ctl.root_devadr) && (bRequest == SET_FEATURE) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 804 | && (wValue == 0x0004) && (split_ctl.root_devadr != 0)) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 805 | /* SET_FEATURE PORT_RESET */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 806 | split_ctl.reset_port = (wIndx & 0x00FF); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 807 | } else if ((td_info.devadr == split_ctl.root_devadr) && (bRequest == GET_STATUS)) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 808 | /* GET_STATUS */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 809 | split_ctl.get_port = wIndx; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 810 | split_ctl.seq_cnt = 1; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 811 | } else { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 812 | /* Do Nothing */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 813 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 814 | } else if (td_info.direction == 2) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 815 | if ((td_info.devadr == split_ctl.root_devadr) && (split_ctl.seq_cnt == 1)) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 816 | if (split_ctl.get_port < PORT_NUM) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 817 | split_ctl.port_sts_bits[split_ctl.get_port] = (p_buf[1] << 8) + p_buf[0]; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 818 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 819 | split_ctl.seq_cnt = 0; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 820 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 821 | } else { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 822 | /* Do Nothing */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 823 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 824 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 825 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 826 | static void set_split_trans_setting(void) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 827 | uint16_t port_speed; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 828 | uint16_t devadd; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 829 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 830 | if ((split_ctl.root_devadr != 0) && (split_ctl.reset_port != 0) && (split_ctl.reset_port < PORT_NUM)) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 831 | usbx_host_get_devadd(USB_HOST_DEVICE_0, &devadd); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 832 | RZA_IO_RegWrite_16(&devadd, split_ctl.root_devadr, USB_DEVADDn_UPPHUB_SHIFT, USB_DEVADDn_UPPHUB); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 833 | RZA_IO_RegWrite_16(&devadd, split_ctl.reset_port, USB_DEVADDn_HUBPORT_SHIFT, USB_DEVADDn_HUBPORT); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 834 | if ((split_ctl.port_sts_bits[split_ctl.reset_port] & PORT_HIGH_SPEED) != 0) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 835 | port_speed = USB_HOST_HIGH_SPEED; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 836 | } else if ((split_ctl.port_sts_bits[split_ctl.reset_port] & PORT_LOW_SPEED) != 0) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 837 | port_speed = USB_HOST_LOW_SPEED; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 838 | } else { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 839 | port_speed = USB_HOST_FULL_SPEED; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 840 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 841 | RZA_IO_RegWrite_16(&devadd, port_speed, USB_DEVADDn_USBSPD_SHIFT, USB_DEVADDn_USBSPD); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 842 | usbx_host_set_devadd(USB_HOST_DEVICE_0, &devadd); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 843 | split_ctl.reset_port = 0; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 844 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 845 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 846 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 847 | static void control_trans(genelal_ed_t *p_g_ed) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 848 | hctd_t *p_td = (hctd_t *)p_g_ed->p_curr_td; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 849 | tdinfo_t td_info; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 850 | uint16_t devadd; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 851 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 852 | get_td_info(p_g_ed, &td_info); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 853 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 854 | if (g_usbx_host_UsbDeviceSpeed == USB_HOST_HIGH_SPEED) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 855 | if (td_info.devadr == 0) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 856 | set_split_trans_setting(); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 857 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 858 | } else { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 859 | /* When a non-Hi-Speed, the communication speed is determined from the TD. */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 860 | usbx_host_get_devadd(USB_HOST_DEVICE_0, &devadd); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 861 | if (td_info.speed == 1) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 862 | RZA_IO_RegWrite_16(&devadd, USB_HOST_LOW_SPEED, USB_DEVADDn_USBSPD_SHIFT, USB_DEVADDn_USBSPD); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 863 | } else { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 864 | RZA_IO_RegWrite_16(&devadd, USB_HOST_FULL_SPEED, USB_DEVADDn_USBSPD_SHIFT, USB_DEVADDn_USBSPD); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 865 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 866 | usbx_host_set_devadd(td_info.devadr, &devadd); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 867 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 868 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 869 | USB20X.DCPMAXP = (td_info.devadr << 12) + td_info.msp; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 870 | if (td_info.direction == 0) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 871 | g_usbx_host_CmdStage = (USB_HOST_STAGE_SETUP | USB_HOST_CMD_IDLE); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 872 | } else if (td_info.count != 0) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 873 | g_usbx_host_CmdStage = (USB_HOST_STAGE_DATA | USB_HOST_CMD_IDLE); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 874 | } else { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 875 | g_usbx_host_CmdStage = (USB_HOST_STAGE_STATUS | USB_HOST_CMD_IDLE); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 876 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 877 | g_usbx_host_pipe_status[USB_HOST_PIPE0] = USB_HOST_PIPE_WAIT; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 878 | p_g_ed->pipe_no = USB_HOST_PIPE0; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 879 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 880 | p_g_ed->trans_wait = 1; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 881 | if (connect_status == 0) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 882 | ohciwrapp_loc_TransEnd(p_g_ed->pipe_no, TD_CC_DEVICENOTRESPONDING); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 883 | } else { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 884 | if (td_info.direction == 0) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 885 | uint16_t Req = (p_td->currBufPtr[1] << 8) + p_td->currBufPtr[0]; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 886 | uint16_t Val = (p_td->currBufPtr[3] << 8) + p_td->currBufPtr[2]; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 887 | uint16_t Indx = (p_td->currBufPtr[5] << 8) + p_td->currBufPtr[4]; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 888 | uint16_t Len = (p_td->currBufPtr[7] << 8) + p_td->currBufPtr[6]; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 889 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 890 | g_usbx_host_data_pointer[USB_HOST_PIPE0] = p_td->bufEnd; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 891 | usbx_host_SetupStage(Req, Val, Indx, Len); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 892 | } else if (td_info.direction == 1) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 893 | usbx_host_CtrlWriteStart(td_info.count, p_td->currBufPtr); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 894 | } else { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 895 | usbx_host_CtrlReadStart(td_info.count, p_td->currBufPtr); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 896 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 897 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 898 | (void)osSemaphoreWait(p_g_ed->semid_wait, CTL_TRANS_TIMEOUT); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 899 | if (p_g_ed->trans_wait == 1) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 900 | p_g_ed->trans_wait = 0; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 901 | RZA_IO_RegWrite_32(&p_td->control, TD_CC_DEVICENOTRESPONDING, TD_CTL_SHFT_CC, TD_CTL_MSK_CC); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 902 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 903 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 904 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 905 | g_usbx_host_CmdStage &= (~USB_HOST_CMD_FIELD); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 906 | g_usbx_host_CmdStage |= USB_HOST_CMD_IDLE; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 907 | g_usbx_host_pipe_status[USB_HOST_PIPE0] = USB_HOST_PIPE_IDLE; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 908 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 909 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 910 | static void bulk_trans(genelal_ed_t *p_g_ed) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 911 | hctd_t *p_td = (hctd_t *)p_g_ed->p_curr_td; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 912 | hced_t *p_ed = p_g_ed->p_curr_ed; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 913 | tdinfo_t td_info; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 914 | USB_HOST_CFG_PIPETBL_t *user_table = &usb_host_blk_ep_tbl1[0]; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 915 | uint8_t wk_table[6]; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 916 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 917 | get_td_info(p_g_ed, &td_info); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 918 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 919 | wk_table[0] = 0; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 920 | wk_table[1] = USB_HOST_ENDPOINT_DESC; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 921 | wk_table[2] = td_info.endpoint_no; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 922 | if (td_info.direction == 2) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 923 | wk_table[2] |= USB_HOST_EP_IN; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 924 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 925 | wk_table[3] = USB_HOST_EP_BULK; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 926 | wk_table[4] = (uint8_t)td_info.msp; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 927 | wk_table[5] = (uint8_t)(td_info.msp >> 8); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 928 | p_g_ed->pipe_no = user_table->pipe_number; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 929 | usbx_api_host_SetEndpointTable(td_info.devadr, user_table, wk_table); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 930 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 931 | set_togle(p_g_ed->pipe_no, p_td, p_ed); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 932 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 933 | p_g_ed->trans_wait = 1; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 934 | if (connect_status == 0) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 935 | ohciwrapp_loc_TransEnd(p_g_ed->pipe_no, TD_CC_DEVICENOTRESPONDING); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 936 | } else { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 937 | if (td_info.direction == 1) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 938 | usbx_host_start_send_transfer(p_g_ed->pipe_no, td_info.count, p_td->currBufPtr); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 939 | } else { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 940 | usbx_host_start_receive_transfer(p_g_ed->pipe_no, td_info.count, p_td->currBufPtr); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 941 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 942 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 943 | (void)osSemaphoreWait(p_g_ed->semid_wait, BLK_TRANS_TIMEOUT); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 944 | usbx_host_stop_transfer(p_g_ed->pipe_no); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 945 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 946 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 947 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 948 | static void int_trans_setting(genelal_ed_t *p_g_ed, uint32_t index) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 949 | hctd_t *p_td = (hctd_t *)p_g_ed->p_curr_td; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 950 | hced_t *p_ed = p_g_ed->p_curr_ed; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 951 | tdinfo_t td_info; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 952 | USB_HOST_CFG_PIPETBL_t *user_table = &usb_host_int_ep_tbl1[index]; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 953 | uint8_t wk_table[6]; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 954 | uint32_t cycle_time; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 955 | uint16_t devadd; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 956 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 957 | get_td_info(p_g_ed, &td_info); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 958 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 959 | wk_table[0] = 0; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 960 | wk_table[1] = USB_HOST_ENDPOINT_DESC; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 961 | wk_table[2] = td_info.endpoint_no; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 962 | if (td_info.direction == 2) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 963 | wk_table[2] |= USB_HOST_EP_IN; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 964 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 965 | wk_table[3] = USB_HOST_EP_INT; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 966 | wk_table[4] = (uint8_t)td_info.msp; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 967 | wk_table[5] = (uint8_t)(td_info.msp >> 8); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 968 | cycle_time = chk_cycle(p_ed); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 969 | p_g_ed->cycle_time = cycle_time; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 970 | user_table->pipe_cycle = 0; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 971 | while (cycle_time > 1) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 972 | cycle_time >>= 1; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 973 | user_table->pipe_cycle++; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 974 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 975 | if (g_usbx_host_UsbDeviceSpeed == USB_HOST_HIGH_SPEED) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 976 | usbx_host_get_devadd(td_info.devadr, &devadd); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 977 | if (RZA_IO_RegRead_16(&devadd, USB_DEVADDn_USBSPD_SHIFT, USB_DEVADDn_USBSPD) == USB_HOST_HIGH_SPEED) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 978 | user_table->pipe_cycle += 3; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 979 | if (user_table->pipe_cycle > 7) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 980 | user_table->pipe_cycle = 7; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 981 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 982 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 983 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 984 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 985 | p_g_ed->pipe_no = user_table->pipe_number; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 986 | usbx_api_host_SetEndpointTable(td_info.devadr, user_table, wk_table); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 987 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 988 | set_togle(p_g_ed->pipe_no, p_td, p_ed); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 989 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 990 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 991 | static uint32_t chk_cycle(hced_t *p_ed) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 992 | uint32_t cnt; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 993 | uint32_t hit_cnt = 0; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 994 | uint32_t cycle_time = 1; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 995 | hcca_t *p_hcca; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 996 | hced_t *p_wk_ed; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 997 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 998 | p_hcca = (hcca_t *)p_usb_reg->HcHCCA; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 999 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1000 | for (cnt = 0; cnt < 32; cnt++) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1001 | p_wk_ed = (hced_t *)p_hcca->IntTable[cnt]; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1002 | while (p_wk_ed != NULL) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1003 | if (p_wk_ed == p_ed) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1004 | hit_cnt++; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1005 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1006 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1007 | p_wk_ed = p_wk_ed->nextED; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1008 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1009 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1010 | if (hit_cnt < 2) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1011 | cycle_time = 32; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1012 | } else if (hit_cnt < 4) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1013 | cycle_time = 16; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1014 | } else if (hit_cnt < 8) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1015 | cycle_time = 8; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1016 | } else if (hit_cnt < 16) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1017 | cycle_time = 4; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1018 | } else if (hit_cnt < 32) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1019 | cycle_time = 2; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1020 | } else{ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1021 | cycle_time = 1; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1022 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1023 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1024 | return cycle_time; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1025 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1026 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1027 | static void int_trans(genelal_ed_t *p_g_ed) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1028 | hctd_t *p_td = (hctd_t *)p_g_ed->p_curr_td; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1029 | tdinfo_t td_info; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1030 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1031 | get_td_info(p_g_ed, &td_info); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1032 | p_g_ed->trans_wait = 1; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1033 | if (connect_status == 0) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1034 | ohciwrapp_loc_TransEnd(p_g_ed->pipe_no, TD_CC_DEVICENOTRESPONDING); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1035 | } else { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1036 | if (td_info.direction == 1) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1037 | usbx_host_start_send_transfer(p_g_ed->pipe_no, td_info.count, p_td->currBufPtr); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1038 | } else { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1039 | usbx_host_start_receive_transfer(p_g_ed->pipe_no, td_info.count, p_td->currBufPtr); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1040 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1041 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1042 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1043 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1044 | static void get_td_info(genelal_ed_t *p_g_ed, tdinfo_t *p_td_info) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1045 | hced_t *p_ed = p_g_ed->p_curr_ed; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1046 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1047 | p_td_info->endpoint_no = (uint8_t)((p_ed->control >> 7) & 0x0000000F); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1048 | p_td_info->msp = (p_ed->control >> 16) & 0x000007FF; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1049 | p_td_info->devadr = p_ed->control & 0x0000000F; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1050 | p_td_info->speed = (p_ed->control >> 13) & 0x00000001; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1051 | p_td_info->direction = (p_ed->control >> 11) & 0x00000003; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1052 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1053 | if ((p_ed->control & ED_FORMAT) == 0) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1054 | hctd_t *p_td = (hctd_t *)p_g_ed->p_curr_td; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1055 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1056 | if ((p_td_info->direction == 0) || (p_td_info->direction == 3)) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1057 | if ((p_td->control & TD_CTL_MSK_DP) == TD_SETUP) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1058 | p_td_info->direction = 0; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1059 | } else if ((p_td->control & TD_CTL_MSK_DP) == TD_OUT) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1060 | p_td_info->direction = 1; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1061 | } else { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1062 | p_td_info->direction = 2; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1063 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1064 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1065 | if (p_td->currBufPtr != NULL) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1066 | p_td_info->count = (uint32_t)p_td->bufEnd - (uint32_t)p_td->currBufPtr + 1; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1067 | } else { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1068 | p_td_info->count = 0; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1069 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1070 | } else { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1071 | #if (ISO_TRANS_MAX_NUM > 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1072 | hcisotd_t *p_isotd = (hcisotd_t *)p_g_ed->p_curr_td; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1073 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1074 | if ((p_td_info->direction == 0) || (p_td_info->direction == 3)) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1075 | if ((p_isotd->control & TD_CTL_MSK_DP) == TD_SETUP) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1076 | p_td_info->direction = 0; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1077 | } else if ((p_isotd->control & TD_CTL_MSK_DP) == TD_OUT) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1078 | p_td_info->direction = 1; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1079 | } else { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1080 | p_td_info->direction = 2; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1081 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1082 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1083 | #endif |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1084 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1085 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1086 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1087 | static void set_togle(uint32_t pipe, hctd_t *p_td, hced_t *p_ed) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1088 | if ((p_td->control & TD_CTL_MSK_T) == TD_TOGGLE_0) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1089 | usbx_host_set_sqclr(pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1090 | } else if ((p_td->control & TD_CTL_MSK_T) == TD_TOGGLE_1) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1091 | usbx_host_set_sqset(pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1092 | } else if ((p_ed->headTD & ED_TOGLE_CARRY) == 0) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1093 | usbx_host_set_sqclr(pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1094 | } else { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1095 | usbx_host_set_sqset(pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1096 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1097 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1098 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1099 | #if (ISO_TRANS_MAX_NUM > 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1100 | static void iso_ed_task(void const * argument) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1101 | genelal_ed_t *p_iso_ed = &iso_ed[(uint32_t)argument]; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1102 | uint32_t wait_cnt = 0; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1103 | hcca_t *p_hcca; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1104 | hced_t *p_ed; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1105 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1106 | while (1) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1107 | (void)osSemaphoreWait(p_iso_ed->semid_list, osWaitForever); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1108 | if (p_iso_ed->p_curr_ed == NULL) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1109 | p_hcca = (hcca_t *)p_usb_reg->HcHCCA; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1110 | p_ed = (hced_t *)p_hcca->IntTable[0]; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1111 | while ((p_ed != NULL) && ((p_usb_reg->HcControl & OR_CONTROL_IE) != 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1112 | && (p_iso_ed->p_curr_ed == NULL)) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1113 | if (iso_trans_doing(p_ed, (uint32_t)argument) == 0) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1114 | p_iso_ed->p_curr_ed = p_ed; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1115 | if (chk_iso_ed(p_iso_ed) != 0) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1116 | iso_trans_setting(p_iso_ed, (uint32_t)argument); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1117 | } else { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1118 | p_iso_ed->p_curr_ed = NULL; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1119 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1120 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1121 | p_ed = p_ed->nextED; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1122 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1123 | p_iso_ed->psw_idx = 0; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1124 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1125 | if (p_iso_ed->p_curr_ed != NULL) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1126 | while ((p_usb_reg->HcControl & OR_CONTROL_IE) != 0) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1127 | if (chk_iso_ed(p_iso_ed) != 0) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1128 | hcisotd_t *p_isotd = (hcisotd_t *)p_iso_ed->p_curr_td; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1129 | uint32_t starting_frame = p_isotd->control & 0x0000FFFF; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1130 | uint32_t wait_time = 0; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1131 | uint32_t wk_HcFmNumber = p_usb_reg->HcFmNumber; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1132 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1133 | if (starting_frame > wk_HcFmNumber) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1134 | wait_time = starting_frame - wk_HcFmNumber; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1135 | } else { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1136 | wait_time = (0xFFFF - wk_HcFmNumber) + starting_frame; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1137 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1138 | if ((wait_time >= 2) && (wait_time <= 1000)) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1139 | for (int cnt = 0; cnt < (wait_time - 1); cnt++) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1140 | osDelay(1); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1141 | p_usb_reg->HcFmNumber = (wk_HcFmNumber + cnt) & 0x0000FFFF; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1142 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1143 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1144 | p_iso_ed->psw_idx = 0; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1145 | iso_trans(p_iso_ed); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1146 | (void)osSemaphoreWait(p_iso_ed->semid_wait, osWaitForever); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1147 | wait_cnt = 8; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1148 | } else { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1149 | if (wait_cnt > 0) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1150 | wait_cnt--; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1151 | } else { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1152 | p_iso_ed->p_curr_ed = NULL; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1153 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1154 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1155 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1156 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1157 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1158 | (void)osSemaphoreRelease(p_iso_ed->semid_list); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1159 | if (p_iso_ed->p_curr_ed == NULL) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1160 | osDelay(10); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1161 | } else { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1162 | osDelay(1); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1163 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1164 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1165 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1166 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1167 | static int32_t iso_trans_doing(hced_t *p_ed, uint32_t index) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1168 | uint32_t cnt; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1169 | int32_t ret = 0; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1170 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1171 | for (cnt = 0; cnt < ISO_TRANS_MAX_NUM; cnt++) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1172 | if ((index != cnt) && (iso_ed[cnt].p_curr_ed == p_ed)) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1173 | ret = 1; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1174 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1175 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1176 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1177 | return ret; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1178 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1179 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1180 | static void chk_iso_td_done(genelal_ed_t *p_g_ed) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1181 | hcca_t *p_hcca; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1182 | hcisotd_t *p_isotd = (hcisotd_t *)p_g_ed->p_curr_td; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1183 | uint32_t ConditionCode = RZA_IO_RegRead_32(&p_isotd->control, TD_CTL_SHFT_CC, TD_CTL_MSK_CC); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1184 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1185 | if ((ConditionCode != TD_CC_NOT_ACCESSED_1) && (ConditionCode != TD_CC_NOT_ACCESSED_2)) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1186 | p_g_ed->p_curr_ed->headTD = ((uint32_t)p_isotd->nextTD & 0xFFFFFFF0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1187 | | (p_g_ed->p_curr_ed->headTD & 0x0000000F); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1188 | p_isotd->nextTD = (hcisotd_t *)p_usb_reg->HcDoneHead; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1189 | p_usb_reg->HcDoneHead = (uint32_t)p_g_ed->p_curr_td; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1190 | if ((p_usb_reg->HcInterruptStatus & OR_INTR_STATUS_WDH) == 0) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1191 | p_hcca = (hcca_t *)p_usb_reg->HcHCCA; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1192 | p_hcca->DoneHead = p_usb_reg->HcDoneHead; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1193 | p_usb_reg->HcDoneHead = 0x00000000; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1194 | p_usb_reg->HcInterruptStatus |= OR_INTR_STATUS_WDH; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1195 | (void)osSemaphoreRelease(semid_cb); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1196 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1197 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1198 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1199 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1200 | static int32_t chk_iso_ed(genelal_ed_t *p_g_ed){ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1201 | int32_t ret = 0; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1202 | hced_t *p_ed = p_g_ed->p_curr_ed; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1203 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1204 | if (((p_ed->control & ED_SKIP) != 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1205 | || ((p_ed->control & ED_FORMAT) == 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1206 | || ((p_ed->headTD & ED_HALTED) != 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1207 | || ((p_ed->tailTD & 0xFFFFFFF0) == (p_ed->headTD & 0xFFFFFFF0))) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1208 | /* Do Nothing */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1209 | } else if ((p_ed->control & 0x0000007F) > 10) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1210 | p_ed->headTD |= ED_HALTED; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1211 | } else { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1212 | p_g_ed->p_curr_td = (void *)(p_ed->headTD & 0xFFFFFFF0); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1213 | if (p_g_ed->p_curr_td == NULL) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1214 | p_ed->headTD |= ED_HALTED; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1215 | } else { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1216 | hcisotd_t *p_isotd = (hcisotd_t *)p_g_ed->p_curr_td; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1217 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1218 | p_g_ed->p_start_buf = p_isotd->bufferPage0; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1219 | ret = 1; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1220 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1221 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1222 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1223 | return ret; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1224 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1225 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1226 | static void iso_trans_setting(genelal_ed_t *p_g_ed, uint32_t index) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1227 | tdinfo_t td_info; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1228 | USB_HOST_CFG_PIPETBL_t *user_table = &usb_host_iso_ep_tbl1[index]; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1229 | uint8_t wk_table[6]; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1230 | uint16_t devadd; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1231 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1232 | get_td_info(p_g_ed, &td_info); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1233 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1234 | wk_table[0] = 0; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1235 | wk_table[1] = USB_HOST_ENDPOINT_DESC; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1236 | wk_table[2] = td_info.endpoint_no; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1237 | if (td_info.direction == 2) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1238 | wk_table[2] |= USB_HOST_EP_IN; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1239 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1240 | wk_table[3] = USB_HOST_EP_ISO; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1241 | wk_table[4] = (uint8_t)td_info.msp; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1242 | wk_table[5] = (uint8_t)(td_info.msp >> 8); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1243 | p_g_ed->cycle_time = 1; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1244 | user_table->pipe_cycle = 0; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1245 | if (g_usbx_host_UsbDeviceSpeed == USB_HOST_HIGH_SPEED) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1246 | usbx_host_get_devadd(td_info.devadr, &devadd); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1247 | if (RZA_IO_RegRead_16(&devadd, USB_DEVADDn_USBSPD_SHIFT, USB_DEVADDn_USBSPD) == USB_HOST_HIGH_SPEED) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1248 | user_table->pipe_cycle += 3; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1249 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1250 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1251 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1252 | p_g_ed->pipe_no = user_table->pipe_number; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1253 | usbx_api_host_SetEndpointTable(td_info.devadr, user_table, wk_table); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1254 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1255 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1256 | static void iso_trans(genelal_ed_t *p_g_ed) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1257 | hcisotd_t *p_isotd = (hcisotd_t *)p_g_ed->p_curr_td; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1258 | tdinfo_t td_info; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1259 | uint32_t buff_addr; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1260 | uint32_t data_size; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1261 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1262 | if (((uint32_t)p_isotd->offsetPSW[p_g_ed->psw_idx] & 0x00001000) == 0) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1263 | buff_addr = (uint32_t)p_isotd->bufferPage0 & 0xFFFFF000; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1264 | } else { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1265 | buff_addr = (uint32_t)p_isotd->bufEnd & 0xFFFFF000; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1266 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1267 | buff_addr |= (uint32_t)p_isotd->offsetPSW[p_g_ed->psw_idx] & 0x00000FFF; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1268 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1269 | if (p_g_ed->psw_idx < RZA_IO_RegRead_32(&p_isotd->control, TD_CTL_SHFT_FC, TD_CTL_MSK_FC)) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1270 | data_size = p_isotd->offsetPSW[p_g_ed->psw_idx + 1] - p_isotd->offsetPSW[p_g_ed->psw_idx]; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1271 | } else { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1272 | data_size = (uint32_t)p_isotd->bufEnd - buff_addr + 1; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1273 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1274 | p_isotd->offsetPSW[p_g_ed->psw_idx] = (uint16_t)data_size; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1275 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1276 | get_td_info(p_g_ed, &td_info); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1277 | p_g_ed->trans_wait = 1; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1278 | if (connect_status == 0) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1279 | ohciwrapp_loc_TransEnd(p_g_ed->pipe_no, TD_CC_DEVICENOTRESPONDING); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1280 | } else { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1281 | if (td_info.direction == 1) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1282 | usbx_host_start_send_transfer(p_g_ed->pipe_no, data_size, (uint8_t *)buff_addr); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1283 | } else { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1284 | usbx_host_start_receive_transfer(p_g_ed->pipe_no, data_size, (uint8_t *)buff_addr); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1285 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1286 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1287 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1288 | #endif |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1289 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1290 | static void connect_check(void) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1291 | uint32_t type = 0; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1292 | uint16_t stat; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1293 | uint16_t devadd = 0; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1294 | uint32_t wk_HcRhPortStatus1 = p_usb_reg->HcRhPortStatus1; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1295 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1296 | if (usbx_host_CheckAttach() == USB_HOST_ATTACH) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1297 | type = 1; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1298 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1299 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1300 | if ((((wk_HcRhPortStatus1 & OR_RH_PORT_CCS) == 0) && (type == 0)) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1301 | || (((wk_HcRhPortStatus1 & OR_RH_PORT_CCS) != 0) && (type != 0))) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1302 | return; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1303 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1304 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1305 | if (type == 0) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1306 | usbx_host_UsbDetach(); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1307 | wk_HcRhPortStatus1 &= ~OR_RH_PORT_CCS; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1308 | } else { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1309 | usbx_host_UsbAttach(); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1310 | stat = usbx_host_UsbBusReset(); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1311 | RZA_IO_RegWrite_16(&devadd, 0, USB_DEVADDn_UPPHUB_SHIFT, USB_DEVADDn_UPPHUB); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1312 | RZA_IO_RegWrite_16(&devadd, 0, USB_DEVADDn_HUBPORT_SHIFT, USB_DEVADDn_HUBPORT); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1313 | if (stat == USB_HOST_HSMODE) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1314 | wk_HcRhPortStatus1 &= ~OR_RH_PORT_LSDA; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1315 | RZA_IO_RegWrite_16(&USB20X.SOFCFG, 0, USB_SOFCFG_TRNENSEL_SHIFT, USB_SOFCFG_TRNENSEL); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1316 | g_usbx_host_UsbDeviceSpeed = USB_HOST_HIGH_SPEED; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1317 | } else if (stat == USB_HOST_FSMODE) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1318 | wk_HcRhPortStatus1 &= ~OR_RH_PORT_LSDA; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1319 | RZA_IO_RegWrite_16(&USB20X.SOFCFG, 0, USB_SOFCFG_TRNENSEL_SHIFT, USB_SOFCFG_TRNENSEL); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1320 | g_usbx_host_UsbDeviceSpeed = USB_HOST_FULL_SPEED; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1321 | } else { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1322 | wk_HcRhPortStatus1 |= OR_RH_PORT_LSDA; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1323 | RZA_IO_RegWrite_16(&USB20X.SOFCFG, 1, USB_SOFCFG_TRNENSEL_SHIFT, USB_SOFCFG_TRNENSEL); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1324 | g_usbx_host_UsbDeviceSpeed = USB_HOST_LOW_SPEED; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1325 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1326 | RZA_IO_RegWrite_16(&devadd, g_usbx_host_UsbDeviceSpeed, USB_DEVADDn_USBSPD_SHIFT, USB_DEVADDn_USBSPD); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1327 | usbx_host_init_pipe_status(); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1328 | usbx_host_set_devadd(USB_HOST_DEVICE_0, &devadd); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1329 | wk_HcRhPortStatus1 |= OR_RH_PORT_CCS; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1330 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1331 | wk_HcRhPortStatus1 |= OR_RH_PORT_CSC; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1332 | p_usb_reg->HcRhPortStatus1 = wk_HcRhPortStatus1; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1333 | p_usb_reg->HcInterruptStatus |= OR_INTR_STATUS_RHSC; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1334 | (void)memset(&split_ctl, 0, sizeof(split_ctl)); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1335 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1336 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1337 | void ohciwrapp_loc_Connect(uint32_t type) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1338 | uint32_t cnt; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1339 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1340 | connect_status = type; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1341 | connect_change = type; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1342 | if (type == 0) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1343 | if (ctl_ed.trans_wait == 1) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1344 | ohciwrapp_loc_TransEnd(ctl_ed.pipe_no, TD_CC_DEVICENOTRESPONDING); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1345 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1346 | if (blk_ed.trans_wait == 1) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1347 | ohciwrapp_loc_TransEnd(blk_ed.pipe_no, TD_CC_DEVICENOTRESPONDING); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1348 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1349 | for (cnt = 0; cnt< INT_TRANS_MAX_NUM; cnt++) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1350 | if (int_ed[cnt].trans_wait == 1) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1351 | ohciwrapp_loc_TransEnd(int_ed[cnt].pipe_no, TD_CC_DEVICENOTRESPONDING); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1352 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1353 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1354 | #if (ISO_TRANS_MAX_NUM > 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1355 | for (cnt = 0; cnt< ISO_TRANS_MAX_NUM; cnt++) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1356 | if (iso_ed[cnt].trans_wait == 1) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1357 | hced_t *p_ed = iso_ed[cnt].p_curr_ed; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1358 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1359 | p_ed->headTD |= ED_HALTED; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1360 | ohciwrapp_loc_TransEnd(iso_ed[cnt].pipe_no, TD_CC_DEVICENOTRESPONDING); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1361 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1362 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1363 | #endif |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1364 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1365 | (void)osSemaphoreRelease(semid_cb); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1366 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1367 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1368 | void ohciwrapp_loc_TransEnd(uint32_t pipe, uint32_t ConditionCode) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1369 | uint32_t periodic = 0; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1370 | uint32_t cnt; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1371 | uint32_t sqmon; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1372 | hced_t *p_ed; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1373 | genelal_ed_t *p_wait_ed = NULL; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1374 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1375 | if (ctl_ed.pipe_no == pipe) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1376 | p_wait_ed = &ctl_ed; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1377 | } else if (blk_ed.pipe_no == pipe) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1378 | p_wait_ed = &blk_ed; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1379 | } else { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1380 | #if (ISO_TRANS_MAX_NUM > 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1381 | if (p_wait_ed == NULL) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1382 | for (cnt = 0; cnt< ISO_TRANS_MAX_NUM; cnt++) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1383 | if (iso_ed[cnt].pipe_no == pipe) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1384 | p_wait_ed = &iso_ed[cnt]; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1385 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1386 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1387 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1388 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1389 | #endif |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1390 | if (p_wait_ed == NULL) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1391 | for (cnt = 0; cnt< INT_TRANS_MAX_NUM; cnt++) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1392 | if (int_ed[cnt].pipe_no == pipe) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1393 | p_wait_ed = &int_ed[cnt]; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1394 | periodic = 1; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1395 | break; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1396 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1397 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1398 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1399 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1400 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1401 | if (p_wait_ed == NULL) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1402 | return; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1403 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1404 | p_ed = p_wait_ed->p_curr_ed; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1405 | if (p_ed == NULL) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1406 | return; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1407 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1408 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1409 | if ((p_ed->control & ED_FORMAT) == 0) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1410 | hctd_t *p_td = (hctd_t *)p_wait_ed->p_curr_td; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1411 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1412 | if (p_td != NULL) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1413 | if (ConditionCode == TD_CC_NOERROR) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1414 | /* ErrorCount */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1415 | RZA_IO_RegWrite_32(&p_td->control, 0, TD_CTL_SHFT_EC, TD_CTL_MSK_EC); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1416 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1417 | /* CurrentBufferPointer */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1418 | p_td->currBufPtr += ((uint32_t)p_td->bufEnd - (uint32_t)p_td->currBufPtr + 1) - g_usbx_host_data_count[pipe]; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1419 | } else { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1420 | /* ErrorCount */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1421 | RZA_IO_RegWrite_32(&p_td->control, 3, TD_CTL_SHFT_EC, TD_CTL_MSK_EC); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1422 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1423 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1424 | /* DataToggle */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1425 | sqmon = usbx_host_get_sqmon(pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1426 | RZA_IO_RegWrite_32(&p_td->control, sqmon, TD_CTL_SHFT_T, TD_CTL_MSK_T); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1427 | if (sqmon == 0) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1428 | p_ed->headTD &= ~ED_TOGLE_CARRY; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1429 | } else { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1430 | p_ed->headTD |= ED_TOGLE_CARRY; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1431 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1432 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1433 | /* ConditionCode */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1434 | RZA_IO_RegWrite_32(&p_td->control, ConditionCode, TD_CTL_SHFT_CC, TD_CTL_MSK_CC); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1435 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1436 | if (p_wait_ed == &ctl_ed) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1437 | chk_split_trans_setting(&ctl_ed); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1438 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1439 | chk_genelal_td_done(p_wait_ed); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1440 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1441 | if (periodic != 0) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1442 | if (chk_genelal_ed(p_wait_ed) != 0) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1443 | int_trans(p_wait_ed); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1444 | } else { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1445 | p_wait_ed->trans_wait = 0; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1446 | (void)osSemaphoreRelease(p_wait_ed->semid_wait); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1447 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1448 | } else { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1449 | p_wait_ed->trans_wait = 0; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1450 | (void)osSemaphoreRelease(p_wait_ed->semid_wait); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1451 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1452 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1453 | } else { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1454 | #if (ISO_TRANS_MAX_NUM > 0) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1455 | hcisotd_t *p_isotd = (hcisotd_t *)p_wait_ed->p_curr_td; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1456 | uint32_t next_trans = 0; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1457 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1458 | if (p_isotd != NULL) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1459 | usbx_host_stop_transfer(pipe); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1460 | p_usb_reg->HcFmNumber = ((p_isotd->control & 0x0000FFFF) + p_wait_ed->psw_idx) & 0x0000FFFF; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1461 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1462 | /* Size of packet */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1463 | p_isotd->offsetPSW[p_wait_ed->psw_idx] -= g_usbx_host_data_count[pipe]; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1464 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1465 | /* ConditionCode */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1466 | RZA_IO_RegWrite_32(&p_isotd->control, ConditionCode, TD_CTL_SHFT_CC, TD_CTL_MSK_CC); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1467 | RZA_IO_RegWrite_16(&p_isotd->offsetPSW[p_wait_ed->psw_idx], |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1468 | (uint16_t)ConditionCode, TD_PSW_SHFT_CC, TD_PSW_MSK_CC); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1469 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1470 | if (usbx_host_CheckAttach() != USB_HOST_ATTACH) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1471 | p_ed->headTD |= ED_HALTED; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1472 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1473 | if (p_wait_ed->psw_idx >= RZA_IO_RegRead_32(&p_isotd->control, TD_CTL_SHFT_FC, TD_CTL_MSK_FC)) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1474 | p_wait_ed->psw_idx = 0; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1475 | chk_iso_td_done(p_wait_ed); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1476 | } else { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1477 | p_wait_ed->psw_idx++; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1478 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1479 | if (chk_iso_ed(p_wait_ed) != 0) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1480 | iso_trans(p_wait_ed); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1481 | next_trans = 1; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1482 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1483 | if (next_trans == 0) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1484 | p_wait_ed->trans_wait = 0; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1485 | (void)osSemaphoreRelease(p_wait_ed->semid_wait); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1486 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1487 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1488 | #endif |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1489 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1490 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1491 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1492 |