hid_exchange.c File Reference

#include <hid.h>
#include <hid_helpers.h>
#include <os.h>
#include <errno.h>
#include <constants.h>
#include <compiler.h>
#include <debug.h>
#include <assert.h>

Go to the source code of this file.

Defines

#define HID_INTERNAL

Functions

hid_return hid_get_input_report (HIDInterface *const hidif, int const path[], unsigned int const depth, char *const buffer, unsigned int const size)
 Send a control message to retrieve an entire input report.
hid_return hid_set_output_report (HIDInterface *const hidif, int const path[], unsigned int const depth, char const *const buffer, unsigned int const size)
 Send an entire output report to the device.
hid_return hid_get_feature_report (HIDInterface *const hidif, int const path[], unsigned int const depth, char *const buffer, unsigned int const size)
 Send a control message to retrieve an entire feature report.
hid_return hid_set_feature_report (HIDInterface *const hidif, int const path[], unsigned int const depth, char const *const buffer, unsigned int const size)
 Send an entire feature report to the device.
hid_return hid_get_item_value (HIDInterface *const hidif, int const path[], unsigned int const depth, double *const value)
 Retrieve a numeric input item.
hid_return hid_get_item_string (HIDInterface *const hidif UNUSED, int const path[] UNUSED, unsigned int const depth UNUSED, char *const value UNUSED, unsigned int const maxlen UNUSED)
 Currently unimplemented.
hid_return hid_set_item_value (HIDInterface *const hidif UNUSED, int const path[] UNUSED, unsigned int const depth UNUSED, double const value UNUSED)
 Currently unimplemented.
hid_return hid_interrupt_read (HIDInterface *const hidif, unsigned int const ep, char *const bytes, unsigned int const size, unsigned int const timeout)
 Read from the interrupt endpoint.
hid_return hid_interrupt_write (HIDInterface *const hidif, unsigned int const ep, const char *const bytes, unsigned int const size, unsigned int const timeout)
 Write to the interrupt endpoint.
hid_return hid_set_idle (HIDInterface *const hidif, unsigned duration, unsigned report_id)
 Execute a Set_Idle request on an Interrupt In pipe.


Define Documentation

#define HID_INTERNAL

Definition at line 1 of file hid_exchange.c.


Function Documentation

hid_return hid_get_feature_report ( HIDInterface *const   hidif,
int const  path[],
unsigned int const  depth,
char *const   buffer,
unsigned int const  size 
)

Send a control message to retrieve an entire feature report.

To use an interrupt endpoint instead of EP0, use hid_interrupt_read().

Parameters:
[in] hidif Which interface to query
[in] path Path to input item (to find Report ID)
[in] depth See hid_find_object()
[out] buffer Result is stored here
[in] size How many bytes to fetch

Definition at line 135 of file hid_exchange.c.

References ASSERT, HIDInterface_t::dev_handle, HIDInterface_t::hid_data, hid_find_object(), hid_is_initialised(), hid_is_opened(), HID_REPORT_GET, HID_RET_DEVICE_NOT_OPENED, HID_RET_FAIL_GET_REPORT, HID_RET_INVALID_PARAMETER, HID_RET_SUCCESS, HID_RT_FEATURE, HIDInterface_t::id, HIDInterface_t::interface, ITEM_FEATURE, NOTICE, HIDData::ReportID, TRACE, HIDData::Type, USB_TIMEOUT, and WARNING.

hid_return hid_get_input_report ( HIDInterface *const   hidif,
int const  path[],
unsigned int const  depth,
char *const   buffer,
unsigned int const  size 
)

Send a control message to retrieve an entire input report.

To use an interrupt endpoint instead of EP0, use hid_interrupt_read().

Parameters:
[in] hidif Which interface to query
[in] path Path to input item (to find Report ID)
[in] depth See hid_find_object()
[out] buffer Result is stored here
[in] size How many bytes to fetch

Definition at line 23 of file hid_exchange.c.

References ASSERT, HIDInterface_t::dev_handle, HIDInterface_t::hid_data, hid_find_object(), hid_is_initialised(), hid_is_opened(), HID_REPORT_GET, HID_RET_DEVICE_NOT_OPENED, HID_RET_FAIL_GET_REPORT, HID_RET_INVALID_PARAMETER, HID_RET_SUCCESS, HID_RT_INPUT, HIDInterface_t::id, HIDInterface_t::interface, ITEM_INPUT, NOTICE, HIDData::ReportID, TRACE, HIDData::Type, USB_TIMEOUT, and WARNING.

hid_return hid_get_item_string ( HIDInterface *const hidif  UNUSED,
int const path[]  UNUSED,
unsigned int const depth  UNUSED,
char *const value  UNUSED,
unsigned int const maxlen  UNUSED 
)

Currently unimplemented.

Definition at line 299 of file hid_exchange.c.

References ASSERT, and HID_RET_SUCCESS.

hid_return hid_get_item_value ( HIDInterface *const   hidif,
int const  path[],
unsigned int const  depth,
double *const  value 
)

Retrieve a numeric input item.

Parameters:
[in] hidif Which interface to send to
[in] path Path to input item
[in] depth See hid_find_object()
[out] value Result from hid_extract_value()
Todo:
Handle exponent and unit conversion (separate library?)

Todo:
Dynamically allocate the item buffer

Definition at line 246 of file hid_exchange.c.

References ASSERT, HIDInterface_t::dev_handle, HIDInterface_t::hid_data, hid_extract_value(), hid_find_object(), hid_get_report_size(), hid_is_initialised(), hid_is_opened(), HID_REPORT_GET, HID_RET_DEVICE_NOT_OPENED, HID_RET_FAIL_GET_REPORT, HID_RET_SUCCESS, HID_RT_FEATURE, HIDInterface_t::id, HIDInterface_t::interface, ITEM_FEATURE, NOTICE, HIDData::ReportID, TRACE, HIDData::Type, USB_TIMEOUT, and WARNING.

