PDL for FM4  Version1.2
Peripheral Driverl Library for FM4
External Bus Interface Functions (EXTIF)

Data Structures

struct  stc_extif_arrays
 Definition of MODE, TIM, AREA, ATIM register arrays. More...
 
struct  stc_extif_area_config
 Extif area configuration. More...
 
struct  stc_extif_intern_data
 EXTIF Error Interrupt Callback Pointers. More...
 

Macros

#define EXTIF   (*((stc_extif_arrays_t *) FM4_EXBUS_BASE))
 
#define EXITIF_NAND_ALE_OFFSET   0x00003000ul
 Address offset for MNALE assert until write. More...
 
#define EXITIF_NAND_ADDR_OFFSET   0x00002000ul
 Address offset for address cycle (+ MNALE) More...
 
#define EXITIF_NAND_CMD_OFFSET   0x00001000ul
 Address offset for command cycle (+ MNCLE) More...
 
#define EXITIF_NAND_DATA_OFFSET   0x00000000ul
 Address offset for data read/write. More...
 
#define Extif_Nand_SetCommand(base, cmd)   {*(volatile unsigned char*)((base) + EXITIF_NAND_CMD_OFFSET) = (unsigned char)(cmd);}
 Sets a NAND command cycle. More...
 
#define Extif_Nand_SetAddress(base, addr)   {*(volatile unsigned char*)((base) + EXITIF_NAND_ADDR_OFFSET) = (unsigned char)(addr);}
 Sets a NAND address cycle. More...
 
#define Extif_Nand_ReadData(base)   (*(volatile unsigned char*)((base) + EXITIF_NAND_DATA_OFFSET))
 Reads NAND data. More...
 
#define Extif_Nand_WriteData(base, data)   {*(volatile unsigned char*)((base) + EXITIF_NAND_DATA_OFFSET) = (unsigned char)(data);}
 Writes NAND data. More...
 
#define Extif_Nand_ClearAle(base)   {*(volatile unsigned char*)((base) + EXITIF_NAND_ALE_OFFSET) = (unsigned char)0;}
 De-asserts MNALE signal. More...
 

Typedefs

typedef struct stc_extif_arrays stc_extif_arrays_t
 Definition of MODE, TIM, AREA, ATIM register arrays. More...
 
typedef enum en_extif_width en_extif_width_t
 Extif data width. More...
 
typedef enum en_extif_cycle en_extif_cycle_t
 Extif cycle defintion. More...
 
typedef enum en_extif_mask en_extif_mask_t
 Extif mask setup (area size) More...
 
typedef enum en_extif_cas en_extif_cas_t
 Extif CAS address select. More...
 
typedef enum en_extif_ras en_extif_ras_t
 Extif RAS address select. More...
 
typedef enum en_extif_bas en_extif_bas_t
 Extif BAS address select. More...
 
typedef struct
stc_extif_area_config 
stc_extif_area_config_t
 Extif area configuration. More...
 
typedef struct
stc_extif_intern_data 
stc_extif_intern_data_t
 EXTIF Error Interrupt Callback Pointers. More...
 

Enumerations

enum  en_extif_width {
  Extif8Bit = 0,
  Extif16Bit = 1
}
 Extif data width. More...
 
enum  en_extif_cycle {
  Extif0Cycle = 0,
  Extif1Cycle = 1,
  Extif2Cycle = 2,
  Extif3Cycle = 3,
  Extif4Cycle = 4,
  Extif5Cycle = 5,
  Extif6Cycle = 6,
  Extif7Cycle = 7,
  Extif8Cycle = 8,
  Extif9Cycle = 9,
  Extif10Cycle = 10,
  Extif11Cycle = 11,
  Extif12Cycle = 12,
  Extif13Cycle = 13,
  Extif14Cycle = 14,
  Extif15Cycle = 15,
  Extif16Cycle = 16,
  ExtifDisabled = 17
}
 Extif cycle defintion. More...
 
