EVE 1.0
spi-memory.h File Reference

Driver for SPI-based memories. More...

#include <dev/spi.h>
#include <dev/eve-module.h>
Include dependency graph for spi-memory.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  spi_memory_t
 
struct  spi_memory_data_buffer_header
 

Macros

#define SPI_MEMORY_HINT_GENERIC   0
 
#define SPI_MEMORY_HINT_GENERIC_SRAM   1
 
#define SPI_MEMORY_DATA_BUFFER_COMMAND_SIZE   4
 
#define SPI_MEMORY_DATA_BUFFER_TYPE(type, size)
 

Typedefs

typedef void(* spi_memory_completion_callback_t) (const struct spi_memory_t *Memory, struct spi_memory_data_buffer_header *BufferHeader)
 

Functions

 SPI_MEMORY_DATA_BUFFER_TYPE (spi_memory_generic_buffer_t, 0)
 
Functions called from application programs
bool SpiMemoryInit (const struct spi_memory_t *Memory)
 Name: SpiMemoryInit
Waits for power on and then release SPI memory from deep powerdown. KŲ!! ???????????? Called from main program level. More...
 
bool SpiMemoryDisable (const struct spi_memory_t *Memory)
 Name: SpiMemoryDisable
Sets SPI memory in deep powerdown. Called from main program level. More...
 
bool SpiMemorySetWriteProtection (const struct spi_memory_t *Memory, enum spi_memory_protection_t Protection)
 Name: SpiMemorySetWriteProtection
Sets write protection for SPI memory and waits for completion. Called from main program level. More...
 
bool SpiMemoryEraseSectorAsync (const struct spi_memory_t *Memory, uint32_t SectorIndex)
 Name: SpiMemoryEraseSectorAsync
Begines erasing given sector in SPI memory. Called from main program level. At function return SPI transfer is completed; erase is started, but not completed. Caller code should use SpiMemoryIsBusy to wait for the completion. More...
 
bool SpiMemoryEraseSector (const struct spi_memory_t *Memory, uint32_t SectorIndex)
 Name: SpiMemoryEraseSector
Erases given sector in SPI memory and waits for completion. Called from main program level. More...
 
bool SpiMemoryEraseBlockAsync (const struct spi_memory_t *Memory, uint32_t BlockIndex)
 Name: SpiMemoryEraseBlockAsync
Begines erasing given block in SPI memory. Called from main program level. At function return SPI transfer is completed; erase is started, but not completed. Caller code should use SpiMemoryIsBusy to wait for the completion. More...
 
bool SpiMemoryEraseBlock (const struct spi_memory_t *Memory, uint32_t BlockIndex)
 Name: SpiMemoryEraseBlock
Erases given block in SPI memory and waits for completion. Called from main program level. More...
 
bool SpiMemoryEraseAsync (const struct spi_memory_t *Memory)
 Name: SpiMemoryEraseAsync
Begines erasing the whole SPI memory. Called from main program level. At function return SPI transfer is completed; erase is started, but not completed. Caller code should use SpiMemoryIsBusy to wait for the completion. More...
 
bool SpiMemoryErase (const struct spi_memory_t *Memory)
 Name: SpiMemoryErase
Erases the whole SPI memory and waits for completion. Called from main program level. More...
 
bool SpiMemoryReadAsync (const struct spi_memory_t *Memory, struct spi_memory_data_buffer_header *DstBuffer, uint32_t SrcAddress, uint32_t ByteCount, spi_memory_completion_callback_t Callback)
 Name: SpiMemoryReadAsync
Reads bytes from SPI memory to DstBuffer. Called from main program level. Does not wait for completion, the completion callback is called instead when transfer is finished. Calling code should not use SPI bus until the completion callback is called. More...
 
bool SpiMemoryRead (const struct spi_memory_t *Memory, void *DstBuffer, uint32_t SrcAddress, uint32_t ByteCount)
 Name: SpiMemoryRead
Reads bytes from SPI memory to DstBuffer. Called from main program level. More...
 
static bool SpiMemoryReadPageAsync (const struct spi_memory_t *Memory, struct spi_memory_data_buffer_header *DstBuffer, uint32_t PageIndex, spi_memory_completion_callback_t Callback)
 Name: SpiMemoryReadPageAsync
Reads the page PageIndex from SPI memory to DstBuffer. Called from main program level. Does not wait for completion, the completion callback is called instead when transfer is finished. Calling code should not use SPI bus until the completion callback is called. More...
 
static bool SpiMemoryReadPage (const struct spi_memory_t *Memory, void *DstBuffer, uint32_t PageIndex)
 Name: SpiMemoryReadPage
