75 return &self->descriptor;
89 size_t n, uint8_t *rp) {
93 osalDbgCheck((self != NULL) && (rp != NULL) && (n > 0U));
130 size_t n,
const uint8_t *pp) {
134 osalDbgCheck((self != NULL) && (pp != NULL) && (n > 0U));
367 __bo_objinit_impl(self,
vmt);
383 oopIfObjectInit(&self->fls, &xsnor_fls_vmt);
389#if XSNOR_USE_WSPI == TRUE
390 self->commands = NULL;
411 __bo_dispose_impl(self);
419#if (XSNOR_USE_SPI == TRUE) || defined (__DOXYGEN__)
448#if (XSNOR_SHARED_BUS == TRUE) || defined (__DOXYGEN__)
457#if XSNOR_USE_BOTH == TRUE
460#if XSNOR_USE_WSPI == TRUE
462 if (self->config->bus.wspi.cfg != self->config->bus.wspi.drv->config) {
463 wspiStart(self->config->bus.wspi.drv, self->config->bus.wspi.cfg);
466#if XSNOR_USE_BOTH == TRUE
470#if XSNOR_USE_SPI == TRUE
472 if (self->config->bus.spi.cfg != self->config->bus.spi.drv->config) {
473 spiStart(self->config->bus.spi.drv, self->config->bus.spi.cfg);
476#if XSNOR_USE_BOTH == TRUE
489#if XSNOR_USE_BOTH == TRUE
492#if XSNOR_USE_WSPI == TRUE
495#if XSNOR_USE_BOTH == TRUE
499#if XSNOR_USE_SPI == TRUE
502#if XSNOR_USE_BOTH == TRUE
518#if XSNOR_USE_BOTH == TRUE
521#if XSNOR_USE_WSPI == TRUE
525 mode.
cfg = self->commands->cmd;
531#if XSNOR_USE_BOTH == TRUE
535#if XSNOR_USE_SPI == TRUE
542#if XSNOR_USE_BOTH == TRUE
559#if XSNOR_USE_BOTH == TRUE
562#if XSNOR_USE_WSPI == TRUE
566 mode.
cfg = self->commands->cmd_data;
572#if XSNOR_USE_BOTH == TRUE
576#if XSNOR_USE_SPI == TRUE
584#if XSNOR_USE_BOTH == TRUE
601#if XSNOR_USE_BOTH == TRUE
604#if XSNOR_USE_WSPI == TRUE
608 mode.
cfg = self->commands->cmd_data;
614#if XSNOR_USE_BOTH == TRUE
618#if XSNOR_USE_SPI == TRUE
626#if XSNOR_USE_BOTH == TRUE
642#if XSNOR_USE_BOTH == TRUE
645#if XSNOR_USE_WSPI == TRUE
649 mode.
cfg = self->commands->cmd_addr;
655#if XSNOR_USE_BOTH == TRUE
659#if XSNOR_USE_SPI == TRUE
665#if XSNOR_USE_BOTH == TRUE
681 size_t n,
const uint8_t *p) {
685#if XSNOR_USE_BOTH == TRUE
688#if XSNOR_USE_WSPI == TRUE
692 mode.
cfg = self->commands->cmd_addr_data;
698#if XSNOR_USE_BOTH == TRUE
702#if XSNOR_USE_SPI == TRUE
709#if XSNOR_USE_BOTH == TRUE
729#if XSNOR_USE_BOTH == TRUE
732#if XSNOR_USE_WSPI == TRUE
736 mode.
cfg = self->commands->cmd_addr_data;
742#if XSNOR_USE_BOTH == TRUE
746#if XSNOR_USE_SPI == TRUE
753#if XSNOR_USE_BOTH == TRUE
769 size_t n, uint8_t *p) {
773#if XSNOR_USE_BOTH == TRUE
776#if XSNOR_USE_WSPI == TRUE
780 mode.
cfg = self->commands->cmd_data;
786#if XSNOR_USE_BOTH == TRUE
790#if XSNOR_USE_SPI == TRUE
791 osalDbgAssert((dummy & 7) == 0U,
"multiple of 8 dummy cycles");
802#if XSNOR_USE_BOTH == TRUE
819 size_t n, uint8_t *p) {
823#if XSNOR_USE_BOTH == TRUE
826#if XSNOR_USE_WSPI == TRUE
830 mode.
cfg = self->commands->cmd_addr_data;
836#if XSNOR_USE_BOTH == TRUE
840#if XSNOR_USE_SPI == TRUE
841 osalDbgAssert((dummy & 7) == 0U,
"multiple of 8 dummy cycles");
851#if XSNOR_USE_BOTH == TRUE
874 self->config = config;
881#if XSNOR_USE_BOTH == TRUE
884#if XSNOR_USE_WSPI == TRUE
885 wspiStart(self->config->bus.wspi.drv, self->config->bus.wspi.cfg);
887#if XSNOR_USE_BOTH == TRUE
891#if XSNOR_USE_SPI == TRUE
892 spiStart(self->config->bus.spi.drv, self->config->bus.spi.cfg);
894#if XSNOR_USE_BOTH == TRUE
927#if XSNOR_USE_BOTH == TRUE
930#if XSNOR_USE_WSPI == TRUE
931 wspiStop(self->config->bus.wspi.drv);
933#if XSNOR_USE_BOTH == TRUE
937#if XSNOR_USE_SPI == TRUE
938 spiStop(self->config->bus.spi.drv);
940#if XSNOR_USE_BOTH == TRUE
952#if (WSPI_SUPPORTS_MEMMAP == TRUE) || defined (__DOXYGEN__)
Base class of all SNOR drivers.
static const struct EFlashDriverVMT vmt
uint32_t flash_sector_t
Type of a flash sector number.
uint32_t flash_offset_t
Type of a flash offset.
flash_error_t
Type of a flash error code.
#define FLASH_ATTR_SPI_4BYTES_ADDR_HINT
Hint to use 4 bytes addresses in SPI protocol.
static flash_error_t __xsnor_fls_verify_erase_impl(void *ip, flash_sector_t sector)
Implementation of interface method flsVerifyErase().
void __xsnor_dispose_impl(void *ip)
Implementation of object finalization.
static flash_error_t __xsnor_fls_start_erase_all_impl(void *ip)
Implementation of interface method flsStartEraseAll().
static flash_error_t __xsnor_fls_query_erase_impl(void *ip, unsigned *msec)
Implementation of interface method flsQueryErase().
void __xsnor_bus_cmd_send(void *ip, uint32_t cmd, size_t n, const uint8_t *p)
Sends a command followed by a data transmit phase.
void __xsnor_spi_cmd_addr(void *ip, uint32_t cmd, flash_offset_t offset)
Sends command and address over SPI.
#define __xsnor_bus_release(self)
static CC_FORCE_INLINE void xsnor_device_mmap_off(void *ip)
#define XSNOR_BUS_MODE_SPI
void * __xsnor_objinit_impl(void *ip, const void *vmt)
Implementation of object creation.
static CC_FORCE_INLINE flash_error_t xsnor_device_mmap_on(void *ip, uint8_t **addrp)
void __xsnor_bus_cmd_addr_send(void *ip, uint32_t cmd, flash_offset_t offset, size_t n, const uint8_t *p)
Sends a command followed by a flash address and a data transmit phase.
static CC_FORCE_INLINE flash_error_t xsnor_device_start_erase_sector(void *ip, flash_sector_t sector)
Starts a sector erase operation.
static CC_FORCE_INLINE flash_error_t xsnor_device_read(void *ip, flash_offset_t offset, size_t n, uint8_t *rp)
Read operation.
void __xsnor_bus_cmd_addr(void *ip, uint32_t cmd, flash_offset_t offset)
Sends a command followed by a flash address.
void xsnorMemoryUnmap(void *ip)
Leaves the memory mapped mode.
static flash_error_t __xsnor_fls_program_impl(void *ip, flash_offset_t offset, size_t n, const uint8_t *pp)
Implementation of interface method flsProgram().
static flash_error_t __xsnor_fls_read_impl(void *ip, flash_offset_t offset, size_t n, uint8_t *rp)
Implementation of interface method flsRead().
void __xsnor_bus_cmd(void *ip, uint32_t cmd)
Sends a naked command.
flash_error_t xsnorStart(void *ip, const xsnor_config_t *config)
Configures and activates a SNOR driver.
static flash_error_t __xsnor_fls_release_exclusive_impl(void *ip)
Implementation of interface method flsReleaseExclusive().
static const flash_descriptor_t * __xsnor_fls_get_descriptor_impl(void *ip)
Implementation of interface method flsGetDescriptor().
struct xsnor_config xsnor_config_t
Type of a SNOR configuration structure.
void __xsnor_bus_cmd_addr_dummy_receive(void *ip, uint32_t cmd, flash_offset_t offset, uint32_t dummy, size_t n, uint8_t *p)
Sends a complete header followed by a data receive phase.
static CC_FORCE_INLINE flash_error_t xsnor_device_query_erase(void *ip, unsigned *msec)
Queries the driver for erase operation progress.
void __xsnor_bus_cmd_dummy_receive(void *ip, uint32_t cmd, uint32_t dummy, size_t n, uint8_t *p)
Sends a command followed by dummy cycles and a data receive phase.
static CC_FORCE_INLINE flash_error_t xsnor_device_init(void *ip)
static CC_FORCE_INLINE flash_error_t xsnor_device_program(void *ip, flash_offset_t offset, size_t n, const uint8_t *pp)
Program operation.
void __xsnor_bus_cmd_receive(void *ip, uint32_t cmd, size_t n, uint8_t *p)
Sends a command followed by a data receive phase.
void __xsnor_bus_cmd_addr_receive(void *ip, uint32_t cmd, flash_offset_t offset, size_t n, uint8_t *p)
Sends a command followed by a flash address and a data receive phase.
void xsnorStop(void *ip)
Deactivates a SNOR driver.
#define __xsnor_bus_acquire(self)
static flash_error_t __xsnor_fls_acquire_exclusive_impl(void *ip)
Implementation of interface method flsAcquireExclusive().
static CC_FORCE_INLINE flash_error_t xsnor_device_verify_erase(void *ip, flash_sector_t sector)
Returns the erase state of a sector.
flash_error_t xsnorMemoryMap(void *ip, uint8_t **addrp)
Enters the memory mapped mode.
static flash_error_t __xsnor_fls_start_erase_sector_impl(void *ip, flash_sector_t sector)
Implementation of interface method flsStartEraseSector().
static CC_FORCE_INLINE flash_error_t xsnor_device_start_erase_all(void *ip)
Starts a whole-device erase operation.
static void osalMutexObjectInit(mutex_t *mp)
Initializes a mutex_t object.
void osalMutexLock(mutex_t *mp)
Locks the specified mutex.
#define osalDbgAssert(c, remark)
Condition assertion.
void osalMutexUnlock(mutex_t *mp)
Unlocks the specified mutex.
#define osalDbgCheck(c)
Function parameters check.
void spiSelect(SPIDriver *spip)
Asserts the slave select signal and prepares for transfers.
void spiReleaseBus(SPIDriver *spip)
Releases exclusive access to the SPI bus.
void spiSend(SPIDriver *spip, size_t n, const void *txbuf)
Sends data over the SPI bus.
void spiIgnore(SPIDriver *spip, size_t n)
Ignores data on the SPI bus.
void spiAcquireBus(SPIDriver *spip)
Gains exclusive access to the SPI bus.
msg_t spiStart(SPIDriver *spip, const SPIConfig *config)
Configures and activates the SPI peripheral.
void spiStop(SPIDriver *spip)
Deactivates the SPI peripheral.
void spiReceive(SPIDriver *spip, size_t n, void *rxbuf)
Receives data from the SPI bus.
void spiUnselect(SPIDriver *spip)
Deasserts the slave select signal.
void wspiAcquireBus(WSPIDriver *wspip)
Gains exclusive access to the WSPI bus.
msg_t wspiStart(WSPIDriver *wspip, const WSPIConfig *config)
Configures and activates the WSPI peripheral.
bool wspiReceive(WSPIDriver *wspip, const wspi_command_t *cmdp, size_t n, uint8_t *rxbuf)
Sends a command then receives data over the WSPI bus.
void wspiReleaseBus(WSPIDriver *wspip)
Releases exclusive access to the WSPI bus.
bool wspiCommand(WSPIDriver *wspip, const wspi_command_t *cmdp)
Sends a command without data phase.
bool wspiSend(WSPIDriver *wspip, const wspi_command_t *cmdp, size_t n, const uint8_t *txbuf)
Sends a command with data over the WSPI bus.
void wspiStop(WSPIDriver *wspip)
Deactivates the WSPI peripheral.
Generated SNOR Base Driver header.
Type of a flash device descriptor.
Interface flash_interface_i virtual methods table.
Type of a WSPI command descriptor.
uint32_t dummy
Number of dummy cycles to be inserted.
uint32_t cfg
Transfer configuration field.
uint32_t alt
Alternate phase data.
uint32_t addr
Address phase data.
uint32_t cmd
Command phase data.
uint8_t spibuf[8]
Non-cacheable SPI buffer.
SPIDriver * drv
SPI driver to be used for physical communication.
WSPIDriver * drv
WSPI driver to be used for physical communication.
int bus_type
Bus type selection switch.
union xsnor_bus_configs bus
WSPI driver configuration.
xsnor_buffers_t * buffers
Pointer to the non-cacheable buffers.
struct xsnor_bus_wspi wspi