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));
357 __bo_objinit_impl(self,
vmt);
373 oopIfObjectInit(&self->fls, &xsnor_fls_vmt);
379#if XSNOR_USE_WSPI == TRUE
380 self->commands = NULL;
401 __bo_dispose_impl(self);
409#if (XSNOR_USE_SPI == TRUE) || defined (__DOXYGEN__)
438#if (XSNOR_SHARED_BUS == TRUE) || defined (__DOXYGEN__)
447#if XSNOR_USE_BOTH == TRUE
450#if XSNOR_USE_WSPI == TRUE
452 if (self->config->bus.wspi.cfg != self->config->bus.wspi.drv->config) {
453 wspiStart(self->config->bus.wspi.drv, self->config->bus.wspi.cfg);
456#if XSNOR_USE_BOTH == TRUE
460#if XSNOR_USE_SPI == TRUE
462 if (self->config->bus.spi.cfg != self->config->bus.spi.drv->config) {
463 spiStart(self->config->bus.spi.drv, self->config->bus.spi.cfg);
466#if XSNOR_USE_BOTH == TRUE
479#if XSNOR_USE_BOTH == TRUE
482#if XSNOR_USE_WSPI == TRUE
485#if XSNOR_USE_BOTH == TRUE
489#if XSNOR_USE_SPI == TRUE
492#if XSNOR_USE_BOTH == TRUE
508#if XSNOR_USE_BOTH == TRUE
511#if XSNOR_USE_WSPI == TRUE
515 mode.
cfg = self->commands->cmd;
521#if XSNOR_USE_BOTH == TRUE
525#if XSNOR_USE_SPI == TRUE
532#if XSNOR_USE_BOTH == TRUE
549#if XSNOR_USE_BOTH == TRUE
552#if XSNOR_USE_WSPI == TRUE
556 mode.
cfg = self->commands->cmd_data;
562#if XSNOR_USE_BOTH == TRUE
566#if XSNOR_USE_SPI == TRUE
574#if XSNOR_USE_BOTH == TRUE
591#if XSNOR_USE_BOTH == TRUE
594#if XSNOR_USE_WSPI == TRUE
598 mode.
cfg = self->commands->cmd_data;
604#if XSNOR_USE_BOTH == TRUE
608#if XSNOR_USE_SPI == TRUE
616#if XSNOR_USE_BOTH == TRUE
632#if XSNOR_USE_BOTH == TRUE
635#if XSNOR_USE_WSPI == TRUE
639 mode.
cfg = self->commands->cmd_addr;
645#if XSNOR_USE_BOTH == TRUE
649#if XSNOR_USE_SPI == TRUE
655#if XSNOR_USE_BOTH == TRUE
671 size_t n,
const uint8_t *p) {
675#if XSNOR_USE_BOTH == TRUE
678#if XSNOR_USE_WSPI == TRUE
682 mode.
cfg = self->commands->cmd_addr_data;
688#if XSNOR_USE_BOTH == TRUE
692#if XSNOR_USE_SPI == TRUE
699#if XSNOR_USE_BOTH == TRUE
719#if XSNOR_USE_BOTH == TRUE
722#if XSNOR_USE_WSPI == TRUE
726 mode.
cfg = self->commands->cmd_addr_data;
732#if XSNOR_USE_BOTH == TRUE
736#if XSNOR_USE_SPI == TRUE
743#if XSNOR_USE_BOTH == TRUE
759 size_t n, uint8_t *p) {
763#if XSNOR_USE_BOTH == TRUE
766#if XSNOR_USE_WSPI == TRUE
770 mode.
cfg = self->commands->cmd_data;
776#if XSNOR_USE_BOTH == TRUE
780#if XSNOR_USE_SPI == TRUE
781 osalDbgAssert((dummy & 7) == 0U,
"multiple of 8 dummy cycles");
792#if XSNOR_USE_BOTH == TRUE
809 size_t n, uint8_t *p) {
813#if XSNOR_USE_BOTH == TRUE
816#if XSNOR_USE_WSPI == TRUE
820 mode.
cfg = self->commands->cmd_addr_data;
826#if XSNOR_USE_BOTH == TRUE
830#if XSNOR_USE_SPI == TRUE
831 osalDbgAssert((dummy & 7) == 0U,
"multiple of 8 dummy cycles");
841#if XSNOR_USE_BOTH == TRUE
864 self->config = config;
871#if XSNOR_USE_BOTH == TRUE
874#if XSNOR_USE_WSPI == TRUE
875 wspiStart(self->config->bus.wspi.drv, self->config->bus.wspi.cfg);
877#if XSNOR_USE_BOTH == TRUE
881#if XSNOR_USE_SPI == TRUE
882 spiStart(self->config->bus.spi.drv, self->config->bus.spi.cfg);
884#if XSNOR_USE_BOTH == TRUE
917#if XSNOR_USE_BOTH == TRUE
920#if XSNOR_USE_WSPI == TRUE
921 wspiStop(self->config->bus.wspi.drv);
923#if XSNOR_USE_BOTH == TRUE
927#if XSNOR_USE_SPI == TRUE
928 spiStop(self->config->bus.spi.drv);
930#if XSNOR_USE_BOTH == TRUE
942#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 an 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