• R/O
  • SSH
  • HTTPS

chibios: Commit


Commit MetaInfo

Revision15619 (tree)
Time2022-05-05 17:09:45
Authorgdisirio

Log Message

SPI demo improvements and more coverage, fixed polled exchange in STM32 SPIv3.

Change Summary

Incremental Difference

--- branches/stable_21.11.x/os/hal/ports/STM32/LLD/SPIv3/hal_spi_v2_lld.c (revision 15618)
+++ branches/stable_21.11.x/os/hal/ports/STM32/LLD/SPIv3/hal_spi_v2_lld.c (revision 15619)
@@ -1135,8 +1135,6 @@
11351135
11361136 osalDbgAssert(n < 65536, "unsupported DMA transfer size");
11371137
1138- spi_lld_wait_complete(spip);
1139-
11401138 #if defined(STM32_SPI_DMA_REQUIRED) && defined(STM32_SPI_BDMA_REQUIRED)
11411139 if (spip->is_bdma)
11421140 #endif
@@ -1195,8 +1193,6 @@
11951193
11961194 osalDbgAssert(n < 65536, "unsupported DMA transfer size");
11971195
1198- spi_lld_wait_complete(spip);
1199-
12001196 #if defined(STM32_SPI_DMA_REQUIRED) && defined(STM32_SPI_BDMA_REQUIRED)
12011197 if (spip->is_bdma)
12021198 #endif
@@ -1255,8 +1251,6 @@
12551251
12561252 osalDbgAssert(n < 65536, "unsupported DMA transfer size");
12571253
1258- spi_lld_wait_complete(spip);
1259-
12601254 #if defined(STM32_SPI_DMA_REQUIRED) && defined(STM32_SPI_BDMA_REQUIRED)
12611255 if (spip->is_bdma)
12621256 #endif
@@ -1353,10 +1347,8 @@
13531347 uint32_t dsize = (spip->spi->CFG1 & SPI_CFG1_DSIZE_Msk) + 1U;
13541348 uint32_t rxframe;
13551349
1356- spi_lld_wait_complete(spip);
1350+ spi_lld_start_transfer(spip);
13571351
1358- spip->spi->CR1 |= SPI_CR1_CSTART;
1359-
13601352 /* wait for room in TX FIFO.*/
13611353 while ((spip->spi->SR & SPI_SR_TXP) == 0U)
13621354 ;
@@ -1390,6 +1382,8 @@
13901382 }
13911383
13921384 spip->spi->CR1 |= SPI_CR1_CSUSP;
1385+ spi_lld_wait_complete(spip);
1386+ spip->spi->CR1 &= ~SPI_CR1_SPE;
13931387
13941388 return rxframe;
13951389 }
--- branches/stable_21.11.x/testhal/STM32/multi/SPI/main.c (revision 15618)
+++ branches/stable_21.11.x/testhal/STM32/multi/SPI/main.c (revision 15619)
@@ -215,9 +215,38 @@
215215 spiUnselect(&PORTAB_SPI1); /* Slave Select de-assertion. */
216216 cacheBufferInvalidate(&rxbuf[0], /* Cache invalidation over the */
217217 sizeof rxbuf);/* buffer. */
218+
219+ /* Waiting button release.*/
220+ while (palReadLine(PORTAB_LINE_BUTTON) == PORTAB_BUTTON_PRESSED) {
221+ chThdSleepMilliseconds(100);
222+ }
218223 #endif
219224
220225 /*
226+ * Testing polled mixed with DMA transfers.
227+ */
228+ spiStart(&PORTAB_SPI1, &ls_spicfg); /* Setup transfer parameters. */
229+ do {
230+ /* Starting synchronous master 256 frames send.*/
231+ spiSelect(&PORTAB_SPI1);
232+ spiPolledExchange(&PORTAB_SPI1, txbuf[0x55]);
233+ spiExchange(&PORTAB_SPI1, 4,
234+ txbuf, rxbuf);
235+ spiUnselect(&PORTAB_SPI1);
236+
237+ /* Toggle the LED, wait a little bit and repeat.*/
238+ #if defined(PORTAB_LINE_LED1)
239+ palToggleLine(PORTAB_LINE_LED1);
240+ #endif
241+ chThdSleepMilliseconds(100);
242+ } while (palReadLine(PORTAB_LINE_BUTTON) != PORTAB_BUTTON_PRESSED);
243+
244+ /* Waiting button release.*/
245+ while (palReadLine(PORTAB_LINE_BUTTON) == PORTAB_BUTTON_PRESSED) {
246+ chThdSleepMilliseconds(100);
247+ }
248+
249+ /*
221250 * Starting the transmitter and receiver threads.
222251 */
223252 chThdCreateStatic(spi_thread_1_wa, sizeof(spi_thread_1_wa),
--- trunk/os/hal/ports/STM32/LLD/SPIv3/hal_spi_v2_lld.c (revision 15618)
+++ trunk/os/hal/ports/STM32/LLD/SPIv3/hal_spi_v2_lld.c (revision 15619)
@@ -1135,8 +1135,6 @@
11351135
11361136 osalDbgAssert(n < 65536, "unsupported DMA transfer size");
11371137
1138- spi_lld_wait_complete(spip);
1139-
11401138 #if defined(STM32_SPI_DMA_REQUIRED) && defined(STM32_SPI_BDMA_REQUIRED)
11411139 if (spip->is_bdma)
11421140 #endif
@@ -1195,8 +1193,6 @@
11951193
11961194 osalDbgAssert(n < 65536, "unsupported DMA transfer size");
11971195
1198- spi_lld_wait_complete(spip);
1199-
12001196 #if defined(STM32_SPI_DMA_REQUIRED) && defined(STM32_SPI_BDMA_REQUIRED)
12011197 if (spip->is_bdma)
12021198 #endif
@@ -1255,8 +1251,6 @@
12551251
12561252 osalDbgAssert(n < 65536, "unsupported DMA transfer size");
12571253
1258- spi_lld_wait_complete(spip);
1259-
12601254 #if defined(STM32_SPI_DMA_REQUIRED) && defined(STM32_SPI_BDMA_REQUIRED)
12611255 if (spip->is_bdma)
12621256 #endif
@@ -1353,10 +1347,8 @@
13531347 uint32_t dsize = (spip->spi->CFG1 & SPI_CFG1_DSIZE_Msk) + 1U;
13541348 uint32_t rxframe;
13551349
1356- spi_lld_wait_complete(spip);
1350+ spi_lld_start_transfer(spip);
13571351
1358- spip->spi->CR1 |= SPI_CR1_CSTART;
1359-
13601352 /* wait for room in TX FIFO.*/
13611353 while ((spip->spi->SR & SPI_SR_TXP) == 0U)
13621354 ;
@@ -1390,6 +1382,8 @@
13901382 }
13911383
13921384 spip->spi->CR1 |= SPI_CR1_CSUSP;
1385+ spi_lld_wait_complete(spip);
1386+ spip->spi->CR1 &= ~SPI_CR1_SPE;
13931387
13941388 return rxframe;
13951389 }
--- trunk/testhal/STM32/multi/SPI/main.c (revision 15618)
+++ trunk/testhal/STM32/multi/SPI/main.c (revision 15619)
@@ -215,9 +215,38 @@
215215 spiUnselect(&PORTAB_SPI1); /* Slave Select de-assertion. */
216216 cacheBufferInvalidate(&rxbuf[0], /* Cache invalidation over the */
217217 sizeof rxbuf);/* buffer. */
218+
219+ /* Waiting button release.*/
220+ while (palReadLine(PORTAB_LINE_BUTTON) == PORTAB_BUTTON_PRESSED) {
221+ chThdSleepMilliseconds(100);
222+ }
218223 #endif
219224
220225 /*
226+ * Testing polled mixed with DMA transfers.
227+ */
228+ spiStart(&PORTAB_SPI1, &ls_spicfg); /* Setup transfer parameters. */
229+ do {
230+ /* Starting synchronous master 256 frames send.*/
231+ spiSelect(&PORTAB_SPI1);
232+ spiPolledExchange(&PORTAB_SPI1, txbuf[0x55]);
233+ spiExchange(&PORTAB_SPI1, 4,
234+ txbuf, rxbuf);
235+ spiUnselect(&PORTAB_SPI1);
236+
237+ /* Toggle the LED, wait a little bit and repeat.*/
238+ #if defined(PORTAB_LINE_LED1)
239+ palToggleLine(PORTAB_LINE_LED1);
240+ #endif
241+ chThdSleepMilliseconds(100);
242+ } while (palReadLine(PORTAB_LINE_BUTTON) != PORTAB_BUTTON_PRESSED);
243+
244+ /* Waiting button release.*/
245+ while (palReadLine(PORTAB_LINE_BUTTON) == PORTAB_BUTTON_PRESSED) {
246+ chThdSleepMilliseconds(100);
247+ }
248+
249+ /*
221250 * Starting the transmitter and receiver threads.
222251 */
223252 chThdCreateStatic(spi_thread_1_wa, sizeof(spi_thread_1_wa),
Show on old repository browser