From 0c592293cde94f09225db72fac3a15ce3948c6ea Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Mon, 25 Oct 2021 14:36:06 +0000 Subject: [PATCH] Improved comments and formatting. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@14949 27425a3e-05d8-49a3-a47f-9c15f0e5edd8 --- testhal/STM32/multi/SPI/main.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/testhal/STM32/multi/SPI/main.c b/testhal/STM32/multi/SPI/main.c index 3034b851d..5df8a69fe 100755 --- a/testhal/STM32/multi/SPI/main.c +++ b/testhal/STM32/multi/SPI/main.c @@ -167,19 +167,26 @@ int main(void) { txbuf[i] = (uint8_t)i; cacheBufferFlush(&txbuf[0], sizeof txbuf); -#if 0//SPI_SUPPORTS_SLAVE_MODE == TRUE - spiStart(&PORTAB_SPI1, &hs_spicfg); /* Master transfer parameters. */ - spiStart(&PORTAB_SPI2, &sl_spicfg); /* Slave transfer parameters. */ +#if SPI_SUPPORTS_SLAVE_MODE == TRUE + spiStart(&PORTAB_SPI1, &hs_spicfg); /* Master transfer parameters. */ + spiStart(&PORTAB_SPI2, &sl_spicfg); /* Slave transfer parameters. */ do { size_t size; + /* Starting asynchronous SPI slave 512 frames receive.*/ spiStartReceive(&PORTAB_SPI2, 512, rxbuf); - spiSelect(&PORTAB_SPI1); /* Slave Select assertion. */ - spiSend(&PORTAB_SPI1, 256, txbuf); - spiUnselect(&PORTAB_SPI1); /* Slave Select de-assertion. */ - /* Slave status.*/ + /* Starting synchronous master 256 frames send.*/ + spiSelect(&PORTAB_SPI1); + spiSend(&PORTAB_SPI1, 256, txbuf); + spiUnselect(&PORTAB_SPI1); + + /* Stopping slave and getting slave status, it should still be + ongoing because the master sent just 256 frames.*/ spiStopTransfer(&PORTAB_SPI2, &size); + + /* Toggle the LED, wait a little bit and repeat.*/ + palToggleLine(PORTAB_LINE_LED1); chThdSleepMilliseconds(100); } while (palReadLine(PORTAB_LINE_BUTTON) != PORTAB_BUTTON_PRESSED);