enum  en_extif_mask {
  Extif1MB = 0,
  Extif2MB = 1,
  Extif4MB = 2,
  Extif8MB = 3,
  Extif16MB = 4,
  Extif32MB = 5,
  Extif64MB = 6,
  Extif128MB = 7
}
 Extif mask setup (area size) More...
 
enum  en_extif_cas {
  ExtifCas16Bit = 0,
  ExtifCas32Bit = 1
}
 Extif CAS address select. More...
 
enum  en_extif_ras {
  ExtifRas_19_6 = 0,
  ExtifRas_20_7 = 1,
  ExtifRas_21_8 = 2,
  ExtifRas_22_9 = 3,
  ExtifRas_23_10 = 4,
  ExtifRas_24_11 = 5,
  ExtifRas_25_12 = 6
}
 Extif RAS address select. More...
 
enum  en_extif_bas {
  ExtifBas_20_19 = 0,
  ExtifBas_21_20 = 1,
  ExtifBas_22_21 = 2,
  ExtifBas_23_22 = 3,
  ExtifBas_24_23 = 4,
  ExtifBas_25_24 = 5,
  ExtifBas_26_25 = 6
}
 Extif BAS address select. More...
 

Functions

void ExtifIrqHandler (void)
 External Bus Interface Error Interrupt Service Routine. More...
 
en_result_t Extif_InitArea (uint8_t u8Area, stc_extif_area_config_t *pstcConfig)
 Setup (init) an EXT-I/F area. More...
 
en_result_t Extif_ReadErrorStatus (void)
 Read Error Status Register. More...
 
uint32_t Extif_ReadErrorAddress (void)
 Read Error Address Register. More...
 
en_result_t Extif_ClearErrorStatus (void)
 Clear Error Status Register. More...
 
en_result_t Extif_CheckSdcmdReady (void)
 Check SDRAM command register is ready. More...
 
en_result_t Extif_SetSdramCommand (uint16_t u16Address, boolean_t bMsdwex, boolean_t bMcasx, boolean_t bMrasx, boolean_t bMcsx8, boolean_t bMadcke)
 Set a SDRAM command. More...
 

Variables

stc_extif_intern_data_t stcExtifInternData
 

Detailed Description

Provided functions of EXTIF module:

Extif_InitArea() initializes an area according the user configuration. Extif_ReadErrorStatus() reads out the error status of the Error Status Register (EST). Extif_ReadErrorAddress() reads out the address were the error occurred. Extif_ClearErrorStatus() clears the error status. Extif_CheckSdcmdReady() checks, if it is allowed to set a SDRAM command. Extif_SetSdramCommand() set the SDRAM command (calls Extif_CheckSdcmdReady() ).

Macro Definition Documentation

#define EXITIF_NAND_ADDR_OFFSET   0x00002000ul

Address offset for address cycle (+ MNALE)

Definition at line 99 of file extif.h.

#define EXITIF_NAND_ALE_OFFSET   0x00003000ul

Address offset for MNALE assert until write.

Definition at line 98 of file extif.h.

#define EXITIF_NAND_CMD_OFFSET   0x00001000ul

Address offset for command cycle (+ MNCLE)

Definition at line 100 of file extif.h.

#define EXITIF_NAND_DATA_OFFSET   0x00000000ul

Address offset for data read/write.

Definition at line 101 of file extif.h.

#define EXTIF   (*((stc_extif_arrays_t *) FM4_EXBUS_BASE))

Definition at line 93 of file extif.h.

Referenced by Extif_InitArea().

#define Extif_Nand_ClearAle (   base)    {*(volatile unsigned char*)((base) + EXITIF_NAND_ALE_OFFSET) = (unsigned char)0;}

De-asserts MNALE signal.

Definition at line 110 of file extif.h.

