1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
24
25
28
29
35
36
37
38
39
40
41
42
43
48
51
52
57
64
65
70
77
78
83
90
91
96
103
104
109
112
113
118
121
122
127
130
131
136
137
138
139
140
141
142
143
144
145
146
147
151
152
153
154
155
160
161
162
167
168
169
170
171
172
175
176
181
182
183
184
185
186
187
188
189
190
191
192
194
195
196
197
198
199
200
202
203
205
206
207
208
209
214
218
219
220
225
226
227
228
229
230
231
232
233
237
241
245
249
251
252
253
254
255
256
257
/* ... */
#include "stm32f4xx_it.h"
Includes
#define CURSOR_STEP 5
Private define
uint8_t HID_Buffer[4];
extern PCD_HandleTypeDef hpcd;
extern USBD_HandleTypeDef USBD_Device;
extern __IO uint8_t JoyButtonInitialized;
Private variables
static void GetPointerData(uint8_t *pbuf);
/* ... */
void NMI_Handler(void)
{
}{ ... }
/* ... */
void HardFault_Handler(void)
{
while (1)
{
}while (1) { ... }
}{ ... }
/* ... */
void MemManage_Handler(void)
{
while (1)
{
}while (1) { ... }
}{ ... }
/* ... */
void BusFault_Handler(void)
{
while (1)
{
}while (1) { ... }
}{ ... }
/* ... */
void UsageFault_Handler(void)
{
while (1)
{
}while (1) { ... }
}{ ... }
/* ... */
void SVC_Handler(void)
{
}{ ... }
/* ... */
void DebugMon_Handler(void)
{
}{ ... }
/* ... */
void PendSV_Handler(void)
{
}{ ... }
/* ... */
void SysTick_Handler(void)
{
static __IO uint32_t counter=0;
HAL_IncTick();
if (counter++ == USBD_HID_GetPollingInterval(&USBD_Device))
{
GetPointerData(HID_Buffer);
if((HID_Buffer[1] != 0) || (HID_Buffer[2] != 0))
{
USBD_HID_SendReport(&USBD_Device, HID_Buffer, 4);
}if ((HID_Buffer[1] != 0) || (HID_Buffer[2] != 0)) { ... }
counter =0;
}if (counter++ == USBD_HID_GetPollingInterval(&USBD_Device)) { ... }
}{ ... }
...
...
/* ... */
#ifdef USE_USB_FS
void OTG_FS_IRQHandler(void)
#else
void OTG_HS_IRQHandler(void)
#endif
{
HAL_PCD_IRQHandler(&hpcd);
...}
/* ... */
#ifdef USE_USB_FS
void OTG_FS_WKUP_IRQHandler(void)
#else
void OTG_HS_WKUP_IRQHandler(void)
#endif
{
if((&hpcd)->Init.low_power_enable)
{
SCB->SCR &= (uint32_t)~((uint32_t)(SCB_SCR_SLEEPDEEP_Msk | SCB_SCR_SLEEPONEXIT_Msk));
/* ... */
SystemClock_Config();
__HAL_PCD_UNGATE_PHYCLOCK((&hpcd));
}if ((&hpcd)->Init.low_power_enable) { ... }
#ifdef USE_USB_FS
__HAL_USB_OTG_FS_WAKEUP_EXTI_CLEAR_FLAG();/* ... */
#else
__HAL_USB_OTG_HS_WAKEUP_EXTI_CLEAR_FLAG();/* ... */
#endif
...}
/* ... */
void EXTI15_10_IRQHandler(void)
{
HAL_GPIO_EXTI_IRQHandler(KEY_BUTTON_PIN);
}{ ... }
/* ... */
static void GetPointerData(uint8_t *pbuf)
{
int8_t x = 0, y = 0 ;
if(JoyButtonInitialized == 1)
{
switch(BSP_JOY_GetState())
{
case JOY_LEFT:
x -= CURSOR_STEP;
break;
case JOY_LEFT:
case JOY_RIGHT:
x += CURSOR_STEP;
break;
case JOY_RIGHT:
case JOY_UP:
y -= CURSOR_STEP;
break;
case JOY_UP:
case JOY_DOWN:
y += CURSOR_STEP;
break;
case JOY_DOWN:
default:
break;default
}switch (BSP_JOY_GetState()) { ... }
}if (JoyButtonInitialized == 1) { ... }
pbuf[0] = 0;
pbuf[1] = x;
pbuf[2] = y;
pbuf[3] = 0;
}{ ... }