Build options complete & tested:

- Implement SCSI WP flag in mode parameter header
 - Refactor #ifdef names
 - #ifdef out more HID code
USG_1.0
Robert Fisk 8 years ago
parent 2cd86a7201
commit cf1d5da8e8

@ -1,5 +1,5 @@
/*
* options.h
* build_config.h
*
* Created on: Jun 20, 2017
* Author: Robert Fisk
@ -9,16 +9,15 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
#ifndef INC_OPTIONS_H_
#define INC_OPTIONS_H_
#ifndef INC_BUILD_CONFIG_H_
#define INC_BUILD_CONFIG_H_
#define ENABLE_MASS_STORAGE
#define ENABLE_KEYBOARD
#define ENABLE_MOUSE
#define CONFIG_MASS_STORAGE_ENABLED
#define CONFIG_MASS_STORAGE_WRITES_PERMITTED
#define MASS_STORAGE_WRITES_PERMITTED
#define CONFIG_KEYBOARD_ENABLED
#define CONFIG_MOUSE_ENABLED
#endif /* INC_OPTIONS_H_ */
#endif /* INC_BUILD_CONFIG_H_ */

@ -43,10 +43,10 @@
/* Includes ------------------------------------------------------------------*/
#include "usbh_hid.h"
#include "options.h"
#include "build_config.h"
#if defined (ENABLE_KEYBOARD) || defined (ENABLE_MOUSE)
#if defined (CONFIG_KEYBOARD_ENABLED) || defined (CONFIG_MOUSE_ENABLED)
/** @addtogroup USBH_LIB
* @{
@ -161,14 +161,14 @@ static USBH_StatusTypeDef USBH_HID_InterfaceInit (USBH_HandleTypeDef *phost)
HID_Handle->state = HID_ERROR;
/*Decode Bootclass Protocol: Mouse or Keyboard*/
#ifdef ENABLE_KEYBOARD
#ifdef CONFIG_KEYBOARD_ENABLED
if(phost->device.CfgDesc.Itf_Desc[phost->device.current_interface].bInterfaceProtocol == HID_KEYBRD_BOOT_CODE)
{
USBH_UsrLog ("KeyBoard device found!");
}
else
#endif
#ifdef ENABLE_MOUSE
#ifdef CONFIG_MOUSE_ENABLED
if(phost->device.CfgDesc.Itf_Desc[phost->device.current_interface].bInterfaceProtocol == HID_MOUSE_BOOT_CODE)
{
USBH_UsrLog ("Mouse device found!");
@ -844,7 +844,7 @@ __weak void USBH_HID_EventCallback(USBH_HandleTypeDef *phost)
}
#endif //#if defined (ENABLE_KEYBOARD) || defined (ENABLE_MOUSE)
#endif //#if defined (CONFIG_KEYBOARD_ENABLED) || defined (CONFIG_MOUSE_ENABLED)
/**
* @}

@ -46,10 +46,10 @@
#include "usbh_msc_bot.h"
#include "usbh_msc_scsi.h"
#include "interrupts.h"
#include "options.h"
#include "build_config.h"
#ifdef ENABLE_MASS_STORAGE
#ifdef CONFIG_MASS_STORAGE_ENABLED
/** @addtogroup USBH_LIB
* @{
*/
@ -496,7 +496,7 @@ static USBH_StatusTypeDef USBH_MSC_Process(USBH_HandleTypeDef *phost)
error = USBH_OK;
break;
#ifdef MASS_STORAGE_WRITES_PERMITTED
#ifdef CONFIG_MASS_STORAGE_WRITES_PERMITTED
case MSC_WRITE:
#endif
case MSC_READ:
@ -574,7 +574,7 @@ static USBH_StatusTypeDef USBH_MSC_RdWrProcess(USBH_HandleTypeDef *phost, uint8_
#endif
break;
#ifdef MASS_STORAGE_WRITES_PERMITTED
#ifdef CONFIG_MASS_STORAGE_WRITES_PERMITTED
case MSC_WRITE:
scsi_status = USBH_MSC_SCSI_Write(phost,lun, 0, 0) ;
@ -596,7 +596,7 @@ static USBH_StatusTypeDef USBH_MSC_RdWrProcess(USBH_HandleTypeDef *phost, uint8_
osMessagePut ( phost->os_event, USBH_CLASS_EVENT, 0);
#endif
break;
#endif //#ifdef MASS_STORAGE_WRITES_PERMITTED
#endif //#ifdef CONFIG_MASS_STORAGE_WRITES_PERMITTED
case MSC_REQUEST_SENSE:
scsi_status = USBH_MSC_SCSI_RequestSense(phost, lun, &MSC_Handle->unit[lun].sense);
@ -762,7 +762,7 @@ USBH_StatusTypeDef USBH_MSC_Read(USBH_HandleTypeDef *phost,
* @param length: number of sector to write
* @retval USBH Status
*/
#ifdef MASS_STORAGE_WRITES_PERMITTED
#ifdef CONFIG_MASS_STORAGE_WRITES_PERMITTED
USBH_StatusTypeDef USBH_MSC_Write(USBH_HandleTypeDef *phost,
uint8_t lun,
uint32_t address,
@ -791,9 +791,9 @@ USBH_StatusTypeDef USBH_MSC_Write(USBH_HandleTypeDef *phost,
length);
return USBH_OK;
}
#endif //#ifdef MASS_STORAGE_WRITES_PERMITTED
#endif //#ifdef CONFIG_MASS_STORAGE_WRITES_PERMITTED
#endif //#ifdef ENABLE_MASS_STORAGE
#endif //#ifdef CONFIG_MASS_STORAGE_ENABLED
/**
* @}

@ -34,10 +34,10 @@
#include "downstream_spi.h"
#include "downstream_msc.h"
#include "downstream_statemachine.h"
#include "options.h"
#include "build_config.h"
#ifdef ENABLE_MASS_STORAGE
#ifdef CONFIG_MASS_STORAGE_ENABLED
static USBH_StatusTypeDef USBH_MSC_BOT_Abort(USBH_HandleTypeDef *phost, uint8_t lun, uint8_t dir);
static BOT_CSWStatusTypeDef USBH_MSC_DecodeCSW(USBH_HandleTypeDef *phost);
@ -301,7 +301,7 @@ USBH_StatusTypeDef USBH_MSC_BOT_Process (USBH_HandleTypeDef *phost, uint8_t lun)
MSC_Handle->OutPipe,
1);
}
#ifdef MASS_STORAGE_WRITES_PERMITTED
#ifdef CONFIG_MASS_STORAGE_WRITES_PERMITTED
else
{
//Asynchronous multi-packet operation: get first packet
@ -330,7 +330,7 @@ USBH_StatusTypeDef USBH_MSC_BOT_Process (USBH_HandleTypeDef *phost, uint8_t lun)
//Simple single-buffer operation: everything must fit in one URB
MSC_Handle->hbot.state = BOT_RECEIVE_CSW;
}
#ifdef MASS_STORAGE_WRITES_PERMITTED
#ifdef CONFIG_MASS_STORAGE_WRITES_PERMITTED
else
{
//Asynchronous multi-packet operation
@ -372,7 +372,7 @@ USBH_StatusTypeDef USBH_MSC_BOT_Process (USBH_HandleTypeDef *phost, uint8_t lun)
{
MSC_Handle->hbot.state = BOT_DATA_OUT;
}
#ifdef MASS_STORAGE_WRITES_PERMITTED
#ifdef CONFIG_MASS_STORAGE_WRITES_PERMITTED
else
{
//Increment counters by the amount of data actually transferred during the NAK'd URB
@ -522,7 +522,7 @@ void USBH_MSC_BOT_Read_Multipacket_PrepareURB(USBH_HandleTypeDef *phost)
MSC_Handle->InPipe);
}
#ifdef MASS_STORAGE_WRITES_PERMITTED
#ifdef CONFIG_MASS_STORAGE_WRITES_PERMITTED
void USBH_MSC_BOT_Write_Multipacket_ReceivePacketCallback(DownstreamPacketTypeDef* receivedPacket,
uint16_t dataLength)
{
@ -709,7 +709,7 @@ static BOT_CSWStatusTypeDef USBH_MSC_DecodeCSW(USBH_HandleTypeDef *phost)
return status;
}
#endif //#ifdef ENABLE_MASS_STORAGE
#endif //#ifdef CONFIG_MASS_STORAGE_ENABLED
/**
* @}

@ -32,10 +32,10 @@
#include "usbh_msc.h"
#include "usbh_msc_scsi.h"
#include "usbh_msc_bot.h"
#include "options.h"
#include "build_config.h"
#ifdef ENABLE_MASS_STORAGE
#ifdef CONFIG_MASS_STORAGE_ENABLED
/** @addtogroup USBH_LIB
* @{
@ -325,7 +325,7 @@ USBH_StatusTypeDef USBH_MSC_SCSI_RequestSense (USBH_HandleTypeDef *phost,
* @param length: number of sector to write
* @retval USBH Status
*/
#ifdef MASS_STORAGE_WRITES_PERMITTED
#ifdef CONFIG_MASS_STORAGE_WRITES_PERMITTED
USBH_StatusTypeDef USBH_MSC_SCSI_Write(USBH_HandleTypeDef *phost,
uint8_t lun,
uint32_t address,
@ -431,7 +431,7 @@ USBH_StatusTypeDef USBH_MSC_SCSI_Read(USBH_HandleTypeDef *phost,
return error;
}
#endif //#ifdef ENABLE_MASS_STORAGE
#endif //#ifdef CONFIG_MASS_STORAGE_ENABLED
/**
* @}

@ -15,10 +15,10 @@
#include "downstream_statemachine.h"
#include "usbh_hid.h"
#include "stm32f4xx_hal.h"
#include "options.h"
#include "build_config.h"
#if defined (ENABLE_KEYBOARD) || defined (ENABLE_MOUSE)
#if defined (CONFIG_KEYBOARD_ENABLED) || defined (CONFIG_MOUSE_ENABLED)
extern USBH_HandleTypeDef hUsbHostFS; //Hard-link ourselves to usb_host.c
extern InterfaceCommandClassTypeDef ConfiguredDeviceClass; //Do a cheap hard-link to downstream_statemachine.c, rather than keep a duplicate here
@ -54,7 +54,7 @@ InterfaceCommandClassTypeDef Downstream_HID_ApproveConnectedDevice(void)
{
HID_HandleTypeDef* HID_Handle = (HID_HandleTypeDef*)hUsbHostFS.pActiveClass->pData;
#ifdef ENABLE_MOUSE
#ifdef CONFIG_MOUSE_ENABLED
if (HID_Handle->Protocol == HID_MOUSE_BOOT_CODE)
{
if (Downstream_HID_Mouse_ParseReportDescriptor() == HAL_OK)
@ -63,7 +63,7 @@ InterfaceCommandClassTypeDef Downstream_HID_ApproveConnectedDevice(void)
}
}
#endif
#ifdef ENABLE_KEYBOARD
#ifdef CONFIG_KEYBOARD_ENABLED
if (HID_Handle->Protocol == HID_KEYBRD_BOOT_CODE)
{
return COMMAND_CLASS_HID_KEYBOARD; //success!
@ -75,7 +75,7 @@ InterfaceCommandClassTypeDef Downstream_HID_ApproveConnectedDevice(void)
}
#ifdef ENABLE_MOUSE
#ifdef CONFIG_MOUSE_ENABLED
static HAL_StatusTypeDef Downstream_HID_Mouse_ParseReportDescriptor(void)
{
uint32_t currentReportBitIndex = 0;
@ -229,7 +229,6 @@ static HAL_StatusTypeDef Downstream_HID_Mouse_ParseReportDescriptor(void)
return HAL_OK;
}
#endif
//Retrieves the next item in the HID report, and at most one of its associated data bytes.
@ -269,6 +268,7 @@ static HAL_StatusTypeDef Downstream_HID_GetNextReportItem(void)
ReportDataPointer += itemLength;
return HAL_OK;
}
#endif
@ -286,6 +286,7 @@ void Downstream_HID_PacketProcessor(DownstreamPacketTypeDef* receivedPacket)
return;
}
#ifdef CONFIG_KEYBOARD_ENABLED
if (receivedPacket->Command == COMMAND_HID_SET_REPORT)
{
if ((ConfiguredDeviceClass != COMMAND_CLASS_HID_KEYBOARD) ||
@ -304,6 +305,7 @@ void Downstream_HID_PacketProcessor(DownstreamPacketTypeDef* receivedPacket)
Downstream_PacketProcessor_NotifyDisconnectReplyRequired();
return;
}
#endif
//else:
Downstream_PacketProcessor_FreakOut();
@ -319,7 +321,7 @@ void Downstream_HID_InterruptReportCallback(USBH_StatusTypeDef result)
if (result == USBH_OK)
{
//Data received from device
#ifdef ENABLE_MOUSE
#ifdef CONFIG_MOUSE_ENABLED
if (ConfiguredDeviceClass == COMMAND_CLASS_HID_MOUSE)
{
Downstream_HID_Mouse_ExtractDataFromReport(freePacket);
@ -327,7 +329,7 @@ void Downstream_HID_InterruptReportCallback(USBH_StatusTypeDef result)
}
else
#endif
#ifdef ENABLE_KEYBOARD
#ifdef CONFIG_KEYBOARD_ENABLED
if (ConfiguredDeviceClass == COMMAND_CLASS_HID_KEYBOARD)
{
Downstream_HID_Keyboard_ExtractDataFromReport(freePacket);
@ -354,7 +356,7 @@ void Downstream_HID_InterruptReportCallback(USBH_StatusTypeDef result)
}
#ifdef ENABLE_MOUSE
#ifdef CONFIG_MOUSE_ENABLED
static void Downstream_HID_Mouse_ExtractDataFromReport(DownstreamPacketTypeDef* packetToSend)
{
HID_HandleTypeDef* HID_Handle = (HID_HandleTypeDef*)hUsbHostFS.pActiveClass->pData;
@ -403,7 +405,7 @@ static uint8_t Downstream_HID_Mouse_Extract8BitValue(HID_HandleTypeDef* hidHandl
#endif
#ifdef ENABLE_KEYBOARD
#ifdef CONFIG_KEYBOARD_ENABLED
static void Downstream_HID_Keyboard_ExtractDataFromReport(DownstreamPacketTypeDef* packetToSend)
{
HID_HandleTypeDef* HID_Handle = (HID_HandleTypeDef*)hUsbHostFS.pActiveClass->pData;
@ -441,5 +443,5 @@ void Downstream_HID_SendReportCallback(USBH_StatusTypeDef result)
}
#endif //#if defined (ENABLE_KEYBOARD) || defined (ENABLE_MOUSE)
#endif //#if defined (CONFIG_KEYBOARD_ENABLED) || defined (CONFIG_MOUSE_ENABLED)

@ -15,10 +15,10 @@
#include "downstream_statemachine.h"
#include "downstream_spi.h"
#include "usbh_msc.h"
#include "options.h"
#include "build_config.h"
#ifdef ENABLE_MASS_STORAGE
#ifdef CONFIG_MASS_STORAGE_ENABLED
extern USBH_HandleTypeDef hUsbHostFS; //Hard-link ourselves to usb_host.c
@ -80,7 +80,7 @@ void Downstream_MSC_PacketProcessor(DownstreamPacketTypeDef* receivedPacket)
Downstream_MSC_PacketProcessor_BeginRead(receivedPacket);
break;
#ifdef MASS_STORAGE_WRITES_PERMITTED
#ifdef CONFIG_MASS_STORAGE_WRITES_PERMITTED
case COMMAND_MSC_WRITE:
Downstream_MSC_PacketProcessor_BeginWrite(receivedPacket);
break;
@ -172,7 +172,7 @@ void Downstream_MSC_PacketProcessor_RdWrCompleteCallback(USBH_StatusTypeDef resu
}
#ifdef MASS_STORAGE_WRITES_PERMITTED
#ifdef CONFIG_MASS_STORAGE_WRITES_PERMITTED
void Downstream_MSC_PacketProcessor_BeginWrite(DownstreamPacketTypeDef* receivedPacket)
{
uint64_t writeBlockAddress;
@ -238,7 +238,7 @@ HAL_StatusTypeDef Downstream_MSC_PutStreamDataPacket(DownstreamPacketTypeDef* pa
}
#ifdef MASS_STORAGE_WRITES_PERMITTED
#ifdef CONFIG_MASS_STORAGE_WRITES_PERMITTED
//Used by USB MSC host driver
HAL_StatusTypeDef Downstream_MSC_GetStreamDataPacket(DownstreamMSCCallbackPacketTypeDef callback)
{
@ -290,7 +290,7 @@ void Downstream_MSC_GetStreamDataPacketCallback(DownstreamPacketTypeDef* receive
}
}
#endif //#ifdef MASS_STORAGE_WRITES_PERMITTED
#endif //#ifdef CONFIG_MASS_STORAGE_WRITES_PERMITTED
#endif //#ifdef ENABLE_MASS_STORAGE
#endif //#ifdef CONFIG_MASS_STORAGE_ENABLED

@ -19,7 +19,7 @@
#include "usbh_msc.h"
#include "usbh_hid.h"
#include "led.h"
#include "options.h"
#include "build_config.h"
DownstreamStateTypeDef DownstreamState = STATE_DEVICE_NOT_READY;
@ -89,17 +89,17 @@ void Downstream_PacketProcessor(DownstreamPacketTypeDef* receivedPacket)
switch (ConfiguredDeviceClass)
{
#ifdef ENABLE_MASS_STORAGE
#ifdef CONFIG_MASS_STORAGE_ENABLED
case COMMAND_CLASS_MASS_STORAGE:
Downstream_MSC_PacketProcessor(receivedPacket);
break;
#endif
#ifdef ENABLE_MOUSE
#ifdef CONFIG_MOUSE_ENABLED
case COMMAND_CLASS_HID_MOUSE:
Downstream_HID_PacketProcessor(receivedPacket);
break;
#endif
#ifdef ENABLE_KEYBOARD
#ifdef CONFIG_KEYBOARD_ENABLED
case COMMAND_CLASS_HID_KEYBOARD:
Downstream_HID_PacketProcessor(receivedPacket);
break;
@ -242,12 +242,12 @@ void Downstream_HostUserCallback(USBH_HandleTypeDef *phost, uint8_t id)
{
switch (phost->pActiveClass->ClassCode)
{
#ifdef ENABLE_MASS_STORAGE
#ifdef CONFIG_MASS_STORAGE_ENABLED
case USB_MSC_CLASS:
newActiveClass = Downstream_MSC_ApproveConnectedDevice();
break;
#endif
#if defined (ENABLE_KEYBOARD) || defined (ENABLE_MOUSE)
#if defined (CONFIG_KEYBOARD_ENABLED) || defined (CONFIG_MOUSE_ENABLED)
case USB_HID_CLASS:
newActiveClass = Downstream_HID_ApproveConnectedDevice();
break;

@ -40,7 +40,8 @@
#include "usbh_msc.h"
#include "usbh_hid.h"
#include "downstream_statemachine.h"
#include "options.h"
#include "build_config.h"
/* USB Host Core handle declaration */
USBH_HandleTypeDef hUsbHostFS;
@ -52,10 +53,10 @@ void USB_Host_Init(void)
/* Init Host Library,Add Supported Class and Start the library*/
USBH_Init(&hUsbHostFS, Downstream_HostUserCallback, HOST_FS);
#ifdef ENABLE_MASS_STORAGE
#ifdef CONFIG_MASS_STORAGE_ENABLED
USBH_RegisterClass(&hUsbHostFS, USBH_MSC_CLASS);
#endif
#if defined (ENABLE_KEYBOARD) || defined (ENABLE_MOUSE)
#if defined (CONFIG_KEYBOARD_ENABLED) || defined (CONFIG_MOUSE_ENABLED)
USBH_RegisterClass(&hUsbHostFS, USBH_HID_CLASS);
#endif

@ -1,5 +1,5 @@
/*
* options.h
* build_config.h
*
* Created on: Jun 20, 2017
* Author: Robert Fisk
@ -9,16 +9,15 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
#ifndef INC_OPTIONS_H_
#define INC_OPTIONS_H_
#ifndef INC_BUILD_CONFIG_H_
#define INC_BUILD_CONFIG_H_
#define ENABLE_MASS_STORAGE
#define ENABLE_KEYBOARD
#define ENABLE_MOUSE
#define CONFIG_MASS_STORAGE_ENABLED
//#define CONFIG_MASS_STORAGE_WRITES_PERMITTED
#define MASS_STORAGE_WRITES_PERMITTED
#define CONFIG_KEYBOARD_ENABLED
//#define CONFIG_MOUSE_ENABLED
#endif /* INC_OPTIONS_H_ */
#endif /* INC_BUILD_CONFIG_H_ */

@ -52,10 +52,10 @@
#include "usbd_hid.h"
#include "usbd_ctlreq.h"
#include "upstream_hid.h"
#include "options.h"
#include "build_config.h"
#if defined (ENABLE_KEYBOARD) || defined (ENABLE_MOUSE)
#if defined (CONFIG_KEYBOARD_ENABLED) || defined (CONFIG_MOUSE_ENABLED)
static uint8_t USBD_HID_Init (USBD_HandleTypeDef *pdev,
@ -79,10 +79,10 @@ static uint8_t USBD_HID_SendReport (uint8_t *report,
static uint8_t USBD_HID_EP0RxReady(USBD_HandleTypeDef *pdev);
#ifdef ENABLE_MOUSE
#ifdef CONFIG_MOUSE_ENABLED
#define USBD_PID_MOUSE 0x0002
#endif
#ifdef ENABLE_KEYBOARD
#ifdef CONFIG_KEYBOARD_ENABLED
#define USBD_PID_KEYBOARD 0x0003
#endif
@ -194,7 +194,7 @@ __ALIGN_BEGIN static uint8_t USBD_HID_DeviceQualifierDesc[USB_LEN_DEV_QUALIFIER_
0x00,
};
#ifdef ENABLE_MOUSE
#ifdef CONFIG_MOUSE_ENABLED
__ALIGN_BEGIN static uint8_t HID_MOUSE_ReportDesc[HID_MOUSE_REPORT_DESC_SIZE] __ALIGN_END =
{
0x05, 0x01, // Usage Page (Generic Desktop Ctrls)
@ -239,7 +239,7 @@ __ALIGN_BEGIN static uint8_t HID_MOUSE_ReportDesc[HID_MOUSE_REPORT_DESC_SIZE] _
};
#endif
#ifdef ENABLE_KEYBOARD
#ifdef CONFIG_KEYBOARD_ENABLED
__ALIGN_BEGIN static uint8_t HID_KEYBOARD_ReportDesc[HID_KEYBOARD_REPORT_DESC_SIZE] __ALIGN_END = {
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
0x09, 0x06, // USAGE (Keyboard)
@ -301,7 +301,7 @@ uint8_t OutReportSize;
* @param cfgidx: Configuration index
* @retval status
*/
#ifdef ENABLE_MOUSE
#ifdef CONFIG_MOUSE_ENABLED
void USBD_HID_PreinitMouse(void)
{
ActiveReportDescriptor = HID_MOUSE_ReportDesc;
@ -318,7 +318,7 @@ void USBD_HID_PreinitMouse(void)
#endif
#ifdef ENABLE_KEYBOARD
#ifdef CONFIG_KEYBOARD_ENABLED
void USBD_HID_PreinitKeyboard(void)
{
ActiveReportDescriptor = HID_KEYBOARD_ReportDesc;
@ -617,7 +617,7 @@ static uint8_t USBD_HID_EP0RxReady(USBD_HandleTypeDef *pdev)
while(1);
}
#ifdef ENABLE_KEYBOARD
#ifdef CONFIG_KEYBOARD_ENABLED
Upstream_HID_RequestSendControlReport(OutReportPacket, OutReportSize);
Upstream_ReleasePacket(OutReportPacket);
OutReportPacket = NULL;
@ -625,7 +625,7 @@ static uint8_t USBD_HID_EP0RxReady(USBD_HandleTypeDef *pdev)
return USBD_OK;
}
#endif //#if defined (ENABLE_KEYBOARD) || defined (ENABLE_MOUSE)
#endif //#if defined (CONFIG_KEYBOARD_ENABLED) || defined (CONFIG_MOUSE_ENABLED)
/**
* @}

@ -46,10 +46,10 @@
#include <upstream_interface_def.h>
#include <upstream_spi.h>
#include "usbd_msc.h"
#include "options.h"
#include "build_config.h"
#ifdef ENABLE_MASS_STORAGE
#ifdef CONFIG_MASS_STORAGE_ENABLED
/** @addtogroup STM32_USB_DEVICE_LIBRARY
* @{
@ -609,7 +609,7 @@ uint8_t *USBD_MSC_GetDeviceQualifierDescriptor (uint16_t *length)
return USBD_MSC_DeviceQualifierDesc;
}
#endif //#ifdef ENABLE_MASS_STORAGE
#endif //#ifdef CONFIG_MASS_STORAGE_ENABLED
/**

@ -32,10 +32,10 @@
#include "usbd_msc.h"
#include "usbd_msc_scsi.h"
#include "usbd_ioreq.h"
#include "options.h"
#include "build_config.h"
#ifdef ENABLE_MASS_STORAGE
#ifdef CONFIG_MASS_STORAGE_ENABLED
/** @addtogroup STM32_USB_DEVICE_LIBRARY
* @{
@ -428,7 +428,7 @@ void MSC_BOT_CplClrFeature (USBD_HandleTypeDef *pdev, uint8_t epnum)
}
#endif //#ifdef ENABLE_MASS_STORAGE
#endif //#ifdef CONFIG_MASS_STORAGE_ENABLED
/**
* @}
*/

@ -27,10 +27,10 @@
/* Includes ------------------------------------------------------------------*/
#include "usbd_msc_data.h"
#include "options.h"
#include "build_config.h"
#ifdef ENABLE_MASS_STORAGE
#ifdef CONFIG_MASS_STORAGE_ENABLED
/** @addtogroup STM32_USB_DEVICE_LIBRARY
* @{
@ -81,30 +81,36 @@ const uint8_t MSC_Page00_Inquiry_Data[] = {//7
0x80,
0x83
};
/* USB Mass storage sense 6 Data */
const uint8_t MSC_Mode_Sense6_data[] = {
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00
0x03, //Mode data length
0x00, //Medium type, direct-access block devices = 0
#ifdef CONFIG_MASS_STORAGE_WRITES_PERMITTED
0x00, //Device-specific parameter, WP is bit 7
#else
0x80, //Device-specific parameter, WP is bit 7
#endif
0x00 //Block descriptor length
};
/* USB Mass storage sense 10 Data */
const uint8_t MSC_Mode_Sense10_data[] = {
0x00,
0x06,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00
0x00, //Mode data length, big endian
0x06, //Mode data length, big endian
0x00, //Medium type, direct-access block devices = 0
#ifdef CONFIG_MASS_STORAGE_WRITES_PERMITTED
0x00, //Device-specific parameter, WP is bit 7
#else
0x80, //Device-specific parameter, WP is bit 7
#endif
0x00, //Reserved
0x00, //Reserved
0x00, //Block descriptor length, big endian
0x00 //Block descriptor length, big endian
};
#endif //ifdef ENABLE_MASS_STORAGE
#endif //ifdef CONFIG_MASS_STORAGE_ENABLED
/**
* @}

@ -36,10 +36,10 @@
#include "usbd_msc.h"
#include "usbd_msc_data.h"
#include "usbd_descriptors.h"
#include "options.h"
#include "build_config.h"
#ifdef ENABLE_MASS_STORAGE
#ifdef CONFIG_MASS_STORAGE_ENABLED
/** @addtogroup STM32_USB_DEVICE_LIBRARY
* @{
@ -195,7 +195,7 @@ void SCSI_ProcessCmd(USBD_HandleTypeDef *pdev,
return;
case SCSI_WRITE10:
#ifdef MASS_STORAGE_WRITES_PERMITTED
#ifdef CONFIG_MASS_STORAGE_WRITES_PERMITTED
SCSI_Write10();
#else
SCSI_SenseCode(pdev,
@ -428,7 +428,7 @@ void SCSI_ReadFormatCapacityCallback(UpstreamPacketTypeDef* upstreamPacket,
*/
static void SCSI_ModeSense6 (void)
{
uint16_t len = 8;
uint16_t len = 4;
UpstreamPacketTypeDef* freePacket;
freePacket = Upstream_GetFreePacketImmediately();
@ -681,7 +681,7 @@ void SCSI_Read10ReplyCallback(UpstreamPacketTypeDef* upstreamPacket,
* @param params: Command parameters
* @retval status
*/
#ifdef MASS_STORAGE_WRITES_PERMITTED
#ifdef CONFIG_MASS_STORAGE_WRITES_PERMITTED
static void SCSI_Write10(void)
{
uint32_t dataLength;
@ -870,7 +870,7 @@ static int8_t SCSI_CheckAddressRange (uint32_t blk_offset , uint16_t blk_nbr)
return 0;
}
#endif //#ifdef ENABLE_MASS_STORAGE
#endif //#ifdef CONFIG_MASS_STORAGE_ENABLED
/**
* @}
*/

@ -13,16 +13,16 @@
#include "upstream_hid.h"
#include "upstream_interface_def.h"
#include "options.h"
#include "build_config.h"
#if defined (ENABLE_KEYBOARD) || defined (ENABLE_MOUSE)
#if defined (CONFIG_KEYBOARD_ENABLED) || defined (CONFIG_MOUSE_ENABLED)
UpstreamPacketTypeDef* UpstreamHidPacket = NULL;
UpstreamHidGetReportCallback GetReportCallback = NULL;
#ifdef ENABLE_KEYBOARD
#ifdef CONFIG_KEYBOARD_ENABLED
KeyboardOutStateTypeDef KeyboardOutDataState = KEYBOARD_OUT_STATE_IDLE;
uint8_t KeyboardOutData[HID_KEYBOARD_OUTPUT_DATA_LEN];
#endif
@ -47,7 +47,7 @@ void Upstream_HID_DeInit(void)
GetReportCallback = NULL;
GetReportLoopIsRunning = 0;
#ifdef ENABLE_KEYBOARD
#ifdef CONFIG_KEYBOARD_ENABLED
KeyboardOutDataState = KEYBOARD_OUT_STATE_IDLE;
#endif
}
@ -142,7 +142,7 @@ static void Upstream_HID_ReceiveInterruptReportCallback(UpstreamPacketTypeDef* r
}
else
{
#ifdef ENABLE_MOUSE
#ifdef CONFIG_MOUSE_ENABLED
if (activeClass == COMMAND_CLASS_HID_MOUSE)
{
if (receivedPacket->Length16 != (UPSTREAM_PACKET_HEADER_LEN_16 + ((HID_MOUSE_INPUT_DATA_LEN + 1) / 2)))
@ -170,7 +170,7 @@ static void Upstream_HID_ReceiveInterruptReportCallback(UpstreamPacketTypeDef* r
}
else
#endif
#ifdef ENABLE_KEYBOARD
#ifdef CONFIG_KEYBOARD_ENABLED
if (activeClass == COMMAND_CLASS_HID_KEYBOARD)
{
if (receivedPacket->Length16 != (UPSTREAM_PACKET_HEADER_LEN_16 + ((HID_KEYBOARD_INPUT_DATA_LEN + 1) / 2)))
@ -229,7 +229,7 @@ static void Upstream_HID_ReceiveInterruptReportCallback(UpstreamPacketTypeDef* r
if (GetReportLoopIsRunning)
{
#ifdef ENABLE_KEYBOARD
#ifdef CONFIG_KEYBOARD_ENABLED
//Check if we need to send OUT data to the keyboard before requesting next Interrupt IN data
if (KeyboardOutDataState == KEYBOARD_OUT_STATE_DATA_READY)
{
@ -245,7 +245,7 @@ static void Upstream_HID_ReceiveInterruptReportCallback(UpstreamPacketTypeDef* r
#ifdef ENABLE_KEYBOARD
#ifdef CONFIG_KEYBOARD_ENABLED
void Upstream_HID_RequestSendControlReport(UpstreamPacketTypeDef* packetToSend, uint8_t dataLength)
{
InterfaceCommandClassTypeDef activeClass;
@ -324,5 +324,5 @@ static void Upstream_HID_SendControlReportCallback(UpstreamPacketTypeDef* receiv
}
#endif
#endif //#if defined (ENABLE_KEYBOARD) || defined (ENABLE_MOUSE)
#endif //#if defined (CONFIG_KEYBOARD_ENABLED) || defined (CONFIG_MOUSE_ENABLED)

@ -15,10 +15,10 @@
#include "upstream_spi.h"
#include "upstream_statemachine.h"
#include "stm32f4xx_hal.h"
#include "options.h"
#include "build_config.h"
#ifdef ENABLE_MASS_STORAGE
#ifdef CONFIG_MASS_STORAGE_ENABLED
//Stuff we need to save for our callbacks to use:
@ -279,7 +279,7 @@ void Upstream_MSC_GetStreamDataPacketCallback(UpstreamPacketTypeDef* replyPacket
}
#ifdef MASS_STORAGE_WRITES_PERMITTED
#ifdef CONFIG_MASS_STORAGE_WRITES_PERMITTED
HAL_StatusTypeDef Upstream_MSC_BeginWrite(UpstreamMSCCallbackTypeDef callback,
uint64_t writeBlockStart,
uint32_t writeBlockCount)
@ -371,5 +371,5 @@ HAL_StatusTypeDef Upstream_MSC_PutStreamDataPacket(UpstreamPacketTypeDef* packet
}
#endif
#endif //#ifdef ENABLE_MASS_STORAGE
#endif //#ifdef CONFIG_MASS_STORAGE_ENABLED

@ -17,7 +17,7 @@
#include "usbd_core.h"
#include "usbd_msc.h"
#include "usbd_hid.h"
#include "options.h"
#include "build_config.h"
UpstreamStateTypeDef UpstreamState = STATE_TEST_INTERFACE;
@ -182,20 +182,20 @@ void Upstream_StateMachine_NotifyDeviceReplyCallback(UpstreamPacketTypeDef* repl
switch (replyPacket->Data[0])
{
#ifdef ENABLE_MASS_STORAGE
#ifdef CONFIG_MASS_STORAGE_ENABLED
case COMMAND_CLASS_MASS_STORAGE:
newActiveClass = COMMAND_CLASS_MASS_STORAGE;
newClassPointer = &USBD_MSC;
break;
#endif
#ifdef ENABLE_MOUSE
#ifdef CONFIG_MOUSE_ENABLED
case COMMAND_CLASS_HID_MOUSE:
newActiveClass = COMMAND_CLASS_HID_MOUSE;
newClassPointer = &USBD_HID;
USBD_HID_PreinitMouse();
break;
#endif
#ifdef ENABLE_KEYBOARD
#ifdef CONFIG_KEYBOARD_ENABLED
case COMMAND_CLASS_HID_KEYBOARD:
newActiveClass = COMMAND_CLASS_HID_KEYBOARD;
newClassPointer = &USBD_HID;

Loading…
Cancel
Save