35static const char*
s_tag =
"USB";
126 uint16_t remaining = len;
127 uint16_t offset = 0U;
128 bool pid_raised =
false;
129 while (remaining > 0U) {
130 const uint16_t chunk =
139 offset = (uint16_t)(offset + chunk);
140 remaining = (uint16_t)(remaining - chunk);
217 if (reg ==
nullptr) {
221 if ((data ==
nullptr) && (len != 0U)) {
279 if ((out_buf ==
nullptr) || (inout_len ==
nullptr)) {
315 if (reg ==
nullptr) {
328 const uint16_t pipe_bit = (uint16_t)(1U << pipe_num);
329 if ((reg->
BRDYSTS & pipe_bit) == 0U) {
340 reg->
BRDYSTS = (uint16_t)(~pipe_bit);
348 if (available == 0U) {
358 const uint16_t take = (available < *inout_len) ? available : *inout_len;
401 if (reg ==
nullptr) {
410 const uint16_t pipe_bit = (uint16_t)(1U << pipe_num);
411 reg->
NRDYSTS = (uint16_t)(~pipe_bit);
444 if (reg ==
nullptr) {
483 if (reg ==
nullptr) {
492 const uint16_t req = reg->
USBREQ;
533 if (reg ==
nullptr) {
540 const uint16_t req = reg->
USBREQ;
570 if (reg ==
nullptr) {
static const char * s_tag
Logging / check tag.
Annotation-attribute framework macros for ra8-firmware.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
Validation and Error-Checking Macros for ra8-firmware.
#define RA8_RETURN_ON_ERROR(err, tag, message)
Early return on error, propagating the code upward.
#define RA8_CHECK_NULL_PTR(ptr, tag, message)
Reject nullptr pointer, returning k_ra8_err_null_ptr.
Error Code Definitions for ra8-firmware.
@ k_ra8_err_no_data
No application data available (e.g.
@ k_ra8_err_invalid_arg
Invalid function argument.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
@ k_ra8_err_null_ptr
Pointer was NULL where a valid pointer was required.
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
Lightweight Logging Interface for ra8-firmware.
void priv_fifo_write(volatile r_usb_regs_t *reg, const uint8_t *data, uint16_t len)
Push a byte buffer into the CFIFO data port.
void priv_dcp_pid(volatile r_usb_regs_t *reg, ra8_usb_pid_t pid)
Set DCPCTR PID field to a specific value while preserving the rest of the register.
void priv_rmw16(volatile uint16_t *reg, uint16_t set_mask, uint16_t clr_mask)
Apply a generic read-modify-write to a 16-bit register.
void priv_select_cfifo(volatile r_usb_regs_t *reg, uint16_t pipe_num, bool is_in_dir)
Set CFIFOSEL.MBW + CURPIPE + ISEL for the given pipe / direction.
ra8_err_t priv_wait_frdy(volatile r_usb_regs_t *reg)
Spin until CFIFOCTR.FRDY asserts or a deadline elapses.
volatile r_usb_regs_t * priv_pick(ra8_usb_speed_t speed)
Resolve the per-speed register pointer.
ra8_err_t priv_dcp_push_chunk(volatile r_usb_regs_t *reg, const uint8_t *p, uint16_t n)
Push a single DCP IN chunk: wait for FRDY, write FIFO, pulse BVAL.
void priv_pipe_pid(volatile r_usb_regs_t *reg, uint8_t pipe_num, ra8_usb_pid_t pid)
Set PIPECTR[idx] PID field.
void priv_fifo_read(volatile r_usb_regs_t *reg, uint8_t *data, uint16_t len)
Drain the CFIFO data port into a buffer.
Native USB controller driver public API (device + host modes).
ra8_usb_speed_t
Selects which controller instance the call targets.
Cross-TU surface for the ra8_usb driver split.
@ k_ra8_usb_byte_mask
Low byte of a 16-bit FIFO word.
@ k_ra8_usb_byte_bits
Bits per byte (shift constant).
@ k_ra8_usb_pipe_max_packet
Max packet ceiling for pipes.
@ k_ra8_usb_max_pipe_num
PIPE1..PIPE9 + DCP at 0.
@ k_ra8_usb_dcp_max_packet
EP0 default packet size.
USB Full-Speed + High-Speed controller layout for the Renesas RA8D2.
@ k_ra8_pid_buf
BUF response (transmit/receive).
@ k_ra8_pid_nak
NAK response.
@ k_ra8_pid_stall
STALL response.
@ k_ra8_fifoctr_bclr
Buffer clear.
@ k_ra8_fifoctr_dtln
Data length (write-bytes-rem).
@ k_ra8_fifoctr_bval
Buffer valid.
@ k_ra8_dcpctr_bit_ccpl
Control transfer end enable.
@ k_ra8_intsts0_mask_valid
SETUP packet detect flag.
ra8_err_t ra8_usb_park_out_pipe(ra8_usb_speed_t speed, uint8_t pipe_num)
Implementation of ra8_usb_park_out_pipe().
volatile uint16_t g_dcp_cfifoctr_post
ra8_err_t ra8_usb_read_setup_if_valid(ra8_usb_speed_t speed, ra8_usb_setup_t *out_setup)
Implementation of ra8_usb_read_setup_if_valid().
ra8_err_t ra8_usb_queue_out(ra8_usb_speed_t speed, uint8_t pipe_num, uint8_t *out_buf, uint16_t *inout_len, bool rearm)
Implementation of ra8_usb_queue_out().
volatile uint32_t g_dcp_push_count
volatile uint16_t g_dcp_cfifoctr_pre
volatile uint8_t g_dcp_last_err
ra8_err_t ra8_usb_control_response(ra8_usb_speed_t speed, bool accept)
Implementation of ra8_usb_control_response().
static ra8_err_t internal_dcp_in_zlp(volatile r_usb_regs_t *reg)
Send a zero-length data stage on the DCP IN endpoint.
static ra8_err_t internal_dcp_in_payload(volatile r_usb_regs_t *reg, const uint8_t *data, uint16_t len)
Send the EP0 IN data-stage payload as one or more DCP chunks.
ra8_err_t ra8_usb_rearm_out_pipe(ra8_usb_speed_t speed, uint8_t pipe_num)
Implementation of ra8_usb_rearm_out_pipe().
volatile uint16_t g_dcp_dcpctr_post_push
volatile uint16_t g_dcp_dcpctr_pre_push
volatile uint16_t g_dcp_last_len
static ra8_err_t internal_check_queue_out_args(uint8_t pipe_num, const uint8_t *out_buf, const uint16_t *inout_len)
Argument validation helper for ra8_usb_queue_out.
ra8_err_t ra8_usb_read_setup_unconditional(ra8_usb_speed_t speed, ra8_usb_setup_t *out_setup)
Implementation of ra8_usb_read_setup_unconditional (see header).
ra8_err_t ra8_usb_queue_in(ra8_usb_speed_t speed, uint8_t pipe_num, const uint8_t *data, uint16_t len)
Implementation of ra8_usb_queue_in().
ra8_err_t ra8_usb_dcp_in_data(ra8_usb_speed_t speed, const uint8_t *data, uint16_t len)
Implementation of ra8_usb_dcp_in_data().
USB FS / HS register window (device-mode subset).
volatile uint16_t USBINDX
+0x058 USB Request wIndex.
volatile uint16_t DCPCTR
+0x060 DCP Control.
volatile uint16_t USBVAL
+0x056 USB Request wValue.
volatile uint16_t CFIFOCTR
+0x022 Control FIFO control.
volatile uint16_t INTSTS0
+0x040 Interrupt Status 0.
volatile uint16_t USBLENG
+0x05A USB Request wLength.
volatile uint16_t NRDYSTS
+0x048 NRDY Interrupt Status.
volatile uint16_t BRDYSTS
+0x046 BRDY Interrupt Status.
volatile uint16_t USBREQ
+0x054 USB Request type/bRequest.
Decoded 8-byte USB SETUP packet.
uint16_t w_length
wLength.
uint8_t b_request
bRequest code.
uint8_t bm_request_type
Request direction / type / recipient.