arch/arm/src/stm32h7: Port QSPI driver from STM32F7 to STM32H7
This commit is contained in:
parent
7136215930
commit
390ebd504f
|
@ -236,6 +236,4 @@
|
|||
* Public Functions
|
||||
****************************************************************************************/
|
||||
|
||||
#endif /* __ARCH_ARM_SRC_STM32F7_HARDWARE_STM32L4_QSPI_H */
|
||||
|
||||
|
||||
#endif /* __ARCH_ARM_SRC_STM32F7_HARDWARE_STM32F7_QSPI_H */
|
||||
|
|
|
@ -304,6 +304,10 @@ config STM32H7_OTG_USBREGEN
|
|||
bool "Enable USB voltage regulator"
|
||||
default n
|
||||
|
||||
config STM32H7_QUADSPI
|
||||
bool "QuadSPI"
|
||||
default n
|
||||
|
||||
config STM32H7_USBDEV_REGDEBUG
|
||||
bool "OTG USBDEV REGDEBUG"
|
||||
default n
|
||||
|
@ -1154,6 +1158,8 @@ config STM32H7_RTC_LSECLOCK_RUN_DRV_CAPABILITY
|
|||
|
||||
endif # STM32H7_RTC_LSECLOCK
|
||||
|
||||
endmenu # RTC Configuration
|
||||
|
||||
config STM32H7_EXTERNAL_RAM
|
||||
bool "External RAM on FMC"
|
||||
default n
|
||||
|
@ -1162,7 +1168,139 @@ config STM32H7_EXTERNAL_RAM
|
|||
---help---
|
||||
In addition to internal SDRAM, external RAM may be available through the FMC.
|
||||
|
||||
endmenu # RTC Configuration
|
||||
menu "QuadSPI Configuration"
|
||||
depends on STM32H7_QUADSPI
|
||||
|
||||
config STM32H7_QSPI_FLASH_SIZE
|
||||
int "Size of attached serial flash, bytes"
|
||||
default 16777216
|
||||
range 1 2147483648
|
||||
---help---
|
||||
The STM32H7 QSPI peripheral requires the size of the Flash be specified
|
||||
|
||||
config STM32H7_QSPI_FIFO_THESHOLD
|
||||
int "Number of bytes before asserting FIFO threshold flag"
|
||||
default 4
|
||||
range 1 16
|
||||
---help---
|
||||
The STM32H7 QSPI peripheral requires that the FIFO threshold be specified
|
||||
I would leave it at the default value of 4 unless you know what you are doing.
|
||||
|
||||
config STM32H7_QSPI_CSHT
|
||||
int "Number of cycles Chip Select must be inactive between transactions"
|
||||
default 1
|
||||
range 1 8
|
||||
---help---
|
||||
The STM32H7 QSPI peripheral requires that it be specified the minimum number
|
||||
of AHB cycles that Chip Select be held inactive between transactions.
|
||||
|
||||
choice
|
||||
prompt "Transfer technique"
|
||||
default STM32H7_QSPI_DMA
|
||||
---help---
|
||||
You can choose between using polling, interrupts, or DMA to transfer data
|
||||
over the QSPI interface.
|
||||
|
||||
config STM32H7_QSPI_POLLING
|
||||
bool "Polling"
|
||||
---help---
|
||||
Use conventional register I/O with status polling to transfer data.
|
||||
|
||||
config STM32H7_QSPI_INTERRUPTS
|
||||
bool "Interrupts"
|
||||
---help---
|
||||
User interrupt driven I/O transfers.
|
||||
|
||||
config STM32H7_QSPI_DMA
|
||||
bool "DMA"
|
||||
depends on STM32H7_DMA
|
||||
---help---
|
||||
Use DMA to improve QSPI transfer performance.
|
||||
|
||||
endchoice
|
||||
|
||||
choice
|
||||
prompt "Bank selection"
|
||||
default STM32H7_QSPI_MODE_BANK1
|
||||
---help---
|
||||
You can choose between using polling, interrupts, or DMA to transfer data
|
||||
over the QSPI interface.
|
||||
|
||||
config STM32H7_QSPI_MODE_BANK1
|
||||
bool "Bank 1"
|
||||
|
||||
config STM32H7_QSPI_MODE_BANK2
|
||||
bool "Bank 2"
|
||||
|
||||
config STM32H7_QSPI_MODE_DUAL
|
||||
bool "Dual Bank"
|
||||
|
||||
endchoice
|
||||
|
||||
choice
|
||||
prompt "DMA Priority"
|
||||
default STM32H7_QSPI_DMAPRIORITY_MEDIUM
|
||||
depends on STM32H7_DMA
|
||||
---help---
|
||||
The DMA controller supports priority levels. You are probably fine
|
||||
with the default of 'medium' except for special cases. In the event
|
||||
of contention between to channels at the same priority, the lower
|
||||
numbered channel has hardware priority over the higher numbered one.
|
||||
|
||||
config STM32H7_QSPI_DMAPRIORITY_VERYHIGH
|
||||
bool "Very High priority"
|
||||
depends on STM32H7_DMA
|
||||
---help---
|
||||
'Highest' priority.
|
||||
|
||||
config STM32H7_QSPI_DMAPRIORITY_HIGH
|
||||
bool "High priority"
|
||||
depends on STM32H7_DMA
|
||||
---help---
|
||||
'High' priority.
|
||||
|
||||
config STM32H7_QSPI_DMAPRIORITY_MEDIUM
|
||||
bool "Medium priority"
|
||||
depends on STM32H7_DMA
|
||||
---help---
|
||||
'Medium' priority.
|
||||
|
||||
config STM32H7_QSPI_DMAPRIORITY_LOW
|
||||
bool "Low priority"
|
||||
depends on STM32H7_DMA
|
||||
---help---
|
||||
'Low' priority.
|
||||
|
||||
endchoice
|
||||
|
||||
config STM32H7_QSPI_DMATHRESHOLD
|
||||
int "QSPI DMA threshold"
|
||||
default 4
|
||||
depends on STM32H7_QSPI_DMA
|
||||
---help---
|
||||
When QSPI DMA is enabled, small DMA transfers will still be performed
|
||||
by polling logic. This value is the threshold below which transfers
|
||||
will still be performed by conventional register status polling.
|
||||
|
||||
config STM32H7_QSPI_DMADEBUG
|
||||
bool "QSPI DMA transfer debug"
|
||||
depends on STM32H7_QSPI_DMA && DEBUG_SPI && DEBUG_DMA
|
||||
default n
|
||||
---help---
|
||||
Enable special debug instrumentation to analyze QSPI DMA data transfers.
|
||||
This logic is as non-invasive as possible: It samples DMA
|
||||
registers at key points in the data transfer and then dumps all of
|
||||
the registers at the end of the transfer.
|
||||
|
||||
config STM32H7_QSPI_REGDEBUG
|
||||
bool "QSPI Register level debug"
|
||||
depends on DEBUG_SPI_INFO
|
||||
default n
|
||||
---help---
|
||||
Output detailed register-level QSPI device debug information.
|
||||
Requires also CONFIG_DEBUG_SPI_INFO.
|
||||
|
||||
endmenu
|
||||
|
||||
config STM32H7_CUSTOM_CLOCKCONFIG
|
||||
bool "Custom clock configuration"
|
||||
|
|
|
@ -161,6 +161,11 @@ ifeq ($(CONFIG_STM32H7_PWR),y)
|
|||
CHIP_CSRCS += stm32_pwr.c
|
||||
endif
|
||||
|
||||
|
||||
ifeq ($(CONFIG_STM32H7_QUADSPI),y)
|
||||
CHIP_CSRCS += stm32_qspi.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_STM32H7_RTC),y)
|
||||
CHIP_CSRCS += stm32_rtc.c
|
||||
ifeq ($(CONFIG_RTC_ALARM),y)
|
||||
|
|
|
@ -0,0 +1,239 @@
|
|||
/****************************************************************************
|
||||
* arch/arm/src/stm32h7/hardware/stm32_qspi.h
|
||||
*
|
||||
* Copyright (C) 2016, 2019 Gregory Nutt. All rights reserved.
|
||||
* Author: dev@ziggurat29.com
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ARCH_ARM_SRC_STM32H7_HARDWARE_STM32H7_QSPI_H
|
||||
#define __ARCH_ARM_SRC_STM32H7_HARDWARE_STM32H7_QSPI_H
|
||||
|
||||
/****************************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <arch/stm32h7/chip.h>
|
||||
|
||||
#include "chip.h"
|
||||
|
||||
/****************************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************************/
|
||||
|
||||
/* General Characteristics **************************************************************/
|
||||
|
||||
#define STM32H7_QSPI_MINBITS 8 /* Minimum word width */
|
||||
#define STM32H7_QSPI_MAXBITS 32 /* Maximum word width */
|
||||
|
||||
/* QSPI register offsets ****************************************************************/
|
||||
|
||||
#define STM32_QUADSPI_CR_OFFSET 0x0000 /* Control Register */
|
||||
#define STM32_QUADSPI_DCR_OFFSET 0x0004 /* Device Configuration Register */
|
||||
#define STM32_QUADSPI_SR_OFFSET 0x0008 /* Status Register */
|
||||
#define STM32_QUADSPI_FCR_OFFSET 0x000c /* Flag Clear Register */
|
||||
#define STM32_QUADSPI_DLR_OFFSET 0x0010 /* Data Length Register */
|
||||
#define STM32_QUADSPI_CCR_OFFSET 0x0014 /* Communication Configuration Register */
|
||||
#define STM32_QUADSPI_AR_OFFSET 0x0018 /* Address Register */
|
||||
#define STM32_QUADSPI_ABR_OFFSET 0x001c /* Alternate Bytes Register */
|
||||
#define STM32_QUADSPI_DR_OFFSET 0x0020 /* Data Register */
|
||||
#define STM32_QUADSPI_PSMKR_OFFSET 0x0024 /* Polling Status mask Register */
|
||||
#define STM32_QUADSPI_PSMAR_OFFSET 0x0028 /* Polling Status match Register */
|
||||
#define STM32_QUADSPI_PIR_OFFSET 0x002c /* Polling Interval Register */
|
||||
#define STM32_QUADSPI_LPTR_OFFSET 0x0030 /* Low-Power Timeout Register */
|
||||
|
||||
/* QSPI register addresses **************************************************************/
|
||||
|
||||
#define STM32_QUADSPI_CR (STM32_QUADSPI_BASE+STM32_QUADSPI_CR_OFFSET) /* Control Register */
|
||||
#define STM32_QUADSPI_DCR (STM32_QUADSPI_BASE+STM32_QUADSPI_DCR_OFFSET) /* Device Configuration Register */
|
||||
#define STM32_QUADSPI_SR (STM32_QUADSPI_BASE+STM32_QUADSPI_SR_OFFSET) /* Status Register */
|
||||
#define STM32_QUADSPI_FCR (STM32_QUADSPI_BASE+STM32_QUADSPI_FCR_OFFSET) /* Flag Clear Register */
|
||||
#define STM32_QUADSPI_DLR (STM32_QUADSPI_BASE+STM32_QUADSPI_DLR_OFFSET) /* Data Length Register */
|
||||
#define STM32_QUADSPI_CCR (STM32_QUADSPI_BASE+STM32_QUADSPI_CCR_OFFSET) /* Communication Configuration Register */
|
||||
#define STM32_QUADSPI_AR (STM32_QUADSPI_BASE+STM32_QUADSPI_AR_OFFSET) /* Address Register */
|
||||
#define STM32_QUADSPI_ABR (STM32_QUADSPI_BASE+STM32_QUADSPI_ABR_OFFSET) /* Alternate Bytes Register */
|
||||
#define STM32_QUADSPI_DR (STM32_QUADSPI_BASE+STM32_QUADSPI_DR_OFFSET) /* Data Register */
|
||||
#define STM32_QUADSPI_PSMKR (STM32_QUADSPI_BASE+STM32_QUADSPI_PSMKR_OFFSET) /* Polling Status mask Register */
|
||||
#define STM32_QUADSPI_PSMAR (STM32_QUADSPI_BASE+STM32_QUADSPI_PSMAR_OFFSET) /* Polling Status match Register */
|
||||
#define STM32_QUADSPI_PIR (STM32_QUADSPI_BASE+STM32_QUADSPI_PIR_OFFSET) /* Polling Interval Register */
|
||||
#define STM32_QUADSPI_LPTR (STM32_QUADSPI_BASE+STM32_QUADSPI_LPTR_OFFSET) /* Low-Power Timeout Register */
|
||||
|
||||
/* QSPI register bit definitions ********************************************************/
|
||||
|
||||
/* Control Register */
|
||||
|
||||
#define QSPI_CR_EN (1 << 0) /* Bit 0: QSPI Enable */
|
||||
#define QSPI_CR_ABORT (1 << 1) /* Bit 1: Abort request */
|
||||
#define QSPI_CR_TCEN (1 << 3) /* Bit 3: Timeout counter enable */
|
||||
#define QSPI_CR_SSHIFT (1 << 4) /* Bit 4: Sample shift */
|
||||
#define QSPI_CR_DFM (1 << 6) /* Bit 6: DFM: Dual-flash mode */
|
||||
#define QSPI_CR_FSEL (1 << 7) /* Bit 7: FSEL: Flash memory selection */
|
||||
#define QSPI_CR_FTHRES_SHIFT (8) /* Bits 8-11: FIFO threshold level */
|
||||
#define QSPI_CR_FTHRES_MASK (0x0f << QSPI_CR_FTHRES_SHIFT)
|
||||
#define QSPI_CR_TEIE (1 << 16) /* Bit 16: Transfer error interrupt enable */
|
||||
#define QSPI_CR_TCIE (1 << 17) /* Bit 17: Transfer complete interrupt enable */
|
||||
#define QSPI_CR_FTIE (1 << 18) /* Bit 18: FIFO threshold interrupt enable */
|
||||
#define QSPI_CR_SMIE (1 << 19) /* Bit 19: Status match interrupt enable */
|
||||
#define QSPI_CR_TOIE (1 << 20) /* Bit 20: TimeOut interrupt enable */
|
||||
#define QSPI_CR_APMS (1 << 22) /* Bit 22: Automatic poll mode stop */
|
||||
#define QSPI_CR_PMM (1 << 23) /* Bit 23: Polling match mode */
|
||||
#define QSPI_CR_PRESCALER_SHIFT (24) /* Bits 24-31: Clock prescaler */
|
||||
#define QSPI_CR_PRESCALER_MASK (0xff << QSPI_CR_PRESCALER_SHIFT)
|
||||
|
||||
/* Device Configuration Register */
|
||||
|
||||
#define QSPI_DCR_CKMODE (1 << 0) /* Bit 0: Mode 0 / mode 3 */
|
||||
#define QSPI_DCR_CSHT_SHIFT (8) /* Bits 8-10: Chip select high time */
|
||||
#define QSPI_DCR_CSHT_MASK (0x7 << QSPI_DCR_CSHT_SHIFT)
|
||||
#define QSPI_DCR_FSIZE_SHIFT (16) /* Bits 16-20: Flash memory size */
|
||||
#define QSPI_DCR_FSIZE_MASK (0x1f << QSPI_DCR_FSIZE_SHIFT)
|
||||
|
||||
/* Status Register */
|
||||
|
||||
#define QSPI_SR_TEF (1 << 0) /* Bit 0: Transfer error flag */
|
||||
#define QSPI_SR_TCF (1 << 1) /* Bit 1: Transfer complete flag */
|
||||
#define QSPI_SR_FTF (1 << 2) /* Bit 2: FIFO threshold flag */
|
||||
#define QSPI_SR_SMF (1 << 3) /* Bit 3: Status match flag */
|
||||
#define QSPI_SR_TOF (1 << 4) /* Bit 4: Timeout flag */
|
||||
#define QSPI_SR_BUSY (1 << 5) /* Bit 5: Busy */
|
||||
#define QSPI_SR_FLEVEL_SHIFT (8) /* Bits 8-12: FIFO threshold level */
|
||||
#define QSPI_SR_FLEVEL_MASK (0x1f << QSPI_SR_FLEVEL_SHIFT)
|
||||
|
||||
/* Flag Clear Register */
|
||||
|
||||
#define QSPI_FCR_CTEF (1 << 0) /* Bit 0: Clear Transfer error flag */
|
||||
#define QSPI_FCR_CTCF (1 << 1) /* Bit 1: Clear Transfer complete flag */
|
||||
#define QSPI_FCR_CSMF (1 << 3) /* Bit 3: Clear Status match flag */
|
||||
#define QSPI_FCR_CTOF (1 << 4) /* Bit 4: Clear Timeout flag */
|
||||
|
||||
/* Data Length Register */
|
||||
|
||||
/* Communication Configuration Register */
|
||||
|
||||
#define CCR_IMODE_NONE 0 /* No instruction */
|
||||
#define CCR_IMODE_SINGLE 1 /* Instruction on a single line */
|
||||
#define CCR_IMODE_DUAL 2 /* Instruction on two lines */
|
||||
#define CCR_IMODE_QUAD 3 /* Instruction on four lines */
|
||||
|
||||
#define CCR_ADMODE_NONE 0 /* No address */
|
||||
#define CCR_ADMODE_SINGLE 1 /* Address on a single line */
|
||||
#define CCR_ADMODE_DUAL 2 /* Address on two lines */
|
||||
#define CCR_ADMODE_QUAD 3 /* Address on four lines */
|
||||
|
||||
#define CCR_ADSIZE_8 0 /* 8-bit address */
|
||||
#define CCR_ADSIZE_16 1 /* 16-bit address */
|
||||
#define CCR_ADSIZE_24 2 /* 24-bit address */
|
||||
#define CCR_ADSIZE_32 3 /* 32-bit address */
|
||||
|
||||
#define CCR_ABMODE_NONE 0 /* No alternate bytes */
|
||||
#define CCR_ABMODE_SINGLE 1 /* Alternate bytes on a single line */
|
||||
#define CCR_ABMODE_DUAL 2 /* Alternate bytes on two lines */
|
||||
#define CCR_ABMODE_QUAD 3 /* Alternate bytes on four lines */
|
||||
|
||||
#define CCR_ABSIZE_8 0 /* 8-bit alternate byte */
|
||||
#define CCR_ABSIZE_16 1 /* 16-bit alternate bytes */
|
||||
#define CCR_ABSIZE_24 2 /* 24-bit alternate bytes */
|
||||
#define CCR_ABSIZE_32 3 /* 32-bit alternate bytes */
|
||||
|
||||
#define CCR_DMODE_NONE 0 /* No data */
|
||||
#define CCR_DMODE_SINGLE 1 /* Data on a single line */
|
||||
#define CCR_DMODE_DUAL 2 /* Data on two lines */
|
||||
#define CCR_DMODE_QUAD 3 /* Data on four lines */
|
||||
|
||||
#define CCR_FMODE_INDWR 0 /* Indirect write mode */
|
||||
#define CCR_FMODE_INDRD 1 /* Indirect read mode */
|
||||
#define CCR_FMODE_AUTOPOLL 2 /* Automatic polling mode */
|
||||
#define CCR_FMODE_MEMMAP 3 /* Memory-mapped mode */
|
||||
|
||||
#define QSPI_CCR_INSTRUCTION_SHIFT (0) /* Bits 0-7: Instruction */
|
||||
#define QSPI_CCR_INSTRUCTION_MASK (0xff << QSPI_CCR_INSTRUCTION_SHIFT)
|
||||
# define QSPI_CCR_INST(n) ((uint32_t)(n) << QSPI_CCR_INSTRUCTION_SHIFT)
|
||||
#define QSPI_CCR_IMODE_SHIFT (8) /* Bits 8-9: Instruction mode */
|
||||
#define QSPI_CCR_IMODE_MASK (0x3 << QSPI_CCR_IMODE_SHIFT)
|
||||
# define QSPI_CCR_IMODE(n) ((uint32_t)(n) << QSPI_CCR_IMODE_SHIFT)
|
||||
#define QSPI_CCR_ADMODE_SHIFT (10) /* Bits 10-11: Address mode */
|
||||
#define QSPI_CCR_ADMODE_MASK (0x3 << QSPI_CCR_ADMODE_SHIFT)
|
||||
# define QSPI_CCR_ADMODE(n) ((uint32_t)(n) << QSPI_CCR_ADMODE_SHIFT)
|
||||
#define QSPI_CCR_ADSIZE_SHIFT (12) /* Bits 12-13: Address size */
|
||||
#define QSPI_CCR_ADSIZE_MASK (0x3 << QSPI_CCR_ADSIZE_SHIFT)
|
||||
# define QSPI_CCR_ADSIZE(n) ((uint32_t)(n) << QSPI_CCR_ADSIZE_SHIFT)
|
||||
#define QSPI_CCR_ABMODE_SHIFT (14) /* Bits 14-15: Alternate bytes mode */
|
||||
#define QSPI_CCR_ABMODE_MASK (0x3 << QSPI_CCR_ABMODE_SHIFT)
|
||||
# define QSPI_CCR_ABMODE(n) ((uint32_t)(n) << QSPI_CCR_ABMODE_SHIFT)
|
||||
#define QSPI_CCR_ABSIZE_SHIFT (16) /* Bits 16-17: Alternate bytes size */
|
||||
#define QSPI_CCR_ABSIZE_MASK (0x3 << QSPI_CCR_ABSIZE_SHIFT)
|
||||
# define QSPI_CCR_ABSIZE(n) ((uint32_t)(n) << QSPI_CCR_ABSIZE_SHIFT)
|
||||
#define QSPI_CCR_DCYC_SHIFT (18) /* Bits 18-23: Number of dummy cycles */
|
||||
#define QSPI_CCR_DCYC_MASK (0x1f << QSPI_CCR_DCYC_SHIFT)
|
||||
# define QSPI_CCR_DCYC(n) ((uint32_t)(n) << QSPI_CCR_DCYC_SHIFT)
|
||||
#define QSPI_CCR_DMODE_SHIFT (24) /* Bits 24-25: Data mode */
|
||||
#define QSPI_CCR_DMODE_MASK (0x3 << QSPI_CCR_DMODE_SHIFT)
|
||||
# define QSPI_CCR_DMODE(n) ((uint32_t)(n) << QSPI_CCR_DMODE_SHIFT)
|
||||
#define QSPI_CCR_FMODE_SHIFT (26) /* Bits 26-27: Functional mode */
|
||||
#define QSPI_CCR_FMODE_MASK (0x3 << QSPI_CCR_FMODE_SHIFT)
|
||||
# define QSPI_CCR_FMODE(n) ((uint32_t)(n) << QSPI_CCR_FMODE_SHIFT)
|
||||
#define QSPI_CCR_SIOO (1 << 28) /* Bit 28: Send instruction only once mode */
|
||||
#define QSPI_CCR_FRCM (1 << 29) /* Bit 28: Enters Free running clock mode */
|
||||
#define QSPI_CCR_DDRM (1 << 31) /* Bit 31: Double data rate mode */
|
||||
|
||||
/* Address Register */
|
||||
|
||||
/* Alternate Bytes Register */
|
||||
|
||||
/* Data Register */
|
||||
|
||||
/* Polling Status mask Register */
|
||||
|
||||
/* Polling Status match Register */
|
||||
|
||||
/* Polling Interval Register */
|
||||
|
||||
#define QSPI_PIR_INTERVAL_SHIFT (0) /* Bits 0-15: Polling interval */
|
||||
#define QSPI_PIR_INTERVAL_MASK (0xFFff << QSPI_PIR_INTERVAL_SHIFT)
|
||||
|
||||
/* Low-Power Timeout Register */
|
||||
|
||||
#define QSPI_LPTR_TIMEOUT_SHIFT (0) /* Bits 0-15: Timeout period */
|
||||
#define QSPI_LPTR_TIMEOUT_MASK (0xFFff << QSPI_PIR_INTERVAL_SHIFT)
|
||||
|
||||
/****************************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************************/
|
||||
|
||||
/****************************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************************/
|
||||
|
||||
/****************************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************************/
|
||||
|
||||
#endif /* __ARCH_ARM_SRC_STM32H7_HARDWARE_STM32H4_QSPI_H */
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,144 @@
|
|||
/****************************************************************************
|
||||
* arch/arm/src/stm32h7/stm32_qspi.h
|
||||
*
|
||||
* Copyright (C) 2016, 2019 Gregory Nutt. All rights reserved.
|
||||
* Author: dev@ziggurat29.com
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ARCH_ARM_SRC_STM32_STM32H7_QSPI_H
|
||||
#define __ARCH_ARM_SRC_STM32_STM32H7_QSPI_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <nuttx/spi/qspi.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "chip.h"
|
||||
|
||||
#ifdef CONFIG_STM32H7_QUADSPI
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Inline Functions
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32l4_qspi_initialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize the selected QSPI port in master mode
|
||||
*
|
||||
* Input Parameters:
|
||||
* intf - Interface number(must be zero)
|
||||
*
|
||||
* Returned Value:
|
||||
* Valid SPI device structure reference on success; a NULL on failure
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
struct qspi_dev_s;
|
||||
FAR struct qspi_dev_s *stm32h7_qspi_initialize(int intf);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32l4_qspi_enter_memorymapped
|
||||
*
|
||||
* Description:
|
||||
* Put the QSPI device into memory mapped mode
|
||||
*
|
||||
* Input Parameters:
|
||||
* dev - QSPI device
|
||||
* meminfo - parameters like for a memory transfer used for reading
|
||||
* lpto - number of cycles to wait to automatically de-assert CS
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void stm32h7_qspi_enter_memorymapped(struct qspi_dev_s *dev,
|
||||
const struct qspi_meminfo_s *meminfo,
|
||||
uint32_t lpto);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32l4_qspi_exit_memorymapped
|
||||
*
|
||||
* Description:
|
||||
* Take the QSPI device out of memory mapped mode
|
||||
*
|
||||
* Input Parameters:
|
||||
* dev - QSPI device
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void stm32h7_qspi_exit_memorymapped(struct qspi_dev_s *dev);
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
#endif /* CONFIG_STM32H7_QSPI */
|
||||
#endif /* __ARCH_ARM_SRC_STM32_STM32H7_QSPI_H */
|
Loading…
Reference in New Issue