Implemented optional build for mass storage, keyboard, and mouse

features.

Conflicts:
	Upstream/.settings/language.settings.xml
pull/7/head
Robert Fisk 8 years ago
parent adc3cd6f9f
commit 5c9dde896c

@ -5,7 +5,7 @@
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="1281764325376415889" id="ilg.gnuarmeclipse.managedbuild.cross.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings Cross ARM" parameter="${COMMAND} ${FLAGS} ${cross_toolchain_flags} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="-534468179008507743" id="ilg.gnuarmeclipse.managedbuild.cross.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings Cross ARM" parameter="${COMMAND} ${FLAGS} ${cross_toolchain_flags} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
@ -16,7 +16,7 @@
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="1283148015830583479" id="ilg.gnuarmeclipse.managedbuild.cross.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings Cross ARM" parameter="${COMMAND} ${FLAGS} ${cross_toolchain_flags} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="-533084488554340153" id="ilg.gnuarmeclipse.managedbuild.cross.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings Cross ARM" parameter="${COMMAND} ${FLAGS} ${cross_toolchain_flags} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>

@ -0,0 +1,24 @@
/*
* options.h
*
* Created on: Jun 20, 2017
* Author: Robert Fisk
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
#ifndef INC_OPTIONS_H_
#define INC_OPTIONS_H_
#define ENABLE_MASS_STORAGE
#define ENABLE_KEYBOARD
#define ENABLE_MOUSE
#define MASS_STORAGE_WRITES_PERMITTED
#endif /* INC_OPTIONS_H_ */

@ -43,13 +43,6 @@
/* Includes ------------------------------------------------------------------*/
#include "stm32f4xx.h"
#include "stm32f4xx_hal.h"
typedef enum {
APPLICATION_IDLE = 0,
APPLICATION_START,
APPLICATION_READY,
APPLICATION_DISCONNECT,
}ApplicationTypeDef;
void USB_Host_Init(void);

