ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
usb_msc_mram_hs_steps.h File Reference

Synthesized FAT16 volume helpers for the USB-HS MRAM MSC demo. More...

#include <stdint.h>
#include "tx_api.h"
#include "ux_api.h"
Include dependency graph for usb_msc_mram_hs_steps.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Enumerations

enum  demo_config_t : uint32_t {
  k_demo_thread_stack = 4096U ,
  k_demo_usbx_pool_bytes = 32768U ,
  k_demo_block_size = 512U ,
  k_demo_idle_ticks = 50U
}
 Compile-time settings for the worker thread + USBX pool + RAM-disk geometry. More...
enum  demo_fat_geom_t : uint32_t {
  k_fat_reserved_sectors = 1U ,
  k_fat_num_fats = 1U ,
  k_fat_fat_sectors = 17U ,
  k_fat_root_entries = 512U ,
  k_fat_root_sectors = 32U ,
  k_fat_data_sectors = 4096U ,
  k_fat_fat_lba = 1U ,
  k_fat_root_lba = 18U ,
  k_fat_data_lba = 50U ,
  k_fat_total_sectors = 4146U ,
  k_fat_first_cluster = 2U ,
  k_fat_mram_clusters = 2048U ,
  k_fat_last_mram_clus = 2049U ,
  k_fat_entries_per_sec = 256U ,
  k_fat_eoc = 0xFFFFU ,
  k_fat_entry0 = 0xFFF8U
}
 Synthesized FAT16 volume geometry (MS FAT spec 1.03). More...

Functions

void demo_fat_fill_sector (uint32_t lba, UCHAR *out)
 Synthesize one 512-byte sector of the read-only volume.

Detailed Description

Synthesized FAT16 volume helpers for the USB-HS MRAM MSC demo.

Tag
[Ring 6 / APP] {World: S}

Declares the read-only FAT16 sector-synthesis API shared between the application entry (main.c) and its implementation sibling (usb_msc_mram_hs_steps.c). The volume's boot sector, FAT, and root directory are generated on the fly; data clusters map 1:1 onto the chip's 1 MiB MRAM window at 0x02000000, exposed as a single root file MRAM.BIN. Only demo_fat_fill_sector() is called from the MSC media-read callback in main.c; the lower-level fillers stay private to the sibling. The shared geometry/config enums live here so both translation units agree on the volume layout and block size.

Author
Brighton Sikarskie
Date
2026-05-02
Since
0.1.0

Definition in file usb_msc_mram_hs_steps.h.

Enumeration Type Documentation

◆ demo_config_t

enum demo_config_t : uint32_t

Compile-time settings for the worker thread + USBX pool + RAM-disk geometry.

Enumerator
k_demo_thread_stack 

Worker thread stack (bytes).

k_demo_usbx_pool_bytes 

USBX memory pool (bytes).

k_demo_block_size 

SCSI logical block size (bytes).

k_demo_idle_ticks 

Heartbeat back-off (ThreadX ticks).

Definition at line 35 of file usb_msc_mram_hs_steps.h.

◆ demo_fat_geom_t

enum demo_fat_geom_t : uint32_t

Synthesized FAT16 volume geometry (MS FAT spec 1.03).

One 512-byte sector per cluster. The data region is padded to 4096 clusters so the cluster count crosses the 4085 FAT16 threshold; only the first 2048 clusters (1 MiB) are backed by MRAM, and nothing references the rest. FAT16 needs 2 bytes per entry for 4098 entries = 8196 bytes = 17 sectors. The root directory holds 512 entries = 32 sectors.

Enumerator
k_fat_reserved_sectors 

Boot sector only.

k_fat_num_fats 

Single FAT copy.

k_fat_fat_sectors 

FAT16 size for 4098 entries.

k_fat_root_entries 

Root directory entries.

k_fat_root_sectors 

512 entries x 32 B / 512 B.

k_fat_data_sectors 

Padded data region (>= 4085).

k_fat_fat_lba 

First FAT sector.

k_fat_root_lba 

First root-directory sector.

k_fat_data_lba 

First data sector (cluster 2).

k_fat_total_sectors 

1 + 17 + 32 + 4096.

k_fat_first_cluster 

FAT data area starts at cluster 2.

k_fat_mram_clusters 

Clusters backed by MRAM (1 MiB).

k_fat_last_mram_clus 

Last cluster of MRAM.BIN.

k_fat_entries_per_sec 

FAT16 entries per 512-byte sector.

k_fat_eoc 

End-of-chain marker.

k_fat_entry0 

FAT[0]: media F8 + filler.

Definition at line 53 of file usb_msc_mram_hs_steps.h.

Function Documentation

◆ demo_fat_fill_sector()

void demo_fat_fill_sector ( uint32_t lba,
UCHAR * out )

Synthesize one 512-byte sector of the read-only volume.

Dispatches on the LBA: boot sector, FAT, root directory, or data region. Data sectors inside the MRAM.BIN chain are copied straight out of the 1 MiB MRAM window; padding clusters past the chain read as zeros.

Parameters
[in]lbaLogical block address inside the volume.
[out]out512-byte destination buffer.
Precondition
lba is below k_fat_total_sectors (caller-checked).
out has 512 writable bytes.
Postcondition
out holds the synthesized sector content.
No other state changes.
Note
Reads chip MRAM directly; no caching.
Since
0.1.0

Definition at line 199 of file usb_msc_mram_steps.c.

References demo_fat_fill_boot(), demo_fat_fill_fat(), demo_fat_fill_root(), k_demo_block_size, k_fat_data_lba, k_fat_fat_lba, k_fat_first_cluster, k_fat_last_mram_clus, k_fat_root_lba, k_mram_base_addr, memcpy(), and memset().