1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
21
22
23
24
28
29
30
31
36
42
43
48
80
81
86
87
88
89
90
91
92
93
94
95
96
97
98
99
103
107
118
131
132
133
134
135
136
137
138
142
146
147
148
152
156
157
158
/* ... */
#include "main.h"
Includes
extern char SD_Path[4];
char USBDISKPath[4];
Private variables
/* ... */
void Menu_Init(void)
{
msc_demo.state = MSC_DEMO_IDLE;
hid_demo.state = HID_DEMO_IDLE;
audio_demo.state = AUDIO_DEMO_IDLE;
}{ ... }
/* ... */
void DS_MenuProcess(void)
{
switch (Appli_state)
{
case APPLICATION_IDLE:
break;
case APPLICATION_IDLE:
case APPLICATION_MSC:
MSC_MenuProcess();
break;
case APPLICATION_MSC:
case APPLICATION_AUDIO:
AUDIO_MenuProcess();
break;
case APPLICATION_AUDIO:
case APPLICATION_HID:
HID_MenuProcess();
break;
case APPLICATION_HID:
default:
break;default
}switch (Appli_state) { ... }
if (Appli_state == APPLICATION_DISCONNECT)
{
Appli_state = APPLICATION_IDLE;
Menu_Init();
FATFS_UnLinkDriver(SD_Path);
FATFS_UnLinkDriver(USBDISKPath);
}if (Appli_state == APPLICATION_DISCONNECT) { ... }
}{ ... }
/* ... */
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
{
static JOYState_TypeDef JoyState = JOY_NONE;
static uint32_t debounce_time = 0;
if (GPIO_Pin == GPIO_PIN_8)
{
JoyState = BSP_JOY_GetState();
BSP_IO_ITClear();
if (Appli_state == APPLICATION_MSC)
{
MSC_DEMO_ProbeKey(JoyState);
}if (Appli_state == APPLICATION_MSC) { ... }
else if (Appli_state == APPLICATION_HID)
{
HID_DEMO_ProbeKey(JoyState);
}else if (Appli_state == APPLICATION_HID) { ... }
else if (Appli_state == APPLICATION_AUDIO)
{
if (audio_select_mode == AUDIO_SELECT_MENU)
{
AUDIO_MenuProbeKey(JoyState);
}if (audio_select_mode == AUDIO_SELECT_MENU) { ... }
else if (audio_select_mode == AUDIO_PLAYBACK_CONTROL)
{
AUDIO_PlaybackProbeKey(JoyState);
}else if (audio_select_mode == AUDIO_PLAYBACK_CONTROL) { ... }
}else if (Appli_state == APPLICATION_AUDIO) { ... }
switch (JoyState)
{
case JOY_LEFT:
LCD_LOG_ScrollBack();
break;
case JOY_LEFT:
case JOY_RIGHT:
LCD_LOG_ScrollForward();
break;
case JOY_RIGHT:
default:
break;default
}switch (JoyState) { ... }
}if (GPIO_Pin == GPIO_PIN_8) { ... }
if (audio_demo.state == AUDIO_DEMO_PLAYBACK)
{
if (GPIO_Pin == KEY_BUTTON_PIN)
{
if ((HAL_GetTick() - debounce_time) > 50)
{
debounce_time = HAL_GetTick();
}if ((HAL_GetTick() - debounce_time) > 50) { ... }
else
{
return;
}else { ... }
if (audio_select_mode == AUDIO_SELECT_MENU)
{
Audio_ChangeSelectMode(AUDIO_PLAYBACK_CONTROL);
}if (audio_select_mode == AUDIO_SELECT_MENU) { ... }
else if (audio_select_mode == AUDIO_PLAYBACK_CONTROL)
{
Audio_ChangeSelectMode(AUDIO_SELECT_MENU);
}else if (audio_select_mode == AUDIO_PLAYBACK_CONTROL) { ... }
}if (GPIO_Pin == KEY_BUTTON_PIN) { ... }
}if (audio_demo.state == AUDIO_DEMO_PLAYBACK) { ... }
}{ ... }