LUFA Library

Board specific Dataflash driver header for the Atmel XMEGA B1 Xplained. More...

Macros

#define DATAFLASH_CHIP1   (1 << 2)
 
#define DATAFLASH_NO_CHIP   0
 
#define DATAFLASH_PAGE_SIZE   1024
 
#define DATAFLASH_PAGES   8192
 
#define DATAFLASH_TOTALCHIPS   1
 

Functions

static void Dataflash_DeselectChip (void) ATTR_ALWAYS_INLINE
 
static uint8_t Dataflash_GetSelectedChip (void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT
 
static void Dataflash_Init (void)
 
static uint8_t Dataflash_ReceiveByte (void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT
 
static void Dataflash_SelectChip (const uint8_t ChipMask) ATTR_ALWAYS_INLINE
 
static void Dataflash_SelectChipFromPage (const uint16_t PageAddress)
 
static void Dataflash_SendAddressBytes (uint16_t PageAddress, const uint16_t BufferByte)
 
static void Dataflash_SendByte (const uint8_t Byte) ATTR_ALWAYS_INLINE
 
static void Dataflash_ToggleSelectedChipCS (void)
 
static uint8_t Dataflash_TransferByte (const uint8_t Byte) ATTR_ALWAYS_INLINE
 
static void Dataflash_WaitWhileBusy (void)
 

Detailed Description

Board specific Dataflash driver header for the Atmel XMEGA B1 Xplained board.

NameInfoSelect PinSPI Port
DATAFLASH_CHIP1AT45DB642D (8MB)PORTD.2USARTC0 (In SPI Mode, Remapped)

Macro Definition Documentation

◆ DATAFLASH_CHIP1

#define DATAFLASH_CHIP1   (1 << 2)

Mask for the first dataflash chip selected.

◆ DATAFLASH_NO_CHIP

#define DATAFLASH_NO_CHIP   0

Mask for no dataflash chip selected.

◆ DATAFLASH_PAGE_SIZE

#define DATAFLASH_PAGE_SIZE   1024

Internal main memory page size for the board's dataflash ICs.

◆ DATAFLASH_PAGES

#define DATAFLASH_PAGES   8192

Total number of pages inside each of the board's dataflash ICs.

◆ DATAFLASH_TOTALCHIPS

#define DATAFLASH_TOTALCHIPS   1

Constant indicating the total number of dataflash ICs mounted on the selected board.

Function Documentation

◆ Dataflash_DeselectChip()

static void Dataflash_DeselectChip ( void  )
inlinestatic

Deselects the current dataflash chip, so that no dataflash is selected.

◆ Dataflash_GetSelectedChip()

static uint8_t Dataflash_GetSelectedChip ( void  )
inlinestatic

Determines the currently selected dataflash chip.

Returns
Mask of the currently selected Dataflash chip, either DATAFLASH_NO_CHIP if no chip is selected or a DATAFLASH_CHIPn mask (where n is the chip number).

◆ Dataflash_Init()

static void Dataflash_Init ( void  )
inlinestatic

Initializes the dataflash driver so that commands and data may be sent to an attached dataflash IC. The appropriate SPI interface will be automatically configured.

◆ Dataflash_ReceiveByte()

static uint8_t Dataflash_ReceiveByte ( void  )
inlinestatic

Sends a dummy byte to the currently selected dataflash IC, and returns the next byte from the dataflash.

Returns
Last response byte from the dataflash

◆ Dataflash_SelectChip()

static void Dataflash_SelectChip ( const uint8_t  ChipMask)
inlinestatic

Selects the given dataflash chip.

Parameters
[in]ChipMaskMask of the Dataflash IC to select, in the form of a DATAFLASH_CHIPn mask (where n is the chip number).

◆ Dataflash_SelectChipFromPage()

static void Dataflash_SelectChipFromPage ( const uint16_t  PageAddress)
inlinestatic

Selects a dataflash IC from the given page number, which should range from 0 to ((DATAFLASH_PAGES * DATAFLASH_TOTALCHIPS) - 1). For boards containing only one dataflash IC, this will select DATAFLASH_CHIP1. If the given page number is outside the total number of pages contained in the boards dataflash ICs, all dataflash ICs are deselected.

Parameters
[in]PageAddressAddress of the page to manipulate, ranging from 0 to ((DATAFLASH_PAGES * DATAFLASH_TOTALCHIPS) - 1).

◆ Dataflash_SendAddressBytes()

static void Dataflash_SendAddressBytes ( uint16_t  PageAddress,
const uint16_t  BufferByte 
)
inlinestatic

Sends a set of page and buffer address bytes to the currently selected dataflash IC, for use with dataflash commands which require a complete 24-bit address.

Parameters
[in]PageAddressPage address within the selected dataflash IC
[in]BufferByteAddress within the dataflash's buffer

◆ Dataflash_SendByte()

static void Dataflash_SendByte ( const uint8_t  Byte)
inlinestatic

Sends a byte to the currently selected dataflash IC, and ignores the next byte from the dataflash.

Parameters
[in]ByteByte of data to send to the dataflash

◆ Dataflash_ToggleSelectedChipCS()

static void Dataflash_ToggleSelectedChipCS ( void  )
inlinestatic

Toggles the select line of the currently selected dataflash IC, so that it is ready to receive a new command.

◆ Dataflash_TransferByte()

static uint8_t Dataflash_TransferByte ( const uint8_t  Byte)
inlinestatic

Sends a byte to the currently selected dataflash IC, and returns a byte from the dataflash.

Parameters
[in]ByteByte of data to send to the dataflash
Returns
Last response byte from the dataflash

◆ Dataflash_WaitWhileBusy()

static void Dataflash_WaitWhileBusy ( void  )
inlinestatic

Spin-loops while the currently selected dataflash is busy executing a command, such as a main memory page program or main memory to buffer transfer.