ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
ra8_usb_cdc.h
Go to the documentation of this file.
1
27
28#pragma once
29
30#ifdef __cplusplus
31extern "C" {
32#endif
33
34#include <stdint.h>
35
36#include "ra8_err.h"
37#include "ra8_usb.h"
38
39/* =============================================================================
40 * Constants
41 * =============================================================================
42 */
43
58
68
78
90
95typedef enum : uint16_t {
99
107typedef struct {
108 uint32_t dte_rate;
109 uint8_t char_format;
110 uint8_t parity_type;
111 uint8_t data_bits;
113
114/* =============================================================================
115 * Lifecycle
116 * =============================================================================
117 */
118
146[[nodiscard]] ra8_err_t ra8_usb_cdc_init(ra8_usb_speed_t speed);
147
163[[nodiscard]] ra8_err_t ra8_usb_cdc_deinit(void);
164
182[[nodiscard]] ra8_err_t ra8_usb_cdc_attach(bool attached);
183
184/* =============================================================================
185 * Bulk byte pipe
186 * =============================================================================
187 */
188
207[[nodiscard]] ra8_err_t ra8_usb_cdc_send(const uint8_t* data, uint16_t len);
208
228[[nodiscard]] ra8_err_t ra8_usb_cdc_recv(uint8_t* out_buf, uint16_t* inout_len);
229
230/* =============================================================================
231 * SETUP request handler
232 * =============================================================================
233 */
234
261[[nodiscard]] ra8_err_t ra8_usb_cdc_handle_setup(const ra8_usb_setup_t* setup);
262
281
300[[nodiscard]] ra8_err_t ra8_usb_cdc_get_line_state(bool* out_dtr, bool* out_rts);
301
302#ifdef __cplusplus
303}
304#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_cdc_line_state_t
Bits inside wValue for SET_CONTROL_LINE_STATE.
Definition ra8_usb_cdc.h:95
@ k_ra8_cdc_line_state_rts
Request to send.
Definition ra8_usb_cdc.h:97
@ k_ra8_cdc_line_state_dtr
Data terminal ready.
Definition ra8_usb_cdc.h:96
ra8_err_t ra8_usb_cdc_recv(uint8_t *out_buf, uint16_t *inout_len)
Drain a chunk of bytes OUT (host -> device).
ra8_err_t ra8_usb_cdc_get_line_state(bool *out_dtr, bool *out_rts)
Get the most recently received DTR / RTS bits.
ra8_err_t ra8_usb_cdc_handle_setup(const ra8_usb_setup_t *setup)
Process a class-specific SETUP packet.
ra8_usb_cdc_ep_t
USB endpoint addresses used by the CDC ACM function.
Definition ra8_usb_cdc.h:63
@ k_ra8_cdc_ep_bulk_in_addr
EP1 IN address.
Definition ra8_usb_cdc.h:64
@ k_ra8_cdc_ep_bulk_out_addr
EP2 OUT address.
Definition ra8_usb_cdc.h:65
@ k_ra8_cdc_ep_intr_in_addr
EP3 IN address.
Definition ra8_usb_cdc.h:66
ra8_err_t ra8_usb_cdc_init(ra8_usb_speed_t speed)
Bring up the CDC ACM function on a chosen USB controller.
ra8_usb_cdc_pipe_t
PIPE numbers used by the CDC ACM function.
Definition ra8_usb_cdc.h:53
@ k_ra8_cdc_pipe_intr_in
PIPE6 -> EP3 IN (interrupt).
Definition ra8_usb_cdc.h:56
@ k_ra8_cdc_pipe_bulk_in
PIPE1 -> EP1 IN (bulk).
Definition ra8_usb_cdc.h:54
@ k_ra8_cdc_pipe_bulk_out
PIPE2 -> EP2 OUT (bulk).
Definition ra8_usb_cdc.h:55
ra8_err_t ra8_usb_cdc_deinit(void)
Tear down the CDC function and release the underlying controller.
ra8_usb_cdc_packet_t
Packet sizing for the CDC ACM bulk + interrupt pipes.
Definition ra8_usb_cdc.h:73
@ k_ra8_cdc_bulk_max_packet_fs
Bulk size at full speed.
Definition ra8_usb_cdc.h:74
@ k_ra8_cdc_bulk_max_packet_hs
Bulk size at high speed.
Definition ra8_usb_cdc.h:75
@ k_ra8_cdc_intr_max_packet
Notification pipe size.
Definition ra8_usb_cdc.h:76
ra8_err_t ra8_usb_cdc_get_line_coding(ra8_usb_cdc_line_coding_t *out)
Get the most recently negotiated line coding.
ra8_err_t ra8_usb_cdc_attach(bool attached)
Raise / drop the D+ pull-up to advertise the CDC function.
ra8_err_t ra8_usb_cdc_send(const uint8_t *data, uint16_t len)
Send a chunk of bytes IN (device -> host).
ra8_usb_cdc_request_t
CDC class-specific request codes carried in bRequest.
Definition ra8_usb_cdc.h:85
@ k_ra8_cdc_req_set_line_coding
7-byte payload.
Definition ra8_usb_cdc.h:86
@ k_ra8_cdc_req_get_line_coding
7-byte payload.
Definition ra8_usb_cdc.h:87
@ k_ra8_cdc_req_set_control_line_state
0-byte payload.
Definition ra8_usb_cdc.h:88
ra8_usb_speed_t
Selects which controller instance the call targets.
7-byte payload of SET_LINE_CODING / GET_LINE_CODING.
uint32_t dte_rate
Baud rate in bits/sec.
uint8_t data_bits
5 / 6 / 7 / 8 / 16.
uint8_t parity_type
0=none, 1=odd, 2=even, ...
uint8_t char_format
0=1 stop, 1=1.5 stop, 2=2 stop.
Decoded 8-byte USB SETUP packet.