diff options
author | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2011-11-12 10:10:52 +0000 |
---|---|---|
committer | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2011-11-12 10:10:52 +0000 |
commit | 30e29ea2155b522e962cd2778cb001089feb58c5 (patch) | |
tree | 0295e58451b0c7ced5a98a4b7b41fa3f98b45cfa /testhal | |
parent | 6eae3c1de5a1936247676750132758d17d9bdaf1 (diff) | |
download | ChibiOS-30e29ea2155b522e962cd2778cb001089feb58c5.tar.gz ChibiOS-30e29ea2155b522e962cd2778cb001089feb58c5.tar.bz2 ChibiOS-30e29ea2155b522e962cd2778cb001089feb58c5.zip |
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3488 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'testhal')
-rw-r--r-- | testhal/STM32F4xx/SPI/main.c | 40 | ||||
-rw-r--r-- | testhal/STM32F4xx/SPI/readme.txt | 6 |
2 files changed, 25 insertions, 21 deletions
diff --git a/testhal/STM32F4xx/SPI/main.c b/testhal/STM32F4xx/SPI/main.c index d12da4215..2414cc559 100644 --- a/testhal/STM32F4xx/SPI/main.c +++ b/testhal/STM32F4xx/SPI/main.c @@ -56,14 +56,14 @@ static msg_t spi_thread_1(void *p) { (void)p;
chRegSetThreadName("SPI thread 1");
while (TRUE) {
- spiAcquireBus(&SPID1); /* Acquire ownership of the bus. */
+ spiAcquireBus(&SPID2); /* Acquire ownership of the bus. */
palSetPad(GPIOD, GPIOD_LED5); /* LED ON. */
- spiStart(&SPID1, &hs_spicfg); /* Setup transfer parameters. */
- spiSelect(&SPID1); /* Slave Select assertion. */
- spiExchange(&SPID1, 512,
+ spiStart(&SPID2, &hs_spicfg); /* Setup transfer parameters. */
+ spiSelect(&SPID2); /* Slave Select assertion. */
+ spiExchange(&SPID2, 512,
txbuf, rxbuf); /* Atomic transfer operations. */
- spiUnselect(&SPID1); /* Slave Select de-assertion. */
- spiReleaseBus(&SPID1); /* Ownership release. */
+ spiUnselect(&SPID2); /* Slave Select de-assertion. */
+ spiReleaseBus(&SPID2); /* Ownership release. */
}
return 0;
}
@@ -77,14 +77,14 @@ static msg_t spi_thread_2(void *p) { (void)p;
chRegSetThreadName("SPI thread 2");
while (TRUE) {
- spiAcquireBus(&SPID1); /* Acquire ownership of the bus. */
+ spiAcquireBus(&SPID2); /* Acquire ownership of the bus. */
palClearPad(GPIOD, GPIOD_LED5); /* LED OFF. */
- spiStart(&SPID1, &ls_spicfg); /* Setup transfer parameters. */
- spiSelect(&SPID1); /* Slave Select assertion. */
- spiExchange(&SPID1, 512,
+ spiStart(&SPID2, &ls_spicfg); /* Setup transfer parameters. */
+ spiSelect(&SPID2); /* Slave Select assertion. */
+ spiExchange(&SPID2, 512,
txbuf, rxbuf); /* Atomic transfer operations. */
- spiUnselect(&SPID1); /* Slave Select de-assertion. */
- spiReleaseBus(&SPID1); /* Ownership release. */
+ spiUnselect(&SPID2); /* Slave Select de-assertion. */
+ spiReleaseBus(&SPID2); /* Ownership release. */
}
return 0;
}
@@ -106,16 +106,16 @@ int main(void) { chSysInit();
/*
- * SPI1 I/O pins setup.
+ * SPI2 I/O pins setup.
*/
- palSetPadMode(GPIOA, 5, PAL_MODE_ALTERNATE(5) |
- PAL_STM32_OSPEED_HIGHEST); /* SCK. */
- palSetPadMode(GPIOA, 6, PAL_MODE_ALTERNATE(5) |
- PAL_STM32_OSPEED_HIGHEST); /* MISO.*/
- palSetPadMode(GPIOA, 7, PAL_MODE_ALTERNATE(5) |
- PAL_STM32_OSPEED_HIGHEST); /* MOSI.*/
+ palSetPadMode(GPIOB, 13, PAL_MODE_ALTERNATE(5) |
+ PAL_STM32_OSPEED_HIGHEST); /* New SCK. */
+ palSetPadMode(GPIOB, 14, PAL_MODE_ALTERNATE(5) |
+ PAL_STM32_OSPEED_HIGHEST); /* New MISO. */
+ palSetPadMode(GPIOB, 15, PAL_MODE_ALTERNATE(5) |
+ PAL_STM32_OSPEED_HIGHEST); /* New MOSI. */
palSetPadMode(GPIOB, 12, PAL_MODE_OUTPUT_PUSHPULL |
- PAL_STM32_OSPEED_HIGHEST);
+ PAL_STM32_OSPEED_HIGHEST); /* New CS. */
palSetPad(GPIOB, 12);
/*
diff --git a/testhal/STM32F4xx/SPI/readme.txt b/testhal/STM32F4xx/SPI/readme.txt index c1914bc43..2a7751877 100644 --- a/testhal/STM32F4xx/SPI/readme.txt +++ b/testhal/STM32F4xx/SPI/readme.txt @@ -8,7 +8,11 @@ The demo runs on an ST STM32F4-Discovery board. ** The Demo **
-The application demonstrates the use of the STM32 SPI driver.
+The application demonstrates the use of the STM32F4xx SPI driver.
+
+** Board Setup **
+
+- Connect PB14 and PB15 together for SPI loop-back.
** Build Procedure **
|