84#include "ux_device_class_cdc_acm.h"
85#include "ux_device_stack.h"
118typedef enum : uint32_t {
125#ifndef RA8_OFF_TARGET
166 volatile uint32_t loop_iter;
167 volatile uint32_t loop_cdc_null;
168 volatile uint32_t loop_pre_read;
169 volatile uint32_t loop_post_read;
170 volatile uint32_t loop_read_ok;
171 volatile uint32_t loop_read_zero;
172 volatile uint32_t loop_pre_write;
173 volatile uint32_t loop_post_write;
393typedef enum : uint8_t {
422 s_cdc_acm = (UX_SLAVE_CLASS_CDC_ACM*)cdc_instance;
429 if (_ux_system_slave != UX_NULL) {
430 _ux_system_slave->ux_system_slave_device.ux_slave_device_state =
431 (
unsigned long)UX_DEVICE_CONFIGURED;
486 return _ux_device_stack_initialize((UCHAR*)UX_NULL,
513 UX_SLAVE_CLASS_CDC_ACM_PARAMETER cdc_params = {
516 .ux_slave_class_cdc_acm_parameter_change = UX_NULL,
518 static UCHAR s_class_name[] =
"ux_slave_class_cdc_acm";
520 return _ux_device_stack_class_register(s_class_name,
521 _ux_device_class_cdc_acm_entry,
545 if (_ux_system_slave != UX_NULL) {
546 _ux_system_slave->ux_system_slave_device.ux_slave_device_state =
547 (
unsigned long)UX_DEVICE_CONFIGURED;
570 UINT read_status = _ux_device_class_cdc_acm_read(
s_cdc_acm, buf, cap, &n);
572 if (read_status != UX_SUCCESS) {
582 if (_ux_device_class_cdc_acm_write(
s_cdc_acm, buf, n, &n) != UX_SUCCESS) {
586 for (
ULONG i = 0UL; i < n; i++) {
656 static CHAR s_semaphore_name[] =
"cdc_active";
659 (void)first_unused_memory;
690 __asm__
volatile(
"wfi");
745 uint32_t cpuclk0_hz = 0U;
776 ra8_log_info(
"USBCDC",
"usb_cdc_echo boot, CGC PLL2 enable OK");
780#ifndef RA8_OFF_TARGET
void main(void)
Secure fallback main entry point.
static TX_THREAD s_demo_thread
demo_config_t
Compile-time settings for the HTTPS client demo.
@ k_demo_thread_stack
Demo thread stack.
static UCHAR s_demo_stack[k_demo_thread_stack]
void tx_application_define(void *first_unused_memory)
ThreadX system-define hook: build worker thread + byte pool.
static UCHAR s_string_framework[]
USBX string descriptor table (vendor / product / serial).
static UCHAR s_usbx_pool[k_wlun_usbx_pool_bytes]
USBX memory pool (USBX uses tx_byte_pool internally).
@ k_usb_langid_en_us_lo
LANGID 0x0409 low byte.
@ k_usb_langid_en_us_hi
LANGID 0x0409 high byte.
static UCHAR s_device_framework_fs[]
static UCHAR s_language_id_framework[]
USBX language-id table – US English.
static void demo_panic_halt(void)
Halt forever in WFI – used as a panic stop on init failure.
static const ra8_port_pin_t k_demo_pin_vbus
USB_FS VBUS pin, packed ra8_port_pin_t.
static ra8_err_t demo_pins_init(void)
Route the four USB-FS pins to the USBFS controller.
static const ra8_port_pin_t k_demo_pin_dp
USB_FS D+ pin, packed ra8_port_pin_t.
static const ra8_port_pin_t k_demo_pin_vbusen
USB_FS VBUSEN pin, packed ra8_port_pin_t.
static const ra8_port_pin_t k_demo_pin_dm
USB_FS D- pin, packed ra8_port_pin_t.
static CHAR s_thread_name[]
static UX_SLAVE_CLASS_CDC_ACM * s_cdc_acm
Active CDC-ACM class instance, captured by the activate callback.
static TX_SEMAPHORE s_cdc_active_sem
Posted by the activate callback so the echo worker blocks on it instead of polling s_cdc_acm with tx_...
static UINT demo_cdc_class_register(void)
Registers the CDC-ACM class against the device-stack configuration.
static UINT demo_usbx_stack_up(void)
Brings USBX system + device stack up with the FS framework.
static void demo_echo_iter(UCHAR *buf, ULONG cap)
One iteration of the CDC echo loop.
volatile demo_diag_t s_demo_diag
Externally-readable counters for demo loop progress.
static VOID demo_cdc_activate(VOID *cdc_instance)
CDC-ACM activate callback.
@ k_demo_echo_buf_bytes
One bulk-FS packet per recv/send.
@ k_demo_idle_ticks
Idle back-off when no class active.
@ k_demo_usbx_pool_bytes
USBX pool: 32 KiB; CDC-ACM enum exhausts 16 KiB.
static VOID demo_worker(ULONG arg)
Worker thread entry.
static VOID demo_cdc_deactivate(VOID *cdc_instance)
CDC-ACM deactivate callback.
static void demo_pin_configured_state(void)
Pin USBX peripheral state at CONFIGURED.
Board-support layer for the Renesas EK-RA8D2 v1 evaluation kit.
ra8_err_t ra8_board_led_toggle(ra8_board_led_id_t led)
Toggle led's output state.
ra8_err_t ra8_board_led_init(ra8_board_led_id_t led)
Configure led as a digital output, initial level low (off).
@ k_ra8_board_led1
LED1, BLUE, P600 (jumper E27).
@ k_ra8_board_usbfs_pin_dm
P8_15 D-.
@ k_ra8_board_usbfs_pin_vbusen
P5_00 VBUSEN GPIO.
@ k_ra8_board_usbfs_pin_vbus
P4_07 VBUS sense.
@ k_ra8_board_usbfs_pin_dp
P8_14 D+.
Boot entry points shared between a vector table and its startup code.
High-level Clock Generation Circuit driver.
ra8_err_t ra8_cgc_get_clock_hz(ra8_clock_id_t id, uint32_t *out_hz)
Query the current frequency of a clock-tree domain.
@ k_ra8_clock_id_cpuclk0
Cortex-M85 CPUCLK0.
ra8_err_t ra8_cgc_init(void)
Configure the clock tree to a safe default.
ra8_err_t ra8_cgc_usbfs_clock_enable(void)
Bring up the USB-FS module clock (USBCKCR / USBCKDIVCR).
Error Code Definitions for ra8-firmware.
@ 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.
PSEL codes for peripheral pin routing on the RA8D2.
@ k_ra8_psel_usb_fs
10011b: USB Full-Speed.
NVIC + ICU IELSR allocator.
void ra8_isr_globals_enable(void)
Globally enable maskable interrupts (PRIMASK = 0).
Lightweight Logging Interface for ra8-firmware.
void ra8_log_init(void)
Initialise the logging backend.
#define ra8_log_info(tag, message)
RA8 log info.
Typed Port / Pin Constants for the RA8D2 IOPORT Module.
ra8_port_pin_t
Packed (port << 8) | pin pin identifier.
@ k_ra8_level_low
Drive or read 0.
High-level GPIO helpers on top of the PORT + PFS register layer.
ra8_err_t ra8_gpio_output_init(ra8_port_pin_t pin, ra8_level_t init_level)
Configure a pin as a digital output and drive it to an initial level.
ra8_err_t ra8_pfs_route_peripheral(ra8_port_pin_t pin, ra8_psel_t psel, const char *owner)
Route a pin to a non-IRQ peripheral function via PFS.PSEL.
SysTick-based tick counter, delay and timestamp helpers.
ra8_err_t ra8_time_init(uint32_t cpu_hz)
Initialise SysTick for a 1 kHz tick interrupt.
Native USB controller driver public API (device + host modes).
ra8_err_t ra8_usb_device_attach(ra8_usb_speed_t speed, bool attached)
Raise / drop the D+ pull-up to advertise the device to the host.
@ k_ra8_usb_speed_fs
Full-Speed controller (USBFS @ 0x40250000).
unsigned int UINT
ThreadX-compatible unsigned int (host stub).
char CHAR
ThreadX-compatible CHAR (host stub).
unsigned long ULONG
ThreadX-compatible unsigned long (host stub).
Opaque thread stand-in for the host build.
Demo-loop counters; read via JLink to localise stalls.
USBX device-controller-driver (DCD) bridge to ra8_usb.
void ux_dcd_ra8_usb_auto_echo_enable(uint8_t out_pipe, uint8_t in_pipe)
Enable ISR-side auto-echo from a bulk OUT pipe to a bulk IN pipe.
ra8_err_t ux_dcd_ra8_usb_initialize(ra8_usb_speed_t speed)
Register the ra8_usb bridge as the active USBX DCD.