Xmega Application Note


ebi_driver.h File Reference


Detailed Description

XMEGA External Bus Interface driver header file.

This file contains the function prototypes and enumerator definitions for various configuration parameters for the XMEGA EBI driver.

The driver is not intended for size and/or speed critical code, since most functions are just a few lines of code, and the function call overhead would decrease code performance. The driver is intended for rapid prototyping and documentation purposes for getting started with the XMEGA EBI module.

For size and/or speed critical code, it is recommended to copy the function contents directly into your application instead of making a function call.

Application note:
AVR1312: Using the XMEGA External Bus Interface
Documentation
For comprehensive code documentation, supported compilers, compiler settings and supported devices see readme.html
Author:
Atmel Corporation: http://www.atmel.com
Support email: avr@atmel.com
Revision
479
Date
2007-03-05 16:30:19 +0100 (ma, 05 mar 2007)

Copyright (c) 2008, Atmel Corporation All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

3. The name of ATMEL may not be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Definition in file ebi_driver.h.

#include "avr_compiler.h"

Include dependency graph for ebi_driver.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define EBI_Disable()   (EBI.CTRL = EBI.CTRL & ~EBI_IFMODE_gm | EBI_IFMODE_DISABLED_gc)
 Disable EBI module.
#define EBI_DisableChipSelect(_chipSelect)   ( (_chipSelect)->CTRLA = (_chipSelect)->CTRLA & ~EBI_CS_MODE_gm | EBI_CS_MODE_DISABLED_gc )
 Disable a Chip Select module.
#define EBI_DisableSelfRefresh()   (EBI.CS3.CTRLB &= ~EBI_CS_SDSREN_bm)
 Disable SDRAM Self-refresh mode.
#define EBI_EnableSelfRefresh()   (EBI.CS3.CTRLB |= EBI_CS_SDSREN_bm)
 Enable SDRAM Self-refresh mode.
#define EBI_SetSDRAMMode(_sdramMode)   ( EBI.CS3.CTRLB = EBI.CS3.CTRLB & ~EBI_CS_SDMODE_gm | (_sdramMode) )
 Switch between normal SDRAM mode and "Load Mode Register" operation.

Functions

void EBI_Enable (EBI_SDDATAW_t sdramDataWidth, EBI_LPCMODE_t lpcMode, EBI_SRMODE_t sramMode, EBI_IFMODE_t interfaceMode)
 Enable EBI module and configure memory types without enabling any Chip Select modules.
void EBI_EnableLPC (volatile EBI_CS_t *chipSelect, EBI_CS_ASPACE_t addrSpace, uint32_t baseAddr, uint8_t waitStateCycles)
 Enable a Chip Select module for LPC operation.
void EBI_EnableSDRAM (EBI_CS_ASPACE_t addrSpace, uint32_t baseAddr, bool casLatency, bool rowBits, EBI_SDCOL_t columnBits, EBI_MRDLY_t modeRegisterDelay, EBI_ROWCYCDLY_t rowCycleDelay, EBI_RPDLY_t rowToPrechargeDelay, EBI_WRDLY_t writeRecoveryDelay, EBI_ESRDLY_t exitSelfRefreshToActiveDelay, EBI_ROWCOLDLY_t rowToColumnDelay, uint16_t refreshPeriod, uint16_t initializationDelay)
 Enable a Chip Select module for SDRAM operation.
void EBI_EnableSRAM (volatile EBI_CS_t *chipSelect, EBI_CS_ASPACE_t addrSpace, uint32_t baseAddr, uint8_t waitStateCycles)
 Enable a Chip Select module for SRAM operation.


Define Documentation

 
#define EBI_Disable (  )     (EBI.CTRL = EBI.CTRL & ~EBI_IFMODE_gm | EBI_IFMODE_DISABLED_gc)

Disable EBI module.

This function disables the EBI module. This will abort any on-going operations, such as DMA transfers.

Definition at line 136 of file ebi_driver.h.

#define EBI_DisableChipSelect ( _chipSelect   )     ( (_chipSelect)->CTRLA = (_chipSelect)->CTRLA & ~EBI_CS_MODE_gm | EBI_CS_MODE_DISABLED_gc )

Disable a Chip Select module.

This function disables one Chip Select submodule.

Parameters:
_chipSelect The EBI_CS_t struct instance

Definition at line 146 of file ebi_driver.h.

 
#define EBI_DisableSelfRefresh (  )     (EBI.CS3.CTRLB &= ~EBI_CS_SDSREN_bm)

Disable SDRAM Self-refresh mode.

This function disables self-refresh for SDRAM. Use this after leaving sleep mode so that SDRAM is accessible again.

