USBLibAPIGuide  1.00.00.01
Data Structures | Macros | Enumerations | Functions
Hid_sensor_device_class_api
Collaboration diagram for Hid_sensor_device_class_api:

Data Structures

struct  tUSBDSensorInstance
 
struct  tUSBDHIDSensorDevice
 
struct  PACKED
 USB_CDC_GET/SET_LINE_CODING request-specific data. More...
 

Macros

#define NUM_HID_SECTIONS
 
#define USBDSENSOR_SUCCESS   0
 
More...
 
#define USBDSENSOR_TX_ERROR   1
 
#define USBDSENSOR_NOT_CONFIGURED   2
 The device is not currently configured and cannot perform any operations. More...
 

Enumerations

enum  tSensorState { eHIDSensorStateNotConnected, eHIDSensorStateIdle, eHIDSensorStateSending }
 

Functions

tUSBDHIDSensorDeviceUSBDHIDSensorInit (uint32_t ui32Index, tUSBDHIDSensorDevice *psHIDSensorDevice)
 
tUSBDHIDSensorDeviceUSBDHIDSensorCompositeInit (uint32_t ui32Index, tUSBDHIDSensorDevice *psHIDSensorDevice, tCompositeEntry *psCompEntry)
 
uint32_t USBDHIDSensorSendReport (tUSBDHIDSensorDevice *psHIDSensor, void *pvReport, uint32_t ui32Size)
 
void USBDHIDSensorTerm (tUSBDHIDSensorDevice *psSensor)
 

Detailed Description

Macro Definition Documentation

§ NUM_HID_SECTIONS

#define NUM_HID_SECTIONS
Value:
((sizeof(g_psHIDSections) / \
sizeof(g_psHIDSections[0])) - 1)
const tConfigSection * g_psHIDSections[]
Definition: usbdhidmouse.c:237

§ USBDSENSOR_SUCCESS

#define USBDSENSOR_SUCCESS   0


The USBDHIDSensorSendReport() call successfully scheduled the report.

Referenced by USBDHIDSensorSendReport().

§ USBDSENSOR_TX_ERROR

#define USBDSENSOR_TX_ERROR   1

The USBDHIDSensorSendReport() function could not send the report at this time.

Referenced by USBDHIDSensorSendReport().

§ USBDSENSOR_NOT_CONFIGURED

#define USBDSENSOR_NOT_CONFIGURED   2

The device is not currently configured and cannot perform any operations.

Referenced by USBDHIDSensorSendReport().

Enumeration Type Documentation

§ tSensorState

Enumerator
eHIDSensorStateNotConnected 
eHIDSensorStateIdle 
eHIDSensorStateSending 

Function Documentation

§ USBDHIDSensorInit()

tUSBDHIDSensorDevice * USBDHIDSensorInit ( uint32_t  ui32Index,
tUSBDHIDSensorDevice psHIDSensorDevice 
)

Initializes HID sensor device operation for a given USB controller.

Parameters
ui32Indexis the index of the USB controller which is to be initialized for HID sensor device operation.
psHIDSensorDevicepoints to a structure containing parameters customizing the operation of the HID Sensor device.

An application wishing to offer a USB HID sensor interface to a USB host must call this function to initialize the USB controller and attach the sensor device to the USB bus. This function performs all required USB initialization.

On successful completion, this function returns the psHIDSensorDevice pointer passed to it. This must be passed on all future calls to the HID sensor device driver.

When a host connects and configures the device, the application callback receives USB_EVENT_CONNECTED after which sensor temp, state and event are reported back to the host.

Note
The application must not make any calls to the lower level USB device interfaces if interacting with USB via the USB HID sensor device class API. Doing so causes unpredictable (though almost certainly unpleasant) behavior.
Returns
Returns NULL on failure or the psHIDSensorDevice pointer on success.

References tUSBDHIDSensorDevice::pfnCallback, tUSBDHIDSensorDevice::ppui8StringDescriptors, tUSBDSensorInstance::sHIDDevice, tUSBDHIDSensorDevice::sPrivateData, and USBDHIDSensorCompositeInit().

§ USBDHIDSensorCompositeInit()

tUSBDHIDSensorDevice * USBDHIDSensorCompositeInit ( uint32_t  ui32Index,
tUSBDHIDSensorDevice psHIDSensorDevice,
tCompositeEntry psCompEntry 
)

Initializes HID sensor device operation for a given USB controller.

