|
px-fwlib 0.10.0
Cross-platform embedded library and documentation for 8/16/32-bit microcontrollers generated with Doxygen 1.9.2
|
Driver that communicates with an Adesto AT25S Serial Flash using SPI.
File(s):
Reference:
Example:
Macros | |
| #define | PX_AT25S_PAGE_SIZE 256 |
| AT25S page size. More... | |
| #define | PX_AT25S_FLASH_SIZE_BYTES (PX_AT25S_PAGES * PX_AT25S_PAGE_SIZE) |
| Flash size (in bytes) More... | |
| #define | PX_AT25S_ADR_MAX (PX_AT25S_FLASH_SIZE_BYTES - 1) |
| Maximum address. More... | |
| #define | PX_AT25S_MAX_SPI_CLOCK_HZ 33000000 |
| Maximum SPI Clock rate. More... | |
| #define | PX_AT25S_SPI_MODE PX_SPI_MODE0 |
| SPI Clock / Data phase. More... | |
| #define | PX_AT25S_SPI_DATA_ORDER PX_SPI_DATA_ORDER_MSB |
| SPI Data order. More... | |
| #define | PX_AT25S_CFG_DEVICE PX_CFG_DEV_AT25SF041 |
| Specify device. More... | |
Enumerations | |
| enum | px_at25s_block_t |
| AT25S block selection. More... | |
Functions | |
| void | px_at25s_init (px_spi_handle_t *handle) |
| Initialise driver. More... | |
| void | px_at25s_deep_power_down (void) |
| Power down device to minimise power consumption. More... | |
| void | px_at25s_resume_from_deep_power_down (void) |
| Power up device to resume communication. More... | |
| void | px_at25s_rd (void *buf, uint32_t adr, uint16_t nr_of_bytes) |
| Read data from Serial Flash. More... | |
| void | px_at25s_rd_page (void *buf, uint16_t page) |
| Read a page from Serial Flash. More... | |
| void | px_at25s_rd_page_offset (void *buf, uint16_t page, uint8_t start_byte_in_page, uint16_t nr_of_bytes) |
| Partial read of data in a page of Serial Flash. More... | |
| void | px_at25s_wr_page (const void *buf, uint16_t page) |
| Write a page from Serial Flash. More... | |
| void | px_at25s_wr_page_offset (const void *buf, uint16_t page, uint8_t start_byte_in_page, uint16_t nr_of_bytes) |
| Partial write of data in a page of Serial Flash. More... | |
| void | px_at25s_erase (px_at25s_block_t block, uint16_t page) |
| Erase a block of Serial Flash. More... | |
| bool | px_at25s_ready (void) |
| Check if Serial Flash is ready for the next read or write access. More... | |
| uint8_t | px_at25s_rd_status_reg1 (void) |
| Read status register 1 of the Serial Flash. More... | |
| void | px_at25s_rd_man_and_dev_id (uint8_t *buf) |
| Read Manufacturer and Device ID. More... | |
List of supported AT25S devices | |
| #define | PX_CFG_DEV_AT25SF041 0 |
| 4 Mbit, 2.5-3.6V 104 MHz Standard Serial Flash More... | |
| #define | PX_CFG_DEV_AT25SF081 1 |
| 8 Mbit, 2.5-3.6V 104 MHz Standard Serial Flash More... | |
| #define | PX_CFG_DEV_AT25SF161 2 |
| 16 Mbit, 2.5-3.6V 104 MHz Standard Serial Flash More... | |
| #define | PX_CFG_DEV_AT25SF321 3 |
| 32 Mbit, 2.5-3.6V 104 MHz Standard Serial Flash More... | |
| #define | PX_CFG_DEV_AT25SF641 4 |
| 64 Mbit, 2.5-3.6V 104 MHz Standard Serial Flash More... | |
AT25S block sizes | |
| #define | PX_AT25S_BLOCK_SIZE_4KB (4 * 1024) |
| #define | PX_AT25S_BLOCK_SIZE_32KB (32 * 1024) |
| #define | PX_AT25S_BLOCK_SIZE_64KB (64 * 1024) |
Pages per block | |
| #define | PX_AT25S_PAGES_PER_BLOCK_4KB (PX_AT25S_BLOCK_SIZE_4KB / PX_AT25S_PAGE_SIZE) |
| #define | PX_AT25S_PAGES_PER_BLOCK_32KB (PX_AT25S_BLOCK_SIZE_32KB / PX_AT25S_PAGE_SIZE) |
| #define | PX_AT25S_PAGES_PER_BLOCK_64KB (PX_AT25S_BLOCK_SIZE_64KB / PX_AT25S_PAGE_SIZE) |
Status register 1 | |
| #define | PX_AT25S_STATUS_REG1_SRP0 7 |
| Status Register Protection bit 0. More... | |
| #define | PX_AT25S_STATUS_REG1_SEC 6 |
| Block Protection. More... | |
| #define | PX_AT25S_STATUS_REG1_TB 5 |
| Top or Bottom Protection. More... | |
| #define | PX_AT25S_STATUS_REG1_BP2 4 |
| Block Protection bit 2. More... | |
| #define | PX_AT25S_STATUS_REG1_BP1 3 |
| Block Protection bit 1. More... | |
| #define | PX_AT25S_STATUS_REG1_BP0 2 |
| Block Protection bit 0. More... | |
| #define | PX_AT25S_STATUS_REG1_WEL 1 |
| Write Enable Latch Status. More... | |
| #define | PX_AT25S_STATUS_REG1_BSY 0 |
| Ready/Busy Status. More... | |
| #define PX_CFG_DEV_AT25SF041 0 |
4 Mbit, 2.5-3.6V 104 MHz Standard Serial Flash
Definition at line 59 of file px_at25s.h.
| #define PX_CFG_DEV_AT25SF081 1 |
8 Mbit, 2.5-3.6V 104 MHz Standard Serial Flash
Definition at line 60 of file px_at25s.h.
| #define PX_CFG_DEV_AT25SF161 2 |
16 Mbit, 2.5-3.6V 104 MHz Standard Serial Flash
Definition at line 61 of file px_at25s.h.
| #define PX_CFG_DEV_AT25SF321 3 |
32 Mbit, 2.5-3.6V 104 MHz Standard Serial Flash
Definition at line 62 of file px_at25s.h.
| #define PX_CFG_DEV_AT25SF641 4 |
64 Mbit, 2.5-3.6V 104 MHz Standard Serial Flash
Definition at line 63 of file px_at25s.h.
| #define PX_AT25S_PAGE_SIZE 256 |
AT25S page size.
Definition at line 67 of file px_at25s.h.
| #define PX_AT25S_FLASH_SIZE_BYTES (PX_AT25S_PAGES * PX_AT25S_PAGE_SIZE) |
Flash size (in bytes)
Definition at line 107 of file px_at25s.h.
| #define PX_AT25S_ADR_MAX (PX_AT25S_FLASH_SIZE_BYTES - 1) |
Maximum address.
Definition at line 110 of file px_at25s.h.
| #define PX_AT25S_STATUS_REG1_SRP0 7 |
Status Register Protection bit 0.
Definition at line 114 of file px_at25s.h.
| #define PX_AT25S_STATUS_REG1_SEC 6 |
Block Protection.
Definition at line 115 of file px_at25s.h.
| #define PX_AT25S_STATUS_REG1_TB 5 |
Top or Bottom Protection.
Definition at line 116 of file px_at25s.h.
| #define PX_AT25S_STATUS_REG1_BP2 4 |
Block Protection bit 2.
Definition at line 117 of file px_at25s.h.
| #define PX_AT25S_STATUS_REG1_BP1 3 |
Block Protection bit 1.
Definition at line 118 of file px_at25s.h.
| #define PX_AT25S_STATUS_REG1_BP0 2 |
Block Protection bit 0.
Definition at line 119 of file px_at25s.h.
| #define PX_AT25S_STATUS_REG1_WEL 1 |
Write Enable Latch Status.
Definition at line 120 of file px_at25s.h.
| #define PX_AT25S_STATUS_REG1_BSY 0 |
Ready/Busy Status.
Definition at line 121 of file px_at25s.h.
| #define PX_AT25S_MAX_SPI_CLOCK_HZ 33000000 |
Maximum SPI Clock rate.
Definition at line 125 of file px_at25s.h.
| #define PX_AT25S_SPI_MODE PX_SPI_MODE0 |
SPI Clock / Data phase.
Definition at line 127 of file px_at25s.h.
| #define PX_AT25S_SPI_DATA_ORDER PX_SPI_DATA_ORDER_MSB |
SPI Data order.
Definition at line 129 of file px_at25s.h.
| #define PX_AT25S_CFG_DEVICE PX_CFG_DEV_AT25SF041 |
Specify device.
Definition at line 34 of file px_at25s_cfg_template.h.
| enum px_at25s_block_t |
AT25S block selection.
Definition at line 70 of file px_at25s.h.
| void px_at25s_init | ( | px_spi_handle_t * | handle | ) |
Initialise driver.
| handle | SPI handle to use for SPI slave device |
Definition at line 95 of file px_at25s.c.
| void px_at25s_deep_power_down | ( | void | ) |
Power down device to minimise power consumption.
Definition at line 103 of file px_at25s.c.
| void px_at25s_resume_from_deep_power_down | ( | void | ) |
Power up device to resume communication.
Definition at line 111 of file px_at25s.c.
| void px_at25s_rd | ( | void * | buf, |
| uint32_t | adr, | ||
| uint16_t | nr_of_bytes | ||
| ) |
Read data from Serial Flash.
This function reads data from Serial Flash and stores it in the specified buffer.
| buf | Buffer to store read data |
| adr | 0 to PX_AT25S_ADR_MAX |
| nr_of_bytes | Number of bytes to read |
Definition at line 119 of file px_at25s.c.
| void px_at25s_rd_page | ( | void * | buf, |
| uint16_t | page | ||
| ) |
Read a page from Serial Flash.
This function reads a page of data from Serial Flash and stores it in the specified buffer. The buffer must be at least PX_AT25S_PAGE_SIZE bytes in size to accomodate a full page.
The Serial Flash has PX_AT25S_PAGES pages.
| [out] | buf | Buffer to store read data |
| [in] | page | 0 to (PX_AT25S_PAGES - 1) |
Definition at line 136 of file px_at25s.c.
| void px_at25s_rd_page_offset | ( | void * | buf, |
| uint16_t | page, | ||
| uint8_t | start_byte_in_page, | ||
| uint16_t | nr_of_bytes | ||
| ) |
Partial read of data in a page of Serial Flash.
This function reads part of a page of data from Serial Flash and stores it in the specified buffer. The buffer must be at least nr_of_bytes in size to the read data.
Only read up to the end of the specified page. If the page boundary is exceeded, the index will wrap to the start of the page, i.e. only the content of the specified page will be read.
| [out] | buf | Buffer to store read data |
| [in] | page | 0 to (PX_AT25S_PAGES - 1) |
| [in] | start_byte_in_page | Index of first byte to read (0 to PX_AT25S_PAGE_SIZE - 1) |
| [in] | nr_of_bytes | Number of bytes to read |
Definition at line 141 of file px_at25s.c.
| void px_at25s_wr_page | ( | const void * | buf, |
| uint16_t | page | ||
| ) |
Write a page from Serial Flash.
This function writes a page of data to Serial Flash using the specified buffer as the source. The buffer must contain at least PX_AT25S_PAGE_SIZE bytes of data.
The Serial Flash has PX_AT25S_PAGES pages.
| [in] | buf | Buffer containing data to be written |
| [in] | page | 0 to (PX_AT25S_PAGES - 1) |
Definition at line 149 of file px_at25s.c.
| void px_at25s_wr_page_offset | ( | const void * | buf, |
| uint16_t | page, | ||
| uint8_t | start_byte_in_page, | ||
| uint16_t | nr_of_bytes | ||
| ) |
Partial write of data in a page of Serial Flash.
This function writes a part of a page of data to Serial Flash using the specified buffer as source. The buffer must contain at least nr_of_bytes of data.
Only write up to the end of the specified page. If the page boundary is exceeded, the index will wrap to the start of the page, i.e. only the content of the specified page will be written.
| [in] | buf | Buffer containing data to be written |
| [in] | page | 0 to (PX_AT25S_PAGES - 1) |
| [in] | start_byte_in_page | Index of first byte to write (0 to PX_AT25S_PAGE_SIZE - 1) |
| [in] | nr_of_bytes | Number of bytes to write |
Definition at line 168 of file px_at25s.c.
| void px_at25s_erase | ( | px_at25s_block_t | block, |
| uint16_t | page | ||
| ) |
Erase a block of Serial Flash.
This function erases a block of Serial Flash. The Serial Flash has PX_AT25S_PAGES pages.
| block | 4KB, 32KB or 64KB |
| page | 0 to (PX_AT25S_PAGES - 1); must be an integer multiple of block size |
Definition at line 190 of file px_at25s.c.
| bool px_at25s_ready | ( | void | ) |
Check if Serial Flash is ready for the next read or write access.
When data is written to Serial Flash, the microcontroller must wait until the operation is finished, before the next one is attempted. This function allows the microcontroller to do something else while waiting for the operation to finish.
| true | Serial Flash is ready for next read or write access. |
| false | Serial Flash is busy writing. |
Definition at line 254 of file px_at25s.c.
| uint8_t px_at25s_rd_status_reg1 | ( | void | ) |
Read status register 1 of the Serial Flash.
The status register contains flags, e.g. PX_AT25S_STATUS_REG1_BSY to see if the device is ready or busy with an internal operation.
Definition at line 278 of file px_at25s.c.
| void px_at25s_rd_man_and_dev_id | ( | uint8_t * | buf | ) |
Read Manufacturer and Device ID.
| buf | Buffer with a size of 3 bytes to hold manufacturer and device ID |
Definition at line 291 of file px_at25s.c.