1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
21
22
23
24
37
40
41
42
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
98
107
116
123
125
126
127
128
129
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
175
/* ... */
#include "main.h"
Includes
MSC_DEMO_StateMachine msc_demo;
uint8_t prev_select = 0;
uint8_t *MSC_main_menu[] = {
(uint8_t *)
" 1 - File Operations ",
(uint8_t *)
" 2 - Explorer Disk ",
(uint8_t *)
" 3 - Re-Enumerate ",
...};
Private variables
static void MSC_SelectItem(uint8_t ** menu, uint8_t item);
Private function prototypes
/* ... */
void MSC_MenuProcess(void)
{
switch (msc_demo.state)
{
case MSC_DEMO_IDLE:
BSP_LCD_SetTextColor(LCD_COLOR_GREEN);
BSP_LCD_DisplayStringAtLine(16,
(uint8_t *)
" ");
BSP_LCD_DisplayStringAtLine(17,
(uint8_t *)
"Use [Buttons Left/Right] to scroll up/down ");
BSP_LCD_DisplayStringAtLine(18,
(uint8_t *)
"Use [Joystick Up/Down] to scroll MSC menu ");
BSP_LCD_SetTextColor(LCD_COLOR_WHITE);
MSC_SelectItem(MSC_main_menu, 0);
msc_demo.state = MSC_DEMO_WAIT;
msc_demo.select = 0;
break;
case MSC_DEMO_IDLE:
case MSC_DEMO_WAIT:
if (msc_demo.select != prev_select)
{
prev_select = msc_demo.select;
MSC_SelectItem(MSC_main_menu, msc_demo.select & 0x7F);
if (msc_demo.select & 0x80)
{
switch (msc_demo.select & 0x7F)
{
case 0:
msc_demo.state = MSC_DEMO_FILE_OPERATIONS;
break;
case 0:
case 1:
msc_demo.state = MSC_DEMO_EXPLORER;
break;
case 1:
case 2:
msc_demo.state = MSC_REENUMERATE;
break;
case 2:
default:
break;default
}switch (msc_demo.select & 0x7F) { ... }
}if (msc_demo.select & 0x80) { ... }
}if (msc_demo.select != prev_select) { ... }
break;
case MSC_DEMO_WAIT:
case MSC_DEMO_FILE_OPERATIONS:
if (Appli_state == APPLICATION_MSC)
{
MSC_File_Operations();
}if (Appli_state == APPLICATION_MSC) { ... }
msc_demo.state = MSC_DEMO_WAIT;
break;
case MSC_DEMO_FILE_OPERATIONS:
case MSC_DEMO_EXPLORER:
if (Appli_state == APPLICATION_MSC)
{
Explore_Disk("0:/", 1);
}if (Appli_state == APPLICATION_MSC) { ... }
msc_demo.state = MSC_DEMO_WAIT;
break;
case MSC_DEMO_EXPLORER:
case MSC_REENUMERATE:
USBH_ReEnumerate(&hUSBHost);
msc_demo.state = MSC_DEMO_WAIT;
break;
case MSC_REENUMERATE:
default:
break;default
}switch (msc_demo.state) { ... }
msc_demo.select &= 0x7F;
}{ ... }
/* ... */
static void MSC_SelectItem(uint8_t ** menu, uint8_t item)
{
BSP_LCD_SetTextColor(LCD_COLOR_WHITE);
switch (item)
{
case 0:
BSP_LCD_SetBackColor(LCD_COLOR_MAGENTA);
BSP_LCD_DisplayStringAtLine(19, menu[0]);
BSP_LCD_SetBackColor(LCD_COLOR_BLUE);
BSP_LCD_DisplayStringAtLine(20, menu[1]);
BSP_LCD_DisplayStringAtLine(21, menu[2]);
break;
case 0:
case 1:
BSP_LCD_SetBackColor(LCD_COLOR_BLUE);
BSP_LCD_DisplayStringAtLine(19, menu[0]);
BSP_LCD_SetBackColor(LCD_COLOR_MAGENTA);
BSP_LCD_DisplayStringAtLine(20, menu[1]);
BSP_LCD_SetBackColor(LCD_COLOR_BLUE);
BSP_LCD_DisplayStringAtLine(21, menu[2]);
break;
case 1:
case 2:
BSP_LCD_SetBackColor(LCD_COLOR_BLUE);
BSP_LCD_DisplayStringAtLine(19, menu[0]);
BSP_LCD_SetBackColor(LCD_COLOR_BLUE);
BSP_LCD_DisplayStringAtLine(20, menu[1]);
BSP_LCD_SetBackColor(LCD_COLOR_MAGENTA);
BSP_LCD_DisplayStringAtLine(21, menu[2]);
break;case 2:
}switch (item) { ... }
BSP_LCD_SetBackColor(LCD_COLOR_BLACK);
}{ ... }
/* ... */
void MSC_DEMO_ProbeKey(JOYState_TypeDef state)
{
if ((state == JOY_UP) && (msc_demo.select > 0))
{
msc_demo.select--;
}if ((state == JOY_UP) && (msc_demo.select > 0)) { ... }
else if ((state == JOY_DOWN) && (msc_demo.select < 2))
{
msc_demo.select++;
}else if ((state == JOY_DOWN) && (msc_demo.select < 2)) { ... }
else if (state == JOY_SEL)
{
msc_demo.select |= 0x80;
}else if (state == JOY_SEL) { ... }
}{ ... }