Parameters
ui32Indexis the index of the USB controller which is to be initialized for HID sensor device operation.
psHIDSensorDevicepoints to a structure containing parameters customizing the operation of the HID sensor device.
psCompEntryis the composite device entry to initialize when creating a composite device.

This call is very similar to USBDHIDSensorInit() except that it is used for initializing an instance of the HID sensor device for use in a composite device. If this HID sensor is part of a composite device, then the psCompEntry should point to the composite device entry to initialize. This is part of the array that is passed to the USBDCompositeInit() function.

Returns
Returns zero on failure or a non-zero instance value that should be used with the remaining USB HID sensor APIs.

References eHIDSensorStateNotConnected, tUSBDSensorInstance::iState, tUSBDHIDSensorDevice::pfnCallback, tUSBDHIDDevice::pfnRxCallback, tUSBDHIDSensorDevice::ppui8StringDescriptors, tUSBDHIDDevice::psReportIdle, tUSBDSensorInstance::sHIDDevice, tUSBDHIDSensorDevice::sPrivateData, tUSBDSensorInstance::sReportIdle, tUSBDHIDSensorDevice::ui16MaxPowermA, tUSBDHIDDevice::ui16MaxPowermA, tUSBDHIDSensorDevice::ui16PID, tUSBDHIDDevice::ui16PID, tHIDReportIdle::ui16TimeTillNextmS, tUSBDHIDSensorDevice::ui16VID, tUSBDHIDDevice::ui16VID, tHIDReportIdle::ui32TimeSinceReportmS, tHIDReportIdle::ui8Duration4mS, tUSBDHIDDevice::ui8NumInputReports, tUSBDHIDDevice::ui8Protocol, tUSBDHIDSensorDevice::ui8PwrAttributes, tUSBDHIDDevice::ui8PwrAttributes, tHIDReportIdle::ui8ReportID, tUSBDHIDDevice::ui8Subclass, USB_HID_PROTOCOL_NONE, and USB_HID_SCLASS_NONE.

Referenced by USBDHIDSensorInit().

§ USBDHIDSensorSendReport()

uint32_t USBDHIDSensorSendReport ( tUSBDHIDSensorDevice psHIDSensor,
void *  pvReport,
uint32_t  ui32Size 
)

Schedules a report to be sent once the host requests more data.

Parameters
psHIDSensoris the structure pointer that is returned from the USBDHIDSensorCompositeInit() or USBDHIDSensorInit() functions.
pvReportis the data to send to the host.
ui32Sizeis the number of bytes in the pvReport buffer.

This call is made by an application to schedule data to be sent to the host when the host requests an update from the device. The application must then wait for a USB_EVENT_TX_COMPLETE event in the function provided in the pfnCallback pointer in the tUSBDHIDSensorDevice structure before being able to send more data with this function. The pointer passed in the pvReport can be updated once this call returns as the data has been copied from the buffer. The function returns USBDSENSOR_SUCCESS if the transmission was successfully scheduled or USBDSENSOR_TX_ERROR if the report could not be sent at this time. If the call is made before the device is connected or ready to communicate with the host, then the function can return USBDSENSOR_NOT_CONFIGURED.

Returns
The function returns one of the USBDSENSOR_* values.

References eHIDSensorStateNotConnected, eHIDSensorStateSending, tUSBDSensorInstance::iState, tUSBDSensorInstance::sHIDDevice, tUSBDHIDSensorDevice::sPrivateData, USBDHIDReportWrite(), USBDHIDTxPacketAvailable(), USBDSENSOR_NOT_CONFIGURED, USBDSENSOR_SUCCESS, and USBDSENSOR_TX_ERROR.

§ USBDHIDSensorTerm()

void USBDHIDSensorTerm ( tUSBDHIDSensorDevice psSensor)

Shuts down the HID Sensor device.

Parameters
psSensoris the pointer to the device instance structure as returned by USBDHIDSensorInit() or USBDHIDSensorCompositeInit().

This function terminates HID Sensor operation for the instance supplied and removes the device from the USB bus. Following this call, the psSensor instance may not me used in any other call to the HID Sensor device other than to reinitialize by calling USBDHIDSensorInit() or USBDHIDSensorCompositeInit().

Returns
None.

References eHIDSensorStateNotConnected, tUSBDSensorInstance::iState, tUSBDSensorInstance::sHIDDevice, tUSBDHIDSensorDevice::sPrivateData, and USBDHIDTerm().

© Copyright 1995-2020, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale