Skip to content

Commit f2b929a

Browse files
dgarskedanielinux
authored andcommitted
QSPI Power control (active low).
1 parent 2cf70f0 commit f2b929a

3 files changed

Lines changed: 14 additions & 0 deletions

File tree

config/examples/nrf5340.config

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,8 @@ USE_GCC=1
4848
# Use larger block size for swapping sectors
4949
CFLAGS_EXTRA+=-DFLASHBUFFER_SIZE=0x1000
5050

51+
# Enable optional power control pin (active low) P1.00
52+
CFLAGS_EXTRA+=-DQSPI_PWR_CTRL_PORT=1 -DQSPI_PWR_CTRL_PIN=0
53+
5154
CFLAGS_EXTRA+=-DDEBUG_FLASH
5255
CFLAGS_EXTRA+=-DDEBUG_QSPI=1

hal/spi/spi_drv_nrf5340.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,10 @@ void spi_init(int polarity, int phase)
195195
GPIO_PIN_CNF(QSPI_IO1_PORT, QSPI_IO1_PIN) = (GPIO_CNF_IN_DIS | GPIO_CNF_HIGH_DRIVE);
196196
GPIO_PIN_CNF(QSPI_IO2_PORT, QSPI_IO2_PIN) = (GPIO_CNF_IN_DIS | GPIO_CNF_HIGH_DRIVE);
197197
GPIO_PIN_CNF(QSPI_IO3_PORT, QSPI_IO3_PIN) = (GPIO_CNF_IN_DIS | GPIO_CNF_HIGH_DRIVE);
198+
#if defined(QSPI_PWR_CTRL_PORT) && defined(QSPI_PWR_CTRL_PIN)
199+
GPIO_PIN_CNF(QSPI_PWR_CTRL_PORT, QSPI_PWR_CTRL_PIN) = (GPIO_CNF_IN_DIS | GPIO_CNF_HIGH_DRIVE);
200+
GPIO_OUTCLR(QSPI_PWR_CTRL_PORT) = (1 << QSPI_PWR_CTRL_PIN); /* active low */
201+
#endif
198202

199203
reg = QSPI_IFCONFIG0;
200204
reg &= ~(QSPI_IFCONFIG0_READOC_MASK | QSPI_IFCONFIG0_WRITEOC_MASK);
@@ -278,6 +282,9 @@ void spi_release(void)
278282
/* Disable QSPI Clock to save power */
279283
QSPI_ENABLE = 0;
280284
CLOCK_HFCLK192MSTOP = 1;
285+
#if defined(QSPI_PWR_CTRL_PORT) && defined(QSPI_PWR_CTRL_PIN)
286+
GPIO_OUTSET(QSPI_PWR_CTRL_PORT) = (1 << QSPI_PWR_CTRL_PIN);
287+
#endif
281288
}
282289
}
283290

hal/spi/spi_drv_nrf5340.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@
8383
#define QSPI_CLOCK_MHZ 48000000UL
8484
#endif
8585

86+
/* Optional power pin for QSPI enable */
87+
//#define QSPI_PWR_CTRL_PORT 1
88+
//#define QSPI_PWR_CTRL_PIN 0
89+
8690
/* MX25R6435F */
8791
#define QSPI_NO_SR2
8892

0 commit comments

Comments
 (0)