59#include "ux_device_class_storage.h"
60#include "ux_device_stack.h"
420 return _ux_device_stack_initialize((UCHAR*)UX_NULL,
453 UX_SLAVE_CLASS_STORAGE_PARAMETER msc_params;
454 (void)
memset(&msc_params, 0,
sizeof(msc_params));
455 msc_params.ux_slave_class_storage_parameter_number_lun = 1UL;
456 msc_params.ux_slave_class_storage_parameter_vendor_id =
s_msc_vendor_id;
460 msc_params.ux_slave_class_storage_parameter_lun[0].ux_slave_class_storage_media_last_lba =
462 msc_params.ux_slave_class_storage_parameter_lun[0].ux_slave_class_storage_media_block_length =
464 msc_params.ux_slave_class_storage_parameter_lun[0].ux_slave_class_storage_media_type =
465 UX_SLAVE_CLASS_STORAGE_MEDIA_FAT_DISK;
466 msc_params.ux_slave_class_storage_parameter_lun[0].ux_slave_class_storage_media_removable_flag =
467 UX_SLAVE_CLASS_STORAGE_MEDIA_IS_REMOVABLE;
468 msc_params.ux_slave_class_storage_parameter_lun[0].ux_slave_class_storage_media_read_only_flag =
470 msc_params.ux_slave_class_storage_parameter_lun[0].ux_slave_class_storage_media_read =
472 msc_params.ux_slave_class_storage_parameter_lun[0].ux_slave_class_storage_media_write =
474 msc_params.ux_slave_class_storage_parameter_lun[0].ux_slave_class_storage_media_status =
477 static UCHAR s_class_name[] =
"ux_slave_class_storage";
479 return _ux_device_stack_class_register(s_class_name,
480 _ux_device_class_storage_entry,
525 if (ux != UX_SUCCESS) {
532 if (ux != UX_SUCCESS) {
static UCHAR s_msc_product_id[]
static UCHAR s_string_framework[]
USBX string descriptor table (vendor / product / serial).
@ k_scsi_ascq_none
ASCQ: none.
@ k_scsi_sense_illegal_request
Sense key: ILLEGAL REQUEST.
@ k_scsi_asc_lba_out_of_range
ASC: LBA out of range.
static volatile uint32_t s_dbg_write_blocks
Total 512-B blocks the device media_write callback stored.
static volatile uint32_t s_dbg_write_calls
Device-side media_write invocations (WRITE(10) data received).
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 volatile uint32_t s_dbg_dev_step
Device worker progress: 1 stack, 2 class, 3 dcd, 4 attach, 5 parked.
static volatile uint32_t s_dbg_dev_err
Device worker first failing return code (0 = none).
static UCHAR s_msc_vendor_id[]
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.
@ k_ra8_board_led2
LED2, GREEN, P303 (jumper E26).
@ k_ra8_board_led1
LED1, BLUE, P600 (jumper E27).
Error Code Definitions for ra8-firmware.
@ k_ra8_err_invalid_state
Module in wrong state for requested operation.
@ 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.
SD card driver in SPI-mode (PMOD-attached cards).
ra8_err_t ra8_sdmmc_spi_read_blocks(uint32_t lba, uint8_t *buf, uint32_t count)
Read count contiguous 512-byte blocks in one CMD18 transaction.
ra8_err_t ra8_sdmmc_spi_write_blocks(uint32_t lba, const uint8_t *buf, uint32_t count)
Write count contiguous 512-byte blocks in one CMD25 transaction.
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).
unsigned long ULONG
ThreadX-compatible unsigned long (host stub).
static UINT sdmsc_usbx_stack_up(void)
Bring USBX system + device stack up with the MSC framework.
VOID sdmsc_device_worker(ULONG arg)
Device worker: bring the live-SD read/write MSC device up, then park.
static UINT sdmsc_class_register(void)
Register the Mass-Storage class with one writable live-SD LUN.
static UINT sdmsc_msc_read(VOID *storage, ULONG lun, UCHAR *data_pointer, ULONG number_blocks, ULONG lba, ULONG *media_status)
Storage media-read callback: stream blocks off the live SD card.
static volatile uint32_t s_dbg_media_err
First failing SD driver error on the media path (0 = none).
static volatile uint32_t s_dbg_read_blocks
Total 512-B blocks served to the host by media_read.
static ra8_err_t sdmsc_print_ready(void)
Print the READY banner: "usb_msc_sdcard: USB MSC SDCARD READY ...".
static UINT sdmsc_msc_status(VOID *storage, ULONG lun, ULONG media_id, ULONG *media_status)
Storage media-status callback.
static UINT sdmsc_msc_write(VOID *storage, ULONG lun, UCHAR *data_pointer, ULONG number_blocks, ULONG lba, ULONG *media_status)
Storage media-write callback: commit host data to the live SD card.
examples/ek_ra8d2/hw_pending/manual/usb_msc_sdcard/inc/usb_msc_sdcard_steps.h
ra8_err_t sdmsc_print(const char *text)
Print a NUL-terminated ASCII string over the SCI8 console.
@ k_sdmsc_dev_step_class
MSC class registered.
@ k_sdmsc_dev_step_dcd
DCD bridge initialized.
@ k_sdmsc_dev_step_parked
Bring-up done; worker parked.
@ k_sdmsc_dev_step_attach
Device attached (DPRPU).
@ k_sdmsc_dev_step_stack
USBX system + device stack up.
ra8_err_t sdmsc_print_dec(uint32_t value)
Print a uint32_t as ASCII decimal over the SCI8 console.
@ k_scsi_asc_unrecovered_read
ASC: unrecovered read error.
@ k_scsi_sense_medium_error
Sense key: MEDIUM ERROR.
@ k_scsi_asc_write_fault
ASC: peripheral dev write fault.
volatile uint32_t s_usb_msc_sdcard_blocks
Live SD card capacity in 512-byte blocks (0 = no card).
ra8_err_t sdmsc_print_fail(const char *what, ra8_err_t err)
Print "FAIL <what> err=0xNNNNNNNN" on its own console line.
@ k_sdmsc_idle_ticks
Parked-loop back-off (ticks).
@ k_sdmsc_block_size
SCSI logical block size (bytes).
@ k_sdmsc_usbx_pool_bytes
USBX memory pool (bytes).
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.