Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
usb_int.c
00001 /******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** 00002 * File Name : usb_int.c 00003 * Author : MCD Application Team 00004 * Version : V3.2.1 00005 * Date : 07/05/2010 00006 * Description : Endpoint CTR (Low and High) interrupt's service routines 00007 ******************************************************************************** 00008 * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 00009 * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. 00010 * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, 00011 * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE 00012 * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING 00013 * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 00014 *******************************************************************************/ 00015 #ifndef STM32F10X_CL 00016 00017 /* Includes ------------------------------------------------------------------*/ 00018 #include "usb_lib.h" 00019 00020 /* Private typedef -----------------------------------------------------------*/ 00021 /* Private define ------------------------------------------------------------*/ 00022 /* Private macro -------------------------------------------------------------*/ 00023 /* Private variables ---------------------------------------------------------*/ 00024 __IO uint16_t SaveRState; 00025 __IO uint16_t SaveTState; 00026 00027 /* Extern variables ----------------------------------------------------------*/ 00028 extern void (*pEpInt_IN[7])(void); /* Handles IN interrupts */ 00029 extern void (*pEpInt_OUT[7])(void); /* Handles OUT interrupts */ 00030 00031 /* Private function prototypes -----------------------------------------------*/ 00032 /* Private functions ---------------------------------------------------------*/ 00033 00034 /******************************************************************************* 00035 * Function Name : CTR_LP. 00036 * Description : Low priority Endpoint Correct Transfer interrupt's service 00037 * routine. 00038 * Input : None. 00039 * Output : None. 00040 * Return : None. 00041 *******************************************************************************/ 00042 void CTR_LP(void) 00043 { 00044 __IO uint16_t wEPVal = 0; 00045 /* stay in loop while pending ints */ 00046 while (((wIstr = _GetISTR()) & ISTR_CTR) != 0) 00047 { 00048 /* extract highest priority endpoint number */ 00049 EPindex = (uint8_t)(wIstr & ISTR_EP_ID); 00050 if (EPindex == 0) 00051 { 00052 /* Decode and service control endpoint interrupt */ 00053 /* calling related service routine */ 00054 /* (Setup0_Process, In0_Process, Out0_Process) */ 00055 00056 /* save RX & TX status */ 00057 /* and set both to NAK */ 00058 00059 00060 SaveRState = _GetENDPOINT(ENDP0); 00061 SaveTState = SaveRState & EPTX_STAT; 00062 SaveRState &= EPRX_STAT; 00063 00064 _SetEPRxTxStatus(ENDP0,EP_RX_NAK,EP_TX_NAK); 00065 00066 /* DIR bit = origin of the interrupt */ 00067 00068 if ((wIstr & ISTR_DIR) == 0) 00069 { 00070 /* DIR = 0 */ 00071 00072 /* DIR = 0 => IN int */ 00073 /* DIR = 0 implies that (EP_CTR_TX = 1) always */ 00074 00075 00076 _ClearEP_CTR_TX(ENDP0); 00077 In0_Process(); 00078 00079 /* before terminate set Tx & Rx status */ 00080 00081 _SetEPRxTxStatus(ENDP0,SaveRState,SaveTState); 00082 return; 00083 } 00084 else 00085 { 00086 /* DIR = 1 */ 00087 00088 /* DIR = 1 & CTR_RX => SETUP or OUT int */ 00089 /* DIR = 1 & (CTR_TX | CTR_RX) => 2 int pending */ 00090 00091 wEPVal = _GetENDPOINT(ENDP0); 00092 00093 if ((wEPVal &EP_SETUP) != 0) 00094 { 00095 _ClearEP_CTR_RX(ENDP0); /* SETUP bit kept frozen while CTR_RX = 1 */ 00096 Setup0_Process(); 00097 /* before terminate set Tx & Rx status */ 00098 00099 _SetEPRxTxStatus(ENDP0,SaveRState,SaveTState); 00100 return; 00101 } 00102 00103 else if ((wEPVal & EP_CTR_RX) != 0) 00104 { 00105 _ClearEP_CTR_RX(ENDP0); 00106 Out0_Process(); 00107 /* before terminate set Tx & Rx status */ 00108 00109 _SetEPRxTxStatus(ENDP0,SaveRState,SaveTState); 00110 return; 00111 } 00112 } 00113 }/* if(EPindex == 0) */ 00114 else 00115 { 00116 /* Decode and service non control endpoints interrupt */ 00117 00118 /* process related endpoint register */ 00119 wEPVal = _GetENDPOINT(EPindex); 00120 if ((wEPVal & EP_CTR_RX) != 0) 00121 { 00122 /* clear int flag */ 00123 _ClearEP_CTR_RX(EPindex); 00124 00125 /* call OUT service function */ 00126 (*pEpInt_OUT[EPindex-1])(); 00127 00128 } /* if((wEPVal & EP_CTR_RX) */ 00129 00130 if ((wEPVal & EP_CTR_TX) != 0) 00131 { 00132 /* clear int flag */ 00133 _ClearEP_CTR_TX(EPindex); 00134 00135 /* call IN service function */ 00136 (*pEpInt_IN[EPindex-1])(); 00137 } /* if((wEPVal & EP_CTR_TX) != 0) */ 00138 00139 }/* if(EPindex == 0) else */ 00140 00141 }/* while(...) */ 00142 } 00143 00144 /******************************************************************************* 00145 * Function Name : CTR_HP. 00146 * Description : High Priority Endpoint Correct Transfer interrupt's service 00147 * routine. 00148 * Input : None. 00149 * Output : None. 00150 * Return : None. 00151 *******************************************************************************/ 00152 void CTR_HP(void) 00153 { 00154 uint32_t wEPVal = 0; 00155 00156 while (((wIstr = _GetISTR()) & ISTR_CTR) != 0) 00157 { 00158 _SetISTR((uint16_t)CLR_CTR); /* clear CTR flag */ 00159 /* extract highest priority endpoint number */ 00160 EPindex = (uint8_t)(wIstr & ISTR_EP_ID); 00161 /* process related endpoint register */ 00162 wEPVal = _GetENDPOINT(EPindex); 00163 if ((wEPVal & EP_CTR_RX) != 0) 00164 { 00165 /* clear int flag */ 00166 _ClearEP_CTR_RX(EPindex); 00167 00168 /* call OUT service function */ 00169 (*pEpInt_OUT[EPindex-1])(); 00170 00171 } /* if((wEPVal & EP_CTR_RX) */ 00172 else if ((wEPVal & EP_CTR_TX) != 0) 00173 { 00174 /* clear int flag */ 00175 _ClearEP_CTR_TX(EPindex); 00176 00177 /* call IN service function */ 00178 (*pEpInt_IN[EPindex-1])(); 00179 00180 00181 } /* if((wEPVal & EP_CTR_TX) != 0) */ 00182 00183 }/* while(...) */ 00184 } 00185 00186 #endif /* STM32F10X_CL */ 00187 00188 /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
Generated on Tue Jul 12 2022 20:45:32 by
1.7.2