SPI demo improvements and more coverage, fixed polled exchange in STM32 SPIv3.
@@ -1135,8 +1135,6 @@ | ||
1135 | 1135 | |
1136 | 1136 | osalDbgAssert(n < 65536, "unsupported DMA transfer size"); |
1137 | 1137 | |
1138 | - spi_lld_wait_complete(spip); | |
1139 | - | |
1140 | 1138 | #if defined(STM32_SPI_DMA_REQUIRED) && defined(STM32_SPI_BDMA_REQUIRED) |
1141 | 1139 | if (spip->is_bdma) |
1142 | 1140 | #endif |
@@ -1195,8 +1193,6 @@ | ||
1195 | 1193 | |
1196 | 1194 | osalDbgAssert(n < 65536, "unsupported DMA transfer size"); |
1197 | 1195 | |
1198 | - spi_lld_wait_complete(spip); | |
1199 | - | |
1200 | 1196 | #if defined(STM32_SPI_DMA_REQUIRED) && defined(STM32_SPI_BDMA_REQUIRED) |
1201 | 1197 | if (spip->is_bdma) |
1202 | 1198 | #endif |
@@ -1255,8 +1251,6 @@ | ||
1255 | 1251 | |
1256 | 1252 | osalDbgAssert(n < 65536, "unsupported DMA transfer size"); |
1257 | 1253 | |
1258 | - spi_lld_wait_complete(spip); | |
1259 | - | |
1260 | 1254 | #if defined(STM32_SPI_DMA_REQUIRED) && defined(STM32_SPI_BDMA_REQUIRED) |
1261 | 1255 | if (spip->is_bdma) |
1262 | 1256 | #endif |
@@ -1353,10 +1347,8 @@ | ||
1353 | 1347 | uint32_t dsize = (spip->spi->CFG1 & SPI_CFG1_DSIZE_Msk) + 1U; |
1354 | 1348 | uint32_t rxframe; |
1355 | 1349 | |
1356 | - spi_lld_wait_complete(spip); | |
1350 | + spi_lld_start_transfer(spip); | |
1357 | 1351 | |
1358 | - spip->spi->CR1 |= SPI_CR1_CSTART; | |
1359 | - | |
1360 | 1352 | /* wait for room in TX FIFO.*/ |
1361 | 1353 | while ((spip->spi->SR & SPI_SR_TXP) == 0U) |
1362 | 1354 | ; |
@@ -1390,6 +1382,8 @@ | ||
1390 | 1382 | } |
1391 | 1383 | |
1392 | 1384 | spip->spi->CR1 |= SPI_CR1_CSUSP; |
1385 | + spi_lld_wait_complete(spip); | |
1386 | + spip->spi->CR1 &= ~SPI_CR1_SPE; | |
1393 | 1387 | |
1394 | 1388 | return rxframe; |
1395 | 1389 | } |
@@ -215,9 +215,38 @@ | ||
215 | 215 | spiUnselect(&PORTAB_SPI1); /* Slave Select de-assertion. */ |
216 | 216 | cacheBufferInvalidate(&rxbuf[0], /* Cache invalidation over the */ |
217 | 217 | sizeof rxbuf);/* buffer. */ |
218 | + | |
219 | + /* Waiting button release.*/ | |
220 | + while (palReadLine(PORTAB_LINE_BUTTON) == PORTAB_BUTTON_PRESSED) { | |
221 | + chThdSleepMilliseconds(100); | |
222 | + } | |
218 | 223 | #endif |
219 | 224 | |
220 | 225 | /* |
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 | + /* | |
221 | 250 | * Starting the transmitter and receiver threads. |
222 | 251 | */ |
223 | 252 | chThdCreateStatic(spi_thread_1_wa, sizeof(spi_thread_1_wa), |
@@ -1135,8 +1135,6 @@ | ||
1135 | 1135 | |
1136 | 1136 | osalDbgAssert(n < 65536, "unsupported DMA transfer size"); |
1137 | 1137 | |
1138 | - spi_lld_wait_complete(spip); | |
1139 | - | |
1140 | 1138 | #if defined(STM32_SPI_DMA_REQUIRED) && defined(STM32_SPI_BDMA_REQUIRED) |
1141 | 1139 | if (spip->is_bdma) |
1142 | 1140 | #endif |
@@ -1195,8 +1193,6 @@ | ||
1195 | 1193 | |
1196 | 1194 | osalDbgAssert(n < 65536, "unsupported DMA transfer size"); |
1197 | 1195 | |
1198 | - spi_lld_wait_complete(spip); | |
1199 | - | |
1200 | 1196 | #if defined(STM32_SPI_DMA_REQUIRED) && defined(STM32_SPI_BDMA_REQUIRED) |
1201 | 1197 | if (spip->is_bdma) |
1202 | 1198 | #endif |
@@ -1255,8 +1251,6 @@ | ||
1255 | 1251 | |
1256 | 1252 | osalDbgAssert(n < 65536, "unsupported DMA transfer size"); |
1257 | 1253 | |
1258 | - spi_lld_wait_complete(spip); | |
1259 | - | |
1260 | 1254 | #if defined(STM32_SPI_DMA_REQUIRED) && defined(STM32_SPI_BDMA_REQUIRED) |
1261 | 1255 | if (spip->is_bdma) |
1262 | 1256 | #endif |
@@ -1353,10 +1347,8 @@ | ||
1353 | 1347 | uint32_t dsize = (spip->spi->CFG1 & SPI_CFG1_DSIZE_Msk) + 1U; |
1354 | 1348 | uint32_t rxframe; |
1355 | 1349 | |
1356 | - spi_lld_wait_complete(spip); | |
1350 | + spi_lld_start_transfer(spip); | |
1357 | 1351 | |
1358 | - spip->spi->CR1 |= SPI_CR1_CSTART; | |
1359 | - | |
1360 | 1352 | /* wait for room in TX FIFO.*/ |
1361 | 1353 | while ((spip->spi->SR & SPI_SR_TXP) == 0U) |
1362 | 1354 | ; |
@@ -1390,6 +1382,8 @@ | ||
1390 | 1382 | } |
1391 | 1383 | |
1392 | 1384 | spip->spi->CR1 |= SPI_CR1_CSUSP; |
1385 | + spi_lld_wait_complete(spip); | |
1386 | + spip->spi->CR1 &= ~SPI_CR1_SPE; | |
1393 | 1387 | |
1394 | 1388 | return rxframe; |
1395 | 1389 | } |
@@ -215,9 +215,38 @@ | ||
215 | 215 | spiUnselect(&PORTAB_SPI1); /* Slave Select de-assertion. */ |
216 | 216 | cacheBufferInvalidate(&rxbuf[0], /* Cache invalidation over the */ |
217 | 217 | sizeof rxbuf);/* buffer. */ |
218 | + | |
219 | + /* Waiting button release.*/ | |
220 | + while (palReadLine(PORTAB_LINE_BUTTON) == PORTAB_BUTTON_PRESSED) { | |
221 | + chThdSleepMilliseconds(100); | |
222 | + } | |
218 | 223 | #endif |
219 | 224 | |
220 | 225 | /* |
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 | + /* | |
221 | 250 | * Starting the transmitter and receiver threads. |
222 | 251 | */ |
223 | 252 | chThdCreateStatic(spi_thread_1_wa, sizeof(spi_thread_1_wa), |