Eric Tsai / Mbed 2 deprecated AA_LIS3DH_SPI

Dependencies:   BLE_API TMP_nrf51 mbed nRF51822

Fork of VTT_NODEV3_LIS3DH by Juho Eskeli

Embed: (wiki syntax)

« Back to documentation index

AT45 Class Reference

AT45 Class Reference

Interface to the Atmel AT45 series Dataflash with Serial Interface (SPI) More...

#include <AT45.h>

Public Member Functions

 AT45 (SPI &spi, PinName ncs)
 Create an instance of the AT45 connected to specfied SPI pins, with the specified address.
char read_byte (int address)
 Read a byte.
int read_page (char *data, int page)
 Read a page.
int read_block (char *data, int block)
 Read a block (from 1 dimension array).
int read_block (char *data[], int block)
 Read a block (from 2 dimension array).
void write_byte (int address, char data)
 Write a byte.
int write_page (char *data, int page)
 Write a page.
int write_block (char *data, int block)
 Write a block (from 1 dimension array).
int write_block (char *data[], int block)
 Write a block (from 2 dimension array).
int FAT_read (char *data, int page)
 FAT Read (512 bits).
int FAT_write (char *data, int page)
 FAT Write (512bits).
void chip_erase (void)
 Function to erase the entire chip.
void block_erase (int block)
 Function to erase the selected block.
void page_erase (int page)
 Function to erase the selected block.
int device_size (void)
 Device size in mbits.
int pages (void)
 Pages in flash.
int pagesize (void)
 Page size.
void set_pageszie_to_binary (void)
 Function to set the page size to binary.
int blocks (void)
 blocks in flash.
int id (void)
 ID of the device.
int status (void)
 Status register.
void busy (void)
 busy ?.
void deep_power_down (bool onoff)
 Deep Power Down.
bool is_it_awake (void)
 Is the device deep power down.

Detailed Description

Interface to the Atmel AT45 series Dataflash with Serial Interface (SPI)

Using the driver:

  • remenber to setup SPI in main routine.
  • remenber to setup Chipselect in main routine.
  • remenber to use FAT functions set pagesize to binary.

Limitations of using this driver:

  • can't use lockdown functions.
  • can't use protections functions.
  • can't use security functions.

Definition at line 56 of file AT45.h.


Constructor & Destructor Documentation

AT45 ( SPI &  spi,
PinName  ncs 
)

Create an instance of the AT45 connected to specfied SPI pins, with the specified address.

Parameters:
spiThe mbed SPI instance (make in main routine)
nCsThe SPI chip select pin.

Definition at line 31 of file AT45.cpp.


Member Function Documentation

void block_erase ( int  block )

Function to erase the selected block.

Parameters:
blockThe selected block to erase.

Definition at line 496 of file AT45.cpp.

int blocks ( void   )

blocks in flash.

Returns:
Numbers af blocks.

Definition at line 622 of file AT45.cpp.

void busy ( void   )

busy ?.

Function will want to the device is not busy.

Definition at line 651 of file AT45.cpp.

void chip_erase ( void   )

Function to erase the entire chip.

Issue: In a certain percentage of units, the chip erase feature may not function correctly and may adversely affect device operation. Therefore, it is recommended that the chip erase commands (opcodes C7H, 94H, 80H, and 9AH) not be used. Workaround: Use block erase (opcode 50H) as an alternative. The block erase function is not affected by the chip erase issue. Resolution: The chip erase feature may be fixed with a new revision of the device. Please contact Atmel for the estimated availability of devices with the fix.

Definition at line 480 of file AT45.cpp.

void deep_power_down ( bool  onoff )

Deep Power Down.

Remenber that you have to want 35uS after the wake up to use the device.

Parameters:
True= Activate and False = Wake Up.

Definition at line 656 of file AT45.cpp.

int device_size ( void   )

Device size in mbits.

Returns:
device size.

Definition at line 588 of file AT45.cpp.

int FAT_read ( char *  data,
int  page 
)

FAT Read (512 bits).

Remenber to set page size to binary.

Parameters:
dataThe data is pointer to a userdefined array that the page is read into.
pageThe page number of the page to read (0 to device page size).
Returns:
Returns "0".

