Skip to content

Commit a6787ed

Browse files
committed
stmhal: Tidy up USB device configuration. Make it use less RAM.
1 parent c2a4cb4 commit a6787ed

File tree

7 files changed

+25
-445
lines changed

7 files changed

+25
-445
lines changed

stmhal/stm32f4xx_hal_msp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747

4848
/* Includes ------------------------------------------------------------------*/
4949
#include "stm32f4xx_hal.h"
50-
#include "usbd_cdc.h"
50+
#include "usbd_cdc_msc.h"
5151
#include "usbd_cdc_interface.h"
5252

5353
/** @addtogroup STM32F4xx_HAL_Driver

stmhal/usbd_cdc_interface.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,22 @@
2828
/* Includes ------------------------------------------------------------------*/
2929
#include <stdbool.h>
3030
#include "stm32f4xx_hal.h"
31-
#include "usbd_cdc.h"
31+
#include "usbd_cdc_msc.h"
3232
#include "usbd_cdc_interface.h"
3333
#include "pendsv.h"
3434
#include "usb.h"
3535

36+
// CDC control commands
37+
#define CDC_SEND_ENCAPSULATED_COMMAND 0x00
38+
#define CDC_GET_ENCAPSULATED_RESPONSE 0x01
39+
#define CDC_SET_COMM_FEATURE 0x02
40+
#define CDC_GET_COMM_FEATURE 0x03
41+
#define CDC_CLEAR_COMM_FEATURE 0x04
42+
#define CDC_SET_LINE_CODING 0x20
43+
#define CDC_GET_LINE_CODING 0x21
44+
#define CDC_SET_CONTROL_LINE_STATE 0x22
45+
#define CDC_SEND_BREAK 0x23
46+
3647
/* Private typedef -----------------------------------------------------------*/
3748
/* Private define ------------------------------------------------------------*/
3849
#define APP_RX_DATA_SIZE 1024 // I think this must be at least CDC_DATA_FS_OUT_PACKET_SIZE (was 2048)

stmhal/usbd_conf.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
#include <string.h>
3737

3838
#include "mpconfig.h"
39-
#include "gc.h" // for gc_alloc and gc_free
4039

4140
/* Exported types ------------------------------------------------------------*/
4241
/* Exported constants --------------------------------------------------------*/
@@ -47,17 +46,18 @@
4746
#define USBD_SUPPORT_USER_STRING 0
4847
#define USBD_SELF_POWERED 0
4948
#define USBD_DEBUG_LEVEL 0
50-
51-
// for MSC device
52-
#define MSC_MEDIA_PACKET 8192
5349

5450
/* Exported macro ------------------------------------------------------------*/
5551
/* Memory management macros */
52+
/*
53+
these should not be used because the GC is reset on a soft reset but the usb is not
54+
#include "gc.h"
5655
#define USBD_malloc gc_alloc
5756
#define USBD_free gc_free
5857
#define USBD_memset memset
5958
#define USBD_memcpy memcpy
60-
59+
*/
60+
6161
/* DEBUG macros */
6262
#if (USBD_DEBUG_LEVEL > 0)
6363
#define USBD_UsrLog(...) printf(__VA_ARGS__);\

stmhal/usbdev/class/cdc_msc/inc/usbd_cdc_msc.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@
55
#include "usbd_msc_scsi.h"
66
#include "usbd_ioreq.h"
77

8-
// CDC endpoint parameters
9-
#define CDC_DATA_FS_MAX_PACKET_SIZE 64 // Endpoint IN & OUT Packet size
10-
#define CDC_CMD_PACKET_SIZE 8 // Control Endpoint Packet size
11-
#define CDC_DATA_FS_IN_PACKET_SIZE CDC_DATA_FS_MAX_PACKET_SIZE
12-
#define CDC_DATA_FS_OUT_PACKET_SIZE CDC_DATA_FS_MAX_PACKET_SIZE
8+
// CDC and MSC packet sizes
9+
#define CDC_DATA_FS_MAX_PACKET_SIZE (64) // endpoint IN & OUT packet size
10+
#define MSC_MEDIA_PACKET (2048) // was 8192; how low can it go whilst still working?
1311

1412
#if 0
1513
// CDC
@@ -34,7 +32,7 @@
3432
#define MSC_IFACE_NUM (0)
3533
#define MSC_IN_EP (0x81)
3634
#define MSC_OUT_EP (0x01)
37-
#elif 0
35+
#elif 1
3836
// CDC + MSC
3937
#define USB_CDC_MSC_CONFIG_DESC_SIZ (98)
4038
#define NUM_INTERFACES (3)

stmhal/usbdev/class/cdc_msc/src/usbd_cdc_msc.c

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,9 @@
33

44
#define USB_DESC_TYPE_ASSOCIATION (0x0b)
55

6-
/* currently unused
7-
#define CDC_SEND_ENCAPSULATED_COMMAND 0x00
8-
#define CDC_GET_ENCAPSULATED_RESPONSE 0x01
9-
#define CDC_SET_COMM_FEATURE 0x02
10-
#define CDC_GET_COMM_FEATURE 0x03
11-
#define CDC_CLEAR_COMM_FEATURE 0x04
12-
#define CDC_SET_LINE_CODING 0x20
13-
#define CDC_GET_LINE_CODING 0x21
14-
#define CDC_SET_CONTROL_LINE_STATE 0x22
15-
#define CDC_SEND_BREAK 0x23
16-
*/
6+
#define CDC_CMD_PACKET_SIZE 8 // Control Endpoint Packet size
7+
#define CDC_DATA_FS_IN_PACKET_SIZE CDC_DATA_FS_MAX_PACKET_SIZE
8+
#define CDC_DATA_FS_OUT_PACKET_SIZE CDC_DATA_FS_MAX_PACKET_SIZE
179

1810
#define BOT_GET_MAX_LUN 0xFE
1911
#define BOT_RESET 0xFF

stmhal/usbdev/core/inc/usbd_conf_template.h

Lines changed: 0 additions & 163 deletions
This file was deleted.

0 commit comments

Comments
 (0)