2 ******************************************************************************
4 * @author MCD Application Team
7 * @brief Endpoint CTR (Low and High) interrupt's service routines
8 ******************************************************************************
11 * <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2>
13 * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
14 * You may not use this file except in compliance with the License.
15 * You may obtain a copy of the License at:
17 * http://www.st.com/software_license_agreement_liberty_v2
19 * Unless required by applicable law or agreed to in writing, software
20 * distributed under the License is distributed on an "AS IS" BASIS,
21 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 * See the License for the specific language governing permissions and
23 * limitations under the License.
25 ******************************************************************************
28 /* Includes ------------------------------------------------------------------*/
31 /* Private typedef -----------------------------------------------------------*/
32 /* Private define ------------------------------------------------------------*/
33 /* Private macro -------------------------------------------------------------*/
34 /* Private variables ---------------------------------------------------------*/
35 __IO
uint16_t SaveRState
;
36 __IO
uint16_t SaveTState
;
38 /* Extern variables ----------------------------------------------------------*/
39 extern void (*pEpInt_IN
[7])(void); /* Handles IN interrupts */
40 extern void (*pEpInt_OUT
[7])(void); /* Handles OUT interrupts */
42 /* Private function prototypes -----------------------------------------------*/
43 /* Private functions ---------------------------------------------------------*/
45 /*******************************************************************************
46 * Function Name : CTR_LP.
47 * Description : Low priority Endpoint Correct Transfer interrupt's service
52 *******************************************************************************/
55 __IO
uint16_t wEPVal
= 0;
56 /* stay in loop while pending interrupts */
57 while (((wIstr
= _GetISTR()) & ISTR_CTR
) != 0)
59 /* extract highest priority endpoint number */
60 EPindex
= (uint8_t)(wIstr
& ISTR_EP_ID
);
63 /* Decode and service control endpoint interrupt */
64 /* calling related service routine */
65 /* (Setup0_Process, In0_Process, Out0_Process) */
67 /* save RX & TX status */
68 /* and set both to NAK */
70 SaveRState
= _GetENDPOINT(ENDP0
);
71 SaveTState
= SaveRState
& EPTX_STAT
;
72 SaveRState
&= EPRX_STAT
;
74 _SetEPRxTxStatus(ENDP0
,EP_RX_NAK
,EP_TX_NAK
);
76 /* DIR bit = origin of the interrupt */
78 if ((wIstr
& ISTR_DIR
) == 0)
82 /* DIR = 0 => IN int */
83 /* DIR = 0 implies that (EP_CTR_TX = 1) always */
85 _ClearEP_CTR_TX(ENDP0
);
88 /* before terminate set Tx & Rx status */
90 _SetEPRxTxStatus(ENDP0
,SaveRState
,SaveTState
);
97 /* DIR = 1 & CTR_RX => SETUP or OUT int */
98 /* DIR = 1 & (CTR_TX | CTR_RX) => 2 int pending */
100 wEPVal
= _GetENDPOINT(ENDP0
);
102 if ((wEPVal
&EP_SETUP
) != 0)
104 _ClearEP_CTR_RX(ENDP0
); /* SETUP bit kept frozen while CTR_RX = 1 */
106 /* before terminate set Tx & Rx status */
108 _SetEPRxTxStatus(ENDP0
,SaveRState
,SaveTState
);
112 else if ((wEPVal
& EP_CTR_RX
) != 0)
114 _ClearEP_CTR_RX(ENDP0
);
116 /* before terminate set Tx & Rx status */
118 _SetEPRxTxStatus(ENDP0
,SaveRState
,SaveTState
);
122 }/* if(EPindex == 0) */
125 /* Decode and service non control endpoints interrupt */
127 /* process related endpoint register */
128 wEPVal
= _GetENDPOINT(EPindex
);
129 if ((wEPVal
& EP_CTR_RX
) != 0)
132 _ClearEP_CTR_RX(EPindex
);
134 /* call OUT service function */
135 (*pEpInt_OUT
[EPindex
-1])();
137 } /* if((wEPVal & EP_CTR_RX) */
139 if ((wEPVal
& EP_CTR_TX
) != 0)
142 _ClearEP_CTR_TX(EPindex
);
144 /* call IN service function */
145 (*pEpInt_IN
[EPindex
-1])();
146 } /* if((wEPVal & EP_CTR_TX) != 0) */
148 }/* if(EPindex == 0) else */
153 /*******************************************************************************
154 * Function Name : CTR_HP.
155 * Description : High Priority Endpoint Correct Transfer interrupt's service
160 *******************************************************************************/
165 while (((wIstr
= _GetISTR()) & ISTR_CTR
) != 0)
167 _SetISTR((uint16_t)CLR_CTR
); /* clear CTR flag */
168 /* extract highest priority endpoint number */
169 EPindex
= (uint8_t)(wIstr
& ISTR_EP_ID
);
170 /* process related endpoint register */
171 wEPVal
= _GetENDPOINT(EPindex
);
172 if ((wEPVal
& EP_CTR_RX
) != 0)
175 _ClearEP_CTR_RX(EPindex
);
177 /* call OUT service function */
178 (*pEpInt_OUT
[EPindex
-1])();
180 } /* if((wEPVal & EP_CTR_RX) */
181 else if ((wEPVal
& EP_CTR_TX
) != 0)
184 _ClearEP_CTR_TX(EPindex
);
186 /* call IN service function */
187 (*pEpInt_IN
[EPindex
-1])();
190 } /* if((wEPVal & EP_CTR_TX) != 0) */
195 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/