41static const char*
s_tag =
"USB";
52typedef enum : uint8_t {
112 if (reg ==
nullptr) {
141 const uint16_t mask = reg->
INTSTS0;
147 reg->
INTSTS0 = (uint16_t)~(uint16_t)(mask & ack_bits);
153 fn(ctx, speed, mask);
173 if (reg ==
nullptr) {
238typedef enum : uint8_t {
378 if (reg ==
nullptr) {
427 if (reg ==
nullptr) {
458 if (reg ==
nullptr) {
490 if (reg ==
nullptr) {
521 if (reg ==
nullptr) {
527 if ((reg->
DCPCTR & sureq_bit) != 0U) {
static const char * s_tag
Logging / check tag.
Annotation-attribute framework macros for ra8-firmware.
#define RA8_ISR_SAFE
The function is callable from interrupt context.
#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_busy
Resource busy – blocking operation cannot proceed.
@ k_ra8_err_invalid_arg
Invalid function argument.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
Lightweight Logging Interface for ra8-firmware.
#define ra8_log_info_val(tag, message, value)
RA8 log info val.
Ref-counted Module Stop Control wrapper for the RA8D2.
ra8_err_t ra8_mstp_enable(ra8_mstp_t id)
Reference-counted "ungate this peripheral" request.
ra8_err_t ra8_mstp_disable(ra8_mstp_t id)
Reference-counted "gate this peripheral" request.
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.
ra8_mstp_t priv_mstp(ra8_usb_speed_t speed)
Resolve the per-speed MSTP id.
volatile r_usb_regs_t * priv_pick(ra8_usb_speed_t speed)
Resolve the per-speed register pointer.
Native USB controller driver public API (device + host modes).
void(* ra8_usb_event_fn_t)(void *ctx, ra8_usb_speed_t speed, uint16_t status_mask)
USB event callback signature.
ra8_usb_speed_t
Selects which controller instance the call targets.
@ k_ra8_usb_speed_hs
High-Speed controller (USBHS @ 0x40351000).
@ k_ra8_usb_speed_fs
Full-Speed controller (USBFS @ 0x40250000).
Cross-TU surface for the ra8_usb driver split.
ra8_err_t priv_usbhs_phy_bringup(volatile r_usb_regs_t *reg)
USBHS embedded-PHY bring-up (HUM Figure 37.2 p 2121).
@ k_ra8_usb_byte_bits
Bits per byte (shift constant).
@ k_ra8_usb_dcp_max_packet
EP0 default packet size.
ra8_usb_dvstctr_bit_t
DVSTCTR0 host-mode bit positions (HUM Ch 36.2.5 "DVSTCTR0").
@ k_ra8_dvstctr_bit_usbrst
Bus reset signal (host).
@ k_ra8_dvstctr_bit_rwupe
Remote-wake detect enable (host).
@ k_ra8_dvstctr_bit_uact
Bus enable (host SOF generation).
@ k_ra8_dvstctr_bit_vbusen
External VBUS-switch enable (HS).
@ k_ra8_dvstctr_bit_resume
Resume signal output (host).
uint16_t ra8_usb_intsts0_snapshot(ra8_usb_speed_t speed)
Implementation of ra8_usb_intsts0_snapshot().
static ra8_err_t internal_host_hs_bringup(volatile r_usb_regs_t *reg)
Bring the USBHS instance up in HOST role (PHY + SYSCFG bits).
static void * s_usb_ctx[k_ra8_usb_cb_slot_n]
@ k_ra8_usb_cb_slot_hs
RA8 USB cb slot hs.
@ k_ra8_usb_cb_slot_n
RA8 USB cb slot n.
@ k_ra8_usb_cb_slot_fs
RA8 USB cb slot fs.
ra8_err_t ra8_usb_host_bus_reset(ra8_usb_speed_t speed, bool assert_reset)
Implementation of ra8_usb_host_bus_reset().
static uint8_t internal_cb_slot(ra8_usb_speed_t speed)
Map a USB speed enum to the per-controller callback slot index.
void ra8_usb_dispatch(ra8_usb_speed_t speed)
Implementation of ra8_usb_dispatch().
ra8_err_t ra8_usb_exit_stop(ra8_usb_speed_t speed)
Implementation of ra8_usb_exit_stop().
static uint16_t internal_host_syscfg_word(ra8_usb_speed_t speed)
Build the host-mode SYSCFG word.
ra8_err_t ra8_usb_host_init(ra8_usb_speed_t speed)
Implementation of ra8_usb_host_init().
ra8_err_t ra8_usb_host_deinit(ra8_usb_speed_t speed)
Implementation of ra8_usb_host_deinit().
static ra8_usb_event_fn_t s_usb_fn[k_ra8_usb_cb_slot_n]
ra8_err_t ra8_usb_enter_stop(ra8_usb_speed_t speed)
Implementation of ra8_usb_enter_stop().
ra8_err_t ra8_usb_host_setup_request(ra8_usb_speed_t speed, const ra8_usb_setup_t *setup)
Implementation of ra8_usb_host_setup_request().
void ra8_usb_attach_handler(ra8_usb_speed_t speed, ra8_usb_event_fn_t fn, void *ctx)
Install (or detach) the per-controller USB event handler.
ra8_err_t ra8_usb_host_set_uact(ra8_usb_speed_t speed, bool enable)
Implementation of ra8_usb_host_set_uact().
static void internal_host_init_defaults(volatile r_usb_regs_t *reg)
Program the host-mode FIFO / DCP / interrupt-enable defaults.
USB Full-Speed + High-Speed controller layout for the Renesas RA8D2.
@ k_ra8_syscfg_bit_usbe
USB module enable.
@ k_ra8_syscfg_bit_cnen
Single-end receiver enable.
@ k_ra8_syscfg_bit_hse
HS enable (HS instance only).
@ k_ra8_syscfg_bit_drpd
D+/D- pull-down (host).
@ k_ra8_syscfg_bit_dcfm
1 = host mode, 0 = device.
@ k_ra8_syscfg_bit_scke
USB clock enable.
@ k_ra8_dcpctr_bit_sureq
Send USB request (host mode).
@ k_ra8_fifosel_mbw_16
16-bit FIFO access width.
@ k_ra8_int0_bit_bemp
Buffer-empty interrupt.
@ k_ra8_int0_bit_dvst
Device-state transition.
@ k_ra8_int0_bit_brdy
Buffer-ready interrupt.
@ k_ra8_int0_bit_ctrt
Control-transfer-stage transition.
@ k_ra8_int0_bit_sofr
Start-of-Frame.
@ k_ra8_int0_bit_vbse
VBUS change.
@ k_ra8_int0_bit_nrdy
Buffer-not-ready interrupt.
@ k_ra8_int0_bit_rsme
Resume.
USB FS / HS register window (device-mode subset).
volatile uint16_t USBINDX
+0x058 USB Request wIndex.
volatile uint16_t NRDYENB
+0x038 NRDY Interrupt Enable.
volatile uint16_t DCPCTR
+0x060 DCP Control.
volatile uint16_t USBVAL
+0x056 USB Request wValue.
volatile uint16_t CFIFOSEL
+0x020 Control FIFO select.
volatile uint16_t DCPMAXP
+0x05E DCP Max Packet.
volatile uint16_t USBADDR
+0x050 USB Address.
volatile uint16_t INTENB0
+0x030 Interrupt Enable 0.
volatile uint16_t INTSTS0
+0x040 Interrupt Status 0.
volatile uint16_t USBLENG
+0x05A USB Request wLength.
volatile uint16_t SYSCFG
+0x000 System Configuration.
volatile uint16_t DVSTCTR0
+0x008 Device State Control.
volatile uint16_t BRDYENB
+0x036 BRDY Interrupt Enable.
volatile uint16_t INTENB1
+0x032 Interrupt Enable 1.
volatile uint16_t DCPCFG
+0x05C DCP Configuration.
volatile uint16_t D0FIFOSEL
+0x028 DMA FIFO 0 select.
volatile uint16_t BEMPENB
+0x03A BEMP Interrupt Enable.
volatile uint16_t D1FIFOSEL
+0x02C DMA FIFO 1 select.
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.