Select one of the symbols to view example projects that use it.
 
Outline
Includes
#include "main.h"
Private define
#define TX_BUFF_SIZE
Private variables
CDC_TX_Buffer
CDC_SendState
CDC_Handle_Send_Menu()
USBH_CDC_TransmitCallback(USBH_HandleTypeDef *)
Files
loading...
CodeScopeSTM32 Libraries and SamplesCDC_StandaloneSrc/cdc_send.c
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/** ****************************************************************************** * @file USB_Host/CDC_Standalone/Src/cdc_send.c * @author MCD Application Team * @brief CDC Send state machine ****************************************************************************** * @attention * * Copyright (c) 2017 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** *//* ... */ /* Includes ------------------------------------------------------------------*/ #include "main.h" Includes /* Private define ------------------------------------------------------------*/ /* The size of the buffer depends on the user's needs */ #define TX_BUFF_SIZE (64 * 1024) Private define /* Private typedef -----------------------------------------------------------*/ /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ uint8_t CDC_TX_Buffer[TX_BUFF_SIZE]; __IO uint8_t CDC_SendState = 0; Private variables /* Private function prototypes -----------------------------------------------*/ /* Private functions ---------------------------------------------------------*/ /** * @brief Handles CDC Send Menu. * @param None * @retval None *//* ... */ 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) /* Data sent */ { BSP_LCD_ClearStringLine(19); BSP_LCD_SetTextColor(LCD_COLOR_GREEN); BSP_LCD_DisplayStringAtLine(19, (uint8_t *)"Press User button to start receiving data "); /* Wait for User Input */ 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) { ... } }{ ... } /** * @brief CDC data transmit callback. * @param phost: Host handle * @retval None *//* ... */ void USBH_CDC_TransmitCallback(USBH_HandleTypeDef *phost) { LCD_DbgLog (">> Data sent\n" ); CDC_SendState = 1; }{ ... }