mirror of https://github.com/rusefi/ChibiOS.git
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
This commit is contained in:
parent
fd7994a06b
commit
3b9390e689
|
@ -1,50 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
|
||||
<storageModule moduleId="org.eclipse.cdt.core.settings">
|
||||
<cconfiguration id="0.114656749">
|
||||
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="0.114656749" moduleId="org.eclipse.cdt.core.settings" name="Default">
|
||||
<externalSettings/>
|
||||
<extensions>
|
||||
<extension id="org.eclipse.cdt.core.VCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
</extensions>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<configuration artifactName="${ProjName}" buildProperties="" description="" id="0.114656749" name="Default" parent="org.eclipse.cdt.build.core.prefbase.cfg">
|
||||
<folderInfo id="0.114656749." name="/" resourcePath="">
|
||||
<toolChain id="org.eclipse.cdt.build.core.prefbase.toolchain.1182750861" name="No ToolChain" resourceTypeBasedDiscovery="false" superClass="org.eclipse.cdt.build.core.prefbase.toolchain">
|
||||
<targetPlatform id="org.eclipse.cdt.build.core.prefbase.toolchain.1182750861.169007201" name=""/>
|
||||
<builder autoBuildTarget="all" cleanBuildTarget="clean" enableAutoBuild="false" enableCleanBuild="true" enabledIncrementalBuild="true" id="org.eclipse.cdt.build.core.settings.default.builder.579570726" incrementalBuildTarget="all" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" parallelBuildOn="true" parallelizationNumber="optimal" superClass="org.eclipse.cdt.build.core.settings.default.builder"/>
|
||||
<tool id="org.eclipse.cdt.build.core.settings.holder.libs.2143276802" name="holder for library settings" superClass="org.eclipse.cdt.build.core.settings.holder.libs"/>
|
||||
<tool id="org.eclipse.cdt.build.core.settings.holder.1873650595" name="Assembly" superClass="org.eclipse.cdt.build.core.settings.holder">
|
||||
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.1337802279" languageId="org.eclipse.cdt.core.assembly" languageName="Assembly" sourceContentType="org.eclipse.cdt.core.asmSource" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
|
||||
</tool>
|
||||
<tool id="org.eclipse.cdt.build.core.settings.holder.1707090075" name="GNU C++" superClass="org.eclipse.cdt.build.core.settings.holder">
|
||||
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.338985256" languageId="org.eclipse.cdt.core.g++" languageName="GNU C++" sourceContentType="org.eclipse.cdt.core.cxxSource,org.eclipse.cdt.core.cxxHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
|
||||
</tool>
|
||||
<tool id="org.eclipse.cdt.build.core.settings.holder.1165165914" name="GNU C" superClass="org.eclipse.cdt.build.core.settings.holder">
|
||||
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.714476670" languageId="org.eclipse.cdt.core.gcc" languageName="GNU C" sourceContentType="org.eclipse.cdt.core.cSource,org.eclipse.cdt.core.cHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
|
||||
</tool>
|
||||
</toolChain>
|
||||
</folderInfo>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
|
||||
</cconfiguration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<project id="STM32F7xx-SPI.null.1703860681" name="STM32F7xx-SPI"/>
|
||||
</storageModule>
|
||||
<storageModule moduleId="scannerConfiguration">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
||||
<scannerConfigBuildInfo instanceId="0.114656749">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile"/>
|
||||
</scannerConfigBuildInfo>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
|
||||
<storageModule moduleId="refreshScope"/>
|
||||
</cproject>
|
|
@ -1,95 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>STM32F7xx-SPI</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
|
||||
<triggers>clean,full,incremental,</triggers>
|
||||
<arguments>
|
||||
<dictionary>
|
||||
<key>?name?</key>
|
||||
<value></value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.append_environment</key>
|
||||
<value>true</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.autoBuildTarget</key>
|
||||
<value>all</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.buildArguments</key>
|
||||
<value>-j1</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.buildCommand</key>
|
||||
<value>make</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.cleanBuildTarget</key>
|
||||
<value>clean</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.contents</key>
|
||||
<value>org.eclipse.cdt.make.core.activeConfigSettings</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.enableAutoBuild</key>
|
||||
<value>false</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.enableCleanBuild</key>
|
||||
<value>true</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.enableFullBuild</key>
|
||||
<value>true</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.fullBuildTarget</key>
|
||||
<value>all</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.stopOnError</key>
|
||||
<value>true</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key>
|
||||
<value>true</value>
|
||||
</dictionary>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
|
||||
<triggers>full,incremental,</triggers>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.cdt.core.cnature</nature>
|
||||
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
|
||||
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
|
||||
</natures>
|
||||
<linkedResources>
|
||||
<link>
|
||||
<name>board</name>
|
||||
<type>2</type>
|
||||
<locationURI>CHIBIOS/os/hal/boards/ST_STM32F746G_DISCOVERY</locationURI>
|
||||
</link>
|
||||
<link>
|
||||
<name>os</name>
|
||||
<type>2</type>
|
||||
<locationURI>CHIBIOS/os</locationURI>
|
||||
</link>
|
||||
<link>
|
||||
<name>test</name>
|
||||
<type>2</type>
|
||||
<locationURI>CHIBIOS/test</locationURI>
|
||||
</link>
|
||||
</linkedResources>
|
||||
</projectDescription>
|
|
@ -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 <string.h>
|
||||
|
||||
#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);
|
||||
}
|
||||
}
|
|
@ -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
|
|
@ -375,6 +375,40 @@
|
|||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
|
||||
</cconfiguration>
|
||||
<cconfiguration id="0.1093754934.532782958.134374917.2006968796.1256936886">
|
||||
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="0.1093754934.532782958.134374917.2006968796.1256936886" moduleId="org.eclipse.cdt.core.settings" name="Build for STM32F746NG-Discovery">
|
||||
<externalSettings/>
|
||||
<extensions>
|
||||
<extension id="org.eclipse.cdt.core.VCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
</extensions>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<configuration artifactName="${ProjName}" buildProperties="" description="" id="0.1093754934.532782958.134374917.2006968796.1256936886" name="Build for STM32F746NG-Discovery" parent="org.eclipse.cdt.build.core.prefbase.cfg">
|
||||
<folderInfo id="0.1093754934.532782958.134374917.2006968796.1256936886." name="/" resourcePath="">
|
||||
<toolChain id="org.eclipse.cdt.build.core.prefbase.toolchain.913133518" name="No ToolChain" resourceTypeBasedDiscovery="false" superClass="org.eclipse.cdt.build.core.prefbase.toolchain">
|
||||
<targetPlatform id="org.eclipse.cdt.build.core.prefbase.toolchain.913133518.822358307" name=""/>
|
||||
<builder arguments="-f ./make/stm32f746ng_discovery.make" command="make" id="org.eclipse.cdt.build.core.settings.default.builder.1571551920" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" parallelBuildOn="true" parallelizationNumber="unlimited" superClass="org.eclipse.cdt.build.core.settings.default.builder"/>
|
||||
<tool id="org.eclipse.cdt.build.core.settings.holder.libs.337297930" name="holder for library settings" superClass="org.eclipse.cdt.build.core.settings.holder.libs"/>
|
||||
<tool id="org.eclipse.cdt.build.core.settings.holder.2123432124" name="Assembly" superClass="org.eclipse.cdt.build.core.settings.holder">
|
||||
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.1243097947" languageId="org.eclipse.cdt.core.assembly" languageName="Assembly" sourceContentType="org.eclipse.cdt.core.asmSource" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
|
||||
</tool>
|
||||
<tool id="org.eclipse.cdt.build.core.settings.holder.1630656856" name="GNU C++" superClass="org.eclipse.cdt.build.core.settings.holder">
|
||||
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.74367733" languageId="org.eclipse.cdt.core.g++" languageName="GNU C++" sourceContentType="org.eclipse.cdt.core.cxxSource,org.eclipse.cdt.core.cxxHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
|
||||
</tool>
|
||||
<tool id="org.eclipse.cdt.build.core.settings.holder.971725617" name="GNU C" superClass="org.eclipse.cdt.build.core.settings.holder">
|
||||
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.1065726784" languageId="org.eclipse.cdt.core.gcc" languageName="GNU C" sourceContentType="org.eclipse.cdt.core.cSource,org.eclipse.cdt.core.cHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
|
||||
</tool>
|
||||
</toolChain>
|
||||
</folderInfo>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
|
||||
</cconfiguration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<project id="STM32-SPI.null.932840044" name="STM32-SPI"/>
|
||||
|
@ -412,6 +446,7 @@
|
|||
<configuration configurationName="Build for STM32H743-Nucleo144">
|
||||
<resource resourceType="PROJECT" workspacePath="/STM32-SPI"/>
|
||||
</configuration>
|
||||
<configuration configurationName="Build for STM32373C-Eval"/>
|
||||
<configuration configurationName="Build for STM32L476-Discovery">
|
||||
<resource resourceType="PROJECT" workspacePath="/STM32-SPI"/>
|
||||
</configuration>
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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. */
|
||||
|
|
|
@ -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. */
|
||||
|
|
|
@ -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. */
|
||||
}
|
||||
|
||||
/** @} */
|
|
@ -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 */
|
||||
|
||||
/** @} */
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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
|
||||
##############################################################################
|
Loading…
Reference in New Issue