Driverlib EPI API
Module: Driverlib (AM13E230X) APIs
Structures
Name |
|
|---|---|
struct |
DL_EPI_AddrMapConfig |
struct |
DL_EPI_GPConfig |
struct |
DL_EPI_SDRAM_Config |
Types
Name |
|
|---|---|
enum |
DL_EPI_MODE { DL_EPI_MODE_GENERAL_PURPOSE = EPI_CFG_MODE_CFG_MODE_GP, DL_EPI_MODE_SDRAM = EPI_CFG_MODE_CFG_MODE_SDRAM, DL_EPI_MODE_HB8 = EPI_CFG_MODE_CFG_MODE_HB8, DL_EPI_MODE_HB16 = EPI_CFG_MODE_CFG_MODE_HB16} |
enum |
DL_EPI_RAM_ADDR { DL_EPI_RAM_ADDR_NOT_MAPPED = EPI_ADDRMAP_ERADR_ADDR_MEM_NO_MAP, DL_EPI_RAM_ADDR_0x60000000 = EPI_ADDRMAP_ERADR_ADDR_MEM_MAP_60000000, DL_EPI_RAM_ADDR_0x80000000 = EPI_ADDRMAP_ERADR_ADDR_MEM_MAP_80000000, DL_EPI_RAM_ADDR_QUAD = EPI_ADDRMAP_ERADR_ADDR_MEM_DUAL_MAP} |
enum |
DL_EPI_PER_ADDR { DL_EPI_PER_ADDR_NOT_MAPPED = EPI_ADDRMAP_EPADR_ADDR_PERIPH_NO_MAP, DL_EPI_PER_ADDR_0xA0000000 = EPI_ADDRMAP_EPADR_ADDR_PERIPH_MAP_60000000, DL_EPI_PER_ADDR_0xC0000000 = EPI_ADDRMAP_EPADR_ADDR_PERIPH_MAP_80000000, DL_EPI_PER_ADDR_QUAD = EPI_ADDRMAP_EPADR_ADDR_PERIPH_DUAL_MAP} |
enum |
DL_EPI_ADDR_SIZE { DL_EPI_ADDR_SIZE_256B = 0x0U, DL_EPI_ADDR_SIZE_64KB = 0x1U, DL_EPI_ADDR_SIZE_16MB = 0x2U, DL_EPI_ADDR_SIZE_256MB = 0x3U} |
enum |
DL_EPI_NBR_SIZE { DL_EPI_NBR_SIZE_BYTE = EPI_RSIZE0_SIZE_SIZE_8_BIT, DL_EPI_NBR_SIZE_HWORD = EPI_RSIZE0_SIZE_SIZE_16_BIT, DL_EPI_NBR_SIZE_WORD = EPI_RSIZE0_SIZE_SIZE_32_BIT} |
enum |
DL_EPI_RD_FIFO_TRIG { DL_EPI_RD_FIFO_TRIG_1 = EPI_FIFOLVL_RDFIFO_FIFOLVL_1_ENTRY_TRIG_READ, DL_EPI_RD_FIFO_TRIG_2 = EPI_FIFOLVL_RDFIFO_FIFOLVL_2_ENTRY_TRIG_READ, DL_EPI_RD_FIFO_TRIG_4 = EPI_FIFOLVL_RDFIFO_FIFOLVL_4_ENTRY_TRIG_READ, DL_EPI_RD_FIFO_TRIG_6 = EPI_FIFOLVL_RDFIFO_FIFOLVL_6_ENTRY_TRIG_READ, DL_EPI_RD_FIFO_TRIG_7 = EPI_FIFOLVL_RDFIFO_FIFOLVL_7_ENTRY_TRIG_READ, DL_EPI_RD_FIFO_TRIG_8 = EPI_FIFOLVL_RDFIFO_FIFOLVL_8_ENTRY_TRIG_READ} |
enum |
DL_EPI_WR_FIFO_TRIG { DL_EPI_WR_FIFO_TRIG_EMPTY = EPI_FIFOLVL_WRFIFO_FIFOLVL_WRFIFO_EMPTY_TRIG_WRITE, DL_EPI_WR_FIFO_TRIG_2SLOTS = EPI_FIFOLVL_WRFIFO_FIFOLVL_2_ENTRY_TRIG_WRITE, DL_EPI_WR_FIFO_TRIG_1SLOT = EPI_FIFOLVL_WRFIFO_FIFOLVL_1_ENTRY_TRIG_WRITE, DL_EPI_WR_FIFO_TRIG_NOTFULL = EPI_FIFOLVL_WRFIFO_FIFOLVL_NOT_FULL_TRIG_WRITE} |
enum |
DL_EPI_GP_DSIZE { DL_EPI_GP_DSIZE_8 = EPI_EPIGPCFG_DSIZE_GPCFG_BUS_SIZE_8, DL_EPI_GP_DSIZE_16 = EPI_EPIGPCFG_DSIZE_GPCFG_BUS_SIZE_16, DL_EPI_GP_DSIZE_24 = EPI_EPIGPCFG_DSIZE_GPCFG_BUS_SIZE_24, DL_EPI_GP_DSIZE_32 = EPI_EPIGPCFG_DSIZE_GPCFG_BUS_SIZE_32} |
enum |
DL_EPI_GP_ASIZE { DL_EPI_GP_ASIZE_NONE = EPI_EPIGPCFG_ASIZE_GPCFG_ADDR_SIZE_NONE, DL_EPI_GP_ASIZE_4 = EPI_EPIGPCFG_ASIZE_GPCFG_ADDR_SIZE_4, DL_EPI_GP_ASIZE_12 = EPI_EPIGPCFG_ASIZE_GPCFG_ADDR_SIZE_12, DL_EPI_GP_ASIZE_20 = EPI_EPIGPCFG_ASIZE_GPCFG_ADDR_SIZE_20} |
enum |
DL_EPI_SDRAM_SIZE { DL_EPI_SDRAM_SIZE_64M = EPI_EPISDRAMCFG_SIZE_SDRAMCFG_SIZE_64MBITS, DL_EPI_SDRAM_SIZE_128M = EPI_EPISDRAMCFG_SIZE_SDRAMCFG_SIZE_128MBITS, DL_EPI_SDRAM_SIZE_256M = EPI_EPISDRAMCFG_SIZE_SDRAMCFG_SIZE_256MBITS, DL_EPI_SDRAM_SIZE_512M = EPI_EPISDRAMCFG_SIZE_SDRAMCFG_SIZE_512MBITS} |
enum |
DL_EPI_SDRAM_FREQ { DL_EPI_SDRAM_FREQ_15M = EPI_EPISDRAMCFG_FREQ_SDRAMCFG_0_TO_15_MHZ, DL_EPI_SDRAM_FREQ_30M = EPI_EPISDRAMCFG_FREQ_SDRAMCFG_15_TO_30_MHZ, DL_EPI_SDRAM_FREQ_50M = EPI_EPISDRAMCFG_FREQ_SDRAMCFG_30_TO_50_MHZ, DL_EPI_SDRAM_FREQ_100M = EPI_EPISDRAMCFG_FREQ_SDRAMCFG_50_TO_100_MHZ} |
Functions
Name |
|
|---|---|
void |
DL_EPI_SDRAM_initParamsSetDefault(DL_EPI_SDRAM_Config * config) |
void |
DL_EPI_SDRAM_init(const DL_EPI_SDRAM_Config * config) |
bool |
DL_EPI_SDRAM_initAndWait(const DL_EPI_SDRAM_Config * config) |
uint32_t |
DL_EPI_SDRAM_calculateRefreshCount(uint32_t epiClkHz, uint32_t numRows, uint32_t refreshPeriodUs) |
void |
DL_EPI_setMode(DL_EPI_MODE mode) |
void |
DL_EPI_SDRAM_configure(uint32_t size, uint32_t freq, uint32_t refresh) |
void |
DL_EPI_setAddressMapRaw(uint32_t ramAddr, uint32_t ramSize, uint32_t perAddr, uint32_t perSize) |
uint32_t |
DL_EPI_readNBRFIFO32(uint32_t count, uint32_t * pBuf) |
uint32_t |
DL_EPI_readNBRFIFO16(uint32_t count, uint16_t * pBuf) |
uint32_t |
DL_EPI_readNBRFIFO8(uint32_t count, uint8_t * pBuf) |
__STATIC_INLINE void |
DL_EPI_enable(void ) |
__STATIC_INLINE void |
DL_EPI_disable(void ) |
__STATIC_INLINE bool |
DL_EPI_isEnabled(void ) |
__STATIC_INLINE uint32_t |
DL_EPI_getStatus(void ) |
__STATIC_INLINE bool |
DL_EPI_isBusy(void ) |
__STATIC_INLINE bool |
DL_EPI_SDRAM_isInitDone(void ) |
__STATIC_INLINE bool |
DL_EPI_SDRAM_isInitializing(void ) |
__STATIC_INLINE bool |
DL_EPI_SDRAM_waitInit(void ) |
__STATIC_INLINE uint32_t |
DL_EPI_getWFIFOAvailableSlots(void ) |
__STATIC_INLINE void |
DL_EPI_waitForReady(void ) |
__STATIC_INLINE void |
DL_EPI_setAddressMap(const DL_EPI_AddrMapConfig * config) |
__STATIC_INLINE void |
DL_EPI_setBaudRate(uint32_t count0, uint32_t count1) |
__STATIC_INLINE void |
DL_EPI_setBaudRate2(uint32_t count0, uint32_t count1) |
__STATIC_INLINE void |
DL_EPI_setupNonBlockingRead0(uint32_t address, DL_EPI_NBR_SIZE size, uint32_t count) |
__STATIC_INLINE void |
DL_EPI_setupNonBlockingRead1(uint32_t address, DL_EPI_NBR_SIZE size, uint32_t count) |
__STATIC_INLINE void |
DL_EPI_cancelNonBlockingRead0(void ) |
__STATIC_INLINE void |
DL_EPI_cancelNonBlockingRead1(void ) |
__STATIC_INLINE uint32_t |
DL_EPI_getNonBlockingReadCount0(void ) |
__STATIC_INLINE uint32_t |
DL_EPI_getNonBlockingReadCount1(void ) |
__STATIC_INLINE uint32_t |
DL_EPI_getNBRFIFOCount(void ) |
__STATIC_INLINE void |
DL_EPI_setFIFOTriggerLevels(DL_EPI_RD_FIFO_TRIG rdTrigger, DL_EPI_WR_FIFO_TRIG wrTrigger) |
__STATIC_INLINE void |
DL_EPI_setErrorInterruptConfig(bool enableWrFull, bool enableRdStall) |
__STATIC_INLINE void |
DL_EPI_setDMATxCount(uint32_t count) |
__STATIC_INLINE void |
DL_EPI_enableInterrupt(uint32_t interruptMask) |
__STATIC_INLINE void |
DL_EPI_disableInterrupt(uint32_t interruptMask) |
__STATIC_INLINE uint32_t |
DL_EPI_getEnabledInterruptStatus(uint32_t interruptMask) |
__STATIC_INLINE uint32_t |
DL_EPI_getRawInterruptStatus(uint32_t interruptMask) |
__STATIC_INLINE void |
DL_EPI_clearInterruptStatus(uint32_t errorMask) |
__STATIC_INLINE uint32_t |
DL_EPI_getErrorStatus(uint32_t errorMask) |
__STATIC_INLINE void |
DL_EPI_SDRAM_enableSleep(void ) |
__STATIC_INLINE void |
DL_EPI_SDRAM_wakeFromSleep(void ) |
__STATIC_INLINE void |
DL_EPI_SDRAM_disableSleep(void ) |
__STATIC_INLINE void |
DL_EPI_SDRAM_setRefreshCount(uint32_t count) |
Defines
Name |
|
|---|---|
DL_EPI_INTERRUPT_ERROR |
|
DL_EPI_INTERRUPT_RD_FIFO |
|
DL_EPI_INTERRUPT_WR_FIFO |
|
DL_EPI_INTERRUPT_DMA_RD |
|
DL_EPI_INTERRUPT_DMA_WR |
|
DL_EPI_STATUS_ACTIVE |
|
DL_EPI_STATUS_NBRBUSY |
|
DL_EPI_STATUS_WBUSY |
|
DL_EPI_STATUS_INITSEQ |
|
DL_EPI_STATUS_XFEMPTY |
|
DL_EPI_STATUS_XFFULL |
|
DL_EPI_SDRAM_INIT_TIMEOUT_COUNT |
|
DL_EPI_ERROR_TIMEOUT |
|
DL_EPI_ERROR_READ_STALL |
|
DL_EPI_ERROR_WRITE_FULL |
|
DL_EPI_SDRAM_CAS_LATENCY |
|
DL_EPI_SDRAM_LOAD_MODE_REG_VAL |
Types Documentation
enum DL_EPI_MODE
Enumerator |
Value |
Description |
|---|---|---|
DL_EPI_MODE_GENERAL_PURPOSE |
EPI_CFG_MODE_CFG_MODE_GP |
General-Purpose mode- wide parallel interface to CPLDs/FPGAs |
DL_EPI_MODE_SDRAM |
EPI_CFG_MODE_CFG_MODE_SDRAM |
SDRAM mode- x16 single data rate SDRAM up to 50 MHz |
DL_EPI_MODE_HB8 |
EPI_CFG_MODE_CFG_MODE_HB8 |
Host-Bus 8-bit mode- 8-bit MCU-style bus |
DL_EPI_MODE_HB16 |
EPI_CFG_MODE_CFG_MODE_HB16 |
Host-Bus 16-bit mode- standard SRAM-style 16-bit bus |
EPI operating mode.
enum DL_EPI_RAM_ADDR
Enumerator |
Value |
Description |
|---|---|---|
DL_EPI_RAM_ADDR_NOT_MAPPED |
EPI_ADDRMAP_ERADR_ADDR_MEM_NO_MAP |
External RAM area not mapped |
DL_EPI_RAM_ADDR_0x60000000 |
EPI_ADDRMAP_ERADR_ADDR_MEM_MAP_60000000 |
External RAM mapped at 0x60000000. |
DL_EPI_RAM_ADDR_0x80000000 |
EPI_ADDRMAP_ERADR_ADDR_MEM_MAP_80000000 |
External RAM mapped at 0x80000000 (0x8000_0000 – 0x9FFF_FFFF). Code execution allowed. |
DL_EPI_RAM_ADDR_QUAD |
EPI_ADDRMAP_ERADR_ADDR_MEM_DUAL_MAP |
Quad chip select- CS0n not supported on AM13E2x; CS1n at 0x80000000 |
EPI address map external RAM area selection.
enum DL_EPI_PER_ADDR
Enumerator |
Value |
Description |
|---|---|---|
DL_EPI_PER_ADDR_NOT_MAPPED |
EPI_ADDRMAP_EPADR_ADDR_PERIPH_NO_MAP |
External peripheral area not mapped |
DL_EPI_PER_ADDR_0xA0000000 |
EPI_ADDRMAP_EPADR_ADDR_PERIPH_MAP_60000000 |
External peripheral mapped at 0xA0000000 |
DL_EPI_PER_ADDR_0xC0000000 |
EPI_ADDRMAP_EPADR_ADDR_PERIPH_MAP_80000000 |
External peripheral mapped at 0xC0000000 |
DL_EPI_PER_ADDR_QUAD |
EPI_ADDRMAP_EPADR_ADDR_PERIPH_DUAL_MAP |
Quad chip select- CS2n at 0xA0000000, CS3n at 0xC0000000 |
EPI address map external peripheral area selection.
enum DL_EPI_ADDR_SIZE
Enumerator |
Value |
Description |
|---|---|---|
DL_EPI_ADDR_SIZE_256B |
0x0U |
256 bytes |
DL_EPI_ADDR_SIZE_64KB |
0x1U |
64 KB |
DL_EPI_ADDR_SIZE_16MB |
0x2U |
16 MB |
DL_EPI_ADDR_SIZE_256MB |
0x3U |
256 MB |
EPI address map size selection (applies to RAM, peripheral, and code areas)
enum DL_EPI_NBR_SIZE
Enumerator |
Value |
Description |
|---|---|---|
DL_EPI_NBR_SIZE_BYTE |
EPI_RSIZE0_SIZE_SIZE_8_BIT |
Byte (8-bit) transactions |
DL_EPI_NBR_SIZE_HWORD |
EPI_RSIZE0_SIZE_SIZE_16_BIT |
Half-word (16-bit) transactions |
DL_EPI_NBR_SIZE_WORD |
EPI_RSIZE0_SIZE_SIZE_32_BIT |
Word (32-bit) transactions |
EPI non-blocking read transaction size.
enum DL_EPI_RD_FIFO_TRIG
Enumerator |
Value |
Description |
|---|---|---|
DL_EPI_RD_FIFO_TRIG_1 |
EPI_FIFOLVL_RDFIFO_FIFOLVL_1_ENTRY_TRIG_READ |
Trigger when NBRFIFO has >= 1 entry |
DL_EPI_RD_FIFO_TRIG_2 |
EPI_FIFOLVL_RDFIFO_FIFOLVL_2_ENTRY_TRIG_READ |
Trigger when NBRFIFO has >= 2 entries |
DL_EPI_RD_FIFO_TRIG_4 |
EPI_FIFOLVL_RDFIFO_FIFOLVL_4_ENTRY_TRIG_READ |
Trigger when NBRFIFO has >= 4 entries |
DL_EPI_RD_FIFO_TRIG_6 |
EPI_FIFOLVL_RDFIFO_FIFOLVL_6_ENTRY_TRIG_READ |
Trigger when NBRFIFO has >= 6 entries |
DL_EPI_RD_FIFO_TRIG_7 |
EPI_FIFOLVL_RDFIFO_FIFOLVL_7_ENTRY_TRIG_READ |
Trigger when NBRFIFO has >= 7 entries |
DL_EPI_RD_FIFO_TRIG_8 |
EPI_FIFOLVL_RDFIFO_FIFOLVL_8_ENTRY_TRIG_READ |
Trigger when NBRFIFO has 8 entries (full) |
EPI NBRFIFO trigger level (for read interrupt/DMA)
enum DL_EPI_WR_FIFO_TRIG
Enumerator |
Value |
Description |
|---|---|---|
DL_EPI_WR_FIFO_TRIG_EMPTY |
EPI_FIFOLVL_WRFIFO_FIFOLVL_WRFIFO_EMPTY_TRIG_WRITE |
Trigger while WFIFO is empty (optimized for burst of 4) |
DL_EPI_WR_FIFO_TRIG_2SLOTS |
EPI_FIFOLVL_WRFIFO_FIFOLVL_2_ENTRY_TRIG_WRITE |
Trigger until 2 slots available (optimized for burst of 2) |
DL_EPI_WR_FIFO_TRIG_1SLOT |
EPI_FIFOLVL_WRFIFO_FIFOLVL_1_ENTRY_TRIG_WRITE |
Trigger until 1 slot available (for single writes) |
DL_EPI_WR_FIFO_TRIG_NOTFULL |
EPI_FIFOLVL_WRFIFO_FIFOLVL_NOT_FULL_TRIG_WRITE |
Trigger while WFIFO is not full |
EPI WFIFO trigger level (for write interrupt/DMA)
enum DL_EPI_GP_DSIZE
Enumerator |
Value |
Description |
|---|---|---|
DL_EPI_GP_DSIZE_8 |
EPI_EPIGPCFG_DSIZE_GPCFG_BUS_SIZE_8 |
8-bit data bus (EPI0S0-EPI0S7) |
DL_EPI_GP_DSIZE_16 |
EPI_EPIGPCFG_DSIZE_GPCFG_BUS_SIZE_16 |
16-bit data bus (EPI0S0-EPI0S15) |
DL_EPI_GP_DSIZE_24 |
EPI_EPIGPCFG_DSIZE_GPCFG_BUS_SIZE_24 |
24-bit data bus (EPI0S0-EPI0S23) |
DL_EPI_GP_DSIZE_32 |
EPI_EPIGPCFG_DSIZE_GPCFG_BUS_SIZE_32 |
32-bit data bus (EPI0S0-EPI0S31) - cannot use with clock/frame/address |
EPI General-Purpose mode data bus width.
enum DL_EPI_GP_ASIZE
Enumerator |
Value |
Description |
|---|---|---|
DL_EPI_GP_ASIZE_NONE |
EPI_EPIGPCFG_ASIZE_GPCFG_ADDR_SIZE_NONE |
No address bus |
DL_EPI_GP_ASIZE_4 |
EPI_EPIGPCFG_ASIZE_GPCFG_ADDR_SIZE_4 |
Up to 4-bit address (EPI0S[27-24]) |
DL_EPI_GP_ASIZE_12 |
EPI_EPIGPCFG_ASIZE_GPCFG_ADDR_SIZE_12 |
Up to 12-bit address (EPI0S[27-16]) - cannot use with 24-bit data |
DL_EPI_GP_ASIZE_20 |
EPI_EPIGPCFG_ASIZE_GPCFG_ADDR_SIZE_20 |
Up to 20-bit address (EPI0S[27-8]) - only with 8-bit data |
EPI General-Purpose mode address bus width.
enum DL_EPI_SDRAM_SIZE
Enumerator |
Value |
Description |
|---|---|---|
DL_EPI_SDRAM_SIZE_64M |
EPI_EPISDRAMCFG_SIZE_SDRAMCFG_SIZE_64MBITS |
64 megabits (8 MB) |
DL_EPI_SDRAM_SIZE_128M |
EPI_EPISDRAMCFG_SIZE_SDRAMCFG_SIZE_128MBITS |
128 megabits (16 MB) |
DL_EPI_SDRAM_SIZE_256M |
EPI_EPISDRAMCFG_SIZE_SDRAMCFG_SIZE_256MBITS |
256 megabits (32 MB) |
DL_EPI_SDRAM_SIZE_512M |
EPI_EPISDRAMCFG_SIZE_SDRAMCFG_SIZE_512MBITS |
512 megabits (64 MB) |
EPI SDRAM memory capacity.
enum DL_EPI_SDRAM_FREQ
Enumerator |
Value |
Description |
|---|---|---|
DL_EPI_SDRAM_FREQ_15M |
EPI_EPISDRAMCFG_FREQ_SDRAMCFG_0_TO_15_MHZ |
EPI clock 0 to 15 MHz |
DL_EPI_SDRAM_FREQ_30M |
EPI_EPISDRAMCFG_FREQ_SDRAMCFG_15_TO_30_MHZ |
EPI clock 15 to 30 MHz |
DL_EPI_SDRAM_FREQ_50M |
EPI_EPISDRAMCFG_FREQ_SDRAMCFG_30_TO_50_MHZ |
EPI clock 30 to 50 MHz |
DL_EPI_SDRAM_FREQ_100M |
EPI_EPISDRAMCFG_FREQ_SDRAMCFG_50_TO_100_MHZ |
EPI clock 50 to 100 MHz |
EPI SDRAM frequency range (affects internal timing delays)
Functions Documentation
function DL_EPI_SDRAM_initParamsSetDefault
void DL_EPI_SDRAM_initParamsSetDefault(
DL_EPI_SDRAM_Config * config
)
Initialize EPI SDRAM mode with default parameters.
Parameters:
config Pointer to the SDRAM config structure to initialize
function DL_EPI_SDRAM_init
void DL_EPI_SDRAM_init(
const DL_EPI_SDRAM_Config * config
)
Initialize EPI in SDRAM mode.
Parameters:
config Pointer to the SDRAM configuration
Note: EPI SDRAM interface maximum clock is 60 MHz. If MCLK/4 > 60 MHz, set config->baudCount0 >= 1 to divide the clock further.
Configures EPIBAUD, EPISDRAMCFG, EPIADDRMAP, then writes EPICFG to enable SDRAM mode, which immediately triggers the hardware initialization sequence.
function DL_EPI_SDRAM_initAndWait
bool DL_EPI_SDRAM_initAndWait(
const DL_EPI_SDRAM_Config * config
)
Initialize EPI SDRAM mode and block until initialization is complete.
Parameters:
config Pointer to the SDRAM configuration
Return:
true if SDRAM initialization completed successfully (INITSEQ cleared)
false if the timeout expired before INITSEQ cleared — hardware fault, missing EPI clock, or incorrect pin mux
Note: Use DL_EPI_SDRAM_calculateRefreshCount to derive the correct config->refreshCount value from the EPI external clock frequency and SDRAM device row count.
Calls DL_EPI_SDRAM_init then spins on EPISTAT.INITSEQ until the hardware initialization sequence finishes (> 100 µs), or until DL_EPI_SDRAM_INIT_TIMEOUT_COUNT iterations have elapsed.
function DL_EPI_SDRAM_calculateRefreshCount
uint32_t DL_EPI_SDRAM_calculateRefreshCount(
uint32_t epiClkHz,
uint32_t numRows,
uint32_t refreshPeriodUs
)
Calculate the RFSH field value for EPISDRAMCFG.
Parameters:
epiClkHz EPI external interface clock in Hz (= MCLK/4 / (COUNT0 + 1) for AM13E2x)
numRows Number of SDRAM rows per bank (typically 4096 or 8192)
refreshPeriodUs SDRAM refresh period in microseconds (typically 64000 µs = 64 ms for standard SDR SDRAM)
Return: Computed RFSH value to store in config->refreshCount, clamped to [1, 2047]
Note: default value of Refresh count is 750
Computes the maximum safe refresh counter value using the formula from the
RFSH <= (tRefresh_us / numRows) / extClkPeriod_us
== (refreshPeriodUs * epiClkHz) / (numRows * 1_000_000)
function DL_EPI_setMode
void DL_EPI_setMode(
DL_EPI_MODE mode
)
Set EPI operating mode in EPICFG.
Parameters:
mode One of DL_EPI_MODE
Writes the MODE field (bits[3-0]) in EPICFG. Any write to EPICFG resets the mode-specific register at offset 0x010 (EPISDRAMCFG when mode=SDRAM, etc.). Always reconfigure the mode-specific register after calling this function.
function DL_EPI_SDRAM_configure
void DL_EPI_SDRAM_configure(
uint32_t size,
uint32_t freq,
uint32_t refresh
)
Configure SDRAM parameters (raw field values)
Parameters:
size SDRAM size field- 0=64Mb, 1=128Mb, 2=256Mb, 3=512Mb
freq Frequency field- 0=0-15MHz, 1=15-30MHz, 2=30-50MHz, 3=50-100MHz
refresh RFSH count (0–2047)- use DL_EPI_SDRAM_calculateRefreshCount()
Writes EPISDRAMCFG directly from raw SIZE, FREQ and RFSH field values. Must be called AFTER DL_EPI_enable() / DL_EPI_setMode(), because any EPICFG write resets EPISDRAMCFG to its reset value.
function DL_EPI_setAddressMapRaw
void DL_EPI_setAddressMapRaw(
uint32_t ramAddr,
uint32_t ramSize,
uint32_t perAddr,
uint32_t perSize
)
Configure address map using raw field values.
Parameters:
ramAddr RAM address field- 0=not mapped, 1=0x60000000, 2=0x80000000, 3=quad
ramSize RAM size field- 0=256B, 1=64KB, 2=16MB, 3=256MB
perAddr PER address field- 0=not mapped, 1=0xA0000000, 2=0xC0000000, 3=quad
perSize PER size field- 0=256B, 1=64KB, 2=16MB, 3=256MB
Sets EPIADDRMAP directly from raw 2-bit field values for each parameter. Use this when you have bare field values (0–3) rather than the enum constants.
function DL_EPI_readNBRFIFO32
uint32_t DL_EPI_readNBRFIFO32(
uint32_t count,
uint32_t * pBuf
)
Drain up to count 32-bit words from the NBRFIFO.
Parameters:
count Maximum number of words to drain
pBuf Destination buffer
Return: Number of words actually drained (0 if NBRFIFO was empty)
Reads entries deposited by the EPI non-blocking read engine Unlike a normal read, the CPU is NOT stalled; data arrives asynchronously in the NBRFIFO (max 8 entries) and is drained here.
Call DL_EPI_setupNonBlockingRead0 first to start the transfer.
function DL_EPI_readNBRFIFO16
uint32_t DL_EPI_readNBRFIFO16(
uint32_t count,
uint16_t * pBuf
)
Drain up to count 16-bit half-words from the NBRFIFO.
Parameters:
count Maximum number of half-words to drain
pBuf Destination buffer
Return: Number of half-words actually drained
Same non-blocking read engine as DL_EPI_readNBRFIFO32. Each NBRFIFO entry holds the lower 16 bits of EPIREADFIFO0.
function DL_EPI_readNBRFIFO8
uint32_t DL_EPI_readNBRFIFO8(
uint32_t count,
uint8_t * pBuf
)
Drain up to count bytes from the NBRFIFO.
Parameters:
count Maximum number of bytes to drain
pBuf Destination buffer
Return: Number of bytes actually drained
Same non-blocking read engine as DL_EPI_readNBRFIFO32. Each NBRFIFO entry holds the lower 8 bits of EPIREADFIFO0.
function DL_EPI_enable
__STATIC_INLINE void DL_EPI_enable(
void
)
Enable the EPI block.
Sets the BLKEN bit in EPICFG. After setting mode and configuration registers, call this to enable the EPI controller.
function DL_EPI_disable
__STATIC_INLINE void DL_EPI_disable(
void
)
Disable the EPI block.
Note: Do NOT disable SDRAM mode once enabled or SDRAM contents will be lost.
function DL_EPI_isEnabled
__STATIC_INLINE bool DL_EPI_isEnabled(
void
)
Check if EPI block is enabled.
Return: true if EPI is enabled, false otherwise
function DL_EPI_getStatus
__STATIC_INLINE uint32_t DL_EPI_getStatus(
void
)
Get the EPI status register value.
Return: EPI status register value
Use DL_EPI_STATUS_xxx masks to check individual status bits.
function DL_EPI_isBusy
__STATIC_INLINE bool DL_EPI_isBusy(
void
)
Check if EPI is busy (write in progress or NBR read busy)
Return: true if EPI write or non-blocking read is in progress
function DL_EPI_SDRAM_isInitDone
__STATIC_INLINE bool DL_EPI_SDRAM_isInitDone(
void
)
Check if SDRAM initialization sequence is complete.
Return: true if SDRAM initialization is complete (INITSEQ = 0)
After enabling SDRAM mode, the SDRAM requires >100µs initialization. Poll this function before performing read/write accesses.
function DL_EPI_SDRAM_isInitializing
__STATIC_INLINE bool DL_EPI_SDRAM_isInitializing(
void
)
Check if SDRAM initialization sequence is still running.
Return: true if SDRAM initialization is still in progress
Returns true while EPISTAT.INITSEQ is set (init in progress). This is the inverse of DL_EPI_SDRAM_isInitDone. Use in polling loops- while (DL_EPI_SDRAM_isInitializing()) {}
function DL_EPI_SDRAM_waitInit
__STATIC_INLINE bool DL_EPI_SDRAM_waitInit(
void
)
Blocking poll until SDRAM initialization sequence is complete.
Return:
true if SDRAM initialization completed successfully (INITSEQ cleared)
false if the timeout expired before INITSEQ cleared
Note: If you have no other work to do between init and first access, use DL_EPI_SDRAM_initAndWait instead.
Spins on EPISTAT.INITSEQ until the EPI hardware finishes the SDRAM power-up sequence (> 100 µs), or until DL_EPI_SDRAM_INIT_TIMEOUT_COUNT iterations have elapsed. Use when you want to separate the non-blocking DL_EPI_SDRAM_init call from the wait:
DL_EPI_SDRAM_init(&myCfg); // kick off init
// ... do other boot-time work here ...
bool ok = DL_EPI_SDRAM_waitInit(); // block until SDRAM is ready
if (!ok) { // handle hardware fault }
function DL_EPI_getWFIFOAvailableSlots
__STATIC_INLINE uint32_t DL_EPI_getWFIFOAvailableSlots(
void
)
Get the number of available slots in the WFIFO.
Return: Number of available WFIFO write slots (0-4; 0 = full/stall(4 writes pending), 4=FIFO empty.)
function DL_EPI_waitForReady
__STATIC_INLINE void DL_EPI_waitForReady(
void
)
Busy-wait until all pending EPI writes complete.
Spins until EPISTAT.WBUSY=0 (no write in progress) AND EPIWFIFOCNT.WTAV=4 (write FIFO fully drained). Call this after a burst of writes to SDRAM space before the first read.
function DL_EPI_setAddressMap
__STATIC_INLINE void DL_EPI_setAddressMap(
const DL_EPI_AddrMapConfig * config
)
Configure EPI address mapping.
Parameters:
config Address map configuration
function DL_EPI_setBaudRate
__STATIC_INLINE void DL_EPI_setBaudRate(
uint32_t count0,
uint32_t count1
)
Set EPI clock divider (baud rate)
Parameters:
count0 CS0n clock divider (0 = sys_clk)
count1 CS1n clock divider; only used when CSBAUD=1 in HB modes
Programs COUNT0 (and optionally COUNT1) in the EPIBAUD register. A value of 0 passes the system clock through unchanged.
function DL_EPI_setBaudRate2
__STATIC_INLINE void DL_EPI_setBaudRate2(
uint32_t count0,
uint32_t count1
)
Set EPI baud rate for CS2n and CS3n (quad chip select modes)
Parameters:
count0 CS2n clock divider
count1 CS3n clock divider
function DL_EPI_setupNonBlockingRead0
__STATIC_INLINE void DL_EPI_setupNonBlockingRead0(
uint32_t address,
DL_EPI_NBR_SIZE size,
uint32_t count
)
Set up and start non-blocking read channel 0.
Parameters:
address Starting byte address for the non-blocking read
size Transaction size- byte (8-bit), halfword (16-bit), or word (32-bit)
count Number of transactions (1-8191); 0 cancels active read
Writing a non-zero count to EPIRPSTD0 arms the EPI non-blocking read engine. The hardware then autonomously executes count SDRAM read transactions Results are deposited in the NBRFIFO (up to 8 entries); the CPU is not stalled. Poll DL_EPI_getNBRFIFOCount or use the NBRFIFO interrupt to know when entries are available, then drain with DL_EPI_readNBRFIFO32.
function DL_EPI_setupNonBlockingRead1
__STATIC_INLINE void DL_EPI_setupNonBlockingRead1(
uint32_t address,
DL_EPI_NBR_SIZE size,
uint32_t count
)
Set up non-blocking read channel 1.
Parameters:
address Starting byte address
size Transaction size
count Number of transactions (1-8191); 0 cancels active read
When channel 0 completes, channel 1 activates. Both channels can be used for ping-pong operation.
function DL_EPI_cancelNonBlockingRead0
__STATIC_INLINE void DL_EPI_cancelNonBlockingRead0(
void
)
Cancel non-blocking read channel 0.
Writes 0 to EPIRPSTD0 to cancel any pending or active non-blocking read. After cancelling, drain the NBRFIFO of any values already read.
function DL_EPI_cancelNonBlockingRead1
__STATIC_INLINE void DL_EPI_cancelNonBlockingRead1(
void
)
Cancel non-blocking read channel 1.
function DL_EPI_getNonBlockingReadCount0
__STATIC_INLINE uint32_t DL_EPI_getNonBlockingReadCount0(
void
)
Get remaining count for non-blocking read channel 0.
Return: Current value of EPIRPSTD0 (remaining read count)
function DL_EPI_getNonBlockingReadCount1
__STATIC_INLINE uint32_t DL_EPI_getNonBlockingReadCount1(
void
)
Get remaining count for non-blocking read channel 1.
Return: Current value of EPIRPSTD1 (remaining read count)
function DL_EPI_getNBRFIFOCount
__STATIC_INLINE uint32_t DL_EPI_getNBRFIFOCount(
void
)
Get the number of valid entries in the NBRFIFO.
Return: Number of filled NBRFIFO entries (0-8)
function DL_EPI_setFIFOTriggerLevels
__STATIC_INLINE void DL_EPI_setFIFOTriggerLevels(
DL_EPI_RD_FIFO_TRIG rdTrigger,
DL_EPI_WR_FIFO_TRIG wrTrigger
)
Configure FIFO trigger levels.
Parameters:
rdTrigger NBRFIFO trigger level for read interrupt/DMA
wrTrigger WFIFO trigger level for write interrupt/DMA
function DL_EPI_setErrorInterruptConfig
__STATIC_INLINE void DL_EPI_setErrorInterruptConfig(
bool enableWrFull,
bool enableRdStall
)
Enable error interrupts for WFIFO full and read stall conditions.
Parameters:
enableWrFull true = interrupt when write attempted to full WFIFO
enableRdStall true = interrupt when read stalled by non-empty WFIFO
function DL_EPI_setDMATxCount
__STATIC_INLINE void DL_EPI_setDMATxCount(
uint32_t count
)
Set EPI DMA transmit count.
Parameters:
count Number of transfers (0-65535); 0 disables DMA write requests
Programs the total number of DMA write transfers to the EPI WFIFO. Asserts a DMA request when WFIFO is at or below the programmed trigger level.
function DL_EPI_enableInterrupt
__STATIC_INLINE void DL_EPI_enableInterrupt(
uint32_t interruptMask
)
Enable EPI interrupts.
Parameters:
interruptMask Bitwise OR of DL_EPI_INTERRUPT_xxx flags
function DL_EPI_disableInterrupt
__STATIC_INLINE void DL_EPI_disableInterrupt(
uint32_t interruptMask
)
Disable EPI interrupts.
Parameters:
interruptMask Bitwise OR of DL_EPI_INTERRUPT_xxx flags
function DL_EPI_getEnabledInterruptStatus
__STATIC_INLINE uint32_t DL_EPI_getEnabledInterruptStatus(
uint32_t interruptMask
)
Get enabled interrupt status (EPIMIS - masked interrupt status)
Parameters:
interruptMask Bitwise OR of DL_EPI_INTERRUPT_xxx flags to check
Return: Non-zero if any of the specified masked interrupts are pending
Returns the bitwise AND of the raw interrupt status and the interrupt mask. Use DL_EPI_INTERRUPT_xxx masks to check individual bits.
function DL_EPI_getRawInterruptStatus
__STATIC_INLINE uint32_t DL_EPI_getRawInterruptStatus(
uint32_t interruptMask
)
Get raw interrupt status (EPIRIS - regardless of mask)
Parameters:
interruptMask Bitwise OR of DL_EPI_INTERRUPT_xxx flags to check
Return: Non-zero if any of the specified raw interrupts are pending
function DL_EPI_clearInterruptStatus
__STATIC_INLINE void DL_EPI_clearInterruptStatus(
uint32_t errorMask
)
Clear EPI error interrupt flags.
Parameters:
errorMask Bitwise OR of DL_EPI_ERROR_xxx or EPI_EISC_xxx_MASK flags
Write 1 to clear one or more error/interrupt bits in EPIEISC. Use DL_EPI_ERROR_xxx masks to identify which errors to clear. Also use EPI_EISC_DMARDIC_MASK or EPI_EISC_DMAWRIC_MASK to clear DMA done flags.
function DL_EPI_getErrorStatus
__STATIC_INLINE uint32_t DL_EPI_getErrorStatus(
uint32_t errorMask
)
Get EPI error status.
Parameters:
errorMask Bitwise OR of DL_EPI_ERROR_xxx flags to check
Return: Non-zero if any of the specified errors have occurred
Returns the current error bits from EPIEISC. Use DL_EPI_ERROR_xxx masks to check individual error conditions.
function DL_EPI_SDRAM_enableSleep
__STATIC_INLINE void DL_EPI_SDRAM_enableSleep(
void
)
Enable SDRAM sleep (self-refresh) mode.
Note: To wake the SDRAM, call DL_EPI_SDRAM_wakeFromSleep which clears the SLEEP bit AND enforces the mandatory post-wake stall period.
Par: Prerequisites before calling-
All non-blocking reads must be cancelled and the NBRFIFO drained
Wait until both WBUSY and NBRBUSY in EPISTAT are clear
No new reads or writes may be in flight
Sets EPISDRAMCFG.SLEEP to put the SDRAM into low-power self-refresh.
function DL_EPI_SDRAM_wakeFromSleep
__STATIC_INLINE void DL_EPI_SDRAM_wakeFromSleep(
void
)
Wake SDRAM from self-refresh and enforce mandatory post-wake stall Clears EPISDRAMCFG.SLEEP and then waits at least 5 EPI clock cycles The stall is implemented as 5 consecutive reads of EPISTAT.
function DL_EPI_SDRAM_disableSleep
__STATIC_INLINE void DL_EPI_SDRAM_disableSleep(
void
)
Disable SDRAM sleep mode Clears EPISDRAMCFG.SLEEP.
function DL_EPI_SDRAM_setRefreshCount
__STATIC_INLINE void DL_EPI_SDRAM_setRefreshCount(
uint32_t count
)
Set SDRAM refresh counter.
Parameters:
count Refresh counter value
RFSH <= (tRefresh_us / numRows) / extClkPeriod_us
For a 50 MHz EPI clock with 4096-row SDRAM- RFSH = (64000 / 4096) / 0.02 = 781.25 -> use 750 (default) for safety margin.
Macros Documentation
define DL_EPI_INTERRUPT_ERROR
#define DL_EPI_INTERRUPT_ERROR (EPI_IM_ERRIM_MASK)
EPI error interrupt (WFIFO full, read stall, or timeout)
define DL_EPI_INTERRUPT_RD_FIFO
#define DL_EPI_INTERRUPT_RD_FIFO (EPI_IM_RDIM_MASK)
EPI NBRFIFO at or above read trigger level interrupt.
define DL_EPI_INTERRUPT_WR_FIFO
#define DL_EPI_INTERRUPT_WR_FIFO (EPI_IM_WRIM_MASK)
EPI WFIFO at or below write trigger level interrupt.
define DL_EPI_INTERRUPT_DMA_RD
#define DL_EPI_INTERRUPT_DMA_RD (EPI_IM_DMARDIM_MASK)
EPI read DMA done interrupt.
define DL_EPI_INTERRUPT_DMA_WR
#define DL_EPI_INTERRUPT_DMA_WR (EPI_IM_DMAWRIM_MASK)
EPI write DMA done interrupt.
define DL_EPI_STATUS_ACTIVE
#define DL_EPI_STATUS_ACTIVE (EPI_STAT_ACTIVE_MASK)
EPI is active (WFIFO not empty or write/NBR read in progress)
define DL_EPI_STATUS_NBRBUSY
#define DL_EPI_STATUS_NBRBUSY (EPI_STAT_NBRBUSY_MASK)
EPI non-blocking read is busy.
define DL_EPI_STATUS_WBUSY
#define DL_EPI_STATUS_WBUSY (EPI_STAT_WBUSY_MASK)
EPI write is busy.
define DL_EPI_STATUS_INITSEQ
#define DL_EPI_STATUS_INITSEQ (EPI_STAT_INITSEQ_MASK)
SDRAM initialization sequence in progress.
define DL_EPI_STATUS_XFEMPTY
#define DL_EPI_STATUS_XFEMPTY (EPI_STAT_XFEMPTY_MASK)
External FIFO is signaling empty.
define DL_EPI_STATUS_XFFULL
#define DL_EPI_STATUS_XFFULL (EPI_STAT_XFFULL_MASK)
External FIFO is signaling full.
define DL_EPI_SDRAM_INIT_TIMEOUT_COUNT
#define DL_EPI_SDRAM_INIT_TIMEOUT_COUNT (100000U)
Timeout iteration count for SDRAM initialization spin-wait.
Used by DL_EPI_SDRAM_initAndWait and DL_EPI_SDRAM_waitInit to prevent an infinite hang if the SDRAM initialization sequence never completes (e.g. missing EPI clock, incorrect pin mux, or hardware fault).
SDRAM power-up requirement is >100 µs. At 250 MHz MCLK, each loop iteration takes ~4 ns, so 100 000 iterations provides a ~400 µs timeout — 4× the SDRAM power-up requirement. Override this macro before including dl_epi.h if a different timeout is needed.
define DL_EPI_ERROR_TIMEOUT
#define DL_EPI_ERROR_TIMEOUT (EPI_EISC_TOUT_MASK)
XFIFO timeout error occurred.
define DL_EPI_ERROR_READ_STALL
#define DL_EPI_ERROR_READ_STALL (EPI_EISC_RSTALL_MASK)
Read stalled error- read attempted while WFIFO not empty.
define DL_EPI_ERROR_WRITE_FULL
#define DL_EPI_ERROR_WRITE_FULL (EPI_EISC_WTFULL_MASK)
Write FIFO full error.
define DL_EPI_SDRAM_CAS_LATENCY
#define DL_EPI_SDRAM_CAS_LATENCY (2U)
SDRAM CAS latency programmed by EPI hardware (not user-configurable)
During the SDRAM initialization sequence the EPI automatically issues a LOAD MODE REGISTER command with value DL_EPI_SDRAM_LOAD_MODE_REG_VAL (0x27), which sets CAS latency = 2 and full-page sequential burst length. These parameters cannot be changed through the EPI register interface.
define DL_EPI_SDRAM_LOAD_MODE_REG_VAL
#define DL_EPI_SDRAM_LOAD_MODE_REG_VAL (0x27U)
LOAD MODE REGISTER value sent by EPI hardware during SDRAM init.
Encoding (JEDEC SDR SDRAM)-
Bits [2-0] = 111 - Burst length = full page (sequential)
Bit [3] = 0 - Burst type = sequential
Bits [6-4] = 010 - CAS latency = 2
Bit [9] = 0 - Write burst = programmed burst length