|
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 AT45D DataFlash using SPI.
File(s):
Reference:
Example:
Macros | |
| #define | PX_AT45D_FLASH_SIZE_BYTES (PX_AT45D_PAGES * PX_AT45D_PAGE_SIZE) |
| Flash size (in bytes) More... | |
| #define | PX_AT45D_ADR_MAX (PX_AT45D_FLASH_SIZE_BYTES - 1) |
| Maximum adress. More... | |
| #define | PX_AT45D_MAX_SPI_CLOCK_HZ 33000000 |
| Maximum SPI Clock rate. More... | |
| #define | PX_AT45D_SPI_MODE PX_SPI_MODE0 |
| SPI Clock / Data phase. More... | |
| #define | PX_AT45D_SPI_DATA_ORDER PX_SPI_DATA_ORDER_MSB |
| SPI Data order. More... | |
| #define | PX_AT45D_CFG_DEVICE PX_AT45DB041 |
| Specify device. More... | |
| #define | PX_AT45D_CFG_PWR_OF_TWO_PAGE_SIZE 0 |
| Select power of two page size. More... | |
Typedefs | |
| typedef uint32_t | px_at45d_adr_t |
| Address size can be optimized, depending on maximum size of FLASH. More... | |
Functions | |
| void | px_at45d_init (px_spi_handle_t *handle) |
| Initialise driver. More... | |
| void | px_at45d_deep_power_down (void) |
| Power down device to minimise power consumption. More... | |
| void | px_at45d_resume_from_deep_power_down (void) |
| Power up device to resume communication. More... | |
| void | px_at45d_ultra_deep_power_down (void) |
| Power down device to minimise power consumption. More... | |
| void | px_at45d_resume_from_ultra_deep_power_down (void) |
| Power up device to resume communication. More... | |
| uint16_t | px_at45d_rd (void *buf, px_at45d_adr_t adr, uint16_t nr_of_bytes) |
| Read data from DataFlash. More... | |
| void | px_at45d_rd_page (void *buf, uint16_t page) |
| Read a page from DataFlash. More... | |
| void | px_at45d_rd_page_offset (void *buf, uint16_t page, uint16_t start_byte_in_page, uint16_t nr_of_bytes) |
| Partial read of data in a page of DataFlash. More... | |
| void | px_at45d_wr_page (const void *buf, uint16_t page) |
| Write a page from DataFlash. More... | |
| void | px_at45d_wr_page_offset (const void *buf, uint16_t page, uint16_t start_byte_in_page, uint16_t nr_of_bytes) |
| Partial write of data in a page of DataFlash. More... | |
| void | px_at45d_erase (uint16_t page) |
| Erase a page of DataFlash. More... | |
| bool | px_at45d_ready (void) |
| Check if DataFlash is ready for the next read or write access. More... | |
| uint8_t | px_at45d_get_status (void) |
| Read the status register of the DataFlash. More... | |
| bool | px_at45d_page_size_is_pwr_of_two (void) |
| Check if page size of the DataFlash is a power of two. More... | |
| bool | px_at45d_set_page_size_to_pwr_of_two (void) |
| Sets the page size of the DataFlash to a power of two. More... | |
List AT45D devices | |
| #define | PX_AT45DB011 0 |
| 1M bit, 2.7-Volt Minimum Serial-Interface Flash with One 264-Byte SRAM Buffer More... | |
| #define | PX_AT45DB021 1 |
| 2M bit, 2.7-Volt Minimum Serial-Interface Flash with One 264-Byte SRAM Buffer More... | |
| #define | PX_AT45DB041 2 |
| 4M bit 2.5-Volt or 2.7-Volt DataFlash More... | |
| #define | PX_AT45DB081 3 |
| 8M bit, 2.5 or 2.7-Volt Only Serial-Interface Flash More... | |
| #define | PX_AT45DB161 4 |
| 16M bit, 2.7-Volt Only Serial-Interface Flash with two SRAM Data Buffers More... | |
| #define | PX_AT45DB321 5 |
| 32M bit, 2.7-Volt Only Serial Interface Flash More... | |
| #define | PX_AT45DB642 6 |
| 64M bit, 2.7-Volt Dual-Interface Flash with two 1056-Byte SRAM More... | |
Status register | |
| #define | PX_AT45D_STATUS_READY 7 |
| Ready flag. More... | |
| #define | PX_AT45D_STATUS_COMP 6 |
| Compare flag. More... | |
| #define | PX_AT45D_STATUS_DENSITY_MASK 0x3C |
| Density mask. More... | |
| #define | PX_AT45D_STATUS_PROTECT 1 |
| Protect flag. More... | |
| #define | PX_AT45D_STATUS_PAGE_SIZE 0 |
| Page size flag. More... | |
| #define PX_AT45DB011 0 |
1M bit, 2.7-Volt Minimum Serial-Interface Flash with One 264-Byte SRAM Buffer
Definition at line 62 of file px_at45d.h.
| #define PX_AT45DB021 1 |
2M bit, 2.7-Volt Minimum Serial-Interface Flash with One 264-Byte SRAM Buffer
Definition at line 63 of file px_at45d.h.
| #define PX_AT45DB041 2 |
4M bit 2.5-Volt or 2.7-Volt DataFlash
Definition at line 64 of file px_at45d.h.
| #define PX_AT45DB081 3 |
8M bit, 2.5 or 2.7-Volt Only Serial-Interface Flash
Definition at line 65 of file px_at45d.h.
| #define PX_AT45DB161 4 |
16M bit, 2.7-Volt Only Serial-Interface Flash with two SRAM Data Buffers
Definition at line 66 of file px_at45d.h.
| #define PX_AT45DB321 5 |
32M bit, 2.7-Volt Only Serial Interface Flash
Definition at line 67 of file px_at45d.h.
| #define PX_AT45DB642 6 |
64M bit, 2.7-Volt Dual-Interface Flash with two 1056-Byte SRAM
Definition at line 68 of file px_at45d.h.
| #define PX_AT45D_FLASH_SIZE_BYTES (PX_AT45D_PAGES * PX_AT45D_PAGE_SIZE) |
Flash size (in bytes)
Definition at line 99 of file px_at45d.h.
| #define PX_AT45D_ADR_MAX (PX_AT45D_FLASH_SIZE_BYTES - 1) |
Maximum adress.
Definition at line 102 of file px_at45d.h.
| #define PX_AT45D_STATUS_READY 7 |
Ready flag.
Definition at line 106 of file px_at45d.h.
| #define PX_AT45D_STATUS_COMP 6 |
Compare flag.
Definition at line 107 of file px_at45d.h.
| #define PX_AT45D_STATUS_DENSITY_MASK 0x3C |
Density mask.
Definition at line 108 of file px_at45d.h.
| #define PX_AT45D_STATUS_PROTECT 1 |
Protect flag.
Definition at line 109 of file px_at45d.h.
| #define PX_AT45D_STATUS_PAGE_SIZE 0 |
Page size flag.
Definition at line 110 of file px_at45d.h.
| #define PX_AT45D_MAX_SPI_CLOCK_HZ 33000000 |
Maximum SPI Clock rate.
Definition at line 114 of file px_at45d.h.
| #define PX_AT45D_SPI_MODE PX_SPI_MODE0 |
SPI Clock / Data phase.
Definition at line 116 of file px_at45d.h.
| #define PX_AT45D_SPI_DATA_ORDER PX_SPI_DATA_ORDER_MSB |
SPI Data order.
Definition at line 118 of file px_at45d.h.
| #define PX_AT45D_CFG_DEVICE PX_AT45DB041 |
Specify device.
Definition at line 34 of file px_at45d_cfg_template.h.
| #define PX_AT45D_CFG_PWR_OF_TWO_PAGE_SIZE 0 |
Select power of two page size.
"Power of 2" binary page size Configuration Register is a user-programmable nonvolatile register that allows the page size of the main memory to be configured for binary page size or the DataFlash standard page size.
See px_at45d_set_page_size_to_pwr_of_two().
Definition at line 45 of file px_at45d_cfg_template.h.
| typedef uint32_t px_at45d_adr_t |
Address size can be optimized, depending on maximum size of FLASH.
Definition at line 125 of file px_at45d.h.
| void px_at45d_init | ( | px_spi_handle_t * | handle | ) |
Initialise driver.
| handle | SPI handle to use for SPI slave device |
Definition at line 99 of file px_at45d.c.
| void px_at45d_deep_power_down | ( | void | ) |
Power down device to minimise power consumption.
Definition at line 107 of file px_at45d.c.
| void px_at45d_resume_from_deep_power_down | ( | void | ) |
Power up device to resume communication.
Definition at line 115 of file px_at45d.c.
| void px_at45d_ultra_deep_power_down | ( | void | ) |
Power down device to minimise power consumption.
Definition at line 123 of file px_at45d.c.
| void px_at45d_resume_from_ultra_deep_power_down | ( | void | ) |
Power up device to resume communication.
After this function call, wait at least 120 us (see tXUDPD in datasheet) for DataFlash to wake up, otherwise it will will ignore the commands.
Definition at line 131 of file px_at45d.c.
| uint16_t px_at45d_rd | ( | void * | buf, |
| px_at45d_adr_t | adr, | ||
| uint16_t | nr_of_bytes | ||
| ) |
Read data from DataFlash.
This function reads data from DataFlash and stores it in the specified buf.
| [out] | buf | Buffer to store read data |
| [in] | adr | 0 to PX_AT45D_ADR_MAX |
| [in] | nr_of_bytes | Number of bytes to read |
Definition at line 139 of file px_at45d.c.
| void px_at45d_rd_page | ( | void * | buf, |
| uint16_t | page | ||
| ) |
Read a page from DataFlash.
This function reads a page of data from DataFlash and stores it in the specified buf. The buf must be at least PX_AT45D_PAGE_SIZE bytes in size to accomodate a full page.
The DataFlash has PX_AT45D_PAGES pages.
| [out] | buf | Buffer to store read data |
| [in] | page | 0 to (PX_AT45D_PAGES - 1) |
Definition at line 184 of file px_at45d.c.
| void px_at45d_rd_page_offset | ( | void * | buf, |
| uint16_t | page, | ||
| uint16_t | start_byte_in_page, | ||
| uint16_t | nr_of_bytes | ||
| ) |
Partial read of data in a page of DataFlash.
This function reads part of a page of data from DataFlash and stores it in the specified buf. The buf 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_AT45D_PAGES - 1) |
| [in] | start_byte_in_page | Index of first byte to read (0 to PX_AT45D_PAGE_SIZE - 1) |
| [in] | nr_of_bytes | Number of bytes to read |
Definition at line 205 of file px_at45d.c.
| void px_at45d_wr_page | ( | const void * | buf, |
| uint16_t | page | ||
| ) |
Write a page from DataFlash.
This function writes a page of data to DataFlash using the specified buf as the source. The buf must contain at least PX_AT45D_PAGE_SIZE bytes of data.
The DataFlash has PX_AT45D_PAGES pages.
| [in] | buf | Buffer containing data to be written |
| [in] | page | 0 to (PX_AT45D_PAGES - 1) |
Definition at line 229 of file px_at45d.c.
| void px_at45d_wr_page_offset | ( | const void * | buf, |
| uint16_t | page, | ||
| uint16_t | start_byte_in_page, | ||
| uint16_t | nr_of_bytes | ||
| ) |
Partial write of data in a page of DataFlash.
This function writes a part of a page of data to DataFlash using the specified buf as source. The buf 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_AT45D_PAGES - 1) |
| [in] | start_byte_in_page | Index of first byte to write (0 to PX_AT45D_PAGE_SIZE - 1) |
| [in] | nr_of_bytes | Number of bytes to write |
Definition at line 246 of file px_at45d.c.
| void px_at45d_erase | ( | uint16_t | page | ) |
Erase a page of DataFlash.
This function erases a page of DataFlash. The DataFlash has PX_AT45D_PAGES pages.
| [in] | page | 0 to (PX_AT45D_PAGES - 1) |
Definition at line 296 of file px_at45d.c.
| bool px_at45d_ready | ( | void | ) |
Check if DataFlash is ready for the next read or write access.
When data is written to DataFlash, 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 | DataFlash is ready for next read or write access. |
| false | DataFlash is busy writing. |
Definition at line 313 of file px_at45d.c.
| uint8_t px_at45d_get_status | ( | void | ) |
Read the status register of the DataFlash.
The status register contains flags (e.g. PX_AT45D_STATUS_READY) and the density value (e.g. PX_AT45D_DENSITY). This function can be used to check that a valid and working DataFlash device is connected.
Definition at line 337 of file px_at45d.c.
| bool px_at45d_page_size_is_pwr_of_two | ( | void | ) |
Check if page size of the DataFlash is a power of two.
The status register contains a flag PX_AT45D_STATUS_PAGE_SIZE that reports the page size: 1 = power of two, 0 = not a power of two.
| true | Page size is a power of two |
| false | Page size is not a power of two |
Definition at line 350 of file px_at45d.c.
| bool px_at45d_set_page_size_to_pwr_of_two | ( | void | ) |
Sets the page size of the DataFlash to a power of two.
A one-time programmable configuration register is written to configure the device for "power of 2" page size. Once it has been written, it can not be reconfigured again.
The device must be power cycled for this configuration bit to come into effect.
| true | page size was set to a power of two |
| false | page size was already set to a power of two |
Definition at line 366 of file px_at45d.c.