dRonin  adbada4
dRonin firmware
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
pios_usb_hid_istr.c
Go to the documentation of this file.
1 /******************** (C) COPYRIGHT 2010 STMicroelectronics ********************
2 * File Name : usb_istr.c
3 * Author : MCD Application Team
4 * Version : V3.2.1
5 * Date : 07/05/2010
6 * Description : ISTR events interrupt service routines
7 ********************************************************************************
8 * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
9 * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
10 * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
11 * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
12 * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
13 * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
14 *******************************************************************************/
15 
16 /* Includes ------------------------------------------------------------------*/
17 #include "usb_lib.h"
18 #include "pios.h"
19 #include "pios_usb_hid_pwr.h"
20 #include "pios_usb_hid_istr.h"
21 #include "pios_usb_hid.h"
22 
23 /* Private typedef -----------------------------------------------------------*/
24 /* Private define ------------------------------------------------------------*/
25 /* Private macro -------------------------------------------------------------*/
26 /* Private variables ---------------------------------------------------------*/
27 __IO uint16_t wIstr; /* ISTR register last read value */
28 __IO uint8_t bIntPackSOF = 0; /* SOFs received between 2 consecutive packets */
29 
30 /* Extern variables ----------------------------------------------------------*/
31 /* Private function prototypes -----------------------------------------------*/
32 /* Private functions ---------------------------------------------------------*/
33 /* function pointers to non-control endpoints service routines */
34 void (*pEpInt_IN[7]) (void) = {
36 
37 void (*pEpInt_OUT[7]) (void) = {
39 
40 #ifndef STM32F10X_CL
41 
42 /*******************************************************************************
43 * Function Name : USB_Istr
44 * Description : STR events interrupt service routine
45 * Input :
46 * Output :
47 * Return :
48 *******************************************************************************/
49 void USB_LP_CAN1_RX0_IRQHandler(void) //USB_Istr(void)
50 {
52  wIstr = _GetISTR();
53 
54 #if (IMR_MSK & ISTR_CTR)
55  if (wIstr & ISTR_CTR & wInterrupt_Mask) {
56  /* servicing of the endpoint correct transfer interrupt */
57  /* clear of the CTR flag into the sub */
58  CTR_LP();
59 #ifdef CTR_CALLBACK
60  CTR_Callback();
61 #endif
62  }
63 #endif
64  /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
65 #if (IMR_MSK & ISTR_RESET)
66  if (wIstr & ISTR_RESET & wInterrupt_Mask) {
67  _SetISTR((uint16_t) CLR_RESET);
68  Device_Property.Reset();
69 #ifdef RESET_CALLBACK
70  RESET_Callback();
71 #endif
72  }
73 #endif
74  /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
75 #if (IMR_MSK & ISTR_DOVR)
76  if (wIstr & ISTR_DOVR & wInterrupt_Mask) {
77  _SetISTR((uint16_t) CLR_DOVR);
78 #ifdef DOVR_CALLBACK
79  DOVR_Callback();
80 #endif
81  }
82 #endif
83  /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
84 #if (IMR_MSK & ISTR_ERR)
85  if (wIstr & ISTR_ERR & wInterrupt_Mask) {
86  _SetISTR((uint16_t) CLR_ERR);
87 #ifdef ERR_CALLBACK
88  ERR_Callback();
89 #endif
90  }
91 #endif
92  /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
93 #if (IMR_MSK & ISTR_WKUP)
94  if (wIstr & ISTR_WKUP & wInterrupt_Mask) {
95  _SetISTR((uint16_t) CLR_WKUP);
97 #ifdef WKUP_CALLBACK
98  WKUP_Callback();
99 #endif
100  }
101 #endif
102  /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
103 #if (IMR_MSK & ISTR_SUSP)
104  if (wIstr & ISTR_SUSP & wInterrupt_Mask) {
105 
106  /* check if SUSPEND is possible */
107  if (fSuspendEnabled) {
108  Suspend();
109  } else {
110  /* if not possible then resume after xx ms */
112  }
113  /* clear of the ISTR bit must be done after setting of CNTR_FSUSP */
114  _SetISTR((uint16_t) CLR_SUSP);
115 #ifdef SUSP_CALLBACK
116  SUSP_Callback();
117 #endif
118  }
119 #endif
120  /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
121 #if (IMR_MSK & ISTR_SOF)
122  if (wIstr & ISTR_SOF & wInterrupt_Mask) {
123  _SetISTR((uint16_t) CLR_SOF);
124  bIntPackSOF++;
125 
126 #ifdef SOF_CALLBACK
127  SOF_Callback();
128 #endif
129  }
130 #endif
131  /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
132 #if (IMR_MSK & ISTR_ESOF)
133  if (wIstr & ISTR_ESOF & wInterrupt_Mask) {
134  _SetISTR((uint16_t) CLR_ESOF);
135  /* resume handling timing is made with ESOFs */
136  Resume(RESUME_ESOF); /* request without change of the machine state */
137 
138 #ifdef ESOF_CALLBACK
139  ESOF_Callback();
140 #endif
141  }
142 #endif
144 } /* USB_Istr */
145 
146 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
147 #else /* STM32F10X_CL */
148 
149 /*******************************************************************************
150 * Function Name : STM32_PCD_OTG_ISR_Handler
151 * Description : Handles all USB Device Interrupts
152 * Input : None
153 * Output : None
154 * Return : status
155 *******************************************************************************/
156 u32 STM32_PCD_OTG_ISR_Handler(void)
157 {
158  USB_OTG_GINTSTS_TypeDef gintr_status;
159  u32 retval = 0;
160 
161  if (USBD_FS_IsDeviceMode()) { /* ensure that we are in device mode */
162  gintr_status.d32 = OTGD_FS_ReadCoreItr();
163 
164  /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
165 
166  /* If there is no interrupt pending exit the interrupt routine */
167  if (!gintr_status.d32) {
168  return 0;
169  }
170 
171  /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
172  /* Early Suspend interrupt */
173 #ifdef INTR_ERLYSUSPEND
174  if (gintr_status.b.erlysuspend) {
175  retval |= OTGD_FS_Handle_EarlySuspend_ISR();
176  }
177 #endif /* INTR_ERLYSUSPEND */
178 
179  /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
180  /* End of Periodic Frame interrupt */
181 #ifdef INTR_EOPFRAME
182  if (gintr_status.b.eopframe) {
183  retval |= OTGD_FS_Handle_EOPF_ISR();
184  }
185 #endif /* INTR_EOPFRAME */
186 
187  /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
188  /* Non Periodic Tx FIFO Emty interrupt */
189 #ifdef INTR_NPTXFEMPTY
190  if (gintr_status.b.nptxfempty) {
191  retval |= OTGD_FS_Handle_NPTxFE_ISR();
192  }
193 #endif /* INTR_NPTXFEMPTY */
194 
195  /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
196  /* Wakeup or RemoteWakeup interrupt */
197 #ifdef INTR_WKUPINTR
198  if (gintr_status.b.wkupintr) {
199  retval |= OTGD_FS_Handle_Wakeup_ISR();
200  }
201 #endif /* INTR_WKUPINTR */
202 
203  /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
204  /* Suspend interrupt */
205 #ifdef INTR_USBSUSPEND
206  if (gintr_status.b.usbsuspend) {
207  /* check if SUSPEND is possible */
208  if (fSuspendEnabled) {
209  Suspend();
210  } else {
211  /* if not possible then resume after xx ms */
212  Resume(RESUME_LATER); /* This case shouldn't happen in OTG Device mode because
213  there's no ESOF interrupt to increment the ResumeS.bESOFcnt in the Resume state machine */
214  }
215 
216  retval |= OTGD_FS_Handle_USBSuspend_ISR();
217  }
218 #endif /* INTR_USBSUSPEND */
219 
220  /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
221  /* Start of Frame interrupt */
222 #ifdef INTR_SOFINTR
223  if (gintr_status.b.sofintr) {
224  /* Update the frame number variable */
225  bIntPackSOF++;
226 
227  retval |= OTGD_FS_Handle_Sof_ISR();
228  }
229 #endif /* INTR_SOFINTR */
230 
231  /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
232  /* Receive FIFO Queue Status Level interrupt */
233 #ifdef INTR_RXSTSQLVL
234  if (gintr_status.b.rxstsqlvl) {
235  retval |= OTGD_FS_Handle_RxStatusQueueLevel_ISR();
236  }
237 #endif /* INTR_RXSTSQLVL */
238 
239  /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
240  /* Enumeration Done interrupt */
241 #ifdef INTR_ENUMDONE
242  if (gintr_status.b.enumdone) {
243  retval |= OTGD_FS_Handle_EnumDone_ISR();
244  }
245 #endif /* INTR_ENUMDONE */
246 
247  /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
248  /* Reset interrutp */
249 #ifdef INTR_USBRESET
250  if (gintr_status.b.usbreset) {
251  retval |= OTGD_FS_Handle_UsbReset_ISR();
252  }
253 #endif /* INTR_USBRESET */
254 
255  /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
256  /* IN Endpoint interrupt */
257 #ifdef INTR_INEPINTR
258  if (gintr_status.b.inepint) {
259  retval |= OTGD_FS_Handle_InEP_ISR();
260  }
261 #endif /* INTR_INEPINTR */
262 
263  /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
264  /* OUT Endpoint interrupt */
265 #ifdef INTR_OUTEPINTR
266  if (gintr_status.b.outepintr) {
267  retval |= OTGD_FS_Handle_OutEP_ISR();
268  }
269 #endif /* INTR_OUTEPINTR */
270 
271  /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
272  /* Mode Mismatch interrupt */
273 #ifdef INTR_MODEMISMATCH
274  if (gintr_status.b.modemismatch) {
275  retval |= OTGD_FS_Handle_ModeMismatch_ISR();
276  }
277 #endif /* INTR_MODEMISMATCH */
278 
279  /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
280  /* Global IN Endpoints NAK Effective interrupt */
281 #ifdef INTR_GINNAKEFF
282  if (gintr_status.b.ginnakeff) {
283  retval |= OTGD_FS_Handle_GInNakEff_ISR();
284  }
285 #endif /* INTR_GINNAKEFF */
286 
287  /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
288  /* Global OUT Endpoints NAK effective interrupt */
289 #ifdef INTR_GOUTNAKEFF
290  if (gintr_status.b.goutnakeff) {
291  retval |= OTGD_FS_Handle_GOutNakEff_ISR();
292  }
293 #endif /* INTR_GOUTNAKEFF */
294 
295  /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
296  /* Isochrounous Out packet Dropped interrupt */
297 #ifdef INTR_ISOOUTDROP
298  if (gintr_status.b.isooutdrop) {
299  retval |= OTGD_FS_Handle_IsoOutDrop_ISR();
300  }
301 #endif /* INTR_ISOOUTDROP */
302 
303  /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
304  /* Endpoint Mismatch error interrupt */
305 #ifdef INTR_EPMISMATCH
306  if (gintr_status.b.epmismatch) {
307  retval |= OTGD_FS_Handle_EPMismatch_ISR();
308  }
309 #endif /* INTR_EPMISMATCH */
310 
311  /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
312  /* Incomplete Isochrous IN tranfer error interrupt */
313 #ifdef INTR_INCOMPLISOIN
314  if (gintr_status.b.incomplisoin) {
315  retval |= OTGD_FS_Handle_IncomplIsoIn_ISR();
316  }
317 #endif /* INTR_INCOMPLISOIN */
318 
319  /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
320  /* Incomplete Isochrous OUT tranfer error interrupt */
321 #ifdef INTR_INCOMPLISOOUT
322  if (gintr_status.b.outepintr) {
323  retval |= OTGD_FS_Handle_IncomplIsoOut_ISR();
324  }
325 #endif /* INTR_INCOMPLISOOUT */
326 
327  }
328  return retval;
329 }
330 
331 #endif /* STM32F10X_CL */
332 
333 /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
void EP3_IN_Callback(void)
void(* pEpInt_IN[7])(void)
void EP2_OUT_Callback(void)
void EP2_IN_Callback(void)
void EP7_OUT_Callback(void)
Main PiOS header to include all the compiled in PiOS options.
void Resume(RESUME_STATE eResumeSetVal)
void EP5_OUT_Callback(void)
#define PIOS_IRQ_Epilogue()
Definition: pios_irq.h:46
USB HID layer functions header.
__IO bool fSuspendEnabled
void EP1_IN_Callback(void)
void Suspend(void)
void EP4_OUT_Callback(void)
__IO uint8_t bIntPackSOF
void EP6_IN_Callback(void)
__IO uint16_t wIstr
void EP5_IN_Callback(void)
void EP1_OUT_Callback(void)
DEVICE_PROP Device_Property
Definition: pios_usbhook.c:116
void EP4_IN_Callback(void)
void USB_LP_CAN1_RX0_IRQHandler(void)
#define PIOS_IRQ_Prologue()
Definition: pios_irq.h:45
void EP3_OUT_Callback(void)
void EP7_IN_Callback(void)
void EP6_OUT_Callback(void)
void(* pEpInt_OUT[7])(void)