diff options
Diffstat (limited to 'testhal/STM32')
4 files changed, 35 insertions, 28 deletions
diff --git a/testhal/STM32/multi/SPI/cfg-stm32f091_nucleo64/portab.c b/testhal/STM32/multi/SPI/cfg-stm32f091_nucleo64/portab.c index 9c2a831a4..8c5f7426e 100644 --- a/testhal/STM32/multi/SPI/cfg-stm32f091_nucleo64/portab.c +++ b/testhal/STM32/multi/SPI/cfg-stm32f091_nucleo64/portab.c @@ -72,4 +72,20 @@ const SPIConfig ls_spicfg = { /* Module exported functions. */
/*===========================================================================*/
+void portab_setup(void) {
+
+ /*
+ * SPI2 I/O pins setup.
+ */
+ 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. */
+}
+
/** @} */
diff --git a/testhal/STM32/multi/SPI/cfg-stm32f091_nucleo64/portab.h b/testhal/STM32/multi/SPI/cfg-stm32f091_nucleo64/portab.h index df5c9e77d..3283d07a9 100644 --- a/testhal/STM32/multi/SPI/cfg-stm32f091_nucleo64/portab.h +++ b/testhal/STM32/multi/SPI/cfg-stm32f091_nucleo64/portab.h @@ -29,13 +29,12 @@ /* Module constants. */
/*===========================================================================*/
-#define PORTAB_LINE_LED1 GPIOA_LED_GREEN
+#define PORTAB_LINE_LED1 LINE_LED_GREEN
//#define PORTAB_LINE_LED2
#define PORTAB_LED_OFF PAL_LOW
#define PORTAB_LED_ON PAL_HIGH
-#define PORTAB_LINE_BUTTON LINE_BUTTON
-#define PORTAB_BUTTON_PRESSED PAL_HIGH
+#define PORTAB_SPI1 SPID2
/*===========================================================================*/
/* Module pre-compile time settings. */
@@ -63,7 +62,7 @@ extern const SPIConfig ls_spicfg; #ifdef __cplusplus
extern "C" {
#endif
-
+ void portab_setup(void);
#ifdef __cplusplus
}
#endif
diff --git a/testhal/STM32/multi/SPI/debug/STM32-SPI for STM32F091-Nucleo64(OpenOCD, Flash and Run).launch b/testhal/STM32/multi/SPI/debug/STM32-SPI for STM32F091-Nucleo64(OpenOCD, Flash and Run).launch index ce01d723a..36f50f84e 100644 --- a/testhal/STM32/multi/SPI/debug/STM32-SPI for STM32F091-Nucleo64(OpenOCD, Flash and Run).launch +++ b/testhal/STM32/multi/SPI/debug/STM32-SPI for STM32F091-Nucleo64(OpenOCD, Flash and Run).launch @@ -33,10 +33,10 @@ <intAttribute key="org.eclipse.cdt.launch.ATTR_BUILD_BEFORE_LAUNCH_ATTR" value="2"/> <stringAttribute key="org.eclipse.cdt.launch.COREFILE_PATH" value=""/> <stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_REGISTER_GROUPS" value=""/> -<stringAttribute key="org.eclipse.cdt.launch.FORMAT" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?><contentList/>"/> +<stringAttribute key="org.eclipse.cdt.launch.FORMAT" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?><contentList><content id="xPSR-(format)" val="4"/></contentList>"/> <stringAttribute key="org.eclipse.cdt.launch.GLOBAL_VARIABLES" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <globalVariableList/> "/> <stringAttribute key="org.eclipse.cdt.launch.MEMORY_BLOCKS" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <memoryBlockExpressionList> <memoryBlockExpressionItem> <expression text="0x40021004"/> </memoryBlockExpressionItem> </memoryBlockExpressionList> "/> -<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="./build-stm32f051_discovery/ch.elf"/> +<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="./build-stm32f091_nucleo64/ch.elf"/> <stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="STM32-SPI"/> <booleanAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_AUTO_ATTR" value="true"/> <stringAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_ID_ATTR" value=""/> 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.
|