1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
21
22
23
24
27
28
29
30
35
40
41
46
47
48
49
50
51
52
53
54
55
56
57
60
61
62
63
64
65
66
67
68
69
77
84
86
87
88
89
90
91
92
93
94
95
96
97
98
/* ... */
#include "main.h"
Includes
CDC_DEMO_StateMachine CdcDemo;
Private variables
/* ... */
void Menu_Init(void)
{
USBH_UsrLog("Starting CDC Demo");
CdcDemo.state = CDC_DEMO_WAIT;
}{ ... }
/* ... */
void CDC_MenuProcess(void)
{
switch(CdcDemo.state)
{
case CDC_DEMO_WAIT:
if(Appli_state == APPLICATION_READY)
{
BSP_LCD_SetTextColor(LCD_COLOR_GREEN);
BSP_LCD_DisplayStringAtLine(19, (uint8_t *)"Press User button to start sending data ");
while((BSP_PB_GetState(BUTTON_WAKEUP) != SET) && (Appli_state != APPLICATION_DISCONNECT))
{
}while ((BSP_PB_GetState(BUTTON_WAKEUP) != SET) && (Appli_state != APPLICATION_DISCONNECT)) { ... }
CdcDemo.state = CDC_DEMO_SEND;
HAL_Delay(400);
BSP_LCD_ClearStringLine(19);
}if (Appli_state == APPLICATION_READY) { ... }
break;
case CDC_DEMO_WAIT:
case CDC_DEMO_SEND:
if(Appli_state == APPLICATION_READY)
{
CDC_Handle_Send_Menu();
}if (Appli_state == APPLICATION_READY) { ... }
break;
case CDC_DEMO_SEND:
case CDC_DEMO_RECEIVE:
if(Appli_state == APPLICATION_READY)
{
CDC_Handle_Receive_Menu();
}if (Appli_state == APPLICATION_READY) { ... }
break;
case CDC_DEMO_RECEIVE:
default:
break;default
}switch (CdcDemo.state) { ... }
if(Appli_state == APPLICATION_DISCONNECT)
{
Appli_state = APPLICATION_IDLE;
LCD_LOG_ClearTextZone();
LCD_ErrLog("CDC device disconnected!\n");
CdcDemo.state = CDC_DEMO_WAIT;
CdcDemo.Receive_state = CDC_RECEIVE_IDLE;
CdcDemo.Send_state = CDC_SEND_IDLE;
CdcDemo.select = 0;
}if (Appli_state == APPLICATION_DISCONNECT) { ... }
}{ ... }