|
Data Structures | |
| struct | at45_device |
| AT45 DataFlash device. More... | |
Modules | |
| AT45 device driver internals | |
Typedefs | |
| typedef bool(* | at45_next_call_t )(struct at45_device *at45d) |
Enumerations | |
| enum | at45_device_flag { AT45_FLAG_VALID, AT45_FLAG_PROTECTED } |
AT45 device flags. More... | |
Functions | |
| bool | at45_wait_ready (struct at45_device *at45d) |
| Actively wait for AT45 device to be ready. | |
| bool | at45_identify (struct at45_device *at45d) |
| Identify AT45 device. | |
| void | at45_device_init (struct at45_device *at45d, spi_id_t spi_id, struct spi_master *spim, struct spi_device *spid) |
| Initialize AT45 struct. | |
| static void | at45_request (struct at45_device *at45d, struct workqueue_task *task) |
| Request exclusive access to AT45 device. | |
| static void | at45_release (struct at45_device *at45d) |
| Release exclusive access to AT45 device. | |
| static void | at45_select (struct at45_device *at45d) |
| Select AT45 device (Chip select). | |
| static void | at45_deselect (struct at45_device *at45d) |
| De-select AT45 device (Chip de-select). | |
| static void | at45_write_cmd (struct at45_device *at45d, uint8_t size) |
| Write command and other opcodes to AT45 device. | |
| static void | at45_read_rsp (struct at45_device *at45d, uint8_t size) |
| Read response from AT45 device. | |
| static void | at45_cmd_read_status_reg (struct at45_device *at45d) |
| Write AT45 device command: read status register. | |
| static void | at45_cmd_read_id (struct at45_device *at45d) |
| Write AT45 device command: read ID. | |
| static void | at45_cmd_cont_array_read (struct at45_device *at45d, uint16_t page, uint16_t pos) |
| Write AT45 device command: continous array read. | |
| static void | at45_cmd_buffer_1_write (struct at45_device *at45d, uint16_t pos) |
| Write AT45 device command: buffer 1 write. | |
| static void | at45_cmd_main_memory_to_buffer_1_transfer (struct at45_device *at45d, uint16_t page) |
| Write AT45 device command: main memory to buffer 1 transfer. | |
| static void | at45_cmd_buffer_1_main_memory_program_with_erase (struct at45_device *at45d, uint16_t page) |
| Write AT45 device command: buffer 1 main memory program with erase. | |
| static void | at45_read_buf_list (struct at45_device *at45d, struct slist *buf_list) |
| Read from AT45 device into buffer list. | |
| static void | at45_write_buf_list (struct at45_device *at45d, struct slist *buf_list) |
| Write from buffer list into AT45 device. | |
| static bool | at45_rsp_status_is_ready (struct at45_device *at45d) |
| Test if AT45 device status register bit is set to ready. | |
| static bool | at45_rsp_status_is_protected (struct at45_device *at45d) |
| Test if AT45 device status register bit is set to protected. | |
This is a driver for AT45 DataFlash devices.
It's initalized by at45_device_init() with a pre-allocated at45_device and SPI ID, master and device references.
Exclusive access is requested with at45_request(), and on access granted the supplied workqueue_task is scheduled to run and it's possible to call different access methods. These access methods can initiate some driver action which will re-schedule the task when ready.
Exclusive access must be ended with at45_release(). And this will start any other pending requests, or set it available.
| typedef bool(* at45_next_call_t)(struct at45_device *at45d) |
For internal use only.
Next function definition for chained calls
Definition at line 75 of file at45_device.h.
| enum at45_device_flag |
AT45 device flags.
| AT45_FLAG_VALID |
Valid AT45 device detected. |
| AT45_FLAG_PROTECTED |
Device is protected from write operations. |
Definition at line 63 of file at45_device.h.
| static void at45_cmd_buffer_1_main_memory_program_with_erase | ( | struct at45_device * | at45d, | |
| uint16_t | page | |||
| ) | [inline, static] |
Write AT45 device command: buffer 1 main memory program with erase.
| at45d | AT45 device struct | |
| page | Page address |
Definition at line 294 of file at45_device.h.
References assert, AT45_CMD_BUFFER_1_MAIN_MEMORY_PROGRAM_WITH_ERASE, AT45_PAGE_ADDR_MASK, at45_write_cmd(), and at45_device::cmdrsp.
| static void at45_cmd_buffer_1_write | ( | struct at45_device * | at45d, | |
| uint16_t | pos | |||
| ) | [inline, static] |
Write AT45 device command: buffer 1 write.
| at45d | AT45 device struct | |
| pos | Position in page |
Definition at line 253 of file at45_device.h.
References assert, AT45_CMD_BUFFER_1_WRITE, AT45_PAGE_POS_MASK, at45_write_cmd(), and at45_device::cmdrsp.
| static void at45_cmd_cont_array_read | ( | struct at45_device * | at45d, | |
| uint16_t | page, | |||
| uint16_t | pos | |||
| ) | [inline, static] |
Write AT45 device command: continous array read.
| at45d | AT45 device struct | |
| page | Page address | |
| pos | Position in page |
Definition at line 228 of file at45_device.h.
References assert, AT45_CMD_CONTINOUS_ARRAY_READ, AT45_PAGE_ADDR_MASK, AT45_PAGE_POS_MASK, at45_write_cmd(), and at45_device::cmdrsp.
| static void at45_cmd_main_memory_to_buffer_1_transfer | ( | struct at45_device * | at45d, | |
| uint16_t | page | |||
| ) | [inline, static] |
Write AT45 device command: main memory to buffer 1 transfer.
| at45d | AT45 device struct | |
| page | Page address |
Definition at line 274 of file at45_device.h.
References assert, AT45_CMD_MAIN_MEMORY_TO_BUFFER_1_TRANSFER, AT45_PAGE_ADDR_MASK, at45_write_cmd(), and at45_device::cmdrsp.
| static void at45_cmd_read_id | ( | struct at45_device * | at45d | ) | [inline, static] |
Write AT45 device command: read ID.
| at45d | AT45 device struct |
Definition at line 213 of file at45_device.h.
References AT45_CMD_READ_ID, at45_write_cmd(), and at45_device::cmdrsp.
| static void at45_cmd_read_status_reg | ( | struct at45_device * | at45d | ) | [inline, static] |
Write AT45 device command: read status register.
| at45d | AT45 device struct |
Definition at line 200 of file at45_device.h.
References AT45_CMD_READ_STATUS_REG, at45_write_cmd(), and at45_device::cmdrsp.
| static void at45_deselect | ( | struct at45_device * | at45d | ) | [inline, static] |
De-select AT45 device (Chip de-select).
| at45d | AT45 device struct |
Definition at line 150 of file at45_device.h.
References spi_deselect_device(), at45_device::spi_id, at45_device::spid, and at45_device::spim.
| void at45_device_init | ( | struct at45_device * | at45d, | |
| spi_id_t | spi_id, | |||
| struct spi_master * | spim, | |||
| struct spi_device * | spid | |||
| ) |
Initialize AT45 struct.
| at45d | AT45 device struct | |
| spi_id | SPI Module ID | |
| spim | SPI master struct | |
| spid | SPI device struct |
| bool at45_identify | ( | struct at45_device * | at45d | ) |
Identify AT45 device.
Extract status and device ID from device and process it.
| at45d | AT45 device struct |
| false | Not done yet. The task supplied in at45_request will be resceduled when it's ready to be called again. | |
| true | Operation completed. Variables at45d::size, at45d::page_size and at45d::flags have now been populated. |
Referenced by dataflash_detect().
| static void at45_read_buf_list | ( | struct at45_device * | at45d, | |
| struct slist * | buf_list | |||
| ) | [inline, static] |
Read from AT45 device into buffer list.
| at45d | AT45 device struct | |
| buf_list | List of buffers |
Definition at line 314 of file at45_device.h.
References at45_device::spi_id, spi_read_buf_list(), and at45_device::spim.
| static void at45_read_rsp | ( | struct at45_device * | at45d, | |
| uint8_t | size | |||
| ) | [inline, static] |
Read response from AT45 device.
This will read the response from the AT45 device into at45_device::cmdrsp .
When the response have been read the task will be rescheduled.
| at45d | AT45 device struct | |
| size | Size to be read |
Definition at line 186 of file at45_device.h.
References assert, at45_device::cmdrsp, at45_device::spi_id, spi_read(), and at45_device::spim.
| static void at45_release | ( | struct at45_device * | at45d | ) | [inline, static] |
Release exclusive access to AT45 device.
| at45d | AT45 device struct |
Definition at line 126 of file at45_device.h.
References spi_release_bus(), and at45_device::spim.
| static void at45_request | ( | struct at45_device * | at45d, | |
| struct workqueue_task * | task | |||
| ) | [inline, static] |
Request exclusive access to AT45 device.
Once exclusive access is granted the task is scheduled to run.
Exclusive access must be ended with at45_release() in order for other requests to be run.
| at45d | AT45 device struct | |
| task | Task to run when ready |
Definition at line 113 of file at45_device.h.
References spi_request_bus(), and at45_device::spim.
Referenced by dataflash_submit().
| static bool at45_rsp_status_is_protected | ( | struct at45_device * | at45d | ) | [inline, static] |
Test if AT45 device status register bit is set to protected.
| at45d | AT45 device struct |
Definition at line 353 of file at45_device.h.
References AT45_STATUS_PROTECT, and at45_device::cmdrsp.
| static bool at45_rsp_status_is_ready | ( | struct at45_device * | at45d | ) | [inline, static] |
Test if AT45 device status register bit is set to ready.
| at45d | AT45 device struct |
Definition at line 341 of file at45_device.h.
References AT45_STATUS_RDY, and at45_device::cmdrsp.
| static void at45_select | ( | struct at45_device * | at45d | ) | [inline, static] |
Select AT45 device (Chip select).
| at45d | AT45 device struct |
Definition at line 138 of file at45_device.h.
References at45_device::spi_id, spi_select_device(), at45_device::spid, and at45_device::spim.
| bool at45_wait_ready | ( | struct at45_device * | at45d | ) |
Actively wait for AT45 device to be ready.
This must be called over and overagain until it returns true.
| at45d | AT45 device struct |
| false | Not done yet. The task supplied in at45_request will be resceduled when it's ready to be called again. | |
| true | Operation completed. Variables size, page_size and flags in at45 have now been populated. |
| static void at45_write_buf_list | ( | struct at45_device * | at45d, | |
| struct slist * | buf_list | |||
| ) | [inline, static] |
Write from buffer list into AT45 device.
| at45d | AT45 device struct | |
| buf_list | List of buffers |
Definition at line 328 of file at45_device.h.
References at45_device::spi_id, spi_write_buf_list(), and at45_device::spim.
| static void at45_write_cmd | ( | struct at45_device * | at45d, | |
| uint8_t | size | |||
| ) | [inline, static] |
Write command and other opcodes to AT45 device.
This will write the command from at45::cmdrsp to the AT45 device.
When the command have been written the task will be rescheduled.
| at45d | AT45 device struct | |
| size | Size to be written |
Definition at line 167 of file at45_device.h.
References assert, at45_device::cmdrsp, at45_device::spi_id, spi_write(), and at45_device::spim.
Referenced by at45_cmd_buffer_1_main_memory_program_with_erase(), at45_cmd_buffer_1_write(), at45_cmd_cont_array_read(), at45_cmd_main_memory_to_buffer_1_transfer(), at45_cmd_read_id(), and at45_cmd_read_status_reg().
1.6.3