make it possible to disable VFS and MSC via makefile

sipo
Ondřej Hruška 6 years ago
parent bcbb66e2e9
commit 8ded459c68
  1. 11
      USB/STM32_USB_Device_Library/Class/MSC_CDC/usbd_msc_cdc.c
  2. 2
      USB/usb_device.c
  3. 6
      USB/usbd_desc.c
  4. 4
      USB/usbd_storage_if.c
  5. 5
      framework/unit_registry.c
  6. 26
      gex.mk
  7. 3
      platform/platform.c
  8. 8
      tasks/task_main.c

@ -164,7 +164,9 @@ static uint8_t USBD_MSC_CDC_Init(struct _USBD_HandleTypeDef *pdev, uint8_t cfgid
{
// this is not correct, but will work if neither returns BUSY (which they don't)
uint8_t ret = 0;
#ifndef DISABLE_MSC
ret |= USBD_MSC_Init(pdev, cfgidx);
#endif
ret |= USBD_CDC_Init(pdev, cfgidx);
return ret;
}
@ -172,7 +174,9 @@ static uint8_t USBD_MSC_CDC_Init(struct _USBD_HandleTypeDef *pdev, uint8_t cfgid
static uint8_t USBD_MSC_CDC_DeInit(struct _USBD_HandleTypeDef *pdev, uint8_t cfgidx)
{
uint8_t ret = 0;
#ifndef DISABLE_MSC
ret |= USBD_MSC_DeInit(pdev, cfgidx);
#endif
ret |= USBD_CDC_DeInit(pdev, cfgidx);
return ret;
}
@ -199,7 +203,9 @@ static uint8_t USBD_MSC_CDC_Setup(struct _USBD_HandleTypeDef *pdev, USBD_SetupRe
}
// class specific, or Interface -> Clear Feature
#ifndef DISABLE_MSC
USBD_MSC_Setup(pdev, req);
#endif
USBD_CDC_Setup(pdev, req);
return USBD_OK;
}
@ -291,6 +297,9 @@ uint8_t *USBD_MSC_CDC_GetFSCfgDesc (uint16_t *length)
// Optionally hide settings (if lock jumper is installed)
bool msc_visible = SystemSettings.editable;
#ifdef DISABLE_MSC
msc_visible = false;
#endif
USBD_MSC_CDC_CfgFSDesc[14] = (uint8_t) (msc_visible ? 0x08 : 0xFF);
return USBD_MSC_CDC_CfgFSDesc;
@ -316,7 +325,7 @@ uint8_t *USBD_MSC_CDC_GetUsrStrDescriptor(struct _USBD_HandleTypeDef *pdev, uin
{
const char *str;
switch (index) {
case 0x04: str = "Settings Virtual Mass Storage"; break;
case 0x04: str = "Settings VFS"; break;
case 0x05: str = "Virtual Comport ACM"; break;
case 0x06: str = "Virtual Comport CDC"; break;
default: str = "No Descriptor";

@ -75,7 +75,9 @@ void MX_USB_DEVICE_Init(void)
USBD_RegisterClass(&hUsbDeviceFS, &USBD_MSC_CDC);
#ifndef DISABLE_MSC
USBD_MSC_RegisterStorage(&hUsbDeviceFS, &USBD_Storage_Interface_fops_FS);
#endif
USBD_CDC_RegisterInterface(&hUsbDeviceFS, &USBD_Interface_fops_FS);
USBD_Start(&hUsbDeviceFS);

@ -72,7 +72,7 @@
/** @defgroup USBD_DESC_Private_Defines
* @{
*/
#define USBD_VID 1155
#define USBD_VID 1155 // TODO choose a VID:PID (eg. via pid.codes - 0x1209)
#define USBD_PID_FS 22314
#define USBD_LANGID_NUM 1033
#define USBD_MANUFACTURER_STRING "MightyPork"
@ -220,7 +220,7 @@ uint8_t * USBD_FS_LangIDStrDescriptor( USBD_SpeedTypeDef speed , uint16_t *leng
*/
uint8_t * USBD_FS_ProductStrDescriptor( USBD_SpeedTypeDef speed , uint16_t *length)
{
USBD_GetString (USBD_PRODUCT_STRING_FS, USBD_StrDesc, length);
USBD_GetString ((uint8_t *) USBD_PRODUCT_STRING_FS, USBD_StrDesc, length);
return USBD_StrDesc;
}
@ -233,7 +233,7 @@ uint8_t * USBD_FS_ProductStrDescriptor( USBD_SpeedTypeDef speed , uint16_t *len
*/
uint8_t * USBD_FS_ManufacturerStrDescriptor( USBD_SpeedTypeDef speed , uint16_t *length)
{
USBD_GetString (USBD_MANUFACTURER_STRING, USBD_StrDesc, length);
USBD_GetString ((uint8_t *) USBD_MANUFACTURER_STRING, USBD_StrDesc, length);
return USBD_StrDesc;
}

@ -47,8 +47,8 @@
*/
/* Includes ------------------------------------------------------------------*/
#include <platform/status_led.h>
#include "platform.h"
#include "platform/status_led.h"
#include "usbd_storage_if.h"
/* USER CODE BEGIN INCLUDE */
#include "vfs/vfs_manager.h"
@ -101,7 +101,7 @@
*/
/* USER CODE BEGIN INQUIRY_DATA_FS */
/* USB Mass storage Standard Inquiry Data */
int8_t STORAGE_Inquirydata_FS[] = {/* 36 */
uint8_t STORAGE_Inquirydata_FS[] = {/* 36 */
/* LUN 0 */
0x00,
0x80,

@ -249,7 +249,10 @@ bool ureg_load_units(PayloadParser *pp)
// TYPE
pp_string(pp, typebuf, 16);
Unit *const pUnit = ureg_instantiate(typebuf);
assert_param(pUnit);
if (!pUnit) {
dbg("!! Unknown unit type %s, aborting load.", typebuf);
break;
}
// NAME
pp_string(pp, typebuf, 16);

@ -11,7 +11,6 @@ GEX_SRC_DIR = \
User/units/pin \
User/TinyFrame \
User/CWPack \
User/vfs \
User/tasks
GEX_SOURCES = \
@ -19,12 +18,7 @@ GEX_SOURCES = \
User/USB/usbd_cdc_if.c \
User/USB/usbd_conf.c \
User/USB/usbd_desc.c \
User/USB/usbd_storage_if.c \
User/USB/STM32_USB_Device_Library/Class/CDC/Src/usbd_cdc.c \
User/USB/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc.c \
User/USB/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_bot.c \
User/USB/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_data.c \
User/USB/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_scsi.c \
User/USB/STM32_USB_Device_Library/Class/MSC_CDC/usbd_msc_cdc.c \
User/USB/STM32_USB_Device_Library/Core/Src/usbd_core.c \
User/USB/STM32_USB_Device_Library/Core/Src/usbd_ctlreq.c \
@ -67,7 +61,7 @@ GEX_CDEFS_BASE = \
-D__packed="__attribute__((__packed__))" \
-DUSE_FULL_LL_DRIVER \
# TODO implement debug build choice
# TODO implement debug build choice - enable or disable debugging
ifeq '1' '1'
GEX_CDEFS = $(GEX_CDEFS_BASE) \
-DUSE_FULL_ASSERT=1 \
@ -87,3 +81,21 @@ GEX_CDEFS = $(GEX_CDEFS_BASE) \
-DUSE_STACK_MONITOR=0 \
-DUSE_DEBUG_UART=0
endif
# TODO implement debug build choice - enable or disable MSC
ifeq '1' '1'
GEX_SOURCES += \
User/USB/usbd_storage_if.c \
User/USB/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc.c \
User/USB/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_bot.c \
User/USB/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_data.c \
User/USB/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_scsi.c
GEX_SRC_DIR += \
User/vfs
else
GEX_CDEFS += -DDISABLE_MSC
endif

@ -12,8 +12,6 @@
#include "units/neopixel/unit_neopixel.h"
#include "units/test/unit_test.h"
// ----- RELEASE AVAILABLE RESOURCES -----
void plat_init_resources(void)
{
__HAL_RCC_GPIOA_CLK_ENABLE();
@ -24,6 +22,7 @@ void plat_init_resources(void)
// --- Common unit drivers ---
ureg_add_type(&UNIT_PIN);
ureg_add_type(&UNIT_TEST);
// --- platform specific resource releases and claims ---

@ -19,8 +19,10 @@ void TaskMain(void const * argument)
{
dbg("> Main task started!");
#ifndef DISABLE_MSC
vfs_if_usbd_msc_init();
vfs_mngr_init(1);
#endif
uint32_t startTime = xTaskGetTickCount();
uint32_t cnt = 1;
@ -33,7 +35,11 @@ void TaskMain(void const * argument)
uint32_t elapsed = now - startTime;
if (elapsed >= 100) {
// interval 100ms or more - slow periodic
#ifndef DISABLE_MSC
vfs_mngr_periodic(elapsed);
#endif
LockJumper_Check();
startTime = now;
@ -61,6 +67,7 @@ void TaskMain(void const * argument)
//
}
#ifndef DISABLE_MSC
// MSC - read/write etc
if (msg & (USBEVT_FLAG_EPx_IN(MSC_EPIN_ADDR))) {
USBD_MSC_DataIn(&hUsbDeviceFS, MSC_EPIN_ADDR);
@ -69,6 +76,7 @@ void TaskMain(void const * argument)
if (msg & (USBEVT_FLAG_EPx_OUT(MSC_EPOUT_ADDR))) {
USBD_MSC_DataOut(&hUsbDeviceFS, MSC_EPOUT_ADDR);
}
#endif
// CDC - config packets and data in/out
if (msg & (USBEVT_FLAG_EPx_IN(CDC_IN_EP))) {

Loading…
Cancel
Save