ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
ra8_usb_hcdc.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
69
81
98
109
124
137
150typedef struct {
152 uint8_t bulk_in_ep;
153 uint8_t bulk_out_ep;
154 uint8_t intr_in_ep;
157 uint16_t vendor_id;
158 uint16_t product_id;
160
174typedef void (*ra8_usb_hcdc_attach_fn_t)(void* ctx, const ra8_usb_hcdc_device_t* device);
175
176/* =============================================================================
177 * Lifecycle
178 * =============================================================================
179 */
180
216[[nodiscard]] ra8_err_t ra8_usb_hcdc_init(ra8_usb_speed_t speed);
217
235[[nodiscard]] ra8_err_t ra8_usb_hcdc_close(void);
236
237/* =============================================================================
238 * Attach callback
239 * =============================================================================
240 */
241
264[[nodiscard]] ra8_err_t ra8_usb_hcdc_attach_callback(ra8_usb_hcdc_attach_fn_t on_attach, void* ctx);
265
266/* =============================================================================
267 * Bulk byte pipe
268 * =============================================================================
269 */
270
298[[nodiscard]] ra8_err_t ra8_usb_hcdc_send(const uint8_t* data, uint16_t len);
299
328[[nodiscard]] ra8_err_t ra8_usb_hcdc_recv(uint8_t* out_buf, uint16_t max_len, uint16_t* got_len);
329
330/* =============================================================================
331 * Class control transfer
332 * =============================================================================
333 */
334
364[[nodiscard]] ra8_err_t ra8_usb_hcdc_set_line_coding(uint32_t baud,
366 ra8_usb_hcdc_stop_bits_t stop_bits);
367
368/* =============================================================================
369 * Test / introspection helpers
370 * =============================================================================
371 */
372
395[[nodiscard]] ra8_err_t ra8_usb_hcdc_step(void);
396
397#ifdef __cplusplus
398}
399#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_hcdc_packet_t
Packet sizing for the attached device's bulk + interrupt endpoints (these are the maxima the host pip...
@ k_ra8_hcdc_intr_max_packet
Notification pipe size.
@ k_ra8_hcdc_bulk_max_packet_hs
Bulk size at high speed.
@ k_ra8_hcdc_bulk_max_packet_fs
Bulk size at full speed.
ra8_err_t ra8_usb_hcdc_set_line_coding(uint32_t baud, ra8_usb_hcdc_parity_t parity, ra8_usb_hcdc_stop_bits_t stop_bits)
Issue SET_LINE_CODING to the attached CDC-ACM device.
ra8_usb_hcdc_parity_t
Parity selector used by ra8_usb_hcdc_set_line_coding.
@ k_ra8_hcdc_parity_odd
Odd parity.
@ k_ra8_hcdc_parity_mark
Mark parity.
@ k_ra8_hcdc_parity_even
Even parity.
@ k_ra8_hcdc_parity_space
Space parity.
@ k_ra8_hcdc_parity_none
No parity.
void(* ra8_usb_hcdc_attach_fn_t)(void *ctx, const ra8_usb_hcdc_device_t *device)
Attach-callback signature.
ra8_usb_hcdc_class_t
Class / subclass / protocol triplets that identify a CDC ACM function within an attached USB device's...
@ k_ra8_hcdc_protocol_at_v25
AT command set (V.25ter).
@ k_ra8_hcdc_class_comms
CDC control interface class.
@ k_ra8_hcdc_subclass_zero
Data subclass = 0.
@ k_ra8_hcdc_class_data
CDC data interface class.
@ k_ra8_hcdc_subclass_acm
Abstract Control Model.
@ k_ra8_hcdc_protocol_zero
Data protocol = 0.
ra8_usb_hcdc_pipe_t
PIPE numbers used by the host-CDC driver for the attached peripheral's endpoints.
@ k_ra8_hcdc_pipe_bulk_in
PIPE1 -> attached EP bulk IN.
@ k_ra8_hcdc_pipe_intr_in
PIPE6 -> attached EP intr IN.
@ k_ra8_hcdc_pipe_bulk_out
PIPE2 -> attached EP bulk OUT.
ra8_err_t ra8_usb_hcdc_attach_callback(ra8_usb_hcdc_attach_fn_t on_attach, void *ctx)
Register (or detach) the attach callback.
ra8_usb_hcdc_stop_bits_t
Stop-bit selector used by ra8_usb_hcdc_set_line_coding.
@ k_ra8_hcdc_stop_1_5
1.5 stop bits.
@ k_ra8_hcdc_stop_2
2 stop bits.
@ k_ra8_hcdc_stop_1
1 stop bit.
ra8_err_t ra8_usb_hcdc_init(ra8_usb_speed_t speed)
Bring up the host-CDC driver on a chosen USB controller.
ra8_err_t ra8_usb_hcdc_step(void)
Drive the enumeration step machine forward by one step.
ra8_err_t ra8_usb_hcdc_send(const uint8_t *data, uint16_t len)
Send a chunk of bytes OUT to the attached CDC-ACM device.
ra8_usb_hcdc_request_t
CDC class-specific request codes the host issues to the attached device.
@ k_ra8_hcdc_req_set_control_line_state
0-byte payload.
@ k_ra8_hcdc_req_get_line_coding
7-byte payload.
@ k_ra8_hcdc_req_set_line_coding
7-byte payload.
ra8_err_t ra8_usb_hcdc_close(void)
Tear down the host-CDC driver and release the controller.
ra8_err_t ra8_usb_hcdc_recv(uint8_t *out_buf, uint16_t max_len, uint16_t *got_len)
Drain a chunk of bytes IN from the attached CDC-ACM device.
Snapshot of the attached CDC-ACM device, passed to the attach callback.
uint8_t device_address
Assigned USB address (1..127).
uint8_t bulk_in_ep
Attached device's bulk IN EP num.
uint8_t intr_in_ep
Attached device's intr IN EP num.
uint8_t bulk_out_ep
Attached device's bulk OUT EP num.
uint16_t vendor_id
idVendor from device descriptor.
uint16_t product_id
idProduct from device descriptor.
uint16_t bulk_out_max_packet
Attached bulk-OUT wMaxPacketSize.
uint16_t bulk_in_max_packet
Attached bulk-IN wMaxPacketSize.