#define Extif_Nand_ReadData (   base)    (*(volatile unsigned char*)((base) + EXITIF_NAND_DATA_OFFSET))

Reads NAND data.

Definition at line 108 of file extif.h.

#define Extif_Nand_SetAddress (   base,
  addr 
)    {*(volatile unsigned char*)((base) + EXITIF_NAND_ADDR_OFFSET) = (unsigned char)(addr);}

Sets a NAND address cycle.

Definition at line 107 of file extif.h.

#define Extif_Nand_SetCommand (   base,
  cmd 
)    {*(volatile unsigned char*)((base) + EXITIF_NAND_CMD_OFFSET) = (unsigned char)(cmd);}

Sets a NAND command cycle.

Definition at line 106 of file extif.h.

#define Extif_Nand_WriteData (   base,
  data 
)    {*(volatile unsigned char*)((base) + EXITIF_NAND_DATA_OFFSET) = (unsigned char)(data);}

Writes NAND data.

Definition at line 109 of file extif.h.

Typedef Documentation

Extif BAS address select.

Select the address for the Bank Address Select

Note
Do not change enumeration number. The numbers are taken for calculating the corresponding bitfield!

Extif CAS address select.

Select the address for the Column Address Select

Note
Do not change enumeration number. The numbers are taken for calculating the corresponding bitfield!

Extif cycle defintion.

To select the bus mode of the interface.

Note
Do not change enumeration number. The numbers are taken for calculating the corresponding bitfield!

Extif mask setup (area size)

To select the Mask Setup value for the address area per chip select.

Note
Do not change enumeration number. The numbers are taken for calculating the corresponding bitfield!

Extif RAS address select.

Select the address for the Row Address Select

Note
Do not change enumeration number. The numbers are taken for calculating the corresponding bitfield!

Extif data width.

To select the data bus width

Extif area configuration.

The WDG configuration is done on a per area (Chip select) basis

Definition of MODE, TIM, AREA, ATIM register arrays.

To select the data bus width

EXTIF Error Interrupt Callback Pointers.

Enumeration Type Documentation

Extif BAS address select.

Select the address for the Bank Address Select

Note
Do not change enumeration number. The numbers are taken for calculating the corresponding bitfield!
Enumerator
ExtifBas_20_19 

MAD[13:0] = Internal address [20:19].

ExtifBas_21_20 

MAD[13:0] = Internal address [21:20].

ExtifBas_22_21 

MAD[13:0] = Internal address [22:21].

ExtifBas_23_22 

MAD[13:0] = Internal address [23:22].

ExtifBas_24_23 

MAD[13:0] = Internal address [24:23].

ExtifBas_25_24 

MAD[13:0] = Internal address [25:24].

ExtifBas_26_25 

MAD[13:0] = Internal address [26:25].

Definition at line 250 of file extif.h.

Extif CAS address select.

Select the address for the Column Address Select

Note
Do not change enumeration number. The numbers are taken for calculating the corresponding bitfield!
Enumerator
ExtifCas16Bit 

MAD[9:0] = Internal address [10:1], 16-Bit width.

ExtifCas32Bit 

MAD[9:0] = Internal address [11:2], 32-Bit width.

Definition at line 215 of file extif.h.

Extif cycle defintion.

To select the bus mode of the interface.

Note
Do not change enumeration number. The numbers are taken for calculating the corresponding bitfield!
Enumerator
Extif0Cycle 

0 cycles

Extif1Cycle 

1 cycle

Extif2Cycle 

2 cycles

Extif3Cycle 

3 cycles

Extif4Cycle 

4 cycles

Extif5Cycle 

5 cycles

Extif6Cycle 

6 cycles

Extif7Cycle 

7 cycles

Extif8Cycle 

8 cycles

Extif9Cycle 

9 cycles

Extif10Cycle 

10 cycles

Extif11Cycle 

11 cycles

Extif12Cycle 

12 cycles

Extif13Cycle 

13 cycles

