From 3b9390e689711513d15056c0302d9ba602da1d33 Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Tue, 26 Oct 2021 13:40:47 +0000 Subject: [PATCH] Moved F7 SPI demo to SPI multi project, removed old demo. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@14959 27425a3e-05d8-49a3-a47f-9c15f0e5edd8 --- testhal/STM32/STM32F7xx/SPI/.cproject | 50 ----- testhal/STM32/STM32F7xx/SPI/.project | 95 --------- testhal/STM32/STM32F7xx/SPI/main.c | 187 ------------------ testhal/STM32/STM32F7xx/SPI/readme.txt | 25 --- testhal/STM32/multi/SPI/.cproject | 35 ++++ testhal/STM32/multi/SPI/Makefile | 11 ++ .../SPI/cfg/stm32f303_discovery/portab.h | 2 +- .../multi/SPI/cfg/stm32f373vc_eval/portab.h | 2 +- .../SPI/cfg/stm32f746ng_discovery}/chconf.h | 0 .../SPI/cfg/stm32f746ng_discovery}/halconf.h | 0 .../SPI/cfg/stm32f746ng_discovery}/mcuconf.h | 0 .../SPI/cfg/stm32f746ng_discovery/portab.c | 119 +++++++++++ .../SPI/cfg/stm32f746ng_discovery/portab.h | 80 ++++++++ testhal/STM32/multi/SPI/main.c | 10 + .../SPI/make/stm32f746ng_discovery.make} | 113 ++++------- 15 files changed, 299 insertions(+), 430 deletions(-) delete mode 100644 testhal/STM32/STM32F7xx/SPI/.cproject delete mode 100644 testhal/STM32/STM32F7xx/SPI/.project delete mode 100644 testhal/STM32/STM32F7xx/SPI/main.c delete mode 100644 testhal/STM32/STM32F7xx/SPI/readme.txt rename testhal/STM32/{STM32F7xx/SPI => multi/SPI/cfg/stm32f746ng_discovery}/chconf.h (100%) rename testhal/STM32/{STM32F7xx/SPI => multi/SPI/cfg/stm32f746ng_discovery}/halconf.h (100%) rename testhal/STM32/{STM32F7xx/SPI => multi/SPI/cfg/stm32f746ng_discovery}/mcuconf.h (100%) create mode 100644 testhal/STM32/multi/SPI/cfg/stm32f746ng_discovery/portab.c create mode 100644 testhal/STM32/multi/SPI/cfg/stm32f746ng_discovery/portab.h rename testhal/STM32/{STM32F7xx/SPI/Makefile => multi/SPI/make/stm32f746ng_discovery.make} (62%) diff --git a/testhal/STM32/STM32F7xx/SPI/.cproject b/testhal/STM32/STM32F7xx/SPI/.cproject deleted file mode 100644 index c4f2acccb..000000000 --- a/testhal/STM32/STM32F7xx/SPI/.cproject +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/testhal/STM32/STM32F7xx/SPI/.project b/testhal/STM32/STM32F7xx/SPI/.project deleted file mode 100644 index cae1b873b..000000000 --- a/testhal/STM32/STM32F7xx/SPI/.project +++ /dev/null @@ -1,95 +0,0 @@ - - - STM32F7xx-SPI - - - - - - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, - - - ?name? - - - - org.eclipse.cdt.make.core.append_environment - true - - - org.eclipse.cdt.make.core.autoBuildTarget - all - - - org.eclipse.cdt.make.core.buildArguments - -j1 - - - org.eclipse.cdt.make.core.buildCommand - make - - - org.eclipse.cdt.make.core.cleanBuildTarget - clean - - - org.eclipse.cdt.make.core.contents - org.eclipse.cdt.make.core.activeConfigSettings - - - org.eclipse.cdt.make.core.enableAutoBuild - false - - - org.eclipse.cdt.make.core.enableCleanBuild - true - - - org.eclipse.cdt.make.core.enableFullBuild - true - - - org.eclipse.cdt.make.core.fullBuildTarget - all - - - org.eclipse.cdt.make.core.stopOnError - true - - - org.eclipse.cdt.make.core.useDefaultBuildCmd - true - - - - - org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder - full,incremental, - - - - - - org.eclipse.cdt.core.cnature - org.eclipse.cdt.managedbuilder.core.managedBuildNature - org.eclipse.cdt.managedbuilder.core.ScannerConfigNature - - - - board - 2 - CHIBIOS/os/hal/boards/ST_STM32F746G_DISCOVERY - - - os - 2 - CHIBIOS/os - - - test - 2 - CHIBIOS/test - - - diff --git a/testhal/STM32/STM32F7xx/SPI/main.c b/testhal/STM32/STM32F7xx/SPI/main.c deleted file mode 100644 index 035e92f52..000000000 --- a/testhal/STM32/STM32F7xx/SPI/main.c +++ /dev/null @@ -1,187 +0,0 @@ -/* - ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -#include - -#include "ch.h" -#include "hal.h" - -/*===========================================================================*/ -/* SPI driver related. */ -/*===========================================================================*/ - -#define SPI_LOOPBACK - -/* - * Maximum speed SPI configuration (27MHz, CPHA=0, CPOL=0, MSb first). - */ -static const SPIConfig hs_spicfg = { - .circular = false, - .slave = false, - .data_cb = NULL, - .error_cb = NULL, - .ssport = GPIOB, - .sspad = GPIOB_ARD_D15, - .cr1 = SPI_CR1_CPOL | SPI_CR1_BR_0, - .cr2 = SPI_CR2_DS_2 | SPI_CR2_DS_1 | SPI_CR2_DS_0 -}; - -/* - * Low speed SPI configuration (421.875kHz, CPHA=0, CPOL=0, MSb first). - */ -static const SPIConfig ls_spicfg = { - .circular = false, - .slave = false, - .data_cb = NULL, - .error_cb = NULL, - .ssport = GPIOB, - .sspad = GPIOB_ARD_D14, - .cr1 = SPI_CR1_BR_2 | SPI_CR1_BR_1, - .cr2 = SPI_CR2_DS_2 | SPI_CR2_DS_1 | SPI_CR2_DS_0 -}; - -/* - * SPI TX and RX buffers. - * Note, the buffer are aligned to a 32 bytes boundary because limitations - * imposed by the data cache. Note, this is GNU specific, it must be - * handled differently for other compilers. - */ -#define SPI_BUFFERS_SIZE 128U - -static uint8_t txbuf[SPI_BUFFERS_SIZE]; -static uint8_t rxbuf[SPI_BUFFERS_SIZE]; - -/*===========================================================================*/ -/* Application code. */ -/*===========================================================================*/ - -/* - * SPI bus contender 1. - */ -static THD_WORKING_AREA(spi_thread_1_wa, 256); -static THD_FUNCTION(spi_thread_1, p) { - - (void)p; - chRegSetThreadName("SPI thread 1"); - while (true) { - unsigned i; - - /* Bush acquisition and SPI reprogramming.*/ - spiAcquireBus(&SPID2); - spiStart(&SPID2, &hs_spicfg); - - /* Preparing data buffer and flushing cache.*/ - for (i = 0; i < SPI_BUFFERS_SIZE; i++) - txbuf[i] = (uint8_t)i; - - /* Slave selection and data exchange.*/ - spiSelect(&SPID2); - spiExchange(&SPID2, SPI_BUFFERS_SIZE, txbuf, rxbuf); - spiUnselect(&SPID2); - -#if defined(SPI_LOOPBACK) - if (memcmp(txbuf, rxbuf, SPI_BUFFERS_SIZE) != 0) - chSysHalt("loopback failure"); -#endif - - /* Releasing the bus.*/ - spiReleaseBus(&SPID2); - } -} - -/* - * SPI bus contender 2. - */ -static THD_WORKING_AREA(spi_thread_2_wa, 256); -static THD_FUNCTION(spi_thread_2, p) { - - (void)p; - chRegSetThreadName("SPI thread 2"); - while (true) { - unsigned i; - - /* Bush acquisition and SPI reprogramming.*/ - spiAcquireBus(&SPID2); - spiStart(&SPID2, &ls_spicfg); - - /* Preparing data buffer and flushing cache.*/ - for (i = 0; i < SPI_BUFFERS_SIZE; i++) - txbuf[i] = (uint8_t)(128U + i); - - /* Slave selection and data exchange.*/ - spiSelect(&SPID2); - spiExchange(&SPID2, SPI_BUFFERS_SIZE, txbuf, rxbuf); - spiUnselect(&SPID2); - -#if defined(SPI_LOOPBACK) - if (memcmp(txbuf, rxbuf, SPI_BUFFERS_SIZE) != 0) - chSysHalt("loopback failure"); -#endif - - /* Releasing the bus.*/ - spiReleaseBus(&SPID2); - } -} - -/* - * Application entry point. - */ -int main(void) { - - /* - * System initializations. - * - HAL initialization, this also initializes the configured device drivers - * and performs the board-specific initializations. - * - Kernel initialization, the main() function becomes a thread and the - * RTOS is active. - */ - halInit(); - chSysInit(); - - /* - * SPI2 I/O pins setup. - */ - palSetLineMode(LINE_ARD_D13, - PAL_MODE_ALTERNATE(5) | - PAL_STM32_OSPEED_HIGHEST); /* SPI SCK. */ - palSetLineMode(LINE_ARD_D12, - PAL_MODE_ALTERNATE(5) | - PAL_STM32_OSPEED_HIGHEST); /* MISO. */ - palSetLineMode(LINE_ARD_D11, - PAL_MODE_ALTERNATE(5) | - PAL_STM32_OSPEED_HIGHEST); /* MOSI. */ - palSetLine(LINE_ARD_D15); - palSetLineMode(LINE_ARD_D15, - PAL_MODE_OUTPUT_PUSHPULL); /* CS0. */ - palSetLine(LINE_ARD_D14); - palSetLineMode(LINE_ARD_D14, - PAL_MODE_OUTPUT_PUSHPULL); /* CS1. */ - - /* - * Starting the transmitter and receiver threads. - */ - chThdCreateStatic(spi_thread_1_wa, sizeof(spi_thread_1_wa), - NORMALPRIO + 1, spi_thread_1, NULL); - chThdCreateStatic(spi_thread_2_wa, sizeof(spi_thread_2_wa), - NORMALPRIO + 1, spi_thread_2, NULL); - - /* - * Normal main() thread activity, in this demo it does nothing. - */ - while (true) { - chThdSleepMilliseconds(500); - } -} diff --git a/testhal/STM32/STM32F7xx/SPI/readme.txt b/testhal/STM32/STM32F7xx/SPI/readme.txt deleted file mode 100644 index 3b24d2ec3..000000000 --- a/testhal/STM32/STM32F7xx/SPI/readme.txt +++ /dev/null @@ -1,25 +0,0 @@ -***************************************************************************** -** ChibiOS/RT port for ARM-Cortex-M7 STM32F746G. ** -***************************************************************************** - -** TARGET ** - -The demo runs on an ST STM32F746G-Discovery board. - -** The Demo ** - - -** Build Procedure ** - -The demo has been tested by using the free Codesourcery GCC-based toolchain -and YAGARTO. just modify the TRGT line in the makefile in order to use -different GCC toolchains. - -** Notes ** - -Some files used by the demo are not part of ChibiOS/RT but are copyright of -ST Microelectronics and are licensed under a different license. -Also note that not all the files present in the ST library are distributed -with ChibiOS/RT, you can find the whole library on the ST web site: - - http://www.st.com diff --git a/testhal/STM32/multi/SPI/.cproject b/testhal/STM32/multi/SPI/.cproject index 8a4d8531b..2cfaf18c0 100644 --- a/testhal/STM32/multi/SPI/.cproject +++ b/testhal/STM32/multi/SPI/.cproject @@ -375,6 +375,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -412,6 +446,7 @@ + diff --git a/testhal/STM32/multi/SPI/Makefile b/testhal/STM32/multi/SPI/Makefile index 761f7109a..207a520b1 100644 --- a/testhal/STM32/multi/SPI/Makefile +++ b/testhal/STM32/multi/SPI/Makefile @@ -12,10 +12,17 @@ all: +@make --no-print-directory -f ./make/stm32f303_discovery.make all @echo ==================================================================== @echo + @echo === Building for STM32373C-Ecal ==================================== + +@make --no-print-directory -f ./make/stm32f373vc_eval.make all + @echo ==================================================================== + @echo @echo === Building for STM32F407-Discovery =============================== +@make --no-print-directory -f ./make/stm32f407_discovery.make all @echo ==================================================================== @echo + @echo === Building for STM32F746NG-Discovery ============================= + +@make --no-print-directory -f ./make/stm32f746ng_discovery.make all + @echo ==================================================================== @echo @echo === Building for STM32G474RE-Nucleo64 ============================== +@make --no-print-directory -f ./make/stm32g474re_nucleo64.make all @@ -48,8 +55,12 @@ clean: @echo +@make --no-print-directory -f ./make/stm32f303_discovery.make clean @echo + +@make --no-print-directory -f ./make/stm32f373vc_eval.make clean + @echo +@make --no-print-directory -f ./make/stm32f407_discovery.make clean @echo + +@make --no-print-directory -f ./make/stm32f746ng_discovery.make clean + @echo +@make --no-print-directory -f ./make/stm32g474re_nucleo64.make clean @echo +@make --no-print-directory -f ./make/stm32h743_nucleo144.make clean diff --git a/testhal/STM32/multi/SPI/cfg/stm32f303_discovery/portab.h b/testhal/STM32/multi/SPI/cfg/stm32f303_discovery/portab.h index a8c20e725..cbc0e85e0 100644 --- a/testhal/STM32/multi/SPI/cfg/stm32f303_discovery/portab.h +++ b/testhal/STM32/multi/SPI/cfg/stm32f303_discovery/portab.h @@ -37,7 +37,7 @@ #define PORTAB_LINE_BUTTON LINE_BUTTON #define PORTAB_BUTTON_PRESSED PAL_HIGH -#define PORTAB_SPI1 SPID1 +#define PORTAB_SPI1 SPID2 /*===========================================================================*/ /* Module pre-compile time settings. */ diff --git a/testhal/STM32/multi/SPI/cfg/stm32f373vc_eval/portab.h b/testhal/STM32/multi/SPI/cfg/stm32f373vc_eval/portab.h index 356eaea04..bbbe9af18 100644 --- a/testhal/STM32/multi/SPI/cfg/stm32f373vc_eval/portab.h +++ b/testhal/STM32/multi/SPI/cfg/stm32f373vc_eval/portab.h @@ -37,7 +37,7 @@ #define PORTAB_LINE_BUTTON LINE_WKUP_BUTTON #define PORTAB_BUTTON_PRESSED PAL_HIGH -#define PORTAB_SPI1 SPID1 +#define PORTAB_SPI1 SPID2 /*===========================================================================*/ /* Module pre-compile time settings. */ diff --git a/testhal/STM32/STM32F7xx/SPI/chconf.h b/testhal/STM32/multi/SPI/cfg/stm32f746ng_discovery/chconf.h similarity index 100% rename from testhal/STM32/STM32F7xx/SPI/chconf.h rename to testhal/STM32/multi/SPI/cfg/stm32f746ng_discovery/chconf.h diff --git a/testhal/STM32/STM32F7xx/SPI/halconf.h b/testhal/STM32/multi/SPI/cfg/stm32f746ng_discovery/halconf.h similarity index 100% rename from testhal/STM32/STM32F7xx/SPI/halconf.h rename to testhal/STM32/multi/SPI/cfg/stm32f746ng_discovery/halconf.h diff --git a/testhal/STM32/STM32F7xx/SPI/mcuconf.h b/testhal/STM32/multi/SPI/cfg/stm32f746ng_discovery/mcuconf.h similarity index 100% rename from testhal/STM32/STM32F7xx/SPI/mcuconf.h rename to testhal/STM32/multi/SPI/cfg/stm32f746ng_discovery/mcuconf.h diff --git a/testhal/STM32/multi/SPI/cfg/stm32f746ng_discovery/portab.c b/testhal/STM32/multi/SPI/cfg/stm32f746ng_discovery/portab.c new file mode 100644 index 000000000..f997f5bb8 --- /dev/null +++ b/testhal/STM32/multi/SPI/cfg/stm32f746ng_discovery/portab.c @@ -0,0 +1,119 @@ +/* + ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +/** + * @file portab.c + * @brief Application portability module code. + * + * @addtogroup application_portability + * @{ + */ + +#include "hal.h" +#include "portab.h" + +/*===========================================================================*/ +/* Module local definitions. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Module exported variables. */ +/*===========================================================================*/ + +void spi_circular_cb(SPIDriver *spip); +void spi_error_cb(SPIDriver *spip); + +/* + * Circular SPI configuration (27MHz, CPHA=0, CPOL=0, MSb first). + */ +const SPIConfig c_spicfg = { + .circular = true, + .slave = false, + .data_cb = spi_circular_cb, + .error_cb = spi_error_cb, + .ssport = GPIOB, + .sspad = GPIOB_ARD_D15, + .cr1 = SPI_CR1_CPOL | SPI_CR1_BR_0, + .cr2 = SPI_CR2_DS_2 | SPI_CR2_DS_1 | SPI_CR2_DS_0 +}; + +/* + * Maximum speed SPI configuration (27MHz, CPHA=0, CPOL=0, MSb first). + */ +const SPIConfig hs_spicfg = { + .circular = false, + .slave = false, + .data_cb = NULL, + .error_cb = spi_error_cb, + .ssport = GPIOB, + .sspad = GPIOB_ARD_D15, + .cr1 = SPI_CR1_CPOL | SPI_CR1_BR_0, + .cr2 = SPI_CR2_DS_2 | SPI_CR2_DS_1 | SPI_CR2_DS_0 +}; + +/* + * Low speed SPI configuration (421.875kHz, CPHA=0, CPOL=0, MSb first). + */ +const SPIConfig ls_spicfg = { + .circular = false, + .slave = false, + .data_cb = NULL, + .error_cb = spi_error_cb, + .ssport = GPIOB, + .sspad = GPIOB_ARD_D14, + .cr1 = SPI_CR1_BR_2 | SPI_CR1_BR_1, + .cr2 = SPI_CR2_DS_2 | SPI_CR2_DS_1 | SPI_CR2_DS_0 +}; + +/*===========================================================================*/ +/* Module local types. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Module local variables. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Module local functions. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Module exported functions. */ +/*===========================================================================*/ + +void portab_setup(void) { + + /* + * SPI2 I/O pins setup. + */ + palSetLineMode(LINE_ARD_D13, + PAL_MODE_ALTERNATE(5) | + PAL_STM32_OSPEED_HIGHEST); /* SPI2 SCK. */ + palSetLineMode(LINE_ARD_D12, + PAL_MODE_ALTERNATE(5) | + PAL_STM32_OSPEED_HIGHEST); /* SPI2 MISO. */ + palSetLineMode(LINE_ARD_D11, + PAL_MODE_ALTERNATE(5) | + PAL_STM32_OSPEED_HIGHEST); /* SPI2 MOSI. */ + palSetLine(LINE_ARD_D15); + palSetLineMode(LINE_ARD_D15, + PAL_MODE_OUTPUT_PUSHPULL); /* SPI2 CS0. */ + palSetLine(LINE_ARD_D14); + palSetLineMode(LINE_ARD_D14, + PAL_MODE_OUTPUT_PUSHPULL); /* SPI2 CS1. */ +} + +/** @} */ diff --git a/testhal/STM32/multi/SPI/cfg/stm32f746ng_discovery/portab.h b/testhal/STM32/multi/SPI/cfg/stm32f746ng_discovery/portab.h new file mode 100644 index 000000000..c19c44330 --- /dev/null +++ b/testhal/STM32/multi/SPI/cfg/stm32f746ng_discovery/portab.h @@ -0,0 +1,80 @@ +/* + ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +/** + * @file portab.h + * @brief Application portability macros and structures. + * + * @addtogroup application_portability + * @{ + */ + +#ifndef PORTAB_H +#define PORTAB_H + +/*===========================================================================*/ +/* Module constants. */ +/*===========================================================================*/ + +//#define PORTAB_LINE_LED1 LINE_LED1 +//#define PORTAB_LINE_LED2 LINE_LED2 +//#define PORTAB_LED_OFF PAL_LOW +//#define PORTAB_LED_ON PAL_HIGH + +#define PORTAB_LINE_BUTTON LINE_BUTTON_USER +#define PORTAB_BUTTON_PRESSED PAL_HIGH + +#define PORTAB_SPI1 SPID2 + +/*===========================================================================*/ +/* Module pre-compile time settings. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Derived constants and error checks. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Module data structures and types. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Module macros. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* External declarations. */ +/*===========================================================================*/ + +extern const SPIConfig c_spicfg; +extern const SPIConfig hs_spicfg; +extern const SPIConfig ls_spicfg; + +#ifdef __cplusplus +extern "C" { +#endif + void portab_setup(void); +#ifdef __cplusplus +} +#endif + +/*===========================================================================*/ +/* Module inline functions. */ +/*===========================================================================*/ + +#endif /* PORTAB_H */ + +/** @} */ diff --git a/testhal/STM32/multi/SPI/main.c b/testhal/STM32/multi/SPI/main.c index 196eff0c2..aae56c68f 100755 --- a/testhal/STM32/multi/SPI/main.c +++ b/testhal/STM32/multi/SPI/main.c @@ -42,11 +42,15 @@ void spi_circular_cb(SPIDriver *spip) { if (spiIsBufferComplete(spip)) { /* 2nd half.*/ +#if defined(PORTAB_LINE_LED1) palWriteLine(PORTAB_LINE_LED1, PORTAB_LED_OFF); +#endif } else { /* 1st half.*/ +#if defined(PORTAB_LINE_LED1) palWriteLine(PORTAB_LINE_LED1, PORTAB_LED_ON); +#endif } } #endif @@ -71,7 +75,9 @@ static THD_FUNCTION(spi_thread_1, p) { chRegSetThreadName("SPI thread 1"); while (true) { spiAcquireBus(&PORTAB_SPI1); /* Acquire ownership of the bus. */ +#if defined(PORTAB_LINE_LED1) palWriteLine(PORTAB_LINE_LED1, PORTAB_LED_ON); +#endif spiStart(&PORTAB_SPI1, &hs_spicfg); /* Setup transfer parameters. */ spiSelect(&PORTAB_SPI1); /* Slave Select assertion. */ spiExchange(&PORTAB_SPI1, 512, @@ -99,7 +105,9 @@ static THD_FUNCTION(spi_thread_2, p) { chRegSetThreadName("SPI thread 2"); while (true) { spiAcquireBus(&PORTAB_SPI1); /* Acquire ownership of the bus. */ +#if defined(PORTAB_LINE_LED1) palWriteLine(PORTAB_LINE_LED1, PORTAB_LED_OFF); +#endif spiStart(&PORTAB_SPI1, &ls_spicfg); /* Setup transfer parameters. */ spiSelect(&PORTAB_SPI1); /* Slave Select assertion. */ spiExchange(&PORTAB_SPI1, 512, @@ -186,7 +194,9 @@ int main(void) { spiStopTransfer(&PORTAB_SPI2, &size); /* Toggle the LED, wait a little bit and repeat.*/ +#if defined(PORTAB_LINE_LED1) palToggleLine(PORTAB_LINE_LED1); +#endif chThdSleepMilliseconds(100); } while (palReadLine(PORTAB_LINE_BUTTON) != PORTAB_BUTTON_PRESSED); diff --git a/testhal/STM32/STM32F7xx/SPI/Makefile b/testhal/STM32/multi/SPI/make/stm32f746ng_discovery.make similarity index 62% rename from testhal/STM32/STM32F7xx/SPI/Makefile rename to testhal/STM32/multi/SPI/make/stm32f746ng_discovery.make index 0ad4ca07e..8a04e9890 100644 --- a/testhal/STM32/STM32F7xx/SPI/Makefile +++ b/testhal/STM32/multi/SPI/make/stm32f746ng_discovery.make @@ -18,7 +18,7 @@ ifeq ($(USE_CPPOPT),) USE_CPPOPT = -fno-rtti endif -# Enable this if you want the linker to remove unused code and data +# Enable this if you want the linker to remove unused code and data. ifeq ($(USE_LINK_GC),) USE_LINK_GC = yes endif @@ -28,16 +28,11 @@ ifeq ($(USE_LDOPT),) USE_LDOPT = endif -# Enable this if you want link time optimizations (LTO) +# Enable this if you want link time optimizations (LTO). ifeq ($(USE_LTO),) USE_LTO = yes endif -# If enabled, this option allows to compile the application in THUMB mode. -ifeq ($(USE_THUMB),) - USE_THUMB = yes -endif - # Enable this if you want to see the full log while compiling. ifeq ($(USE_VERBOSE_COMPILE),) USE_VERBOSE_COMPILE = no @@ -76,7 +71,7 @@ endif # FPU-related options. ifeq ($(USE_FPU_OPT),) - USE_FPU_OPT = -mfloat-abi=$(USE_FPU) -mfpu=fpv5-sp-d16 -fsingle-precision-constant + USE_FPU_OPT = -mfloat-abi=$(USE_FPU) -mfpu=fpv5-sp-d16 endif # @@ -84,14 +79,20 @@ endif ############################################################################## ############################################################################## -# Project, sources and paths +# Project, target, sources and paths # # Define project name here PROJECT = ch -# Imported source files and paths -CHIBIOS = ../../../.. +# Target settings. +MCU = cortex-m4 + +# Imported source files and paths. +CHIBIOS := ../../../.. +CONFDIR := ./cfg/stm32f746ng_discovery +BUILDDIR := ./build/stm32f746ng_discovery +DEPDIR := ./.dep/stm32f746ng_discovery # Licensing files. include $(CHIBIOS)/os/license/license.mk @@ -105,91 +106,44 @@ include $(CHIBIOS)/os/hal/osal/rt-nil/osal.mk # RTOS files (optional). include $(CHIBIOS)/os/rt/rt.mk include $(CHIBIOS)/os/common/ports/ARMv7-M/compilers/GCC/mk/port.mk +# Auto-build files in ./source recursively. +include $(CHIBIOS)/tools/mk/autobuild.mk # Other files (optional). #include $(CHIBIOS)/os/test/test.mk #include $(CHIBIOS)/test/rt/rt_test.mk #include $(CHIBIOS)/test/oslib/oslib_test.mk -# Define linker script file here +# Define linker script file here. LDSCRIPT= $(STARTUPLD)/STM32F746xG.ld # C sources that can be compiled in ARM or THUMB mode depending on the global # setting. CSRC = $(ALLCSRC) \ $(TESTSRC) \ + $(CONFDIR)/portab.c \ main.c # C++ sources that can be compiled in ARM or THUMB mode depending on the global # setting. CPPSRC = $(ALLCPPSRC) -# C sources to be compiled in ARM mode regardless of the global setting. -# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler -# option that results in lower performance and larger code size. -ACSRC = - -# C++ sources to be compiled in ARM mode regardless of the global setting. -# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler -# option that results in lower performance and larger code size. -ACPPSRC = - -# C sources to be compiled in THUMB mode regardless of the global setting. -# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler -# option that results in lower performance and larger code size. -TCSRC = - -# C sources to be compiled in THUMB mode regardless of the global setting. -# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler -# option that results in lower performance and larger code size. -TCPPSRC = - -# List ASM source files here +# List ASM source files here. ASMSRC = $(ALLASMSRC) + +# List ASM with preprocessor source files here. ASMXSRC = $(ALLXASMSRC) -INCDIR = $(ALLINC) $(TESTINC) +# Inclusion directories. +INCDIR = $(CONFDIR) $(ALLINC) $(TESTINC) -# -# Project, sources and paths -############################################################################## - -############################################################################## -# Compiler settings -# - -MCU = cortex-m7 - -#TRGT = arm-elf- -TRGT = arm-none-eabi- -CC = $(TRGT)gcc -CPPC = $(TRGT)g++ -# Enable loading with g++ only if you need C++ runtime support. -# NOTE: You can use C++ even without C++ support if you are careful. C++ -# runtime support makes code size explode. -LD = $(TRGT)gcc -#LD = $(TRGT)g++ -CP = $(TRGT)objcopy -AS = $(TRGT)gcc -x assembler-with-cpp -AR = $(TRGT)ar -OD = $(TRGT)objdump -SZ = $(TRGT)size -HEX = $(CP) -O ihex -BIN = $(CP) -O binary - -# ARM-specific options here -AOPT = - -# THUMB-specific options here -TOPT = -mthumb -DTHUMB - -# Define C warning options here +# Define C warning options here. CWARN = -Wall -Wextra -Wundef -Wstrict-prototypes -# Define C++ warning options here +# Define C++ warning options here. CPPWARN = -Wall -Wextra -Wundef # -# Compiler settings +# Project, target, sources and paths ############################################################################## ############################################################################## @@ -212,8 +166,25 @@ ULIBDIR = ULIBS = # -# End of user defines +# End of user section ############################################################################## +############################################################################## +# Common rules +# + RULESPATH = $(CHIBIOS)/os/common/startup/ARMCMx/compilers/GCC/mk +include $(RULESPATH)/arm-none-eabi.mk include $(RULESPATH)/rules.mk + +# +# Common rules +############################################################################## + +############################################################################## +# Custom rules +# + +# +# Custom rules +##############################################################################