SaturnRingLibrary 0.9.2
SGL wrapper
Loading...
Searching...
No Matches
SRL::DevCart::CS0 Namespace Reference

Detailed Description

CS0 area: Flash memory and USB-related registers This namespace groups constants and functions for accessing the cartridge's CS0 memory space, which includes flash memory and USB communication registers (likely for a Sega Saturn USB dev cart). Addresses are memory-mapped I/O; accesses should use volatile pointers to prevent optimization issues.

Namespaces

namespace  SDCardRegisters
 Registers for controlling the SD card on the development cartridge These registers are mapped in the CS0 memory space.

Classes

struct  USBFlags
 Struct containing the USB flags register bits and masks. More...

Functions

static bool IsConnected ()
 Checks if the USB device is connected and ready This function checks the UsbFlags register. It assumes the device is connected if the reserved bits (those not in AllFlags) are all zero. This is a common way to detect hardware presence on embedded systems.
static bool IsPortAvailable ()
 Returns true when USB dev cart flag register pattern looks valid.
static bool IsRxfEmpty ()
 Checks if the Receive FIFO (Rxf) is empty Reads the UsbFlags register and checks the Rxf bit. The FIFO is considered empty while Rxf is set.
static bool IsTxeFull ()
 Checks if the Transmit FIFO Empty (Txe) flag is set Reads the UsbFlags register and tests the Txe bit. When the Txe bit is set, the transmit FIFO is full and cannot accept new data. The function name IsTxeFull is accurate in this context, though Txe often means "Transmit Empty" in other hardware.
static uint8_t Read ()
 Reads a single byte from the USB FIFO This function waits until data is available in the receive FIFO (WaitRxf()) and then reads a single byte.
static uint8_t ReadFlags ()
 Reads the raw UsbFlags register value.
static bool WaitRxf (uint32_t maxPolls=0)
 Waits until data is available in the receive FIFO, with timeout Polls IsRxfEmpty() until it returns false. If maxPolls is non-zero and reached first, the function returns false to signal timeout.
static bool WaitTxe (uint32_t maxPolls=0)
 Waits until the Transmit FIFO is ready, with timeout Polls IsTxeFull() until it returns false. If maxPolls is non-zero and reached first, the function returns false to signal timeout.
static size_t Write (const uint8_t *c)
 Writes a single byte to the USB FIFO This function waits until the transmit FIFO is not full (WaitTxe()) and then writes a single byte to the FIFO.
static size_t Write (const uint8_t *c, size_t size)
 Writes a sequence of bytes to the USB FIFO This function iterates through the buffer, calling Write() for each byte.

Variables

static constexpr uintptr_t CartBaseAdr = 0x22000000UL
 Base address of the cartridge in CS0 area This is the starting point for flash and USB registers (overlaps with DataCart in srl_cartridge.hpp).
static constexpr uintptr_t CartHwver = CartBaseAdr + 0x1FFFFF6UL
 Address of the Wasca hardware version register major/minor (e.g. 0x050C = v5.12).
static constexpr uintptr_t CartPcntr = CartBaseAdr + 0x1FFFFF0UL
 Address of the Wasca Prepare counter register.
static constexpr uintptr_t CartSignature = CartBaseAdr + 0x1FFFFFAUL
 Address of the Signature register ("wasca " in ASCII: 0x7761 0x7363 0x6120).
static constexpr uintptr_t CartStatus = CartBaseAdr + 0x1FFFFF2UL
 Address of the Wasca Status register.
static constexpr size_t FirmMaxlen = 1024 * 1024
 Maximum length allowed for firmware uploads (matches flash size).
static constexpr uintptr_t FlashMemoryBase = CartBaseAdr + 0x0
 Base address of the flash memory (1MB region).
static constexpr uintptr_t UsbFifo = CartBaseAdr + 0x100001
 Address of the USB FIFO data register (8-bit Read/Write) Used for sending/receiving bytes over USB.
static constexpr uintptr_t USBFlagsAdr = CartBaseAdr + 0x200001UL
 Address of the USB flags register (8-bit Read/Write) This register holds status flags for USB FIFO operations (Rxf, Txe, Pwren).