Extif14Cycle 

14 cycles

Extif15Cycle 

15 cycles

Extif16Cycle 

16 cycles

ExtifDisabled 

Setting disabled.

Definition at line 163 of file extif.h.

Extif mask setup (area size)

To select the Mask Setup value for the address area per chip select.

Note
Do not change enumeration number. The numbers are taken for calculating the corresponding bitfield!
Enumerator
Extif1MB 

Area 1 MByte.

Extif2MB 

Area 2 MByte.

Extif4MB 

Area 4 MByte.

Extif8MB 

Area 8 MByte.

Extif16MB 

Area 16 MByte.

Extif32MB 

Area 32 MByte.

Extif64MB 

Area 64 MByte.

Extif128MB 

Area 128 MByte.

Definition at line 194 of file extif.h.

Extif RAS address select.

Select the address for the Row Address Select

Note
Do not change enumeration number. The numbers are taken for calculating the corresponding bitfield!
Enumerator
ExtifRas_19_6 

MAD[13:0] = Internal address [19:6].

ExtifRas_20_7 

MAD[13:0] = Internal address [20:7].

ExtifRas_21_8 

MAD[13:0] = Internal address [21:8].

ExtifRas_22_9 

MAD[13:0] = Internal address [22:9].

ExtifRas_23_10 

MAD[13:0] = Internal address [23:10].

ExtifRas_24_11 

MAD[13:0] = Internal address [24:11].

ExtifRas_25_12 

MAD[13:0] = Internal address [25:12].

Definition at line 230 of file extif.h.

Extif data width.

To select the data bus width

Enumerator
Extif8Bit 

8 Bit mode

Extif16Bit 

16 Bit mode

Definition at line 148 of file extif.h.

Function Documentation

en_result_t Extif_CheckSdcmdReady ( void  )

Check SDRAM command register is ready.

Return values
OkWriting to SDCMD register is possible
ErrorNotReadyAccess to SDCMD register not possible

Definition at line 468 of file extif.c.

References ErrorNotReady, Ok, and TRUE.

Referenced by Extif_SetSdramCommand().

Here is the caller graph for this function:

en_result_t Extif_ClearErrorStatus ( void  )

Clear Error Status Register.

Return values
OkStatus Error cleared

Definition at line 454 of file extif.c.

References Ok.

en_result_t Extif_InitArea ( uint8_t  u8Area,
stc_extif_area_config_t *  pstcConfig 
)

Setup (init) an EXT-I/F area.

Parameters
u8AreaExtbus I/F area (chip select) number
pstcConfigPointer to area configuration
Return values
OkSetup successful
ErrorInvalidParameterpstcConfig == NULL, Area number wrong, other invalid setting.
ErrorInvalidModeSDMODE is set for area different from 8

Definition at line 137 of file extif.c.

