Skip to content

Commit

Permalink
Added settings for STM32 OCTOSPIv1 and OCTOSPIv2 TCR bits SSHIFT and …
Browse files Browse the repository at this point in the history
…DHQC.

git-svn-id: https://svn.code.sf.net/p/chibios/code/branches/stable_21.11.x@16199 085d63ac-f8f8-4fb4-a5e5-c089fd4f3ff4
  • Loading branch information
gdisirio authored and tridge committed Apr 26, 2023
1 parent fb3f520 commit 6ac1089
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 8 deletions.
24 changes: 20 additions & 4 deletions os/hal/ports/STM32/LLD/OCTOSPIv1/hal_wspi_lld.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,14 @@ void wspi_lld_init(void) {

#if STM32_WSPI_USE_OCTOSPI1
wspiObjectInit(&WSPID1);
WSPID1.extra_tcr = 0U
#if STM32_WSPI_OCTOSPI1_SSHIFT
| OCTOSPI_TCR_SSHIFT
#endif
#if STM32_WSPI_OCTOSPI1_DHQC
| OCTOSPI_TCR_DHQC
#endif
;
WSPID1.ospi = OCTOSPI1;
WSPID1.dma = NULL;
WSPID1.dmamode = STM32_DMA_CR_CHSEL(OCTOSPI1_DMA_STREAM) |
Expand All @@ -182,6 +190,14 @@ void wspi_lld_init(void) {

#if STM32_WSPI_USE_OCTOSPI2
wspiObjectInit(&WSPID2);
WSPID2.extra_tcr = 0U
#if STM32_WSPI_OCTOSPI2_SSHIFT
| OCTOSPI_TCR_SSHIFT
#endif
#if STM32_WSPI_OCTOSPI1_DHQC
| OCTOSPI_TCR_DHQC
#endif
;
WSPID2.ospi = OCTOSPI2;
WSPID2.dma = NULL;
WSPID2.dmamode = STM32_DMA_CR_CHSEL(OCTOSPI2_DMA_STREAM) |
Expand Down Expand Up @@ -308,7 +324,7 @@ void wspi_lld_command(WSPIDriver *wspip, const wspi_command_t *cmdp) {
#endif
wspip->ospi->CR &= ~OCTOSPI_CR_FMODE;
wspip->ospi->DLR = 0U;
wspip->ospi->TCR = cmdp->dummy;
wspip->ospi->TCR = cmdp->dummy | wspip->extra_tcr;
wspip->ospi->CCR = cmdp->cfg;
wspip->ospi->ABR = cmdp->alt;
wspip->ospi->IR = cmdp->cmd;
Expand Down Expand Up @@ -346,7 +362,7 @@ void wspi_lld_send(WSPIDriver *wspip, const wspi_command_t *cmdp,

wspip->ospi->CR &= ~OCTOSPI_CR_FMODE;
wspip->ospi->DLR = n - 1U;
wspip->ospi->TCR = cmdp->dummy;
wspip->ospi->TCR = cmdp->dummy | wspip->extra_tcr;
wspip->ospi->CCR = cmdp->cfg;
wspip->ospi->ABR = cmdp->alt;
wspip->ospi->IR = cmdp->cmd;
Expand Down Expand Up @@ -386,7 +402,7 @@ void wspi_lld_receive(WSPIDriver *wspip, const wspi_command_t *cmdp,

wspip->ospi->CR = (wspip->ospi->CR & ~OCTOSPI_CR_FMODE) | OCTOSPI_CR_FMODE_0;
wspip->ospi->DLR = n - 1U;
wspip->ospi->TCR = cmdp->dummy;
wspip->ospi->TCR = cmdp->dummy | wspip->extra_tcr;
wspip->ospi->CCR = cmdp->cfg;
wspip->ospi->ABR = cmdp->alt;
wspip->ospi->IR = cmdp->cmd;
Expand Down Expand Up @@ -416,7 +432,7 @@ void wspi_lld_map_flash(WSPIDriver *wspip,

/* Starting memory mapped mode using the passed parameters.*/
wspip->ospi->CR = OCTOSPI_CR_FMODE_1 | OCTOSPI_CR_FMODE_0 | OCTOSPI_CR_EN;
wspip->ospi->TCR = cmdp->dummy;
wspip->ospi->TCR = cmdp->dummy | wspip->extra_tcr;
wspip->ospi->CCR = cmdp->cfg;
wspip->ospi->IR = cmdp->cmd;
wspip->ospi->ABR = 0U;
Expand Down
30 changes: 30 additions & 0 deletions os/hal/ports/STM32/LLD/OCTOSPIv1/hal_wspi_lld.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,34 @@
#define STM32_WSPI_OCTOSPI2_PRESCALER_VALUE 1
#endif

/**
* @brief OCTOSPI1 TCR_SSHIFT enforcing.
*/
#if !defined(STM32_WSPI_OCTOSPI1_SSHIFT) || defined(__DOXYGEN__)
#define STM32_WSPI_OCTOSPI1_SSHIFT TRUE
#endif

/**
* @brief OCTOSPI2 TCR_SSHIFT enforcing.
*/
#if !defined(STM32_WSPI_OCTOSPI2_SSHIFT) || defined(__DOXYGEN__)
#define STM32_WSPI_OCTOSPI2_SSHIFT TRUE
#endif

/**
* @brief OCTOSPI1 TCR_DHQC enforcing.
*/
#if !defined(STM32_WSPI_OCTOSPI1_DHQC) || defined(__DOXYGEN__)
#define STM32_WSPI_OCTOSPI1_DHQC TRUE
#endif

/**
* @brief OCTOSPI2 TCR_DHQC enforcing.
*/
#if !defined(STM32_WSPI_OCTOSPI2_DHQC) || defined(__DOXYGEN__)
#define STM32_WSPI_OCTOSPI2_DHQC TRUE
#endif

/**
* @brief OCTOSPI1 interrupt priority level setting.
*/
Expand Down Expand Up @@ -292,6 +320,8 @@
* @brief Low level fields of the WSPI driver structure.
*/
#define wspi_lld_driver_fields \
/* Extra bits for the TCR register.*/ \
uint32_t extra_tcr; \
/* Pointer to the OCTOSPIx registers block.*/ \
OCTOSPI_TypeDef *ospi; \
/* OCTOSPI DMA stream.*/ \
Expand Down
24 changes: 20 additions & 4 deletions os/hal/ports/STM32/LLD/OCTOSPIv2/hal_wspi_lld.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,28 @@ void wspi_lld_init(void) {

#if STM32_WSPI_USE_OCTOSPI1
wspiObjectInit(&WSPID1);
WSPID1.extra_tcr = 0U
#if STM32_WSPI_OCTOSPI1_SSHIFT
| OCTOSPI_TCR_SSHIFT
#endif
#if STM32_WSPI_OCTOSPI1_DHQC
| OCTOSPI_TCR_DHQC
#endif
;
WSPID1.ospi = OCTOSPI1;
WSPID1.mdma = NULL;
#endif

#if STM32_WSPI_USE_OCTOSPI2
wspiObjectInit(&WSPID2);
WSPID2.extra_tcr = 0U
#if STM32_WSPI_OCTOSPI2_SSHIFT
| OCTOSPI_TCR_SSHIFT
#endif
#if STM32_WSPI_OCTOSPI1_DHQC
| OCTOSPI_TCR_DHQC
#endif
;
WSPID2.ospi = OCTOSPI2;
WSPID2.mdma = NULL;
#endif
Expand Down Expand Up @@ -220,7 +236,7 @@ void wspi_lld_command(WSPIDriver *wspip, const wspi_command_t *cmdp) {

wspip->ospi->CR &= ~OCTOSPI_CR_FMODE;
wspip->ospi->DLR = 0U;
wspip->ospi->TCR = cmdp->dummy;
wspip->ospi->TCR = cmdp->dummy | wspip->extra_tcr;
wspip->ospi->CCR = cmdp->cfg;
wspip->ospi->ABR = cmdp->alt;
wspip->ospi->IR = cmdp->cmd;
Expand Down Expand Up @@ -273,7 +289,7 @@ void wspi_lld_send(WSPIDriver *wspip, const wspi_command_t *cmdp,

wspip->ospi->CR &= ~OCTOSPI_CR_FMODE;
wspip->ospi->DLR = n - 1U;
wspip->ospi->TCR = cmdp->dummy;
wspip->ospi->TCR = cmdp->dummy | wspip->extra_tcr;
wspip->ospi->CCR = cmdp->cfg;
wspip->ospi->ABR = cmdp->alt;
wspip->ospi->IR = cmdp->cmd;
Expand Down Expand Up @@ -328,7 +344,7 @@ void wspi_lld_receive(WSPIDriver *wspip, const wspi_command_t *cmdp,

wspip->ospi->CR = (wspip->ospi->CR & ~OCTOSPI_CR_FMODE) | OCTOSPI_CR_FMODE_0;
wspip->ospi->DLR = n - 1U;
wspip->ospi->TCR = cmdp->dummy;
wspip->ospi->TCR = cmdp->dummy | wspip->extra_tcr;
wspip->ospi->CCR = cmdp->cfg;
wspip->ospi->ABR = cmdp->alt;
wspip->ospi->IR = cmdp->cmd;
Expand Down Expand Up @@ -358,7 +374,7 @@ void wspi_lld_map_flash(WSPIDriver *wspip,

/* Starting memory mapped mode using the passed parameters.*/
wspip->ospi->CR = OCTOSPI_CR_FMODE_1 | OCTOSPI_CR_FMODE_0 | OCTOSPI_CR_EN;
wspip->ospi->TCR = cmdp->dummy;
wspip->ospi->TCR = cmdp->dummy | wspip->extra_tcr;
wspip->ospi->CCR = cmdp->cfg;
wspip->ospi->IR = cmdp->cmd;
wspip->ospi->ABR = 0U;
Expand Down
30 changes: 30 additions & 0 deletions os/hal/ports/STM32/LLD/OCTOSPIv2/hal_wspi_lld.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,34 @@
#define STM32_WSPI_OCTOSPI2_PRESCALER_VALUE 1
#endif

/**
* @brief OCTOSPI1 TCR_SSHIFT enforcing.
*/
#if !defined(STM32_WSPI_OCTOSPI1_SSHIFT) || defined(__DOXYGEN__)
#define STM32_WSPI_OCTOSPI1_SSHIFT TRUE
#endif

/**
* @brief OCTOSPI2 TCR_SSHIFT enforcing.
*/
#if !defined(STM32_WSPI_OCTOSPI2_SSHIFT) || defined(__DOXYGEN__)
#define STM32_WSPI_OCTOSPI2_SSHIFT TRUE
#endif

/**
* @brief OCTOSPI1 TCR_DHQC enforcing.
*/
#if !defined(STM32_WSPI_OCTOSPI1_DHQC) || defined(__DOXYGEN__)
#define STM32_WSPI_OCTOSPI1_DHQC TRUE
#endif

/**
* @brief OCTOSPI2 TCR_DHQC enforcing.
*/
#if !defined(STM32_WSPI_OCTOSPI2_DHQC) || defined(__DOXYGEN__)
#define STM32_WSPI_OCTOSPI2_DHQC TRUE
#endif

/**
* @brief OCTOSPI1 MDMA channel selection.
*/
Expand Down Expand Up @@ -276,6 +304,8 @@
* @brief Low level fields of the WSPI driver structure.
*/
#define wspi_lld_driver_fields \
/* Extra bits for the TCR register.*/ \
uint32_t extra_tcr; \
/* Pointer to the OCTOSPIx registers block.*/ \
OCTOSPI_TypeDef *ospi; \
/* QUADSPI MDMA channel.*/ \
Expand Down

0 comments on commit 6ac1089

Please sign in to comment.