Skip to content

Commit

Permalink
QSPI Power control (active low).
Browse files Browse the repository at this point in the history
  • Loading branch information
dgarske authored and danielinux committed Oct 11, 2024
1 parent 2cf70f0 commit f2b929a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions config/examples/nrf5340.config
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,8 @@ USE_GCC=1
# Use larger block size for swapping sectors
CFLAGS_EXTRA+=-DFLASHBUFFER_SIZE=0x1000

# Enable optional power control pin (active low) P1.00
CFLAGS_EXTRA+=-DQSPI_PWR_CTRL_PORT=1 -DQSPI_PWR_CTRL_PIN=0

CFLAGS_EXTRA+=-DDEBUG_FLASH
CFLAGS_EXTRA+=-DDEBUG_QSPI=1
7 changes: 7 additions & 0 deletions hal/spi/spi_drv_nrf5340.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,10 @@ void spi_init(int polarity, int phase)
GPIO_PIN_CNF(QSPI_IO1_PORT, QSPI_IO1_PIN) = (GPIO_CNF_IN_DIS | GPIO_CNF_HIGH_DRIVE);
GPIO_PIN_CNF(QSPI_IO2_PORT, QSPI_IO2_PIN) = (GPIO_CNF_IN_DIS | GPIO_CNF_HIGH_DRIVE);
GPIO_PIN_CNF(QSPI_IO3_PORT, QSPI_IO3_PIN) = (GPIO_CNF_IN_DIS | GPIO_CNF_HIGH_DRIVE);
#if defined(QSPI_PWR_CTRL_PORT) && defined(QSPI_PWR_CTRL_PIN)
GPIO_PIN_CNF(QSPI_PWR_CTRL_PORT, QSPI_PWR_CTRL_PIN) = (GPIO_CNF_IN_DIS | GPIO_CNF_HIGH_DRIVE);
GPIO_OUTCLR(QSPI_PWR_CTRL_PORT) = (1 << QSPI_PWR_CTRL_PIN); /* active low */
#endif

reg = QSPI_IFCONFIG0;
reg &= ~(QSPI_IFCONFIG0_READOC_MASK | QSPI_IFCONFIG0_WRITEOC_MASK);
Expand Down Expand Up @@ -278,6 +282,9 @@ void spi_release(void)
/* Disable QSPI Clock to save power */
QSPI_ENABLE = 0;
CLOCK_HFCLK192MSTOP = 1;
#if defined(QSPI_PWR_CTRL_PORT) && defined(QSPI_PWR_CTRL_PIN)
GPIO_OUTSET(QSPI_PWR_CTRL_PORT) = (1 << QSPI_PWR_CTRL_PIN);
#endif
}
}

Expand Down
4 changes: 4 additions & 0 deletions hal/spi/spi_drv_nrf5340.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@
#define QSPI_CLOCK_MHZ 48000000UL
#endif

/* Optional power pin for QSPI enable */
//#define QSPI_PWR_CTRL_PORT 1
//#define QSPI_PWR_CTRL_PIN 0

/* MX25R6435F */
#define QSPI_NO_SR2

Expand Down

0 comments on commit f2b929a

Please sign in to comment.