References stc_extif_area_config::bAddrOnDataLinesOff, stc_extif_area_config::bAleInvert, stc_extif_area_config::bMclkoutEnable, stc_extif_area_config::bMoexWidthAsFradc, stc_extif_area_config::bMpxcsOff, stc_extif_area_config::bMultiplexMode, stc_extif_area_config::bNandFlash, stc_extif_area_config::bPageAccess, stc_extif_area_config::bPrecedReadContinuousWrite, stc_extif_area_config::bRdyOn, stc_extif_area_config::bReadByteMask, stc_extif_area_config::bRefreshEnable, stc_extif_area_config::bSdramEnable, stc_extif_area_config::bSdramErrorInterruptEnable, stc_extif_intern_data::bSdramErrorInterruptEnable, stc_extif_area_config::bSdramPowerDownMode, stc_extif_area_config::bSdramRefreshOff, stc_extif_area_config::bSramFlashErrorInterruptEnable, stc_extif_intern_data::bSramFlashErrorInterruptEnable, stc_extif_area_config::bStopDataOutAtFirstIdle, stc_extif_area_config::bWriteEnableOff, stc_extif_area_config::enAddressLatchCycle, stc_extif_area_config::enAddressLatchWidthCycle, stc_extif_area_config::enAreaMask, stc_extif_area_config::enBasel, stc_extif_area_config::enCasel, stc_extif_area_config::enFirstReadAddressCycle, stc_extif_area_config::enRasel, stc_extif_area_config::enReadAccessCycle, stc_extif_area_config::enReadAddressSetupCycle, stc_extif_area_config::enReadIdleCycle, stc_extif_area_config::enSdramCasLatencyCycle, stc_extif_area_config::enSdramPrechargeCycle, stc_extif_area_config::enSdramRasActiveCycle, stc_extif_area_config::enSdramRasCasDelayCycle, stc_extif_area_config::enSdramRasCycle, stc_extif_area_config::enSdramRasPrechargeCycle, stc_extif_area_config::enSdramRefreshCycle, stc_extif_area_config::enWidth, stc_extif_area_config::enWriteAccessCycle, stc_extif_area_config::enWriteAddressSetupCycle, stc_extif_area_config::enWriteEnableCycle, stc_extif_area_config::enWriteIdleCycle, ErrorInvalidMode, ErrorInvalidParameter, EXTIF, Extif0Cycle, Extif16Bit, Extif16Cycle, Extif1Cycle, Extif2Cycle, Extif8Bit, ExtifCas16Bit, ExtifCas32Bit, ExtifDisabled, FALSE, Ok, PDL_IRQ_LEVEL_EXTIF, PDL_ZERO_STRUCT, stc_extif_area_config::pfnSdramErrorCallback, stc_extif_intern_data::pfnSdramErrorCallback, stc_extif_area_config::pfnSramFlashErrorCallback, stc_extif_intern_data::pfnSramFlashErrorCallback, TRUE, stc_extif_area_config::u16PowerDownCount, stc_extif_area_config::u16RefreshCount, stc_extif_area_config::u8AreaAddress, stc_extif_area_config::u8MclkDivision, and stc_extif_area_config::u8RefreshNumber.

uint32_t Extif_ReadErrorAddress ( void  )

Read Error Address Register.

Returns
uint32_t Error Address

Definition at line 443 of file extif.c.

en_result_t Extif_ReadErrorStatus ( void  )

Read Error Status Register.

Return values
OkNo error response exists
ErrorError response exists

Definition at line 427 of file extif.c.

References Error, Ok, and TRUE.

en_result_t Extif_SetSdramCommand ( uint16_t  u16Address,
boolean_t  bMsdwex,
boolean_t  bMcasx,
boolean_t  bMrasx,
boolean_t  bMcsx8,
boolean_t  bMadcke 
)

Set a SDRAM command.

Note
This function calls Extif_CheckSdcmdReady().
Parameters
u16AddressSDRAM address (MAD[15:00] pin values)
bMsdwexMDSWEX pin value
bMcasxMCASX pin value
bMrasxMRASX pin value
bMcsx8MCSX8 pin value
bMadckeMADCKE pin value
Return values
OkWriting to SDCMD register was successful
ErrorNotReadyAccess to SDCMD register was not possible

Definition at line 494 of file extif.c.

References ErrorNotReady, Extif_CheckSdcmdReady(), and Ok.

Here is the call graph for this function:

void ExtifIrqHandler ( void  )

External Bus Interface Error Interrupt Service Routine.

This function provides the user callback functions, if defined.

Definition at line 102 of file extif.c.

References stc_extif_intern_data::bSdramErrorInterruptEnable, stc_extif_intern_data::bSramFlashErrorInterruptEnable, stc_extif_intern_data::pfnSdramErrorCallback, stc_extif_intern_data::pfnSramFlashErrorCallback, and TRUE.

Variable Documentation

stc_extif_intern_data_t stcExtifInternData

Definition at line 77 of file extif.c.