Skip to content

File syn_usb_hid.c

FileList > drivers > syn_usb_hid.c

Go to the source code of this file

Zero-Heap USB 2.0 Human Interface Device (HID) Class Driver Implementation.

  • #include "syntropic/drivers/syn_usb_hid.h"
  • #include <string.h>

Public Static Attributes

Type Name
const uint8_t HID_INTERFACE_DESC = /* multi line expression */

Public Functions

Type Name
SYN_Status syn_usb_hid_init (SYN_USB_HID * hid)
Initialize USB HID Class Instance.
SYN_Status syn_usb_hid_read_report (SYN_USB_HID * hid, void * buf, size_t max_len, size_t * out_len)
Read received OUT report from host.
SYN_Status syn_usb_hid_register (SYN_USB_Device * dev, SYN_USB_HID * hid, const uint8_t * report_desc, uint16_t report_desc_len)
Register USB HID class driver with USB device core.
bool syn_usb_hid_report_available (const SYN_USB_HID * hid)
Check if OUT report is available.
SYN_Status syn_usb_hid_send_report (SYN_USB_HID * hid, const void * report, size_t len)
Queue an IN report for transmission to host.
bool syn_usb_hid_tx_ready (const SYN_USB_HID * hid)
Check if IN transmit buffer is ready.

Public Static Functions

Type Name
SYN_Status hid_class_setup (void * ctx, const SYN_USB_SetupPacket * pkt, uint8_t * resp, uint16_t * rlen)
Class setup request dispatcher for HID class requests.

Public Static Attributes Documentation

variable HID_INTERFACE_DESC

const uint8_t HID_INTERFACE_DESC[25];

Standard HID Interface Descriptor Template (1 interface, 1 IN EP, 25 bytes)


Public Functions Documentation

function syn_usb_hid_init

Initialize USB HID Class Instance.

SYN_Status syn_usb_hid_init (
    SYN_USB_HID * hid
) 

Parameters:

  • hid Pointer to USB HID instance.

Returns:

SYN_OK on success.


function syn_usb_hid_read_report

Read received OUT report from host.

SYN_Status syn_usb_hid_read_report (
    SYN_USB_HID * hid,
    void * buf,
    size_t max_len,
    size_t * out_len
) 

Parameters:

  • hid Pointer to USB HID instance.
  • buf Output buffer.
  • max_len Capacity.
  • out_len Pointer to receive read byte count.

Returns:

SYN_OK on success.


function syn_usb_hid_register

Register USB HID class driver with USB device core.

SYN_Status syn_usb_hid_register (
    SYN_USB_Device * dev,
    SYN_USB_HID * hid,
    const uint8_t * report_desc,
    uint16_t report_desc_len
) 

Parameters:

  • dev Pointer to USB device core context.
  • hid Pointer to USB HID instance.
  • report_desc Pointer to static HID report descriptor.
  • report_desc_len Byte length of report descriptor.

Returns:

SYN_OK on success.


function syn_usb_hid_report_available

Check if OUT report is available.

bool syn_usb_hid_report_available (
    const SYN_USB_HID * hid
) 

Parameters:

  • hid Pointer to USB HID instance.

Returns:

true if unread report data exists.


function syn_usb_hid_send_report

Queue an IN report for transmission to host.

SYN_Status syn_usb_hid_send_report (
    SYN_USB_HID * hid,
    const void * report,
    size_t len
) 

Parameters:

  • hid Pointer to USB HID instance.
  • report Pointer to report data.
  • len Report byte length.

Returns:

SYN_OK on success.


function syn_usb_hid_tx_ready

Check if IN transmit buffer is ready.

bool syn_usb_hid_tx_ready (
    const SYN_USB_HID * hid
) 

Parameters:

  • hid Pointer to USB HID instance.

Returns:

true if transmit buffer is free.


Public Static Functions Documentation

function hid_class_setup

Class setup request dispatcher for HID class requests.

static SYN_Status hid_class_setup (
    void * ctx,
    const SYN_USB_SetupPacket * pkt,
    uint8_t * resp,
    uint16_t * rlen
) 

Parameters:

  • ctx Pointer to SYN_USB_HID instance.
  • pkt Pointer to received Setup Packet.
  • resp Response buffer.
  • rlen Output pointer to receive response byte length.

Returns:

SYN_OK on success.



The documentation for this class was generated from the following file src/syntropic/drivers/syn_usb_hid.c