Select one of the symbols to view example projects that use it.
 
Outline
Includes
#include "DIALOG.h"
#include "k_module.h"
#include "usbd_res.c"
#include "k_modules_res.h"
#include "k_storage.h"
#include "usbd_app.h"
Private typedef
usb_device
USBDSettingsTypeDef
Private defines
#define ID_FRAMEWIN_INFO
#define ID_USB_NOT_CONNECTED
#define ID_MSD_NOT_CONNECTED
#define ID_BUTTON_USB
#define ID_IMAGE1_CONNECTED
#define ID_IMAGE1_NOT_CONNECTED
#define ID_IMAGE2_CONNECTED
#define ID_IMAGE2_NOT_CONNECTED
Private variables
_aDialog
USBDSettings
_cbMSDConnectionStatus(WM_MESSAGE *)
_cbDialog(WM_MESSAGE *)
Startup(GUI_HWIN, uint16_t, uint16_t)
Files
loading...
CodeScopeSTM32 Libraries and SamplesMB1063Gui/Core/usbdevice/usbd_win.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/** ****************************************************************************** * @file usbd_win.c * @author MCD Application Team * @brief USB Device functions ****************************************************************************** * @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 "DIALOG.h" #include "k_module.h" #include "usbd_res.c" #include "k_modules_res.h" #include "k_storage.h" #include "usbd_app.h" 6 includes /** @addtogroup USB_DEVICE_MODULE * @{ *//* ... */ /** @defgroup USB_DEVICE * @brief usb device routines * @{ *//* ... */ Includes /* External variables --------------------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/ static void Startup(WM_HWIN hWin, uint16_t xpos, uint16_t ypos); /* Private typedef -----------------------------------------------------------*/ K_ModuleItem_Typedef usb_device = { 10, "USB Device", &bmusbdevice, Startup, NULL, ...} ; typedef union { uint32_t d32; struct { uint32_t sd_mounted : 1; uint32_t connection : 1; ...}b; ...} USBDSettingsTypeDef; Private typedef /* Private defines -----------------------------------------------------------*/ #define ID_FRAMEWIN_INFO (GUI_ID_USER + 0x01) #define ID_USB_NOT_CONNECTED (GUI_ID_USER + 0x02) #define ID_MSD_NOT_CONNECTED (GUI_ID_USER + 0x03) #define ID_BUTTON_USB (GUI_ID_USER + 0x04) /* USB and MSD info */ #define ID_IMAGE1_CONNECTED (GUI_ID_USER + 0x12) #define ID_IMAGE1_NOT_CONNECTED (GUI_ID_USER + 0x13) #define ID_IMAGE2_CONNECTED (GUI_ID_USER + 0x14) #define ID_IMAGE2_NOT_CONNECTED (GUI_ID_USER + 0x15) 8 defines Private defines/* Private macros ------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ static const GUI_WIDGET_CREATE_INFO _aDialog[] = { { FRAMEWIN_CreateIndirect, "USB Mass Storage Device [mSD]", ID_FRAMEWIN_INFO, 0, 0, 640, 439, 0, 0x64, 0 }, { IMAGE_CreateIndirect, "Image", ID_USB_NOT_CONNECTED, 170, 59, 100, 100, 0, 0, 0 }, { IMAGE_CreateIndirect, "Image", ID_MSD_NOT_CONNECTED, 365, 59, 100, 100, 0, 0, 0 }, { BUTTON_CreateIndirect, "Connect USB ", ID_BUTTON_USB, 145, 260, 350, 55, 0, 0, 0 }, { IMAGE_CreateIndirect, "", ID_IMAGE1_CONNECTED, 226, 120, 18, 19, 0, 0, 0 }, { IMAGE_CreateIndirect, "", ID_IMAGE2_CONNECTED, 421, 120, 18, 19, 0, 0, 0 }, ...}; USBDSettingsTypeDef USBDSettings; Private variables /* Private functions ---------------------------------------------------------*/ /** * @brief Callback function of the CPU window * @param pMsg: pointer to data structure of type WM_MESSAGE * @retval None *//* ... */ static void _cbMSDConnectionStatus(WM_MESSAGE * pMsg) { static WM_HTIMER hTimerTime; WM_HWIN hItem; static uint8_t msd_connection_Changed = 0; switch (pMsg->MsgId) { case WM_CREATE: /* Create timer */ hTimerTime = WM_CreateTimer(pMsg->hWin, 0, 500, 0); break; case WM_CREATE: case WM_TIMER: if(msd_connection_Changed != k_StorageGetStatus(MSD_DISK_UNIT)) { msd_connection_Changed = k_StorageGetStatus(MSD_DISK_UNIT); if(msd_connection_Changed == 1) { hItem = WM_GetDialogItem(WM_GetParent(pMsg->hWin), ID_IMAGE2_CONNECTED); IMAGE_SetBitmap(hItem, &bmconnected); }if (msd_connection_Changed == 1) { ... } else { hItem = WM_GetDialogItem(WM_GetParent(pMsg->hWin), ID_IMAGE2_CONNECTED); IMAGE_SetBitmap(hItem, &bmnot_connected); }else { ... } }if (msd_connection_Changed != k_StorageGetStatus(MSD_DISK_UNIT)) { ... } WM_RestartTimer(pMsg->Data.v, 500); break; case WM_TIMER: case WM_DELETE: msd_connection_Changed = 0; WM_DeleteTimer(hTimerTime); break; case WM_DELETE: default: WM_DefaultProc(pMsg);default }switch (pMsg->MsgId) { ... } }{ ... } /** * @brief Callback routine of the dialog * @param pMsg: pointer to data structure of type WM_MESSAGE * @retval None *//* ... */ static void _cbDialog(WM_MESSAGE * pMsg) { WM_HWIN hItem; int Id, NCode; switch (pMsg->MsgId) { case WM_INIT_DIALOG: /* Initialization of 'System Information' */ hItem = pMsg->hWin; FRAMEWIN_AddCloseButton(hItem, FRAMEWIN_BUTTON_RIGHT, 0); hItem = WM_GetDialogItem(pMsg->hWin, ID_USB_NOT_CONNECTED); IMAGE_SetBitmap(hItem, &bmUSB_not_connected); hItem = WM_GetDialogItem(pMsg->hWin, ID_MSD_NOT_CONNECTED); IMAGE_SetBitmap(hItem, &bmsdcard_not_connected); USBDSettings.b.connection = DISCONNECTED; WM_CreateWindowAsChild(470, 0, 10, 10, pMsg->hWin, WM_CF_SHOW | WM_CF_HASTRANS, _cbMSDConnectionStatus , 0); break; case WM_INIT_DIALOG: case WM_PAINT: DrawRect3D(120, 20, 400, 320); break; case WM_PAINT: case WM_DELETE: USBDSTOR_Stop(); break; case WM_DELETE: case WM_NOTIFY_PARENT: Id = WM_GetId(pMsg->hWinSrc); /* Id of widget */ NCode = pMsg->Data.v; /* Notification code */ switch(Id) { /* Notifications sent by 'Connect' Button */ case ID_BUTTON_USB: if(NCode == WM_NOTIFICATION_RELEASED) { hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_USB); if(USBDSettings.b.connection == DISCONNECTED) { BUTTON_SetText(hItem, "Disconnect USB"); hItem = WM_GetDialogItem(pMsg->hWin, ID_IMAGE1_CONNECTED); IMAGE_SetBitmap(hItem, &bmconnected); USBDSettings.b.connection = CONNECTED; USBDSTOR_Connect(); }if (USBDSettings.b.connection == DISCONNECTED) { ... } else { BUTTON_SetText(hItem, "Connect USB "); hItem = WM_GetDialogItem(pMsg->hWin, ID_IMAGE1_CONNECTED); IMAGE_SetBitmap(hItem, &bmnot_connected); USBDSettings.b.connection = DISCONNECTED; USBDSTOR_Disconnect(); }else { ... } }if (NCode == WM_NOTIFICATION_RELEASED) { ... } break; case ID_BUTTON_USB: }switch (Id) { ... } break; case WM_NOTIFY_PARENT: default: WM_DefaultProc(pMsg); break;default }switch (pMsg->MsgId) { ... } }{ ... } /** * @brief USB Device window Startup * @param hWin: pointer to the parent handle. * @param xpos: X position * @param ypos: Y position * @retval None *//* ... */ static void Startup(WM_HWIN hWin, uint16_t xpos, uint16_t ypos) { USBDSTOR_Start(); GUI_CreateDialogBox(_aDialog, GUI_COUNTOF(_aDialog), _cbDialog, hWin, xpos, ypos); }{ ... } /** * @} *//* ... */ /** * @} *//* ... */