Reads the page PageIndex from SPI memory to DstBuffer. Called from main program level. More...
 
static bool SpiMemoryReadPageWithOffsetAsync (const struct spi_memory_t *Memory, struct spi_memory_data_buffer_header *DstBuffer, uint32_t PageIndex, uint32_t PageOffset, uint32_t ByteCount, spi_memory_completion_callback_t Callback)
 Name: SpiMemoryReadPageWithOffsetAsync
Reads the page PageIndex with offset from SPI memory to DstBuffer. Called from main program level. Does not wait for completion, the completion callback is called instead when transfer is finished. Calling code should not use SPI bus until the completion callback is called. More...
 
static bool SpiMemoryReadPageWithOffset (const struct spi_memory_t *Memory, void *DstBuffer, uint32_t PageIndex, uint32_t PageOffset, uint32_t ByteCount)
 Name: SpiMemoryReadPageWithOffset
Reads the page PageIndex with offset from SPI memory to DstBuffer. Called from main program level. More...
 
bool SpiMemoryWriteAsync (const struct spi_memory_t *Memory, uint32_t DstAddress, struct spi_memory_data_buffer_header *SrcBuffer, uint32_t ByteCount, spi_memory_completion_callback_t Callback)
 Name: SpiMemoryWriteAsync
Writes bytes from SrcBuffer to SPI memory. It the SPI memory is page based, the data must fit into a single page, and the page must be erased before writing. Return after writing is finished. Called from main program level. Does not wait for completion, the completion callback is called instead when SPI transfer is finished. Calling code should not use SPI bus until the completion callback is called. Note that completion of the in-chip writing process is not indicated by any kind of callback. Calling code should use SpiMemoryIsBusy to wait for the completion. More...
 
bool SpiMemoryWrite (const struct spi_memory_t *Memory, uint32_t DstAddress, const void *SrcBuffer, uint32_t ByteCount)
 Name: SpiMemoryWrite
Writes bytes from SrcBuffer to SPI memory. It the SPI memory is page based, the data must fit into a single page, and the page must be erased before writing. Return after writing is finished. Called from main program level. More...
 
static bool SpiMemoryWritePageAsync (const struct spi_memory_t *Memory, uint32_t PageIndex, struct spi_memory_data_buffer_header *SrcBuffer, spi_memory_completion_callback_t Callback)
 Name: SpiMemoryWritePageAsync
Writes page data from SrcBuffer to page PageIndex in SPI memory. The page must be erased before writing. Return after writing is finished. Called from main program level. Does not wait for completion, the completion callback is called instead when SPI transfer is finished. Calling code should not use SPI bus until the completion callback is called. Note that completion of the in-chip writing process is not indicated by any kind of callback. Calling code should use SpiMemoryIsBusy to wait for the completion. More...
 
static bool SpiMemoryWritePage (const struct spi_memory_t *Memory, uint32_t PageIndex, const void *SrcBuffer)
 Name: SpiMemoryWritePage
Writes page data from SrcBuffer to page PageIndex in SPI memory. The page must be erased before writing. Return after writing is finished. Called from main program level. More...
 
bool SpiMemoryVerify (const struct spi_memory_t *Memory, uint32_t SrcAddress, const void *SrcBuffer, uint32_t ByteCount)
 Name: SpiMemoryVerify
Verifies data in SPI memory with SrcBuffer. Called from main program level. More...
 
static bool SpiMemoryVerifyPage (const struct spi_memory_t *Memory, uint32_t PageIndex, const void *SrcBuffer)
 Name: SpiMemoryVerifyPage
Verifies data in page PageIndex in SPI memory with SrcBuffer. Called from main program level. More...
 
bool SpiMemoryIsBusy (const struct spi_memory_t *Memory)
 Name: SpiMemoryIsBusy
Checks if the memory write or erase operation is in progress Called from main program level. More...
 
void SpiMemoryPowerUp (const struct spi_memory_t *Memory)
 Name: SpiMemoryPowerUp
Power up VCC for SPI memory. SpiEnable() must be called after this function to get SPI pin setup. Only to be used from EveSpiPowerUp() More...
 
void SpiMemoryPowerDown (const struct spi_memory_t *Memory)
 Name: SpiMemoryPowerDown
Power down VCC for SPI memory. SpiDisable() must be called prior to this function to get default pin setup. Only to be used from EveSpiPowerDown() More...
 

Detailed Description

Driver for SPI-based memories.

Author
KLO, Jetro AS

Definition in file spi-memory.h.