Contiki-Inga 3.x
|
Data Structures | |
struct | bufmgr_t |
Macros | |
#define | AT45DB_CS 1 |
#define | AT45DB_STATUS_REG 0xD7 |
#define | AT45DB_BLOCK_ERASE 0x50 |
#define | AT45DB_PAGE_ERASE 0x81 |
#define | AT45DB_PAGE_PROGRAM_1 0x82 |
#define | AT45DB_PAGE_PROGRAM_2 0x85 |
#define | AT45DB_BUFFER_1 0x84 |
#define | AT45DB_BUFFER_2 0x87 |
#define | AT45DB_BUF_1_TO_PAGE 0x83 |
#define | AT45DB_BUF_2_TO_PAGE 0x86 |
#define | AT45DB_PAGE_READ 0xD2 |
#define | AT45DB_PAGE_TO_BUF 0x55 |
#define | AT45DB_READ_BUFFER 0xD6 |
Functions | |
int8_t | at45db_init (void) |
Initialize the AT45DBxx1 Flash EEPROM. More... | |
void | at45db_erase_chip (void) |
This function erases the whole chip. More... | |
void | at45db_erase_block (uint16_t addr) |
This function erases one block (4 Kbytes) More... | |
void | at45db_erase_page (uint16_t addr) |
This function erases one page e.g. More... | |
void | at45db_write_buffer (uint16_t addr, uint8_t *buffer, uint16_t bytes) |
This function writes bytes to the active buffer, while the buffer management is done automatically. More... | |
void | at45db_buffer_to_page (uint16_t addr) |
This function copies the active buffer into the Flash EEPROM page. More... | |
void | at45db_write_page (uint16_t p_addr, uint16_t b_addr, uint8_t *buffer, uint16_t bytes) |
This function copies the data from the the pointer into the buffer, erases the EEPROM page and flashes the new content directly into the page. More... | |
void | at45db_read_page_buffered (uint16_t p_addr, uint16_t b_addr, uint8_t *buffer, uint16_t bytes) |
Bytes can be read via buffer from a Flash EEPROM page. More... | |
void | at45db_read_page_bypassed (uint16_t p_addr, uint16_t b_addr, uint8_t *buffer, uint16_t bytes) |
Bytes can be read direct (bypassed) from a Flash EEPROM page. More... | |
void | at45db_page_to_buf (uint16_t addr) |
Copies the given page into the buffer 2. More... | |
void | at45db_read_buffer (uint16_t b_addr, uint8_t *buffer, uint16_t bytes) |
This function readouts the buffer 2 data. More... | |
void | at45db_write_cmd (uint8_t *cmd) |
The command word of the AT45DBxx1 normally consists of 4 bytes. More... | |
void | at45db_busy_wait (void) |
This function waits until the busy flag of the status register is set, to detect when the AT45DBxx1 device is ready to receive new commands. | |
A fixed Flash EEPROM is always good to store some data. Furthermore in this project environment, the AT45DBxx1 will be used as a hardware interface between the boot section and the application section.
#define AT45DB_BLOCK_ERASE 0x50 |
#define AT45DB_BUF_1_TO_PAGE 0x83 |
#define AT45DB_BUF_2_TO_PAGE 0x86 |
#define AT45DB_BUFFER_1 0x84 |
Write byte(s) to buffer 1 opcode
Definition at line 109 of file at45db.h.
Referenced by at45db_init().
#define AT45DB_BUFFER_2 0x87 |
Write byte(s) to buffer 2 opcode
Definition at line 113 of file at45db.h.
Referenced by at45db_init().
#define AT45DB_CS 1 |
SPI device order. The chip select number where the AT45DBxx1 Flash EEPROM is connected to the BCD-decimal decoder
Definition at line 79 of file at45db.h.
Referenced by at45db_buffer_to_page(), at45db_busy_wait(), at45db_erase_block(), at45db_erase_chip(), at45db_erase_page(), at45db_init(), at45db_page_to_buf(), at45db_read_buffer(), at45db_read_page_bypassed(), at45db_write_buffer(), at45db_write_cmd(), and at45db_write_page().
#define AT45DB_PAGE_ERASE 0x81 |
#define AT45DB_PAGE_PROGRAM_1 0x82 |
Main Memory Page Program Buffer 1
Definition at line 100 of file at45db.h.
Referenced by at45db_init().
#define AT45DB_PAGE_PROGRAM_2 0x85 |
Main Memory Page Program Buffer 2
Definition at line 104 of file at45db.h.
Referenced by at45db_init().
#define AT45DB_PAGE_READ 0xD2 |
Read direct from Flash EEPROM page Opcode
Definition at line 126 of file at45db.h.
Referenced by at45db_read_page_bypassed().
#define AT45DB_PAGE_TO_BUF 0x55 |
Transfer page to buffer 2 Opcode
Definition at line 133 of file at45db.h.
Referenced by at45db_page_to_buf().
#define AT45DB_READ_BUFFER 0xD6 |
Read buffer 2 opcode
Definition at line 139 of file at45db.h.
Referenced by at45db_read_buffer().
#define AT45DB_STATUS_REG 0xD7 |
Status Register Address. Bit 7 signalizes if the device is busy.
Definition at line 87 of file at45db.h.
Referenced by at45db_busy_wait().
void at45db_buffer_to_page | ( | uint16_t | addr | ) |
This function copies the active buffer into the Flash EEPROM page.
Moreover it switches the active buffer to avoid latency.
addr | page address e.g. AT45DB161 (0 ... 4095) |
Definition at line 159 of file at45db.c.
References bufmgr_t::active_buffer, at45db_busy_wait(), AT45DB_CS, at45db_write_cmd(), bufmgr_t::buf_to_page_addr, and mspi_chip_release().
void at45db_erase_block | ( | uint16_t | addr | ) |
This function erases one block (4 Kbytes)
addr | block address e.g. AT45DB161 (0 ... 511) |
Definition at line 114 of file at45db.c.
References AT45DB_BLOCK_ERASE, at45db_busy_wait(), AT45DB_CS, at45db_write_cmd(), mspi_chip_release(), and mspi_chip_select().
void at45db_erase_chip | ( | void | ) |
This function erases the whole chip.
Definition at line 101 of file at45db.c.
References at45db_busy_wait(), AT45DB_CS, at45db_write_cmd(), mspi_chip_release(), and mspi_chip_select().
void at45db_erase_page | ( | uint16_t | addr | ) |
This function erases one page e.g.
AT45DB161 (512 bytes)
addr | page address e.g. AT45DB161 (0 ... 4095) |
Definition at line 128 of file at45db.c.
References at45db_busy_wait(), AT45DB_CS, AT45DB_PAGE_ERASE, at45db_write_cmd(), mspi_chip_release(), and mspi_chip_select().
int8_t at45db_init | ( | void | ) |
Initialize the AT45DBxx1 Flash EEPROM.
0 | at45db available |
-1 | at45db not available |
Definition at line 68 of file at45db.c.
References bufmgr_t::active_buffer, AT45DB_BUF_1_TO_PAGE, AT45DB_BUF_2_TO_PAGE, AT45DB_BUFFER_1, AT45DB_BUFFER_2, AT45DB_CS, AT45DB_PAGE_PROGRAM_1, AT45DB_PAGE_PROGRAM_2, bufmgr_t::buf_to_page_addr, bufmgr_t::buffer_addr, MSPI_BAUD_MAX, mspi_chip_release(), mspi_chip_select(), mspi_init(), MSPI_MODE_3, mspi_transceive(), and bufmgr_t::page_program.
void at45db_page_to_buf | ( | uint16_t | addr | ) |
Copies the given page into the buffer 2.
addr | page address e.g. AT45DB161 (0 - 4095) |
Definition at line 231 of file at45db.c.
References at45db_busy_wait(), AT45DB_CS, AT45DB_PAGE_TO_BUF, at45db_write_cmd(), and mspi_chip_release().
Referenced by at45db_read_page_buffered().
void at45db_read_buffer | ( | uint16_t | b_addr, |
uint8_t * | buffer, | ||
uint16_t | bytes | ||
) |
This function readouts the buffer 2 data.
b_addr | byte address within the page e.g. AT45DB161 (0 - 527) |
*buffer | Pointer to local byte buffer |
bytes | Number of bytes (e.g. byte buffer size) which have to be read to the local byte buffer |
Definition at line 249 of file at45db.c.
References at45db_busy_wait(), AT45DB_CS, AT45DB_READ_BUFFER, at45db_write_cmd(), mspi_chip_release(), and mspi_transceive().
Referenced by at45db_read_page_buffered().
void at45db_read_page_buffered | ( | uint16_t | p_addr, |
uint16_t | b_addr, | ||
uint8_t * | buffer, | ||
uint16_t | bytes | ||
) |
Bytes can be read via buffer from a Flash EEPROM page.
With this function you select the page, the start byte within the page and the number of bytes you want to read.
p_addr | page address e.g. AT45DB161 (0 - 4095) |
b_addr | byte address within the page e.g. AT45DB161 (0 - 527) |
*buffer | Pointer to local byte buffer |
bytes | Number of bytes (e.g. byte buffer size) which have to be read to the local byte buffer |
Definition at line 196 of file at45db.c.
References at45db_busy_wait(), at45db_page_to_buf(), and at45db_read_buffer().
void at45db_read_page_bypassed | ( | uint16_t | p_addr, |
uint16_t | b_addr, | ||
uint8_t * | buffer, | ||
uint16_t | bytes | ||
) |
Bytes can be read direct (bypassed) from a Flash EEPROM page.
With this function you select the page, the start byte within the page and the number of bytes you want to read.
p_addr | page address e.g. AT45DB161 (0 - 4095) |
b_addr | byte address within the page e.g. AT45DB161 (0 - 527) |
*buffer | Pointer to local byte buffer |
bytes | Number of bytes (e.g. byte buffer size) which have to be read to the local byte buffer |
Definition at line 206 of file at45db.c.
References at45db_busy_wait(), AT45DB_CS, AT45DB_PAGE_READ, at45db_write_cmd(), mspi_chip_release(), and mspi_transceive().
void at45db_write_buffer | ( | uint16_t | addr, |
uint8_t * | buffer, | ||
uint16_t | bytes | ||
) |
This function writes bytes to the active buffer, while the buffer management is done automatically.
addr | Byte address within the buffer e.g. AT45DB161 (0 ... 527) |
*buffer | Pointer to local byte buffer |
bytes | Number of bytes (e.g. byte buffer size) which have to be written to the active buffer |
Definition at line 142 of file at45db.c.
References bufmgr_t::active_buffer, AT45DB_CS, at45db_write_cmd(), bufmgr_t::buffer_addr, mspi_chip_release(), and mspi_transceive().
void at45db_write_cmd | ( | uint8_t * | cmd | ) |
The command word of the AT45DBxx1 normally consists of 4 bytes.
This function enables the chip select and sends the command (opcode + address information) to the AT45DBxx1.
*cmd | Pointer to the 4 byte command array |
Definition at line 265 of file at45db.c.
References AT45DB_CS, mspi_chip_select(), and mspi_transceive().
Referenced by at45db_buffer_to_page(), at45db_erase_block(), at45db_erase_chip(), at45db_erase_page(), at45db_page_to_buf(), at45db_read_buffer(), at45db_read_page_bypassed(), at45db_write_buffer(), and at45db_write_page().
void at45db_write_page | ( | uint16_t | p_addr, |
uint16_t | b_addr, | ||
uint8_t * | buffer, | ||
uint16_t | bytes | ||
) |
This function copies the data from the the pointer into the buffer, erases the EEPROM page and flashes the new content directly into the page.
p_addr | page address e.g. AT45DB161 (0 - 4095) |
b_addr | byte address within the page e.g. AT45DB161 (0 - 527) |
*buffer | Pointer to local byte buffer |
bytes | Number of bytes (e.g. byte buffer size) which have to be read to the local byte buffer |
Definition at line 174 of file at45db.c.
References bufmgr_t::active_buffer, AT45DB_CS, at45db_write_cmd(), mspi_chip_release(), mspi_transceive(), and bufmgr_t::page_program.