hid_return hid_interrupt_read ( HIDInterface *const   hidif,
unsigned int const  ep,
char *const   bytes,
unsigned int const  size,
unsigned int const  timeout 
)

Read from the interrupt endpoint.

Parameters:
[in] hidif Which interface to send to
[in] ep Which endpoint to read
[out] bytes Buffer to store results
[in] size How many bytes to read
[in] timeout How long to wait, in milliseconds
Upon successful completion, the bytes array will contain an input report from the device. It is up to the programmer to determine which input endpoint to read, and to ensure that the endpoint is bitwise-ORed with 0x80 (USB_ENDPOINT_IN).

Definition at line 332 of file hid_exchange.c.

References ASSERT, HIDInterface_t::dev_handle, hid_is_initialised(), hid_is_opened(), HID_RET_DEVICE_NOT_OPENED, HID_RET_FAIL_INT_READ, HID_RET_INVALID_PARAMETER, HID_RET_SUCCESS, HID_RET_TIMEOUT, HIDInterface_t::id, NOTICE, TRACE, and WARNING.

hid_return hid_interrupt_write ( HIDInterface *const   hidif,
unsigned int const  ep,
const char *const  bytes,
unsigned int const  size,
unsigned int const  timeout 
)

Write to the interrupt endpoint.

Parameters:
[in] hidif Which interface to send to
[in] ep Which endpoint to write
[out] bytes Buffer to send
[in] size How many bytes to write
[in] timeout How long to wait, in milliseconds
It is up to the programmer to determine which input endpoint to write.

Definition at line 386 of file hid_exchange.c.

References ASSERT, HIDInterface_t::dev_handle, hid_is_initialised(), hid_is_opened(), HID_RET_DEVICE_NOT_OPENED, HID_RET_FAIL_INT_READ, HID_RET_INVALID_PARAMETER, HID_RET_SUCCESS, HID_RET_TIMEOUT, HIDInterface_t::id, NOTICE, TRACE, and WARNING.

hid_return hid_set_feature_report ( HIDInterface *const   hidif,
int const  path[],
unsigned int const  depth,
char const *const  buffer,
unsigned int const  size 
)

Send an entire feature report to the device.

This routine uses a control message to send the report. To use an interrupt endpoint, use hid_interrupt_write().

Parameters:
[in] hidif Which interface to send to
[in] path Path to an output item (to find Report ID)
[in] depth See hid_find_object()
[in] buffer Output Report
[in] size How many bytes to send

Definition at line 191 of file hid_exchange.c.

References ASSERT, HIDInterface_t::dev_handle, HIDInterface_t::hid_data, hid_find_object(), hid_is_initialised(), hid_is_opened(), HID_REPORT_SET, HID_RET_DEVICE_NOT_OPENED, HID_RET_FAIL_SET_REPORT, HID_RET_INVALID_PARAMETER, HID_RET_SUCCESS, HID_RT_FEATURE, HIDInterface_t::id, HIDInterface_t::interface, ITEM_FEATURE, NOTICE, HIDData::ReportID, TRACE, HIDData::Type, USB_TIMEOUT, and WARNING.

hid_return hid_set_idle ( HIDInterface *const   hidif,
unsigned  duration,
unsigned  report_id 
)

Execute a Set_Idle request on an Interrupt In pipe.

This is used to tell a device not to send reports unless something has changed (duration = 0), or unless a minimum time interval has passed.

Parameters:
[in] hidif Which interface to send to
[in] duration 0 for indefinite, otherwise in increments of 4 ms (to 1020 ms)
[in] report_id 0 for all reports, otherwise a Report ID

Definition at line 439 of file hid_exchange.c.

References HIDInterface_t::dev_handle, HID_RET_FAIL_GET_REPORT, HID_RET_INVALID_PARAMETER, HID_RET_SUCCESS, HID_SET_IDLE, HIDInterface_t::id, HIDInterface_t::interface, USB_TIMEOUT, and WARNING.

hid_return hid_set_item_value ( HIDInterface *const hidif  UNUSED,
int const path[]  UNUSED,
unsigned int const depth  UNUSED,
double const value  UNUSED 
)

Currently unimplemented.

Definition at line 310 of file hid_exchange.c.

References ASSERT, and HID_RET_SUCCESS.

hid_return hid_set_output_report ( HIDInterface *const   hidif,
int const  path[],
unsigned int const  depth,
char const *const  buffer,
unsigned int const  size 
)

Send an entire output report to the device.

This routine uses a control message to send the report. To use an interrupt endpoint, use hid_interrupt_write().

Parameters:
[in] hidif Which interface to send to
[in] path Path to an output item (to find Report ID)
[in] depth See hid_find_object()
[in] buffer Output Report
[in] size How many bytes to send

Definition at line 79 of file hid_exchange.c.

References ASSERT, HIDInterface_t::dev_handle, HIDInterface_t::hid_data, hid_find_object(), hid_is_initialised(), hid_is_opened(), HID_REPORT_SET, HID_RET_DEVICE_NOT_OPENED, HID_RET_FAIL_SET_REPORT, HID_RET_INVALID_PARAMETER, HID_RET_SUCCESS, HID_RT_OUTPUT, HIDInterface_t::id, HIDInterface_t::interface, ITEM_OUTPUT, NOTICE, HIDData::ReportID, TRACE, HIDData::Type, USB_TIMEOUT, and WARNING.


Generated on Sun Mar 30 15:28:25 2008 for libhid by  doxygen 1.5.1