36#include "ux_device_stack.h"
38#include "ux_utility.h"
57typedef enum : uint16_t {
79typedef enum : uint8_t {
198typedef enum : uint8_t {
229 return (
unsigned long)UX_DEVICE_SUSPENDED;
233 return (
unsigned long)UX_DEVICE_ATTACHED;
235 return (
unsigned long)UX_DEVICE_ADDRESSED;
237 return (
unsigned long)UX_DEVICE_CONFIGURED;
240 return (
unsigned long)UX_DEVICE_ATTACHED;
264 const uint8_t dvst_slot =
267 if (_ux_system_slave != UX_NULL) {
268 entry_state = (uint8_t)(_ux_system_slave->ux_system_slave_device.ux_slave_device_state &
326 if (new_state == (
unsigned long)UX_DEVICE_SUSPENDED) {
328 }
else if (new_state > device->ux_slave_device_state) {
331 (void)_ux_device_stack_disconnect();
378 if (_ux_system_slave == UX_NULL) {
381 UX_SLAVE_DEVICE* device = &_ux_system_slave->ux_system_slave_device;
391 device->ux_slave_device_state = new_state;
392 if (_ux_system_slave->ux_system_slave_change_function != UX_NULL) {
393 (void)_ux_system_slave->ux_system_slave_change_function(new_state);
432 if (_ux_system_slave == UX_NULL) {
436 _ux_system_slave->ux_system_slave_speed = UX_FULL_SPEED_DEVICE;
437 _ux_system_slave->ux_system_slave_device_framework =
438 _ux_system_slave->ux_system_slave_device_framework_full_speed;
439 _ux_system_slave->ux_system_slave_device_framework_length =
440 _ux_system_slave->ux_system_slave_device_framework_length_full_speed;
442 _ux_system_slave->ux_system_slave_speed = UX_HIGH_SPEED_DEVICE;
443 _ux_system_slave->ux_system_slave_device_framework =
444 _ux_system_slave->ux_system_slave_device_framework_high_speed;
445 _ux_system_slave->ux_system_slave_device_framework_length =
446 _ux_system_slave->ux_system_slave_device_framework_length_high_speed;
476 const uint16_t dvstctr0 = reg->
DVSTCTR0;
482 const uint8_t rhst = (uint8_t)(dvstctr0 & rhst_mask);
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
Validation and Error-Checking Macros for ra8-firmware.
Event Link Controller (ELC) register layout for the Renesas RA8D2.
NVIC + ICU IELSR allocator.
Lightweight Logging Interface for ra8-firmware.
ra8_usb_speed_t
Selects which controller instance the call targets.
@ k_ra8_usb_speed_hs
High-Speed controller (USBHS @ 0x40351000).
USB Full-Speed + High-Speed controller layout for the Renesas RA8D2.
static volatile r_usb_regs_t * ra8_usb_hs(void)
Get pointer to the USB HS controller register block.
@ k_ra8_intsts0_mask_dvsq
Device state.
@ k_ra8_dvsq_suspend
Suspended (any sub-state).
@ k_ra8_dvsq_address
Address assigned.
@ k_ra8_dvsq_default
Default (post bus reset).
@ k_ra8_dvsq_configured
Configured.
@ k_ra8_dvsq_powered
Powered (no reset yet).
static volatile r_usb_regs_t * ra8_usb_fs(void)
Compile-time offset and size insurance for r_usb_regs_t.
USB FS / HS register window (device-mode subset).
volatile uint16_t DVSTCTR0
+0x008 Device State Control.
USBX device-controller-driver (DCD) bridge to ra8_usb.
ra8_usb_dcd_sentinel_t
"Not yet captured" sentinel for 16-bit register snapshots.
@ k_ra8_usb_u16_unset
Snapshot has not been latched yet.
static bool internal_dvst_policy_apply(UX_SLAVE_DEVICE *device, uint16_t dvsq, unsigned long new_state)
DVSQ mirror policy: may new_state be written into USBX?
static void internal_handle_dvst(ra8_usb_speed_t speed, uint16_t intsts0)
Handle the DVST (device-state-changed) interrupt branch.
volatile uint16_t g_dvstctr0_at_first_dvst
Snapshot of DVSTCTR0 (RHST field) on first DVST event.
volatile uint32_t g_dvst_state_history_count
Total DVST events recorded into g_dvst_state_history.
static unsigned long internal_dvst_map_dvsq_to_ux_state(uint16_t dvsq)
Map a DVSQ-bits-4..6 value to the USBX device-state enum.
ra8_usb_dcd_rhst_hist_t
Sizing for the DVSTCTR0.RHST history ring.
@ k_ra8_usb_dcd_rhst_hist_n
Slots in g_rhst_history.
static void internal_dvst_track_speed(uint8_t rhst)
Mirror the negotiated link speed from DVSTCTR0.RHST into USBX.
volatile uint32_t g_dvstctr0_history_count
Total dispatch ticks observed; modulo k_ra8_usb_dcd_rhst_hist_n is the next write slot in g_dvstctr0_...
volatile uint32_t g_dvst_irq_count
Counter of INTSTS0.DVST (device-state-transition) events.
volatile uint16_t g_intsts1_history[(uint32_t) k_ra8_usb_dcd_rhst_hist_n]
Per-dispatch-tick capture of the full INTSTS1 register.
static void internal_dvst_record_history(uint16_t dvsq)
Record one DVST event into the JLink-readable causal history.
ra8_usb_dcd_rhst_t
DVSTCTR0.RHST[2:0] settled link-speed encodings.
@ k_ra8_usb_rhst_fs
Full speed settled.
@ k_ra8_usb_rhst_hs
High speed settled.
volatile uint8_t g_rhst_history[(uint32_t) k_ra8_usb_dcd_rhst_hist_n]
Per-DVST-event capture of DVSTCTR0.RHST[2:0].
volatile uint32_t g_rhst_history_count
Total DVST events seen; modulo k_ra8_usb_dcd_rhst_hist_n is the next write slot.
void priv_irq_dvst_prelude(ra8_usb_speed_t speed, uint16_t intsts0)
Capture DVSTCTR0 / RHST history, mirror speed, dispatch DVST.
volatile uint16_t g_dvstctr0_history[(uint32_t) k_ra8_usb_dcd_rhst_hist_n]
Per-dispatch-tick capture of the full DVSTCTR0 register.
volatile uint8_t g_dvst_state_history[(uint32_t) k_ra8_usb_dcd_rhst_hist_n]
Per-DVST-event capture of the decoded DVSQ[2:0] field.
USBX device-controller-driver bridge to ra8_usb – per-module cross-translation-unit contract.
volatile uint64_t g_last_dispatched_setup_fp
64-bit fingerprint of the last dispatched SETUP packet.
void priv_trace_event(uint8_t kind, uint8_t code, uint16_t length)
Append one packed event to the JLink-readable trace ring.
@ k_ra8_int0_dvsq_shift
DVSQ[2:0] field starts at bit 4.
@ k_dcd_trace_nib_shift
High-nibble shift.
@ k_dcd_trace_nibble
Low-nibble mask for packed bytes.
@ k_dcd_trace_kind_dvst
DVST event (code = dvsq|state).
void priv_dvst_default_state(ra8_usb_speed_t speed)
Process the DVSQ=Default branch of the DVST handler.
@ k_ra8_usb_dvsq_field_mask
3-bit DVSQ/RHST field after shift.