summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdonais Romero González <[email protected]>2023-08-21 16:32:32 -0700
committerAdonais Romero González <[email protected]>2023-08-21 16:32:32 -0700
commit4fe6dd3bcf2f27214af9f89d3cf13b321f45a012 (patch)
tree7def5a07dab21c623c213dd4456c55d6419ffd8c
parentdb7372d88ef425b082f478afe5f4acaf999704b3 (diff)
Remove legacy sample - Radio Switch using USB-FX2 board
-rw-r--r--network/radio/HidSwitchDriverSample/HidSwitchDriverSample.sln28
-rw-r--r--network/radio/HidSwitchDriverSample/README.md62
-rw-r--r--network/radio/HidSwitchDriverSample/RadioSwitchHidUsbFx2.h156
-rw-r--r--network/radio/HidSwitchDriverSample/RadioSwitchHidUsbFx2.inxbin7114 -> 0 bytes
-rw-r--r--network/radio/HidSwitchDriverSample/RadioSwitchHidUsbFx2.rc11
-rw-r--r--network/radio/HidSwitchDriverSample/RadioSwitchHidUsbFx2.vcxproj193
-rw-r--r--network/radio/HidSwitchDriverSample/RadioSwitchHidUsbFx2.vcxproj.Filters50
-rw-r--r--network/radio/HidSwitchDriverSample/driver.c156
-rw-r--r--network/radio/HidSwitchDriverSample/hid.c659
-rw-r--r--network/radio/HidSwitchDriverSample/trace.h13
-rw-r--r--network/radio/HidSwitchDriverSample/usb.c466
11 files changed, 0 insertions, 1794 deletions
diff --git a/network/radio/HidSwitchDriverSample/HidSwitchDriverSample.sln b/network/radio/HidSwitchDriverSample/HidSwitchDriverSample.sln
deleted file mode 100644
index 7bbffb25..00000000
--- a/network/radio/HidSwitchDriverSample/HidSwitchDriverSample.sln
+++ /dev/null
@@ -1,28 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 2013
-VisualStudioVersion = 12.0
-MinimumVisualStudioVersion = 12.0
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RadioSwitchHidUsbFx2", "RadioSwitchHidUsbFx2.vcxproj", "{43FD9C1A-290E-4FF7-8B6F-35A88A075DF8}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Win32 = Debug|Win32
- Release|Win32 = Release|Win32
- Debug|x64 = Debug|x64
- Release|x64 = Release|x64
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {43FD9C1A-290E-4FF7-8B6F-35A88A075DF8}.Debug|Win32.ActiveCfg = Debug|Win32
- {43FD9C1A-290E-4FF7-8B6F-35A88A075DF8}.Debug|Win32.Build.0 = Debug|Win32
- {43FD9C1A-290E-4FF7-8B6F-35A88A075DF8}.Release|Win32.ActiveCfg = Release|Win32
- {43FD9C1A-290E-4FF7-8B6F-35A88A075DF8}.Release|Win32.Build.0 = Release|Win32
- {43FD9C1A-290E-4FF7-8B6F-35A88A075DF8}.Debug|x64.ActiveCfg = Debug|x64
- {43FD9C1A-290E-4FF7-8B6F-35A88A075DF8}.Debug|x64.Build.0 = Debug|x64
- {43FD9C1A-290E-4FF7-8B6F-35A88A075DF8}.Release|x64.ActiveCfg = Release|x64
- {43FD9C1A-290E-4FF7-8B6F-35A88A075DF8}.Release|x64.Build.0 = Release|x64
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
diff --git a/network/radio/HidSwitchDriverSample/README.md b/network/radio/HidSwitchDriverSample/README.md
deleted file mode 100644
index 55ca9daf..00000000
--- a/network/radio/HidSwitchDriverSample/README.md
+++ /dev/null
@@ -1,62 +0,0 @@
----
-page_type: sample
-description: "Demonstrates how to structure a HID driver for radio switches for the OSR USB-FX2 Development Board."
-languages:
-- cpp
-products:
-- windows
-- windows-wdk
----
-
-# Radio Switch Test Driver for OSR USB-FX2 Development Board
-
-This sample demonstrates how to structure a HID driver for radio switches for the OSR USB-FX2 Development Board.
-
-The hardware switch or button to control wireless transmission and the global software switch (Airplane mode switch) in the Radio Management User Interface must be synchronized. To ensure the hardware and software switches that control radio transmission are synchronized, the hardware switch or button must have a HID-compliant driver.
-
-## Switch Pack Mapping
-
-### Switch Mapping
-
-| 1 | 2 | 3 | 4 | 5 | 7 | 8 |
-| --- | --- | --- | --- | --- | --- | --- |
-| Mode Select Bit 3 | Mode Select Bit 2 | Mode Select Bit 1 | - | - | - | Radio Switch |
-
-## Testing
-
-### Testing Modes
-
-The driver supports five modes representing the valid combinations of HID descriptors that we have defined for the USB forum. Modes are selected using switches 1, 2, and 3 on the switch pack.
-
-### Switch Mapping Modes
-
-| 1 | 2 | 3 | Mode |
-| --- | --- | --- | --- |
-| 0 | 0 | 0 | Mode 1 |
-| 0 | 0 | 1 | Mode 1 |
-| 0 | 1 | 0 | Mode 2 |
-| 0 | 1 | 1 | Mode 3 |
-| 1 | 0 | 0 | Mode 4 |
-| 1 | 0 | 1 | Mode 5 |
-| 1 | 1 | 0 | Mode 1 |
-| 1 | 1 | 1 | Mode 1 |
-
-### Mode 1 Radio Push Button
-
-In this mode the radio switch (switch 8 on the switch pack) represents a momentary push button. A HID report is generated when the switch transitions to the On state (switch down).
-
-### Mode 2 Radio Push Button & LED
-
-In this mode the radio switch (switch 8 on the switch pack) represents a momentary push button. A HID report is generated when the switch transitions to the On state (switch down). In addition, the LED array will reflect the state of the Radio LED: either all on or all off (note that the top 2 LEDs never illuminate as these are not wired in).
-
-### Mode 3 Radio Slider Switch
-
-In this mode the radio switch (switch 8 on the switch pack) represents a momentary push button. A HID report is generated when the switch transitions to the On state (switch down).
-
-### Mode 4 Radio Slider Switch & LED
-
-In this mode the radio switch (switch 8 on the switch pack) represents an A-B slider switch. A HID report is generated in both cases: when the switch transitions to the On state (switch down) and to the Off state (switch up). In addition the LED array will reflect the state of the Radio LED: either all on or all off (note that the top 2 LEDs never illuminate as these are not wired in).
-
-### Mode 5 LED only
-
-In this mode the radio switch (switch 8 on the switch pack) is ignored. The LED array will reflect the state of the Radio LED: either all on or all off (note that the top 2 LEDs never illuminate as these are not wired in).
diff --git a/network/radio/HidSwitchDriverSample/RadioSwitchHidUsbFx2.h b/network/radio/HidSwitchDriverSample/RadioSwitchHidUsbFx2.h
deleted file mode 100644
index ce92cfff..00000000
--- a/network/radio/HidSwitchDriverSample/RadioSwitchHidUsbFx2.h
+++ /dev/null
@@ -1,156 +0,0 @@
-#ifndef _RADIOSWITCHHIDUSBFX2_H_
-#define _RADIOSWITCHHIDUSBFX2_H_
-
-#include <initguid.h>
-#include <wdm.h>
-#include "usbdi.h"
-#include "usbdlib.h"
-#include <wdf.h>
-#include "wdfusb.h"
-#include <hidport.h>
-#define NTSTRSAFE_LIB
-#include <ntstrsafe.h>
-#include "trace.h"
-
-
-#define HID_CLASS_SPEC_RELEASE_1_00 0x0100 // HID Class Specification release 1.00
-#define HID_COUNTRY_NON_LOCALIZED 0x00 // Hardware is not localized
-
-#define GENERIC_DESKTOP_REPORT_ID 0x01
-
-#define GENERIC_DESKTOP_USAGE_PAGE 0x01
-#define WIRELESS_RADIO_CONTROLS_USAGE 0x0C
-#define WIRELESS_RADIO_BUTTON_USAGE 0xC6
-#define WIRELESS_RADIO_LED_USAGE 0xC7
-#define WIRELESS_RADIO_SLIDER_USAGE 0xC8
-
-
-#define MODE_SELECTION_BUTTONS_BIT_MASK 0xE0
-#define RADIO_SWITCH_BUTTONS_BIT_MASK 0x01
-#define SWITCHPACK_SELECTION_FOR_MODE2 0x40
-#define SWITCHPACK_SELECTION_FOR_MODE3 0x60
-#define SWITCHPACK_SELECTION_FOR_MODE4 0x80
-#define SWITCHPACK_SELECTION_FOR_MODE5 0xA0
-
-#define INTERRUPT_ENDPOINT_INDEX (0)
-
-#define SWITCHPACK_DEBOUNCE_TIME 10 // in millseconds
-
-// Define the vendor commands supported by device
-#define HIDFX2_READ_SWITCH_STATE 0xD6
-#define HIDFX2_READ_7SEGMENT_DISPLAY 0xD4
-#define HIDFX2_READ_BARGRAPH_DISPLAY 0xD7
-#define HIDFX2_SET_BARGRAPH_DISPLAY 0xD8
-#define HIDFX2_IS_HIGH_SPEED 0xD9
-#define HIDFX2_REENUMERATE 0xDA
-#define HIDFX2_SET_7SEGMENT_DISPLAY 0xDB
-
-// Bit masks for 7 segment display to be used with vendor command
-#define SEG_TOP 0x1
-#define SEG_R_UPPER 0x2
-#define SEG_R_LOWER 0x4
-#define SEG_DOT 0x8
-#define SEG_L_LOWER 0x10
-#define SEG_MID 0x20
-#define SEG_L_UPPER 0x40
-#define SEG_BASE 0x80
-
-#define SEGMENT_DISPLAY_1 SEG_R_UPPER | SEG_R_LOWER
-#define SEGMENT_DISPLAY_2 SEG_TOP | SEG_R_UPPER | SEG_MID | SEG_L_LOWER | SEG_BASE
-#define SEGMENT_DISPLAY_3 SEG_TOP | SEG_R_UPPER | SEG_MID | SEG_R_LOWER | SEG_BASE
-#define SEGMENT_DISPLAY_4 SEG_R_UPPER | SEG_R_LOWER | SEG_MID | SEG_L_UPPER
-#define SEGMENT_DISPLAY_5 SEG_TOP | SEG_R_LOWER | SEG_MID | SEG_L_UPPER | SEG_BASE
-#define SEGMENT_DISPLAY_6 SEG_TOP | SEG_R_LOWER | SEG_L_LOWER | SEG_MID | SEG_L_UPPER | SEG_BASE
-#define SEGMENT_DISPLAY_7 SEG_TOP | SEG_R_UPPER | SEG_R_LOWER
-#define SEGMENT_DISPLAY_8 SEG_TOP | SEG_R_UPPER | SEG_R_LOWER | SEG_L_UPPER | SEG_L_LOWER | SEG_MID | SEG_BASE
-
-#define BARGRAPH_LED_ALL_ON 0xff
-#define BARGRAPH_LED_ALL_OFF 0x00
-
-
-typedef UCHAR HID_REPORT_DESCRIPTOR, *PHID_REPORT_DESCRIPTOR;
-
-#include <pshpack1.h> // make sure packing is handled correctly
-
-typedef struct _HIDFX2_IO_REPORT
-{
- unsigned char bReportId; //Report ID for the collection
- unsigned char bData; //one-byte data for switch/LED
-}HIDFX2_IO_REPORT, *PHIDFX2_IO_REPORT;
-
-
-typedef enum _DRIVER_MODE
-{
- DM_BUTTON = 1,
- DM_BUTTON_AND_LED,
- DM_SLIDER_SWITCH,
- DM_SLIDER_SWITCH_AND_LED,
- DM_LED_ONLY
-} DRIVER_MODE;
-
-#include <poppack.h>
-
-typedef struct _DEVICE_EXTENSION
-{
- WDFUSBDEVICE hUsbDevice; //WDF handles for USB Target
- WDFUSBINTERFACE hUsbInterface;
- WDFUSBPIPE hInterruptPipe;
- WDFMEMORY hDeviceDescriptor; // Device descriptor for the USB device
- unsigned char bCurrentSwitchState; // Switch state.
- unsigned char bLatestToggledSwitch; // State for the switch that got toggled most recently
- BOOLEAN fIsPowerUpSwitchState; //Interrupt endpoints sends switch state when first started .we ignore this
- WDFTIMER hDebounceTimer; // Handle debouncing of switchpack
- WDFQUEUE hInterruptMsgQueue; // WDF Queue for read IOCTLs from hidclass that get satisfied from USB interrupt endpoint
- DRIVER_MODE driverMode;
-} DEVICE_EXTENSION, *PDEVICE_EXTENSION;
-
-WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(DEVICE_EXTENSION, GetDeviceContext)
-
-
-//
-// Driver routines
-//
-DRIVER_INITIALIZE DriverEntry;
-
-EVT_WDF_DRIVER_DEVICE_ADD HidFx2EvtDeviceAdd;
-
-EVT_WDF_IO_QUEUE_IO_INTERNAL_DEVICE_CONTROL HidFx2EvtInternalDeviceControl;
-
-EVT_WDF_DEVICE_PREPARE_HARDWARE HidFx2EvtDevicePrepareHardware;
-
-EVT_WDF_DEVICE_D0_ENTRY HidFx2EvtDeviceD0Entry;
-
-EVT_WDF_DEVICE_D0_EXIT HidFx2EvtDeviceD0Exit;
-
-EVT_WDF_USB_READER_COMPLETION_ROUTINE HidFx2EvtUsbInterruptPipeReadComplete;
-
-EVT_WDF_TIMER HidFx2EvtTimerFunction;
-
-EVT_WDF_OBJECT_CONTEXT_CLEANUP HidFx2EvtDriverContextCleanup;
-
-EVT_WDF_IO_QUEUE_IO_CANCELED_ON_QUEUE HidFx2EvtIoCanceledOnQueue;
-
-
-NTSTATUS HidFx2GetHidDescriptor(_In_ WDFDEVICE hDevice, _In_ WDFREQUEST hRequest);
-
-NTSTATUS HidFx2GetReportDescriptor(_In_ WDFDEVICE hDevice, _In_ WDFREQUEST hRequest);
-
-NTSTATUS HidFx2GetDeviceAttributes(_In_ WDFREQUEST hRequest);
-
-NTSTATUS HidFx2ConfigContReaderForInterruptEndPoint(PDEVICE_EXTENSION pDeviceContext);
-
-NTSTATUS HidFx2SendIdleNotification(_In_ WDFREQUEST hRequest);
-
-NTSTATUS HidFx2SetOutput(_In_ WDFREQUEST hRequest);
-
-NTSTATUS HidFx2GetInput(_In_ WDFREQUEST hRequest);
-
-NTSTATUS HidFx2GetSwitchState(_In_ WDFDEVICE hDevice, _Out_ unsigned char *pbSwitchState);
-
-NTSTATUS SendVendorCommand(_In_ WDFDEVICE hDevice, _In_ unsigned char bVendorCommand, _In_ unsigned char bCommandData);
-
-PCWSTR DbgDevicePowerString(_In_ WDF_POWER_DEVICE_STATE powerState);
-
-#endif //_RADIOSWITCHHIDUSBFX2_H_
-
-
diff --git a/network/radio/HidSwitchDriverSample/RadioSwitchHidUsbFx2.inx b/network/radio/HidSwitchDriverSample/RadioSwitchHidUsbFx2.inx
deleted file mode 100644
index a9cf9004..00000000
--- a/network/radio/HidSwitchDriverSample/RadioSwitchHidUsbFx2.inx
+++ /dev/null
Binary files differ
diff --git a/network/radio/HidSwitchDriverSample/RadioSwitchHidUsbFx2.rc b/network/radio/HidSwitchDriverSample/RadioSwitchHidUsbFx2.rc
deleted file mode 100644
index 6737f603..00000000
--- a/network/radio/HidSwitchDriverSample/RadioSwitchHidUsbFx2.rc
+++ /dev/null
@@ -1,11 +0,0 @@
-#include <windows.h>
-
-#include <ntverp.h>
-
-#define VER_FILETYPE VFT_DRV
-#define VER_FILESUBTYPE VFT2_DRV_SYSTEM
-#define VER_FILEDESCRIPTION_STR "HID Radio Switch mini driver for USB Fx2 Device"
-#define VER_INTERNALNAME_STR "RadioSwitchHidUsbFx2.sys"
-
-#include "common.ver"
-
diff --git a/network/radio/HidSwitchDriverSample/RadioSwitchHidUsbFx2.vcxproj b/network/radio/HidSwitchDriverSample/RadioSwitchHidUsbFx2.vcxproj
deleted file mode 100644
index 84bbb1ea..00000000
--- a/network/radio/HidSwitchDriverSample/RadioSwitchHidUsbFx2.vcxproj
+++ /dev/null
@@ -1,193 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup Label="ProjectConfigurations">
- <ProjectConfiguration Include="Debug|Win32">
- <Configuration>Debug</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|Win32">
- <Configuration>Release</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug|x64">
- <Configuration>Debug</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|x64">
- <Configuration>Release</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- </ItemGroup>
- <PropertyGroup Label="Globals">
- <ProjectGuid>{43FD9C1A-290E-4FF7-8B6F-35A88A075DF8}</ProjectGuid>
- <RootNamespace>$(MSBuildProjectName)</RootNamespace>
- <KMDF_VERSION_MAJOR>1</KMDF_VERSION_MAJOR>
- <Configuration Condition="'$(Configuration)' == ''">Debug</Configuration>
- <Platform Condition="'$(Platform)' == ''">Win32</Platform>
- <SampleGuid>{88093BCB-F03A-40B7-B648-891643B48CC0}</SampleGuid>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
- <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- <TargetVersion>Windows10</TargetVersion>
- <UseDebugLibraries>False</UseDebugLibraries>
- <DriverTargetPlatform>Universal</DriverTargetPlatform>
- <DriverType>KMDF</DriverType>
- <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>
- <ConfigurationType>Driver</ConfigurationType>
- </PropertyGroup>
- <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <TargetVersion>Windows10</TargetVersion>
- <UseDebugLibraries>True</UseDebugLibraries>
- <DriverTargetPlatform>Universal</DriverTargetPlatform>
- <DriverType>KMDF</DriverType>
- <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>
- <ConfigurationType>Driver</ConfigurationType>
- </PropertyGroup>
- <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <TargetVersion>Windows10</TargetVersion>
- <UseDebugLibraries>False</UseDebugLibraries>
- <DriverTargetPlatform>Universal</DriverTargetPlatform>
- <DriverType>KMDF</DriverType>
- <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>
- <ConfigurationType>Driver</ConfigurationType>
- </PropertyGroup>
- <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <TargetVersion>Windows10</TargetVersion>
- <UseDebugLibraries>True</UseDebugLibraries>
- <DriverTargetPlatform>Universal</DriverTargetPlatform>
- <DriverType>KMDF</DriverType>
- <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>
- <ConfigurationType>Driver</ConfigurationType>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
- <PropertyGroup>
- <OutDir>$(IntDir)</OutDir>
- </PropertyGroup>
- <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" />
- </ImportGroup>
- <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" />
- </ImportGroup>
- <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" />
- </ImportGroup>
- <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" />
- </ImportGroup>
- <ItemGroup Label="WrappedTaskItems">
- <ClCompile Include="driver.c; hid.c; usb.c">
- <WppEnabled>true</WppEnabled>
- <WppKernelMode>true</WppKernelMode>
- <WppTraceFunction>TraceEvents(LEVEL,FLAGS,MSG,...);TraceErr{LEVEL=TRACE_LEVEL_ERROR}(FLAGS,MSG,...);TraceWarning{LEVEL=TRACE_LEVEL_WARNING}(FLAGS,MSG,...);TraceInfo{LEVEL=TRACE_LEVEL_INFORMATION}(FLAGS,MSG,...);TraceVerbose{LEVEL=TRACE_LEVEL_VERBOSE}(FLAGS,MSG,...)</WppTraceFunction>
- <WppGenerateUsingTemplateFile>{km-WdfDefault.tpl}*.tmh</WppGenerateUsingTemplateFile>
- </ClCompile>
- <Inf Include=".\RadioSwitchHidUsbFx2.inx">
- <Architecture>$(InfArch)</Architecture>
- <SpecifyArchitecture>true</SpecifyArchitecture>
- <CopyOutput>.\$(IntDir)\RadioSwitchHidUsbFx2.inf</CopyOutput>
- </Inf>
- <OtherWpp Include="RadioSwitchHidUsbFx2.rc">
- <WppEnabled>true</WppEnabled>
- <WppKernelMode>true</WppKernelMode>
- <WppTraceFunction>TraceEvents(LEVEL,FLAGS,MSG,...);TraceErr{LEVEL=TRACE_LEVEL_ERROR}(FLAGS,MSG,...);TraceWarning{LEVEL=TRACE_LEVEL_WARNING}(FLAGS,MSG,...);TraceInfo{LEVEL=TRACE_LEVEL_INFORMATION}(FLAGS,MSG,...);TraceVerbose{LEVEL=TRACE_LEVEL_VERBOSE}(FLAGS,MSG,...)</WppTraceFunction>
- <WppGenerateUsingTemplateFile>{km-WdfDefault.tpl}*.tmh</WppGenerateUsingTemplateFile>
- </OtherWpp>
- </ItemGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- <TargetName>RadioSwitchHidUsbFx2</TargetName>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <TargetName>RadioSwitchHidUsbFx2</TargetName>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <TargetName>RadioSwitchHidUsbFx2</TargetName>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <TargetName>RadioSwitchHidUsbFx2</TargetName>
- </PropertyGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- <Link>
- <AdditionalDependencies>%(AdditionalDependencies);$(DDK_LIB_PATH)\hidclass.lib;$(DDK_LIB_PATH)\ntstrsafe.lib</AdditionalDependencies>
- </Link>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <Link>
- <AdditionalDependencies>%(AdditionalDependencies);$(DDK_LIB_PATH)\hidclass.lib;$(DDK_LIB_PATH)\ntstrsafe.lib</AdditionalDependencies>
- </Link>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <Link>
- <AdditionalDependencies>%(AdditionalDependencies);$(DDK_LIB_PATH)\hidclass.lib;$(DDK_LIB_PATH)\ntstrsafe.lib</AdditionalDependencies>
- </Link>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <Link>
- <AdditionalDependencies>%(AdditionalDependencies);$(DDK_LIB_PATH)\hidclass.lib;$(DDK_LIB_PATH)\ntstrsafe.lib</AdditionalDependencies>
- </Link>
- </ItemDefinitionGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- <ALLOW_DATE_TIME>1</ALLOW_DATE_TIME>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <ALLOW_DATE_TIME>1</ALLOW_DATE_TIME>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <ALLOW_DATE_TIME>1</ALLOW_DATE_TIME>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <ALLOW_DATE_TIME>1</ALLOW_DATE_TIME>
- </PropertyGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- <ClCompile>
- <ExceptionHandling>
- </ExceptionHandling>
- </ClCompile>
- <DriverSign>
- <FileDigestAlgorithm>sha256</FileDigestAlgorithm>
- </DriverSign>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <ClCompile>
- <ExceptionHandling>
- </ExceptionHandling>
- </ClCompile>
- <DriverSign>
- <FileDigestAlgorithm>sha256</FileDigestAlgorithm>
- </DriverSign>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <ClCompile>
- <ExceptionHandling>
- </ExceptionHandling>
- </ClCompile>
- <DriverSign>
- <FileDigestAlgorithm>sha256</FileDigestAlgorithm>
- </DriverSign>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <ClCompile>
- <ExceptionHandling>
- </ExceptionHandling>
- </ClCompile>
- <DriverSign>
- <FileDigestAlgorithm>sha256</FileDigestAlgorithm>
- </DriverSign>
- </ItemDefinitionGroup>
- <ItemGroup>
- <ResourceCompile Include="RadioSwitchHidUsbFx2.rc" />
- </ItemGroup>
- <ItemGroup>
- <Inf Exclude="@(Inf)" Include="*.inf" />
- <FilesToPackage Include="$(TargetPath)" Condition="'$(ConfigurationType)'=='Driver' or '$(ConfigurationType)'=='DynamicLibrary'" />
- </ItemGroup>
- <ItemGroup>
- <None Exclude="@(None)" Include="*.txt;*.htm;*.html" />
- <None Exclude="@(None)" Include="*.ico;*.cur;*.bmp;*.dlg;*.rct;*.gif;*.jpg;*.jpeg;*.wav;*.jpe;*.tiff;*.tif;*.png;*.rc2" />
- <None Exclude="@(None)" Include="*.def;*.bat;*.hpj;*.asmx" />
- </ItemGroup>
- <ItemGroup>
- <ClInclude Exclude="@(ClInclude)" Include="*.h;*.hpp;*.hxx;*.hm;*.inl;*.xsd" />
- </ItemGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
-</Project> \ No newline at end of file
diff --git a/network/radio/HidSwitchDriverSample/RadioSwitchHidUsbFx2.vcxproj.Filters b/network/radio/HidSwitchDriverSample/RadioSwitchHidUsbFx2.vcxproj.Filters
deleted file mode 100644
index b8f7cb14..00000000
--- a/network/radio/HidSwitchDriverSample/RadioSwitchHidUsbFx2.vcxproj.Filters
+++ /dev/null
@@ -1,50 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup>
- <Filter Include="Source Files">
- <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx;*</Extensions>
- <UniqueIdentifier>{652E78B0-5E7D-4A38-BAF7-486EBD37CAF8}</UniqueIdentifier>
- </Filter>
- <Filter Include="Header Files">
- <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
- <UniqueIdentifier>{D1C9D70E-E910-4C53-9624-EB5A85A5A36B}</UniqueIdentifier>
- </Filter>
- <Filter Include="Resource Files">
- <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms;man;xml</Extensions>
- <UniqueIdentifier>{91962FEB-66CF-4C7D-A911-BA196B70A87A}</UniqueIdentifier>
- </Filter>
- <Filter Include="Driver Files">
- <Extensions>inf;inv;inx;mof;mc;</Extensions>
- <UniqueIdentifier>{DCB61952-1CBD-4DF7-A231-3432A7250271}</UniqueIdentifier>
- </Filter>
- </ItemGroup>
- <ItemGroup>
- <ClCompile Include="driver.c; hid.c; usb.c">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="driver.c; hid.c; usb.c">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="driver.c; hid.c; usb.c">
- <Filter>Source Files</Filter>
- </ClCompile>
- </ItemGroup>
- <ItemGroup>
- <Inf Include=".\RadioSwitchHidUsbFx2.inx">
- <Filter>Driver Files</Filter>
- </Inf>
- </ItemGroup>
- <ItemGroup>
- <ResourceCompile Include="RadioSwitchHidUsbFx2.rc">
- <Filter>Resource Files</Filter>
- </ResourceCompile>
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="*.h;*.hpp;*.hxx;*.hm;*.inl;*.xsd">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="*.h;*.hpp;*.hxx;*.hm;*.inl;*.xsd">
- <Filter>Header Files</Filter>
- </ClInclude>
- </ItemGroup>
-</Project> \ No newline at end of file
diff --git a/network/radio/HidSwitchDriverSample/driver.c b/network/radio/HidSwitchDriverSample/driver.c
deleted file mode 100644
index 61cc97fc..00000000
--- a/network/radio/HidSwitchDriverSample/driver.c
+++ /dev/null
@@ -1,156 +0,0 @@
-#include "RadioSwitchHidUsbFx2.h"
-#pragma warning(disable:28252)
-#pragma warning(disable:28253)
-#include "driver.tmh"
-
-
-#ifdef ALLOC_PRAGMA
- #pragma alloc_text(INIT, DriverEntry)
- #pragma alloc_text(PAGE, HidFx2EvtDriverContextCleanup)
- #pragma alloc_text(PAGE, HidFx2EvtDeviceAdd)
-#endif
-
-
-
-//Installable driver initialization entry point. This entry point is called directly by the I/O system.
-//
-NTSTATUS DriverEntry (_In_ PDRIVER_OBJECT pDriverObject, _In_ PUNICODE_STRING pszRegistryPath)
-{
- NTSTATUS status = STATUS_SUCCESS;
- WDF_DRIVER_CONFIG config;
- WDF_OBJECT_ATTRIBUTES attributes;
-
-
- // Initialize WPP Tracing
- WPP_INIT_TRACING(pDriverObject, pszRegistryPath);
-
- TraceInfo(DBG_INIT, "(%!FUNC!) Enter -DriverEntry\n");
-
- WDF_DRIVER_CONFIG_INIT(&config, HidFx2EvtDeviceAdd);
-
- // Register a cleanup callback so that we can call WPP_CLEANUP when the framework driver object is deleted during driver unload.
- WDF_OBJECT_ATTRIBUTES_INIT(&attributes);
- attributes.EvtCleanupCallback = HidFx2EvtDriverContextCleanup;
-
- // Create a framework driver object to represent our driver.
- status = WdfDriverCreate(pDriverObject,
- pszRegistryPath,
- &attributes, // Driver Attributes
- &config, // Driver Config Info
- WDF_NO_HANDLE
- );
- if (!NT_SUCCESS(status))
- {
- TraceErr(DBG_INIT, "(%!FUNC!)WdfDriverCreate failed with status %!STATUS!\n", status);
- WPP_CLEANUP(pDriverObject);
- }
-
- TraceVerbose(DBG_INIT, "(%!FUNC!) Exit\n");
- return status;
-}
-
-
-
-//Free resources allocated in DriverEntry that are not automatically cleaned up framework.
-//
-void HidFx2EvtDriverContextCleanup(_In_ WDFOBJECT hDriver)
-{
- PAGED_CODE ();
-
- TraceVerbose(DBG_INIT, "(%!FUNC!) Enter/Exit\n");
-
- WPP_CLEANUP(WdfDriverWdmGetDriverObject(hDriver));
-}
-
-
-
-//HidFx2EvtDeviceAdd is called by the framework in response to AddDevicecall from the PnP manager.
-//We create and initialize a WDF device object to represent a new instance of device.
-//
-NTSTATUS HidFx2EvtDeviceAdd(_In_ WDFDRIVER hDriver, _Inout_ PWDFDEVICE_INIT pDeviceInit)
-{
- NTSTATUS status = STATUS_SUCCESS;
- WDF_IO_QUEUE_CONFIG queueConfig;
- WDF_OBJECT_ATTRIBUTES attributes;
- WDFDEVICE hDevice;
- PDEVICE_EXTENSION pDevContext = NULL;
- WDFQUEUE hQueue;
- WDF_PNPPOWER_EVENT_CALLBACKS pnpPowerCallbacks;
- WDF_TIMER_CONFIG timerConfig;
- WDFTIMER hTimer;
-
- UNREFERENCED_PARAMETER(hDriver);
-
- PAGED_CODE();
-
- TraceVerbose(DBG_PNP, "(%!FUNC!) Enter\n");
-
- // Tell framework this is a filter driver.
- WdfFdoInitSetFilter(pDeviceInit);
-
- // Initialize pnp-power callbacks, attributes and a context area for the device object.
- WDF_PNPPOWER_EVENT_CALLBACKS_INIT(&pnpPowerCallbacks);
-
- // For usb devices, PrepareHardware callback is the to place select the interface and configure the device.
- pnpPowerCallbacks.EvtDevicePrepareHardware = HidFx2EvtDevicePrepareHardware;
-
- // These two callbacks start and stop the wdfusb pipe continuous reader as we go in and out of the D0-working state.
- pnpPowerCallbacks.EvtDeviceD0Entry = HidFx2EvtDeviceD0Entry;
- pnpPowerCallbacks.EvtDeviceD0Exit = HidFx2EvtDeviceD0Exit;
-
- WdfDeviceInitSetPnpPowerEventCallbacks(pDeviceInit, &pnpPowerCallbacks);
-
- WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&attributes, DEVICE_EXTENSION);
-
- // Create a framework device object.This call will in turn create a WDM device object, attach to the lower stack.
- status = WdfDeviceCreate(&pDeviceInit, &attributes, &hDevice);
- if (!NT_SUCCESS(status))
- {
- TraceErr(DBG_PNP, "(%!FUNC!) WdfDeviceCreate failed with status code %!STATUS!\n", status);
- return status;
- }
-
- pDevContext = GetDeviceContext(hDevice);
-
- WDF_IO_QUEUE_CONFIG_INIT_DEFAULT_QUEUE(&queueConfig, WdfIoQueueDispatchParallel);
- queueConfig.EvtIoInternalDeviceControl = HidFx2EvtInternalDeviceControl;
-
- status = WdfIoQueueCreate(hDevice, &queueConfig, WDF_NO_OBJECT_ATTRIBUTES, &hQueue);
- if (!NT_SUCCESS (status))
- {
- TraceErr(DBG_PNP, "(%!FUNC!) WdfIoQueueCreate failed 0x%x\n", status);
- return status;
- }
-
- // Register a manual I/O queue for handling Interrupt Message Read Requests.
- WDF_IO_QUEUE_CONFIG_INIT(&queueConfig, WdfIoQueueDispatchManual);
-
- // This queue is used for requests that dont directly access the device.
- // The requests in this queue are serviced only when the device is in a fully powered state and sends an interrupt.
- queueConfig.PowerManaged = WdfFalse;
-
- status = WdfIoQueueCreate(hDevice, &queueConfig, WDF_NO_OBJECT_ATTRIBUTES, &pDevContext->hInterruptMsgQueue);
- if (!NT_SUCCESS(status))
- {
- TraceErr(DBG_PNP, "(%!FUNC!) WdfIoQueueCreate failed %!STATUS!\n", status);
- return status;
- }
-
- // Create a timer to handle debouncing of switchpack
- WDF_TIMER_CONFIG_INIT(&timerConfig, HidFx2EvtTimerFunction);
- timerConfig.AutomaticSerialization = FALSE;
-
- WDF_OBJECT_ATTRIBUTES_INIT(&attributes);
- attributes.ParentObject = hDevice;
- status = WdfTimerCreate(&timerConfig, &attributes, &hTimer);
- if (!NT_SUCCESS(status))
- {
- TraceErr(DBG_PNP, "(%!FUNC!) WdfTimerCreate failed status:%!STATUS!\n", status);
- return status;
- }
-
- pDevContext->hDebounceTimer = hTimer;
-
- TraceVerbose(DBG_PNP, "(%!FUNC!) Exit\n");
- return status;
-}
diff --git a/network/radio/HidSwitchDriverSample/hid.c b/network/radio/HidSwitchDriverSample/hid.c
deleted file mode 100644
index 2421b88f..00000000
--- a/network/radio/HidSwitchDriverSample/hid.c
+++ /dev/null
@@ -1,659 +0,0 @@
-#include "RadioSwitchHidUsbFx2.h"
-#include "hid.tmh"
-
-// Radio Management Collection - Scenario 1 control collection (Button only)
-//
-const HID_REPORT_DESCRIPTOR c_ButtonDescriptor[] = {
- 0x05, GENERIC_DESKTOP_USAGE_PAGE, // USAGE_PAGE (Generic Desktop)
- 0x09, WIRELESS_RADIO_CONTROLS_USAGE,// USAGE (Wireless Radio Controls)
- 0xA1, 0x01, // COLLECTION (Application)
- 0x85, GENERIC_DESKTOP_REPORT_ID, // REPORT_ID
- 0x15, 0x00, // LOGICAL_MINIMUM(0)
- 0x25, 0x01, // LOGICAL_MAXIMUM(1)
- //
- 0x09, WIRELESS_RADIO_BUTTON_USAGE, // USAGE (Wireless Radio Button)
- 0x95, 0x01, // REPORT_COUNT (1)
- 0x75, 0x01, // REPORT_SIZE (1)
- 0x81, 0x06, // INPUT (Data, Variable, Rel) - button bit
- 0x75, 0x07, // REPORT_SIZE (7)
- 0x81, 0x03, // INPUT (const, var, abs) -7 bits of padding
- 0xC0 // END_COLLECTION
-};
-
-
-// Radio Management Collection - Scenario 2 control collection (Button with LED)
-//
-const HID_REPORT_DESCRIPTOR c_ButtonWithLedDescriptor[] = {
- 0x05, GENERIC_DESKTOP_USAGE_PAGE, // USAGE_PAGE (Generic Desktop)
- 0x09, WIRELESS_RADIO_CONTROLS_USAGE,// USAGE (Wireless Radio Controls)
- 0xA1, 0x01, // COLLECTION (Application)
- 0x85, GENERIC_DESKTOP_REPORT_ID, // REPORT_ID
- 0x15, 0x00, // LOGICAL_MINIMUM(0)
- 0x25, 0x01, // LOGICAL_MAXIMUM(1)
- //
- 0x09, WIRELESS_RADIO_BUTTON_USAGE, // USAGE (Wireless Radio Button)
- 0x95, 0x01, // REPORT_COUNT (1)
- 0x75, 0x01, // REPORT_SIZE (1)
- 0x81, 0x06, // INPUT (Data, Variable, Rel) - button bit
- 0x75, 0x07, // REPORT_SIZE (7)
- 0x81, 0x03, // INPUT (const, var, abs) -7 bits of padding
- //
- 0x09, WIRELESS_RADIO_LED_USAGE, // USAGE (Wireless Radio LED)
- 0x75, 0x01, // REPORT_SIZE (1)
- 0x91, 0x02, // OUTPUT (Data, Variable, Rel) -led bit
- 0x75, 0x07, // REPORT_SIZE (7)
- 0x91, 0x03, // OUTPUT (const, var, abs) -7 bits of padding
- 0xC0 // END_COLLECTION
-};
-
-
-// Radio Management Collection - Scenario 3 control collection (Slider Switch)
-//
-const HID_REPORT_DESCRIPTOR c_SliderSwitchDescriptor[] = {
- 0x05, GENERIC_DESKTOP_USAGE_PAGE, // USAGE_PAGE (Generic Desktop)
- 0x09, WIRELESS_RADIO_CONTROLS_USAGE,// USAGE (Wireless Radio Controls)
- 0xA1, 0x01, // COLLECTION (Application)
- 0x85, GENERIC_DESKTOP_REPORT_ID, // REPORT_ID
- 0x15, 0x00, // LOGICAL_MINIMUM(0)
- 0x25, 0x01, // LOGICAL_MAXIMUM(1)
- //
- 0x09, WIRELESS_RADIO_SLIDER_USAGE, // USAGE (Wireless Radio Slider Switch)
- 0x95, 0x01, // REPORT_COUNT (1)
- 0x75, 0x01, // REPORT_SIZE (1)
- 0x81, 0x02, // INPUT (Data, Variable, Abs) -switch bit
- 0x75, 0x07, // REPORT_SIZE (7)
- 0x81, 0x03, // INPUT (const, var, abs) -7 bits of padding
- 0xC0 // END_COLLECTION
-};
-
-
-// Radio Management Collection - Scenario 4 control collection (Slider Switch with LED)
-//
-const HID_REPORT_DESCRIPTOR c_SliderSwitchWithLedDescriptor[] = {
- 0x05, GENERIC_DESKTOP_USAGE_PAGE, // USAGE_PAGE (Generic Desktop)
- 0x09, WIRELESS_RADIO_CONTROLS_USAGE,// USAGE (Wireless Radio Controls)
- 0xA1, 0x01, // COLLECTION (Application)
- 0x85, GENERIC_DESKTOP_REPORT_ID, // REPORT_ID
- 0x15, 0x00, // LOGICAL_MINIMUM(0)
- 0x25, 0x01, // LOGICAL_MAXIMUM(1)
- //
- 0x09, WIRELESS_RADIO_SLIDER_USAGE, // USAGE (Wireless Radio Slider Switch)
- 0x95, 0x01, // REPORT_COUNT (1)
- 0x75, 0x01, // REPORT_SIZE (1)
- 0x81, 0x02, // INPUT (Data, Variable, Abs) -switch bit
- 0x75, 0x07, // REPORT_SIZE (7)
- 0x81, 0x03, // INPUT (const, var, abs) -7 bits of padding
- //
- 0x09, WIRELESS_RADIO_LED_USAGE, // USAGE (Wireless Radio LED)
- 0x75, 0x01, // REPORT_SIZE (1)
- 0x91, 0x02, // OUTPUT (Data, Variable, Rel) -led bit
- 0x75, 0x07, // REPORT_SIZE (7)
- 0x91, 0x03, // OUTPUT (const, var, abs) -7 bits of padding
- 0xC0 // END_COLLECTION
-};
-
-
-// Radio Management Collection - Scenario 5 control collection (LED only)
-//
-const HID_REPORT_DESCRIPTOR c_LedOnlyDescriptor[] = {
- 0x05, GENERIC_DESKTOP_USAGE_PAGE, // USAGE_PAGE (Generic Desktop)
- 0x09, WIRELESS_RADIO_CONTROLS_USAGE,// USAGE (Wireless Radio Controls)
- 0xA1, 0x01, // COLLECTION (Application)
- 0x85, GENERIC_DESKTOP_REPORT_ID, // REPORT_ID
- 0x15, 0x00, // LOGICAL_MINIMUM(0)
- 0x25, 0x01, // LOGICAL_MAXIMUM(1)
- //
- 0x09, WIRELESS_RADIO_LED_USAGE, // USAGE (Wireless Radio LED)
- 0x95, 0x01, // REPORT_COUNT (1)
- 0x75, 0x01, // REPORT_SIZE (1)
- 0x91, 0x02, // OUTPUT (Data, Variable, Rel) -led bit
- 0x75, 0x07, // REPORT_SIZE (7)
- 0x91, 0x03, // OUTPUT (const, var, abs) -7 bits of padding
- 0xC0 // END_COLLECTION
-};
-
-
-#ifdef ALLOC_PRAGMA
- #pragma alloc_text(PAGE, HidFx2SetOutput)
- #pragma alloc_text(PAGE, HidFx2GetInput)
- #pragma alloc_text(PAGE, SendVendorCommand)
-#endif
-
-
-// This event is called when the framework receives IRP_MJ_INTERNAL DEVICE_CONTROL requests from the system.
-//
-void HidFx2EvtInternalDeviceControl(
- _In_ WDFQUEUE hQueue,
- _In_ WDFREQUEST hRequest,
- _In_ size_t cOutputBufferLength,
- _In_ size_t cInputBufferLength,
- _In_ ULONG ulIoControlCode
- )
-{
- NTSTATUS status = STATUS_SUCCESS;
- WDFDEVICE hDevice;
- PDEVICE_EXTENSION pDevContext = NULL;
-
- UNREFERENCED_PARAMETER(cOutputBufferLength);
- UNREFERENCED_PARAMETER(cInputBufferLength);
-
- TraceVerbose(DBG_IOCTL, "(%!FUNC!) Enter\n");
-
- hDevice = WdfIoQueueGetDevice(hQueue);
- pDevContext = GetDeviceContext(hDevice);
-
- TraceInfo(DBG_IOCTL, "(%!FUNC!) Queue:0x%p, Request:0x%p\n", hQueue, hRequest);
-
- switch (ulIoControlCode)
- {
- case IOCTL_HID_GET_DEVICE_DESCRIPTOR:
- TraceInfo(DBG_IOCTL, "IOCTL_HID_GET_DEVICE_DESCRIPTOR\n");
- status = HidFx2GetHidDescriptor(hDevice, hRequest);
- WdfRequestComplete(hRequest, status);
- break;
-
- case IOCTL_HID_GET_DEVICE_ATTRIBUTES:
- TraceInfo(DBG_IOCTL, "IOCTL_HID_GET_DEVICE_ATTRIBUTES\n");
- status = HidFx2GetDeviceAttributes(hRequest);
- WdfRequestComplete(hRequest, status);
- break;
-
- case IOCTL_HID_GET_REPORT_DESCRIPTOR:
- TraceInfo(DBG_IOCTL, "IOCTL_HID_GET_REPORT_DESCRIPTOR\n");
- status = HidFx2GetReportDescriptor(hDevice, hRequest);
- WdfRequestComplete(hRequest, status);
- break;
-
- case IOCTL_HID_READ_REPORT:
- TraceInfo(DBG_IOCTL, "IOCTL_HID_READ_REPORT\n");
- status = WdfRequestForwardToIoQueue(hRequest, pDevContext->hInterruptMsgQueue);
- if (!NT_SUCCESS(status))
- {
- TraceErr(DBG_IOCTL, "WdfRequestForwardToIoQueue failed with status: %!STATUS!\n", status);
- WdfRequestComplete(hRequest, status);
- }
- break;
-
- case IOCTL_HID_SEND_IDLE_NOTIFICATION_REQUEST:
- TraceInfo(DBG_IOCTL, "IOCTL_HID_SEND_IDLE_NOTIFICATION_REQUEST\n");
- status = HidFx2SendIdleNotification(hRequest);
- if (!NT_SUCCESS(status))
- {
- TraceErr(DBG_IOCTL, "SendIdleNotification failed with status: %!STATUS!\n", status);
- WdfRequestComplete(hRequest, status);
- }
- break;
-
- case IOCTL_HID_GET_INPUT_REPORT:
- TraceInfo(DBG_IOCTL, "IOCTL_HID_GET_INPUT_REPORT\n");
- HidFx2GetInput(hRequest);
- WdfRequestComplete(hRequest, status);
- break;
-
- case IOCTL_HID_SET_OUTPUT_REPORT:
- TraceInfo(DBG_IOCTL, "IOCTL_HID_SET_OUTPUT_REPORT\n");
- status = HidFx2SetOutput(hRequest);
- WdfRequestComplete(hRequest, status);
- break;
-
- default:
- TraceInfo(DBG_IOCTL, "IOCTL Not Supported 0x%X\n", ulIoControlCode);
- status = STATUS_NOT_SUPPORTED;
- WdfRequestComplete(hRequest, status);
- break;
- }
-
- TraceVerbose(DBG_IOCTL, "(%!FUNC!) Exit\n");
- return;
-}
-
-
-
-NTSTATUS HidFx2GetInput(_In_ WDFREQUEST hRequest)
-{
- NTSTATUS status = STATUS_SUCCESS;
- WDF_REQUEST_PARAMETERS params;
- WDFDEVICE hDevice;
- PHID_XFER_PACKET pTransferPacket = NULL;
- PHIDFX2_IO_REPORT pOutputReport = NULL;
- unsigned char bSwitchState = 0;
-
- PAGED_CODE();
-
- TraceVerbose(DBG_IOCTL, "(%!FUNC!) Enter\n");
-
- hDevice = WdfIoQueueGetDevice(WdfRequestGetIoQueue(hRequest));
-
- WDF_REQUEST_PARAMETERS_INIT(&params);
- WdfRequestGetParameters(hRequest, &params);
-
-
- if (params.Parameters.DeviceIoControl.OutputBufferLength < sizeof(HID_XFER_PACKET))
- {
- status = STATUS_BUFFER_TOO_SMALL;
- TraceErr(DBG_IOCTL, "(%!FUNC!) Userbuffer is small %!STATUS!\n", status);
- return status;
- }
-
- pTransferPacket = (PHID_XFER_PACKET) WdfRequestWdmGetIrp(hRequest)->UserBuffer;
- if (pTransferPacket == NULL)
- {
- status = STATUS_INVALID_DEVICE_REQUEST;
- TraceErr(DBG_IOCTL, "(%!FUNC!) Irp->UserBuffer is NULL %!STATUS!\n", status);
- return status;
- }
-
- if (pTransferPacket->reportBufferLen == 0)
- {
- status = STATUS_BUFFER_TOO_SMALL;
- TraceErr(DBG_IOCTL, "(%!FUNC!) HID_XFER_PACKET->reportBufferLen is 0, %!STATUS!\n", status);
- return status;
- }
-
- if (pTransferPacket->reportBufferLen < sizeof(UCHAR))
- {
- status = STATUS_BUFFER_TOO_SMALL;
- TraceErr(DBG_IOCTL, "(%!FUNC!) HID_XFER_PACKET->reportBufferLen is too small, %!STATUS!\n", status);
- return status;
- }
-
- if (pTransferPacket->reportId != GENERIC_DESKTOP_REPORT_ID)
- {
- status = STATUS_INVALID_DEVICE_REQUEST;
- TraceErr(DBG_IOCTL, "(%!FUNC!) Incorrect report ID, %!STATUS!\n", status);
- return status;
- }
-
- pOutputReport = (PHIDFX2_IO_REPORT)pTransferPacket->reportBuffer;
-
- // Get the switch state directly from the hardware
- status = HidFx2GetSwitchState(hDevice, &bSwitchState);
- TraceVerbose(DBG_IOCTL, "(%!FUNC!) switch state 0x%x\n", bSwitchState);
-
- //Mask off everything except the actual switch bit
- bSwitchState &= RADIO_SWITCH_BUTTONS_BIT_MASK;
- TraceVerbose(DBG_IOCTL, "(%!FUNC!) maskedswitch state 0x%x\n", bSwitchState);
-
- pOutputReport->bReportId = GENERIC_DESKTOP_REPORT_ID;
- pOutputReport->bData = bSwitchState;
-
- TraceVerbose(DBG_IOCTL, "(%!FUNC!) Exit status %!STATUS!\n", status);
- return status;
-}
-
-
-
-NTSTATUS HidFx2SetOutput(_In_ WDFREQUEST hRequest)
-{
- NTSTATUS status = STATUS_SUCCESS;
- PHID_XFER_PACKET pTransferPacket = NULL;
- WDF_REQUEST_PARAMETERS params;
- PHIDFX2_IO_REPORT pOutputReport = NULL;
- WDFDEVICE hDevice;
-
- PAGED_CODE();
-
- TraceVerbose(DBG_IOCTL, "(%!FUNC!) Enter\n");
-
- hDevice = WdfIoQueueGetDevice(WdfRequestGetIoQueue(hRequest));
-
- WDF_REQUEST_PARAMETERS_INIT(&params);
- WdfRequestGetParameters(hRequest, &params);
-
- if (params.Parameters.DeviceIoControl.InputBufferLength < sizeof(HID_XFER_PACKET))
- {
- status = STATUS_BUFFER_TOO_SMALL;
- TraceErr(DBG_IOCTL, "(%!FUNC!) Userbuffer is small %!STATUS!\n", status);
- return status;
- }
-
- pTransferPacket = (PHID_XFER_PACKET) WdfRequestWdmGetIrp(hRequest)->UserBuffer;
- if (pTransferPacket == NULL)
- {
- status = STATUS_INVALID_DEVICE_REQUEST;
- TraceErr(DBG_IOCTL, "(%!FUNC!) Irp->UserBuffer is NULL %!STATUS!\n", status);
- return status;
- }
-
- if (pTransferPacket->reportBufferLen == 0)
- {
- status = STATUS_BUFFER_TOO_SMALL;
- TraceErr(DBG_IOCTL, "(%!FUNC!) HID_XFER_PACKET->reportBufferLen is 0, %!STATUS!\n", status);
- return status;
- }
-
- if (pTransferPacket->reportBufferLen < sizeof(UCHAR))
- {
- status = STATUS_BUFFER_TOO_SMALL;
- TraceErr(DBG_IOCTL, "(%!FUNC!) HID_XFER_PACKET->reportBufferLen is too small, %!STATUS!\n", status);
- return status;
- }
-
- if (pTransferPacket->reportId != GENERIC_DESKTOP_REPORT_ID)
- {
- status = STATUS_INVALID_DEVICE_REQUEST;
- TraceErr(DBG_IOCTL, "(%!FUNC!) Incorrect report ID, %!STATUS!\n", status);
- return status;
- }
-
- pOutputReport = (PHIDFX2_IO_REPORT)pTransferPacket->reportBuffer;
-
- if (pOutputReport->bData == 0)
- {
- status = SendVendorCommand(hDevice, HIDFX2_SET_BARGRAPH_DISPLAY, BARGRAPH_LED_ALL_OFF);
- }
- else
- {
- status = SendVendorCommand(hDevice, HIDFX2_SET_BARGRAPH_DISPLAY, BARGRAPH_LED_ALL_ON);
- }
-
- TraceVerbose(DBG_IOCTL, "(%!FUNC!) Exit status %!STATUS!\n", status);
- return status;
-}
-
-
-
-//This routine sets the state of the Feature: in this case Segment Display on the USB FX2 board.
-NTSTATUS SendVendorCommand(_In_ WDFDEVICE hDevice, _In_ unsigned char bVendorCommand, _In_ unsigned char bCommandData)
-{
- NTSTATUS status = STATUS_SUCCESS;
- ULONG cBytesTransferred = 0;
- PDEVICE_EXTENSION pDevContext = NULL;
- WDF_MEMORY_DESCRIPTOR memDesc;
- WDF_USB_CONTROL_SETUP_PACKET controlSetupPacket;
- WDF_REQUEST_SEND_OPTIONS sendOptions;
-
- PAGED_CODE();
-
- TraceVerbose(DBG_IOCTL, "(%!FUNC!) Enter\n");
-
- pDevContext = GetDeviceContext(hDevice);
-
- TraceInfo(DBG_IOCTL, "(%!FUNC!): Command:0x%x, data: 0x%x\n", bVendorCommand, bCommandData);
-
- // Send the I/O with a timeout.
- // We do that because we send the I/O in the context of the user thread and if it gets stuck, it would prevent the user process from existing.
- WDF_REQUEST_SEND_OPTIONS_INIT(&sendOptions, WDF_REQUEST_SEND_OPTION_TIMEOUT);
-
- WDF_REQUEST_SEND_OPTIONS_SET_TIMEOUT(&sendOptions, WDF_REL_TIMEOUT_IN_SEC(5));
-
- WDF_USB_CONTROL_SETUP_PACKET_INIT_VENDOR(&controlSetupPacket,
- BmRequestHostToDevice,
- BmRequestToDevice,
- bVendorCommand, // Request
- 0, // Value
- 0); // Index
-
- WDF_MEMORY_DESCRIPTOR_INIT_BUFFER(&memDesc, &bCommandData, sizeof(bCommandData));
-
- status = WdfUsbTargetDeviceSendControlTransferSynchronously(pDevContext->hUsbDevice,
- WDF_NO_HANDLE, // Optional WDFREQUEST
- &sendOptions, // PWDF_REQUEST_SEND_OPTIONS
- &controlSetupPacket,
- &memDesc,
- &cBytesTransferred);
- if (!NT_SUCCESS(status))
- {
- TraceErr(DBG_IOCTL, "(%!FUNC!): Failed to set Segment Display state - %!STATUS!\n", status);
- }
-
- TraceVerbose(DBG_IOCTL, "(%!FUNC!) Exit\n");
-
- return status;
-}
-
-
-
-// Finds the HID descriptor and copies it into the buffer provided by the Request.
-//
-NTSTATUS HidFx2GetHidDescriptor(_In_ WDFDEVICE hDevice, _In_ WDFREQUEST hRequest)
-{
- NTSTATUS status = STATUS_SUCCESS;
- size_t cBytesToCopy = 0;
- WDFMEMORY memory;
- PDEVICE_EXTENSION pDevContext = NULL;
- HID_DESCRIPTOR hidDescriptor;
-
-
- TraceVerbose(DBG_IOCTL, "(%!FUNC!) Entry\n");
-
- status = WdfRequestRetrieveOutputMemory(hRequest, &memory);
- if (NT_SUCCESS(status))
- {
- hidDescriptor.bLength= sizeof(hidDescriptor); // length of HID descriptor
- hidDescriptor.bDescriptorType= HID_HID_DESCRIPTOR_TYPE; // descriptor type == HID 0x21
- hidDescriptor.bcdHID= HID_CLASS_SPEC_RELEASE_1_00; // hid spec release
- hidDescriptor.bCountry= HID_COUNTRY_NON_LOCALIZED; // country code
- hidDescriptor.bNumDescriptors= 0x01; // number of HID class descriptors
- hidDescriptor.DescriptorList[0].bReportType =HID_REPORT_DESCRIPTOR_TYPE;
- hidDescriptor.DescriptorList[0].wReportLength = sizeof(c_ButtonDescriptor);
-
- pDevContext = GetDeviceContext(hDevice);
- if (pDevContext != NULL)
- {
- // Set length of non default report descriptor
- switch (pDevContext->driverMode)
- {
- case DM_BUTTON_AND_LED:
- hidDescriptor.DescriptorList[0].wReportLength = sizeof(c_ButtonWithLedDescriptor);
- break;
- case DM_SLIDER_SWITCH:
- hidDescriptor.DescriptorList[0].wReportLength = sizeof(c_SliderSwitchDescriptor);
- break;
- case DM_SLIDER_SWITCH_AND_LED:
- hidDescriptor.DescriptorList[0].wReportLength = sizeof(c_SliderSwitchWithLedDescriptor);
- break;
- case DM_LED_ONLY:
- hidDescriptor.DescriptorList[0].wReportLength = sizeof(c_LedOnlyDescriptor);
- break;
- default:
- break;
- }
- }
- cBytesToCopy = hidDescriptor.bLength;
- if (cBytesToCopy != 0)
- {
- status = WdfMemoryCopyFromBuffer(memory, 0, (PVOID)&hidDescriptor, cBytesToCopy);
- if (NT_SUCCESS(status))
- {
- // Report how many bytes were copied
- WdfRequestSetInformation(hRequest, cBytesToCopy);
- }
- else // WdfMemoryCopyFromBuffer failed
- {
- TraceErr(DBG_IOCTL, "(%!FUNC!) WdfMemoryCopyFromBuffer failed %!STATUS!\n", status);
- return status;
- }
- }
- else // length is zero
- {
- status = STATUS_INVALID_DEVICE_STATE;
- TraceErr(DBG_IOCTL, "(%!FUNC!) c_DefaultHidDescriptor is zero, %!STATUS!\n", status);
- return status;
- }
-
- }
- else // WdfRequestRetrieveOutputMemory failed
- {
- TraceErr(DBG_IOCTL, " (%!FUNC!) WdfRequestRetrieveOutputMemory failed %!STATUS!\n", status);
- return status;
- }
-
- TraceVerbose(DBG_IOCTL, " (%!FUNC!) HidFx2GetHidDescriptor Exit = %!STATUS!\n", status);
- return status;
-}
-
-
-
-// Finds the Report descriptor and copies it into the buffer provided by the Request.
-//
-NTSTATUS HidFx2GetReportDescriptor(_In_ WDFDEVICE hDevice, _In_ WDFREQUEST hRequest)
-{
- NTSTATUS status = STATUS_SUCCESS;
- WDFMEMORY memory;
- PDEVICE_EXTENSION pDevContext = NULL;
- PVOID pBuffer = (PVOID)c_ButtonDescriptor;
- size_t cBytesToCopy = sizeof(c_ButtonDescriptor);
-
-
- TraceVerbose(DBG_IOCTL, "(%!FUNC!) Entry\n");
-
- status = WdfRequestRetrieveOutputMemory(hRequest, &memory);
- if (NT_SUCCESS(status))
- {
- pDevContext = GetDeviceContext(hDevice);
- if (pDevContext != NULL)
- {
- // Select a non default report descriptor
- switch (pDevContext->driverMode)
- {
- case DM_BUTTON_AND_LED:
- pBuffer = (PVOID)c_ButtonWithLedDescriptor;
- cBytesToCopy = sizeof(c_ButtonWithLedDescriptor);
- break;
- case DM_SLIDER_SWITCH:
- pBuffer = (PVOID)c_SliderSwitchDescriptor;
- cBytesToCopy = sizeof(c_SliderSwitchDescriptor);
- break;
- case DM_SLIDER_SWITCH_AND_LED:
- pBuffer = (PVOID)c_SliderSwitchWithLedDescriptor;
- cBytesToCopy = sizeof(c_SliderSwitchWithLedDescriptor);
- break;
- case DM_LED_ONLY:
- pBuffer = (PVOID)c_LedOnlyDescriptor;
- cBytesToCopy = sizeof(c_LedOnlyDescriptor);
- break;
- default:
- break;
- }
- }
- if (cBytesToCopy != 0)
- {
- status = WdfMemoryCopyFromBuffer(memory, 0, pBuffer, cBytesToCopy);
- if (NT_SUCCESS(status))
- {
- // Report how many bytes were copied
- WdfRequestSetInformation(hRequest, cBytesToCopy);
- }
- else // WdfMemoryCopyFromBuffer failed
- {
- TraceErr(DBG_IOCTL, "(%!FUNC!) WdfMemoryCopyFromBuffer failed %!STATUS!\n", status);
- }
- }
- else // report length is zero
- {
- status = STATUS_INVALID_DEVICE_STATE;
- TraceErr(DBG_IOCTL, "(%!FUNC!) c_DefaultHidDescriptor's reportLength is zero, %!STATUS!\n", status);
- }
- }
- else // WdfRequestRetrieveOutputMemory failed
- {
- TraceErr(DBG_IOCTL, "(%!FUNC!)WdfRequestRetrieveOutputMemory failed %!STATUS!\n", status);
-
- }
-
- TraceVerbose(DBG_IOCTL, "(%!FUNC!) Exit = %!STATUS!\n", status);
- return status;
-}
-
-
-
-// Fill in the given struct _HID_DEVICE_ATTRIBUTES
-//
-NTSTATUS HidFx2GetDeviceAttributes(_In_ WDFREQUEST hRequest)
-{
- NTSTATUS status = STATUS_SUCCESS;
- PHID_DEVICE_ATTRIBUTES pDeviceAttributes = NULL;
- PUSB_DEVICE_DESCRIPTOR pUsbDeviceDescriptor = NULL;
- PDEVICE_EXTENSION pDeviceInfo = NULL;
-
- TraceVerbose(DBG_IOCTL, "(%!FUNC!) Entry\n");
-
- pDeviceInfo = GetDeviceContext(WdfIoQueueGetDevice(WdfRequestGetIoQueue(hRequest)));
- status = WdfRequestRetrieveOutputBuffer(hRequest, sizeof (HID_DEVICE_ATTRIBUTES), &pDeviceAttributes, NULL);
- if (NT_SUCCESS(status))
- {
- // Retrieve USB device descriptor saved in device context
- pUsbDeviceDescriptor = WdfMemoryGetBuffer(pDeviceInfo->hDeviceDescriptor, NULL);
- pDeviceAttributes->Size = sizeof (HID_DEVICE_ATTRIBUTES);
- pDeviceAttributes->VendorID = pUsbDeviceDescriptor->idVendor;
- pDeviceAttributes->ProductID = pUsbDeviceDescriptor->idProduct;
- pDeviceAttributes->VersionNumber = pUsbDeviceDescriptor->bcdDevice;
- // Report how many bytes were copied
- WdfRequestSetInformation(hRequest, sizeof (HID_DEVICE_ATTRIBUTES));
- }
- else // WdfRequestRetrieveOutputBuffer failed
- {
- TraceErr(DBG_IOCTL, "(%!FUNC!) WdfRequestRetrieveOutputBuffer failed %!STATUS!\n", status);
- }
-
- TraceVerbose(DBG_IOCTL, "(%!FUNC!) Exit = %!STATUS!\n", status);
- return status;
-}
-
-
-
-// Pass down Idle notification request to lower driver
-//
-NTSTATUS HidFx2SendIdleNotification(_In_ WDFREQUEST hRequest)
-{
- NTSTATUS status = STATUS_SUCCESS;
- WDF_REQUEST_SEND_OPTIONS options;
- WDFIOTARGET hNextLowerDriver;
- WDFDEVICE hDevice;
- PIO_STACK_LOCATION pCurrentIrpStack = NULL;
- IO_STACK_LOCATION nextIrpStack;
-
- TraceVerbose(DBG_IOCTL, "(%!FUNC!) Entry\n");
-
- hDevice = WdfIoQueueGetDevice(WdfRequestGetIoQueue(hRequest));
- pCurrentIrpStack = IoGetCurrentIrpStackLocation(WdfRequestWdmGetIrp(hRequest));
-
- // Convert the request to corresponding USB Idle notification request
- if (pCurrentIrpStack->Parameters.DeviceIoControl.InputBufferLength >= sizeof(HID_SUBMIT_IDLE_NOTIFICATION_CALLBACK_INFO))
- {
- ASSERT(sizeof(HID_SUBMIT_IDLE_NOTIFICATION_CALLBACK_INFO) == sizeof(USB_IDLE_CALLBACK_INFO));
- #pragma warning(suppress :4127) // conditional expression is constant warning
- if (sizeof(HID_SUBMIT_IDLE_NOTIFICATION_CALLBACK_INFO) == sizeof(USB_IDLE_CALLBACK_INFO))
- {
- // prepare next stack location
- RtlZeroMemory(&nextIrpStack, sizeof(IO_STACK_LOCATION));
- nextIrpStack.MajorFunction = pCurrentIrpStack->MajorFunction;
- nextIrpStack.Parameters.DeviceIoControl.InputBufferLength = pCurrentIrpStack->Parameters.DeviceIoControl.InputBufferLength;
- nextIrpStack.Parameters.DeviceIoControl.Type3InputBuffer = pCurrentIrpStack->Parameters.DeviceIoControl.Type3InputBuffer;
- nextIrpStack.Parameters.DeviceIoControl.IoControlCode = IOCTL_INTERNAL_USB_SUBMIT_IDLE_NOTIFICATION;
- nextIrpStack.DeviceObject = WdfIoTargetWdmGetTargetDeviceObject(WdfDeviceGetIoTarget(hDevice));
-
- // Format the I/O request for the driver's local I/O target by using the contents of the specified WDM I/O stack location structure.
- WdfRequestWdmFormatUsingStackLocation(hRequest, &nextIrpStack);
-
- // Send the request down using Fire and forget option.
- WDF_REQUEST_SEND_OPTIONS_INIT(&options, WDF_REQUEST_SEND_OPTION_SEND_AND_FORGET);
- hNextLowerDriver = WdfDeviceGetIoTarget(hDevice);
- if (WdfRequestSend(hRequest, hNextLowerDriver, &options) == FALSE)
- {
- status = STATUS_UNSUCCESSFUL;
- }
- }
- else // Incorrect DeviceIoControl.InputBufferLength
- {
- status = STATUS_INFO_LENGTH_MISMATCH;
- TraceErr(DBG_IOCTL, "(%!FUNC!) Incorrect DeviceIoControl.InputBufferLength, %!STATUS!\n", status);
- return status;
- }
- }
- else // DeviceIoControl.InputBufferLength too small
- {
- status = STATUS_BUFFER_TOO_SMALL;
- TraceErr(DBG_IOCTL, "(%!FUNC!) DeviceIoControl.InputBufferLength too small, %!STATUS!\n", status);
- return status;
- }
-
- TraceVerbose(DBG_IOCTL, "(%!FUNC!) Exit = %!STATUS!\n", status);
- return status;
-}
-
-
-
-
-
diff --git a/network/radio/HidSwitchDriverSample/trace.h b/network/radio/HidSwitchDriverSample/trace.h
deleted file mode 100644
index 0ec09b91..00000000
--- a/network/radio/HidSwitchDriverSample/trace.h
+++ /dev/null
@@ -1,13 +0,0 @@
-#pragma once
-
-#define WPP_CHECK_FOR_NULL_STRING //to prevent exceptions due to NULL strings
-
-#define WPP_CONTROL_GUIDS \
- WPP_DEFINE_CONTROL_GUID(HidUsbFx2TraceGuid, (091182d7, 5167, 4e77, aa80, ca6c1e6201e9), \
- WPP_DEFINE_BIT(DBG_INIT) \
- WPP_DEFINE_BIT(DBG_PNP) \
- WPP_DEFINE_BIT(DBG_IOCTL) \
- )
-
-#define WPP_LEVEL_FLAGS_LOGGER(lvl,flags) WPP_LEVEL_LOGGER(flags)
-#define WPP_LEVEL_FLAGS_ENABLED(lvl, flags) (WPP_LEVEL_ENABLED(flags) && WPP_CONTROL(WPP_BIT_ ## flags).Level >= lvl)
diff --git a/network/radio/HidSwitchDriverSample/usb.c b/network/radio/HidSwitchDriverSample/usb.c
deleted file mode 100644
index 84cf7faa..00000000
--- a/network/radio/HidSwitchDriverSample/usb.c
+++ /dev/null
@@ -1,466 +0,0 @@
-#include "RadioSwitchHidUsbFx2.h"
-#include "usb.tmh"
-
-
-#ifdef ALLOC_PRAGMA
-#pragma alloc_text(PAGE, HidFx2EvtDevicePrepareHardware)
-#pragma alloc_text(PAGE, HidFx2EvtDeviceD0Exit)
-#pragma alloc_text(PAGE, HidFx2ConfigContReaderForInterruptEndPoint)
-#endif
-
-
-// In this callback, the driver does whatever is necessary to make the hardware ready to use.
-// In the case of a USB device, this involves reading and selecting descriptors.
-NTSTATUS
-HidFx2EvtDevicePrepareHardware(
- _In_ WDFDEVICE hDevice,
- _In_ WDFCMRESLIST hResourceList,
- _In_ WDFCMRESLIST hResourceListTranslated
- )
-{
- NTSTATUS status = STATUS_SUCCESS;
- PDEVICE_EXTENSION pDevContext = NULL;
- WDF_USB_DEVICE_SELECT_CONFIG_PARAMS configParams;
- WDF_OBJECT_ATTRIBUTES attributes;
- PUSB_DEVICE_DESCRIPTOR pUsbDeviceDescriptor = NULL;
-
- UNREFERENCED_PARAMETER(hResourceList);
- UNREFERENCED_PARAMETER(hResourceListTranslated);
-
- PAGED_CODE ();
-
- TraceVerbose(DBG_INIT, "(%!FUNC!) Enter\n");
-
- pDevContext = GetDeviceContext(hDevice);
-
- // Create a WDFUSBDEVICE object. WdfUsbTargetDeviceCreate obtains the USB device descriptor and the first USB configuration
- //descriptor from the device and stores them. It also creates a framework USB interface object for each interface in the device's first configuration.
- //
- // The parent of each USB device object is the driver's framework driver object. The driver cannot change this parent, and the ParentObject
- // member or the WDF_OBJECT_ATTRIBUTES structure must be NULL.
- //
- // We only create device the first time PrepareHardware is called. If the device is restarted by pnp manager for resource rebalance, we
- // will use the same device handle but then select the interfaces again because the USB stack could reconfigure the device on restart.
- if (pDevContext->hUsbDevice == NULL)
- {
- status = WdfUsbTargetDeviceCreate(hDevice, WDF_NO_OBJECT_ATTRIBUTES, &pDevContext->hUsbDevice);
- if (!NT_SUCCESS(status))
- {
- TraceErr(DBG_PNP, "(%!FUNC!) WdfUsbTargetDeviceCreate failed %!STATUS!\n", status);
- return status;
- }
- }
-
- // Select a device configuration by using a WDF_USB_DEVICE_SELECT_CONFIG_PARAMS
- WDF_USB_DEVICE_SELECT_CONFIG_PARAMS_INIT_SINGLE_INTERFACE(&configParams);
- status = WdfUsbTargetDeviceSelectConfig(pDevContext->hUsbDevice, WDF_NO_OBJECT_ATTRIBUTES, &configParams);
- if (!NT_SUCCESS(status))
- {
- TraceErr(DBG_PNP, "(%!FUNC!) WdfUsbTargetDeviceSelectConfig failed %!STATUS!\n", status);
- return status;
- }
-
- pDevContext->hUsbInterface = configParams.Types.SingleInterface.ConfiguredUsbInterface;
-
- // Get the device descriptor and store it in device context
- WDF_OBJECT_ATTRIBUTES_INIT(&attributes);
- attributes.ParentObject = hDevice;
- status = WdfMemoryCreate(&attributes,
- NonPagedPoolNx,
- 0,
- sizeof(USB_DEVICE_DESCRIPTOR),
- &pDevContext->hDeviceDescriptor,
- &pUsbDeviceDescriptor);
- if (!NT_SUCCESS(status))
- {
- TraceErr(DBG_PNP, "(%!FUNC!) WdfMemoryCreate for Device Descriptor failed %!STATUS!\n", status);
- return status;
- }
-
- WdfUsbTargetDeviceGetDeviceDescriptor(pDevContext->hUsbDevice, pUsbDeviceDescriptor);
-
- // Get the Interrupt pipe. There are other endpoints but we are only interested in interrupt endpoint since our HID data comes from this
- pDevContext->hInterruptPipe = WdfUsbInterfaceGetConfiguredPipe(pDevContext->hUsbInterface, INTERRUPT_ENDPOINT_INDEX, NULL);
- if (NULL == pDevContext->hInterruptPipe)
- {
- TraceErr(DBG_PNP, "(%!FUNC!) Failed to get interrupt pipe info\n");
- status = STATUS_INVALID_DEVICE_STATE;
- return status;
- }
-
- // Tell the framework that it's okay to read less than MaximumPacketSize
- WdfUsbTargetPipeSetNoMaximumPacketSizeCheck(pDevContext->hInterruptPipe);
-
- //configure continuous reader
- status = HidFx2ConfigContReaderForInterruptEndPoint(pDevContext);
-
- TraceVerbose(DBG_INIT, "(%!FUNC!) Exit, Status: %!STATUS!\n", status);
-
- return status;
-}
-
-
-
-// This routine configures a continuous reader on the interrupt endpoint. It's called from the PrepareHarware event.
-//
-NTSTATUS HidFx2ConfigContReaderForInterruptEndPoint(PDEVICE_EXTENSION pDeviceContext)
-{
- WDF_USB_CONTINUOUS_READER_CONFIG contReaderConfig;
- NTSTATUS status = STATUS_SUCCESS;
-
- PAGED_CODE ();
-
- TraceVerbose(DBG_INIT, "(%!FUNC!) Enter\n");
-
- WDF_USB_CONTINUOUS_READER_CONFIG_INIT(&contReaderConfig,
- HidFx2EvtUsbInterruptPipeReadComplete,
- pDeviceContext, // Context
- sizeof(UCHAR)); // TransferLength
-
- status = WdfUsbTargetPipeConfigContinuousReader(pDeviceContext->hInterruptPipe, &contReaderConfig);
- if (!NT_SUCCESS(status))
- {
- TraceErr(DBG_INIT, "(%!FUNC!) failed %!STATUS!\n", status);
- }
-
- TraceVerbose(DBG_INIT, "(%!FUNC!) Exit, status: %!STATUS!\n", status);
-
- return status;
-}
-
-
-
-// This the completion routine of the continuous reader. This can called concurrently on multiprocessor system if there are
-// more than one readers configured. So make sure to protect access to global resources.
-//
-void HidFx2EvtUsbInterruptPipeReadComplete(
- WDFUSBPIPE hPipe,
- WDFMEMORY hBuffer,
- size_t cNumBytesTransferred,
- WDFCONTEXT pContext
- )
-{
- PDEVICE_EXTENSION pDevContext = pContext;
- BOOLEAN fInTimerQueue;
- unsigned char *pbSwitchState = NULL;
- unsigned char bCurrentSwitchState = 0;
- unsigned char bPrevSwitchState = 0;
- unsigned char bToggledSwitch = 0;
-
- UNREFERENCED_PARAMETER(cNumBytesTransferred);
- UNREFERENCED_PARAMETER(hPipe);
-
- TraceVerbose(DBG_INIT, "(%!FUNC!) Enter\n");
-
- // Interrupt endpoints sends switch state when first started or when resuming from suspend.
- // We need to ignore that data since user did not change the switch state.
- if (pDevContext->fIsPowerUpSwitchState)
- {
- pDevContext->fIsPowerUpSwitchState = FALSE;
- TraceInfo(DBG_INIT, "(%!FUNC!) Dropping interrupt message since received during powerup/resume\n");
- return;
- }
-
-
- // Make sure that there is data in the read packet.
- // Depending on the device specification, it is possible for it to return a 0 length read in certain conditions.
- if (cNumBytesTransferred == 0)
- {
- TraceWarning(DBG_INIT, "(%!FUNC!) Zero length read occured on the Interrupt Pipe's Continuous Reader\n");
- return;
- }
-
- pbSwitchState = WdfMemoryGetBuffer(hBuffer, NULL);
- bCurrentSwitchState = ~(*pbSwitchState); // switchs are inverted on hardware boards
- bCurrentSwitchState &= RADIO_SWITCH_BUTTONS_BIT_MASK; //Mask off everything except the actual radio switch bit
- bPrevSwitchState = pDevContext->bCurrentSwitchState;
-
- if (bPrevSwitchState ^ bCurrentSwitchState) // make sure we toggled the radio switch
- {
- switch(pDevContext->driverMode)
- {
- // If it's a slider switch we want 0->1 and 1->0 transitions.
- case DM_SLIDER_SWITCH:
- case DM_SLIDER_SWITCH_AND_LED:
- bToggledSwitch = bCurrentSwitchState;
- // A timer is started for 10 ms everytime there is a switch toggled
- fInTimerQueue = WdfTimerStart(pDevContext->hDebounceTimer, WDF_REL_TIMEOUT_IN_MS(SWITCHPACK_DEBOUNCE_TIME));
- TraceInfo(DBG_INIT, "(%!FUNC!) Debounce Timer started. Existing -%!bool!\n", fInTimerQueue);
- break;
- //If it's a button so we only report 0->1 transitions
- case DM_BUTTON:
- case DM_BUTTON_AND_LED:
- bToggledSwitch = (bPrevSwitchState ^ bCurrentSwitchState) & bCurrentSwitchState;
- if (bToggledSwitch != 0)
- {
- // A timer is started for 10 ms everytime there is a switch toggled on
- fInTimerQueue = WdfTimerStart(pDevContext->hDebounceTimer, WDF_REL_TIMEOUT_IN_MS(SWITCHPACK_DEBOUNCE_TIME));
- TraceInfo(DBG_INIT, "(%!FUNC!) Debounce Timer started. Existing -%!bool!\n", fInTimerQueue);
- }
- break;
- // Ignore button presses if LED only
- case DM_LED_ONLY:
- default:
- break;
- }
-
- // Store switch state in device context
- pDevContext->bCurrentSwitchState = bCurrentSwitchState;
- pDevContext->bLatestToggledSwitch = bToggledSwitch;
- }
- else
- {
- TraceInfo(DBG_INIT, "(%!FUNC!) Not a radio switch toggle\n");
- }
- TraceInfo(DBG_INIT, "(%!FUNC!) Switch 0x%x, prevSwitch:0x%x, X0R:0x%x\n", bCurrentSwitchState, bPrevSwitchState, bToggledSwitch);
-
- TraceVerbose(DBG_INIT, "(%!FUNC!) Exit\n");
-}
-
-
-
-// This function gets called when the timeout period of debounce timer elapses.
-// It reports a switch change by completing a pending request
-//
-void HidFx2EvtTimerFunction(_In_ WDFTIMER hTimer)
-{
- WDFDEVICE hDevice = NULL;
- WDFREQUEST hRequest;
- PDEVICE_EXTENSION pDevContext = NULL;
- NTSTATUS status = STATUS_SUCCESS;
- size_t cBytesReturned = 0;
- unsigned char bToggledSwitch = 0;
- ULONG cBytesToCopy = 0;
- PHIDFX2_IO_REPORT pInputReport = NULL;
-
- TraceVerbose(DBG_IOCTL, "(%!FUNC!) Enter\n");
-
-
- hDevice = WdfTimerGetParentObject(hTimer);
- pDevContext = GetDeviceContext(hDevice);
-
- bToggledSwitch = pDevContext->bLatestToggledSwitch;
- TraceInfo(DBG_IOCTL, "(%!FUNC!) mode %d switch %d\n", pDevContext->driverMode, bToggledSwitch);
-
- if (!((pDevContext->driverMode == DM_BUTTON || pDevContext->driverMode == DM_BUTTON_AND_LED) && bToggledSwitch == 0))
- {
- // Check if there are any pending requests in the Interrupt Message Queue.
- // If a request is found then complete the pending request.
- status = WdfIoQueueRetrieveNextRequest(pDevContext->hInterruptMsgQueue, &hRequest);
- if (NT_SUCCESS(status))
- {
- cBytesToCopy = sizeof(pInputReport[0]);
- status = WdfRequestRetrieveOutputBuffer(hRequest,
- cBytesToCopy,
- &pInputReport,
- &cBytesReturned); // BufferLength
- if (NT_SUCCESS(status))
- {
- TraceInfo(DBG_IOCTL, "(%!FUNC!) WdfRequestRetrieveOutputBuffer switch %d\n", bToggledSwitch);
-
- pInputReport->bReportId = GENERIC_DESKTOP_REPORT_ID;
- pInputReport->bData = bToggledSwitch;
- cBytesReturned = cBytesToCopy;
- }
- else // WdfRequestRetrieveOutputBuffer failed
- {
- TraceErr(DBG_IOCTL, "(%!FUNC!) WdfRequestRetrieveOutputBuffer failed with status: %!STATUS!\n", status);
- }
-
- WdfRequestCompleteWithInformation(hRequest, status, cBytesReturned);
-
- }
- else if (status != STATUS_NO_MORE_ENTRIES)
- {
- TraceErr(DBG_IOCTL, "(%!FUNC!) WdfIoQueueRetrieveNextRequest status %!STATUS!\n", status);
- }
- }
- else
- {
- TraceInfo(DBG_IOCTL, "(%!FUNC!) ignore switch");
- }
-
- TraceVerbose(DBG_IOCTL, "(%!FUNC!) Exit\n");
-}
-
-
-
-// This function gets the switch state of the USB device directly from the hardware
-//
-NTSTATUS HidFx2GetSwitchState(_In_ WDFDEVICE hDevice, _Out_ unsigned char *pbSwitchState)
-{
- PDEVICE_EXTENSION pDevContext = NULL;
- NTSTATUS status = STATUS_SUCCESS;
- WDF_MEMORY_DESCRIPTOR memDesc;
- WDF_USB_CONTROL_SETUP_PACKET controlSetupPacket;
- ULONG cBytesTransferred = 0;
-
- if(pbSwitchState != NULL)
- {
- *pbSwitchState = 0;
- }
-
- TraceVerbose(DBG_IOCTL, "(%!FUNC!) Entry\n");
-
- pDevContext = GetDeviceContext(hDevice);
-
- // set the segment state on the USB device
- WDF_USB_CONTROL_SETUP_PACKET_INIT_VENDOR(&controlSetupPacket,
- BmRequestDeviceToHost,
- BmRequestToDevice,
- HIDFX2_READ_SWITCH_STATE, // Request
- 0, // Value
- 0); // Index
-
- WDF_MEMORY_DESCRIPTOR_INIT_BUFFER(&memDesc, pbSwitchState, sizeof(*pbSwitchState));
-
- status = WdfUsbTargetDeviceSendControlTransferSynchronously(pDevContext->hUsbDevice,
- NULL, // Optional WDFREQUEST
- NULL, // PWDF_REQUEST_SEND_OPTIONS
- &controlSetupPacket,
- &memDesc,
- &cBytesTransferred);
-
- if (!NT_SUCCESS(status))
- {
- TraceErr(DBG_IOCTL, "(%!FUNC!) Failed to read switch state - %!STATUS! \n", status);
- }
- else
- {
- TraceVerbose(DBG_IOCTL, "(%!FUNC!) Switch state is 0x%x\n", *pbSwitchState);
- *pbSwitchState = ~(*pbSwitchState); // switchs are inverted on hardware boards
- TraceVerbose(DBG_IOCTL, "(%!FUNC!) Switch state is 0x%x\n", *pbSwitchState);
- }
-
- TraceVerbose(DBG_IOCTL, "(%!FUNC!) Exit, status: %!STATUS!\n", status);
- return status;
-}
-
-
-
-// EvtDeviceD0Entry event callback must perform any operations that are necessary before the specified device is used.
-// Called every time the hardware needs to be initialized/reinitialized.
-// This function is not marked pageable because this function is in the device power up path.
-// This function runs at PASSIVE_LEVEL, even though it is not paged.
-//
-NTSTATUS HidFx2EvtDeviceD0Entry(_In_ WDFDEVICE hDevice, _In_ WDF_POWER_DEVICE_STATE previousState)
-{
- PDEVICE_EXTENSION pDevContext = NULL;
- NTSTATUS status = STATUS_SUCCESS;
- unsigned char bSwitchState = 0;
- unsigned char bMode = 0;
-
- pDevContext = GetDeviceContext(hDevice);
-
- TraceVerbose(DBG_PNP, "(%!FUNC!) Enter - coming from %S\n", DbgDevicePowerString(previousState));
-
- SendVendorCommand(hDevice, HIDFX2_SET_BARGRAPH_DISPLAY, BARGRAPH_LED_ALL_OFF);
-
- // Retrieve the current switch state and store it in device context
- status = HidFx2GetSwitchState(hDevice, &bSwitchState);
- if (NT_SUCCESS(status))
- {
- // Left most switches define Mode
- bMode = bSwitchState & MODE_SELECTION_BUTTONS_BIT_MASK;
- switch (bMode)
- {
- case SWITCHPACK_SELECTION_FOR_MODE2:
- pDevContext->driverMode = DM_BUTTON_AND_LED;
- SendVendorCommand(hDevice, HIDFX2_SET_7SEGMENT_DISPLAY, SEGMENT_DISPLAY_2);
- break;
- case SWITCHPACK_SELECTION_FOR_MODE3:
- pDevContext->driverMode = DM_SLIDER_SWITCH;
- SendVendorCommand(hDevice, HIDFX2_SET_7SEGMENT_DISPLAY, SEGMENT_DISPLAY_3);
- break;
- case SWITCHPACK_SELECTION_FOR_MODE4:
- pDevContext->driverMode = DM_SLIDER_SWITCH_AND_LED;
- SendVendorCommand(hDevice, HIDFX2_SET_7SEGMENT_DISPLAY, SEGMENT_DISPLAY_4);
- break;
- case SWITCHPACK_SELECTION_FOR_MODE5:
- pDevContext->driverMode = DM_LED_ONLY;
- SendVendorCommand(hDevice, HIDFX2_SET_7SEGMENT_DISPLAY, SEGMENT_DISPLAY_5);
- break;
- default:
- pDevContext->driverMode = DM_BUTTON;
- SendVendorCommand(hDevice, HIDFX2_SET_7SEGMENT_DISPLAY, SEGMENT_DISPLAY_1);
- break;
- }
-
- pDevContext->bCurrentSwitchState = bSwitchState;
-
- // Start the target. This will start the continuous reader
- status = WdfIoTargetStart(WdfUsbTargetPipeGetIoTarget(pDevContext->hInterruptPipe));
- if (NT_SUCCESS(status))
- {
- pDevContext->fIsPowerUpSwitchState = TRUE;
- }
- }
- else
- {
- TraceErr(DBG_PNP, "(%!FUNC!) Failed to get current switch state, status: %!STATUS!\n", status);
- }
-
- TraceVerbose(DBG_PNP, "(%!FUNC!) Exit, status: %!STATUS!\n", status);
- return status;
-}
-
-
-
-/*
-This routine undoes anything done in EvtDeviceD0Entry. It is called whenever the device leaves the D0 state, which happens when the device is
-stopped, when it is removed, and when it is powered off.
-
-The device is still in D0 when this callback is invoked, which means that the driver can still touch hardware in this routine.
-
-EvtDeviceD0Exit event callback must perform any operations that are necessary before the specified device is moved out of the D0 state.
-If the driver needs to save hardware state before the device is powered down, then that should be done here.
-
-This function runs at PASSIVE_LEVEL, though it is generally not paged. A driver can optionally make this function pageable if DO_POWER_PAGABLE is set.
-
-Even if DO_POWER_PAGABLE isn't set, this function still runs at PASSIVE_LEVEL.
-In this case, though, the function absolutely must not do anything that will cause a page fault.
-*/
-NTSTATUS HidFx2EvtDeviceD0Exit(_In_ WDFDEVICE hDevice, _In_ WDF_POWER_DEVICE_STATE targetState)
-{
- PDEVICE_EXTENSION pDevContext;
-
- PAGED_CODE();
-
- TraceVerbose(DBG_PNP, "(%!FUNC!) Enter- moving to %S\n", DbgDevicePowerString(targetState));
-
- pDevContext = GetDeviceContext(hDevice);
-
- WdfIoTargetStop(WdfUsbTargetPipeGetIoTarget(pDevContext->hInterruptPipe), WdfIoTargetCancelSentIo);
-
- TraceVerbose(DBG_PNP, "(%!FUNC!) Exit\n");
-
- return STATUS_SUCCESS;
-}
-
-
-
-PCWSTR DbgDevicePowerString(_In_ WDF_POWER_DEVICE_STATE powerState)
-{
- switch (powerState)
- {
- case WdfPowerDeviceInvalid:
- return L"WdfPowerDeviceInvalid";
- case WdfPowerDeviceD0:
- return L"WdfPowerDeviceD0";
- case PowerDeviceD1:
- return L"WdfPowerDeviceD1";
- case WdfPowerDeviceD2:
- return L"WdfPowerDeviceD2";
- case WdfPowerDeviceD3:
- return L"WdfPowerDeviceD3";
- case WdfPowerDeviceD3Final:
- return L"WdfPowerDeviceD3Final";
- case WdfPowerDevicePrepareForHibernation:
- return L"WdfPowerDevicePrepareForHibernation";
- case WdfPowerDeviceMaximum:
- return L"PowerDeviceMaximum";
- default:
- return L"UnKnown Device Power State";
- }
-}
-