69#include "ux_device_class_storage.h"
70#include "ux_device_stack.h"
114typedef enum : uint8_t {
121typedef enum : uint8_t {
126#ifndef RA8_OFF_TARGET
302typedef enum : uint8_t {
365 for (
ULONG i = 0UL; i < number_blocks; i++) {
461 return _ux_device_stack_initialize((UCHAR*)UX_NULL,
488 UX_SLAVE_CLASS_STORAGE_PARAMETER msc_params;
489 (void)
memset(&msc_params, 0,
sizeof(msc_params));
490 msc_params.ux_slave_class_storage_parameter_number_lun = 1UL;
491 msc_params.ux_slave_class_storage_parameter_vendor_id =
s_msc_vendor_id;
495 msc_params.ux_slave_class_storage_parameter_lun[0].ux_slave_class_storage_media_last_lba =
497 msc_params.ux_slave_class_storage_parameter_lun[0].ux_slave_class_storage_media_block_length =
499 msc_params.ux_slave_class_storage_parameter_lun[0].ux_slave_class_storage_media_type =
500 UX_SLAVE_CLASS_STORAGE_MEDIA_FAT_DISK;
501 msc_params.ux_slave_class_storage_parameter_lun[0].ux_slave_class_storage_media_removable_flag =
502 UX_SLAVE_CLASS_STORAGE_MEDIA_IS_REMOVABLE;
503 msc_params.ux_slave_class_storage_parameter_lun[0].ux_slave_class_storage_media_read_only_flag =
505 msc_params.ux_slave_class_storage_parameter_lun[0].ux_slave_class_storage_media_read =
507 msc_params.ux_slave_class_storage_parameter_lun[0].ux_slave_class_storage_media_write =
509 msc_params.ux_slave_class_storage_parameter_lun[0].ux_slave_class_storage_media_status =
512 static UCHAR s_class_name[] =
"ux_slave_class_storage";
514 return _ux_device_stack_class_register(s_class_name,
515 _ux_device_class_storage_entry,
563 (void)first_unused_memory;
593 __asm__
volatile(
"wfi");
642 uint32_t cpuclk0_hz = 0U;
671#ifndef RA8_OFF_TARGET
void main(void)
Secure fallback main entry point.
static TX_THREAD s_demo_thread
@ 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.
void _tx_timer_interrupt(void)
void SysTick_Handler(void)
SysTick exception handler – tail-calls the ThreadX timer.
static UCHAR s_msc_product_id[]
static UCHAR s_string_framework[]
USBX string descriptor table (vendor / product / serial).
scsi_sense_code_t
SCSI sense triple for an unsupported / out-of-range request.
@ k_scsi_ascq_none
ASCQ: none.
@ k_scsi_asc_write_protected
ASC: WRITE PROTECTED.
@ k_scsi_sense_illegal_request
Sense key: ILLEGAL REQUEST.
@ k_scsi_sense_data_protect
Sense key: DATA PROTECT.
@ k_scsi_asc_lba_out_of_range
ASC: LBA out of range.
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_msc_product_rev[]
static UCHAR s_language_id_framework[]
USBX language-id table – US English.
static volatile uint32_t s_dbg_read_calls
Device-side media_read invocations.
static UCHAR s_msc_vendor_id[]
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 UINT demo_usbx_stack_up(void)
Brings USBX system + device stack up with the FS framework.
@ 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 UINT demo_msc_read(VOID *storage, ULONG lun, UCHAR *data_pointer, ULONG number_blocks, ULONG lba, ULONG *media_status)
Storage media-read callback.
static UINT demo_msc_status(VOID *storage, ULONG lun, ULONG media_id, ULONG *media_status)
Storage media-status callback.
static UINT demo_msc_class_register(void)
Registers the Mass-Storage class with one LUN backed by s_ramdisk.
@ k_demo_block_size
SCSI logical block size (bytes).
static UINT demo_msc_write(VOID *storage, ULONG lun, UCHAR *data_pointer, ULONG number_blocks, ULONG lba, ULONG *media_status)
Storage media-write callback.
static volatile uint32_t s_dbg_read_last_lba
Most recent starting LBA.
static volatile uint32_t s_dbg_read_last_n
Most recent block count.
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.
void * memset(void *dst, int value, size_t n)
Fill memory with a constant byte value.
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).
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.
void ux_dcd_ra8_usb_irq_reenable(void)
Storm-guard recovery: zero the run counter and re-enable the USB IRQ.
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.
void ra8_time_on_tick(void)
SysTick IRQ handler – called from the vector table.
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.
scsi_wp_sense_t
SCSI sense triple for a write to the protected medium.
@ k_fat_total_sectors
1 + 17 + 32 + 4096.
Shared geometry constants + FAT16 sector-synthesis prototype.
void demo_fat_fill_sector(uint32_t lba, UCHAR *out)
Synthesize one 512-byte sector of the read-only volume.
USBX device-controller-driver (DCD) bridge to ra8_usb.
ra8_err_t ux_dcd_ra8_usb_initialize(ra8_usb_speed_t speed)
Register the ra8_usb bridge as the active USBX DCD.