1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
21
25
26
27
31
32
33
34
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
64
65
66
67
68
69
70
71
73
74
75
76
81
/* ... */
#include "main.h"
Includes
#define TX_BUFF_SIZE (64 * 1024)
Private define
uint8_t CDC_TX_Buffer[TX_BUFF_SIZE];
__IO uint8_t CDC_SendState = 0;
Private variables
/* ... */
void CDC_Handle_Send_Menu(void)
{
switch(CdcDemo.Send_state)
{
case CDC_SEND_IDLE:
CdcDemo.Send_state = CDC_SEND_WAIT;
CDC_SendState = 0;
USBH_CDC_Stop(&hUSBHost);
memset(CDC_TX_Buffer, 0x5A, TX_BUFF_SIZE);
LCD_LOG_ClearTextZone();
LCD_DbgLog("Sending data ...\n");
USBH_CDC_Transmit(&hUSBHost, CDC_TX_Buffer, TX_BUFF_SIZE);
break;
case CDC_SEND_IDLE:
case CDC_SEND_WAIT:
if(CDC_SendState == 1)
{
BSP_LCD_ClearStringLine(19);
BSP_LCD_SetTextColor(LCD_COLOR_GREEN);
BSP_LCD_DisplayStringAtLine(19, (uint8_t *)"Press User button to start receiving data ");
while((BSP_PB_GetState(BUTTON_WAKEUP) != SET) && (Appli_state != APPLICATION_DISCONNECT))
{
}while ((BSP_PB_GetState(BUTTON_WAKEUP) != SET) && (Appli_state != APPLICATION_DISCONNECT)) { ... }
HAL_Delay(400);
CdcDemo.state = CDC_DEMO_RECEIVE;
CdcDemo.Send_state = CDC_SEND_IDLE;
...}
break;
case CDC_SEND_WAIT:
default:
break;default
}switch (CdcDemo.Send_state) { ... }
}{ ... }
/* ... */
void USBH_CDC_TransmitCallback(USBH_HandleTypeDef *phost)
{
LCD_DbgLog (">> Data sent\n" );
CDC_SendState = 1;
}{ ... }