Definition at line 176 of file ebi_driver.h.

 
#define EBI_EnableSelfRefresh (  )     (EBI.CS3.CTRLB |= EBI_CS_SDSREN_bm)

Enable SDRAM Self-refresh mode.

This function enables self-refresh for SDRAM. Use this before entering sleep mode so that SDRAM device refreshes itself. SDRAM will be inaccessible while in self-refresh mode.

Definition at line 167 of file ebi_driver.h.

#define EBI_SetSDRAMMode ( _sdramMode   )     ( EBI.CS3.CTRLB = EBI.CS3.CTRLB & ~EBI_CS_SDMODE_gm | (_sdramMode) )

Switch between normal SDRAM mode and "Load Mode Register" operation.

This function selects normal operation or Load Mode Register for SDRAM operation. SDRAM must be enabled first.

Parameters:
_sdramMode Selects SDRAM mode.

Definition at line 157 of file ebi_driver.h.


Function Documentation

void EBI_Enable ( EBI_SDDATAW_t  sdramDataWidth,
EBI_LPCMODE_t  lpcMode,
EBI_SRMODE_t  sramMode,
EBI_IFMODE_t  interfaceMode 
)

Enable EBI module and configure memory types without enabling any Chip Select modules.

This function enables the EBI module. Note that individual Chip Select submodules must be enabled using EBI_EnableSRAM(...), EBI_EnableLPC(...) or EBI_EnableSDRAM(...).

This function also applies various parameters regarding SRAM, LPC and SDRAM operation, however these does not come into play before a Chip Select submodule is enabled.

Parameters:
sdramDataWidth SDRAM module to use 4-bit or 8-bit data bus.
lpcMode ALE mode for SRAM LPC operation.
sramMode ALE mode for ordinary SRAM operation.
interfaceMode EBI module to use 2-port, 3-port or 4-port interface. Note that SDRAM needs 3-port or 4-port.

Definition at line 85 of file ebi_driver.c.

Referenced by main().

00089 {
00090         /* These fields fill up the whole register, so we don't have to protect any bits with masks. */
00091         EBI.CTRL = (uint8_t) sdramDataWidth | lpcMode | sramMode | interfaceMode;
00092 }

void EBI_EnableLPC ( volatile EBI_CS_t *  chipSelect,
EBI_CS_ASPACE_t  addrSpace,
uint32_t  baseAddr,
uint8_t  waitStateCycles 
)

Enable a Chip Select module for LPC operation.

This function enables one Chip Select submodule for SRAM LPC operation.

Parameters:
chipSelect Pointer to Chip Select register submodule.
addrSpace Address space covered by this Chip Select submodule.
baseAddr Base address. This will be truncated to a 4K boundary.
waitStateCycles Wait state cycle count for SRAM LPC operation.

Definition at line 133 of file ebi_driver.c.

00137 {
00138         /* Configure SRAM LPC settings. */
00139         chipSelect->CTRLB = (chipSelect->CTRLB & ~EBI_CS_SRWS_gm) |
00140                             (waitStateCycles & EBI_CS_SRWS_gm); /* Truncate too large values. */
00141 
00142         /* Truncate the base address to an address space boundary. */
00143         chipSelect->BASEADDR = (((uint32_t) baseAddr)>>8) & (0xFFFF<<(addrSpace>>2));
00144 
00145         /* Last part of configuration and then enable Chip Select module in SRAM LPC mode. */
00146         chipSelect->CTRLA = (chipSelect->CTRLA & ~(EBI_CS_ASPACE_gm | EBI_CS_MODE_gm)) |
00147                             addrSpace | EBI_CS_MODE_LPC_gc;
00148 }

void EBI_EnableSDRAM ( EBI_CS_ASPACE_t  addrSpace,
uint32_t  baseAddr,
bool  casLatency,
bool  rowBits,
EBI_SDCOL_t  columnBits,
EBI_MRDLY_t  modeRegisterDelay,
EBI_ROWCYCDLY_t  rowCycleDelay,
EBI_RPDLY_t  rowToPrechargeDelay,
EBI_WRDLY_t  writeRecoveryDelay,
EBI_ESRDLY_t  exitSelfRefreshToActiveDelay,
EBI_ROWCOLDLY_t  rowToColumnDelay,
uint16_t  refreshPeriod,
uint16_t  initializationDelay 
)

Enable a Chip Select module for SDRAM operation.

This function enables Chip Select submodule 3 for SDRAM operation. SDARM operation is only supported by Chip Select submodule 3.

