ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
ra8_usb_phid.h
Go to the documentation of this file.
1
39
40#pragma once
41
42#ifdef __cplusplus
43extern "C" {
44#endif
45
46#include <stdint.h>
47
48#include "ra8_err.h"
49#include "ra8_usb.h"
50
51/* =============================================================================
52 * Constants
53 * =============================================================================
54 */
55
70
79
94
112
130
143
155
165
188typedef ra8_err_t (*ra8_usb_phid_setup_fn_t)(void* ctx, const ra8_usb_setup_t* setup);
189
190/* =============================================================================
191 * Lifecycle
192 * =============================================================================
193 */
194
225[[nodiscard]] ra8_err_t ra8_usb_phid_init(ra8_usb_speed_t speed);
226
242[[nodiscard]] ra8_err_t ra8_usb_phid_close(void);
243
244/* =============================================================================
245 * Descriptor handoff
246 * =============================================================================
247 */
248
281[[nodiscard]] ra8_err_t ra8_usb_phid_set_descriptors(const uint8_t* report_desc,
282 uint16_t report_desc_len,
283 const uint8_t* hid_desc,
284 uint16_t hid_desc_len);
285
286/* =============================================================================
287 * Input / output reports
288 * =============================================================================
289 */
290
320[[nodiscard]] ra8_err_t
321ra8_usb_phid_send_report(uint8_t report_id, const uint8_t* payload, uint16_t len);
322
352[[nodiscard]] ra8_err_t
353ra8_usb_phid_recv_report(uint8_t report_id, uint8_t* buf, uint16_t max_len, uint16_t* got_len);
354
355/* =============================================================================
356 * Setup-handler attach
357 * =============================================================================
358 */
359
385 void* ctx);
386
387/* =============================================================================
388 * Class SETUP dispatch
389 * =============================================================================
390 */
391
418[[nodiscard]] ra8_err_t ra8_usb_phid_handle_setup(const ra8_usb_setup_t* setup);
419
420/* =============================================================================
421 * Introspection
422 * =============================================================================
423 */
424
443[[nodiscard]] ra8_err_t ra8_usb_phid_get_idle(uint8_t* out_idle_rate);
444
463
464#ifdef __cplusplus
465}
466#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_phid_desc_t
HID-specific descriptor types (USB HID 1.11 sec 7.1).
@ k_ra8_phid_desc_hid
HID class descriptor.
@ k_ra8_phid_desc_report
HID Report descriptor.
@ k_ra8_phid_desc_physical
HID Physical descriptor.
ra8_err_t ra8_usb_phid_recv_report(uint8_t report_id, uint8_t *buf, uint16_t max_len, uint16_t *got_len)
Drain a HID output report from the interrupt-OUT endpoint.
ra8_usb_phid_protocol_select_t
wValue payload for SET_PROTOCOL.
@ k_ra8_phid_proto_boot
Boot protocol.
@ k_ra8_phid_proto_report
Report protocol.
ra8_usb_phid_class_t
Class / subclass / protocol triplet that identifies the local HID function in the configuration descr...
@ k_ra8_phid_class_hid
HID interface class.
@ k_ra8_phid_protocol_mouse
Boot mouse.
@ k_ra8_phid_protocol_other
Non keyboard / mouse.
@ k_ra8_phid_subclass_none
No subclass.
@ k_ra8_phid_protocol_keyboard
Boot keyboard.
@ k_ra8_phid_subclass_boot
Boot Interface Subclass.
ra8_err_t ra8_usb_phid_get_idle(uint8_t *out_idle_rate)
Read the most-recently negotiated idle rate.
ra8_usb_phid_packet_t
Packet sizing for the device-HID interrupt endpoints.
@ k_ra8_phid_intr_max_packet_default
Boot-protocol default.
@ k_ra8_phid_intr_max_packet_fs
FS ceiling.
@ k_ra8_phid_intr_max_packet_hs
HS ceiling.
ra8_err_t ra8_usb_phid_get_protocol(ra8_usb_phid_protocol_select_t *out_protocol)
Read the most-recently negotiated protocol.
ra8_err_t ra8_usb_phid_init(ra8_usb_speed_t speed)
Bring up the device-HID function on a chosen USB controller.
ra8_usb_phid_request_t
HID class-specific request codes the host issues to the device.
@ k_ra8_phid_req_set_idle
SET_IDLE.
@ k_ra8_phid_req_get_report
GET_REPORT.
@ k_ra8_phid_req_get_idle
GET_IDLE.
@ k_ra8_phid_req_set_report
SET_REPORT.
@ k_ra8_phid_req_set_protocol
SET_PROTOCOL.
@ k_ra8_phid_req_get_protocol
GET_PROTOCOL.
ra8_err_t ra8_usb_phid_handle_setup(const ra8_usb_setup_t *setup)
Process a class-specific SETUP packet on EP0.
ra8_err_t ra8_usb_phid_attach_setup_handler(ra8_usb_phid_setup_fn_t setup_fn, void *ctx)
Register the application's HID class-setup handler.
ra8_usb_phid_report_type_t
HID report-type selector encoded in wValue's high byte for GET_REPORT / SET_REPORT.
@ k_ra8_phid_report_type_input
Input report.
@ k_ra8_phid_report_type_feature
Feature report.
@ k_ra8_phid_report_type_output
Output report.
ra8_usb_phid_ep_t
USB endpoint addresses used by the device-HID function.
@ k_ra8_phid_ep_intr_in_addr
EP1 IN address.
@ k_ra8_phid_ep_intr_out_addr
EP2 OUT address.
ra8_err_t ra8_usb_phid_set_descriptors(const uint8_t *report_desc, uint16_t report_desc_len, const uint8_t *hid_desc, uint16_t hid_desc_len)
Install the caller-supplied HID Report descriptor and HID class descriptor.
ra8_err_t(* ra8_usb_phid_setup_fn_t)(void *ctx, const ra8_usb_setup_t *setup)
Caller-supplied HID class-setup handler signature.
ra8_err_t ra8_usb_phid_close(void)
Tear down the device-HID function and release the controller.
ra8_err_t ra8_usb_phid_send_report(uint8_t report_id, const uint8_t *payload, uint16_t len)
Push a HID input report on the interrupt-IN endpoint.
ra8_usb_phid_pipe_t
PIPE numbers used by the device-HID function for the local interrupt endpoints.
@ k_ra8_phid_pipe_intr_out
PIPE7 -> EP2 OUT (intr).
@ k_ra8_phid_pipe_intr_in
PIPE6 -> EP1 IN (intr).
Decoded 8-byte USB SETUP packet.