From 16224e72a4a567fa5b2f829ffc38917af9fd7a1a Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Sun, 17 Sep 2017 07:22:40 +0000 Subject: Demo working now. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@10606 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- testhal/STM32/multi/SPI/main.c | 36 ++++++++++++++---------------------- 1 file changed, 14 insertions(+), 22 deletions(-) (limited to 'testhal/STM32/multi/SPI/main.c') diff --git a/testhal/STM32/multi/SPI/main.c b/testhal/STM32/multi/SPI/main.c index fd37eb4a5..fd1d74250 100755 --- a/testhal/STM32/multi/SPI/main.c +++ b/testhal/STM32/multi/SPI/main.c @@ -34,14 +34,14 @@ static THD_FUNCTION(spi_thread_1, p) { (void)p; chRegSetThreadName("SPI thread 1"); while (true) { - spiAcquireBus(&SPID2); /* Acquire ownership of the bus. */ + spiAcquireBus(&PORTAB_SPI1); /* Acquire ownership of the bus. */ palWriteLine(PORTAB_LINE_LED1, PORTAB_LED_ON); - spiStart(&SPID2, &hs_spicfg); /* Setup transfer parameters. */ - spiSelect(&SPID2); /* Slave Select assertion. */ - spiExchange(&SPID2, 512, + spiStart(&PORTAB_SPI1, &hs_spicfg); /* Setup transfer parameters. */ + spiSelect(&PORTAB_SPI1); /* Slave Select assertion. */ + spiExchange(&PORTAB_SPI1, 512, txbuf, rxbuf); /* Atomic transfer operations. */ - spiUnselect(&SPID2); /* Slave Select de-assertion. */ - spiReleaseBus(&SPID2); /* Ownership release. */ + spiUnselect(&PORTAB_SPI1); /* Slave Select de-assertion. */ + spiReleaseBus(&PORTAB_SPI1); /* Ownership release. */ } } @@ -54,14 +54,14 @@ static THD_FUNCTION(spi_thread_2, p) { (void)p; chRegSetThreadName("SPI thread 2"); while (true) { - spiAcquireBus(&SPID2); /* Acquire ownership of the bus. */ + spiAcquireBus(&PORTAB_SPI1); /* Acquire ownership of the bus. */ palWriteLine(PORTAB_LINE_LED1, PORTAB_LED_OFF); - spiStart(&SPID2, &ls_spicfg); /* Setup transfer parameters. */ - spiSelect(&SPID2); /* Slave Select assertion. */ - spiExchange(&SPID2, 512, + spiStart(&PORTAB_SPI1, &ls_spicfg); /* Setup transfer parameters. */ + spiSelect(&PORTAB_SPI1); /* Slave Select assertion. */ + spiExchange(&PORTAB_SPI1, 512, txbuf, rxbuf); /* Atomic transfer operations. */ - spiUnselect(&SPID2); /* Slave Select de-assertion. */ - spiReleaseBus(&SPID2); /* Ownership release. */ + spiUnselect(&PORTAB_SPI1); /* Slave Select de-assertion. */ + spiReleaseBus(&PORTAB_SPI1); /* Ownership release. */ } } @@ -98,17 +98,9 @@ int main(void) { chSysInit(); /* - * SPI2 I/O pins setup. + * Board-dependent GPIO setup code. */ - palSetPadMode(GPIOB, 13, PAL_MODE_ALTERNATE(0) | - PAL_STM32_OSPEED_HIGHEST); /* New SCK. */ - palSetPadMode(GPIOB, 14, PAL_MODE_ALTERNATE(0) | - PAL_STM32_OSPEED_HIGHEST); /* New MISO. */ - palSetPadMode(GPIOB, 15, PAL_MODE_ALTERNATE(0) | - PAL_STM32_OSPEED_HIGHEST); /* New MOSI. */ - palSetPad(GPIOB, 12); - palSetPadMode(GPIOB, 12, PAL_MODE_OUTPUT_PUSHPULL | - PAL_STM32_OSPEED_HIGHEST); /* New CS. */ + portab_setup(); /* * Prepare transmit pattern. -- cgit v1.2.3