@ -43,8 +43,11 @@
/* Includes ------------------------------------------------------------------*/
#include "usbh_hid.h"
#include "options.h"
#if defined (ENABLE_KEYBOARD) || defined (ENABLE_MOUSE)
/** @addtogroup USBH_LIB
* @{
*/
@ -158,15 +161,20 @@ static USBH_StatusTypeDef USBH_HID_InterfaceInit (USBH_HandleTypeDef *phost)
HID_Handle->state = HID_ERROR;
/*Decode Bootclass Protocol: Mouse or Keyboard*/
#ifdef ENABLE_KEYBOARD
if(phost->device.CfgDesc.Itf_Desc[phost->device.current_interface].bInterfaceProtocol == HID_KEYBRD_BOOT_CODE)
{
USBH_UsrLog ("KeyBoard device found!");
}
else if(phost->device.CfgDesc.Itf_Desc[phost->device.current_interface].bInterfaceProtocol == HID_MOUSE_BOOT_CODE)
else
#endif
#ifdef ENABLE_MOUSE
if(phost->device.CfgDesc.Itf_Desc[phost->device.current_interface].bInterfaceProtocol == HID_MOUSE_BOOT_CODE)
{
USBH_UsrLog ("Mouse device found!");
}
else
#endif
{
USBH_UsrLog ("Protocol not supported.");
return USBH_FAIL;
@ -835,6 +843,9 @@ __weak void USBH_HID_EventCallback(USBH_HandleTypeDef *phost)
{
}
#endif //#if defined (ENABLE_KEYBOARD) || defined (ENABLE_MOUSE)
/**
* @}
*/

@ -46,8 +46,10 @@
#include "usbh_msc_bot.h"
#include "usbh_msc_scsi.h"
#include "interrupts.h"
#include "options.h"
#ifdef ENABLE_MASS_STORAGE
/** @addtogroup USBH_LIB
* @{
*/
@ -785,6 +787,8 @@ USBH_StatusTypeDef USBH_MSC_Write(USBH_HandleTypeDef *phost,
return USBH_OK;
}
#endif //#ifdef ENABLE_MASS_STORAGE
/**
* @}
*/

@ -34,8 +34,10 @@
#include "downstream_spi.h"
#include "downstream_msc.h"
#include "downstream_statemachine.h"
#include "options.h"
#ifdef ENABLE_MASS_STORAGE
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);
@ -700,6 +702,7 @@ static BOT_CSWStatusTypeDef USBH_MSC_DecodeCSW(USBH_HandleTypeDef *phost)
return status;
}
#endif //#ifdef ENABLE_MASS_STORAGE
/**
* @}

@ -32,8 +32,11 @@
#include "usbh_msc.h"
#include "usbh_msc_scsi.h"
#include "usbh_msc_bot.h"
#include "options.h"
#ifdef ENABLE_MASS_STORAGE
/** @addtogroup USBH_LIB
* @{
*/
@ -426,6 +429,7 @@ USBH_StatusTypeDef USBH_MSC_SCSI_Read(USBH_HandleTypeDef *phost,
return error;
}
#endif //#ifdef ENABLE_MASS_STORAGE
/**
* @}

@ -15,8 +15,11 @@
#include "downstream_statemachine.h"
#include "usbh_hid.h"
#include "stm32f4xx_hal.h"
#include "options.h"
#if defined (ENABLE_KEYBOARD) || defined (ENABLE_MOUSE)
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
@ -51,6 +54,7 @@ InterfaceCommandClassTypeDef Downstream_HID_ApproveConnectedDevice(void)
{
HID_HandleTypeDef* HID_Handle = (HID_HandleTypeDef*)hUsbHostFS.pActiveClass->pData;
#ifdef ENABLE_MOUSE
if (HID_Handle->Protocol == HID_MOUSE_BOOT_CODE)
{
if (Downstream_HID_Mouse_ParseReportDescriptor() == HAL_OK)
@ -58,18 +62,20 @@ InterfaceCommandClassTypeDef Downstream_HID_ApproveConnectedDevice(void)
return COMMAND_CLASS_HID_MOUSE; //success!
}
}
#endif
#ifdef ENABLE_KEYBOARD
if (HID_Handle->Protocol == HID_KEYBRD_BOOT_CODE)
{
return COMMAND_CLASS_HID_KEYBOARD; //success!
}
#endif
//else:
return COMMAND_CLASS_INTERFACE; //fail
}
#ifdef ENABLE_MOUSE
static HAL_StatusTypeDef Downstream_HID_Mouse_ParseReportDescriptor(void)
{
uint32_t currentReportBitIndex = 0;
@ -223,7 +229,7 @@ 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.
@ -313,19 +319,24 @@ void Downstream_HID_InterruptReportCallback(USBH_StatusTypeDef result)
if (result == USBH_OK)
{
//Data received from device
#ifdef ENABLE_MOUSE
if (ConfiguredDeviceClass == COMMAND_CLASS_HID_MOUSE)
{
Downstream_HID_Mouse_ExtractDataFromReport(freePacket);
freePacket->Length16 = ((HID_MOUSE_INPUT_DATA_LEN + 1) / 2) + DOWNSTREAM_PACKET_HEADER_LEN_16;
}
else if (ConfiguredDeviceClass == COMMAND_CLASS_HID_KEYBOARD)
else
#endif
#ifdef ENABLE_KEYBOARD
if (ConfiguredDeviceClass == COMMAND_CLASS_HID_KEYBOARD)
{
Downstream_HID_Keyboard_ExtractDataFromReport(freePacket);
freePacket->Length16 = ((HID_KEYBOARD_INPUT_DATA_LEN + 1) / 2) + DOWNSTREAM_PACKET_HEADER_LEN_16;
}
//else if...
else
#endif
//else if...
{
Downstream_PacketProcessor_FreakOut();
return;
@ -343,6 +354,7 @@ void Downstream_HID_InterruptReportCallback(USBH_StatusTypeDef result)
}
#ifdef ENABLE_MOUSE
static void Downstream_HID_Mouse_ExtractDataFromReport(DownstreamPacketTypeDef* packetToSend)
{
HID_HandleTypeDef* HID_Handle = (HID_HandleTypeDef*)hUsbHostFS.pActiveClass->pData;
@ -388,9 +400,10 @@ static uint8_t Downstream_HID_Mouse_Extract8BitValue(HID_HandleTypeDef* hidHandl
if (readData > INT8_MAX) readData = INT8_MAX;
return (int8_t)readData;
}
#endif
#ifdef ENABLE_KEYBOARD
static void Downstream_HID_Keyboard_ExtractDataFromReport(DownstreamPacketTypeDef* packetToSend)
{
HID_HandleTypeDef* HID_Handle = (HID_HandleTypeDef*)hUsbHostFS.pActiveClass->pData;
@ -410,11 +423,14 @@ static void Downstream_HID_Keyboard_ExtractDataFromReport(DownstreamPacketTypeDe
packetToSend->Data[i] = readData;
}
}
#endif
void Downstream_HID_SendReportCallback(USBH_StatusTypeDef result)
{
UNUSED(result);
DownstreamPacketTypeDef* freePacket;
freePacket = Downstream_GetFreePacketImmediately();
@ -424,3 +440,6 @@ void Downstream_HID_SendReportCallback(USBH_StatusTypeDef result)
Downstream_PacketProcessor_ClassReply(freePacket);
}
#endif //#if defined (ENABLE_KEYBOARD) || defined (ENABLE_MOUSE)

@ -15,8 +15,11 @@
#include "downstream_statemachine.h"
#include "downstream_spi.h"
#include "usbh_msc.h"
#include "options.h"
#ifdef ENABLE_MASS_STORAGE
extern USBH_HandleTypeDef hUsbHostFS; //Hard-link ourselves to usb_host.c
@ -284,4 +287,5 @@ void Downstream_MSC_GetStreamDataPacketCallback(DownstreamPacketTypeDef* receive
}
#endif //#ifdef ENABLE_MASS_STORAGE

@ -19,7 +19,7 @@
#include "usbh_msc.h"
#include "usbh_hid.h"
#include "led.h"
#include "options.h"
DownstreamStateTypeDef DownstreamState = STATE_DEVICE_NOT_READY;
@ -88,15 +88,22 @@ void Downstream_PacketProcessor(DownstreamPacketTypeDef* receivedPacket)
switch (ConfiguredDeviceClass)
{
#ifdef ENABLE_MASS_STORAGE
case COMMAND_CLASS_MASS_STORAGE:
Downstream_MSC_PacketProcessor(receivedPacket);
break;
#endif
#ifdef ENABLE_MOUSE
case COMMAND_CLASS_HID_MOUSE:
Downstream_HID_PacketProcessor(receivedPacket);
break;
#endif
#ifdef ENABLE_KEYBOARD
case COMMAND_CLASS_HID_KEYBOARD:
Downstream_HID_PacketProcessor(receivedPacket);
break;
#endif
//Add other classes here...
@ -235,13 +242,16 @@ void Downstream_HostUserCallback(USBH_HandleTypeDef *phost, uint8_t id)
{
switch (phost->pActiveClass->ClassCode)
{
#ifdef ENABLE_MASS_STORAGE
case USB_MSC_CLASS:
newActiveClass = Downstream_MSC_ApproveConnectedDevice();
break;
#endif
#if defined (ENABLE_KEYBOARD) || defined (ENABLE_MOUSE)
case USB_HID_CLASS:
newActiveClass = Downstream_HID_ApproveConnectedDevice();
break;
#endif
//Add other classes here...

@ -40,6 +40,7 @@
#include "usbh_msc.h"
#include "usbh_hid.h"
#include "downstream_statemachine.h"
#include "options.h"
/* USB Host Core handle declaration */
USBH_HandleTypeDef hUsbHostFS;
@ -51,8 +52,12 @@ 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
USBH_RegisterClass(&hUsbHostFS, USBH_MSC_CLASS);
#endif
#if defined (ENABLE_KEYBOARD) || defined (ENABLE_MOUSE)
USBH_RegisterClass(&hUsbHostFS, USBH_HID_CLASS);
#endif
USBH_Start(&hUsbHostFS);
}

@ -16,7 +16,7 @@
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="1291980636662895857" id="ilg.gnuarmeclipse.managedbuild.cross.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings Cross ARM" parameter="${COMMAND} ${FLAGS} ${cross_toolchain_flags} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="-524251867722027775" id="ilg.gnuarmeclipse.managedbuild.cross.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings Cross ARM" parameter="${COMMAND} ${FLAGS} ${cross_toolchain_flags} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>

Loading…
Cancel
Save