Definition at line 268 of file AT45.cpp.

int FAT_write ( char *  data,
int  page 
)

FAT Write (512bits).

Remenber to set page size to binary.

Parameters:
dataThe data is pointer to a userdefined array that holds the data to write into.
pageThe page number of the page to write into (0 to device page size).
Returns:
Returns "0" or "-1" for error.

Definition at line 373 of file AT45.cpp.

int id ( void   )

ID of the device.

Returns:
Manufacturer, Family and Density code.

Definition at line 628 of file AT45.cpp.

bool is_it_awake ( void   )

Is the device deep power down.

Returns:
True = Activate and False = Awake.

Definition at line 706 of file AT45.cpp.

void page_erase ( int  page )

Function to erase the selected block.

Parameters:
pageThe number of the page to erase.

Definition at line 542 of file AT45.cpp.

int pages ( void   )

Pages in flash.

Returns:
Numbers af pages.

Definition at line 594 of file AT45.cpp.

int pagesize ( void   )

Page size.

for 2-8 Mbits 256 or 264 for 16-32 Mbits 512 or 528 for 64 Mbits 1024 or 1056

Returns:
Page size.

Definition at line 600 of file AT45.cpp.

int read_block ( char *  data,
int  block 
)

Read a block (from 1 dimension array).

Parameters:
dataThe data is pointer to a userdefined array that holds 4096 bytes of the data that is read into.
blockThe block number of the block to read (0 to device block size).
Returns:
Returns "0" or "-1" for error.

Definition at line 102 of file AT45.cpp.

int read_block ( char *  data[],
int  block 
)

Read a block (from 2 dimension array).

Then using 2 dimension array, the array shall have a starting point like "read_block(data[0],0)"

Parameters:
dataThe data is pointer to a userdefined array that holds 8 x 512 bytes of the data that is read into.
blockThe block number of the block to read (0 to device block size).
Returns:
Returns "0" or "-1" for error.

Definition at line 125 of file AT45.cpp.

char read_byte ( int  address )

Read a byte.

Parameters:
addressThe address of the byte to read.
Returns:
The data in the byte.

Definition at line 45 of file AT45.cpp.

int read_page ( char *  data,
int  page 
)

Read a page.

Parameters:
dataThe data is pointer to a userdefined array that the page is read into.
pageThe page number of the page to read (0 to device page size).
Returns:
Returns "0" or "-1" for error.

Definition at line 51 of file AT45.cpp.

void set_pageszie_to_binary ( void   )

Function to set the page size to binary.

Remenber is a one-time programmable configuration. Remenber to total power down after the functions has been run.

Definition at line 606 of file AT45.cpp.

int status ( void   )

Status register.

Returns:
The status register.

Definition at line 640 of file AT45.cpp.

int write_block ( char *  data,
int  block 
)

Write a block (from 1 dimension array).

Parameters:
dataThe data is pointer to a userdefined array that holds 4096 bytes of the data to write into.
blockThe block number of the block to write into (0 to device block size).
Returns:
Returns "0" or "-1" for error.

Definition at line 217 of file AT45.cpp.

int write_block ( char *  data[],
int  block 
)

Write a block (from 2 dimension array).

Then using 2 dimension array, the array shall have a starting point like "write_block(data[0],0)"

Parameters:
dataThe data is pointer to a userdefined array that holds 8 x 512 bytes of the data to write into (remenber it has to be a 2 dimension array).
blockThe block number of the block to write into (0 to device block size).
Returns:
Returns "0" or "-1" for error.

Definition at line 241 of file AT45.cpp.

void write_byte ( int  address,
char  data 
)

Write a byte.

Parameters:
addressThe address to where the data is storage in the flash.
dataThe data to write into the flash.

Definition at line 154 of file AT45.cpp.

int write_page ( char *  data,
int  page 
)

Write a page.

Parameters:
dataThe data is pointer to a userdefined array that holds the data to write into.
pageThe page number of the page to write into (0 to device page size).
Returns:
Returns "0" or "-1" for error.

Definition at line 164 of file AT45.cpp.