Parameters:
addrSpace Address space covered by this Chip Select submodule.
baseAddr Base address. This will be truncated to a 4K boundary.
casLatency False = 2 cycles, true = 3 cycles.
rowBits False = 11 row bits, True = 12 row bits.
columnBits Column bits configuration. 8-11 column bits.
modeRegisterDelay Delay between Mode Register and Activate command. 0-3 cycles.
rowCycleDelay Delay between Refresh and Activate command. 0-7 cycles.
rowToPrechargeDelay Delay between Pre-charge and another command. 0-7 cycles.
writeRecoveryDelay Write Recovery time. 0-3 cycles.
exitSelfRefreshToActiveDelay Delay between CKE high and Activate command. 0-7 cycles.
rowToColumnDelay Delay between Activate and Read/Write command. 0-7 cycles.
refreshPeriod SDRAM refresh period. 0-1023 cycles.
initializationDelay SDRAM initialization delay. 0-1023 cycles.

Definition at line 171 of file ebi_driver.c.

Referenced by main().

00184 {
00185         /* Set two single-bit fields and one larger field, while protecting reserved bits. */
00186         EBI.SDRAMCTRLA = (EBI.SDRAMCTRLA & ~(EBI_SDCAS_bm | EBI_SDROW_bm | EBI_SDCOL_gm)) |
00187                          (casLatency ? EBI_SDCAS_bm : 0) | (rowBits ? EBI_SDROW_bm : 0) | columnBits;
00188 
00189         /* Set delay counts. Fields fill up the entire registers. */
00190         EBI.SDRAMCTRLB = (uint8_t) modeRegisterDelay | rowCycleDelay | rowToPrechargeDelay;
00191         EBI.SDRAMCTRLC = (uint8_t) writeRecoveryDelay | exitSelfRefreshToActiveDelay | rowToColumnDelay;
00192 
00193         /* Set refresh period and initialization delay, truncate too large values. */
00194         EBI.REFRESH = refreshPeriod & 0x03FF;
00195         EBI.INITDLY = initializationDelay & 0x3FFF;
00196 
00197         /* Last part of configuration and then enable Chip Select module in SDRAM mode. */
00198         EBI.CS3.CTRLB = (EBI.CS3.CTRLB & ~(EBI_CS_SDSREN_bm | EBI_CS_SDMODE_gm)) |
00199                         EBI_CS_SDMODE_NORMAL_gc;
00200 
00201         /* Truncate the base address to an address space boundary. */
00202         EBI.CS3.BASEADDR = (((uint32_t) baseAddr)>>8) & (0xFFFF<<(addrSpace>>2));
00203 
00204         EBI.CS3.CTRLA = (EBI.CS3.CTRLA & ~(EBI_CS_ASPACE_gm | EBI_CS_MODE_gm)) |
00205                         addrSpace | EBI_CS_MODE_SDRAM_gc;
00206 
00207         /* Wait for SDRAM to initialize. */
00208         while ((EBI.CS3.CTRLB & EBI_CS_SDINITDONE_bm) == 0){
00209 
00210         }
00211 }

void EBI_EnableSRAM ( volatile EBI_CS_t *  chipSelect,
EBI_CS_ASPACE_t  addrSpace,
uint32_t  baseAddr,
uint8_t  waitStateCycles 
)

Enable a Chip Select module for SRAM operation.

This function enables one Chip Select submodule for SRAM operation.

Parameters:
chipSelect Pointer to Chip Select register submodule.
addrSpace Address space covered by this Chip Select submodule.
baseAddr Base address. This will be truncated to a 4K boundary.
waitStateCycles Wait state cycle count for SRAM operation.

Definition at line 105 of file ebi_driver.c.

Referenced by main().

00109 {
00110         /* Configure SRAM settings. */
00111         chipSelect->CTRLB = (chipSelect->CTRLB & ~EBI_CS_SRWS_gm) |
00112                             (waitStateCycles & EBI_CS_SRWS_gm); /* Truncate too large values. */
00113 
00114         /* Truncate the base address to an address space boundary. */
00115         chipSelect->BASEADDR = (((uint32_t) baseAddr)>>8) & (0xFFFF<<(addrSpace>>2));
00116 
00117         /* Last part of configuration and then enable Chip Select module in SRAM mode. */
00118         chipSelect->CTRLA = (chipSelect->CTRLA & ~(EBI_CS_ASPACE_gm | EBI_CS_MODE_gm)) |
00119                             addrSpace | EBI_CS_MODE_SRAM_gc;
00120 }

@DOC_TITLE@
Generated on Mon Jun 21 09:15:38 2010 for AVR1312 Using the XMEGA External Bus Interface by doxygen 1.5.5