Update repo

This commit is contained in:
2026-08-30 23:04:35 -07:00
parent 749dab5721
commit ce65a0f59a
14950 changed files with 4408250 additions and 1 deletions
@@ -0,0 +1,408 @@
//#############################################################################
// FILE: usbdaudio.h
// TITLE: USB audio device class driver
//#############################################################################
//!
//! Copyright: Copyright (C) 2023 Texas Instruments Incorporated -
//! All rights reserved not granted herein.
//! Limited License.
//!
//! Texas Instruments Incorporated grants a world-wide, royalty-free,
//! non-exclusive license under copyrights and patents it now or hereafter
//! owns or controls to make, have made, use, import, offer to sell and sell
//! ("Utilize") this software subject to the terms herein. With respect to the
//! foregoing patent license, such license is granted solely to the extent that
//! any such patent is necessary to Utilize the software alone. The patent
//! license shall not apply to any combinations which include this software,
//! other than combinations with devices manufactured by or for TI
//! ("TI Devices").
//! No hardware patent is licensed hereunder.
//!
//! Redistributions must preserve existing copyright notices and reproduce this
//! license (including the above copyright notice and the disclaimer and
//! (if applicable) source code license limitations below) in the documentation
//! and/or other materials provided with the distribution.
//!
//! Redistribution and use in binary form, without modification, are permitted
//! provided that the following conditions are met:
//!
//! * No reverse engineering, decompilation, or disassembly of this software is
//! permitted with respect to any software provided in binary form.
//! * Any redistribution and use are licensed by TI for use only
//! with TI Devices.
//! * Nothing shall obligate TI to provide you with source code for the
//! software licensed and provided to you in object code.
//!
//! If software source code is provided to you, modification and redistribution
//! of the source code are permitted provided that the following conditions
//! are met:
//!
//! * any redistribution and use of the source code, including any resulting
//! derivative works, are licensed by TI for use only with TI Devices.
//! * any redistribution and use of any object code compiled from the source
//! code and any resulting derivative works, are licensed by TI for use
//! only with TI Devices.
//!
//! Neither the name of Texas Instruments Incorporated nor the names of its
//! suppliers may be used to endorse or promote products derived from this
//! software without specific prior written permission.
//#############################################################################
#ifndef __USBDAUDIO_H__
#define __USBDAUDIO_H__
//*****************************************************************************
//
// If building with a C++ compiler, make all of the definitions in this header
// have a C binding.
//
//*****************************************************************************
#ifdef __cplusplus
extern "C"
{
#endif
//*****************************************************************************
//
//! \addtogroup audio_device_class_api
//! @{
//
//*****************************************************************************
typedef void (* tUSBAudioBufferCallback)(void *pvBuffer, uint32_t ui32Param,
uint32_t ui32Event);
//*****************************************************************************
//
// PRIVATE
//
// This structure defines the private instance data and state variables for the
// audio device class. The memory for this structure is pointed to by
// the pi16PrivateData field in the tUSBDAudioDevice structure passed on
// USBDAudioInit() and should not be modified by any code outside of the audio
// device.
//
//*****************************************************************************
typedef struct
{
//
// Base address for the USB controller.
//
uint32_t ui32USBBase;
//
// The device info to interact with the lower level DCD code.
//
tDeviceInfo sDevInfo;
//
// The maximum volume expressed as an 8.8 signed value.
//
int16_t i16VolumeMax;
//
// The minimum volume expressed as an 8.8 signed value.
//
int16_t i16VolumeMin;
//
// The minimum volume step expressed as an 8.8 signed value.
//
int16_t i16VolumeStep;
struct
{
//
// Pointer to a buffer provided by caller.
//
void *pvData;
//
// Size of the data area provided in pvData in bytes.
//
uint32_t ui32Size;
//
// Number of valid bytes copied into the pvData area.
//
uint32_t ui32NumBytes;
//
// The buffer callback for this function.
//
tUSBAudioBufferCallback pfnCallback;
}
sBuffer;
//
// Pending request type.
//
uint16_t ui16RequestType;
//
// Pending request.
//
uint8_t ui8Request;
//
// Pending update value.
//
uint16_t ui16Update;
//
// Current Volume setting.
//
int16_t i16Volume;
//
// Current Mute setting.
//
uint8_t ui8Mute;
//
// Current Sample rate, this is not writable but the host will try.
//
uint32_t ui32SampleRate;
//
// The OUT endpoint in use by this instance.
//
uint8_t ui8OUTEndpoint;
//
// The OUT endpoint DMA channel in use by this instance.
//
uint8_t ui8OUTDMA;
//
// The control interface number associated with this instance.
//
uint8_t ui8InterfaceControl;
//
// The audio interface number associated with this instance.
//
uint8_t ui8InterfaceAudio;
//
// A copy of the DMA instance data used with calls to USBLibDMA functions.
//
tUSBDMAInstance *psDMAInstance;
}
tAudioInstance;
//*****************************************************************************
//
// This is the size of the g_pui8IADAudioDescriptor array in bytes.
//
//*****************************************************************************
#define AUDIODESCRIPTOR_SIZE (8)
//*****************************************************************************
//
// This is the size of the g_pui8AudioControlInterface array in bytes.
//
//*****************************************************************************
#define CONTROLINTERFACE_SIZE (52)
//*****************************************************************************
//
// This is the size of the g_pui8AudioStreamInterface array in bytes.
//
//*****************************************************************************
#define STREAMINTERFACE_SIZE (52)
//*****************************************************************************
//
//! The size of the memory that should be allocated to create a configuration
//! descriptor for a single instance of the USB Audio Device.
//! This does not include the configuration descriptor which is automatically
//! ignored by the composite device class.
//
//*****************************************************************************
#define COMPOSITE_DAUDIO_SIZE (AUDIODESCRIPTOR_SIZE + \
CONTROLINTERFACE_SIZE + STREAMINTERFACE_SIZE)
//*****************************************************************************
//
//! The structure used by the application to define operating parameters for
//! the device audio class.
//
//*****************************************************************************
typedef struct
{
//
//! The vendor ID that this device is to present in the device descriptor.
//
const uint16_t ui16VID;
//
//! The product ID that this device is to present in the device descriptor.
//
const uint16_t ui16PID;
//
//! 8 byte vendor string.
//
const char pcVendor[8];
//
//! 16 byte vendor string.
//
const char pcProduct[16];
//
//! 4 byte vendor string.
//
const char pcVersion[4];
//
//! The maximum power consumption of the device, expressed in mA.
//
const uint16_t ui16MaxPowermA;
//
//! Indicates whether the device is self or bus-powered and whether or not
//! it supports remote wake up. Valid values are USB_CONF_ATTR_SELF_PWR or
//! USB_CONF_ATTR_BUS_PWR, optionally ORed with USB_CONF_ATTR_RWAKE.
//
const uint8_t ui8PwrAttributes;
//
//! A pointer to the callback function which will be called to notify
//! the application of events relating to the operation of the audio
//! device.
//
const tUSBCallback pfnCallback;
//
//! A pointer to the string descriptor array for this device. This array
//! must contain the following string descriptor pointers in this order.
//! Language descriptor, Manufacturer name string (language 1), Product
//! name string (language 1), Serial number string (language 1), Audio
//! Interface description string (language 1), Configuration description
//! string (language 1).
//!
//! If supporting more than 1 language, the descriptor block (except for
//! string descriptor 0) must be repeated for each language defined in the
//! language descriptor.
//!
//
const uint8_t * const *ppui8StringDescriptors;
//
//! The number of descriptors provided in the ppStringDescriptors
//! array. This must be 1 + ((5 + (number of strings)) *
//! (number of languages)).
//
const uint32_t ui32NumStringDescriptors;
//
//! The maximum volume expressed as an 8.8 signed value.
//
const int16_t i16VolumeMax;
//
//! The minimum volume expressed as an 8.8 signed value.
//
const int16_t i16VolumeMin;
//
//! The minimum volume step expressed as an 8.8 signed value.
//
const int16_t i16VolumeStep;
//
//! The private instance data for the audio device.
//
tAudioInstance sPrivateData;
}
tUSBDAudioDevice;
//*****************************************************************************
//
// Audio specific device class driver events
//
//*****************************************************************************
//*****************************************************************************
//
//! This USB audio event indicates that the device is connected but not active.
//
//*****************************************************************************
#define USBD_AUDIO_EVENT_IDLE (USBD_AUDIO_EVENT_BASE + 0)
//*****************************************************************************
//
//! This USB audio event indicates that the device is connected and is now
//! active.
//
//*****************************************************************************
#define USBD_AUDIO_EVENT_ACTIVE (USBD_AUDIO_EVENT_BASE + 1)
//*****************************************************************************
//
//! This USB audio event indicates that the device is returning a data buffer
//! provided by the USBAudioBufferOut() function back to the application with
//! valid audio data received from the USB host controller. The \e pvBuffer
//! parameter holds the pointer to the buffer with the new audio data and
//! the \e ui32Param value holds the amount of valid data in bytes that are
//! contained in the \e pvBuffer parameter.
//
//*****************************************************************************
#define USBD_AUDIO_EVENT_DATAOUT (USBD_AUDIO_EVENT_BASE + 2)
//*****************************************************************************
//
//! This USB audio event indicates that a volume change has occurred. The
//! \e ui32Param value contains a signed 8.8 fixed point value that represents
//! the current volume gain/attenuation in decibels(dB). The provided message
//! handler should be prepared to handle negative and positive values with the
//! value 0x8000 indicating maximum attenuation. The \e pvBuffer parameter
//! should be ignored.
//
//*****************************************************************************
#define USBD_AUDIO_EVENT_VOLUME (USBD_AUDIO_EVENT_BASE + 4)
//*****************************************************************************
//
//! This USB audio event indicates that a mute request has occurred. The
//! \e ui32Param value will either be a 1 to indicate that the audio is now
//! muted, and a value of 0 indicates that the audio has been unmuted.
//
//*****************************************************************************
#define USBD_AUDIO_EVENT_MUTE (USBD_AUDIO_EVENT_BASE + 5)
//*****************************************************************************
//
// API Function Prototypes
//
//*****************************************************************************
extern void *USBDAudioInit(uint32_t ui32Index,
tUSBDAudioDevice *psAudioDevice);
extern void *USBDAudioCompositeInit(uint32_t ui32Index,
tUSBDAudioDevice *psAudioDevice,
tCompositeEntry *psCompEntry);
extern void USBDAudioTerm(void *pvAudioDevice);
extern int32_t USBAudioBufferOut(void *pvAudioDevice, void *pvBuffer,
uint32_t ui32Size,
tUSBAudioBufferCallback pfnCallback);
//*****************************************************************************
//
// Close the Doxygen group.
//! @}
//
//*****************************************************************************
//*****************************************************************************
//
// Mark the end of the C bindings section for C++ compilers.
//
//*****************************************************************************
#ifdef __cplusplus
}
#endif
#endif
@@ -0,0 +1,318 @@
//#############################################################################
// FILE: usbdcdc.h
// TITLE: USBLib support for a generic bulk device
//#############################################################################
//!
//! Copyright: Copyright (C) 2023 Texas Instruments Incorporated -
//! All rights reserved not granted herein.
//! Limited License.
//!
//! Texas Instruments Incorporated grants a world-wide, royalty-free,
//! non-exclusive license under copyrights and patents it now or hereafter
//! owns or controls to make, have made, use, import, offer to sell and sell
//! ("Utilize") this software subject to the terms herein. With respect to the
//! foregoing patent license, such license is granted solely to the extent that
//! any such patent is necessary to Utilize the software alone. The patent
//! license shall not apply to any combinations which include this software,
//! other than combinations with devices manufactured by or for TI
//! ("TI Devices").
//! No hardware patent is licensed hereunder.
//!
//! Redistributions must preserve existing copyright notices and reproduce this
//! license (including the above copyright notice and the disclaimer and
//! (if applicable) source code license limitations below) in the documentation
//! and/or other materials provided with the distribution.
//!
//! Redistribution and use in binary form, without modification, are permitted
//! provided that the following conditions are met:
//!
//! * No reverse engineering, decompilation, or disassembly of this software is
//! permitted with respect to any software provided in binary form.
//! * Any redistribution and use are licensed by TI for use only
//! with TI Devices.
//! * Nothing shall obligate TI to provide you with source code for the
//! software licensed and provided to you in object code.
//!
//! If software source code is provided to you, modification and redistribution
//! of the source code are permitted provided that the following conditions
//! are met:
//!
//! * any redistribution and use of the source code, including any resulting
//! derivative works, are licensed by TI for use only with TI Devices.
//! * any redistribution and use of any object code compiled from the source
//! code and any resulting derivative works, are licensed by TI for use
//! only with TI Devices.
//!
//! Neither the name of Texas Instruments Incorporated nor the names of its
//! suppliers may be used to endorse or promote products derived from this
//! software without specific prior written permission.
//#############################################################################
#ifndef __USBDBULK_H__
#define __USBDBULK_H__
//*****************************************************************************
//
// If building with a C++ compiler, make all of the definitions in this header
// have a C binding.
//
//*****************************************************************************
#ifdef __cplusplus
extern "C"
{
#endif
//*****************************************************************************
//
//! \addtogroup bulk_device_class_api
//! @{
//
//*****************************************************************************
//*****************************************************************************
//
// PRIVATE
//
// The first few sections of this header are private defines that are used by
// the USB Bulk example code and are here only to help with the application
// allocating the correct amount of memory for the Bulk example device code.
//
//*****************************************************************************
//*****************************************************************************
//
// PRIVATE
//
// This enumeration holds the various states that the device can be in during
// normal operation.
//
//*****************************************************************************
typedef enum
{
//
// Not configured.
//
eBulkStateUnconfigured,
//
// No outstanding transaction remains to be completed.
//
eBulkStateIdle,
//
// Waiting on completion of a send or receive transaction.
//
eBulkStateWaitData,
//
// Waiting for client to process data.
//
eBulkStateWaitClient
}
tBulkState;
//*****************************************************************************
//
// PRIVATE
//
// This structure defines the private instance data and state variables for the
// Bulk only example device. The memory for this structure is inlcluded in
// the sPrivateData field in the tUSBDBulkDevice structure passed on
// USBDBulkInit().
//
//*****************************************************************************
typedef struct
{
//
// Base address for the USB controller.
//
uint32_t ui32USBBase;
//
// The device info to interact with the lower level DCD code.
//
tDeviceInfo sDevInfo;
//
// The state of the bulk receive channel.
//
volatile tBulkState iBulkRxState;
//
// The state of the bulk transmit channel.
//
volatile tBulkState iBulkTxState;
//
// State of any pending operations that could not be handled immediately
// upon receipt.
//
volatile uint16_t ui16DeferredOpFlags;
//
// Size of the last transmit.
//
uint16_t ui16LastTxSize;
//
// The connection status of the device.
//
volatile bool bConnected;
//
// The IN endpoint number, this is modified in composite devices.
//
uint8_t ui8INEndpoint;
//
// The OUT endpoint number, this is modified in composite devices.
//
uint8_t ui8OUTEndpoint;
//
// The bulk class interface number, this is modified in composite devices.
//
uint8_t ui8Interface;
}
tBulkInstance;
//*****************************************************************************
//
// This is the size of the g_pui8BulkInterface array in bytes.
//
//*****************************************************************************
#define BULKINTERFACE_SIZE (23)
//*****************************************************************************
//
//! The size of the memory that should be allocated to create a configuration
//! descriptor for a single instance of the USB Bulk Device.
//! This does not include the configuration descriptor which is automatically
//! ignored by the composite device class.
//
//*****************************************************************************
#define COMPOSITE_DBULK_SIZE (BULKINTERFACE_SIZE)
//*****************************************************************************
//
//! The structure used by the application to define operating parameters for
//! the bulk device.
//
//*****************************************************************************
typedef struct
{
//
//! The vendor ID that this device is to present in the device descriptor.
//
const uint16_t ui16VID;
//
//! The product ID that this device is to present in the device descriptor.
//
const uint16_t ui16PID;
//
//! The maximum power consumption of the device, expressed in milliamps.
//
const uint16_t ui16MaxPowermA;
//
//! Indicates whether the device is self- or bus-powered and whether or not
//! it supports remote wakeup. Valid values are USB_CONF_ATTR_SELF_PWR or
//! USB_CONF_ATTR_BUS_PWR, optionally ORed with USB_CONF_ATTR_RWAKE.
//
const uint8_t ui8PwrAttributes;
//
//! A pointer to the callback function which will be called to notify
//! the application of events related to the device's data receive channel.
//
const tUSBCallback pfnRxCallback;
//
//! A client-supplied pointer which will be sent as the first
//! parameter in all calls made to the receive channel callback,
//! pfnRxCallback.
//
void *pvRxCBData;
//
//! A pointer to the callback function which will be called to notify
//! the application of events related to the device's data transmit
//! channel.
//
const tUSBCallback pfnTxCallback;
//
//! A client-supplied pointer which will be sent as the first
//! parameter in all calls made to the transmit channel callback,
//! pfnTxCallback.
//
void *pvTxCBData;
//
//! A pointer to the string descriptor array for this device. This array
//! must contain pointers to the following string descriptors in this
//! order. Language descriptor, Manufacturer name string (language 1),
//! Product name string (language 1), Serial number string (language 1),
//! Interface description string (language 1) and Configuration description
//! string (language 1).
//!
//! If supporting more than 1 language, the strings for indices 1 through 5
//! must be repeated for each of the other languages defined in the
//! language descriptor.
//
const uint8_t * const *ppui8StringDescriptors;
//
//! The number of descriptors provided in the ppStringDescriptors array.
//! This must be 1 + (5 * number of supported languages).
//
const uint32_t ui32NumStringDescriptors;
//
//! The private instance data for this device. This memory must
//! not be modified by any code outside the bulk class driver.
//
tBulkInstance sPrivateData;
}
tUSBDBulkDevice;
//*****************************************************************************
//
// API Function Prototypes
//
//*****************************************************************************
extern void *USBDBulkInit(uint32_t ui32Index, tUSBDBulkDevice *psBulkDevice);
extern void *USBDBulkCompositeInit(uint32_t ui32Index,
tUSBDBulkDevice *psBulkDevice,
tCompositeEntry *psCompEntry);
extern void USBDBulkTerm(void *pvBulkInstance);
extern void *USBDBulkSetRxCBData(void *pvBulkInstance, void *pvCBData);
extern void *USBDBulkSetTxCBData(void *pvBulkInstance, void *pvCBData);
extern uint32_t USBDBulkPacketWrite(void *pvBulkInstance, uint8_t *pi8Data,
uint32_t ui32Length, bool bLast);
extern uint32_t USBDBulkPacketRead(void *pvBulkInstance, uint8_t *pi8Data,
uint32_t ui32Length, bool bLast);
extern uint32_t USBDBulkTxPacketAvailable(void *pvBulkInstance);
extern uint32_t USBDBulkRxPacketAvailable(void *pvBulkInstance);
extern void USBDBulkPowerStatusSet(void *pvBulkInstance, uint8_t ui8Power);
extern bool USBDBulkRemoteWakeupRequest(void *pvBulkInstance);
//*****************************************************************************
//
// Close the Doxygen group.
//! @}
//
//*****************************************************************************
//*****************************************************************************
//
// Mark the end of the C bindings section for C++ compilers.
//
//*****************************************************************************
#ifdef __cplusplus
}
#endif
#endif // __USBDBULK_H__
@@ -0,0 +1,460 @@
//#############################################################################
// FILE: usbdcdc.h
// TITLE: USBLib support for generic CDC ACM (serial) device.
//#############################################################################
//!
//! Copyright: Copyright (C) 2023 Texas Instruments Incorporated -
//! All rights reserved not granted herein.
//! Limited License.
//!
//! Texas Instruments Incorporated grants a world-wide, royalty-free,
//! non-exclusive license under copyrights and patents it now or hereafter
//! owns or controls to make, have made, use, import, offer to sell and sell
//! ("Utilize") this software subject to the terms herein. With respect to the
//! foregoing patent license, such license is granted solely to the extent that
//! any such patent is necessary to Utilize the software alone. The patent
//! license shall not apply to any combinations which include this software,
//! other than combinations with devices manufactured by or for TI
//! ("TI Devices").
//! No hardware patent is licensed hereunder.
//!
//! Redistributions must preserve existing copyright notices and reproduce this
//! license (including the above copyright notice and the disclaimer and
//! (if applicable) source code license limitations below) in the documentation
//! and/or other materials provided with the distribution.
//!
//! Redistribution and use in binary form, without modification, are permitted
//! provided that the following conditions are met:
//!
//! * No reverse engineering, decompilation, or disassembly of this software is
//! permitted with respect to any software provided in binary form.
//! * Any redistribution and use are licensed by TI for use only
//! with TI Devices.
//! * Nothing shall obligate TI to provide you with source code for the
//! software licensed and provided to you in object code.
//!
//! If software source code is provided to you, modification and redistribution
//! of the source code are permitted provided that the following conditions
//! are met:
//!
//! * any redistribution and use of the source code, including any resulting
//! derivative works, are licensed by TI for use only with TI Devices.
//! * any redistribution and use of any object code compiled from the source
//! code and any resulting derivative works, are licensed by TI for use
//! only with TI Devices.
//!
//! Neither the name of Texas Instruments Incorporated nor the names of its
//! suppliers may be used to endorse or promote products derived from this
//! software without specific prior written permission.
//#############################################################################
#ifndef __USBDCDC_H__
#define __USBDCDC_H__
//*****************************************************************************
//
// If building with a C++ compiler, make all of the definitions in this header
// have a C binding.
//
//*****************************************************************************
#ifdef __cplusplus
extern "C"
{
#endif
//*****************************************************************************
//
//! \addtogroup cdc_device_class_api
//! @{
//
//*****************************************************************************
//*****************************************************************************
//
// PRIVATE
//
// The first few sections of this header are private defines that are used by
// the USB CDC Serial code and are here only to help with the application
// allocating the correct amount of memory for the CDC Serial device code.
//
//*****************************************************************************
//*****************************************************************************
//
// PRIVATE
//
// This enumeration holds the various states that the device can be in during
// normal operation.
//
//*****************************************************************************
typedef enum
{
//
// Unconfigured.
//
eCDCStateUnconfigured,
//
// No outstanding transaction remains to be completed.
//
eCDCStateIdle,
//
// Waiting on completion of a send or receive transaction.
//
eCDCStateWaitData,
//
// Waiting for client to process data.
//
eCDCStateWaitClient
}
tCDCState;
//*****************************************************************************
//
// PRIVATE
//
// This structure defines the private instance data and state variables for the
// CDC Serial device. The memory for this structure is allocated in the
// tUSBDCDCDevice structure passed on USBDCDCInit().
//
//*****************************************************************************
typedef struct
{
//
// Base address for the USB controller.
//
uint32_t ui32USBBase;
//
// The device info to interact with the lower level DCD code.
//
tDeviceInfo sDevInfo;
//
// The state of the serial receive state.
//
volatile tCDCState iCDCRxState;
//
// The state of the serial transmit state.
//
volatile tCDCState iCDCTxState;
//
// The state of the serial request state.
//
volatile tCDCState iCDCRequestState;
//
// The state of the serial interrupt state.
//
volatile tCDCState iCDCInterruptState;
//
// The current pending request.
//
volatile uint8_t ui8PendingRequest;
//
// The current break duration used during send break requests.
//
uint16_t ui16BreakDuration;
//
// The current line control state for the serial port.
//
uint16_t ui16ControlLineState;
//
// The general serial state.
//
uint16_t ui16SerialState;
//
// State of any pending operations that could not be handled immediately
// upon receipt.
//
volatile uint16_t ui16DeferredOpFlags;
//
// Size of the last transmit.
//
uint16_t ui16LastTxSize;
//
// The current serial line coding.
//
tLineCoding sLineCoding;
//
// Serial port receive is blocked.
//
volatile bool bRxBlocked;
//
// Serial control port is blocked.
//
volatile bool bControlBlocked;
//
// The connection status of the device.
//
volatile bool bConnected;
//
// The control endpoint number, this is modified in composite devices.
//
uint8_t ui8ControlEndpoint;
//
// The IN endpoint number, this is modified in composite devices.
//
uint8_t ui8BulkINEndpoint;
//
// The OUT endpoint number, this is modified in composite devices.
//
uint8_t ui8BulkOUTEndpoint;
//
// The interface number for the control interface, this is modified in
// composite devices.
//
uint8_t ui8InterfaceControl;
//
// The interface number for the data interface, this is modified in
// composite devices.
//
uint8_t ui8InterfaceData;
}
tCDCSerInstance;
//*****************************************************************************
//
// The following defines are used when working with composite devices.
//
//*****************************************************************************
//*****************************************************************************
//
// This is the size of the g_pui8IADSerDescriptor array in bytes.
//
//*****************************************************************************
#define SERDESCRIPTOR_SIZE (8)
//*****************************************************************************
//
// This is the size of the g_pui8CDCSerCommInterface array in bytes.
//
//*****************************************************************************
#define SERCOMMINTERFACE_SIZE (35)
//*****************************************************************************
//
// This is the size of the g_pui8CDCSerDataInterface array in bytes.
//
//*****************************************************************************
#define SERDATAINTERFACE_SIZE (23)
//*****************************************************************************
//
//! The size of the memory that should be allocated to create a configuration
//! descriptor for a single instance of the USB Serial CDC Device.
//! This does not include the configuration descriptor which is automatically
//! ignored by the composite device class.
//
//*****************************************************************************
#define COMPOSITE_DCDC_SIZE (SERDESCRIPTOR_SIZE + SERCOMMINTERFACE_SIZE + \
SERDATAINTERFACE_SIZE)
//*****************************************************************************
//
// CDC-specific events These events are provided to the application in the
// \e ui32Msg parameter of the tUSBCallback function.
//
//*****************************************************************************
//
//! The host requests that the device send a BREAK condition on its
//! serial communication channel. The BREAK should remain active until
//! a USBD_CDC_EVENT_CLEAR_BREAK event is received.
//
#define USBD_CDC_EVENT_SEND_BREAK (USBD_CDC_EVENT_BASE + 0)
//
//! The host requests that the device stop sending a BREAK condition on its
//! serial communication channel.
//
#define USBD_CDC_EVENT_CLEAR_BREAK (USBD_CDC_EVENT_BASE + 1)
//
//! The host requests that the device set the RS232 signaling lines to
//! a particular state. The ui32MsgValue parameter contains the RTS and
//! DTR control line states as defined in table 51 of the USB CDC class
//! definition and is a combination of the following values:
//!
//! (RTS) USB_CDC_DEACTIVATE_CARRIER or USB_CDC_ACTIVATE_CARRIER
//! (DTR) USB_CDC_DTE_NOT_PRESENT or USB_CDC_DTE_PRESENT
//
#define USBD_CDC_EVENT_SET_CONTROL_LINE_STATE (USBD_CDC_EVENT_BASE + 2)
//
//! The host requests that the device set the RS232 communication
//! parameters. The pvMsgData parameter points to a tLineCoding structure
//! defining the required number of bits per character, parity mode,
//! number of stop bits and the baud rate.
//
#define USBD_CDC_EVENT_SET_LINE_CODING (USBD_CDC_EVENT_BASE + 3)
//
//! The host is querying the current RS232 communication parameters. The
//! pvMsgData parameter points to a tLineCoding structure that the
//! application must fill with the current settings prior to returning
//! from the callback.
//
#define USBD_CDC_EVENT_GET_LINE_CODING (USBD_CDC_EVENT_BASE + 4)
//*****************************************************************************
//
//! The structure used by the application to define operating parameters for
//! the CDC device.
//
//*****************************************************************************
typedef struct
{
//
//! The vendor ID that this device is to present in the device descriptor.
//
const uint16_t ui16VID;
//
//! The product ID that this device is to present in the device descriptor.
//
const uint16_t ui16PID;
//
//! The maximum power consumption of the device, expressed in milliamps.
//
const uint16_t ui16MaxPowermA;
//
//! Indicates whether the device is self- or bus-powered and whether or not
//! it supports remote wakeup. Valid values are USB_CONF_ATTR_SELF_PWR or
//! USB_CONF_ATTR_BUS_PWR, optionally ORed with USB_CONF_ATTR_RWAKE.
//
const uint8_t ui8PwrAttributes;
//
//! A pointer to the callback function which will be called to notify
//! the application of all asynchronous control events related to the
//! operation of the device.
//
const tUSBCallback pfnControlCallback;
//
//! A client-supplied pointer which will be sent as the first
//! parameter in all calls made to the control channel callback,
//! pfnControlCallback.
//
void *pvControlCBData;
//
//! A pointer to the callback function which will be called to notify
//! the application of events related to the device's data receive channel.
//
const tUSBCallback pfnRxCallback;
//
//! A client-supplied pointer which will be sent as the first
//! parameter in all calls made to the receive channel callback,
//! pfnRxCallback.
//
void *pvRxCBData;
//
//! A pointer to the callback function which will be called to notify
//! the application of events related to the device's data transmit
//! channel.
//
const tUSBCallback pfnTxCallback;
//
//! A client-supplied pointer which will be sent as the first
//! parameter in all calls made to the transmit channel callback,
//! pfnTxCallback.
//
void *pvTxCBData;
//
//! A pointer to the string descriptor array for this device. This array
//! must contain the following string descriptor pointers in this order.
//! Language descriptor, Manufacturer name string (language 1), Product
//! name string (language 1), Serial number string (language 1),
//! Control interface description string (language 1), Configuration
//! description string (language 1).
//!
//! If supporting more than 1 language, the strings for indices 1 through 5
//! must be repeated for each of the other languages defined in the
//! language descriptor.
//
const uint8_t * const *ppui8StringDescriptors;
//
//! The number of descriptors provided in the ppStringDescriptors
//! array. This must be 1 + (5 * number of supported languages).
//
const uint32_t ui32NumStringDescriptors;
//
//! The private instance data for this device. This memory
//! must remain accessible for as long as the CDC device is in use and
//! must not be modified by any code outside the CDC class driver.
//
tCDCSerInstance sPrivateData;
}
tUSBDCDCDevice;
//*****************************************************************************
//
// API Function Prototypes
//
//*****************************************************************************
extern void *USBDCDCCompositeInit(uint32_t ui32Index,
tUSBDCDCDevice *psCDCDevice,
tCompositeEntry *psCompEntry);
extern void *USBDCDCInit(uint32_t ui32Index,
tUSBDCDCDevice *psCDCDevice);
extern void USBDCDCTerm(void *pvCDCDevice);
extern void *USBDCDCSetControlCBData(void *pvCDCDevice, void *pvCBData);
extern void *USBDCDCSetRxCBData(void *pvCDCDevice, void *pvCBData);
extern void *USBDCDCSetTxCBData(void *pvCDCDevice, void *pvCBData);
extern uint32_t USBDCDCPacketWrite(void *pvCDCDevice, uint8_t *pi8Data,
uint32_t ui32Length, bool bLast);
extern uint32_t USBDCDCPacketRead(void *pvCDCDevice, uint8_t *pi8Data,
uint32_t ui32Length, bool bLast);
extern uint32_t USBDCDCTxPacketAvailable(void *pvCDCDevice);
extern uint32_t USBDCDCRxPacketAvailable(void *pvCDCDevice);
extern void USBDCDCSerialStateChange(void *pvCDCDevice, uint16_t ui16State);
extern void USBDCDCPowerStatusSet(void *pvCDCDevice, uint8_t ui8Power);
extern bool USBDCDCRemoteWakeupRequest(void *pvCDCDevice);
//*****************************************************************************
//
// Close the Doxygen group.
//! @}
//
//*****************************************************************************
//*****************************************************************************
//
// Mark the end of the C bindings section for C++ compilers.
//
//*****************************************************************************
#ifdef __cplusplus
}
#endif
#endif // __USBDCDC_H__
@@ -0,0 +1,286 @@
//#############################################################################
// FILE: usbdcomp.h
// TITLE: USB composite device class driver
//#############################################################################
//!
//! Copyright: Copyright (C) 2023 Texas Instruments Incorporated -
//! All rights reserved not granted herein.
//! Limited License.
//!
//! Texas Instruments Incorporated grants a world-wide, royalty-free,
//! non-exclusive license under copyrights and patents it now or hereafter
//! owns or controls to make, have made, use, import, offer to sell and sell
//! ("Utilize") this software subject to the terms herein. With respect to the
//! foregoing patent license, such license is granted solely to the extent that
//! any such patent is necessary to Utilize the software alone. The patent
//! license shall not apply to any combinations which include this software,
//! other than combinations with devices manufactured by or for TI
//! ("TI Devices").
//! No hardware patent is licensed hereunder.
//!
//! Redistributions must preserve existing copyright notices and reproduce this
//! license (including the above copyright notice and the disclaimer and
//! (if applicable) source code license limitations below) in the documentation
//! and/or other materials provided with the distribution.
//!
//! Redistribution and use in binary form, without modification, are permitted
//! provided that the following conditions are met:
//!
//! * No reverse engineering, decompilation, or disassembly of this software is
//! permitted with respect to any software provided in binary form.
//! * Any redistribution and use are licensed by TI for use only
//! with TI Devices.
//! * Nothing shall obligate TI to provide you with source code for the
//! software licensed and provided to you in object code.
//!
//! If software source code is provided to you, modification and redistribution
//! of the source code are permitted provided that the following conditions
//! are met:
//!
//! * any redistribution and use of the source code, including any resulting
//! derivative works, are licensed by TI for use only with TI Devices.
//! * any redistribution and use of any object code compiled from the source
//! code and any resulting derivative works, are licensed by TI for use
//! only with TI Devices.
//!
//! Neither the name of Texas Instruments Incorporated nor the names of its
//! suppliers may be used to endorse or promote products derived from this
//! software without specific prior written permission.
//#############################################################################
#ifndef __USBDCOMP_H__
#define __USBDCOMP_H__
//*****************************************************************************
//
// If building with a C++ compiler, make all of the definitions in this header
// have a C binding.
//
//*****************************************************************************
#ifdef __cplusplus
extern "C"
{
#endif
//*****************************************************************************
//
// Return to default packing when using the IAR Embedded Workbench compiler.
//
//*****************************************************************************
#ifdef __ICCARM__
#pragma pack()
#endif
//*****************************************************************************
//
//! \addtogroup composite_device_class_api
//! @{
//
//*****************************************************************************
//
// Defines a single entry in a table of device types supported by the composite
// device.
//
typedef struct
{
//
// This is set internally by the composite class so it can be left
// uninitialized by the application.
//
const tDeviceInfo *psDeviceInfo;
//
// This should be the header to the configuration header for a class.
//
const tConfigHeader *psConfigHeader;
//
// The offset to this devices interface, filled in by the composite class.
//
uint8_t ui8IfaceOffset;
}
tUSBDCompositeEntry;
//*****************************************************************************
//
// PRIVATE
//
// This structure defines the private instance data and state variables for the
// composite device class. The memory for this structure is included in
// the sPrivateData field in the tUSBDCompositeDevice structure passed on
// USBDCompositeInit() and should not be modified by any code outside of the
// composite device code.
//
//*****************************************************************************
typedef struct
{
//
// Saves which USB controller is in use.
//
uint32_t ui32USBBase;
//
// The device information pointer.
//
tDeviceInfo sDevInfo;
//
// This is the configuration descriptor for this instance.
//
tConfigDescriptor sConfigDescriptor;
//
// This is the device descriptor for this instance.
//
tDeviceDescriptor sDeviceDescriptor;
//
// The configuration header for this instance.
//
tConfigHeader sCompConfigHeader;
//
// These are the configuration sections that will be built from the
// Configuration Descriptor header and the descriptors from the devices
// that are part of this composite device.
//
tConfigSection psCompSections[2];
tConfigSection *ppsCompSections[2];
//
// The size and pointer to the data used by the instance.
//
uint32_t ui32DataSize;
uint8_t *pui8Data;
//
// The current "owner" of endpoint 0. This is used to track the device
// class which is currently transferring data on EP0.
//
uint32_t ui32EP0Owner;
}
tCompositeInstance;
//*****************************************************************************
//
//! The structure used by the application to define operating parameters for
//! the composite device class.
//
//*****************************************************************************
typedef struct
{
//
//! The vendor ID that this device is to present in the device descriptor.
//
const uint16_t ui16VID;
//
//! The product ID that this device is to present in the device descriptor.
//
const uint16_t ui16PID;
//
//! The maximum power consumption of the device, expressed in mA.
//
const uint16_t ui16MaxPowermA;
//
//! Indicates whether the device is self or bus-powered and whether or not
//! it supports remote wake up. Valid values are USB_CONF_ATTR_SELF_PWR or
//! USB_CONF_ATTR_BUS_PWR, optionally ORed with USB_CONF_ATTR_RWAKE.
//
const uint8_t ui8PwrAttributes;
//
//! A pointer to the callback function which will be called to notify
//! the application of events relating to the operation of the composite
//! device.
//
const tUSBCallback pfnCallback;
//
//! A pointer to the string descriptor array for this device. This array
//! must contain the following string descriptor pointers in this order.
//! Language descriptor, Manufacturer name string (language 1), Product
//! name string (language 1), Serial number string (language 1), Composite
//! device interface description string (language 1), Configuration
//! description string (language 1).
//!
//! If supporting more than 1 language, the descriptor block (except for
//! string descriptor 0) must be repeated for each language defined in the
//! language descriptor.
//!
//
const uint8_t * const *ppui8StringDescriptors;
//
//! The number of descriptors provided in the ppStringDescriptors
//! array. This must be 1 + ((5 + (number of strings)) *
//! (number of languages)).
//
const uint32_t ui32NumStringDescriptors;
//
//! The number of devices in the psDevices array.
//
const uint32_t ui32NumDevices;
//
//! This application supplied array holds the the top level device class
//! information as well as the Instance data for that class.
//
tCompositeEntry * const psDevices;
//
//! The private data for this device instance. This memory must remain
//! accessible for as long as the composite device is in use and must
//! not be modified by any code outside the composite class driver.
//
tCompositeInstance sPrivateData;
}
tUSBDCompositeDevice;
//*****************************************************************************
//
// Return to default packing when using the IAR Embedded Workbench compiler.
//
//*****************************************************************************
#ifdef __ICCARM__
#pragma pack()
#endif
//*****************************************************************************
//
// Composite specific device class driver events
//
//*****************************************************************************
//*****************************************************************************
//
// API Function Prototypes
//
//*****************************************************************************
extern void *USBDCompositeInit(uint32_t ui32Index,
tUSBDCompositeDevice *psCompDevice,
uint32_t ui32Size, uint8_t *pui8Data);
extern void USBDCompositeTerm(void *pvInstance);
//*****************************************************************************
//
// Close the Doxygen group.
//! @}
//
//*****************************************************************************
//*****************************************************************************
//
// Mark the end of the C bindings section for C++ compilers.
//
//*****************************************************************************
#ifdef __cplusplus
}
#endif
#endif
@@ -0,0 +1,210 @@
//#############################################################################
// FILE: usbddfu_rt.h
// TITLE: Definitions used by runtime DFU class devices.
//#############################################################################
//!
//! Copyright: Copyright (C) 2023 Texas Instruments Incorporated -
//! All rights reserved not granted herein.
//! Limited License.
//!
//! Texas Instruments Incorporated grants a world-wide, royalty-free,
//! non-exclusive license under copyrights and patents it now or hereafter
//! owns or controls to make, have made, use, import, offer to sell and sell
//! ("Utilize") this software subject to the terms herein. With respect to the
//! foregoing patent license, such license is granted solely to the extent that
//! any such patent is necessary to Utilize the software alone. The patent
//! license shall not apply to any combinations which include this software,
//! other than combinations with devices manufactured by or for TI
//! ("TI Devices").
//! No hardware patent is licensed hereunder.
//!
//! Redistributions must preserve existing copyright notices and reproduce this
//! license (including the above copyright notice and the disclaimer and
//! (if applicable) source code license limitations below) in the documentation
//! and/or other materials provided with the distribution.
//!
//! Redistribution and use in binary form, without modification, are permitted
//! provided that the following conditions are met:
//!
//! * No reverse engineering, decompilation, or disassembly of this software is
//! permitted with respect to any software provided in binary form.
//! * Any redistribution and use are licensed by TI for use only
//! with TI Devices.
//! * Nothing shall obligate TI to provide you with source code for the
//! software licensed and provided to you in object code.
//!
//! If software source code is provided to you, modification and redistribution
//! of the source code are permitted provided that the following conditions
//! are met:
//!
//! * any redistribution and use of the source code, including any resulting
//! derivative works, are licensed by TI for use only with TI Devices.
//! * any redistribution and use of any object code compiled from the source
//! code and any resulting derivative works, are licensed by TI for use
//! only with TI Devices.
//!
//! Neither the name of Texas Instruments Incorporated nor the names of its
//! suppliers may be used to endorse or promote products derived from this
//! software without specific prior written permission.
//#############################################################################
#ifndef __USBDDFURT_H__
#define __USBDDFURT_H__
//*****************************************************************************
//
// If building with a C++ compiler, make all of the definitions in this header
// have a C binding.
//
//*****************************************************************************
#ifdef __cplusplus
extern "C"
{
#endif
//*****************************************************************************
//
//! \addtogroup dfu_device_class_api
//! @{
//
//*****************************************************************************
//*****************************************************************************
//
// This is the size of the g_pui8DFUInterface array in bytes.
//
//*****************************************************************************
#define DFUINTERFACE_SIZE (9)
//*****************************************************************************
//
// This is the size of the g_pui8DFUFunctionalDesc array in bytes.
//
//*****************************************************************************
#define DFUFUNCTIONALDESC_SIZE (9)
//*****************************************************************************
//
//! The size of the memory that should be allocated to create a configuration
//! descriptor for a single instance of the DFU runtime device. This does not
//! include the configuration descriptor which is automatically ignored by the
//! composite device class.
//!
//! This label is used to compute the value which will be passed to the
//! USBDCompositeInit function in the ui32Size parameter.
//
//*****************************************************************************
#define COMPOSITE_DDFU_SIZE (DFUINTERFACE_SIZE + DFUFUNCTIONALDESC_SIZE)
//*****************************************************************************
//
//! This value is passed to the client via the callback function provided in
//! the tUSBDDFUDevice structure and indicates that the host has sent a DETACH
//! request to the DFU interface. This request indicates that the device detach
//! from the USB bus and reattach in DFU mode in preparation for a firmware
//! upgrade. Currently, this is the only event that the DFU runtime class
//! reports to the client.
//!
//! When this event is received, the client should call USBDDFUUpdateBegin()
//! from a non-interrupt context at its earliest opportunity.
//
//*****************************************************************************
#define USBD_DFU_EVENT_DETACH (USBD_DFU_EVENT_BASE + 0)
//*****************************************************************************
//
// PRIVATE
//
// This structure defines the private instance data and state variables for
// DFU devices. The memory for this structure is included in the
// sPrivateData field in the tUSBDDFUDevice structure passed in the
// USBDDFUCompositeInit() function.
//
//*****************************************************************************
typedef struct
{
//
// Base address for the USB controller.
//
uint32_t ui32USBBase;
//
// The device info to interact with the lower level DCD code.
//
tDeviceInfo sDevInfo;
//
// The DFU class interface number, this is modified in composite devices.
//
uint8_t ui8Interface;
//
// The connection status of the device.
//
bool bConnected;
}
tDFUInstance;
//*****************************************************************************
//
//! The structure used by the application to define operating parameters for
//! the DFU device. Note that, unlike all other devices, this structure does
//! not contain any fields which configure the device descriptor sent back to
//! the host. The DFU runtime device class must be used as part of a composite
//! device since all it provides is the capability to signal the device to
//! switch into DFU mode in preparation for a firmware upgrade. Creating a
//! device with nothing but DFU runtime mode capability is rather pointless
//! so this is not supported.
//
//*****************************************************************************
typedef struct
{
//
//! A pointer to the callback function which will be called to notify
//! the application of DETACH requests.
//
const tUSBCallback pfnCallback;
//
//! A client-supplied pointer which will be sent as the first
//! parameter in all calls made to the pfnCallback function.
//
void * const pvCBData;
//
//! The private instance data for this device class. This
//! memory must remain accessible for as long as the DFU device is in use
//! and must not be modified by any code outside the DFU class driver.
//
tDFUInstance sPrivateData;
}
tUSBDDFUDevice;
//*****************************************************************************
//
// API Function Prototypes
//
//*****************************************************************************
extern void *USBDDFUCompositeInit(uint32_t ui32Index,
tUSBDDFUDevice *psDFUDevice,
tCompositeEntry *psCompEntry);
extern void USBDDFUCompositeTerm(void *pvDFUInstance);
extern void USBDDFUUpdateBegin(void);
//*****************************************************************************
//
// Close the Doxygen group.
//! @}
//
//*****************************************************************************
//*****************************************************************************
//
// Mark the end of the C bindings section for C++ compilers.
//
//*****************************************************************************
#ifdef __cplusplus
}
#endif
#endif // __USBDDFURT_H__
@@ -0,0 +1,232 @@
//#############################################################################
// FILE: usbdevice.h
// TITLE: types and definitions used during USB enumeration
//#############################################################################
//!
//! Copyright: Copyright (C) 2023 Texas Instruments Incorporated -
//! All rights reserved not granted herein.
//! Limited License.
//!
//! Texas Instruments Incorporated grants a world-wide, royalty-free,
//! non-exclusive license under copyrights and patents it now or hereafter
//! owns or controls to make, have made, use, import, offer to sell and sell
//! ("Utilize") this software subject to the terms herein. With respect to the
//! foregoing patent license, such license is granted solely to the extent that
//! any such patent is necessary to Utilize the software alone. The patent
//! license shall not apply to any combinations which include this software,
//! other than combinations with devices manufactured by or for TI
//! ("TI Devices").
//! No hardware patent is licensed hereunder.
//!
//! Redistributions must preserve existing copyright notices and reproduce this
//! license (including the above copyright notice and the disclaimer and
//! (if applicable) source code license limitations below) in the documentation
//! and/or other materials provided with the distribution.
//!
//! Redistribution and use in binary form, without modification, are permitted
//! provided that the following conditions are met:
//!
//! * No reverse engineering, decompilation, or disassembly of this software is
//! permitted with respect to any software provided in binary form.
//! * Any redistribution and use are licensed by TI for use only
//! with TI Devices.
//! * Nothing shall obligate TI to provide you with source code for the
//! software licensed and provided to you in object code.
//!
//! If software source code is provided to you, modification and redistribution
//! of the source code are permitted provided that the following conditions
//! are met:
//!
//! * any redistribution and use of the source code, including any resulting
//! derivative works, are licensed by TI for use only with TI Devices.
//! * any redistribution and use of any object code compiled from the source
//! code and any resulting derivative works, are licensed by TI for use
//! only with TI Devices.
//!
//! Neither the name of Texas Instruments Incorporated nor the names of its
//! suppliers may be used to endorse or promote products derived from this
//! software without specific prior written permission.
//#############################################################################
#ifndef __USBDEVICE_H__
#define __USBDEVICE_H__
//*****************************************************************************
//
// If building with a C++ compiler, make all of the definitions in this header
// have a C binding.
//
//*****************************************************************************
#ifdef __cplusplus
extern "C"
{
#endif
//*****************************************************************************
//
//! \addtogroup device_api
//! @{
//
//*****************************************************************************
//*****************************************************************************
//
//! The maximum number of independent interfaces that any single device
//! implementation can support. Independent interfaces means interface
//! descriptors with different bInterfaceNumber values - several interface
//! descriptors offering different alternative settings but the same interface
//! number count as a single interface.
//
//*****************************************************************************
#define USB_MAX_INTERFACES_PER_DEVICE 8
#include "usbdevicepriv.h"
//*****************************************************************************
//
//! This structure is passed to the USB library on a call to USBDCDInit and
//! provides the library with information about the device that the
//! application is implementing. It contains functions pointers for the
//! various USB event handlers and pointers to each of the standard device
//! descriptors.
//
//*****************************************************************************
struct tDeviceInfo
{
//
//! A pointer to a structure containing pointers to event handler functions
//! provided by the client to support the operation of this device.
//
const tCustomHandlers * psCallbacks;
//
//! A pointer to the device descriptor for this device.
//
const uint8_t *pui8DeviceDescriptor;
//
//! A pointer to an array of configuration descriptor pointers. Each entry
//! in the array corresponds to one configuration that the device may be
//! set to use by the USB host. The number of entries in the array must
//! match the bNumConfigurations value in the device descriptor
//! array, pui8DeviceDescriptor.
//
const tConfigHeader * const *ppsConfigDescriptors;
//
//! A pointer to the string descriptor array for this device. This array
//! must be arranged as follows:
//!
//! - [0] - Standard descriptor containing supported language codes.
//! - [1] - String 1 for the first language listed in descriptor 0.
//! - [2] - String 2 for the first language listed in descriptor 0.
//! - ...
//! - [n] - String n for the first language listed in descriptor 0.
//! - [n+1] - String 1 for the second language listed in descriptor 0.
//! - ...
//! - [2n] - String n for the second language listed in descriptor 0.
//! - [2n+1]- String 1 for the third language listed in descriptor 0.
//! - ...
//! - [3n] - String n for the third language listed in descriptor 0.
//!
//! and so on.
//
const uint8_t * const *ppui8StringDescriptors;
//
//! The total number of descriptors provided in the ppStringDescriptors
//! array.
//
uint32_t ui32NumStringDescriptors;
};
//*****************************************************************************
//
//! This type is used by an application to describe and instance of a device
//! and an instance data pointer for that class. The psDevice pointer should
//! be a pointer to a valid device class to include in the composite device.
//! The pvInstance pointer should be a pointer to an instance pointer for the
//! device in the psDevice pointer.
//!
//
//*****************************************************************************
typedef struct
{
//
//! This is the top level device information structure.
//
const tDeviceInfo *psDevInfo;
//
//! This is the instance data for the device structure.
//
void *pvInstance;
//
//! A per-device workspace used by the composite device.
//
uint32_t ui32DeviceWorkspace;
}
tCompositeEntry;
//*****************************************************************************
//
// Close the Doxygen group.
//! @}
//
//*****************************************************************************
//*****************************************************************************
//
// Public APIs offered by the USB library device control driver.
//
//*****************************************************************************
extern void USBDCDInit(uint32_t ui32Index, tDeviceInfo *psDevice,
void *pvDCDCBData);
extern void USBDCDTerm(uint32_t ui32Index);
extern void USBDCDStallEP0(uint32_t ui32Index);
extern void USBDCDRequestDataEP0(uint32_t ui32Index, uint8_t *pui8Data,
uint32_t ui32Size);
extern void USBDCDSendDataEP0(uint32_t ui32Index, uint8_t *pui8Data,
uint32_t ui32Size);
extern void USBDCDSetDefaultConfiguration(uint32_t ui32Index,
uint32_t ui32DefaultConfig);
extern uint32_t USBDCDConfigDescGetSize(const tConfigHeader *psConfig);
extern uint32_t USBDCDConfigDescGetNum(const tConfigHeader *psConfig,
uint32_t ui32Type);
extern tDescriptorHeader *USBDCDConfigDescGet(const tConfigHeader *psConfig,
uint32_t ui32Type,
uint32_t ui32Index,
uint32_t *pui32Section);
extern uint32_t
USBDCDConfigGetNumAlternateInterfaces(const tConfigHeader *psConfig,
uint8_t ui8InterfaceNumber);
extern tInterfaceDescriptor *
USBDCDConfigGetInterface(const tConfigHeader *psConfig,
uint32_t ui32Index, uint32_t ui32AltCfg,
uint32_t *pui32Section);
extern tEndpointDescriptor *
USBDCDConfigGetInterfaceEndpoint(const tConfigHeader *psConfig,
uint32_t ui32InterfaceNumber,
uint32_t ui32AltCfg,
uint32_t ui32Index);
extern void USBDCDPowerStatusSet(uint32_t ui32Index, uint8_t ui8Power);
extern bool USBDCDRemoteWakeupRequest(uint32_t ui32Index);
//*****************************************************************************
//
// Device mode interrupt handler for controller index 0.
//
//*****************************************************************************
extern void USB0DeviceIntHandler(void);
//*****************************************************************************
//
// Mark the end of the C bindings section for C++ compilers.
//
//*****************************************************************************
#ifdef __cplusplus
}
#endif
#endif // __USBENUM_H__
@@ -0,0 +1,263 @@
//#############################################################################
// FILE: usbdevicepriv.h
// TITLE: Private header file used to share internal variables and
// modules in the USB library. This header MUST NOT be
// used by application code.
//#############################################################################
//!
//! Copyright: Copyright (C) 2023 Texas Instruments Incorporated -
//! All rights reserved not granted herein.
//! Limited License.
//!
//! Texas Instruments Incorporated grants a world-wide, royalty-free,
//! non-exclusive license under copyrights and patents it now or hereafter
//! owns or controls to make, have made, use, import, offer to sell and sell
//! ("Utilize") this software subject to the terms herein. With respect to the
//! foregoing patent license, such license is granted solely to the extent that
//! any such patent is necessary to Utilize the software alone. The patent
//! license shall not apply to any combinations which include this software,
//! other than combinations with devices manufactured by or for TI
//! ("TI Devices").
//! No hardware patent is licensed hereunder.
//!
//! Redistributions must preserve existing copyright notices and reproduce this
//! license (including the above copyright notice and the disclaimer and
//! (if applicable) source code license limitations below) in the documentation
//! and/or other materials provided with the distribution.
//!
//! Redistribution and use in binary form, without modification, are permitted
//! provided that the following conditions are met:
//!
//! * No reverse engineering, decompilation, or disassembly of this software is
//! permitted with respect to any software provided in binary form.
//! * Any redistribution and use are licensed by TI for use only
//! with TI Devices.
//! * Nothing shall obligate TI to provide you with source code for the
//! software licensed and provided to you in object code.
//!
//! If software source code is provided to you, modification and redistribution
//! of the source code are permitted provided that the following conditions
//! are met:
//!
//! * any redistribution and use of the source code, including any resulting
//! derivative works, are licensed by TI for use only with TI Devices.
//! * any redistribution and use of any object code compiled from the source
//! code and any resulting derivative works, are licensed by TI for use
//! only with TI Devices.
//!
//! Neither the name of Texas Instruments Incorporated nor the names of its
//! suppliers may be used to endorse or promote products derived from this
//! software without specific prior written permission.
//#############################################################################
#ifndef __USBDEVICEPRIV_H__
#define __USBDEVICEPRIV_H__
//*****************************************************************************
//
// If building with a C++ compiler, make all of the definitions in this header
// have a C binding.
//
//*****************************************************************************
#ifdef __cplusplus
extern "C"
{
#endif
//*****************************************************************************
//
// The states for endpoint zero during enumeration.
//
//*****************************************************************************
typedef enum
{
//
// The USB device is waiting on a request from the host controller on
// endpoint zero.
//
eUSBStateIdle,
//
// The USB device is sending data back to the host due to an IN request.
//
eUSBStateTx,
//
// The USB device is sending the configuration descriptor back to the host
// due to an IN request.
//
eUSBStateTxConfig,
//
// The USB device is receiving data from the host due to an OUT
// request from the host.
//
eUSBStateRx,
//
// The USB device has completed the IN or OUT request and is now waiting
// for the host to acknowledge the end of the IN/OUT transaction. This
// is the status phase for a USB control transaction.
//
eUSBStateStatus,
//
// This endpoint has signaled a stall condition and is waiting for the
// stall to be acknowledged by the host controller.
//
eUSBStateStall
}
tEP0State;
typedef struct tDeviceInfo tDeviceInfo;
//*****************************************************************************
//
// The USB controller device information.
//
//*****************************************************************************
typedef struct
{
//
// The current state of endpoint zero.
//
volatile tEP0State iEP0State;
//
// The devices current address, this also has a change pending bit in the
// MSB of this value specified by DEV_ADDR_PENDING.
//
volatile uint32_t ui32DevAddress;
//
// This holds the current active configuration for this device.
//
uint32_t ui32Configuration;
//
// This holds the configuration id that will take effect after a reset.
//
uint32_t ui32DefaultConfiguration;
//
// This holds the current alternate interface for this device.
//
uint8_t pui8AltSetting[USB_MAX_INTERFACES_PER_DEVICE];
//
// This is the pointer to the current data being sent out or received
// on endpoint zero.
//
uint8_t *pui8EP0Data;
//
// This is the number of bytes that remain to be sent from or received
// into the g_sUSBDeviceState.pui8EP0Data data buffer.
//
volatile uint32_t ui32EP0DataRemain;
//
// The amount of data being sent/received due to a custom request.
//
uint32_t ui32OUTDataSize;
//
// Holds the current device status.
//
uint8_t ui8Status;
//
// Holds the endpoint status for the HALT condition. This array is sized
// to hold halt status for all IN and OUT endpoints.
//
uint8_t ppui8Halt[2][USBLIB_NUM_EP - 1];
//
// Holds the configuration descriptor section number currently being sent
// to the host.
//
uint8_t ui8ConfigSection;
//
// Holds the offset within the configuration descriptor section currently
// being sent to the host.
//
uint8_t ui8SectionOffset;
//
// Holds the index of the configuration that we are currently sending back
// to the host.
//
uint8_t ui8ConfigIndex;
//
// This flag is set to true if the client has called USBDPowerStatusSet()
// and tells the USB library not to try to determine the current power
// status from the configuration descriptor.
//
bool bPwrSrcSet;
//
// This flag indicates whether or not remote wake up signaling is in
// progress.
//
bool bRemoteWakeup;
//
// During remote wake up signaling, this counter is used to track the
// number of milliseconds since the signaling was initiated.
//
uint8_t ui8RemoteWakeupCount;
//
// The DMA instance information for this USB controller.
//
tUSBDMAInstance *psDMAInstance;
//
// The interrupt number for this instance.
//
uint32_t ui32IntNum;
//
// Pointer to the device supplied call back data.
//
void *pvCBData;
}
tDCDInstance;
extern tDCDInstance g_psDCDInst[];
extern tDeviceInfo *g_ppsDevInfo[];
//*****************************************************************************
//
// Device enumeration functions provided by device/usbenum.c and called from
// the interrupt handler in device/usbhandler.c
//
//*****************************************************************************
extern bool USBDeviceConfig(tDCDInstance *psDevInst,
const tConfigHeader *psConfig);
extern bool USBDeviceConfigAlternate(tDCDInstance *psDevInst,
const tConfigHeader *psConfig,
uint8_t ui8InterfaceNum,
uint8_t ui8AlternateSetting);
extern void USBDCDDeviceInfoInit(uint32_t ui32Index, tDeviceInfo *psDevice);
//*****************************************************************************
//
// Macro access function to device information.
//
//*****************************************************************************
#define DCDGetDMAInstance(psDevInfo) (&(psDevInfo->psDCDInst->sDMAInstance))
//*****************************************************************************
//
// Mark the end of the C bindings section for C++ compilers.
//
//*****************************************************************************
#ifdef __cplusplus
}
#endif
#endif // __USBDEVICEPRIV_H__
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,390 @@
//#############################################################################
// FILE: usbdhidkeyb.h
// TITLE: Definitions used by HID keyboard class devices
//#############################################################################
//!
//! Copyright: Copyright (C) 2023 Texas Instruments Incorporated -
//! All rights reserved not granted herein.
//! Limited License.
//!
//! Texas Instruments Incorporated grants a world-wide, royalty-free,
//! non-exclusive license under copyrights and patents it now or hereafter
//! owns or controls to make, have made, use, import, offer to sell and sell
//! ("Utilize") this software subject to the terms herein. With respect to the
//! foregoing patent license, such license is granted solely to the extent that
//! any such patent is necessary to Utilize the software alone. The patent
//! license shall not apply to any combinations which include this software,
//! other than combinations with devices manufactured by or for TI
//! ("TI Devices").
//! No hardware patent is licensed hereunder.
//!
//! Redistributions must preserve existing copyright notices and reproduce this
//! license (including the above copyright notice and the disclaimer and
//! (if applicable) source code license limitations below) in the documentation
//! and/or other materials provided with the distribution.
//!
//! Redistribution and use in binary form, without modification, are permitted
//! provided that the following conditions are met:
//!
//! * No reverse engineering, decompilation, or disassembly of this software is
//! permitted with respect to any software provided in binary form.
//! * Any redistribution and use are licensed by TI for use only
//! with TI Devices.
//! * Nothing shall obligate TI to provide you with source code for the
//! software licensed and provided to you in object code.
//!
//! If software source code is provided to you, modification and redistribution
//! of the source code are permitted provided that the following conditions
//! are met:
//!
//! * any redistribution and use of the source code, including any resulting
//! derivative works, are licensed by TI for use only with TI Devices.
//! * any redistribution and use of any object code compiled from the source
//! code and any resulting derivative works, are licensed by TI for use
//! only with TI Devices.
//!
//! Neither the name of Texas Instruments Incorporated nor the names of its
//! suppliers may be used to endorse or promote products derived from this
//! software without specific prior written permission.
//#############################################################################
#ifndef __USBDHIDKEYB_H__
#define __USBDHIDKEYB_H__
//*****************************************************************************
//
// If building with a C++ compiler, make all of the definitions in this header
// have a C binding.
//
//*****************************************************************************
#ifdef __cplusplus
extern "C"
{
#endif
//*****************************************************************************
//
//! \addtogroup hid_keyboard_device_class_api
//! @{
//
//*****************************************************************************
//*****************************************************************************
//
//! The maximum number of simultaneously-pressed, non-modifier keys that the
//! HID BIOS keyboard protocol can send at once. Attempts to send more pressed
//! keys than this will result in a rollover error being reported to the host
//! and KEYB_ERR_TOO_MANY_KEYS being returned from
//! USBDHIDKeyboardKeyStateChange.
//
//*****************************************************************************
#define KEYB_MAX_CHARS_PER_REPORT \
6
//*****************************************************************************
//
// PRIVATE
//
// The first few sections of this header are private defines that are used by
// the USB HID keyboard code and are here only to help with the application
// allocating the correct amount of memory for the USB HID Keyboard device
// code.
//
//*****************************************************************************
//*****************************************************************************
//
// PRIVATE
//
// This enumeration holds the various states that the keyboard can be in during
// normal operation.
//
//*****************************************************************************
typedef enum
{
//
// Unconfigured.
//
HID_KEYBOARD_STATE_UNCONFIGURED,
//
// No keys to send and not waiting on data.
//
HID_KEYBOARD_STATE_IDLE,
//
// Waiting on report data from the host.
//
HID_KEYBOARD_STATE_WAIT_DATA,
//
// Waiting on data to be sent out.
//
HID_KEYBOARD_STATE_SEND
}
tKeyboardState;
//*****************************************************************************
//
// PRIVATE
//
// The size of the keyboard input and output reports.
//
//*****************************************************************************
#define KEYB_IN_REPORT_SIZE 8
#define KEYB_OUT_REPORT_SIZE 1
//*****************************************************************************
//
// PRIVATE
//
// This structure defines the private instance data structure for the USB HID
// keyboard device. This structure forms the RAM workspace used by each
// instance of the keyboard.
//
//*****************************************************************************
typedef struct
{
//
// The USB configuration number set by the host or 0 of the device is
// currently unconfigured.
//
uint8_t ui8USBConfigured;
//
// The protocol requested by the host, USB_HID_PROTOCOL_BOOT or
// USB_HID_PROTOCOL_REPORT.
//
uint8_t ui8Protocol;
//
// The current states that the keyboard LEDs are to be set to.
//
volatile uint8_t ui8LEDStates;
//
// The total number of keys currently pressed. This indicates the number
// of key press entries in the pui8KeysPressed array.
//
uint8_t ui8KeyCount;
//
// The current state of the keyboard interrupt IN endpoint.
//
volatile tKeyboardState eKeyboardState;
//
// A flag to indicate that the application pressed or released a key
// but that we couldn't send the report immediately.
//
volatile bool bChangeMade;
//
// A buffer used to receive output reports from the host.
//
uint8_t pui8DataBuffer[KEYB_OUT_REPORT_SIZE];
//
// A buffer used to hold the last input report sent to the host.
//
uint8_t pui8Report[KEYB_IN_REPORT_SIZE];
//
// A buffer containing the usage codes of all non-modifier keys currently
// in the pressed state.
//
uint8_t pui8KeysPressed[KEYB_MAX_CHARS_PER_REPORT];
//
// The idle timeout control structure for our input report. This is
// required by the lower level HID driver.
//
tHIDReportIdle sReportIdle;
//
// This is needed for the lower level HID driver.
//
tUSBDHIDDevice sHIDDevice;
}
tHIDKeyboardInstance;
//*****************************************************************************
//
//! This structure is used by the application to define operating parameters
//! for the HID keyboard device.
//
//*****************************************************************************
typedef struct
{
//
//! The vendor ID that this device is to present in the device descriptor.
//
const uint16_t ui16VID;
//
//! The product ID that this device is to present in the device descriptor.
//
const uint16_t ui16PID;
//
//! The maximum power consumption of the device, expressed in milliamps.
//
const uint16_t ui16MaxPowermA;
//
//! Indicates whether the device is self- or bus-powered and whether or not
//! it supports remote wakeup. Valid values are USB_CONF_ATTR_SELF_PWR or
//! USB_CONF_ATTR_BUS_PWR, optionally ORed with USB_CONF_ATTR_RWAKE.
//
const uint8_t ui8PwrAttributes;
//! A pointer to the callback function which will be called to notify
//! the application of general events and those related to reception of
//! Output and Feature reports via the (optional) interrupt OUT endpoint.
//
const tUSBCallback pfnCallback;
//
//! A client-supplied pointer which will be sent as the first
//! parameter in all calls made to the keyboard callback,
//! pfnCallback.
//
void *pvCBData;
//
//! A pointer to the string descriptor array for this device. This array
//! must contain the following string descriptor pointers in this order.
//! Language descriptor, Manufacturer name string (language 1), Product
//! name string (language 1), Serial number string (language 1),HID
//! Interface description string (language 1), Configuration description
//! string (language 1).
//!
//! If supporting more than 1 language, the descriptor block (except for
//! string descriptor 0) must be repeated for each language defined in the
//! language descriptor.
//
const uint8_t * const *ppui8StringDescriptors;
//
//! The number of descriptors provided in the ppStringDescriptors
//! array. This must be (1 + (5 * (num languages))).
//
const uint32_t ui32NumStringDescriptors;
//
//! The private instance data for this device. This memory must
//! remain accessible for as long as the keyboard device is in use and
//! must not be modified by any code outside the HID keyboard driver.
//
tHIDKeyboardInstance sPrivateData;
}
tUSBDHIDKeyboardDevice;
//*****************************************************************************
//
// Keyboard-specific device class driver events
//
//*****************************************************************************
//*****************************************************************************
//
//! This event indicates that the keyboard LED states are to be set. The
//! ui32MsgValue parameter contains the requested state for each of the LEDs
//! defined as a collection of ORed bits where a 1 indicates that the LED is
//! to be turned on and a 0 indicates that it should be turned off. The
//! individual LED bits are defined using labels HID_KEYB_NUM_LOCK,
//! HID_KEYB_CAPS_LOCK, HID_KEYB_SCROLL_LOCK, HID_KEYB_COMPOSE and
//! HID_KEYB_KANA.
//
//*****************************************************************************
#define USBD_HID_KEYB_EVENT_SET_LEDS \
USBD_HID_KEYB_EVENT_BASE
//*****************************************************************************
//
//! This return code from USBDHIDKeyboardKeyStateChange indicates success.
//
//*****************************************************************************
#define KEYB_SUCCESS 0
//*****************************************************************************
//
//! This return code from USBDHIDKeyboardKeyStateChange indicates that an
//! attempt has been made to record more than 6 simultaneously pressed,
//! non-modifier keys. The USB HID BIOS keyboard protocol allows no more than
//! 6 pressed keys to be reported at one time. Until at least one key is
//! released, the device will report a roll over error to the host each time it
//! is asked for the keyboard input report.
//
//*****************************************************************************
#define KEYB_ERR_TOO_MANY_KEYS 1
//*****************************************************************************
//
//! This return code from USBDHIDKeyboardKeyStateChange indicates that an
//! error was reported while attempting to send a report to the host. A client
//! should assume that the host has disconnected if this return code is seen.
//
//*****************************************************************************
#define KEYB_ERR_TX_ERROR 2
//*****************************************************************************
//
//! USBDHIDKeyboardKeyStateChange returns this value if it is called with the
//! bPress parameter set to false but with a ui8UsageCode parameter which does
//! does not indicate a key that is currently recorded as being pressed. This
//! may occur if an attempt was previously made to report more than 6 pressed
//! keys and the earlier pressed keys are released before the later ones. This
//! condition is benign and should not be used to indicate a host disconnection
//! or serious error.
//
//*****************************************************************************
#define KEYB_ERR_NOT_FOUND 3
//*****************************************************************************
//
//! USBDHIDKeyboardKeyStateChange returns this value if it is called before the
//! USB host has connected and configured the device. Any key usage code
//! passed will be stored and passed to the host once configuration completes.
//
//*****************************************************************************
#define KEYB_ERR_NOT_CONFIGURED 4
//*****************************************************************************
//
// API Function Prototypes
//
//*****************************************************************************
extern void *USBDHIDKeyboardInit(uint32_t ui32Index,
tUSBDHIDKeyboardDevice *psHIDKbDevice);
extern void *USBDHIDKeyboardCompositeInit(uint32_t ui32Index,
tUSBDHIDKeyboardDevice *psHIDKbDevice,
tCompositeEntry *psCompEntry);
extern void USBDHIDKeyboardTerm(void *pvKeyboardInstance);
extern void *USBDHIDKeyboardSetCBData(void *pvKeyboardInstance,
void *pvCBData);
extern uint32_t USBDHIDKeyboardKeyStateChange(void *pvKeyboardInstance,
uint8_t ui8Modifiers,
uint8_t ui8UsageCode,
bool bPressed);
extern void USBDHIDKeyboardPowerStatusSet(void *pvKeyboardInstance,
uint8_t ui8Power);
extern bool USBDHIDKeyboardRemoteWakeupRequest(void *pvKeyboardInstance);
//*****************************************************************************
//
// Close the Doxygen group.
//! @}
//
//*****************************************************************************
//*****************************************************************************
//
// Mark the end of the C bindings section for C++ compilers.
//
//*****************************************************************************
#ifdef __cplusplus
}
#endif
#endif // __USBDHIDKEYB_H__
@@ -0,0 +1,324 @@
//#############################################################################
// FILE: usbdhidmouse.h
// TITLE: Public header file for the USB HID Mouse device class
//#############################################################################
//!
//! Copyright: Copyright (C) 2023 Texas Instruments Incorporated -
//! All rights reserved not granted herein.
//! Limited License.
//!
//! Texas Instruments Incorporated grants a world-wide, royalty-free,
//! non-exclusive license under copyrights and patents it now or hereafter
//! owns or controls to make, have made, use, import, offer to sell and sell
//! ("Utilize") this software subject to the terms herein. With respect to the
//! foregoing patent license, such license is granted solely to the extent that
//! any such patent is necessary to Utilize the software alone. The patent
//! license shall not apply to any combinations which include this software,
//! other than combinations with devices manufactured by or for TI
//! ("TI Devices").
//! No hardware patent is licensed hereunder.
//!
//! Redistributions must preserve existing copyright notices and reproduce this
//! license (including the above copyright notice and the disclaimer and
//! (if applicable) source code license limitations below) in the documentation
//! and/or other materials provided with the distribution.
//!
//! Redistribution and use in binary form, without modification, are permitted
//! provided that the following conditions are met:
//!
//! * No reverse engineering, decompilation, or disassembly of this software is
//! permitted with respect to any software provided in binary form.
//! * Any redistribution and use are licensed by TI for use only
//! with TI Devices.
//! * Nothing shall obligate TI to provide you with source code for the
//! software licensed and provided to you in object code.
//!
//! If software source code is provided to you, modification and redistribution
//! of the source code are permitted provided that the following conditions
//! are met:
//!
//! * any redistribution and use of the source code, including any resulting
//! derivative works, are licensed by TI for use only with TI Devices.
//! * any redistribution and use of any object code compiled from the source
//! code and any resulting derivative works, are licensed by TI for use
//! only with TI Devices.
//!
//! Neither the name of Texas Instruments Incorporated nor the names of its
//! suppliers may be used to endorse or promote products derived from this
//! software without specific prior written permission.
//#############################################################################
#ifndef __USBDHIDMOUSE_H__
#define __USBDHIDMOUSE_H__
//*****************************************************************************
//
// If building with a C++ compiler, make all of the definitions in this header
// have a C binding.
//
//*****************************************************************************
#ifdef __cplusplus
extern "C"
{
#endif
//*****************************************************************************
//
//! \addtogroup hid_mouse_device_class_api
//! @{
//
//*****************************************************************************
//*****************************************************************************
//
// PRIVATE
//
// The first few sections of this header are private defines that are used by
// the USB HID mouse code and are here only to help with the application
// allocating the correct amount of memory for the HID mouse device code.
//
//*****************************************************************************
//*****************************************************************************
//
// PRIVATE
//
// The size of the mouse input report sent to the host.
//
//*****************************************************************************
#define MOUSE_REPORT_SIZE 3
//*****************************************************************************
//
// PRIVATE
//
// This enumeration holds the various states that the mouse can be in during
// normal operation.
//
//*****************************************************************************
typedef enum
{
//
// Unconfigured.
//
eHIDMouseStateUnconfigured,
//
// No keys to send and not waiting on data.
//
eHIDMouseStateIdle,
//
// Waiting on report data from the host.
//
eHIDMouseStateWaitData,
//
// Waiting on data to be sent out.
//
eHIDMouseStateSend
}
tMouseState;
//*****************************************************************************
//
// PRIVATE
//
// This structure provides the private instance data structure for the USB
// HID Mouse device. This structure forms the RAM workspace used by each
// instance of the mouse.
//
//*****************************************************************************
typedef struct
{
//
// The USB configuration number set by the host or 0 of the device is
// currently unconfigured.
//
uint8_t ui8USBConfigured;
//
// The protocol requested by the host, USB_HID_PROTOCOL_BOOT or
// USB_HID_PROTOCOL_REPORT.
//
uint8_t ui8Protocol;
//
// A buffer used to hold the last input report sent to the host.
//
uint8_t pui8Report[MOUSE_REPORT_SIZE];
//
// The current state of the mouse interrupt IN endpoint.
//
volatile tMouseState iMouseState;
//
// The idle timeout control structure for our input report. This is
// required by the lower level HID driver.
//
tHIDReportIdle sReportIdle;
//
// This is needed for the lower level HID driver.
//
tUSBDHIDDevice sHIDDevice;
}
tHIDMouseInstance;
//*****************************************************************************
//
//! This structure is used by the application to define operating parameters
//! for the HID mouse device.
//
//*****************************************************************************
typedef struct
{
//
//! The vendor ID that this device is to present in the device descriptor.
//
const uint16_t ui16VID;
//
//! The product ID that this device is to present in the device descriptor.
//
const uint16_t ui16PID;
//
//! The maximum power consumption of the device, expressed in milliamps.
//
const uint16_t ui16MaxPowermA;
//
//! Indicates whether the device is self- or bus-powered and whether or not
//! it supports remote wakeup. Valid values are USB_CONF_ATTR_SELF_PWR or
//! USB_CONF_ATTR_BUS_PWR, optionally ORed with USB_CONF_ATTR_RWAKE.
//
const uint8_t ui8PwrAttributes;
//
//! A pointer to the callback function which is called to notify
//! the application of events relating to the operation of the mouse.
//
const tUSBCallback pfnCallback;
//
//! A client-supplied pointer which is sent as the first
//! parameter in all calls made to the mouse callback, pfnCallback.
//
void *pvCBData;
//
//! A pointer to the string descriptor array for this device. This array
//! must contain the following string descriptor pointers in this order.
//! Language descriptor, Manufacturer name string (language 1), Product
//! name string (language 1), Serial number string (language 1),HID
//! Interface description string (language 1), Configuration description
//! string (language 1).
//!
//! If supporting more than 1 language, the descriptor block (except for
//! string descriptor 0) must be repeated for each language defined in the
//! language descriptor.
//
const uint8_t * const *ppui8StringDescriptors;
//
//! The number of descriptors provided in the ppStringDescriptors
//! array. This must be (1 + (5 * (num languages))).
//
const uint32_t ui32NumStringDescriptors;
//
//! The private instance data for this device. This memory must
//! remain accessible for as long as the mouse device is in use and must
//! not be modified by any code outside the HID mouse driver.
//
tHIDMouseInstance sPrivateData;
}
tUSBDHIDMouseDevice;
//*****************************************************************************
//
//! This return code from USBDHIDMouseStateChange indicates success.
//
//*****************************************************************************
#define MOUSE_SUCCESS 0
//*****************************************************************************
//
//! This return code from USBDHIDMouseStateChange indicates that an error was
//! reported while attempting to send a report to the host. A client should
//! assume that the host has disconnected if this return code is seen.
//
//*****************************************************************************
#define MOUSE_ERR_TX_ERROR 2
//*****************************************************************************
//
//! USBDHIDMouseStateChange returns this value if it is called before the
//! USB host has connected and configured the device. All mouse state
//! information passed on the call is been ignored.
//
//*****************************************************************************
#define MOUSE_ERR_NOT_CONFIGURED \
4
//*****************************************************************************
//
//! Setting this bit in the ui8Buttons parameter to USBDHIDMouseStateChange
//! indicates to the USB host that button 1 on the mouse is pressed.
//
//*****************************************************************************
#define MOUSE_REPORT_BUTTON_1 0x01
//*****************************************************************************
//
//! Setting this bit in the ui8Buttons parameter to USBDHIDMouseStateChange
//! indicates to the USB host that button 2 on the mouse is pressed.
//
//*****************************************************************************
#define MOUSE_REPORT_BUTTON_2 0x02
//*****************************************************************************
//
//! Setting this bit in the ui8Buttons parameter to USBDHIDMouseStateChange
//! indicates to the USB host that button 3 on the mouse is pressed.
//
//*****************************************************************************
#define MOUSE_REPORT_BUTTON_3 0x04
//*****************************************************************************
//
// API Function Prototypes
//
//*****************************************************************************
extern void *USBDHIDMouseInit(uint32_t ui32Index,
tUSBDHIDMouseDevice *psMouseDevice);
extern void *USBDHIDMouseCompositeInit(uint32_t ui32Index,
tUSBDHIDMouseDevice *psMouseDevice,
tCompositeEntry *psCompEntry);
extern void USBDHIDMouseTerm(void *pvMouseDevice);
extern void *USBDHIDMouseSetCBData(void *pvMouseDevice, void *pvCBData);
extern uint32_t USBDHIDMouseStateChange(void *pvMouseDevice, int8_t i8DeltaX,
int8_t i8DeltaY, uint8_t ui8Buttons);
extern void USBDHIDMousePowerStatusSet(void *pvMouseDevice,
uint8_t ui8Power);
extern bool USBDHIDMouseRemoteWakeupRequest(void *pvMouseDevice);
//*****************************************************************************
//
// Close the Doxygen group.
//! @}
//
//*****************************************************************************
//*****************************************************************************
//
// Mark the end of the C bindings section for C++ compilers.
//
//*****************************************************************************
#ifdef __cplusplus
}
#endif
#endif // __USBDHIDMOUSE_H__
@@ -0,0 +1,187 @@
//#############################################################################
// FILE: usbhaudio.h
// TITLE: USB host audio class driver
//#############################################################################
//!
//! Copyright: Copyright (C) 2023 Texas Instruments Incorporated -
//! All rights reserved not granted herein.
//! Limited License.
//!
//! Texas Instruments Incorporated grants a world-wide, royalty-free,
//! non-exclusive license under copyrights and patents it now or hereafter
//! owns or controls to make, have made, use, import, offer to sell and sell
//! ("Utilize") this software subject to the terms herein. With respect to the
//! foregoing patent license, such license is granted solely to the extent that
//! any such patent is necessary to Utilize the software alone. The patent
//! license shall not apply to any combinations which include this software,
//! other than combinations with devices manufactured by or for TI
//! ("TI Devices").
//! No hardware patent is licensed hereunder.
//!
//! Redistributions must preserve existing copyright notices and reproduce this
//! license (including the above copyright notice and the disclaimer and
//! (if applicable) source code license limitations below) in the documentation
//! and/or other materials provided with the distribution.
//!
//! Redistribution and use in binary form, without modification, are permitted
//! provided that the following conditions are met:
//!
//! * No reverse engineering, decompilation, or disassembly of this software is
//! permitted with respect to any software provided in binary form.
//! * Any redistribution and use are licensed by TI for use only
//! with TI Devices.
//! * Nothing shall obligate TI to provide you with source code for the
//! software licensed and provided to you in object code.
//!
//! If software source code is provided to you, modification and redistribution
//! of the source code are permitted provided that the following conditions
//! are met:
//!
//! * any redistribution and use of the source code, including any resulting
//! derivative works, are licensed by TI for use only with TI Devices.
//! * any redistribution and use of any object code compiled from the source
//! code and any resulting derivative works, are licensed by TI for use
//! only with TI Devices.
//!
//! Neither the name of Texas Instruments Incorporated nor the names of its
//! suppliers may be used to endorse or promote products derived from this
//! software without specific prior written permission.
//#############################################################################
#ifndef __USBHAUDIO_H__
#define __USBHAUDIO_H__
//*****************************************************************************
//
// If building with a C++ compiler, make all of the definitions in this header
// have a C binding.
//
//*****************************************************************************
#ifdef __cplusplus
extern "C"
{
#endif
//*****************************************************************************
//
//! \addtogroup usblib_host_class
//! @{
//
//*****************************************************************************
//*****************************************************************************
//
// USB host audio specific events
//
//*****************************************************************************
//*****************************************************************************
//
//! This USB host audio event indicates that the device is connected and
//! ready to send or receive buffers. The \e pvBuffer and \e ui32Param
//! values are not used in this event.
//
//*****************************************************************************
#define USBH_AUDIO_EVENT_OPEN (USBH_AUDIO_EVENT_BASE + 0)
//*****************************************************************************
//
//! This USB host audio event indicates that the previously connected device
//! has been disconnected. The \e pvBuffer and \e ui32Param values are not used
//! in this event.
//
//*****************************************************************************
#define USBH_AUDIO_EVENT_CLOSE (USBH_AUDIO_EVENT_BASE + 1)
//*****************************************************************************
//
// This definition is used with the USBHostAudioFormatGet() and
// USBHostAudioFormatSet() API's to determine if the audio input is being
// accesses(USBH_AUDIO_FORMAT_IN set) or audio output(USBH_AUDIO_FORMAT clear).
//
//*****************************************************************************
#define USBH_AUDIO_FORMAT_IN 0x00000001
#define USBH_AUDIO_FORMAT_OUT 0x00000000
typedef struct
{
uint8_t ui8Channels;
uint8_t ui8Bits;
uint32_t ui32SampleRate;
}
tUSBAudioFormat;
typedef struct tUSBHostAudioInstance tUSBHostAudioInstance;
//*****************************************************************************
//
// The prototype for the host USB Audio driver callback function.
//
//*****************************************************************************
typedef void (*tUSBHostAudioCallback)(tUSBHostAudioInstance *psAudioInstance,
uint32_t ui32Event,
uint32_t ui32MsgParam,
void *pvMsgData);
//*****************************************************************************
//
// API Function Prototypes
//
//*****************************************************************************
extern tUSBHostAudioInstance * USBHostAudioOpen(uint32_t ui32Index,
tUSBHostAudioCallback pfnCallback);
extern void USBHostAudioClose(tUSBHostAudioInstance *psAudioInstance);
extern int32_t USBHostAudioPlay(tUSBHostAudioInstance *psAudioInstance,
void *pvBuffer, uint32_t ui32Size,
tUSBHostAudioCallback pfnCallback);
extern uint32_t USBHostAudioFormatGet(tUSBHostAudioInstance *psAudioInstance,
uint32_t ui32SampleRate,
uint32_t ui32Bits, uint32_t ui32Channels,
uint32_t ui32Flags);
extern uint32_t USBHostAudioFormatSet(tUSBHostAudioInstance *psAudioInstance,
uint32_t ui32SampleRate,
uint32_t ui32Bits, uint32_t ui32Channels,
uint32_t ui32Flags);
extern int32_t USBHostAudioRecord(tUSBHostAudioInstance *psAudioInstance,
void *pvBuffer, uint32_t ui32Size,
tUSBHostAudioCallback pfnAudioCallback);
extern uint32_t USBHostAudioVolumeGet(tUSBHostAudioInstance *psAudioInstance,
uint32_t ui32Interface,
uint32_t ui32Channel);
extern void USBHostAudioVolumeSet(tUSBHostAudioInstance *psAudioInstance,
uint32_t ui32Interface, uint32_t ui32Channel,
uint32_t ui32Value);
extern uint32_t USBHostAudioVolumeMaxGet(tUSBHostAudioInstance *psAudioInstance,
uint32_t ui32Interface,
uint32_t ui32Channel);
extern uint32_t USBHostAudioVolumeMinGet(tUSBHostAudioInstance *psAudioInstance,
uint32_t ui32Interface,
uint32_t ui32Channel);
extern uint32_t USBHostAudioVolumeResGet(tUSBHostAudioInstance *psAudioInstance,
uint32_t ui32Interface,
uint32_t ui32Channel);
//*****************************************************************************
//
//! @}
//
//*****************************************************************************
//*****************************************************************************
//
// Mark the end of the C bindings section for C++ compilers.
//
//*****************************************************************************
#ifdef __cplusplus
}
#endif
#endif
@@ -0,0 +1,190 @@
//#############################################################################
// FILE: usbhhid.h
// TITLE: This hold the host driver for hid class
//#############################################################################
//!
//! Copyright: Copyright (C) 2023 Texas Instruments Incorporated -
//! All rights reserved not granted herein.
//! Limited License.
//!
//! Texas Instruments Incorporated grants a world-wide, royalty-free,
//! non-exclusive license under copyrights and patents it now or hereafter
//! owns or controls to make, have made, use, import, offer to sell and sell
//! ("Utilize") this software subject to the terms herein. With respect to the
//! foregoing patent license, such license is granted solely to the extent that
//! any such patent is necessary to Utilize the software alone. The patent
//! license shall not apply to any combinations which include this software,
//! other than combinations with devices manufactured by or for TI
//! ("TI Devices").
//! No hardware patent is licensed hereunder.
//!
//! Redistributions must preserve existing copyright notices and reproduce this
//! license (including the above copyright notice and the disclaimer and
//! (if applicable) source code license limitations below) in the documentation
//! and/or other materials provided with the distribution.
//!
//! Redistribution and use in binary form, without modification, are permitted
//! provided that the following conditions are met:
//!
//! * No reverse engineering, decompilation, or disassembly of this software is
//! permitted with respect to any software provided in binary form.
//! * Any redistribution and use are licensed by TI for use only
//! with TI Devices.
//! * Nothing shall obligate TI to provide you with source code for the
//! software licensed and provided to you in object code.
//!
//! If software source code is provided to you, modification and redistribution
//! of the source code are permitted provided that the following conditions
//! are met:
//!
//! * any redistribution and use of the source code, including any resulting
//! derivative works, are licensed by TI for use only with TI Devices.
//! * any redistribution and use of any object code compiled from the source
//! code and any resulting derivative works, are licensed by TI for use
//! only with TI Devices.
//!
//! Neither the name of Texas Instruments Incorporated nor the names of its
//! suppliers may be used to endorse or promote products derived from this
//! software without specific prior written permission.
//#############################################################################
#ifndef __USBHHID_H__
#define __USBHHID_H__
//*****************************************************************************
//
// If building with a C++ compiler, make all of the definitions in this header
// have a C binding.
//
//*****************************************************************************
#ifdef __cplusplus
extern "C"
{
#endif
//*****************************************************************************
//
//! \addtogroup usblib_host_class
//! @{
//
//*****************************************************************************
typedef struct tHIDInstance tHIDInstance;
//*****************************************************************************
//
// These defines are the the events that will be passed in the ui32Event
// parameter of the callback from the driver.
//
//*****************************************************************************
#define USBH_EVENT_HID_SETRPT USBH_HID_EVENT_BASE + 0
#define USBH_EVENT_HID_REPORT USBH_HID_EVENT_BASE + 1
//
//! The HID keyboard detected a key being pressed.
//
#define USBH_EVENT_HID_KB_PRESS USBH_HID_EVENT_BASE + 16
//
//! The HID keyboard detected a key being released.
//
#define USBH_EVENT_HID_KB_REL USBH_HID_EVENT_BASE + 17
//
//! The HID keyboard detected one of the keyboard modifiers being pressed.
//
#define USBH_EVENT_HID_KB_MOD USBH_HID_EVENT_BASE + 18
//
//! A button was pressed on a HID mouse.
//
#define USBH_EVENT_HID_MS_PRESS USBH_HID_EVENT_BASE + 32
//
//! A button was released on a HID mouse.
//
#define USBH_EVENT_HID_MS_REL USBH_HID_EVENT_BASE + 33
//
//! The HID mouse detected movement in the X direction.
//
#define USBH_EVENT_HID_MS_X USBH_HID_EVENT_BASE + 34
//
//! The HID mouse detected movement in the Y direction.
//
#define USBH_EVENT_HID_MS_Y USBH_HID_EVENT_BASE + 35
//*****************************************************************************
//
//! The following values are used to register callbacks to the USB HOST HID
//! device class layer.
//
//*****************************************************************************
typedef enum
{
//
//! No device should be used. This value should not be used by
//! applications.
//
eUSBHHIDClassNone = 0,
//
//! This is a keyboard device.
//
eUSBHHIDClassKeyboard,
//
//! This is a mouse device.
//
eUSBHHIDClassMouse,
//
//! This is a vendor specific device.
//
eUSBHHIDClassVendor
}
tHIDSubClassProtocol;
//*****************************************************************************
//
// Close the Doxygen group.
//! @}
//
//*****************************************************************************
//*****************************************************************************
//
// Prototypes.
//
//*****************************************************************************
extern tHIDInstance * USBHHIDOpen(tHIDSubClassProtocol iDeviceType,
tUSBCallback pfnCallback,
void *pvCBData);
extern void USBHHIDClose(tHIDInstance *psHIDInstance);
extern uint32_t USBHHIDGetReportDescriptor(tHIDInstance *psHIDInstance,
uint8_t *pui8Buffer,
uint32_t ui32Size);
extern uint32_t USBHHIDSetIdle(tHIDInstance *psHIDInstance, uint8_t ui8Duration,
uint8_t ui8ReportID);
extern uint32_t USBHHIDSetProtocol(tHIDInstance *psHIDInstance,
uint32_t ui32BootProtocol);
extern uint32_t USBHHIDSetReport(tHIDInstance *psHIDInstance,
uint32_t ui32Interface, uint8_t *pui8Data,
uint32_t ui32Size);
extern uint32_t USBHHIDGetReport(tHIDInstance *psHIDInstance,
uint32_t ui32Interface, uint8_t *pui8Data,
uint32_t ui32Size);
extern const tUSBHostClassDriver g_sUSBHIDClassDriver;
//*****************************************************************************
//
// Mark the end of the C bindings section for C++ compilers.
//
//*****************************************************************************
#ifdef __cplusplus
}
#endif
#endif // __USBHHID_H__
@@ -0,0 +1,112 @@
//#############################################################################
// FILE: usbhhidkeyboard.h
// TITLE: This file holds the application interfaces for USB
//#############################################################################
//!
//! Copyright: Copyright (C) 2023 Texas Instruments Incorporated -
//! All rights reserved not granted herein.
//! Limited License.
//!
//! Texas Instruments Incorporated grants a world-wide, royalty-free,
//! non-exclusive license under copyrights and patents it now or hereafter
//! owns or controls to make, have made, use, import, offer to sell and sell
//! ("Utilize") this software subject to the terms herein. With respect to the
//! foregoing patent license, such license is granted solely to the extent that
//! any such patent is necessary to Utilize the software alone. The patent
//! license shall not apply to any combinations which include this software,
//! other than combinations with devices manufactured by or for TI
//! ("TI Devices").
//! No hardware patent is licensed hereunder.
//!
//! Redistributions must preserve existing copyright notices and reproduce this
//! license (including the above copyright notice and the disclaimer and
//! (if applicable) source code license limitations below) in the documentation
//! and/or other materials provided with the distribution.
//!
//! Redistribution and use in binary form, without modification, are permitted
//! provided that the following conditions are met:
//!
//! * No reverse engineering, decompilation, or disassembly of this software is
//! permitted with respect to any software provided in binary form.
//! * Any redistribution and use are licensed by TI for use only
//! with TI Devices.
//! * Nothing shall obligate TI to provide you with source code for the
//! software licensed and provided to you in object code.
//!
//! If software source code is provided to you, modification and redistribution
//! of the source code are permitted provided that the following conditions
//! are met:
//!
//! * any redistribution and use of the source code, including any resulting
//! derivative works, are licensed by TI for use only with TI Devices.
//! * any redistribution and use of any object code compiled from the source
//! code and any resulting derivative works, are licensed by TI for use
//! only with TI Devices.
//!
//! Neither the name of Texas Instruments Incorporated nor the names of its
//! suppliers may be used to endorse or promote products derived from this
//! software without specific prior written permission.
//#############################################################################
#ifndef __USBHHIDKEYBOARD_H__
#define __USBHHIDKEYBOARD_H__
//*****************************************************************************
//
// If building with a C++ compiler, make all of the definitions in this header
// have a C binding.
//
//*****************************************************************************
#ifdef __cplusplus
extern "C"
{
#endif
//*****************************************************************************
//
//! \addtogroup usblib_host_device
//! @{
//
//*****************************************************************************
typedef struct tUSBHKeyboard tUSBHKeyboard;
//*****************************************************************************
//
// The prototype for the host USB Keyboard driver callback function.
//
//*****************************************************************************
typedef void (*tUSBHIDKeyboardCallback)(tUSBHKeyboard *psKbInstance,
uint32_t ui32Event,
uint32_t ui32MsgParam,
void *pvMsgData);
extern tUSBHKeyboard * USBHKeyboardOpen(tUSBHIDKeyboardCallback pfnCallback,
uint8_t *pui8Buffer,
uint32_t ui32BufferSize);
extern uint32_t USBHKeyboardClose(tUSBHKeyboard *psKbInstance);
extern uint32_t USBHKeyboardInit(tUSBHKeyboard *psKbInstance);
extern uint32_t USBHKeyboardModifierSet(tUSBHKeyboard *psKbInstance,
uint32_t ui32Modifiers);
extern uint32_t USBHKeyboardPollRateSet(tUSBHKeyboard *psKbInstance,
uint32_t ui32PollRate);
extern uint32_t USBHKeyboardUsageToChar(tUSBHKeyboard *psKbInstance,
const tHIDKeyboardUsageTable *psTable,
uint8_t ui8UsageID);
//*****************************************************************************
//
//! @}
//
//*****************************************************************************
//*****************************************************************************
//
// Mark the end of the C bindings section for C++ compilers.
//
//*****************************************************************************
#ifdef __cplusplus
}
#endif
#endif
@@ -0,0 +1,104 @@
//#############################################################################
// FILE: usbhhidmouse.h
// TITLE: This file holds the application interfaces for USB
//#############################################################################
//!
//! Copyright: Copyright (C) 2023 Texas Instruments Incorporated -
//! All rights reserved not granted herein.
//! Limited License.
//!
//! Texas Instruments Incorporated grants a world-wide, royalty-free,
//! non-exclusive license under copyrights and patents it now or hereafter
//! owns or controls to make, have made, use, import, offer to sell and sell
//! ("Utilize") this software subject to the terms herein. With respect to the
//! foregoing patent license, such license is granted solely to the extent that
//! any such patent is necessary to Utilize the software alone. The patent
//! license shall not apply to any combinations which include this software,
//! other than combinations with devices manufactured by or for TI
//! ("TI Devices").
//! No hardware patent is licensed hereunder.
//!
//! Redistributions must preserve existing copyright notices and reproduce this
//! license (including the above copyright notice and the disclaimer and
//! (if applicable) source code license limitations below) in the documentation
//! and/or other materials provided with the distribution.
//!
//! Redistribution and use in binary form, without modification, are permitted
//! provided that the following conditions are met:
//!
//! * No reverse engineering, decompilation, or disassembly of this software is
//! permitted with respect to any software provided in binary form.
//! * Any redistribution and use are licensed by TI for use only
//! with TI Devices.
//! * Nothing shall obligate TI to provide you with source code for the
//! software licensed and provided to you in object code.
//!
//! If software source code is provided to you, modification and redistribution
//! of the source code are permitted provided that the following conditions
//! are met:
//!
//! * any redistribution and use of the source code, including any resulting
//! derivative works, are licensed by TI for use only with TI Devices.
//! * any redistribution and use of any object code compiled from the source
//! code and any resulting derivative works, are licensed by TI for use
//! only with TI Devices.
//!
//! Neither the name of Texas Instruments Incorporated nor the names of its
//! suppliers may be used to endorse or promote products derived from this
//! software without specific prior written permission.
//#############################################################################
#ifndef __USBHHIDMOUSE_H__
#define __USBHHIDMOUSE_H__
//*****************************************************************************
//
// If building with a C++ compiler, make all of the definitions in this header
// have a C binding.
//
//*****************************************************************************
#ifdef __cplusplus
extern "C"
{
#endif
//*****************************************************************************
//
//! \addtogroup usblib_host_device
//! @{
//
//*****************************************************************************
typedef struct tUSBHMouse tUSBHMouse;
//*****************************************************************************
//
// The prototype for the host USB mouse driver callback function.
//
//*****************************************************************************
typedef void (*tUSBHIDMouseCallback)(tUSBHMouse *psMsInstance,
uint32_t ui32Event,
uint32_t ui32MsgParam,
void *pvMsgData);
extern tUSBHMouse * USBHMouseOpen(tUSBHIDMouseCallback pfnCallback,
uint8_t *pui8Buffer, uint32_t ui32Size);
extern uint32_t USBHMouseClose(tUSBHMouse *psMsInstance);
extern uint32_t USBHMouseInit(tUSBHMouse *psMsInstance);
//*****************************************************************************
//
//! @}
//
//*****************************************************************************
//*****************************************************************************
//
// Mark the end of the C bindings section for C++ compilers.
//
//*****************************************************************************
#ifdef __cplusplus
}
#endif
#endif
@@ -0,0 +1,198 @@
//#############################################################################
// FILE: usbhhub.h
// TITLE: This hold the host driver for hid class
//#############################################################################
//!
//! Copyright: Copyright (C) 2023 Texas Instruments Incorporated -
//! All rights reserved not granted herein.
//! Limited License.
//!
//! Texas Instruments Incorporated grants a world-wide, royalty-free,
//! non-exclusive license under copyrights and patents it now or hereafter
//! owns or controls to make, have made, use, import, offer to sell and sell
//! ("Utilize") this software subject to the terms herein. With respect to the
//! foregoing patent license, such license is granted solely to the extent that
//! any such patent is necessary to Utilize the software alone. The patent
//! license shall not apply to any combinations which include this software,
//! other than combinations with devices manufactured by or for TI
//! ("TI Devices").
//! No hardware patent is licensed hereunder.
//!
//! Redistributions must preserve existing copyright notices and reproduce this
//! license (including the above copyright notice and the disclaimer and
//! (if applicable) source code license limitations below) in the documentation
//! and/or other materials provided with the distribution.
//!
//! Redistribution and use in binary form, without modification, are permitted
//! provided that the following conditions are met:
//!
//! * No reverse engineering, decompilation, or disassembly of this software is
//! permitted with respect to any software provided in binary form.
//! * Any redistribution and use are licensed by TI for use only
//! with TI Devices.
//! * Nothing shall obligate TI to provide you with source code for the
//! software licensed and provided to you in object code.
//!
//! If software source code is provided to you, modification and redistribution
//! of the source code are permitted provided that the following conditions
//! are met:
//!
//! * any redistribution and use of the source code, including any resulting
//! derivative works, are licensed by TI for use only with TI Devices.
//! * any redistribution and use of any object code compiled from the source
//! code and any resulting derivative works, are licensed by TI for use
//! only with TI Devices.
//!
//! Neither the name of Texas Instruments Incorporated nor the names of its
//! suppliers may be used to endorse or promote products derived from this
//! software without specific prior written permission.
//#############################################################################
#ifndef __USBHHUB_H__
#define __USBHHUB_H__
//*****************************************************************************
//
// If building with a C++ compiler, make all of the definitions in this header
// have a C binding.
//
//*****************************************************************************
#ifdef __cplusplus
extern "C"
{
#endif
typedef struct tHubInstance tHubInstance;
extern const tUSBHostClassDriver g_sUSBHubClassDriver;
//*****************************************************************************
//
// The USB standard allows for up to 127 downstream ports on a single hub.
// This would require rather more memory than we would like to set aside so the
// default configuration of the hub driver supports hubs with up to 7
// downstream-facing ports. In practice, this should be more than enough
// since this covers the vast majority of consumer hubs. Note that, by
// default, we will only support 4 devices so you can't fully populate a 7 port
// hub and have everything work.
//
// Feel free to change this but bad things will happen if you increase it above
// 31 since we assume the reports will always fit inside a 4 byte buffer.
//
//*****************************************************************************
#define ROOT_HUB_MAX_PORTS 7
//*****************************************************************************
//
// Values used as the ui16Feature parameter to USBHHubClearHubFeature().
//
//*****************************************************************************
#define HUB_FEATURE_C_HUB_LOCAL_POWER \
0
#define HUB_FEATURE_C_HUB_OVER_CURRENT \
1
//*****************************************************************************
//
// Values used as the ui16Feature parameter to USBHHubSetPortFeature() and
// USBHHubClearPortFeature().
//
//*****************************************************************************
#define HUB_FEATURE_PORT_CONNECTION \
0
#define HUB_FEATURE_PORT_ENABLE 1
#define HUB_FEATURE_PORT_SUSPEND \
2
#define HUB_FEATURE_PORT_OVER_CURRENT \
3
#define HUB_FEATURE_PORT_RESET 4
#define HUB_FEATURE_PORT_POWER 8
#define HUB_FEATURE_PORT_LOW_SPEED \
9
#define HUB_FEATURE_C_PORT_CONNECTION \
16
#define HUB_FEATURE_C_PORT_ENABLE \
17
#define HUB_FEATURE_C_PORT_SUSPEND \
18
#define HUB_FEATURE_C_PORT_OVER_CURRENT \
19
#define HUB_FEATURE_C_PORT_RESET \
20
#define HUB_FEATURE_PORT_TEST 21
#define HUB_FEATURE_PORT_INDICATOR \
22
//*****************************************************************************
//
// Values returned via the *pui16HubStatus and *pui16HubChange parameters
// passed to USBHHubGetHubStatus(). These may be ORed together into the
// returned status value.
//
//*****************************************************************************
#define HUB_STATUS_PWR_LOST 1
#define HUB_STATUS_OVER_CURRENT 2
//*****************************************************************************
//
// Values returned via the *pui16PortStatus parameter passed to
// USBHHubGetPortStatus(). These may be ORed together into the returned status
// value.
//
//*****************************************************************************
#define HUB_PORT_STATUS_DEVICE_PRESENT \
0x0001
#define HUB_PORT_STATUS_ENABLED 0x0002
#define HUB_PORT_STATUS_SUSPENDED \
0x0004
#define HUB_PORT_STATUS_OVER_CURRENT \
0x0008
#define HUB_PORT_STATUS_RESET 0x0010
#define HUB_PORT_STATUS_POWERED 0x0100
#define HUB_PORT_STATUS_LOW_SPEED \
0x0200
#define HUB_PORT_STATUS_HIGH_SPEED \
0x0400
#define HUB_PORT_STATUS_TEST_MODE \
0x0800
#define HUB_PORT_STATUS_INDICATOR_CONTROL \
0x1000
//*****************************************************************************
//
// Values returned via the *pui16PortChange parameter passed to
// USBHHubGetPortStatus(). These may be ORed together into the returned status
// value.
//
//*****************************************************************************
#define HUB_PORT_CHANGE_DEVICE_PRESENT \
0x0001
#define HUB_PORT_CHANGE_ENABLED 0x0002
#define HUB_PORT_CHANGE_SUSPENDED \
0x0004
#define HUB_PORT_CHANGE_OVER_CURRENT \
0x0008
#define HUB_PORT_CHANGE_RESET 0x0010
//*****************************************************************************
//
// The prototype for the USB Hub host driver callback function.
//
//*****************************************************************************
typedef void (*tUSBHHubCallback)(tHubInstance *psHubInstance,
uint32_t ui32Event, uint32_t ui32MsgParam,
void *pvMsgData);
//*****************************************************************************
//
// Public function prototypes for the HUB class driver.
//
//*****************************************************************************
extern tHubInstance * USBHHubOpen(tUSBHHubCallback pfnCallback);
extern void USBHHubClose(tHubInstance *psHubInstance);
#ifdef __cplusplus
}
#endif
#endif // __USBHHUB_H__
@@ -0,0 +1,123 @@
//#############################################################################
// FILE: usbhmsc.h
// TITLE: Definitions for the USB MSC host driver
//#############################################################################
//!
//! Copyright: Copyright (C) 2023 Texas Instruments Incorporated -
//! All rights reserved not granted herein.
//! Limited License.
//!
//! Texas Instruments Incorporated grants a world-wide, royalty-free,
//! non-exclusive license under copyrights and patents it now or hereafter
//! owns or controls to make, have made, use, import, offer to sell and sell
//! ("Utilize") this software subject to the terms herein. With respect to the
//! foregoing patent license, such license is granted solely to the extent that
//! any such patent is necessary to Utilize the software alone. The patent
//! license shall not apply to any combinations which include this software,
//! other than combinations with devices manufactured by or for TI
//! ("TI Devices").
//! No hardware patent is licensed hereunder.
//!
//! Redistributions must preserve existing copyright notices and reproduce this
//! license (including the above copyright notice and the disclaimer and
//! (if applicable) source code license limitations below) in the documentation
//! and/or other materials provided with the distribution.
//!
//! Redistribution and use in binary form, without modification, are permitted
//! provided that the following conditions are met:
//!
//! * No reverse engineering, decompilation, or disassembly of this software is
//! permitted with respect to any software provided in binary form.
//! * Any redistribution and use are licensed by TI for use only
//! with TI Devices.
//! * Nothing shall obligate TI to provide you with source code for the
//! software licensed and provided to you in object code.
//!
//! If software source code is provided to you, modification and redistribution
//! of the source code are permitted provided that the following conditions
//! are met:
//!
//! * any redistribution and use of the source code, including any resulting
//! derivative works, are licensed by TI for use only with TI Devices.
//! * any redistribution and use of any object code compiled from the source
//! code and any resulting derivative works, are licensed by TI for use
//! only with TI Devices.
//!
//! Neither the name of Texas Instruments Incorporated nor the names of its
//! suppliers may be used to endorse or promote products derived from this
//! software without specific prior written permission.
//#############################################################################
#ifndef __USBHMSC_H__
#define __USBHMSC_H__
//*****************************************************************************
//
// If building with a C++ compiler, make all of the definitions in this header
// have a C binding.
//
//*****************************************************************************
#ifdef __cplusplus
extern "C"
{
#endif
//*****************************************************************************
//
//! \addtogroup usblib_host_class
//! @{
//
//*****************************************************************************
typedef struct tUSBHMSCInstance tUSBHMSCInstance;
//*****************************************************************************
//
// These defines are the the events that will be passed in the \e ui32Event
// parameter of the callback from the driver.
//
//*****************************************************************************
#define MSC_EVENT_OPEN 1
#define MSC_EVENT_CLOSE 2
//*****************************************************************************
//
// The prototype for the USB MSC host driver callback function.
//
//*****************************************************************************
typedef void (*tUSBHMSCCallback)(tUSBHMSCInstance *psMSCInstance,
uint32_t ui32Event,
void *pvEventData);
//*****************************************************************************
//
// Prototypes for the USB MSC host driver APIs.
//
//*****************************************************************************
extern tUSBHMSCInstance * USBHMSCDriveOpen(uint32_t ui32Drive,
tUSBHMSCCallback pfnCallback);
extern void USBHMSCDriveClose(tUSBHMSCInstance *psMSCInstance);
extern int32_t USBHMSCDriveReady(tUSBHMSCInstance *psMSCInstance);
extern int32_t USBHMSCBlockRead(tUSBHMSCInstance *psMSCInstance,
uint32_t ui32LBA, uint8_t *pui8Data,
uint32_t ui32NumBlocks);
extern int32_t USBHMSCBlockWrite(tUSBHMSCInstance *psMSCInstance,
uint32_t ui32LBA, uint8_t *pui8Data,
uint32_t ui32NumBlocks);
//*****************************************************************************
//
//! @}
//
//*****************************************************************************
//*****************************************************************************
//
// Mark the end of the C bindings section for C++ compilers.
//
//*****************************************************************************
#ifdef __cplusplus
}
#endif
#endif // __USBHMSC_H__
@@ -0,0 +1,300 @@
//#############################################################################
// FILE: usbhost.h
// TITLE: Host specific definitions for the USB host library
//#############################################################################
//!
//! Copyright: Copyright (C) 2023 Texas Instruments Incorporated -
//! All rights reserved not granted herein.
//! Limited License.
//!
//! Texas Instruments Incorporated grants a world-wide, royalty-free,
//! non-exclusive license under copyrights and patents it now or hereafter
//! owns or controls to make, have made, use, import, offer to sell and sell
//! ("Utilize") this software subject to the terms herein. With respect to the
//! foregoing patent license, such license is granted solely to the extent that
//! any such patent is necessary to Utilize the software alone. The patent
//! license shall not apply to any combinations which include this software,
//! other than combinations with devices manufactured by or for TI
//! ("TI Devices").
//! No hardware patent is licensed hereunder.
//!
//! Redistributions must preserve existing copyright notices and reproduce this
//! license (including the above copyright notice and the disclaimer and
//! (if applicable) source code license limitations below) in the documentation
//! and/or other materials provided with the distribution.
//!
//! Redistribution and use in binary form, without modification, are permitted
//! provided that the following conditions are met:
//!
//! * No reverse engineering, decompilation, or disassembly of this software is
//! permitted with respect to any software provided in binary form.
//! * Any redistribution and use are licensed by TI for use only
//! with TI Devices.
//! * Nothing shall obligate TI to provide you with source code for the
//! software licensed and provided to you in object code.
//!
//! If software source code is provided to you, modification and redistribution
//! of the source code are permitted provided that the following conditions
//! are met:
//!
//! * any redistribution and use of the source code, including any resulting
//! derivative works, are licensed by TI for use only with TI Devices.
//! * any redistribution and use of any object code compiled from the source
//! code and any resulting derivative works, are licensed by TI for use
//! only with TI Devices.
//!
//! Neither the name of Texas Instruments Incorporated nor the names of its
//! suppliers may be used to endorse or promote products derived from this
//! software without specific prior written permission.
//#############################################################################
#ifndef __USBHOST_H__
#define __USBHOST_H__
//*****************************************************************************
//
// If building with a C++ compiler, make all of the definitions in this header
// have a C binding.
//
//*****************************************************************************
#ifdef __cplusplus
extern "C"
{
#endif
//*****************************************************************************
//
//! \addtogroup usblib_hcd
//! @{
//
//*****************************************************************************
//*****************************************************************************
//
// This is the type used to identify what the pipe is currently in use for.
//
//*****************************************************************************
#define USBHCD_PIPE_UNUSED 0x00100000
#define USBHCD_PIPE_CONTROL 0x00130000
#define USBHCD_PIPE_BULK_OUT 0x00210000
#define USBHCD_PIPE_BULK_IN 0x00220000
#define USBHCD_PIPE_INTR_OUT 0x00410000
#define USBHCD_PIPE_INTR_IN 0x00420000
#define USBHCD_PIPE_ISOC_OUT 0x00810000
#define USBHCD_PIPE_ISOC_IN 0x00820000
#define USBHCD_PIPE_ISOC_OUT_DMA 0x01810000
#define USBHCD_PIPE_ISOC_IN_DMA 0x01820000
#define USBHCD_PIPE_BULK_OUT_DMA 0x01210000
#define USBHCD_PIPE_BULK_IN_DMA 0x01220000
//*****************************************************************************
//
// These are the defines that are used with USBHCDPowerConfigInit().
//
//*****************************************************************************
#define USBHCD_FAULT_LOW 0x00000010
#define USBHCD_FAULT_HIGH 0x00000030
#define USBHCD_FAULT_VBUS_NONE 0x00000000
#define USBHCD_FAULT_VBUS_TRI 0x00000140
#define USBHCD_FAULT_VBUS_DIS 0x00000400
#define USBHCD_VBUS_MANUAL 0x00000004
#define USBHCD_VBUS_AUTO_LOW 0x00000002
#define USBHCD_VBUS_AUTO_HIGH 0x00000003
#define USBHCD_VBUS_FILTER 0x00010000
//*****************************************************************************
//
//! This macro is used to declare an instance of an Event driver for the USB
//! library.
//!
//! \param VarName is the name of the variable.
//! \param pfnOpen is the callback for the Open call to this driver. This
//! value is currently reserved and should be set to 0.
//! \param pfnClose is the callback for the Close call to this driver. This
//! value is currently reserved and should be set to 0.
//! \param pfnEvent is the callback that will be called for various USB events.
//!
//! The first parameter is the actual name of the variable that will
//! be declared by this macro. The second and third parameter are reserved
//! for future functionality and are unused and should be set to zero. The
//! last parameter is the actual callback function and is specified as
//! a function pointer of the type:
//!
//! void (*pfnEvent)(void *pvData);
//!
//! When the \e pfnEvent function is called the void pointer that is passed in
//! as a parameter should be cast to a pointer to a structure of type
//! tEventInfo. This will contain the event that caused the pfnEvent function
//! to be called.
//
//*****************************************************************************
#define DECLARE_EVENT_DRIVER(VarName, pfnOpen, pfnClose, pfnEvent) \
void IntFn(void *pvData); \
const tUSBHostClassDriver VarName = \
{ \
USB_CLASS_EVENTS, \
0, \
0, \
pfnEvent \
}
//*****************************************************************************
//
// This is the type definition a callback for events on USB Pipes allocated
// by USBHCDPipeAlloc().
//
// \param ui32Pipe is well the pipe
// \param ui32Event is well the event
//
// This prototype is used by any Pipe callbacks that are used in the host
// class drivers. These functions typically handle data events like
// USB_EVENT_RX_AVAILABLE or USB_EVENT_TX_COMPLETE but can be sent other events
// depending on the USB host class in use. See the documentation for the
// individual classes for the valid events for that class.
//
// \return None.
//
//*****************************************************************************
typedef void (* tHCDPipeCallback)(uint32_t ui32Pipe, uint32_t ui32Event);
//*****************************************************************************
//
// Predeclare the private tUSBHostDevice structure.
//
//*****************************************************************************
typedef struct tUSBHostDevice tUSBHostDevice;
//*****************************************************************************
//
//! This structure defines a USB host class driver interface, it is parsed to
//! find a USB class driver once a USB device is enumerated.
//
//*****************************************************************************
typedef struct
{
//
//! The interface class that this device class driver supports.
//
uint32_t ui32InterfaceClass;
//
//! The function is called when this class of device has been detected.
//
void *(*pfnOpen)(tUSBHostDevice *psDevice);
//
//! The function is called when the device, originally opened with a call
//! to the pfnOpen function, is disconnected.
//
void (*pfnClose)(void *pvInstance);
//
//! This is the optional interrupt handler that will be called when an
//! endpoint associated with this device instance generates an interrupt.
//
void (*pfnIntHandler)(void *pvInstance);
}
tUSBHostClassDriver;
//*****************************************************************************
//
// Close the Doxygen group.
//! @}
//
//*****************************************************************************
//*****************************************************************************
//
// If the g_USBEventDriver is included in the host controller driver list then
// this function must be provided by the application.
//
//*****************************************************************************
extern void USBHCDEvents(void *pvData);
//*****************************************************************************
//
// Prototypes for the USB Host controller APIs.
//
//*****************************************************************************
extern void USBHCDMain(void);
extern int32_t USBHCDEventEnable(uint32_t ui32Index, void *pvEventDriver,
uint32_t ui32Event);
extern int32_t USBHCDEventDisable(uint32_t ui32Index, void *pvEventDriver,
uint32_t ui32Event);
extern void USBHCDInit(uint32_t ui32Index, void *pvData,
uint32_t ui32Size);
extern void USBHCDPowerConfigInit(uint32_t ui32Index,
uint32_t ui32Flags);
extern uint32_t USBHCDPowerConfigGet(uint32_t ui32Index);
extern uint32_t USBHCDPowerConfigSet(uint32_t ui32Index,
uint32_t ui32Config);
extern uint32_t USBHCDPowerAutomatic(uint32_t ui32Index);
extern void USBHCDRegisterDrivers(uint32_t ui32Index,
const tUSBHostClassDriver * const *ppsHClassDrvrs,
uint32_t ui32NumDrivers);
extern void USBHCDTerm(uint32_t ui32Index);
extern void USBHCDSetConfig(uint32_t ui32Index, uint32_t ui32Device,
uint32_t ui32Configuration);
extern void USBHCDSetInterface(uint32_t ui32Index, uint32_t ui32Device,
uint32_t ui32Interface,
uint32_t ui32AltSetting);
extern void USBHCDSuspend(uint32_t ui32Index);
extern void USBHCDResume(uint32_t ui32Index);
extern void USBHCDReset(uint32_t ui32Index);
extern void USBHCDPipeFree(uint32_t ui32Pipe);
extern uint32_t USBHCDPipeAlloc(uint32_t ui32Index,
uint32_t ui32EndpointType,
tUSBHostDevice *psDevice,
tHCDPipeCallback pfnCallback);
extern uint32_t USBHCDPipeAllocSize(uint32_t ui32Index,
uint32_t ui32EndpointType,
tUSBHostDevice *psDevice,
uint32_t ui32FIFOSize,
tHCDPipeCallback pfnCallback);
extern uint32_t USBHCDPipeConfig(uint32_t ui32Pipe, uint32_t ui32MaxPayload,
uint32_t ui32Interval,
uint32_t ui32TargetEndpoint);
extern uint32_t USBHCDPipeStatus(uint32_t ui32Pipe);
extern uint32_t USBHCDPipeWrite(uint32_t ui32Pipe, uint8_t *pui8Data,
uint32_t ui32Size);
extern uint32_t USBHCDPipeRead(uint32_t ui32Pipe, uint8_t *pui8Data,
uint32_t ui32Size);
extern uint32_t USBHCDPipeSchedule(uint32_t ui32Pipe, uint8_t *pui8Data,
uint32_t ui32Size);
extern void USBHCDPipeDataAck(uint32_t ui32Pipe);
extern uint32_t USBHCDPipeReadNonBlocking(uint32_t ui32Pipe, uint8_t *pui8Data,
uint32_t ui32Size);
extern uint32_t USBHCDControlTransfer(uint32_t ui32Index,
tUSBRequest *psSetupPacket,
tUSBHostDevice *psDevice,
uint8_t *pui8Data, uint32_t ui32Size,
uint32_t ui32MaxPacketSize);
extern void USB0HostIntHandler(void);
extern uint8_t USBHCDDevHubPort(uint32_t ui32Instance);
extern uint8_t USBHCDDevAddress(uint32_t ui32Instance);
extern uint8_t USBHCDDevClass(uint32_t ui32Instance, uint32_t ui32Interface);
extern uint8_t USBHCDDevSubClass(uint32_t ui32Instance,
uint32_t ui32Interface);
extern uint8_t USBHCDDevProtocol(uint32_t ui32Instance,
uint32_t ui32Interface);
//*****************************************************************************
//
// The host class drivers supported by the USB library.
//
//*****************************************************************************
extern const tUSBHostClassDriver g_sUSBHostMSCClassDriver;
extern const tUSBHostClassDriver g_sUSBHIDClassDriver;
extern const tUSBHostClassDriver g_sUSBHostAudioClassDriver;
//*****************************************************************************
//
// Mark the end of the C bindings section for C++ compilers.
//
//*****************************************************************************
#ifdef __cplusplus
}
#endif
#endif // __USBHOST_H__
@@ -0,0 +1,221 @@
//#############################################################################
// FILE: usbhostpriv.h
// TITLE: Internal header file for USB host functions
//#############################################################################
//!
//! Copyright: Copyright (C) 2023 Texas Instruments Incorporated -
//! All rights reserved not granted herein.
//! Limited License.
//!
//! Texas Instruments Incorporated grants a world-wide, royalty-free,
//! non-exclusive license under copyrights and patents it now or hereafter
//! owns or controls to make, have made, use, import, offer to sell and sell
//! ("Utilize") this software subject to the terms herein. With respect to the
//! foregoing patent license, such license is granted solely to the extent that
//! any such patent is necessary to Utilize the software alone. The patent
//! license shall not apply to any combinations which include this software,
//! other than combinations with devices manufactured by or for TI
//! ("TI Devices").
//! No hardware patent is licensed hereunder.
//!
//! Redistributions must preserve existing copyright notices and reproduce this
//! license (including the above copyright notice and the disclaimer and
//! (if applicable) source code license limitations below) in the documentation
//! and/or other materials provided with the distribution.
//!
//! Redistribution and use in binary form, without modification, are permitted
//! provided that the following conditions are met:
//!
//! * No reverse engineering, decompilation, or disassembly of this software is
//! permitted with respect to any software provided in binary form.
//! * Any redistribution and use are licensed by TI for use only
//! with TI Devices.
//! * Nothing shall obligate TI to provide you with source code for the
//! software licensed and provided to you in object code.
//!
//! If software source code is provided to you, modification and redistribution
//! of the source code are permitted provided that the following conditions
//! are met:
//!
//! * any redistribution and use of the source code, including any resulting
//! derivative works, are licensed by TI for use only with TI Devices.
//! * any redistribution and use of any object code compiled from the source
//! code and any resulting derivative works, are licensed by TI for use
//! only with TI Devices.
//!
//! Neither the name of Texas Instruments Incorporated nor the names of its
//! suppliers may be used to endorse or promote products derived from this
//! software without specific prior written permission.
//#############################################################################
#ifndef __USBHOSTPRIV_H__
#define __USBHOSTPRIV_H__
//*****************************************************************************
//
// If building with a C++ compiler, make all of the definitions in this header
// have a C binding.
//
//*****************************************************************************
#ifdef __cplusplus
extern "C"
{
#endif
//*****************************************************************************
//
// The states a hub port can be in during device connection.
//
//*****************************************************************************
typedef enum
{
//
// The port has no device connected.
//
ePortIdle,
//
// The port has a device present and is waiting for the enumeration
// sequence to begin.
//
ePortConnected,
//
// A device connection notification has been received and we have initiated
// a reset to the port. We are waiting for the reset to complete.
//
ePortResetActive,
//
// The Port reset has completed but now the hub is waiting the required
// 10ms before accessing the device.
//
ePortResetWait,
//
// A device is connected and the port has been reset. Control has been
// passed to the main host handling portion of USBLib to enumerate the
// device.
//
ePortActive,
//
// A device has completed enumeration.
//
ePortEnumerated,
//
// A device is attached to the port but enumeration failed.
//
ePortError
}
tHubPortState;
//*****************************************************************************
//
// The list of valid event flags in the g_sUSBHCD.ui32EventEnables member
// variable.
//
//*****************************************************************************
#define USBHCD_EVFLAG_SOF 0x00000001
#define USBHCD_EVFLAG_CONNECT 0x00000002
#define USBHCD_EVFLAG_UNKCNCT 0x00000004
#define USBHCD_EVFLAG_DISCNCT 0x00000008
#define USBHCD_EVFLAG_PWRFAULT 0x00000010
#define USBHCD_EVFLAG_PWRDIS 0x00000020
#define USBHCD_EVFLAG_PWREN 0x00000040
//*****************************************************************************
//
// This is the structure that holds all of the information for devices
// that are enumerated in the system. It is passed in to Open function of
// USB host class drivers so that they can allocate any endpoints and parse
// out other information that the device class needs to complete enumeration.
//
//*****************************************************************************
struct tUSBHostDevice
{
//
// The current device address for this device.
//
uint32_t ui32Address;
//
// The current interface for this device.
//
uint32_t ui32Interface;
//
// A flag used to record whether this is a low-speed or a full-speed
// device.
//
bool bLowSpeed;
//
// A flag indicating whether or not we have read the device's
// configuration descriptor yet.
//
bool bConfigRead;
//
// The hub number to which this device is attached.
//
uint8_t ui8Hub;
//
// The hub port number to which the device is attached.
//
uint8_t ui8HubPort;
//
// The device descriptor for this device.
//
tDeviceDescriptor sDeviceDescriptor;
//
// A pointer to the configuration descriptor for this device.
//
tConfigDescriptor *psConfigDescriptor;
//
// The size of the buffer allocated to psConfigDescriptor.
//
uint32_t ui32ConfigDescriptorSize;
//
// Internal flags used by the host controller driver.
//
uint32_t ui32Flags;
};
//*****************************************************************************
//
// Functions within the host controller that are called by the hub class driver
//
//*****************************************************************************
extern uint32_t USBHCDHubDeviceConnected(uint32_t ui32Index, uint8_t ui8Hub,
uint8_t ui8Port,
bool bLowSpeed);
extern void USBHCDHubDeviceDisconnected(uint32_t ui32Index,
uint32_t ui32DevIndex);
//*****************************************************************************
//
// Functions in the hub class driver that are called by the host controller.
//
//*****************************************************************************
extern void USBHHubMain(void);
extern void USBHHubInit(void);
extern void USBHHubEnumerationComplete(uint8_t ui8Hub, uint8_t ui8Port);
extern void USBHHubEnumerationError(uint8_t ui8Hub, uint8_t ui8Port);
//*****************************************************************************
//
// Mark the end of the C bindings section for C++ compilers.
//
//*****************************************************************************
#ifdef __cplusplus
}
#endif
#endif // __USBHOSTPRIV_H__
@@ -0,0 +1,113 @@
//#############################################################################
// FILE: usbhscsi.h
// TITLE: Definitions for the USB host SCSI layer
//#############################################################################
//!
//! Copyright: Copyright (C) 2023 Texas Instruments Incorporated -
//! All rights reserved not granted herein.
//! Limited License.
//!
//! Texas Instruments Incorporated grants a world-wide, royalty-free,
//! non-exclusive license under copyrights and patents it now or hereafter
//! owns or controls to make, have made, use, import, offer to sell and sell
//! ("Utilize") this software subject to the terms herein. With respect to the
//! foregoing patent license, such license is granted solely to the extent that
//! any such patent is necessary to Utilize the software alone. The patent
//! license shall not apply to any combinations which include this software,
//! other than combinations with devices manufactured by or for TI
//! ("TI Devices").
//! No hardware patent is licensed hereunder.
//!
//! Redistributions must preserve existing copyright notices and reproduce this
//! license (including the above copyright notice and the disclaimer and
//! (if applicable) source code license limitations below) in the documentation
//! and/or other materials provided with the distribution.
//!
//! Redistribution and use in binary form, without modification, are permitted
//! provided that the following conditions are met:
//!
//! * No reverse engineering, decompilation, or disassembly of this software is
//! permitted with respect to any software provided in binary form.
//! * Any redistribution and use are licensed by TI for use only
//! with TI Devices.
//! * Nothing shall obligate TI to provide you with source code for the
//! software licensed and provided to you in object code.
//!
//! If software source code is provided to you, modification and redistribution
//! of the source code are permitted provided that the following conditions
//! are met:
//!
//! * any redistribution and use of the source code, including any resulting
//! derivative works, are licensed by TI for use only with TI Devices.
//! * any redistribution and use of any object code compiled from the source
//! code and any resulting derivative works, are licensed by TI for use
//! only with TI Devices.
//!
//! Neither the name of Texas Instruments Incorporated nor the names of its
//! suppliers may be used to endorse or promote products derived from this
//! software without specific prior written permission.
//#############################################################################
#ifndef __USBHSCSI_H__
#define __USBHSCSI_H__
//*****************************************************************************
//
// If building with a C++ compiler, make all of the definitions in this header
// have a C binding.
//
//*****************************************************************************
#ifdef __cplusplus
extern "C"
{
#endif
//*****************************************************************************
//
//! \addtogroup usblib_host_class
//! @{
//
//*****************************************************************************
//*****************************************************************************
//
// Prototypes for the APIs exported by the USB SCSI layer.
//
//*****************************************************************************
extern uint32_t USBHSCSIInquiry(uint32_t ui32InPipe, uint32_t ui32OutPipe,
uint8_t *pui8Buffer, uint32_t *pui32Size);
extern uint32_t USBHSCSIReadCapacity(uint32_t ui32InPipe, uint32_t ui32OutPipe,
uint8_t *pui8Data, uint32_t *pui32Size);
extern uint32_t USBHSCSIReadCapacities(uint32_t ui32InPipe,
uint32_t ui32OutPipe, uint8_t *pui8Data,
uint32_t *pui32Size);
extern uint32_t USBHSCSIModeSense6(uint32_t ui32InPipe, uint32_t ui32OutPipe,
uint32_t ui32Flags, uint8_t *pui8Data,
uint32_t *pui32Size);
extern uint32_t USBHSCSITestUnitReady(uint32_t ui32InPipe,
uint32_t ui32OutPipe);
extern uint32_t USBHSCSIRequestSense(uint32_t ui32InPipe, uint32_t ui32OutPipe,
uint8_t *pui8Data, uint32_t *pui32Size);
extern uint32_t USBHSCSIRead10(uint32_t ui32InPipe, uint32_t ui32OutPipe,
uint32_t ui32LBA, uint8_t *pui8Data,
uint32_t *pui32Size, uint32_t ui32NumBlocks);
extern uint32_t USBHSCSIWrite10(uint32_t ui32InPipe, uint32_t ui32OutPipe,
uint32_t ui32LBA, uint8_t *pui8Data,
uint32_t *pui32Size, uint32_t ui32NumBlocks);
//*****************************************************************************
//
//! @}
//
//*****************************************************************************
//*****************************************************************************
//
// Mark the end of the C bindings section for C++ compilers.
//
//*****************************************************************************
#ifdef __cplusplus
}
#endif
#endif // __USBHSCSI_H__
@@ -0,0 +1,81 @@
//#############################################################################
// FILE: usb_ids.h
// TITLE: Definitions of VIDs and PIDs used by C2000 USB examples.
//#############################################################################
//!
//! Copyright: Copyright (C) 2023 Texas Instruments Incorporated -
//! All rights reserved not granted herein.
//! Limited License.
//!
//! Texas Instruments Incorporated grants a world-wide, royalty-free,
//! non-exclusive license under copyrights and patents it now or hereafter
//! owns or controls to make, have made, use, import, offer to sell and sell
//! ("Utilize") this software subject to the terms herein. With respect to the
//! foregoing patent license, such license is granted solely to the extent that
//! any such patent is necessary to Utilize the software alone. The patent
//! license shall not apply to any combinations which include this software,
//! other than combinations with devices manufactured by or for TI
//! ("TI Devices").
//! No hardware patent is licensed hereunder.
//!
//! Redistributions must preserve existing copyright notices and reproduce this
//! license (including the above copyright notice and the disclaimer and
//! (if applicable) source code license limitations below) in the documentation
//! and/or other materials provided with the distribution.
//!
//! Redistribution and use in binary form, without modification, are permitted
//! provided that the following conditions are met:
//!
//! * No reverse engineering, decompilation, or disassembly of this software is
//! permitted with respect to any software provided in binary form.
//! * Any redistribution and use are licensed by TI for use only
//! with TI Devices.
//! * Nothing shall obligate TI to provide you with source code for the
//! software licensed and provided to you in object code.
//!
//! If software source code is provided to you, modification and redistribution
//! of the source code are permitted provided that the following conditions
//! are met:
//!
//! * any redistribution and use of the source code, including any resulting
//! derivative works, are licensed by TI for use only with TI Devices.
//! * any redistribution and use of any object code compiled from the source
//! code and any resulting derivative works, are licensed by TI for use
//! only with TI Devices.
//!
//! Neither the name of Texas Instruments Incorporated nor the names of its
//! suppliers may be used to endorse or promote products derived from this
//! software without specific prior written permission.
//#############################################################################
#ifndef __USBIDS_H__
#define __USBIDS_H__
//*****************************************************************************
//
// TI Vendor ID for devices that use VID as 0x1CBE.
//
//*****************************************************************************
#define USB_VID_TI_1CBE 0x1cbe
//*****************************************************************************
//
// Product IDs.
//
//*****************************************************************************
#define USB_PID_MOUSE 0x0000
#define USB_PID_KEYBOARD 0x0001
#define USB_PID_SERIAL 0x0002
#define USB_PID_BULK 0x0003
#define USB_PID_SCOPE 0x0004
#define USB_PID_MSC 0x0005
#define USB_PID_AUDIO 0x0006
#define USB_PID_COMP_SERIAL 0x0007
#define USB_PID_COMP_AUDIO_HID 0x0008
#define USB_PID_COMP_HID_SER 0x0009
#define USB_PID_COMP_HID_DFU 0x000A
#define USB_PID_DATA_LOGGER 0x000B
#define USB_PID_COMP_HID_HID 0x000D
#define USB_PID_DFU 0x00FF
#endif /* __USBIDS_H__ */
@@ -0,0 +1,744 @@
//#############################################################################
// FILE: usbaudio.h
// TITLE: Definitions used by Audio Class devices
//#############################################################################
//!
//! Copyright: Copyright (C) 2023 Texas Instruments Incorporated -
//! All rights reserved not granted herein.
//! Limited License.
//!
//! Texas Instruments Incorporated grants a world-wide, royalty-free,
//! non-exclusive license under copyrights and patents it now or hereafter
//! owns or controls to make, have made, use, import, offer to sell and sell
//! ("Utilize") this software subject to the terms herein. With respect to the
//! foregoing patent license, such license is granted solely to the extent that
//! any such patent is necessary to Utilize the software alone. The patent
//! license shall not apply to any combinations which include this software,
//! other than combinations with devices manufactured by or for TI
//! ("TI Devices").
//! No hardware patent is licensed hereunder.
//!
//! Redistributions must preserve existing copyright notices and reproduce this
//! license (including the above copyright notice and the disclaimer and
//! (if applicable) source code license limitations below) in the documentation
//! and/or other materials provided with the distribution.
//!
//! Redistribution and use in binary form, without modification, are permitted
//! provided that the following conditions are met:
//!
//! * No reverse engineering, decompilation, or disassembly of this software is
//! permitted with respect to any software provided in binary form.
//! * Any redistribution and use are licensed by TI for use only
//! with TI Devices.
//! * Nothing shall obligate TI to provide you with source code for the
//! software licensed and provided to you in object code.
//!
//! If software source code is provided to you, modification and redistribution
//! of the source code are permitted provided that the following conditions
//! are met:
//!
//! * any redistribution and use of the source code, including any resulting
//! derivative works, are licensed by TI for use only with TI Devices.
//! * any redistribution and use of any object code compiled from the source
//! code and any resulting derivative works, are licensed by TI for use
//! only with TI Devices.
//!
//! Neither the name of Texas Instruments Incorporated nor the names of its
//! suppliers may be used to endorse or promote products derived from this
//! software without specific prior written permission.
//#############################################################################
#ifndef __USBAUDIO_H__
#define __USBAUDIO_H__
//*****************************************************************************
//
// Standard Audio descriptor sub types.
//
//*****************************************************************************
#define USB_AI_UNDEFINED 0
#define USB_AI_HEADER 1
#define USB_AI_INPUT_TERMINAL 2
#define USB_AI_OUTPUT_TERMINAL 3
#define USB_AI_MIXER_UNIT 4
#define USB_AI_SELECTOR_UNIT 5
#define USB_AI_FEATURE_UNIT 6
#define USB_AI_PROCESSING_UNIT 7
#define USB_AI_EXTENSION_UNIT 8
//*****************************************************************************
//
// Standard Audio Streaming Interface descriptor types.
//
//*****************************************************************************
#define USB_AS_UNDEFINED 0
#define USB_AS_GENERAL 1
#define USB_AS_FORMAT_TYPE 2
#define USB_AS_FORMAT_SPECIFIC 3
//*****************************************************************************
//
// Standard USB terminal types used with audio terminal descriptors. These
// are defined in the "Universal Serial Bus Device Class Definition for
// Terminal Types" version 1.0 released March 18, 1998.
//
//*****************************************************************************
#define USB_TTYPE_UNDEFINED 0x0100
#define USB_TTYPE_STREAMING 0x0101
#define USB_TTYPE_VENDOR 0x01ff
#define USB_TTYPE_OUT_UNDEF 0x0300
#define USB_TTYPE_OUT_SPEAKER 0x0301
#define USB_TTYPE_OUT_HEADPHONE 0x0302
#define USB_TTYPE_OUT_DESK_SPKR 0x0304
#define USB_TTYPE_OUT_ROOM_SPKR 0x0305
#define USB_TTYPE_OUT_COMM_SPKR 0x0306
#define USB_TTYPE_OUT_LFE 0x0307
#define USB_TTYPE_EXT_UNDEF 0x0600
#define USB_TTYPE_EXT_ANALOG 0x0601
#define USB_TTYPE_EXT_DIGITAL 0x0602
#define USB_TTYPE_EXT_LINE 0x0603
#define USB_TTYPE_EXT_LEGACY 0x0604
#define USB_TTYPE_EXT_SPDIF 0x0605
#define USB_TTYPE_EXT_1394_DA 0x0606
#define USB_TTYPE_EXT_1394_DV 0x0607
//*****************************************************************************
//
// Audio Interface Subclass Codes
//
//*****************************************************************************
#define USB_ASC_UNDEFINED 0x00
#define USB_ASC_AUDIO_CONTROL 0x01
#define USB_ASC_AUDIO_STREAMING 0x02
#define USB_ASC_MIDI_STREAMING 0x03
//*****************************************************************************
//
// Audio Class-Specific Descriptor Types
// (Table A-4)
//
//*****************************************************************************
#define USB_ACSDT_UNDEFINED 0x20
#define USB_ACSDT_DEVICE 0x21
#define USB_ACSDT_CONFIGURATION 0x22
#define USB_ACSDT_STRING 0x23
#define USB_ACSDT_INTERFACE 0x24
#define USB_ACSDT_ENDPOINT 0x25
//*****************************************************************************
//
// Audio Class-Specific AC Interface Descriptor Subtypes
// (Table A-5)
//
//*****************************************************************************
#define USB_ACDSTYPE_UNDEFINED 0x00
#define USB_ACDSTYPE_HEADER 0x01
#define USB_ACDSTYPE_IN_TERMINAL 0x02
#define USB_ACDSTYPE_OUT_TERMINAL 0x03
#define USB_ACDSTYPE_MIXER_UNIT 0x04
#define USB_ACDSTYPE_SELECTOR_UNIT 0x05
#define USB_ACDSTYPE_FEATURE_UNIT 0x06
#define USB_ACDSTYPE_PROCESSING_UNIT 0x07
#define USB_ACDSTYPE_EXTENSION_UNIT 0x08
//*****************************************************************************
//
// Audio Class-Specific AS Interface Descriptor Subtypes
// (Table A-6)
//
//*****************************************************************************
#define USB_ASDSTYPE_UNDEFINED 0x00
#define USB_ASDSTYPE_GENERAL 0x01
#define USB_ASDSTYPE_FORMAT_TYPE 0x02
#define USB_ASDSTYPE_FORMAT_SPECIFIC 0x03
//*****************************************************************************
//
// Audio Data Format Type I Codes.
//
//*****************************************************************************
#define USB_ADF_UNDEFINED 0x0000
#define USB_ADF_PCM 0x0001
#define USB_ADF_PCM8 0x0002
#define USB_ADF_IEEE_FLOAT 0x0003
#define USB_ADF_ALAW 0x0004
#define USB_ADF_MULAW 0x0005
//*****************************************************************************
//
// Audio Format Type Codes
//
//*****************************************************************************
#define USB_AF_TYPE_UNDEFINED 0x00
#define USB_AF_TYPE_TYPE_I 0x01
#define USB_AF_TYPE_TYPE_II 0x02
#define USB_AF_TYPE_TYPE_III 0x03
//*****************************************************************************
//
// Audio Class-Specific controls used with bmaControls values.
//
//*****************************************************************************
#define USB_ACONTROL_MUTE 0x0001 // Mute
#define USB_ACONTROL_VOLUME 0x0002 // Volume
#define USB_ACONTROL_BASS 0x0004 // Bass
#define USB_ACONTROL_MID 0x0008 // Mid
#define USB_ACONTROL_TREBLE 0x0010 // Treble
#define USB_ACONTROL_EQ 0x0020 // Graphic Equalizer
#define USB_ACONTROL_AGC 0x0040 // Automatic Gain
#define USB_ACONTROL_DELAY 0x0080 // Delay
#define USB_ACONTROL_BASS_BOOST 0x0100 // Bass Boost
#define USB_ACONTROL_LOUD 0x0200 // Loudness
//*****************************************************************************
//
// Audio Class-Specific Output terminal types.
//
//*****************************************************************************
#define USB_ATTYPE_UNDEFINED 0x0300 // Output Terminal, undefined Type.
#define USB_ATTYPE_SPEAKER 0x0301 // A generic speaker.
#define USB_ATTYPE_HEADPHONES 0x0302 // A head-mounted audio output device.
#define USB_ATTYPE_HMD 0x0303 // The audio part of a VR head mounted
// display.
#define USB_ATTYPE_SPEAKER_DT 0x0304 // Desktop or Monitor speaker(s).
#define USB_ATTYPE_SPEAKER_RM 0x0305 // Larger room speaker(s).
#define USB_ATTYPE_SPEAKER_COM 0x0306 // Communications Speaker (phone).
#define USB_ATTYPE_SPEAKER_LFE 0x0307 // Speaker designed for low
// frequencies.
//*****************************************************************************
//
// USB Audio channel configuration bits for wChannelConfig values.
// wChannelConfig: a bit field that indicates which spatial locations are
// present in the cluster. The bit allocations are as follows:
//
//*****************************************************************************
#define USB_CHANNEL_L 0x0001 // Left Front (L)
#define USB_CHANNEL_R 0x0002 // Right Front (R)
#define USB_CHANNEL_C 0x0004 // Center Front (C)
#define USB_CHANNEL_LFE 0x0008 // Low Frequency Enhancement (LFE)
#define USB_CHANNEL_LS 0x0010 // Left Surround (LS)
#define USB_CHANNEL_RS 0x0020 // Right Surround (RS)
#define USB_CHANNEL_LC 0x0040 // Left of Center (LC)
#define USB_CHANNEL_RC 0x0080 // Right of Center (RC)
#define USB_CHANNEL_S 0x0100 // Surround (S)
#define USB_CHANNEL_SL 0x0200 // Side Left (SL)
#define USB_CHANNEL_SR 0x0400 // Side Right (SR)
#define USB_CHANNEL_T 0x0800 // Top (T)
//*****************************************************************************
//
// Endpoint attributes for Audio Class General type.
//
//*****************************************************************************
#define USB_EP_ATTR_ACG_SAMPLING 0x01 // Sampling Frequency
#define USB_EP_ATTR_ACG_PITCH 0x02 // Pitch
#define USB_EP_ATTR_ACG_MAXPACKET 0x80 // MaxPacketsOnly
//*****************************************************************************
//
// Indicates the units used for the wLockDelay field for Audio Class General
// type.
//
//*****************************************************************************
#define USB_EP_LOCKDELAY_UNDEF 0x00 // Undefined
#define USB_EP_LOCKDELAY_MS 0x01 // Milliseconds
#define USB_EP_LOCKDELAY_PCM 0x02 // Decoded PCM samples
//*****************************************************************************
//
// Audio Class-Specific Request Codes
//
//*****************************************************************************
#define USB_AC_SET_CUR 0x01
#define USB_AC_SET_MIN 0x02
#define USB_AC_SET_MAX 0x03
#define USB_AC_SET_RES 0x04
#define USB_AC_SET_MEM 0x05
#define USB_AC_GET_CUR 0x81
#define USB_AC_GET_MIN 0x82
#define USB_AC_GET_MAX 0x83
#define USB_AC_GET_RES 0x84
#define USB_AC_GET_MEM 0x85
#define USB_AC_GET_STAT 0xff
#define USB_CS_CONTROL_M 0xff00
#define USB_CS_CHANNEL_M 0x00ff
//*****************************************************************************
//
// Endpoint Control Selectors
//
//*****************************************************************************
#define EP_CONTROL_UNDEFINED 0x0000
#define SAMPLING_FREQ_CONTROL 0x0100
#define PITCH_CONTROL 0x0200
//*****************************************************************************
//
// Feature Unit Control Selectors
//
//*****************************************************************************
#define FU_CONTROL_UNDEFINED 0x0000
#define MUTE_CONTROL 0x0100
#define VOLUME_CONTROL 0x0200
#define BASS_CONTROL 0x0300
#define MID_CONTROL 0x0400
#define TREBLE_CONTROL 0x0500
#define EQUALIZER_CONTROL 0x0600
#define AUTOMATIC_GAIN_CONTROL 0x0700
#define DELAY_CONTROL 0x0800
#define BASS_BOOST_CONTROL 0x0900
#define LOUDNESS_CONTROL 0x0A00
//*****************************************************************************
//
// All structures defined in this section of the header require byte packing of
// fields. This is usually accomplished using the PACKED macro but, for IAR
// Embedded Workbench, this requires a pragma.
//
//*****************************************************************************
#ifdef __ICCARM__
#pragma pack(1)
#endif
//*****************************************************************************
//
//! This structure describes the Class-Specific Audio Class Interface Header
//! Descriptor as defined in Universal Serial Bus Device Class Definition
//! for Audio Devices Release 1.0.
//
//*****************************************************************************
typedef struct
{
//
//! The length of this descriptor in bytes.
//
uint8_t bLength;
//
//! The type of the descriptor. For an interface descriptor, this will
//! be USB_DTYPE_CS_INTERFACE (36).
//
uint8_t bDescriptorType;
//
//! This will be USB_DSUBTYPE_HEADER for the header.
//
uint8_t bDescriptorSubtype;
//
//! Audio Device Class Specification Release Number in Binary-Coded
//! Decimal.
//
uint16_t bcdADC;
//
//! Total number of bytes returned for the class-specific AudioControl
//! interface descriptor. Includes the combined length of this descriptor
//! header and all Unit and Terminal descriptors.
//
uint16_t wTotai32Length;
//
//! The number of AudioStreaming and MIDIStreaming interfaces in the Audio
//! Interface Collection to which this AudioControl interface belongs.
//
uint8_t bInCollection;
//
//! Interface number of the first AudioStreaming or MIDIStreaming interface
//! in the Collection.
//
uint8_t baInterfaceNr;
}
PACKED tACHeader;
//*****************************************************************************
//
// These are the possible bits set in the tACInputTerminal.wChannelConfig
// value.
//
//*****************************************************************************
#define USB_AC_CC_LEFT 0x0001
#define USB_AC_CC_RIGHT 0x0002
#define USB_AC_CC_CENTER 0x0004
#define USB_AC_CC_LFE 0x0008
#define USB_AC_CC_LEFTSURROUND 0x0010
#define USB_AC_CC_RIGHTSURROUND 0x0020
#define USB_AC_CC_LEFT_CENTER 0x0040
#define USB_AC_CC_RIGHT_CENTER 0x0080
#define USB_AC_CC_SURROUND 0x0100
#define USB_AC_CC_SIDE_LEFT 0x0200
#define USB_AC_CC_SIDE_RIGHT 0x0400
#define USB_AC_CC_TOP 0x0800
//*****************************************************************************
//
//! This structure describes the Feature Unit Descriptor as defined in
//! Universal Serial Bus Device Class Definition for Audio Devices Release 1.0.
//
//*****************************************************************************
typedef struct
{
//
//! The length of this descriptor in bytes.
//
uint8_t bLength;
//
//! The type of the descriptor. For an interface descriptor, this will
//! be USB_DTYPE_CS_INTERFACE (36).
//
uint8_t bDescriptorType;
//
//! This will be USB_DSUBTYPE_IN_TERM for the header.
//
uint8_t bDescriptorSubtype;
//
//! Constant uniquely identifying the Unit within the audio function. This
//! value is used in all requests to address this Unit.
//
uint8_t bUnitID;
//
//! ID of the Unit or Terminal to which this Feature Unit is connected.
//
uint8_t bSourceID;
//
//! ID of the Output Terminal to which this Input Terminal is associated.
//
uint8_t bControlSize;
//
//! A bit set to 1 indicates that the mentioned Control is supported for
//! a given channel. See the USB_FU_* defines for the bit definitions.
//! This actually an array of elements of size bControlSize so be
//! careful when using this value directly.
//
uint16_t bmaControls;
}
PACKED tACFeatureUnit;
//*****************************************************************************
//
//! This structure describes the Output Terminal Descriptor as defined in
//! Universal Serial Bus Device Class Definition for Audio Devices Release 1.0.
//
//*****************************************************************************
typedef struct
{
//
//! The length of this descriptor in bytes.
//
uint8_t bLength;
//
//! The type of the descriptor. For an interface descriptor, this will
//! be USB_DTYPE_CS_INTERFACE (36).
//
uint8_t bDescriptorType;
//
//! This will be USB_DSUBTYPE_OUT_TERM for the header.
//
uint8_t bDescriptorSubtype;
//
//! Constant uniquely identifying the Terminal within the audio function.
//! This value is used in all requests to address this Terminal.
//
uint8_t bTerminalID;
//
//! Constant characterizing the type of Terminal. See USB Audio Terminal
//! Types.
//
uint16_t wTerminalType;
//
//! Constant, identifying the Input Terminal to which this Output Terminal
//! is associated.
//
uint8_t bAssocTerminal;
//
//! ID of the Unit or Terminal to which this Terminal is connected.
//
uint8_t bSourceID;
//
//! Index of a string descriptor, describing the Output Terminal.
//
uint8_t iTerminal;
}
PACKED tACOutputTerminal;
//*****************************************************************************
//
//! This structure describes the Input Terminal Descriptor as defined in
//! Universal Serial Bus Device Class Definition for Audio Devices Release 1.0.
//
//*****************************************************************************
typedef struct
{
//
//! The length of this descriptor in bytes.
//
uint8_t bLength;
//
//! The type of the descriptor. For an interface descriptor, this will
//! be USB_DTYPE_CS_INTERFACE (36).
//
uint8_t bDescriptorType;
//
//! This will be USB_DSUBTYPE_OUT_TERM for the header.
//
uint8_t bDescriptorSubtype;
//
//! Constant uniquely identifying the Terminal within the audio function.
//! This value is used in all requests to address this Terminal.
//
uint8_t bTerminalID;
//
//! Constant characterizing the type of Terminal. See USB Audio Terminal
//! Types.
//
uint16_t wTerminalType;
//
//! Constant, identifying the Input Terminal to which this Output Terminal
//! is associated.
//
uint8_t bAssocTerminal;
//
//! Number of logical output channels in the Terminal's output audio
//! channel cluster.
//
uint8_t bNrChannels;
//
//! Describes the spatial location of the logical channels.
//
uint16_t wChannelConfig;
//
//! Index of a string descriptor, describing the name of the first logical
//! channel.
//
uint8_t iChannelNames;
//
//! Index of a string descriptor, describing the Output Terminal.
//
uint8_t iTerminal;
}
PACKED tACInputTerminal;
//*****************************************************************************
//
//! This structure describes the Mixer Descriptor as defined in Universal
//! Serial Bus Device Class Definition for Audio Devices Release 1.0.
//
//*****************************************************************************
typedef struct
{
//
//! The length of this descriptor in bytes.
//
uint8_t bLength;
//
//! The type of the descriptor. For an interface descriptor, this will
//! be USB_DTYPE_CS_INTERFACE (36).
//
uint8_t bDescriptorType;
//
//! This will be USB_AI_MIXER_UNIT for the header.
//
uint8_t bDescriptorSubtype;
//
//! Constant uniquely identifying the Unit within the audio function. This
//! value is used in all requests to address this Unit.
//
uint8_t bUnitID;
//
//! Number of Input Pins of this Unit.
//
uint8_t bNrInPins;
//
//! ID of the Unit or Terminal to which the first Input Pin of this Mixer
//! Unit is connected.
//
uint8_t baSourceID;
}
PACKED tACMixer;
//*****************************************************************************
//
//! This structure describes the Selector Descriptor as defined in Universal
//! Serial Bus Device Class Definition for Audio Devices Release 1.0.
//
//*****************************************************************************
typedef struct
{
//
//! The length of this descriptor in bytes.
//
uint8_t bLength;
//
//! The type of the descriptor. For an interface descriptor, this will
//! be USB_DTYPE_CS_INTERFACE (36).
//
uint8_t bDescriptorType;
//
//! This will be USB_AI_MIXER_UNIT for the header.
//
uint8_t bDescriptorSubtype;
//
//! Constant uniquely identifying the Unit within the audio function. This
//! value is used in all requests to address this Unit.
//
uint8_t bUnitID;
//
//! Number of Input Pins of this Unit.
//
uint8_t bNrInPins;
//
//! ID of the Unit or Terminal to which the first Input Pin of this Mixer
//! Unit is connected.
//
uint8_t baSourceID;
}
PACKED tACSelector;
//*****************************************************************************
//
//! This structure describes the Output Terminal Descriptor as defined in
//! Universal Serial Bus Device Class Definition for Audio Devices Release 1.0.
//
//*****************************************************************************
typedef struct
{
//
//! The length of this descriptor in bytes.
//
uint8_t bLength;
//
//! The type of the descriptor. For an interface descriptor, this will
//! be USB_DTYPE_CS_INTERFACE (36).
//
uint8_t bDescriptorType;
//
//! This will be USB_DSUBTYPE_GENERAL for the header.
//
uint8_t bDescriptorSubtype;
//
//! The Terminal ID of the Terminal to which the endpoint of this
//! interface is connected.
//
uint8_t bTerminalLink;
//
//! Delay introduced by the data path. Expressed in number of frames.
//
uint8_t bDelay;
//
//! The Audio Data Format that has to be used to communicate with this
//! interface.
//
uint16_t wFormatTag;
}
PACKED tACGeneral;
//*****************************************************************************
//
//! This structure describes the Type I Audio format descriptors defined in
//! USB Audio Devices Release 1.0.
//
//*****************************************************************************
typedef struct
{
//
//! The length of this descriptor in bytes.
//
uint8_t bLength;
//
//! The type of the descriptor. For an interface descriptor, this will
//! be USB_DTYPE_CS_INTERFACE (36).
//
uint8_t bDescriptorType;
//
//! This will be USB_AS_FORMAT_TYPE.
//
uint8_t bDescriptorSubtype;
//
//! This will be USB_AS_FORMAT_TYPE_I.
//
uint8_t bFormatType;
//
//! Number of channels on this streaming interface.
//
uint8_t bNrChannels;
//
//! Number of bytes per audio sub-frame or channel.
//
uint8_t bSubFrameSize;
//
//! Number of bits per sample.
//
uint8_t bBitResolution;
//
//! Number of sample rates that are supported.
//
uint8_t bSamFreqType;
//
//! Number of bits per sample.
//
uint8_t tSamFreq;
}
PACKED tASFormat;
//*****************************************************************************
//
// Return to default packing when using the IAR Embedded Workbench compiler.
//
//*****************************************************************************
#ifdef __ICCARM__
#pragma pack()
#endif
#endif
@@ -0,0 +1,979 @@
//#############################################################################
// FILE: usbhid.h
// TITLE: Definitions used by Communication Device Class devices
//#############################################################################
//!
//! Copyright: Copyright (C) 2023 Texas Instruments Incorporated -
//! All rights reserved not granted herein.
//! Limited License.
//!
//! Texas Instruments Incorporated grants a world-wide, royalty-free,
//! non-exclusive license under copyrights and patents it now or hereafter
//! owns or controls to make, have made, use, import, offer to sell and sell
//! ("Utilize") this software subject to the terms herein. With respect to the
//! foregoing patent license, such license is granted solely to the extent that
//! any such patent is necessary to Utilize the software alone. The patent
//! license shall not apply to any combinations which include this software,
//! other than combinations with devices manufactured by or for TI
//! ("TI Devices").
//! No hardware patent is licensed hereunder.
//!
//! Redistributions must preserve existing copyright notices and reproduce this
//! license (including the above copyright notice and the disclaimer and
//! (if applicable) source code license limitations below) in the documentation
//! and/or other materials provided with the distribution.
//!
//! Redistribution and use in binary form, without modification, are permitted
//! provided that the following conditions are met:
//!
//! * No reverse engineering, decompilation, or disassembly of this software is
//! permitted with respect to any software provided in binary form.
//! * Any redistribution and use are licensed by TI for use only
//! with TI Devices.
//! * Nothing shall obligate TI to provide you with source code for the
//! software licensed and provided to you in object code.
//!
//! If software source code is provided to you, modification and redistribution
//! of the source code are permitted provided that the following conditions
//! are met:
//!
//! * any redistribution and use of the source code, including any resulting
//! derivative works, are licensed by TI for use only with TI Devices.
//! * any redistribution and use of any object code compiled from the source
//! code and any resulting derivative works, are licensed by TI for use
//! only with TI Devices.
//!
//! Neither the name of Texas Instruments Incorporated nor the names of its
//! suppliers may be used to endorse or promote products derived from this
//! software without specific prior written permission.
//#############################################################################
//*****************************************************************************
//
// Note: This header contains definitions related to the USB Communication
// Device Class specification. The header is complete for ACM model
// devices but request and notification definitions specific to other
// modem types, ISDN, ATM and Ethernet are currently incomplete or
// omitted.
//
//*****************************************************************************
#ifndef __USBCDC_H__
#define __USBCDC_H__
//*****************************************************************************
//
// If building with a C++ compiler, make all of the definitions in this header
// have a C binding.
//
//*****************************************************************************
#ifdef __cplusplus
extern "C"
{
#endif
//*****************************************************************************
//
//! \addtogroup cdc_device_class_api
//! @{
//
//*****************************************************************************
//*****************************************************************************
//
// Generic macros to read an 8-bit, 16-bit or 32-bit value from a character
// pointer.
//
//*****************************************************************************
#define BYTE(pui8Data) (*(uint8_t *)(pui8Data))
#define SHORT(pui8Data) (*(uint16_t *)(pui8Data))
#define LONG(pui8Data) (*(uint32_t *)(pui8Data))
//*****************************************************************************
//
// USB CDC subclass codes. Used in interface descriptor, bInterfaceClass
//
//*****************************************************************************
#define USB_CDC_SUBCLASS_DIRECT_LINE_MODEL \
0x01
#define USB_CDC_SUBCLASS_ABSTRACT_MODEL \
0x02
#define USB_CDC_SUBCLASS_TELEPHONE_MODEL \
0x03
#define USB_CDC_SUBCLASS_MULTI_CHANNEL_MODEL \
0x04
#define USB_CDC_SUBCLASS_CAPI_MODEL \
0x05
#define USB_CDC_SUBCLASS_ETHERNET_MODEL \
0x06
#define USB_CDC_SUBCLASS_ATM_MODEL \
0x07
//*****************************************************************************
//
// USB CDC control interface protocols. Used in control interface descriptor,
// bInterfaceProtocol. Control interface is the interface where the control
// information is sent or received. Usually interface 0.
//
//*****************************************************************************
#define USB_CDC_PROTOCOL_NONE 0x00
#define USB_CDC_PROTOCOL_V25TER 0x01
#define USB_CDC_PROTOCOL_VENDOR 0xFF
//*****************************************************************************
//
// USB CDC data interface protocols. Used in data interface descriptor,
// bInterfaceProtocol. Data interface is the interface where the data from
// CDC device is sent or received. Usually interface 1
//
//*****************************************************************************
// USB_CDC_PROTOCOL_NONE 0x00
#define USB_CDC_PROTOCOL_I420 0x30
#define USB_CDC_PROTOCOL_TRANSPARENT \
0x32
#define USB_CDC_PROTOCOL_Q921M 0x50
#define USB_CDC_PROTOCOL_Q921 0x51
#define USB_CDC_PROTOCOL_Q921TM 0x52
#define USB_CDC_PROTOCOL_V42BIS 0x90
#define USB_CDC_PROTOCOL_Q921EURO \
0x91
#define USB_CDC_PROTOCOL_V120 0x92
#define USB_CDC_PROTOCOL_CAPI20 0x93
#define USB_CDC_PROTOCOL_HOST_DRIVER \
0xFD
#define USB_CDC_PROTOCOL_CDC_SPEC \
0xFE
// USB_CDC_PROTOCOL_VENDOR 0xFF
//*****************************************************************************
//
// Functional descriptor definitions
//
//*****************************************************************************
//*****************************************************************************
//
// Functional descriptor types
//
//*****************************************************************************
#define USB_CDC_CS_INTERFACE 0x24
#define USB_CDC_CS_ENDPOINT 0x25
//*****************************************************************************
//
// Functional descriptor subtypes
//
//*****************************************************************************
#define USB_CDC_FD_SUBTYPE_HEADER \
0x00
#define USB_CDC_FD_SUBTYPE_CALL_MGMT \
0x01
#define USB_CDC_FD_SUBTYPE_ABSTRACT_CTL_MGMT \
0x02
#define USB_CDC_FD_SUBTYPE_DIRECT_LINE_MGMT \
0x03
#define USB_CDC_FD_SUBTYPE_TELEPHONE_RINGER \
0x04
#define USB_CDC_FD_SUBTYPE_LINE_STATE_CAPS \
0x05
#define USB_CDC_FD_SUBTYPE_UNION \
0x06
#define USB_CDC_FD_SUBTYPE_COUNTRY \
0x07
#define USB_CDC_FD_SUBTYPE_TELEPHONE_MODES \
0x08
#define USB_CDC_FD_SUBTYPE_USB_TERMINAL \
0x09
#define USB_CDC_FD_SUBTYPE_NETWORK_TERMINAL \
0x0A
#define USB_CDC_FD_SUBTYPE_PROTOCOL_UNIT \
0x0B
#define USB_CDC_FD_SUBTYPE_EXTENSION_UNIT \
0x0C
#define USB_CDC_FD_SUBTYPE_MULTI_CHANNEL_MGMT \
0x0D
#define USB_CDC_FD_SUBTYPE_CAPI_MGMT \
0x0E
#define USB_CDC_FD_SUBTYPE_ETHERNET \
0x0F
#define USB_CDC_FD_SUBTYPE_ATM 0x10
//*****************************************************************************
//
// USB_CDC_FD_SUBTYPE_CALL_MGMT, Header functional descriptor, bmCapabilities
//
//*****************************************************************************
#define USB_CDC_CALL_MGMT_VIA_DATA \
0x02
#define USB_CDC_CALL_MGMT_HANDLED \
0x01
//*****************************************************************************
//
// USB_CDC_FD_SUBTYPE_ABSTRACT_CTL_MGMT, Abstract Control Management functional
// descriptor, bmCapabilities
//
//*****************************************************************************
#define USB_CDC_ACM_SUPPORTS_NETWORK_CONNECTION \
0x08
#define USB_CDC_ACM_SUPPORTS_SEND_BREAK \
0x04
#define USB_CDC_ACM_SUPPORTS_LINE_PARAMS \
0x02
#define USB_CDC_ACM_SUPPORTS_COMM_FEATURE \
0x01
//*****************************************************************************
//
// USB_CDC_FD_SUBTYPE_DIRECT_LINE_MGMT, Direct Line Management functional
// descriptor, bmCapabilities
//
//*****************************************************************************
#define USB_CDC_DLM_NEEDS_EXTRA_PULSE_SETUP \
0x04
#define USB_CDC_DLM_SUPPORTS_AUX \
0x02
#define USB_CDC_DLM_SUPPORTS_PULSE \
0x01
//*****************************************************************************
//
// USB_CDC_FD_SUBTYPE_TELEPHONE_MODES, Telephone Operational Modes functional
// descriptor, bmCapabilities
//
//*****************************************************************************
#define USB_CDC_TELEPHONE_SUPPORTS_COMPUTER \
0x04
#define USB_CDC_TELEPHONE_SUPPORTS_STANDALONE \
0x02
#define USB_CDC_TELEPHONE_SUPPORTS_SIMPLE \
0x01
//*****************************************************************************
//
// USB_CDC_FD_SUBTYPE_LINE_STATE_CAPS, Telephone Call and Line State Reporting
// Capabilities descriptor
//
//*****************************************************************************
#define USB_CDC_LINE_STATE_CHANGES_NOTIFIED \
0x20
#define USB_CDC_LINE_STATE_REPORTS_DTMF \
0x10
#define USB_CDC_LINE_STATE_REPORTS_DIST_RING \
0x08
#define USB_CDC_LINE_STATE_REPORTS_CALLERID \
0x04
#define USB_CDC_LINE_STATE_REPORTS_BUSY \
0x02
#define USB_CDC_LINE_STATE_REPORTS_INT_DIALTONE \
0x01
//*****************************************************************************
//
// USB_CDC_FD_SUBTYPE_USB_TERMINAL, USB Terminal functional descriptor,
// bmOptions
//
//*****************************************************************************
#define USB_CDC_TERMINAL_NO_WRAPPER_USED \
0x00
#define USB_CDC_TERMINAL_WRAPPER_USED \
0x01
//*****************************************************************************
//
// USB_CDC_FD_SUBTYPE_MULTI_CHANNEL_MGMT, Multi-Channel Management functional
// descriptor, bmCapabilities
//
//*****************************************************************************
#define USB_CDC_MCM_SUPPORTS_SET_UNIT_PARAM \
0x04
#define USB_CDC_MCM_SUPPORTS_CLEAR_UNIT_PARAM \
0x02
#define USB_CDC_MCM_UNIT_PARAMS_NON_VOLATILE \
0x01
//*****************************************************************************
//
// USB_CDC_FD_SUBTYPE_CAPI_MGMT, CAPI Control Management functional descriptor,
// bmCapabilities
//
//*****************************************************************************
#define USB_CDC_CAPI_INTELLIGENT \
0x01
#define USB_CDC_CAPI_SIMPLE 0x00
//*****************************************************************************
//
// USB_CDC_FD_SUBTYPE_ETHERNET, Ethernet Networking functional descriptor,
// bmEthernetStatistics
//
//*****************************************************************************
#define USB_CDC_ETHERNET_XMIT_OK \
0x01000000
#define USB_CDC_ETHERNET_RCV_OK 0x02000000
#define USB_CDC_ETHERNET_XMIT_ERROR \
0x04000000
#define USB_CDC_ETHERNET_RCV_ERROR \
0x08000000
#define USB_CDC_ETHERNET_RCV_NO_BUFFER \
0x10000000
#define USB_CDC_ETHERNET_DIRECTED_BYTES_XMIT \
0x20000000
#define USB_CDC_ETHERNET_DIRECTED_FRAMES_XMIT \
0x40000000
#define USB_CDC_ETHERNET_MULTICAST_BYTES_XMIT \
0x80000000
#define USB_CDC_ETHERNET_MULTICAST_FRAMES_XMIT \
0x00010000
#define USB_CDC_ETHERNET_BROADCAST_BYTES_XMIT \
0x00020000
#define USB_CDC_ETHERNET_BROADCAST_FRAMES_XMIT \
0x00040000
#define USB_CDC_ETHERNET_DIRECTED_BYTES_RCV \
0x00080000
#define USB_CDC_ETHERNET_DIRECTED_FRAMES_RCV \
0x00100000
#define USB_CDC_ETHERNET_MULTICAST_BYTES_RCV \
0x00200000
#define USB_CDC_ETHERNET_MULTICAST_FRAMES_RCV \
0x00400000
#define USB_CDC_ETHERNET_BROADCAST_BYTES_RCV \
0x00800000
#define USB_CDC_ETHERNET_BROADCAST_FRAMES_RCV \
0x00000100
#define USB_CDC_ETHERNET_RCV_CRC_ERROR \
0x00000200
#define USB_CDC_ETHERNET_TRANSMIT_QUEUE_LENGTH \
0x00000400
#define USB_CDC_ETHERNET_RCV_ERROR_ALIGNMENT \
0x00000800
#define USB_CDC_ETHERNET_XMIT_ONE_COLLISION \
0x00001000
#define USB_CDC_ETHERNET_XMIT_MORE_COLLISIONS \
0x00002000
#define USB_CDC_ETHERNET_XMIT_DEFERRED \
0x00004000
#define USB_CDC_ETHERNET_XMIT_MAX_COLLISIONS \
0x00008000
#define USB_CDC_ETHERNET_RCV_OVERRUN \
0x00000001
#define USB_CDC_ETHERNET_XMIT_UNDERRUN \
0x00000002
#define USB_CDC_ETHERNET_XMIT_HEARTBEAT_FAILURE \
0x00000004
#define USB_CDC_ETHERNET_XMIT_TIMES_CRS_LOST \
0x00000010
//*****************************************************************************
//
// USB_CDC_FD_SUBTYPE_ATM, ATM Networking functional descriptor,
// bmDataCapabilities
//
//*****************************************************************************
#define USB_CDC_ATM_TYPE_3 0x08
#define USB_CDC_ATM_TYPE_2 0x04
#define USB_CDC_ATM_TYPE_1 0x02
//*****************************************************************************
//
// bmATMDeviceStatistics
//
//*****************************************************************************
#define USB_CDC_ATM_VC_US_CELLS_SENT \
0x10
#define USB_CDC_ATM_VC_US_CELLS_RECEIVED \
0x08
#define USB_CDC_ATM_DS_CELLS_HEC_ERR_CORRECTED \
0x04
#define USB_CDC_ATM_US_CELLS_SENT \
0x02
#define USB_CDC_ATM_US_CELLS_RECEIVED \
0x01
//*****************************************************************************
//
// Management Element Requests (provided in tUSBRequest.bRequest)
//
//*****************************************************************************
#define USB_CDC_SEND_ENCAPSULATED_COMMAND \
0x00
#define USB_CDC_GET_ENCAPSULATED_RESPONSE \
0x01
#define USB_CDC_SET_COMM_FEATURE \
0x02
#define USB_CDC_GET_COMM_FEATURE \
0x03
#define USB_CDC_CLEAR_COMM_FEATURE \
0x04
#define USB_CDC_SET_AUX_LINE_STATE \
0x10
#define USB_CDC_SET_HOOK_STATE 0x11
#define USB_CDC_PULSE_SETUP 0x12
#define USB_CDC_SEND_PULSE 0x13
#define USB_CDC_SET_PULSE_TIME 0x14
#define USB_CDC_RING_AUX_JACK 0x15
#define USB_CDC_SET_LINE_CODING 0x20
#define USB_CDC_GET_LINE_CODING 0x21
#define USB_CDC_SET_CONTROL_LINE_STATE \
0x22
#define USB_CDC_SEND_BREAK 0x23
#define USB_CDC_SET_RINGER_PARMS \
0x30
#define USB_CDC_GET_RINGER_PARMS \
0x31
#define USB_CDC_SET_OPERATION_PARMS \
0x32
#define USB_CDC_GET_OPERATION_PARMS \
0x33
#define USB_CDC_SET_LINE_PARMS 0x34
#define USB_CDC_GET_LINE_PARMS 0x35
#define USB_CDC_DIAL_DIGITS 0x36
#define USB_CDC_SET_UNIT_PARAMETER \
0x37
#define USB_CDC_GET_UNIT_PARAMETER \
0x38
#define USB_CDC_CLEAR_UNIT_PARAMETER \
0x39
#define USB_CDC_GET_PROFILE 0x3A
#define USB_CDC_SET_ETHERNET_MULTICAST_FILTERS \
0x40
#define USB_CDC_SET_ETHERNET_POWER_MANAGEMENT_PATTERN_FILTER \
0x41
#define USB_CDC_GET_ETHERNET_POWER_MANAGEMENT_PATTERN_FILTER \
0x42
#define USB_CDC_SET_ETHERNET_PACKET_FILTER \
0x43
#define USB_CDC_GET_ETHERNET_STATISTIC \
0x44
#define USB_CDC_SET_ATM_DATA_FORMAT \
0x50
#define USB_CDC_GET_ATM_DEVICE_STATISTICS \
0x51
#define USB_CDC_SET_ATM_DEFAULT_VC \
0x52
#define USB_CDC_GET_ATM_VC_STATISTICS \
0x53
//*****************************************************************************
//
// In cases where a request defined above results in the return of a fixed size
// data block, the following group of labels define the size of that block. In
// each of these cases, an access macro is also provided to write the response
// data into an appropriately-sized array of 8-bit characters.
//
//*****************************************************************************
#define USB_CDC_SIZE_COMM_FEATURE \
2
#define USB_CDC_SIZE_LINE_CODING \
7
#define USB_CDC_SIZE_RINGER_PARMS \
4
#define USB_CDC_SIZE_OPERATION_PARMS \
2
#define USB_CDC_SIZE_UNIT_PARAMETER \
2
#define USB_CDC_SIZE_PROFILE 64
#define USB_CDC_SIZE_ETHERNET_POWER_MANAGEMENT_PATTERN_FILTER \
2
#define USB_CDC_SIZE_ETHERNET_STATISTIC \
4
#define USB_CDC_SIZE_ATM_DEVICE_STATISTICS \
4
#define USB_CDC_SIZE_ATM_VC_STATISTICS \
4
#define USB_CDC_SIZE_LINE_PARMS \
10
//*****************************************************************************
//
// NB: USB_CDC_SIZE_LINE_PARAMS assumes only a single call. For multiple
// calls, add 4 bytes per additional call.
//
//*****************************************************************************
//*****************************************************************************
//
// USB_CDC_GET_COMM_FEATURE & USB_CDC_SET_COMM_FEATURE
//
//*****************************************************************************
//*****************************************************************************
//
// wValue (Feature Selector)
//
//*****************************************************************************
#define USB_CDC_ABSTRACT_STATE 0x0001
#define USB_CDC_COUNTRY_SETTING 0x0002
//*****************************************************************************
//
// Data when feature selector is USB_DCD_ABSTRACT_STATE
//
//*****************************************************************************
#define USB_CDC_ABSTRACT_CALL_DATA_MULTIPLEXED \
0x0002
#define USB_CDC_ABSTRACT_ENDPOINTS_IDLE \
0x0001
//*****************************************************************************
//
// Macros to populate the response data buffer (whose size in bytes is defined
// by USB_CDC_SIZE_COMM_FEATURE).
//
//*****************************************************************************
#define SetResponseCommFeature(pi8Buf, ui16Data) \
do \
{ \
(*(uint16_t *)(pi8Buf)) = ui16Data; \
} \
while(0)
//*****************************************************************************
//
// USB_CDC_SET_AUX_LINE_STATE, wValue
//
//*****************************************************************************
#define USB_CDC_AUX_DISCONNECT 0x0000
#define USB_CDC_AUX_CONNECT 0x0001
//*****************************************************************************
//
// USB_CDC_SET_HOOK_STATE, wValue
//
//*****************************************************************************
#define USB_CDC_ON_HOOK 0x0000
#define USB_CDC_OFF_HOOK 0x0001
#define USB_CDC_SNOOPING 0x0002
//*****************************************************************************
//
// USB_CDC_GET_LINE_CODING
//
//*****************************************************************************
#define USB_CDC_STOP_BITS_1 0x00
#define USB_CDC_STOP_BITS_1_5 0x01
#define USB_CDC_STOP_BITS_2 0x02
#define USB_CDC_PARITY_NONE 0x00
#define USB_CDC_PARITY_ODD 0x01
#define USB_CDC_PARITY_EVEN 0x02
#define USB_CDC_PARITY_MARK 0x03
#define USB_CDC_PARITY_SPACE 0x04
//*****************************************************************************
//
// Macro to populate the response data buffer (whose size in bytes is defined
// by USB_CDC_SIZE_LINE_CODING).
//
//*****************************************************************************
#define SetResponseLineCoding(pi8Buf, ui8Rate, ui8Stop, ui8Parity, \
ui8Databits) \
do \
{ \
(*(uint32_t *)(pi8Buf)) = ui8Rate; \
(*((uint8_t *)(pi8Buf) + 4)) = ui8Stop; \
(*((uint8_t *)(pi8Buf) + 5)) = ui8Parity; \
(*((uint8_t *)(pi8Buf) + 6)) = ui8Databits; \
} \
while(0)
//*****************************************************************************
//
// USB_CDC_SET_CONTROL_LINE_STATE, wValue
//
//*****************************************************************************
#define USB_CDC_DEACTIVATE_CARRIER \
0x00
#define USB_CDC_ACTIVATE_CARRIER \
0x02
#define USB_CDC_DTE_NOT_PRESENT 0x00
#define USB_CDC_DTE_PRESENT 0x01
//*****************************************************************************
//
// USB_CDC_SET_RINGER_PARMS, USB_CDC_GET_RINGER_PARMS and
// USB_CDC_GET_LINE_PARMS (ui32RingerBmp)
//
//*****************************************************************************
#define USB_CDC_RINGER_EXISTS 0x80000000
#define USB_CDC_RINGER_DOES_NOT_EXIST \
0x00000000
//*****************************************************************************
//
// Macro to populate the response data buffer to USB_CDC_GET_RINGER_PARMS.
// Parameter buf points to a buffer of size USB_CDC_SIZE_RINGER_PARMS bytes.
//
//*****************************************************************************
#define SetResponseRingerParms(pi8Buf, ui8Pattern, ui8Volume, ui32Exists) \
do \
{ \
*(uint32_t *)(pi8Buf) = ((ui8Pattern) + \
((ui8Volume & 0xFF) << 8) + \
(ui32Exists & USB_CDC_RINGER_EXISTS)); \
} \
while(0)
//*****************************************************************************
//
// Macros to extract fields from the USB_CDC_SET_RINGER_PARMS data
//
//*****************************************************************************
#define GetRingerVolume(pi8Data) \
(BYTE((pi8Data) + 1))
#define GetRingerPattern(pi8Data) \
(BYTE(pi8Data))
#define GetRingerExists(pi8Data) \
((LONG(pi8Data)) & USB_CDC_RINGER_EXISTS)
//*****************************************************************************
//
// USB_CDC_SET_OPERATION_PARMS, wValue
//
//*****************************************************************************
#define USB_CDC_SIMPLE_MODE 0x0000
#define USB_CDC_STANDALONE_MODE 0x0001
#define USB_CDC_HOST_CENTRIC_MODE \
0x0002
//*****************************************************************************
//
// Macro to populate the response data buffer to USB_CDC_GET_OPERATION_PARMS.
// Parameter buf points to a buffer of size USB_CDC_SIZE_OPERATION_PARMS
// bytes.
//
//*****************************************************************************
#define SetResponseOperationParms(pi8Bbuf, ui16Data) \
do \
{ \
WORD(pi8Buf) = ui16Data; \
} \
while(0)
//*****************************************************************************
//
// USB_CDC_SET_LINE_PARMS, wParam - Line State Change
//
//*****************************************************************************
#define USB_CDC_DROP_ACTIVE_CALL \
0x0000
#define USB_CDC_START_NEW_CALL 0x0001
#define USB_CDC_APPLY_RINGING 0x0002
#define USB_CDC_REMOVE_RINGING 0x0003
#define USB_CDC_SWITCH_CALL 0x0004
//*****************************************************************************
//
// Line state bitmap in USB_CDC_GET_LINE_PARMS response
//
//*****************************************************************************
#define USB_CDC_LINE_IS_ACTIVE 0x80000000
#define USB_CDC_LINE_IS_IDLE 0x00000000
#define USB_CDC_LINE_NO_ACTIVE_CALL \
0x000000FF
#define USB_CDC_CALL_ACTIVE 0x80000000
//*****************************************************************************
//
// Call state value definitions
//
//*****************************************************************************
#define USB_CDC_CALL_IDLE 0x00000000
#define USB_CDC_CALL_TYPICAL_DIALTONE \
0x00000001
#define USB_CDC_CALL_INTERRUPTED_DIALTONE \
0x00000002
#define USB_CDC_CALL_DIALING 0x00000003
#define USB_CDC_CALL_RINGBACK 0x00000004
#define USB_CDC_CALL_CONNECTED 0x00000005
#define USB_CDC_CALL_INCOMING 0x00000006
//*****************************************************************************
//
// Call state change value definitions
//
//*****************************************************************************
#define USB_CDC_CALL_STATE_IDLE 0x01
#define USB_CDC_CALL_STATE_DIALING \
0x02
#define USB_CDC_CALL_STATE_RINGBACK \
0x03
#define USB_CDC_CALL_STATE_CONNECTED \
0x04
#define USB_CDC_CALL_STATE_INCOMING \
0x05
//*****************************************************************************
//
// Extra byte of data describing the connection type for
// USB_CDC_CALL_STATE_CONNECTED.
//
//*****************************************************************************
#define USB_CDC_VOICE 0x00
#define USB_CDC_ANSWERING_MACHINE \
0x01
#define USB_CDC_FAX 0x02
#define USB_CDC_MODEM 0x03
#define USB_CDC_UNKNOWN 0xFF
//*****************************************************************************
//
// Macro to extract call index from request in cases where wParam is
// USB_CDC_SWITCH_CALL.
//
//*****************************************************************************
#define GetCallIndex(pi8Data) (BYTE(pi8Data))
//*****************************************************************************
//
// Macro to populate the CallState entries in response to request
// USB_CDC_GET_LINE_PARMS. The ui8Index parameter is a zero based index
// indicating which call entry in the pi8Buf response buffer to fill in. Note
// that pi8Buf points to the first byte of the buffer (the wLength field).
//
//*****************************************************************************
#define SetResponseCallState(pi8Buf, ui8Index, ui32Active, ui8StateChange, \
ui8State) \
do \
{ \
(LONG((uint8_t *)(pi8Buf) + (10 + (4 * (ui8Index))))) = \
(((ui32Active) & USB_CDC_CALL_IS_ACTIVE) + \
(((ui8StateChange) & 0xFF) << 8) + \
((ui8State) & 0xFF)); \
} \
while(0)
//*****************************************************************************
//
// Macro to populate the response data buffer (whose size in bytes is defined
// by USB_CDC_SIZE_LINE_PARMS). Note that this macro only populates fields for
// a single call. If multiple calls are being managed, additional 4 byte
// fields must be appended to provide call state for each call after the first.
// This may be done using the SetResponseCallState macro with the appropriate
// call index supplied.
//
//*****************************************************************************
#define SetResponseLineParms(pi8Buf, ui16Length, \
ui8RingPattern, ui8RingVolume, ui32RingExists, \
ui32LineActive, ui8LineCallIndex, \
ui32CallActive, ui8CallStateChange, \
ui8CallState) \
do \
{ \
(WORD(pi8Buf)) = ui16Length; \
SetResponseRingerParams(((uint8_t *)(pi8Buf) + 2), \
ui8RingPattern, ui8RingVolume, \
ui32RingExists); \
(LONG((uint8_t *)(pi8Buf) + 6)) = \
(((ui32LineActive) & USB_CDC_LINE_IS_ACTIVE) + \
((ui8LineCallIndex) & 0xFF)) ; \
SetResponseCallState(pi8Buf, 0, ui32CallActive, \
ui8CallStateChange, ui8CallState); \
} \
while(0)
//*****************************************************************************
//
// Notification Element definitions
//
//*****************************************************************************
#define USB_CDC_NOTIFY_NETWORK_CONNECTION \
0x00
#define USB_CDC_NOTIFY_RESPONSE_AVAILABLE \
0x01
#define USB_CDC_NOTIFY_AUX_JACK_HOOK_STATE \
0x08
#define USB_CDC_NOTIFY_RING_DETECT \
0x09
#define USB_CDC_NOTIFY_SERIAL_STATE \
0x20
#define USB_CDC_NOTIFY_CALL_STATE_CHANGE \
0x28
#define USB_CDC_NOTIFY_LINE_STATE_CHANGE \
0x29
#define USB_CDC_NOTIFY_CONNECTION_SPEED_CHANGE \
0x2A
//*****************************************************************************
//
// USB_CDC_NOTIFY_NETWORK_CONNECTION, wValue
//
//*****************************************************************************
#define USB_CDC_NETWORK_DISCONNECTED \
0x0000
#define USB_CDC_NETWORK_CONNECTED \
0x0001
//*****************************************************************************
//
// USB_CDC_NOTIFY_AUX_JACK_HOOK_STATE, wValue
//
//*****************************************************************************
#define USB_CDC_AUX_JACK_ON_HOOK \
0x0000
#define USB_CDC_AUX_JACK_OFF_HOOK \
0x0001
//*****************************************************************************
//
// USB_CDC_NOTIFY_SERIAL_STATE, Data
//
//*****************************************************************************
//*****************************************************************************
//
// Number of bytes of data returned alongside this notification.
//
//*****************************************************************************
#define USB_CDC_NOTIFY_SERIAL_STATE_SIZE \
2
#define USB_CDC_SERIAL_STATE_OVERRUN \
0x0040
#define USB_CDC_SERIAL_STATE_PARITY \
0x0020
#define USB_CDC_SERIAL_STATE_FRAMING \
0x0010
#define USB_CDC_SERIAL_STATE_RING_SIGNAL \
0x0008
#define USB_CDC_SERIAL_STATE_BREAK \
0x0004
#define USB_CDC_SERIAL_STATE_TXCARRIER \
0x0002
#define USB_CDC_SERIAL_STATE_RXCARRIER \
0x0001
//*****************************************************************************
//
// USB_CDC_NOTIFY_CALL_STATE_CHANGE, wValue
//
// Call state values are defined above in the group beginning
// USB_CDC_CALL_STATE_IDLE. Note that the data returned alongside this
// notification are heavily dependent upon the call state being reported so no
// specific lengths or access macros are provided here.
//
// Macro to construct the correct wValue for this notification given a state
// and call index.
//
//*****************************************************************************
#define SetNotifyCallStatewValue(pi16Result, ui8CallState, ui8Index) \
do \
{ \
(WORD(pi16Result)) = (((ui8CallState) & 0xFF) + \
(((ui8Index) & 0xFF) << 8)); \
} \
while(0)
//*****************************************************************************
//
// USB_CDC_NOTIFY_LINE_STATE_CHANGE, wValue
//
// Note that the data returned alongside this notification are heavily
// dependent upon the call state being reported so no specific lengths or
// access macros are provided here.
//
//*****************************************************************************
#define USB_CDC_LINE_STATE_IDLE 0x0000
#define USB_CDC_LINE_STATE_HOLD 0x0001
#define USB_CDC_LINE_STATE_OFF_HOOK \
0x0002
#define USB_CDC_LINE_STATE_ON_HOOK \
0x0003
//*****************************************************************************
//
// USB_CDC_NOTIFY_CONNECTION_SPEED_CHANGE, Data
//
// Macro to populate the 8 byte data structure returned alongside this
// notification.
//
//*****************************************************************************
#define SetNotifyConnectionSpeedChange(pi8Buf, ui32USBitRate, ui32DSBitRate) \
do \
{ \
LONG(pi8Buf) = ui32USBitRate; \
LONG((uint8_t *)(pi8Buf) + 4) = ui32DSBitRate; \
} \
while(0)
//*****************************************************************************
//
// Packed structure definitions for request/response data blocks
//
//*****************************************************************************
//*****************************************************************************
//
// All structures defined in this section of the header require byte packing of
// fields. This is usually accomplished using the PACKED macro but, for IAR
// Embedded Workbench, this requires a pragma.
//
//*****************************************************************************
#ifdef __ICCARM__
#pragma pack(1)
#endif
//*****************************************************************************
//
//! USB_CDC_GET/SET_LINE_CODING request-specific data.
//
//*****************************************************************************
typedef struct
{
//
//! The data terminal rate in bits per second.
//
#ifdef __TMS320C28XX__
usb32_t ui32Rate;
#else
uint32_t ui32Rate;
#endif
//
//! The number of stop bits. Valid values are USB_CDC_STOP_BITS_1,
//! USB_CDC_STOP_BITS_1_5 or USB_CDC_STOP_BITS_2
//
uint8_t ui8Stop;
//
//! The parity setting. Valid values are USB_CDC_PARITY_NONE,
//! USB_CDC_PARITY_ODD, USB_CDC_PARITY_EVEN, USB_CDC_PARITY_MARK and
//! USB_CDC_PARITY_SPACE.
//
uint8_t ui8Parity;
//
//! The number of data bits per character. Valid values are 5, 6, 7 and 8
//! in this implementation.
//
uint8_t ui8Databits;
}
PACKED tLineCoding;
//*****************************************************************************
//
// Return to default packing when using the IAR Embedded Workbench compiler.
//
//*****************************************************************************
#ifdef __ICCARM__
#pragma pack()
#endif
//*****************************************************************************
//
// Close the Doxygen group.
//! @}
//
//*****************************************************************************
//*****************************************************************************
//
// Mark the end of the C bindings section for C++ compilers.
//
//*****************************************************************************
#ifdef __cplusplus
}
#endif
#endif // __USBCDC_H__
@@ -0,0 +1,530 @@
//#############################################################################
// FILE: usbdfu.h
// TITLE: Definitions related to the USB Device Firmware Upgrade class
//#############################################################################
//!
//! Copyright: Copyright (C) 2023 Texas Instruments Incorporated -
//! All rights reserved not granted herein.
//! Limited License.
//!
//! Texas Instruments Incorporated grants a world-wide, royalty-free,
//! non-exclusive license under copyrights and patents it now or hereafter
//! owns or controls to make, have made, use, import, offer to sell and sell
//! ("Utilize") this software subject to the terms herein. With respect to the
//! foregoing patent license, such license is granted solely to the extent that
//! any such patent is necessary to Utilize the software alone. The patent
//! license shall not apply to any combinations which include this software,
//! other than combinations with devices manufactured by or for TI
//! ("TI Devices").
//! No hardware patent is licensed hereunder.
//!
//! Redistributions must preserve existing copyright notices and reproduce this
//! license (including the above copyright notice and the disclaimer and
//! (if applicable) source code license limitations below) in the documentation
//! and/or other materials provided with the distribution.
//!
//! Redistribution and use in binary form, without modification, are permitted
//! provided that the following conditions are met:
//!
//! * No reverse engineering, decompilation, or disassembly of this software is
//! permitted with respect to any software provided in binary form.
//! * Any redistribution and use are licensed by TI for use only
//! with TI Devices.
//! * Nothing shall obligate TI to provide you with source code for the
//! software licensed and provided to you in object code.
//!
//! If software source code is provided to you, modification and redistribution
//! of the source code are permitted provided that the following conditions
//! are met:
//!
//! * any redistribution and use of the source code, including any resulting
//! derivative works, are licensed by TI for use only with TI Devices.
//! * any redistribution and use of any object code compiled from the source
//! code and any resulting derivative works, are licensed by TI for use
//! only with TI Devices.
//!
//! Neither the name of Texas Instruments Incorporated nor the names of its
//! suppliers may be used to endorse or promote products derived from this
//! software without specific prior written permission.
//#############################################################################
#ifndef __USBDFU_H__
#define __USBDFU_H__
//*****************************************************************************
//
// DFU attributes as published in the functional descriptor.
//
//*****************************************************************************
#define DFU_ATTR_WILL_DETACH 0x08
#define DFU_ATTR_MANIFEST_TOLERANT \
0x04
#define DFU_ATTR_CAN_UPLOAD 0x02
#define DFU_ATTR_CAN_DOWNLOAD 0x01
//*****************************************************************************
//
// The states that the DFU device can be in. These values are reported to
// the host in response to a USBD_DFU_REQUEST_GETSTATE request.
//
//*****************************************************************************
typedef enum
{
eDFUStateAppIdle = 0,
eDFUStateAppDetach,
eDFUStateIdle,
eDFUStateDnloadSync,
eDFUStateDnBusy,
eDFUStateDnloadIdle,
eDFUStateManifestSync,
eDFUStateManifest,
eDFUStateManifestWaitReset,
eDFUStateUploadIdle,
eDFUStateError
}
tDFUState;
//*****************************************************************************
//
// The current error status of the DFU device. These values are reported to
// the host in response to a USBD_DFU_REQUEST_GETSTATUS request.
//
//*****************************************************************************
typedef enum
{
eDFUStatusOk = 0,
eDFUStatusErrTarget,
eDFUStatusErrFile,
eDFUStatusErrWrite,
eDFUStatusErrErase,
eDFUStatusErrCheckErased,
eDFUStatusErrProg,
eDFUStatusErrVerify,
eDFUStatusErrAddress,
eDFUStatusErrNotDone,
eDFUStatusErrFirmware,
eDFUStatusErrVendor,
eDFUStatusErrUSBR,
eDFUStatusErrPOR,
eDFUStatusErrUnknown,
eDFUStatusErrStalledPkt
}
tDFUStatus;
//*****************************************************************************
//
// The descriptor type for the DFU functional descriptor.
//
//*****************************************************************************
#define USB_DFU_FUNC_DESCRIPTOR_TYPE \
0x21
//*****************************************************************************
//
// The subclass identifier for DFU as reported to the host in the
// bInterfaceSubClass field of the DFU interface descriptor.
//
//*****************************************************************************
#define USB_DFU_SUBCLASS 0x01
//*****************************************************************************
//
// The protocol identifier for DFU as reported to the host in the
// bInterfaceProtocol field of the DFU interface descriptor.
//
//*****************************************************************************
#define USB_DFU_PROTOCOL 0x02
#define USB_DFU_RUNTIME_PROTOCOL \
0x01
//*****************************************************************************
//
// DFU class-specific request identifiers.
//
//*****************************************************************************
#define USBD_DFU_REQUEST_DETACH 0
#define USBD_DFU_REQUEST_DNLOAD 1
#define USBD_DFU_REQUEST_UPLOAD 2
#define USBD_DFU_REQUEST_GETSTATUS \
3
#define USBD_DFU_REQUEST_CLRSTATUS \
4
#define USBD_DFU_REQUEST_GETSTATE \
5
#define USBD_DFU_REQUEST_ABORT 6
//*****************************************************************************
//
// Request 1KB blocks from the host. This value is published in the USB
// functional descriptor.
//
//*****************************************************************************
#define DFU_TRANSFER_SIZE 1024
//*****************************************************************************
//
// USBLib-specific request identifier. This is used to determine whether
// the target device supports our DFU command protocol. It is expected that
// a device not supporting our extensions will stall this request. This
// request is only supported while the DFU device is in eDFUStateIdle.
//
// An IN request containing the following parameters will result in the device
// sending back a tDFUQueryC2000Protocol structure indicating that
// USBLib extensions are supported. The actual values in wValue and wIndex
// have no meaning other than to act as markers in the unlikely event that
// another DFU device also chooses to use request ID 0x42 for some other
// purpose.
//
// wValue - 0x23(REQUEST_C2000_VALUE)
// wIndex - Interface number
// wLength - sizeof(tDFUQueryC2000Protocol)
//
//*****************************************************************************
#define USBD_DFU_REQUEST_C2000 0x42
#define REQUEST_C2000_VALUE 0x23
#define DFU_PROTOCOL_C2000_MARKER \
0x4C4D
#define DFU_PROTOCOL_C2000_VERSION_1 \
0x0001
#ifdef __ICCARM__
#pragma pack(1)
#endif
//*****************************************************************************
//
// The structure sent to the host when a valid USBD_DFU_REQUEST_C2000 is
// received while the DFU device is in idle state.
//
//*****************************************************************************
typedef struct
{
//
// The protocol marker(DFU_PROTOCOL_C2000_MARKER)
//
uint16_t ui16Marker;
//
// The protocol version(DFU_PROTOCOL_C2000_VERSION_1)
//
uint16_t ui16Version;
}
PACKED tDFUQueryC2000Protocol;
//*****************************************************************************
//
// Structure sent to the host in response to USBD_DFU_REQUEST_GETSTATUS.
//
//*****************************************************************************
typedef struct
{
uint8_t bStatus;
uint8_t bwPollTimeout[3];
uint8_t bState;
uint8_t iString;
}
PACKED tDFUGetStatusResponse;
//*****************************************************************************
//
// Firmware Download Commands
//
// The data passed on a USBD_DFU_REQUEST_DNLOAD request is comprised of a
// header which instructs the boot loader how to interpret the block and
// block-specific data. The following definitions relate to the download
// block headers.
//
//*****************************************************************************
//*****************************************************************************
//
// Supported command identifiers
//
//*****************************************************************************
#define DFU_CMD_PROG 0x01
#define DFU_CMD_READ 0x02
#define DFU_CMD_CHECK 0x03
#define DFU_CMD_ERASE 0x04
#define DFU_CMD_INFO 0x05
#define DFU_CMD_BIN 0x06
#define DFU_CMD_RESET 0x07
//*****************************************************************************
//
// Generic download command header.
//
//*****************************************************************************
typedef struct
{
//
// Command identifier.
//
uint8_t ui8Command;
//
// Command-specific data elements.
//
uint8_t pui8Data[7];
}
PACKED tDFUDownloadHeader;
//*****************************************************************************
//
// Header for the DFU_CMD_PROG command.
//
// This command is used to program a section of the flash with the binary data
// which immediately follows the header. The start address of the data is
// expressed as a 1KB block number so 0 would represent the bottom of flash
// (which, incidentally, the USB boot loader will not let you program) and 0x10
// would represent address 16KB or 16384 (0x4000). The ui32Length field
// contains the total number of bytes of data in the following programming
// operation. The DFU device will not look for any command header on following
// USBD_DFU_REQUEST_DNLOAD requests until the operation is completed or
// aborted.
//
// By using this protocol, the DFU_CMD_PROG command header may be used as a
// simple header on the binary files to be sent to the DFU device for
// programming. If we enforce the requirement that the DFU_CMD_PROG header is
// applied to each USBD_DFU_REQUEST_DNLOAD (one per block), this means that the
// host-side DFU application must be aware of the underlying protocol and
// insert these headers dynamically during programming operations. This could
// be handled by post processing the binary to insert the headers at the
// appropriate points but this would then tie the binary structure to the
// chosen transfer size and break the operation if the transfer size were to
// change in the future.
//
//*****************************************************************************
typedef struct
{
//
// DFU_CMD_PROG
//
uint8_t ui8Command;
//
// Reserved - set to 0x00.
//
uint8_t ui8Reserved;
//
// Block start address / 1024
//
uint16_t ui16StartAddr;
//
// Total length, in bytes, of following data for the complete download
// operation.
//
uint32_t ui32Length;
}
PACKED tDFUDownloadProgHeader;
//*****************************************************************************
//
// Header for the DFU_CMD_READ and DFU_CMD_CHECK commands.
//
// This command may be used to set the address range whose content will be
// returned on subsequent USBD_DFU_REQUEST_UPLOAD requests from the host.
//
// To read back a the contents of a region of flash, the host should send
// USBD_DFU_REQUEST_DNLOAD with ui8Command DFU_CMD_READ, ui16StartAddr set to
// the 1KB block start address and ui32Length set to the number of bytes to
// read. The host should then send one or more USBD_DFU_REQUEST_UPLOAD
// requests to receive the current flash contents from the configured
// addresses. Data returned will include an 8 byte DFU_CMD_PROG prefix
// structure unless the prefix has been disabled by sending a DFU_CMD_BIN
// command with the bBinary parameter set to 1.
//
// To check that a region of flash is erased, the DFU_CMD_CHECK command should
// be sent with ui16StartAddr and ui32Length set to describe the region to
// check. The host should then send a USBD_DFU_REQUEST_GETSTATUS. If the
// erase check was successful, the returned bStatus value will be STATUS_OK,
// otherwise it will be STATUS_ERR_CHECK_ERASED. Note that ui32Length passed
// must be a multiple of 4. If this is not the case, the value will be
// truncated before the check is performed.
//
//*****************************************************************************
typedef struct
{
//
// DFU_CMD_READ or DFU_CMD_CHECK
//
uint8_t ui8Command;
//
// Reserved - write to 0
//
uint8_t ui8Reserved;
//
// Block start address / 1024
//
uint16_t ui16StartAddr;
//
// The number of bytes of data to read back or check.
//
uint32_t ui32Length;
}
PACKED tDFUDownloadReadCheckHeader;
//*****************************************************************************
//
// Header for the DFU_CMD_ERASE command.
//
// This command may be used to erase a number of flash blocks. The address of
// the first block to be erased is passed in ui16StartAddr with ui16NumBlocks
// containing the number of blocks to be erased from this address. The block
// size of the device may be determined using the DFU_CMD_INFO command.
//
//*****************************************************************************
typedef struct
{
//
// DFU_CMD_ERASE
//
uint8_t ui8Command;
//
// Reserved - set to 0.
//
uint8_t ui8Reserved;
//
// Block start address / 1024
//
uint16_t ui16StartAddr;
//
// The number of blocks to erase.
//
uint16_t ui16NumBlocks;
//
// Reserved - set to 0.
//
uint8_t pui8Reserved2[2];
}
PACKED tDFUDownloadEraseHeader;
//*****************************************************************************
//
// Header for the DFU_CMD_INFO command.
//
// This command may be used to query information about the connected device.
// After sending the command, the information is returned on the next
// USBD_DFU_REQUEST_UPLOAD request.
//
//*****************************************************************************
typedef struct
{
//
// DFU_CMD_INFO
//
uint8_t ui8Command;
//
// Reserved - set to 0.
//
uint8_t pui8Reserved[7];
}
PACKED tDFUDownloadInfoHeader;
//*****************************************************************************
//
// Header for the DFU_CMD_BIN command.
//
// This command may be used to set the format of uploaded data. By default,
// images read using USBD_DFU_REQUEST_UPLOAD are formatted with the appropriate
// header to allow the same image to be flashed back to the device and have it
// located at the address from which it originated. This is a requirement of
// the DFU class specification (section 6.2 "the uploaded image must be
// usable in a subsequent download") but may not be helpful in some cases where
// the application wishes to receive only the binary image from flash. To
// instruct the DFU device to omit the position and size header, send this
// command with the bBinary field set to \b true prior to issuing a
// USBD_DFU_REQUEST_UPLOAD for image data. The format choice remains in effect
// until the command is sent once again with bBinary set to \b false.
//
// Note that the format choice affects only image data sent and not responses
// read via USBD_DFU_REQUEST_UPLOAD following USBLib-specific commands such
// as DFU_CMD_INFO.
//
//*****************************************************************************
typedef struct
{
//
// DFU_CMD_BIN
//
uint8_t ui8Command;
//
// Set to true to omit image header or false to include it (the default).
//
uint8_t ui8Binary;
//
// Reserved - set to 0.
//
uint8_t pui8Reserved[6];
}
PACKED tDFUDownloadBinHeader;
//*****************************************************************************
//
// The DFU_CMD_RESET command uses a tDFUDownloadHeader structure since
// only the ui8Command field is important. This command causes an immediate
// reset of the the target board.
//
//*****************************************************************************
//*****************************************************************************
//
//! Payload returned in response to the DFU_CMD_INFO command.
//!
//! This is structure is returned in response to the first
//! USBD_DFU_REQUEST_UPLOAD request following a DFU_CMD_INFO command.
//
//*****************************************************************************
typedef struct
{
//
//! The size of a flash block in bytes.
//
uint16_t ui16FlashBlockSize;
//
//! The number of blocks of flash in the device. Total flash size is
//! ui16NumFlashBlocks * ui16FlashBlockSize.
//
uint16_t ui16NumFlashBlocks;
//
//! Information on the part number, family, version and package as
//! read from SYSCTL register DID1.
//
uint32_t ui32PartInfo;
//
//! Information on the part class and revision as read from SYSCTL DID0.
//
uint32_t ui32ClassInfo;
//
//! Address 1 byte above the highest location the boot loader can access.
//
uint32_t ui32FlashTop;
//
//! Lowest address the boot loader can write or erase.
//
uint32_t ui32AppStartAddr;
}
PACKED tDFUDeviceInfo;
#ifdef __ICCARM__
#pragma pack()
#endif
#endif // __USBDFU_H__
@@ -0,0 +1,695 @@
//#############################################################################
// FILE: usbhid.h
// TITLE: Definitions used by HID class devices and hosts
//#############################################################################
//!
//! Copyright: Copyright (C) 2023 Texas Instruments Incorporated -
//! All rights reserved not granted herein.
//! Limited License.
//!
//! Texas Instruments Incorporated grants a world-wide, royalty-free,
//! non-exclusive license under copyrights and patents it now or hereafter
//! owns or controls to make, have made, use, import, offer to sell and sell
//! ("Utilize") this software subject to the terms herein. With respect to the
//! foregoing patent license, such license is granted solely to the extent that
//! any such patent is necessary to Utilize the software alone. The patent
//! license shall not apply to any combinations which include this software,
//! other than combinations with devices manufactured by or for TI
//! ("TI Devices").
//! No hardware patent is licensed hereunder.
//!
//! Redistributions must preserve existing copyright notices and reproduce this
//! license (including the above copyright notice and the disclaimer and
//! (if applicable) source code license limitations below) in the documentation
//! and/or other materials provided with the distribution.
//!
//! Redistribution and use in binary form, without modification, are permitted
//! provided that the following conditions are met:
//!
//! * No reverse engineering, decompilation, or disassembly of this software is
//! permitted with respect to any software provided in binary form.
//! * Any redistribution and use are licensed by TI for use only
//! with TI Devices.
//! * Nothing shall obligate TI to provide you with source code for the
//! software licensed and provided to you in object code.
//!
//! If software source code is provided to you, modification and redistribution
//! of the source code are permitted provided that the following conditions
//! are met:
//!
//! * any redistribution and use of the source code, including any resulting
//! derivative works, are licensed by TI for use only with TI Devices.
//! * any redistribution and use of any object code compiled from the source
//! code and any resulting derivative works, are licensed by TI for use
//! only with TI Devices.
//!
//! Neither the name of Texas Instruments Incorporated nor the names of its
//! suppliers may be used to endorse or promote products derived from this
//! software without specific prior written permission.
//#############################################################################
#ifndef __USBHID_H__
#define __USBHID_H__
//*****************************************************************************
//
// If building with a C++ compiler, make all of the definitions in this header
// have a C binding.
//
//*****************************************************************************
#ifdef __cplusplus
extern "C"
{
#endif
//*****************************************************************************
//
//! \addtogroup hid_device_class_api
//! @{
//
//*****************************************************************************
//*****************************************************************************
//
// HID Interface descriptor Subclasses.
//
//*****************************************************************************
#define USB_HID_SCLASS_NONE 0x00
#define USB_HID_SCLASS_BOOT 0x01
//*****************************************************************************
//
// USB Interface descriptor HID protocols.
//
//*****************************************************************************
#define USB_HID_PROTOCOL_NONE 0
#define USB_HID_PROTOCOL_KEYB 1
#define USB_HID_PROTOCOL_MOUSE 2
//*****************************************************************************
//
// HID Class descriptor types.
//
//*****************************************************************************
#define USB_HID_DTYPE_HID 0x21
#define USB_HID_DTYPE_REPORT 0x22
#define USB_HID_DTYPE_PHYSICAL 0x23
//*****************************************************************************
//
// HID USB requests.
//
//*****************************************************************************
#define USBREQ_GET_REPORT 0x01
#define USBREQ_GET_IDLE 0x02
#define USBREQ_GET_PROTOCOL 0x03
#define USBREQ_SET_REPORT 0x09
#define USBREQ_SET_IDLE 0x0a
#define USBREQ_SET_PROTOCOL 0x0b
//*****************************************************************************
//
// GET_REPORT or SET_REPORT Definitions.
//
//*****************************************************************************
#define USB_HID_REPORT_IN 0x01
#define USB_HID_REPORT_OUTPUT 0x02
#define USB_HID_REPORT_FEATURE 0x03
//*****************************************************************************
//
// GET_PROTOCOL or SET_PROTOCOL Definitions.
//
//*****************************************************************************
#define USB_HID_PROTOCOL_BOOT 0
#define USB_HID_PROTOCOL_REPORT 1
//*****************************************************************************
//
// Report Values used with the Report macros.
//
//*****************************************************************************
#define USB_HID_GENERIC_DESKTOP 0x01
#define USB_HID_BUTTONS 0x09
#define USB_HID_X 0x30
#define USB_HID_Y 0x31
#define USB_HID_POINTER 0x01
#define USB_HID_MOUSE 0x02
#define USB_HID_KEYBOARD 0x06
#define USB_HID_PHYSICAL 0x00
#define USB_HID_APPLICATION 0x01
#define USB_HID_LOGICAL 0x02
#define USB_HID_USAGE_POINTER 0x0109
#define USB_HID_USAGE_BUTTONS 0x0509
#define USB_HID_USAGE_LEDS 0x0508
#define USB_HID_USAGE_KEYCODES 0x0507
//*****************************************************************************
//
// HID mouse button definitions as used in the first byte of the output report
// used in the BIOS mouse protocol.
//
//*****************************************************************************
#define HID_MOUSE_BUTTON_1 0x01
#define HID_MOUSE_BUTTON_2 0x02
#define HID_MOUSE_BUTTON_3 0x04
//*****************************************************************************
//
// HID Keyboard LED definitions as used in the first byte of the output report
// used in the BIOS keyboard protocol.
//
//*****************************************************************************
#define HID_KEYB_NUM_LOCK 0x01
#define HID_KEYB_CAPS_LOCK 0x02
#define HID_KEYB_SCROLL_LOCK 0x04
#define HID_KEYB_COMPOSE 0x08
#define HID_KEYB_KANA 0x10
//*****************************************************************************
//
// HID Keyboard key modifiers as provided in the first byte of the input report
// used in the BIOS keyboard protocol.
//
//*****************************************************************************
#define HID_KEYB_LEFT_CTRL 0x01
#define HID_KEYB_LEFT_SHIFT 0x02
#define HID_KEYB_LEFT_ALT 0x04
#define HID_KEYB_LEFT_GUI 0x08
#define HID_KEYB_RIGHT_CTRL 0x10
#define HID_KEYB_RIGHT_SHIFT 0x20
#define HID_KEYB_RIGHT_ALT 0x40
#define HID_KEYB_RIGHT_GUI 0x80
//*****************************************************************************
//
// A subset of the HID keyboard usage IDs.
//
//*****************************************************************************
#define HID_KEYB_USAGE_RESERVED 0x00
#define HID_KEYB_USAGE_ROLLOVER 0x01
#define HID_KEYB_USAGE_A 0x04
#define HID_KEYB_USAGE_B 0x05
#define HID_KEYB_USAGE_C 0x06
#define HID_KEYB_USAGE_D 0x07
#define HID_KEYB_USAGE_E 0x08
#define HID_KEYB_USAGE_F 0x09
#define HID_KEYB_USAGE_G 0x0A
#define HID_KEYB_USAGE_H 0x0B
#define HID_KEYB_USAGE_I 0x0C
#define HID_KEYB_USAGE_J 0x0D
#define HID_KEYB_USAGE_K 0x0E
#define HID_KEYB_USAGE_L 0x0F
#define HID_KEYB_USAGE_M 0x10
#define HID_KEYB_USAGE_N 0x11
#define HID_KEYB_USAGE_O 0x12
#define HID_KEYB_USAGE_P 0x13
#define HID_KEYB_USAGE_Q 0x14
#define HID_KEYB_USAGE_R 0x15
#define HID_KEYB_USAGE_S 0x16
#define HID_KEYB_USAGE_T 0x17
#define HID_KEYB_USAGE_U 0x18
#define HID_KEYB_USAGE_V 0x19
#define HID_KEYB_USAGE_W 0x1A
#define HID_KEYB_USAGE_X 0x1B
#define HID_KEYB_USAGE_Y 0x1C
#define HID_KEYB_USAGE_Z 0x1D
#define HID_KEYB_USAGE_1 0x1E
#define HID_KEYB_USAGE_2 0x1F
#define HID_KEYB_USAGE_3 0x20
#define HID_KEYB_USAGE_4 0x21
#define HID_KEYB_USAGE_5 0x22
#define HID_KEYB_USAGE_6 0x23
#define HID_KEYB_USAGE_7 0x24
#define HID_KEYB_USAGE_8 0x25
#define HID_KEYB_USAGE_9 0x26
#define HID_KEYB_USAGE_0 0x27
#define HID_KEYB_USAGE_ENTER 0x28
#define HID_KEYB_USAGE_ESCAPE 0x29
#define HID_KEYB_USAGE_BACKSPACE \
0x2A
#define HID_KEYB_USAGE_TAB 0x2B
#define HID_KEYB_USAGE_SPACE 0x2C
#define HID_KEYB_USAGE_MINUS 0x2D
#define HID_KEYB_USAGE_EQUAL 0x2E
#define HID_KEYB_USAGE_LBRACKET 0x2F
#define HID_KEYB_USAGE_RBRACKET 0x30
#define HID_KEYB_USAGE_BSLASH 0x31
#define HID_KEYB_USAGE_SEMICOLON \
0x33
#define HID_KEYB_USAGE_FQUOTE 0x34
#define HID_KEYB_USAGE_BQUOTE 0x35
#define HID_KEYB_USAGE_COMMA 0x36
#define HID_KEYB_USAGE_PERIOD 0x37
#define HID_KEYB_USAGE_FSLASH 0x38
#define HID_KEYB_USAGE_CAPSLOCK 0x39
#define HID_KEYB_USAGE_F1 0x3A
#define HID_KEYB_USAGE_F2 0x3B
#define HID_KEYB_USAGE_F3 0x3C
#define HID_KEYB_USAGE_F4 0x3D
#define HID_KEYB_USAGE_F5 0x3E
#define HID_KEYB_USAGE_F6 0x3F
#define HID_KEYB_USAGE_F7 0x40
#define HID_KEYB_USAGE_F8 0x41
#define HID_KEYB_USAGE_F9 0x42
#define HID_KEYB_USAGE_F10 0x43
#define HID_KEYB_USAGE_F11 0x44
#define HID_KEYB_USAGE_F12 0x45
#define HID_KEYB_USAGE_SCROLLOCK \
0x47
#define HID_KEYB_USAGE_PAGE_UP 0x4B
#define HID_KEYB_USAGE_PAGE_DOWN \
0x4E
#define HID_KEYB_USAGE_RIGHT_ARROW \
0x4F
#define HID_KEYB_USAGE_LEFT_ARROW \
0x50
#define HID_KEYB_USAGE_DOWN_ARROW \
0x51
#define HID_KEYB_USAGE_UP_ARROW 0x52
#define HID_KEYB_USAGE_NUMLOCK 0x53
#define HID_KEYB_USAGE_KEYPAD_SLASH \
0x54
#define HID_KEYB_USAGE_KEYPAD_STAR \
0x55
#define HID_KEYB_USAGE_KEYPAD_MINUS \
0x56
#define HID_KEYB_USAGE_KEYPAD_PLUS \
0x57
#define HID_KEYB_USAGE_KEPAD_ENTER \
0x58
#define HID_KEYB_USAGE_KEYPAD_1 0x59
#define HID_KEYB_USAGE_KEYPAD_2 0x5A
#define HID_KEYB_USAGE_KEYPAD_3 0x5B
#define HID_KEYB_USAGE_KEYPAD_4 0x5C
#define HID_KEYB_USAGE_KEYPAD_5 0x5D
#define HID_KEYB_USAGE_KEYPAD_6 0x5E
#define HID_KEYB_USAGE_KEYPAD_7 0x5F
#define HID_KEYB_USAGE_KEYPAD_8 0x60
#define HID_KEYB_USAGE_KEYPAD_9 0x61
#define HID_KEYB_USAGE_KEYPAD_0 0x62
#define HID_KEYB_USAGE_KEPAD_PERIOD \
0x63
//*****************************************************************************
//
// HID descriptor country codes (most of these are described as "countries" in
// the HID specification even though they are really languages).
//
//*****************************************************************************
#define USB_HID_COUNTRY_NONE 0x00
#define USB_HID_COUNTRY_ARABIC 0x01
#define USB_HID_COUNTRY_BELGIAN 0x02
#define USB_HID_COUNTRY_CANADA_BI \
0x03
#define USB_HID_COUNTRY_CANADA_FR \
0x04
#define USB_HID_COUNTRY_CZECH_REPUBLIC \
0x05
#define USB_HID_COUNTRY_DANISH 0x06
#define USB_HID_COUNTRY_FINNISH 0x07
#define USB_HID_COUNTRY_FRENCH 0x08
#define USB_HID_COUNTRY_GERMAN 0x09
#define USB_HID_COUNTRY_GREEK 0x0A
#define USB_HID_COUNTRY_HEBREW 0x0B
#define USB_HID_COUNTRY_HUNGARY 0x0C
#define USB_HID_COUNTRY_INTERNATIONAL_ISO \
0x0D
#define USB_HID_COUNTRY_ITALIAN 0x0E
#define USB_HID_COUNTRY_JAPAN_KATAKANA \
0x0F
#define USB_HID_COUNTRY_KOREAN 0x10
#define USB_HID_COUNTRY_LATIN_AMERICAN \
0x11
#define USB_HID_COUNTRY_NETHERLANDS \
0x12
#define USB_HID_COUNTRY_NORWEGIAN \
0x13
#define USB_HID_COUNTRY_PERSIAN 0x14
#define USB_HID_COUNTRY_POLAND 0x15
#define USB_HID_COUNTRY_PORTUGUESE \
0x16
#define USB_HID_COUNTRY_RUSSIA 0x17
#define USB_HID_COUNTRY_SLOVAKIA \
0x18
#define USB_HID_COUNTRY_SPANISH 0x19
#define USB_HID_COUNTRY_SWEDISH 0x1A
#define USB_HID_COUNTRY_SWISS_FRENCH \
0x1B
#define USB_HID_COUNTRY_SWISS_GERMAN \
0x1C
#define USB_HID_COUNTRY_SWITZERLAND \
0x1D
#define USB_HID_COUNTRY_TAIWAN 0x1E
#define USB_HID_COUNTRY_TURKISH_Q \
0x1F
#define USB_HID_COUNTRY_UK 0x20
#define USB_HID_COUNTRY_US 0x21
#define USB_HID_COUNTRY_YUGOSLAVIA \
0x22
#define USB_HID_COUNTRY_TURKISH_F \
0x23
//*****************************************************************************
//
// Data flags used in Input item tags within report descriptors.
//
//*****************************************************************************
#define USB_HID_INPUT_DATA 0x0000
#define USB_HID_INPUT_CONSTANT 0x0001
#define USB_HID_INPUT_ARRAY 0x0000
#define USB_HID_INPUT_VARIABLE 0x0002
#define USB_HID_INPUT_ABS 0x0000
#define USB_HID_INPUT_RELATIVE 0x0004
#define USB_HID_INPUT_NOWRAP 0x0000
#define USB_HID_INPUT_WRAP 0x0008
#define USB_HID_INPUT_LINEAR 0x0000
#define USB_HID_INPUT_NONLINEAR 0x0010
#define USB_HID_INPUT_PREFER 0x0000
#define USB_HID_INPUT_NONPREFER 0x0020
#define USB_HID_INPUT_NONULL 0x0000
#define USB_HID_INPUT_NULL 0x0040
#define USB_HID_INPUT_BITF 0x0100
#define USB_HID_INPUT_BYTES 0x0000
//*****************************************************************************
//
// Data flags used in Feature item tags within report descriptors.
//
//*****************************************************************************
#define USB_HID_FEATURE_DATA 0x0000
#define USB_HID_FEATURE_CONSTANT \
0x0001
#define USB_HID_FEATURE_ARRAY 0x0000
#define USB_HID_FEATURE_VARIABLE \
0x0002
#define USB_HID_FEATURE_ABS 0x0000
#define USB_HID_FEATURE_RELATIVE \
0x0004
#define USB_HID_FEATURE_NOWRAP 0x0000
#define USB_HID_FEATURE_WRAP 0x0008
#define USB_HID_FEATURE_LINEAR 0x0000
#define USB_HID_FEATURE_NONLINEAR \
0x0010
#define USB_HID_FEATURE_PREFER 0x0000
#define USB_HID_FEATURE_NONPREFER \
0x0020
#define USB_HID_FEATURE_NONULL 0x0000
#define USB_HID_FEATURE_NULL 0x0040
#define USB_HID_FEATURE_BITF 0x0100
#define USB_HID_FEATURE_BYTES 0x0000
//*****************************************************************************
//
// Data flags used in Output item tags within report descriptors.
//
//*****************************************************************************
#define USB_HID_OUTPUT_DATA 0x0000
#define USB_HID_OUTPUT_CONSTANT 0x0001
#define USB_HID_OUTPUT_ARRAY 0x0000
#define USB_HID_OUTPUT_VARIABLE 0x0002
#define USB_HID_OUTPUT_ABS 0x0000
#define USB_HID_OUTPUT_RELATIVE 0x0004
#define USB_HID_OUTPUT_NOWRAP 0x0000
#define USB_HID_OUTPUT_WRAP 0x0008
#define USB_HID_OUTPUT_LINEAR 0x0000
#define USB_HID_OUTPUT_NONLINEAR \
0x0010
#define USB_HID_OUTPUT_PREFER 0x0000
#define USB_HID_OUTPUT_NONPREFER \
0x0020
#define USB_HID_OUTPUT_NONULL 0x0000
#define USB_HID_OUTPUT_NULL 0x0040
#define USB_HID_OUTPUT_BITF 0x0100
#define USB_HID_OUTPUT_BYTES 0x0000
//*****************************************************************************
//
// Physical descriptor bias values.
//
//*****************************************************************************
#define USB_HID_BIAS_NOT_APPLICABLE \
0x00
#define USB_HID_BIAS_RIGHT_HAND 0x01
#define USB_HID_BIAS_LEFT_HAND 0x02
#define USB_HID_BIAS_BOTH_HANDS 0x03
#define USB_HID_BIAS_EITHER_HAND \
0x04
//*****************************************************************************
//
// Physical descriptor designator values.
//
//*****************************************************************************
#define USB_HID_DESIGNATOR_NONE 0x00
#define USB_HID_DESIGNATOR_HAND 0x01
#define USB_HID_DESIGNATOR_EYEBALL \
0x02
#define USB_HID_DESIGNATOR_EYEBROW \
0x03
#define USB_HID_DESIGNATOR_EYELID \
0x04
#define USB_HID_DESIGNATOR_EAR 0x05
#define USB_HID_DESIGNATOR_NOSE 0x06
#define USB_HID_DESIGNATOR_MOUTH \
0x07
#define USB_HID_DESIGNATOR_UPPER_LIP \
0x08
#define USB_HID_DESIGNATOR_LOWER_LIP \
0x09
#define USB_HID_DESIGNATOR_JAW 0x0A
#define USB_HID_DESIGNATOR_NECK 0x0B
#define USB_HID_DESIGNATOR_UPPER_ARM \
0x0C
#define USB_HID_DESIGNATOR_ELBOW \
0x0D
#define USB_HID_DESIGNATOR_FOREARM \
0x0E
#define USB_HID_DESIGNATOR_WRIST \
0x0F
#define USB_HID_DESIGNATOR_PALM 0x10
#define USB_HID_DESIGNATOR_THUMB \
0x11
#define USB_HID_DESIGNATOR_INDEX_FINGER \
0x12
#define USB_HID_DESIGNATOR_MIDDLE_FINGER \
0x13
#define USB_HID_DESIGNATOR_RING_FINGER \
0x14
#define USB_HID_DESIGNATOR_LITTLE_FINGER \
0x15
#define USB_HID_DESIGNATOR_HEAD 0x16
#define USB_HID_DESIGNATOR_SHOULDER \
0x17
#define USB_HID_DESIGNATOR_HIP 0x18
#define USB_HID_DESIGNATOR_WAIST \
0x19
#define USB_HID_DESIGNATOR_THIGH \
0x1A
#define USB_HID_DESIGNATOR_KNEE 0x1B
#define USB_HID_DESIGNATOR_CALF 0x1C
#define USB_HID_DESIGNATOR_ANKLE \
0x1D
#define USB_HID_DESIGNATOR_FOOT 0x1E
#define USB_HID_DESIGNATOR_HEEL 0x1F
#define USB_HID_DESIGNATOR_BALL_OF_FOOT \
0x20
#define USB_HID_DESIGNATOR_BIG_TOE \
0x21
#define USB_HID_DESIGNATOR_SECOND_TOE \
0x22
#define USB_HID_DESIGNATOR_THIRD_TOE \
0x23
#define USB_HID_DESIGNATOR_FOURTH_TOE \
0x24
#define USB_HID_DESIGNATOR_LITTLE_TOE \
0x25
#define USB_HID_DESIGNATOR_BROW 0x26
#define USB_HID_DESIGNATOR_CHEEK \
0x27
//*****************************************************************************
//
// Physical descriptor qualifier values.
//
//*****************************************************************************
#define USB_HID_QUALIFIER_NOT_APPLICABLE \
(0x00 << 5)
#define USB_HID_QUALIFIER_RIGHT (0x01 << 5)
#define USB_HID_QUALIFIER_LEFT (0x02 << 5)
#define USB_HID_QUALIFIER_BOTH (0x03 << 5)
#define USB_HID_QUALIFIER_EITHER \
(0x04 << 5)
#define USB_HID_QUALIFIER_CENTER \
(0x05 << 5)
//*****************************************************************************
//
// This is the maximum value for a usage code.
//
//*****************************************************************************
#define USBH_HID_MAX_USAGE 256
#define USBH_HID_CAPS_ARRAY_SZ (USBH_HID_MAX_USAGE/sizeof(uint32_t))
//*****************************************************************************
//
// All structures defined in this section of the header require byte packing of
// fields. This is usually accomplished using the PACKED macro but, for IAR
// Embedded Workbench, this requires a pragma.
//
//*****************************************************************************
#ifdef __ICCARM__
#pragma pack(1)
#endif
//*****************************************************************************
//
//! The class descriptor information structure is used to announce the presence
//! of HID-specific class descriptors within the HID descriptor.
//
//*****************************************************************************
typedef struct
{
//
//! The type of HID class descriptor. This will be \b USB_HID_DTYPE_REPORT
//! or \b USB_HID_DTYPE_PHYSICAL.
//
uint8_t bDescriptorType;
//
//! The total length of the HID class descriptor.
//
#ifdef __TMS320C28XX__
usb16_t wDescriptorLength;
#else
uint16_t wDescriptorLength;
#endif
}
PACKED tHIDClassDescriptorInfo;
//*****************************************************************************
//
//! The HID descriptor is inserted following the interface descriptor and
//! before the endpoint descriptors for a HID class device.
//
//*****************************************************************************
typedef struct
{
//
//! The length of this descriptor in bytes.
//
uint8_t bLength;
//
//! The type of the descriptor. For a HID descriptor, this will be
//! \b USB_HID_DTYPE_HID.
//
uint8_t bDescriptorType;
//
//! A BCD value identifying the HID Class specification release supported
//! by the device. For version 1.11, for example, this value would be
//! 0x0111.
//
#ifdef __TMS320C28XX__
usb16_t bcdHID;
#else
uint16_t bcdHID;
#endif
//
//! The country code for which this hardware is localized or 0 if no
//! localization has been performed. Valid country (or language) codes are
//! in labels of the form \b USB_HID_COUNTRY_xxx.
uint8_t bCountryCode;
//
//! The number of class-specific descriptors that exist for this device.
//! This indicates the number of class descriptor information structures
//! that are appended to this structure and must be at least 1 (since all
//! HID devices must publish at least 1 report descriptor).
//
uint8_t bNumDescriptors;
//
//! A table announcing each of the class-specific descriptors that this
//! device publishes. The actual number of entries in the array is given
//! by the bNumDescriptors field.
//
tHIDClassDescriptorInfo sClassDescriptor[1];
}
PACKED tHIDDescriptor;
//*****************************************************************************
//
// Return to default packing when using the IAR Embedded Workbench compiler.
//
//*****************************************************************************
#ifdef __ICCARM__
#pragma pack()
#endif
//*****************************************************************************
//
//! This structure defines the mapping of USB usage identifiers to printable
//! characters. The structure has three members that hold this information.
//! The ui8BytesPerChar, indicates the number of bytes per character in
//! the table. The pui32CapsLock array holds a packed bit array of usage
//! identifiers that can be modified by the Caps Lock key. The pCharMapping
//! array is treated as a double indexed array with two "columns". In the case
//! of a single byte character it is treated as pairs of 8 bit values for
//! unshifted and shifted values. In the case of a double byte characters it
//! is treated as pairs of 16 bit values.
//
//*****************************************************************************
typedef struct
{
//
//! Number of bytes per character in the pCharMapping table of this
//! structure.
//
uint8_t ui8BytesPerChar;
//
//! This is a packed bitmasked structure with a one bit flags that
//! indicates if the corresponding Usage ID is affected by the Caps Lock
//! key.
//
uint32_t pui32CapsLock[USBH_HID_CAPS_ARRAY_SZ];
//
//! This is the indexed table of Usage ID to character value. It must be
//! at least ui8BytesPerChar * 2 * \b USBH_HID_MAX_USAGE bytes in size as
//! it is treated as a double indexed array.
//
void *pvCharMapping;
}
tHIDKeyboardUsageTable;
//*****************************************************************************
//
// The US Keyboard mapping used by USB keyboard usage ID to character mapping.
//
//*****************************************************************************
extern const tHIDKeyboardUsageTable g_sUSKeyboardMap;
//*****************************************************************************
//
// Close the Doxygen group.
//! @}
//
//*****************************************************************************
//*****************************************************************************
//
// Mark the end of the C bindings section for C++ compilers.
//
//*****************************************************************************
#ifdef __cplusplus
}
#endif
#endif // __USBHID_H__
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,553 @@
//#############################################################################
// FILE: usblibpriv.h
// TITLE: Private header file used to share internal variables and
// library. This header MUST NOT be used by application code.
//#############################################################################
//!
//! Copyright: Copyright (C) 2023 Texas Instruments Incorporated -
//! All rights reserved not granted herein.
//! Limited License.
//!
//! Texas Instruments Incorporated grants a world-wide, royalty-free,
//! non-exclusive license under copyrights and patents it now or hereafter
//! owns or controls to make, have made, use, import, offer to sell and sell
//! ("Utilize") this software subject to the terms herein. With respect to the
//! foregoing patent license, such license is granted solely to the extent that
//! any such patent is necessary to Utilize the software alone. The patent
//! license shall not apply to any combinations which include this software,
//! other than combinations with devices manufactured by or for TI
//! ("TI Devices").
//! No hardware patent is licensed hereunder.
//!
//! Redistributions must preserve existing copyright notices and reproduce this
//! license (including the above copyright notice and the disclaimer and
//! (if applicable) source code license limitations below) in the documentation
//! and/or other materials provided with the distribution.
//!
//! Redistribution and use in binary form, without modification, are permitted
//! provided that the following conditions are met:
//!
//! * No reverse engineering, decompilation, or disassembly of this software is
//! permitted with respect to any software provided in binary form.
//! * Any redistribution and use are licensed by TI for use only
//! with TI Devices.
//! * Nothing shall obligate TI to provide you with source code for the
//! software licensed and provided to you in object code.
//!
//! If software source code is provided to you, modification and redistribution
//! of the source code are permitted provided that the following conditions
//! are met:
//!
//! * any redistribution and use of the source code, including any resulting
//! derivative works, are licensed by TI for use only with TI Devices.
//! * any redistribution and use of any object code compiled from the source
//! code and any resulting derivative works, are licensed by TI for use
//! only with TI Devices.
//!
//! Neither the name of Texas Instruments Incorporated nor the names of its
//! suppliers may be used to endorse or promote products derived from this
//! software without specific prior written permission.
//#############################################################################
#ifndef __USBLIBPRIV_H__
#define __USBLIBPRIV_H__
//*****************************************************************************
//
// If building with a C++ compiler, make all of the definitions in this header
// have a C binding.
//
//*****************************************************************************
#ifdef __cplusplus
extern "C"
{
#endif
//*****************************************************************************
//
//! \addtogroup usblib_dma_api
//! @{
//
//*****************************************************************************
//*****************************************************************************
//
// Internal interrupt handlers called from the main vectors in device and
// host mode.
//
//*****************************************************************************
extern void USBDeviceIntHandlerInternal(uint32_t ui32Index,
uint32_t ui32Status,
uint32_t ui32IntStatusEP);
extern void USBHostIntHandlerInternal(uint32_t ui32Index,
uint32_t ui32Status,
uint32_t ui32IntStatusEP);
//*****************************************************************************
//
// The maximum number of tick handlers that can be registered in a system.
//
//*****************************************************************************
#define MAX_USB_TICK_HANDLERS 6
//*****************************************************************************
//
// This value defines the number of SOF ticks that must pass before a call
// is made to InternalUSBStartOfFrameTick. The value 5 ensures that the
// function is called every 5 milliseconds assuming that SOF interrupts are
// enabled and SOF is present.
//
//*****************************************************************************
#define USB_SOF_TICK_DIVIDE 5
//*****************************************************************************
//
// Tick handler function pointer type.
//
//*****************************************************************************
typedef void(* tUSBTickHandler)(void *pvInstance, uint32_t ui32TicksmS);
//*****************************************************************************
//
// Internal functions use to initialize the tick handler and register tick
// callbacks.
//
//*****************************************************************************
extern void InternalUSBTickInit(void);
extern void InternalUSBTickReset(void);
extern int32_t InternalUSBRegisterTickHandler(tUSBTickHandler pfnHandler,
void *pvInstance);
extern void InternalUSBStartOfFrameTick(uint32_t ui32TicksmS);
extern void InternalUSBHCDSendEvent(uint32_t ui32Index, tEventInfo *psEvent,
uint32_t ui32EvFlag);
//*****************************************************************************
//
// g_ui32CurrentUSBTick holds the elapsed time in milliseconds since the
// tick module was first initialized based on calls to the function
// InternalUSBStartOfFrameTick. The granularity is USB_SOF_TICK_DIVIDE
// milliseconds.
//
//*****************************************************************************
extern uint32_t g_ui32CurrentUSBTick;
//*****************************************************************************
//
// g_ui32USBSOFCount is a global counter for Start of Frame interrupts. It is
// incremented by the low level device- or host-mode interrupt handlers.
//
//*****************************************************************************
extern uint32_t g_ui32USBSOFCount;
//*****************************************************************************
//
// InternalUSBGetTime is a macro which will return the system time in
// milliseconds as calculated based on calls to the function
// InternalUSBStartOfFrameTick. The granularity is USB_SOF_TICK_DIVIDE
// milliseconds.
//
// Currently, this merely returns the value of a global variable.
//
//*****************************************************************************
#define InternalUSBGetTime() g_ui32CurrentUSBTick
//*****************************************************************************
//
// Macros to convert between USB controller base address and an index. These
// are currently trivial but are included to allow for the possibility of
// supporting more than one controller in the future.
//
//*****************************************************************************
#define USBBaseToIndex(BaseAddr)(0)
#define USBIndexToBase(Index) (USB_BASE)
//
// Maximum number of channels for Type 0 USB controllers.
//
#define USB_MAX_DMA_CHANNELS_0 6
//
// Maximum number of channels for all other USB controllers.
//
#define USB_MAX_DMA_CHANNELS 8
//*****************************************************************************
//
// Values returned by the USBLibDMAChannelStatus() function.
//
//*****************************************************************************
#define USBLIBSTATUS_DMA_IDLE 0x00000000
#define USBLIBSTATUS_DMA_COMPLETE \
0x00000001
#define USBLIBSTATUS_DMA_ERROR 0x00000002
#define USBLIBSTATUS_DMA_PENDING \
0x00000004
//*****************************************************************************
//
// DMA endpoint types used with the USBLibDMAChannelAllocate() function.
//
//*****************************************************************************
#define USB_DMA_EP_RX 0x00000080
#define USB_DMA_EP_TX 0x00000000
#define USB_DMA_EP_HOST 0x00000040
#define USB_DMA_EP_DEVICE 0x00000000
#define USB_DMA_EP_TYPE_CTRL 0x00000000
#define USB_DMA_EP_TYPE_ISOC 0x00000001
#define USB_DMA_EP_TYPE_BULK 0x00000002
#define USB_DMA_EP_TYPE_INT 0x00000003
#define USB_DMA_EP_TYPE_M 0x00000003
//*****************************************************************************
//
// This is the internal instance data for the DMA functions and should not
// be modified outside the usbdma.c file.
//
//*****************************************************************************
struct tUSBDMAInstance
{
uint32_t ui32Base;
uint32_t ui32IntNum;
uint32_t pui32Config[USB_MAX_DMA_CHANNELS];
uint32_t pui32MaxPacketSize[USB_MAX_DMA_CHANNELS];
uint32_t *ppui32Data[USB_MAX_DMA_CHANNELS];
uint32_t pui32Count[USB_MAX_DMA_CHANNELS];
uint8_t pui8Endpoint[USB_MAX_DMA_CHANNELS];
uint32_t pui32EPDMAMode0[USB_MAX_DMA_CHANNELS];
uint32_t pui32EPDMAMode1[USB_MAX_DMA_CHANNELS];
uint32_t ui32Pending;
uint32_t ui32Complete;
void (* pfnArbSizeSet)(tUSBDMAInstance *psUSBDMAInst, uint32_t ui32Channel,
uint32_t ui32ArbSize);
uint32_t (* pfnChannelAllocate)(tUSBDMAInstance *psUSBDMAInst,
uint8_t ui8Endpoint,
uint32_t ui32MaxPacketSize,
uint32_t ui32Config);
void (* pfnChannelEnable)(tUSBDMAInstance *psUSBDMAInst,
uint32_t ui32Channel);
void (* pfnChannelDisable)(tUSBDMAInstance *psUSBDMAInst,
uint32_t ui32Channel);
void (* pfnChannelRelease)(tUSBDMAInstance *psUSBDMAInst,
uint8_t ui8Endpoint);
uint32_t (* pfnChannelStatus)(tUSBDMAInstance *psUSBDMAInst,
uint32_t ui32Channel);
void (* pfnChannelIntDisable)(tUSBDMAInstance *psUSBDMAInst,
uint32_t ui32Channel);
void (* pfnChannelIntEnable)(tUSBDMAInstance *psUSBDMAInst,
uint32_t ui32Channel);
void (* pfnIntHandler)(tUSBDMAInstance *psUSBDMAInst,
uint32_t ui32Status);
uint32_t (* pfnIntStatus)(tUSBDMAInstance *psUSBDMAInst);
void (* pfnIntStatusClear)(tUSBDMAInstance *psUSBDMAInst,
uint32_t ui32Status);
uint32_t (* pfnStatus)(tUSBDMAInstance *psUSBDMAInst);
uint32_t (* pfnTransfer)(tUSBDMAInstance *psUSBDMAInst,
uint32_t ui32Channel, void *pvBuffer,
uint32_t ui32Size);
void (* pfnUnitSizeSet)(tUSBDMAInstance *psUSBDMAInst,
uint32_t ui32Channel,
uint32_t ui32BitSize);
};
//*****************************************************************************
//
// These are the USB libraries DMA functions.
//
//*****************************************************************************
extern tUSBDMAInstance * USBLibDMAInit(uint32_t ui32Index);
//*****************************************************************************
//
//! This function returns the current DMA status for a given DMA channel.
//!
//! \param psUSBDMAInst is the DMA structure pointer for this instance.
//! \param ui32Channel is the DMA channel number used to retrieve the DMA
//! status.
//!
//! This function returns the current status of a DMA transfer on a given
//! DMA channel. The DMA channel is specified by the \e ui32Channel parameter.
//!
//! \return This function returns one of the \b USBLIBSTATUS_DMA_* values.
//
//*****************************************************************************
#define USBLibDMAChannelStatus(psUSBDMAInst, ui32Channel) \
psUSBDMAInst->pfnChannelStatus(psUSBDMAInst, ui32Channel)
//*****************************************************************************
//
//! This function is used to return any global status information for USB DMA.
//!
//! \param psUSBDMAInst is a generic instance pointer that can be used to
//! distinguish between different hardware instances.
//!
//! This function performs returns the global status for the USB DMA
//! interface.
//!
//! \return Always returns 0.
//
//*****************************************************************************
#define USBLibDMAStatus(psUSBDMAInst) psUSBDMAInst->pfnStatus(psUSBDMAInst)
//*****************************************************************************
//
//! This function returns the current DMA interrupt status.
//!
//! \param psUSBDMAInst is the DMA structure pointer for this instance.
//!
//! This function returns the interrupt status for all DMA channels. The value
//! returned is a per channel interrupt mapping with the DMA channels mapped
//! into bits 0-31 by channel number with channel 1 starting at bit 0.
//!
//! \note This function does not return an endpoint interrupt status, but the
//! interrupt status for the DMA interface used with the USB controller.
//!
//! \return This function returns the pending DMA interrupts.
//
//*****************************************************************************
#define USBLibDMAIntStatus(psUSBDMAInst) \
psUSBDMAInst->pfnIntStatus(psUSBDMAInst)
//*****************************************************************************
//
//! This function clears the requested DMA interrupt status.
//!
//! \param psUSBDMAInst is the DMA structure pointer for this instance.
//! \param ui32Status contains the interrupts to clear.
//!
//! This function clears the current DMA interrupt status for the
//! controller specified by the \e ui32Instance parameter. The \e ui32Status
//! value has the same format as the value returned from the
//! USBLibDMAIntStatus() function which is a per channel interrupt mapping.
//! The DMA channels are mapped into bits 0-31 by channel number with channel 1
//!starting at bit 0.
//!
//! \return None.
//
//*****************************************************************************
#define USBLibDMAIntStatusClear(psUSBDMAInst, ui32Status) \
psUSBDMAInst->pfnIntStatusClear(psUSBDMAInst, ui32Status)
//*****************************************************************************
//
//! This function enables DMA for a given channel.
//!
//! \param psUSBDMAInst is the DMA structure pointer for this instance.
//! \param ui32Channel is the DMA channel to enable.
//!
//! This function enables DMA on the channel number passed in the
//! \e ui32Channel parameter.
//!
//! \return None.
//
//*****************************************************************************
#define USBLibDMAChannelEnable(psUSBDMAInst, ui32Channel) \
psUSBDMAInst->pfnChannelEnable(psUSBDMAInst, ui32Channel)
//*****************************************************************************
//
//! This function disables DMA for a given DMA channel.
//!
//! \param psUSBDMAInst is the DMA structure pointer for this instance.
//! \param ui32Channel is the DMA channel to disable.
//!
//! This function disables DMA on the channel number passed in the
//!\e ui32Channel parameter.
//!
//! \return None.
//
//*****************************************************************************
#define USBLibDMAChannelDisable(psUSBDMAInst, ui32Channel) \
psUSBDMAInst->pfnChannelDisable(psUSBDMAInst, ui32Channel)
//*****************************************************************************
//
//! This function is configures a USB transfer on a given DMA channel.
//!
//! \param psUSBDMAInst is the DMA structure pointer for this instance.
//! \param ui32Channel is the DMA channel to use.
//! \param pvBuffer is a pointer to the buffer to use for the transfer.
//! \param ui32Size is the size of the data to be transferred in bytes.
//!
//! This function is called to configure a transfer using the USB
//! controller depending on the parameters. The \e ui32Channel parameter
//! holds the channel number to use for this transfer which must have already
//! been allocated with a call to the USBLibDMAChannelAllocate() function. The
//! transaction is configured to transfer \e ui32Size bytes to/from the buffer
//! held in the \e pvBuffer pointer.
//!
//! \return This function returns the number of bytes scheduled to be
//! transferred.
//
//*****************************************************************************
#define USBLibDMATransfer(psUSBDMAInst, ui32Channel, pvBuffer, ui32Size) \
psUSBDMAInst->pfnTransfer(psUSBDMAInst, ui32Channel, \
pvBuffer, ui32Size)
//*****************************************************************************
//
//! This function is called by the USB interrupt handler.
//!
//! \param psUSBDMAInst is the DMA structure pointer for this instance.
//! \param ui32Status is the DMA interrupt status.
//!
//! This function is called by the USB interrupt handler to allow the DMA
//! interface to handle interrupts outside of the context of the normal USB
//! interrupt handler. The \e ui32Status is the current DMA interrupt status
//! at the time of the USB interrupt. Since some DMA controller interrupts are
//! cleared automatically when read, this value must be retrieved by calling
//! the USBLibDMAIntStatus() function and passed into this function.
//!
//! \return None.
//
//*****************************************************************************
#define USBLibDMAIntHandler(psUSBDMAInst, ui32Status) \
psUSBDMAInst->pfnIntHandler(psUSBDMAInst, ui32Status)
//*****************************************************************************
//
//! This function is used to assign a DMA channel to an endpoint.
//!
//! \param psUSBDMAInst is the DMA instance data for a USB controller.
//! \param ui8Endpoint is the endpoint number to assign a DMA channel.
//! \param ui32MaxPacketSize is the maximum packet size for the endpoint
//! assigned that is being assigned to the DMA channel.
//! \param ui32Config are the basic configuration options for the DMA channel.
//!
//! This function assigns a DMA channel to a given endpoint. The
//! \e ui8Endpoint parameter is the zero based endpoint number that is assigned
//! a DMA channel. The \e ui32Config parameter contains any configuration
//! options for the DMA channel. The current options include the following:
//! - \b USB_DMA_EP_TX - this request is for a transmit DMA channel.
//! - \b USB_DMA_EP_RX - this request is for a receive DMA channel.
//!
//! \note The maximum number of available DMA channels to endpoints varies
//! between devices.
//!
//! \return Zero or the DMA channel assigned to the endpoint.
//
//*****************************************************************************
#define USBLibDMAChannelAllocate(psUSBDMAInst, ui8Endpoint, ui32MaxPacketSize,\
ui32Config) \
psUSBDMAInst->pfnChannelAllocate(psUSBDMAInst, \
ui8Endpoint, \
ui32MaxPacketSize, \
ui32Config)
//*****************************************************************************
//
//! This function is used to free a DMA channel that was assigned to an
//! endpoint.
//!
//! \param psUSBDMAInst is the DMA instance data for a USB controller.
//! \param ui8Endpoint is the DMA channel number to free up.
//!
//! This function frees up a DMA channel that was allocated to an endpoint
//! by the USBLibDMAChannelAllocate() function.
//!
//! \return None.
//
//*****************************************************************************
#define USBLibDMAChannelRelease(psUSBDMAInst, ui8Endpoint) \
psUSBDMAInst->pfnChannelRelease(psUSBDMAInst, ui8Endpoint)
//*****************************************************************************
//
//! This function is used to set the individual transfer size of a DMA channel.
//!
//! \param psUSBDMAInst is the DMA instance data for a USB controller.
//! \param ui32Channel is the DMA channel number to modify.
//! \param ui32BitSize is the individual transfer size in bits(8, 16 or 32).
//!
//! This function configures the individual transfer size of the DMA channel
//! provided in the \e ui32Channel parameter. The \e ui32Channel must already
//! be allocated to an endpoint by calling the USBLibDMAChannelAllocate()
//! function. The \e ui32BitSize parameter should be on of the following
//! values: 8, 16 or 32.
//!
//! \return None.
//
//*****************************************************************************
#define USBLibDMAUnitSizeSet(psUSBDMAInst, ui32Channel, ui32BitSize) \
psUSBDMAInst->pfnUnitSizeSet(psUSBDMAInst, ui32Channel, \
ui32BitSize);
//*****************************************************************************
//
//! This function is used to set the arbitration size for a DMA channel.
//!
//! \param psUSBDMAInst is the DMA instance data for a USB controller.
//! \param ui32Channel is the DMA channel number to modify.
//! \param ui32ArbSize is the transfer arbitration size in bytes.
//!
//! This function configures the individual transfer size of the DMA channel
//! provided in the \e ui32Channel parameter. The \e ui32Channel must already
//! be allocated to an endpoint by calling the USBLibDMAChannelAllocate()
//! function.
//!
//! \return None.
//
//*****************************************************************************
#define USBLibDMAArbSizeSet(psUSBDMAInst, ui32Channel, ui32ArbSize) \
psUSBDMAInst->pfnArbSizeSet(psUSBDMAInst, ui32Channel, \
ui32ArbSize);
//*****************************************************************************
//
//! This function enables the DMA interrupt for a given channel.
//!
//! \param psUSBDMAInst is the DMA structure pointer for this instance.
//! \param ui32Channel is the DMA channel interrupt to enable.
//!
//! This function enables DMA interrupt on the channel number passed in the
//! \e ui32Channel parameter.
//!
//! \return None.
//
//*****************************************************************************
#define USBLibDMAChannelIntEnable(psUSBDMAInst, ui32Channel) \
psUSBDMAInst->pfnChannelIntEnable(psUSBDMAInst, ui32Channel)
//*****************************************************************************
//
//! This function disables DMA interrupt for a given DMA channel.
//!
//! \param psUSBDMAInst is the DMA structure pointer for this instance.
//! \param ui32Channel is the DMA channel interrupt to disable.
//!
//! This function disables the DMA interrupt on the channel number passed in
//! the \e ui32Channel parameter.
//!
//! \return None.
//
//*****************************************************************************
#define USBLibDMAChannelIntDisable(psUSBDMAInst, ui32Channel) \
psUSBDMAInst->pfnChannelIntDisable(psUSBDMAInst, ui32Channel)
//*****************************************************************************
//
// Mark the end of the C bindings section for C++ compilers.
//
//*****************************************************************************
#ifdef __cplusplus
}
#endif
//*****************************************************************************
//
// Close the Doxygen group.
//! @}
//
//*****************************************************************************
#endif // __USBLIBPRIV_H__
@@ -0,0 +1,443 @@
//#############################################################################
// FILE: usbmsc.h
// TITLE: Generic types and defines use by the mass storage class
//#############################################################################
//!
//! Copyright: Copyright (C) 2023 Texas Instruments Incorporated -
//! All rights reserved not granted herein.
//! Limited License.
//!
//! Texas Instruments Incorporated grants a world-wide, royalty-free,
//! non-exclusive license under copyrights and patents it now or hereafter
//! owns or controls to make, have made, use, import, offer to sell and sell
//! ("Utilize") this software subject to the terms herein. With respect to the
//! foregoing patent license, such license is granted solely to the extent that
//! any such patent is necessary to Utilize the software alone. The patent
//! license shall not apply to any combinations which include this software,
//! other than combinations with devices manufactured by or for TI
//! ("TI Devices").
//! No hardware patent is licensed hereunder.
//!
//! Redistributions must preserve existing copyright notices and reproduce this
//! license (including the above copyright notice and the disclaimer and
//! (if applicable) source code license limitations below) in the documentation
//! and/or other materials provided with the distribution.
//!
//! Redistribution and use in binary form, without modification, are permitted
//! provided that the following conditions are met:
//!
//! * No reverse engineering, decompilation, or disassembly of this software is
//! permitted with respect to any software provided in binary form.
//! * Any redistribution and use are licensed by TI for use only
//! with TI Devices.
//! * Nothing shall obligate TI to provide you with source code for the
//! software licensed and provided to you in object code.
//!
//! If software source code is provided to you, modification and redistribution
//! of the source code are permitted provided that the following conditions
//! are met:
//!
//! * any redistribution and use of the source code, including any resulting
//! derivative works, are licensed by TI for use only with TI Devices.
//! * any redistribution and use of any object code compiled from the source
//! code and any resulting derivative works, are licensed by TI for use
//! only with TI Devices.
//!
//! Neither the name of Texas Instruments Incorporated nor the names of its
//! suppliers may be used to endorse or promote products derived from this
//! software without specific prior written permission.
//#############################################################################
#ifndef __USBMSC_H__
#define __USBMSC_H__
//*****************************************************************************
//
// If building with a C++ compiler, make all of the definitions in this header
// have a C binding.
//
//*****************************************************************************
#ifdef __cplusplus
extern "C"
{
#endif
//*****************************************************************************
//
// The request for the maximum number of logical units on a mass storage
// device.
//
//*****************************************************************************
#define USBREQ_GET_MAX_LUN 0xfe
//*****************************************************************************
//
// The signatures defined by USB MSC class specification.
//
//*****************************************************************************
#define CBW_SIGNATURE 0x43425355
#define CSW_SIGNATURE 0x53425355
//*****************************************************************************
//
// Flag for the bmCBWFlags member of tMSCCBW
//
//*****************************************************************************
#define CBWFLAGS_DIR_M 0x80
#define CBWFLAGS_DIR_IN 0x80
#define CBWFLAGS_DIR_OUT 0x00
//*****************************************************************************
//
// All structures defined in this section of the header require byte packing of
// fields. This is usually accomplished using the PACKED macro but, for IAR
// Embedded Workbench, this requries a pragma.
//
//*****************************************************************************
#ifdef __ICCARM__
#pragma pack(1)
#endif
//*****************************************************************************
//
// The following packed structure is used to access the Command Block Wrapper
// (CBW) data structure that is used when communicating with USB Mass Storage
// Class devices.
//
//*****************************************************************************
typedef struct
{
//
// Signature that helps identify this data packet as a CBW. The signature
// field shall contain the value 0x43425355 (little endian), indicating a
// CBW.
//
#ifdef __TMS320C28XX__
usb32_t dCBWSignature;
#else
uint32_t dCBWSignature;
#endif
//
// The Command Block Tag sent by the host controller. The device shall
// echo the contents of this field back to the host in the dCSWTag field
// of the associated CSW. The dCSWTag positively associates a CSW with the
// corresponding CBW.
//
#ifdef __TMS320C28XX__
usb32_t dCBWTag;
#else
uint32_t dCBWTag;
#endif
//
// The number of bytes of data that the host expects to transfer on the
// Bulk-In or Bulk-Out endpoint (as indicated by the Direction bit) during
// the execution of this command. If this field is zero, the device and
// the host will not transfer data between the CBW and the associated CSW,
// and the device will ignore the value of the Direction bit in
// bmCBWFlags.
//
#ifdef __TMS320C28XX__
usb32_t dCBWDataTransferLength;
#else
uint32_t dCBWDataTransferLength;
#endif
//
// The device will ignore these bits if the dCBWDataTransferLength value
// is set to 0.
//
// The bits of this field are defined as follows:
// Bit 7 Direction
// 0 = Data-Out from host to the device,
// 1 = Data-In from the device to the host.
// Bit 6 Obsolete - The host shall set this bit to zero.
// Bits 5..0 Reserved - the host shall set these bits to zero.
//
uint8_t bmCBWFlags;
//
// The device Logical Unit Number (LUN) to which the command block is being
// sent. For devices that support multiple LUNs, the host shall place into
// this field the LUN to which this command block is addressed. Otherwise,
// the host shall set this field to zero.
//
uint8_t bCBWLUN;
//
// The valid length of the CBWCB in bytes. This defines the valid length
// of the command block. The only legal values are 1 through 16. All
// other values are reserved.
//
uint8_t bCBWCBLength;
//
// This array holds the command block to be executed by the device. The
// MSC device will interpret the first bCBWCBLength bytes in this field as
// a command block as defined by the command set identified by
// bInterfaceSubClass. If the command set supported by the device uses
// command blocks of fewer than 16 bytes in length, the significant bytes
// shall be transferred first, beginning with the byte at offset 15. The
// device will ignore the content of the CBWCB field past the byte at
// offset (15 + bCBWCBLength - 1).
//
uint8_t CBWCB[16];
}
PACKED tMSCCBW;
//*****************************************************************************
//
// Flags for the bCSWStatus member of tMSCCSW
//
//*****************************************************************************
#define CSWSTATUS_CMD_SUCCESS 0
#define CSWSTATUS_CMD_FAILED 1
#define CSWSTATUS_PHASE_ERROR 2
//*****************************************************************************
//
// This structure encapsulates the Command Status Word (CSW) structure that is
// sent in response to all CBW commands.
//
//*****************************************************************************
typedef struct
{
//
// Signature that identifies this data packet as a CSW. The signature
// field must contain the value 53425355h (little endian) to indicate CSW.
//
#ifdef __TMS320C28XX__
usb32_t dCSWSignature;
#else
uint32_t dCSWSignature;
#endif
//
// The device will set this field to the value received in the dCBWTag of
// the associated CBW.
//
#ifdef __TMS320C28XX__
usb32_t dCSWTag;
#else
uint32_t dCSWTag;
#endif
//
// For OUT transactions the device will fill the dCSWDataResidue field with
// the difference between the amount of data expected as stated in the
// dCBWDataTransferLength, and the actual amount of data processed by the
// device. For IN transactions the device will fill the dCSWDataResidue
// field with the difference between the amount of data expected as stated
// in the dCBWDataTransferLength and the actual amount of relevant data
// sent by the device. The dCSWDataResidue will not exceed the value sent
// in the dCBWDataTransferLength.
//
#ifdef __TMS320C28XX__
usb32_t dCSWDataResidue;
#else
uint32_t dCSWDataResidue;
#endif
//
// The bCSWStatus field indicates the success or failure of the command.
// The device shall set this byte to zero if the command completed
// successfully. A non-zero value shall indicate a failure during command
// execution.
//
uint8_t bCSWStatus;
}
PACKED tMSCCSW;
//*****************************************************************************
//
// Return to default packing when using the IAR Embedded Workbench compiler.
//
//*****************************************************************************
#ifdef __ICCARM__
#pragma pack()
#endif
//*****************************************************************************
//
// SCSI Command return codes.
//
//*****************************************************************************
#define SCSI_CMD_STATUS_PASS 0x00
#define SCSI_CMD_STATUS_FAIL 0x01
//*****************************************************************************
//
// SCSI commands.
//
//*****************************************************************************
#define SCSI_TEST_UNIT_READY 0x00
#define SCSI_REQUEST_SENSE 0x03
#define SCSI_INQUIRY_CMD 0x12
#define SCSI_MODE_SENSE_6 0x1a
#define SCSI_READ_CAPACITIES 0x23
#define SCSI_READ_CAPACITY 0x25
#define SCSI_READ_10 0x28
#define SCSI_WRITE_10 0x2a
//*****************************************************************************
//
// SCSI Test Unit Ready definitions.
//
//*****************************************************************************
//*****************************************************************************
//
// SCSI Inquiry command definitions.
//
//*****************************************************************************
//*****************************************************************************
//
// Size of the SCSI inquiry response data.
//
//*****************************************************************************
#define SCSI_INQUIRY_DATA_SZ 36
//*****************************************************************************
//
// Offset 0 of the Inquiry Data.
//
//*****************************************************************************
#define SCSI_INQ_PQ_M 0xe0 // Peripheral Qualifier Mask.
#define SCSI_INQ_PQ_CNCT 0x00 // Device connected.
#define SCSI_INQ_PQ_DISC 0x20 // Device disconnected.
#define SCSI_INQ_PDT_M 0x1f // Peripheral Device Type Mask.
#define SCSI_INQ_PDT_SBC 0x00 // Direct Access device.
//*****************************************************************************
//
// Offset 1 of the Inquiry Data.
//
//*****************************************************************************
#define SCSI_INQ_RMB 0x80 // Device is removable.
//*****************************************************************************
//
// Macro to check if removeable.
//
//*****************************************************************************
#define SCSIIsRemovable(pData) \
(((uint8_t *)pData)[1] & SCSI_INQ_RMB)
//*****************************************************************************
//
// SCSI Read Capacity definitions.
//
//*****************************************************************************
//*****************************************************************************
//
// Size of the SCSI Read Capacity response data.
//
//*****************************************************************************
#define SCSI_READ_CAPACITY_SZ 0x08
//*****************************************************************************
//
// SCSI Mode Sense definitions, these are passed in via the ui32Flags parameter
// of the SCSIModeSense() function call.
//
//*****************************************************************************
//*****************************************************************************
//
// Disable block descriptors.
//
//*****************************************************************************
#define SCSI_MS_DBD 0x00000800
//*****************************************************************************
//
// Page Code values, used in combination with Page Control values.
//
//*****************************************************************************
#define SCSI_MS_PC_VENDOR 0x00000000
#define SCSI_MS_PC_DISCO 0x00020000
#define SCSI_MS_PC_CONTROL 0x000a0000
#define SCSI_MS_PC_LUN 0x00180000
#define SCSI_MS_PC_PORT 0x00190000
#define SCSI_MS_PC_POWER 0x001a0000
#define SCSI_MS_PC_INFORM 0x001c0000
#define SCSI_MS_PC_ALL 0x003f0000
//*****************************************************************************
//
// Page Control values.
//
//*****************************************************************************
#define SCSI_MS_PC_CURRENT 0x00000000
#define SCSI_MS_PC_CHANGEABLE 0x00400000
#define SCSI_MS_PC_DEFAULT 0x00800000
#define SCSI_MS_PC_SAVED 0x00c00000
//*****************************************************************************
//
// Request Sense Definitions.
//
//*****************************************************************************
//*****************************************************************************
//
// Size of the data returned by the Request Sense command.
//
//*****************************************************************************
#define SCSI_REQUEST_SENSE_SZ 18
#define SCSI_RS_SKEY 2 // Sense Key offset.
#define SCSI_RS_SKEY_AD_SKEY 12 // Additional Sense Key offset.
//*****************************************************************************
//
// Offset 0 in the Request Sense response.
//
//*****************************************************************************
#define SCSI_RS_VALID 0x80 // Response is valid.
#define SCSI_RS_CUR_ERRORS 0x70 // Current errors returned.
#define SCSI_RS_DEFER_ERRORS 0x71 // Deferred errors returned.
//*****************************************************************************
//
// Offset 2 in the Request Sense response.
//
//*****************************************************************************
#define SCSI_RS_KEY_M 0x0f // Sense Key.
#define SCSI_RS_KEY_NO_SENSE 0x00 // No Sense Data.
#define SCSI_RS_KEY_RECOVRD_ERR 0x01 // Recovered Error.
#define SCSI_RS_KEY_NOT_READY 0x02 // Not Ready.
#define SCSI_RS_KEY_MEDIUM_ERR 0x03 // Error in the media.
#define SCSI_RS_KEY_HW_ERR 0x04 // Hardware Error, non recoverable.
#define SCSI_RS_KEY_ILGL_RQST 0x05 // Illegal request.
#define SCSI_RS_KEY_UNIT_ATTN 0x06 // Unit changed or reset.
#define SCSI_RS_KEY_DATA_PROT 0x07 // Write Protect error.
#define SCSI_RS_KEY_BLANK_CHK 0x08 // Write once error, block not clear.
#define SCSI_RS_KEY_ABORT 0x0b // Last command was aborted.
#define SCSI_RS_ILI 0x20 // Incorrect length indicator.
#define SCSI_RS_EOM 0x40 // End of medium condition.
#define SCSI_RS_FILEMARK 0x80 // Command has read a filemark/setmark.
#define SCSI_RS_MED_NOT_PRSNT 0x003a // Medium not present.
#define SCSI_RS_MED_NOTRDY2RDY 0x0028 // Not ready to ready transition.
#define SCSI_RS_PV_INVALID 0x0226 // Parameter Value Invalid.
//*****************************************************************************
//
// Additional information for SCSI_RS_KEY_NOT_READY
//
//*****************************************************************************
#define SCSI_RS_KEY_NOTPRSNT 0x3A // Media Not Present.
//*****************************************************************************
//
// Mark the end of the C bindings section for C++ compilers.
//
//*****************************************************************************
#ifdef __cplusplus
}
#endif
#endif // __USBMSC_H__