ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
ra8_usb_hhid.h
Go to the documentation of this file.
1
43
44#pragma once
45
46#ifdef __cplusplus
47extern "C" {
48#endif
49
50#include <stdint.h>
51
52#include "ra8_err.h"
53#include "ra8_usb.h"
54
55/* =============================================================================
56 * Constants
57 * =============================================================================
58 */
59
75
89
107
124
137
149
159
170typedef enum : uint16_t {
173
185typedef struct {
187 uint8_t intr_in_ep;
188 uint8_t intr_out_ep;
191 uint8_t subclass;
192 uint8_t protocol;
195 uint16_t vendor_id;
196 uint16_t product_id;
198 const uint8_t* hid_descriptor;
199 const uint8_t* report_descriptor;
201
215typedef void (*ra8_usb_hhid_attach_fn_t)(void* ctx, const ra8_usb_hhid_device_t* device);
216
217/* =============================================================================
218 * Lifecycle
219 * =============================================================================
220 */
221
249[[nodiscard]] ra8_err_t ra8_usb_hhid_init(ra8_usb_speed_t speed);
250
267[[nodiscard]] ra8_err_t ra8_usb_hhid_close(void);
268
269/* =============================================================================
270 * Attach callback
271 * =============================================================================
272 */
273
297[[nodiscard]] ra8_err_t ra8_usb_hhid_attach_callback(ra8_usb_hhid_attach_fn_t on_attach, void* ctx);
298
299/* =============================================================================
300 * Class control transfers
301 * =============================================================================
302 */
303
340[[nodiscard]] ra8_err_t ra8_usb_hhid_get_report(ra8_usb_hhid_report_type_t target_report_type,
341 uint8_t target_report_id,
342 uint8_t* out_buf,
343 uint16_t max_len,
344 uint16_t* got_len);
345
377[[nodiscard]] ra8_err_t ra8_usb_hhid_set_report(ra8_usb_hhid_report_type_t target_report_type,
378 uint8_t target_report_id,
379 const uint8_t* in_buf,
380 uint16_t len);
381
409[[nodiscard]] ra8_err_t ra8_usb_hhid_set_idle(uint8_t duration, uint8_t report_id);
410
437
438/* =============================================================================
439 * Interrupt-IN polling
440 * =============================================================================
441 */
442
471[[nodiscard]] ra8_err_t
472ra8_usb_hhid_get_input_report(uint8_t* out_buf, uint16_t max_len, uint16_t* got_len);
473
474/* =============================================================================
475 * Test / introspection helpers
476 * =============================================================================
477 */
478
501[[nodiscard]] ra8_err_t ra8_usb_hhid_step(void);
502
503#ifdef __cplusplus
504}
505#endif
Error Code Definitions for ra8-firmware.
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
Definition ra8_err.h:546
Native USB controller driver public API (device + host modes).
ra8_usb_speed_t
Selects which controller instance the call targets.
ra8_usb_hhid_report_type_t
HID report-type selector encoded in wValue's high byte for GET_REPORT / SET_REPORT.
@ k_ra8_hhid_report_type_input
Input report.
@ k_ra8_hhid_report_type_feature
Feature report.
@ k_ra8_hhid_report_type_output
Output report.
ra8_err_t ra8_usb_hhid_close(void)
Tear down the host-HID driver and release the controller.
ra8_err_t ra8_usb_hhid_set_report(ra8_usb_hhid_report_type_t target_report_type, uint8_t target_report_id, const uint8_t *in_buf, uint16_t len)
Issue SET_REPORT (USB HID 1.11 sec 7.2.2) over the DCP.
ra8_err_t ra8_usb_hhid_set_protocol(ra8_usb_hhid_protocol_select_t boot_or_report)
Issue SET_PROTOCOL (USB HID 1.11 sec 7.2.6) over the DCP.
void(* ra8_usb_hhid_attach_fn_t)(void *ctx, const ra8_usb_hhid_device_t *device)
Attach-callback signature.
ra8_usb_hhid_class_t
Class / subclass / protocol triplet that identifies an HID function within an attached USB device's d...
@ k_ra8_hhid_protocol_keyboard
Boot keyboard.
@ k_ra8_hhid_class_hid
HID interface class.
@ k_ra8_hhid_subclass_boot
Boot Interface Subclass.
@ k_ra8_hhid_protocol_mouse
Boot mouse.
@ k_ra8_hhid_subclass_none
No subclass.
@ k_ra8_hhid_protocol_other
Non keyboard / mouse.
ra8_usb_hhid_desc_t
HID-specific descriptor types (USB HID 1.11 sec 7.1).
@ k_ra8_hhid_desc_report
HID Report descriptor.
@ k_ra8_hhid_desc_hid
HID class descriptor.
@ k_ra8_hhid_desc_physical
HID Physical descriptor.
ra8_usb_hhid_packet_t
Packet sizing for the attached device's interrupt endpoints.
@ k_ra8_hhid_intr_max_packet_default
Boot-protocol default.
@ k_ra8_hhid_intr_max_packet_hs
HS ceiling.
@ k_ra8_hhid_intr_max_packet_fs
FS ceiling.
ra8_err_t ra8_usb_hhid_init(ra8_usb_speed_t speed)
Bring up the host-HID driver on a chosen USB controller.
ra8_err_t ra8_usb_hhid_set_idle(uint8_t duration, uint8_t report_id)
Issue SET_IDLE (USB HID 1.11 sec 7.2.4) over the DCP.
ra8_usb_hhid_report_buf_t
Compile-time ceiling on the cached HID Report descriptor.
@ k_ra8_hhid_report_desc_max
Cached Report desc max len.
ra8_err_t ra8_usb_hhid_get_input_report(uint8_t *out_buf, uint16_t max_len, uint16_t *got_len)
Drain the next input report from the interrupt-IN pipe.
ra8_err_t ra8_usb_hhid_get_report(ra8_usb_hhid_report_type_t target_report_type, uint8_t target_report_id, uint8_t *out_buf, uint16_t max_len, uint16_t *got_len)
Issue GET_REPORT (USB HID 1.11 sec 7.2.1) over the DCP.
ra8_usb_hhid_request_t
HID class-specific request codes the host issues to the attached device.
@ k_ra8_hhid_req_get_idle
GET_IDLE.
@ k_ra8_hhid_req_set_report
SET_REPORT.
@ k_ra8_hhid_req_get_protocol
GET_PROTOCOL.
@ k_ra8_hhid_req_get_report
GET_REPORT.
@ k_ra8_hhid_req_set_protocol
SET_PROTOCOL.
@ k_ra8_hhid_req_set_idle
SET_IDLE.
ra8_usb_hhid_protocol_select_t
wValue payload for SET_PROTOCOL.
@ k_ra8_hhid_proto_boot
Boot protocol.
@ k_ra8_hhid_proto_report
Report protocol.
ra8_err_t ra8_usb_hhid_step(void)
Drive the enumeration step machine forward by one step.
ra8_err_t ra8_usb_hhid_attach_callback(ra8_usb_hhid_attach_fn_t on_attach, void *ctx)
Register (or detach) the attach callback.
ra8_usb_hhid_pipe_t
PIPE numbers used by the host-HID driver for the attached peripheral's interrupt endpoints.
@ k_ra8_hhid_pipe_intr_out
PIPE7 -> attached EP intr OUT.
@ k_ra8_hhid_pipe_intr_in
PIPE6 -> attached EP intr IN.
Snapshot of the attached HID device, passed to the attach callback.
uint8_t intr_in_ep
Attached device's intr IN EP num.
uint8_t protocol
bInterfaceProtocol (kb=1, ms=2).
const uint8_t * hid_descriptor
Pointer to cached HID class desc.
uint8_t interface_number
HID bInterfaceNumber.
uint16_t report_descriptor_len
Cached Report desc length.
uint8_t subclass
bInterfaceSubClass (boot=1).
uint16_t product_id
idProduct from device descriptor.
uint8_t device_address
Assigned USB address (1..127).
const uint8_t * report_descriptor
Pointer to cached HID Report desc.
uint8_t intr_out_ep
Attached device's intr OUT EP num (0 if absent).
uint16_t vendor_id
idVendor from device descriptor.
uint16_t intr_in_max_packet
Attached intr-IN wMaxPacketSize.
uint16_t intr_out_max_packet
Attached intr-OUT wMaxPacketSize.