mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/cmake-demo.git
synced 2025-06-10 18:45:59 +00:00
Initial Commit
This commit is contained in:
commit
81a16b2acc
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
build/
|
||||||
|
.cache/
|
||||||
|
**/.DS_Store
|
15
.gitmodules
vendored
Normal file
15
.gitmodules
vendored
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
[submodule "libs/sta-core"]
|
||||||
|
path = libs/sta-core
|
||||||
|
url = ssh://git@git.intern.spaceteamaachen.de:22222/ALPAKA/sta-core.git
|
||||||
|
[submodule "libs/rtos2-utils"]
|
||||||
|
path = libs/rtos2-utils
|
||||||
|
url = ssh://git@git.intern.spaceteamaachen.de:22222/ALPAKA/rtos2-utils.git
|
||||||
|
[submodule "libs/TACOS"]
|
||||||
|
path = libs/TACOS
|
||||||
|
url = ssh://git@git.intern.spaceteamaachen.de:22222/ALPAKA/TACOS.git
|
||||||
|
[submodule "libs/STAHR-defs"]
|
||||||
|
path = libs/STAHR-defs
|
||||||
|
url = ssh://git@git.intern.spaceteamaachen.de:22222/STAHR/STAHR-defs.git
|
||||||
|
[submodule "libs/stm32-cmake"]
|
||||||
|
path = libs/stm32-cmake
|
||||||
|
url = https://github.com/ObKo/stm32-cmake.git
|
32
.project
Normal file
32
.project
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>Cmake-demo</name>
|
||||||
|
<comment></comment>
|
||||||
|
<projects>
|
||||||
|
</projects>
|
||||||
|
<buildSpec>
|
||||||
|
<buildCommand>
|
||||||
|
<name>com.st.stm32cube.ide.cmake.CmakeConfigureProjectBuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
|
||||||
|
<triggers>clean,full,incremental,</triggers>
|
||||||
|
<arguments>
|
||||||
|
</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>
|
||||||
|
<nature>com.st.stm32cube.ide.cmake.CmakeConfigProjectNature</nature>
|
||||||
|
</natures>
|
||||||
|
</projectDescription>
|
25
.settings/language.settings.xml
Normal file
25
.settings/language.settings.xml
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<project>
|
||||||
|
<configuration id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.debug.1601841492" name="Debug">
|
||||||
|
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
|
||||||
|
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
|
||||||
|
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
|
||||||
|
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
|
||||||
|
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="-768575732412150847" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true">
|
||||||
|
<language-scope id="org.eclipse.cdt.core.gcc"/>
|
||||||
|
<language-scope id="org.eclipse.cdt.core.g++"/>
|
||||||
|
</provider>
|
||||||
|
</extension>
|
||||||
|
</configuration>
|
||||||
|
<configuration id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.debug.524555750" name="Release">
|
||||||
|
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
|
||||||
|
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
|
||||||
|
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
|
||||||
|
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
|
||||||
|
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="-768575732412150847" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true">
|
||||||
|
<language-scope id="org.eclipse.cdt.core.gcc"/>
|
||||||
|
<language-scope id="org.eclipse.cdt.core.g++"/>
|
||||||
|
</provider>
|
||||||
|
</extension>
|
||||||
|
</configuration>
|
||||||
|
</project>
|
2
.settings/org.eclipse.core.resources.prefs
Normal file
2
.settings/org.eclipse.core.resources.prefs
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
eclipse.preferences.version=1
|
||||||
|
encoding/<project>=UTF-8
|
94
App/Inc/shared.hpp
Normal file
94
App/Inc/shared.hpp
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
#ifndef INC_SHARED_HPP_
|
||||||
|
#define INC_SHARED_HPP_
|
||||||
|
|
||||||
|
#include <cmsis_os2.h>
|
||||||
|
#include <states.hpp>
|
||||||
|
|
||||||
|
namespace rres
|
||||||
|
{
|
||||||
|
struct LoggingData
|
||||||
|
{
|
||||||
|
uint32_t hash;
|
||||||
|
uint32_t timestamp;
|
||||||
|
|
||||||
|
uint8_t state;
|
||||||
|
uint8_t sense_fire;
|
||||||
|
uint16_t sense_adc[6];
|
||||||
|
uint8_t fired;
|
||||||
|
};
|
||||||
|
|
||||||
|
enum Event
|
||||||
|
{
|
||||||
|
TICK_10HZ = 1 << 0,
|
||||||
|
TOCK_10HZ = 1 << 1,
|
||||||
|
START_LOGGING = 1 << 2,
|
||||||
|
DUMP_FLASH = 1 << 3,
|
||||||
|
CLEAR_FLASH = 1 << 4,
|
||||||
|
FLASH_EVENT = DUMP_FLASH | CLEAR_FLASH
|
||||||
|
};
|
||||||
|
|
||||||
|
void init();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Wait for any of the provided flags to be set.
|
||||||
|
*
|
||||||
|
* @note Example usage: waitForAny(GYRO | TICK_20HZ); to either wait for the 20Hz tick or new gyro data.
|
||||||
|
*
|
||||||
|
* @param event An integer with every bit representing a specific event.
|
||||||
|
* @param timeout An optional timeout for additional safety.
|
||||||
|
* @return uint32_t Returns the flags that were set.
|
||||||
|
*/
|
||||||
|
uint32_t waitForAny(uint32_t event, uint32_t timeout = osWaitForever);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Wait for all of the provided flags to be set.
|
||||||
|
*
|
||||||
|
* @note Example usage: waitForAny(GYRO | TICK_20HZ); to wait for both the 20Hz tick as well as new gyro data.
|
||||||
|
*
|
||||||
|
* @param event An integer with every bit representing a specific event.
|
||||||
|
* @param timeout An optional timeout for additional safety.
|
||||||
|
* @return uint32_t Returns the flags that were set.
|
||||||
|
*/
|
||||||
|
uint32_t waitForAll(uint32_t event, uint32_t timeout = osWaitForever);
|
||||||
|
|
||||||
|
LoggingData getData();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set the sensed fire bits.
|
||||||
|
*
|
||||||
|
* @param sense_fire The sensed fire bits.
|
||||||
|
*/
|
||||||
|
void setSenseFire(uint8_t sense_fire);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set Capacitor Voltages.
|
||||||
|
*
|
||||||
|
* @param sense_adc The sensed ADC values.
|
||||||
|
*/
|
||||||
|
void setSenseADC(uint16_t sense_adc[6]);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set fired event.
|
||||||
|
*
|
||||||
|
* @param fired The fired event.
|
||||||
|
*/
|
||||||
|
void setFired(uint8_t fired);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Start logging data to the flash memory.
|
||||||
|
*/
|
||||||
|
void startLogging();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Dump the flash memory to the console.
|
||||||
|
*/
|
||||||
|
void dumpFlash();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Clear the flash memory.
|
||||||
|
*/
|
||||||
|
void clearFlash();
|
||||||
|
|
||||||
|
} // namespace grsm
|
||||||
|
|
||||||
|
#endif /* INC_SHARED_HPP_ */
|
126
App/Inc/sta/config.hpp
Normal file
126
App/Inc/sta/config.hpp
Normal file
@ -0,0 +1,126 @@
|
|||||||
|
/*
|
||||||
|
* Configuration file for STA-Core.
|
||||||
|
*
|
||||||
|
* Created on: Aug 30, 2023
|
||||||
|
* Author: Dario
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef INC_STA_CONFIG_HPP_
|
||||||
|
#define INC_STA_CONFIG_HPP_
|
||||||
|
|
||||||
|
#define STA_STM32_ASEAG
|
||||||
|
#include <sta/devices/stm32/mcu/STM32F407xx.hpp>
|
||||||
|
|
||||||
|
// Doesn't really do too much right now. Has to be added for successful compilation.
|
||||||
|
#define STA_PRINTF_USE_STDLIB
|
||||||
|
|
||||||
|
#define STA_MCU_LITTLE_ENDIAN
|
||||||
|
#define STA_PLATFORM_STM32
|
||||||
|
|
||||||
|
// Enable debug serial output and assertions.
|
||||||
|
//#define STA_ASSERT_FORCE
|
||||||
|
#define STA_DEBUGGING_ENABLED
|
||||||
|
|
||||||
|
// Activate the timer for microsecond delays.
|
||||||
|
// #define STA_STM32_DELAY_ENABLE
|
||||||
|
// #define STA_STM32_DELAY_US_TIM htim1
|
||||||
|
|
||||||
|
// Settings for the rtos-utils
|
||||||
|
#define STA_RTOS_SYSTEM_EVENTS_ENABLE
|
||||||
|
// #define STA_RTOS_SYSTEM_WATCHDOG_ENABLE
|
||||||
|
#define STA_TACOS_CAN_BUS_ENABLED
|
||||||
|
#define STA_CAN_BUS_ENABLE
|
||||||
|
|
||||||
|
// Uses the default configuration for TACOS.
|
||||||
|
#include <sta/tacos/configs/default.hpp>
|
||||||
|
#include <states.hpp>
|
||||||
|
#include <can_ids.hpp>
|
||||||
|
#include <modules.hpp>
|
||||||
|
|
||||||
|
// Pin Definitions:
|
||||||
|
// Arming pins
|
||||||
|
// Hatch arming
|
||||||
|
#define ARMING_GROUPA GPIOE
|
||||||
|
#define ARMING_PIN_A GPIO_PIN_15
|
||||||
|
|
||||||
|
#define ARMING_GROUPB GPIOG
|
||||||
|
#define ARMING_PIN_B GPIO_PIN_0
|
||||||
|
|
||||||
|
// Main arming
|
||||||
|
#define ARMING_GROUPC GPIOA
|
||||||
|
#define ARMING_PIN_C GPIO_PIN_6
|
||||||
|
|
||||||
|
#define ARMING_GROUPD GPIOE
|
||||||
|
#define ARMING_PIN_D GPIO_PIN_0
|
||||||
|
|
||||||
|
// Main dereefing
|
||||||
|
#define ARMING_GROUPE GPIOB
|
||||||
|
#define ARMING_PIN_E GPIO_PIN_6
|
||||||
|
|
||||||
|
#define ARMING_GROUPF GPIOG
|
||||||
|
#define ARMING_PIN_F GPIO_PIN_11
|
||||||
|
|
||||||
|
// Shorting pins
|
||||||
|
// Hatch shorting
|
||||||
|
#define SHORTING_GROUPA GPIOE
|
||||||
|
#define SHORTING_PIN_A GPIO_PIN_13
|
||||||
|
|
||||||
|
#define SHORTING_GROUPB GPIOC
|
||||||
|
#define SHORTING_PIN_B GPIO_PIN_5
|
||||||
|
|
||||||
|
// Main shorting
|
||||||
|
#define SHORTING_GROUPC GPIOA
|
||||||
|
#define SHORTING_PIN_C GPIO_PIN_4
|
||||||
|
|
||||||
|
#define SHORTING_GROUPD GPIOB
|
||||||
|
#define SHORTING_PIN_D GPIO_PIN_8
|
||||||
|
|
||||||
|
// Main dereefing
|
||||||
|
#define SHORTING_GROUPE GPIOB
|
||||||
|
#define SHORTING_PIN_E GPIO_PIN_4
|
||||||
|
|
||||||
|
#define SHORTING_GROUPF GPIOG
|
||||||
|
#define SHORTING_PIN_F GPIO_PIN_9
|
||||||
|
|
||||||
|
// Fire pins
|
||||||
|
// Hatch fire
|
||||||
|
#define FIRE_DEREEFING_GROUP1 GPIOB
|
||||||
|
#define FIRE_DEREEFING_PIN_1 GPIO_PIN_10
|
||||||
|
|
||||||
|
#define FIRE_DEREEFING_GROUP2 GPIOE
|
||||||
|
#define FIRE_DEREEFING_PIN_2 GPIO_PIN_7
|
||||||
|
|
||||||
|
// Main fire
|
||||||
|
#define FIRE_MAIN_GROUP1 GPIOA
|
||||||
|
#define FIRE_MAIN_PIN_1 GPIO_PIN_7
|
||||||
|
|
||||||
|
#define FIRE_MAIN_GROUP2 GPIOE
|
||||||
|
#define FIRE_MAIN_PIN_2 GPIO_PIN_1
|
||||||
|
|
||||||
|
// Main dereefing
|
||||||
|
#define FIRE_HATCH_GROUP1 GPIOB
|
||||||
|
#define FIRE_HATCH_PIN_1 GPIO_PIN_7
|
||||||
|
|
||||||
|
#define FIRE_HATCH_GROUP2 GPIOG
|
||||||
|
#define FIRE_HATCH_PIN_2 GPIO_PIN_12
|
||||||
|
|
||||||
|
// Sense fire pins
|
||||||
|
#define SENSE_FIRE_GROUP1 GPIOE
|
||||||
|
#define SENSE_FIRE_PIN_1 GPIO_PIN_14
|
||||||
|
|
||||||
|
#define SENSE_FIRE_GROUP2 GPIOF
|
||||||
|
#define SENSE_FIRE_PIN_2 GPIO_PIN_15
|
||||||
|
|
||||||
|
#define SENSE_FIRE_GROUP3 GPIOA
|
||||||
|
#define SENSE_FIRE_PIN_3 GPIO_PIN_5
|
||||||
|
|
||||||
|
#define SENSE_FIRE_GROUP4 GPIOB
|
||||||
|
#define SENSE_FIRE_PIN_4 GPIO_PIN_9
|
||||||
|
|
||||||
|
#define SENSE_FIRE_GROUP5 GPIOB
|
||||||
|
#define SENSE_FIRE_PIN_5 GPIO_PIN_5
|
||||||
|
|
||||||
|
#define SENSE_FIRE_GROUP6 GPIOG
|
||||||
|
#define SENSE_FIRE_PIN_6 GPIO_PIN_10
|
||||||
|
|
||||||
|
#endif /* INC_STA_CONFIG_HPP_ */
|
26
App/Inc/tasks/arming.hpp
Normal file
26
App/Inc/tasks/arming.hpp
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
/*
|
||||||
|
* arming.hpp
|
||||||
|
*
|
||||||
|
* Created on: Jun 17, 2024
|
||||||
|
* Author: carlos
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef INC_TASKS_ARMING_HPP_
|
||||||
|
#define INC_TASKS_ARMING_HPP_
|
||||||
|
|
||||||
|
#include <sta/tacos.hpp>
|
||||||
|
|
||||||
|
namespace tasks
|
||||||
|
{
|
||||||
|
class ArmingTask : public sta::tacos::TacosThread
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ArmingTask();
|
||||||
|
|
||||||
|
void init() override;
|
||||||
|
|
||||||
|
void func() override;
|
||||||
|
};
|
||||||
|
} // namespace tasks
|
||||||
|
|
||||||
|
#endif /* INC_TASKS_ARMING_HPP_ */
|
27
App/Inc/tasks/fire.hpp
Normal file
27
App/Inc/tasks/fire.hpp
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
/*
|
||||||
|
* fire.hpp
|
||||||
|
*
|
||||||
|
* Created on: Jun 17, 2024
|
||||||
|
* Author: carlos
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef INC_TASKS_FIRE_HPP_
|
||||||
|
#define INC_TASKS_FIRE_HPP_
|
||||||
|
|
||||||
|
#include <sta/tacos.hpp>
|
||||||
|
#include <sta/devices/stm32/can.hpp>
|
||||||
|
|
||||||
|
namespace tasks
|
||||||
|
{
|
||||||
|
class FireTask : public sta::tacos::TacosThread
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
FireTask();
|
||||||
|
|
||||||
|
void init() override;
|
||||||
|
|
||||||
|
void func() override;
|
||||||
|
};
|
||||||
|
} // namespace tasks
|
||||||
|
|
||||||
|
#endif /* INC_TASKS_FIRE_HPP_ */
|
37
App/Inc/tasks/sense.hpp
Normal file
37
App/Inc/tasks/sense.hpp
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* sense.hpp
|
||||||
|
*
|
||||||
|
* Created on: Jun 17, 2024
|
||||||
|
* Author: carlos
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef INC_TASKS_SENSE_HPP_
|
||||||
|
#define INC_TASKS_SENSE_HPP_
|
||||||
|
|
||||||
|
#include <sta/tacos.hpp>
|
||||||
|
#include <sta/devices/stm32/adc.hpp>
|
||||||
|
#include <sta/devices/stm32/bus/spi.hpp>
|
||||||
|
|
||||||
|
namespace tasks
|
||||||
|
{
|
||||||
|
class SenseTask : public sta::tacos::TacosThread
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SenseTask(ADC_HandleTypeDef *handle);
|
||||||
|
|
||||||
|
void init() override;
|
||||||
|
|
||||||
|
void func() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
sta::STM32ADC adc_;
|
||||||
|
uint16_t dmaBuffer_[6];
|
||||||
|
size_t bufferSize_ = 6;
|
||||||
|
uint16_t result_[6];
|
||||||
|
|
||||||
|
CanSysMsg msg_;
|
||||||
|
uint16_t result_counter_ = 0;
|
||||||
|
};
|
||||||
|
} // namespace tasks
|
||||||
|
|
||||||
|
#endif /* INC_TASKS_SENSE_HPP_ */
|
164
App/Src/shared.cpp
Normal file
164
App/Src/shared.cpp
Normal file
@ -0,0 +1,164 @@
|
|||||||
|
/*
|
||||||
|
* shared.cpp
|
||||||
|
*
|
||||||
|
* Created on: Jun 17, 2024
|
||||||
|
* Author: Dario
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <shared.hpp>
|
||||||
|
#include <sta/tacos.hpp>
|
||||||
|
|
||||||
|
#include <sta/rtos/mutex.hpp>
|
||||||
|
#include <sta/rtos/event.hpp>
|
||||||
|
#include <sta/rtos/timer.hpp>
|
||||||
|
#include <sta/rtos/sharedmem.hpp>
|
||||||
|
|
||||||
|
#include <sta/time.hpp>
|
||||||
|
|
||||||
|
namespace rres
|
||||||
|
{
|
||||||
|
sta::RtosEvent *signal;
|
||||||
|
sta::RtosSharedMem<LoggingData> *memory;
|
||||||
|
sta::RtosTimer *sync_10Hz;
|
||||||
|
|
||||||
|
bool _10Hz_tick = true;
|
||||||
|
|
||||||
|
void init()
|
||||||
|
{
|
||||||
|
signal = new sta::RtosEvent();
|
||||||
|
memory = new sta::RtosSharedMem<LoggingData>(100);
|
||||||
|
|
||||||
|
sync_10Hz = new sta::RtosTimer([](void *)
|
||||||
|
{
|
||||||
|
if (_10Hz_tick)
|
||||||
|
{
|
||||||
|
signal->set(TICK_10HZ);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
signal->set(TOCK_10HZ);
|
||||||
|
}
|
||||||
|
|
||||||
|
_10Hz_tick = !_10Hz_tick; }, NULL, true);
|
||||||
|
sync_10Hz->start(50);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t waitForAny(uint32_t dataTypes, uint32_t timeout /* = osWaitForever */)
|
||||||
|
{
|
||||||
|
uint32_t flags = signal->wait(dataTypes, timeout);
|
||||||
|
signal->clear(dataTypes);
|
||||||
|
|
||||||
|
return flags;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t waitForAll(uint32_t dataTypes, uint32_t timeout /* = osWaitForever */)
|
||||||
|
{
|
||||||
|
uint32_t received = 0x00;
|
||||||
|
uint32_t startTime = sta::timeMs();
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
// Wait for the remaining flags and set the remaining time as the timeout.
|
||||||
|
received |= waitForAny(dataTypes & ~received, timeout - (sta::timeMs() - startTime));
|
||||||
|
} while (received != dataTypes && sta::timeMs() - startTime < timeout);
|
||||||
|
|
||||||
|
signal->clear(received);
|
||||||
|
|
||||||
|
return received;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setSenseFire(uint8_t sense_fire)
|
||||||
|
{
|
||||||
|
LoggingData data = memory->read();
|
||||||
|
data.sense_fire = sense_fire;
|
||||||
|
memory->write(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setSenseADC(uint16_t sense_adc[6])
|
||||||
|
{
|
||||||
|
LoggingData data = memory->read();
|
||||||
|
for (int i = 0; i < 6; i++)
|
||||||
|
{
|
||||||
|
data.sense_adc[i] = sense_adc[i];
|
||||||
|
}
|
||||||
|
memory->write(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setFired(uint8_t fired)
|
||||||
|
{
|
||||||
|
LoggingData data = memory->read();
|
||||||
|
data.fired = fired;
|
||||||
|
memory->write(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
LoggingData getData()
|
||||||
|
{
|
||||||
|
return memory->read();
|
||||||
|
}
|
||||||
|
|
||||||
|
void startLogging()
|
||||||
|
{
|
||||||
|
signal->set(START_LOGGING);
|
||||||
|
}
|
||||||
|
|
||||||
|
void dumpFlash()
|
||||||
|
{
|
||||||
|
signal->set(DUMP_FLASH);
|
||||||
|
}
|
||||||
|
|
||||||
|
void clearFlash()
|
||||||
|
{
|
||||||
|
signal->set(CLEAR_FLASH);
|
||||||
|
}
|
||||||
|
} // namespace rres
|
||||||
|
|
||||||
|
#ifdef STA_TACOS_CAN_BUS_ENABLED
|
||||||
|
namespace sta
|
||||||
|
{
|
||||||
|
namespace tacos
|
||||||
|
{
|
||||||
|
bool handleSysMessage(CanMsgHeader &header, uint8_t *payload)
|
||||||
|
{
|
||||||
|
// STA_DEBUG_PRINTF("> CAN ID recved: %d", header.sid);
|
||||||
|
switch (header.sid)
|
||||||
|
{
|
||||||
|
// State transition message
|
||||||
|
case STA_TACOS_CAN_BUS_SYS_MSG_ID:
|
||||||
|
// First byte of payload is the origin state, second byte is the destination state
|
||||||
|
tacos::forceState(payload[0], payload[1], 0, true);
|
||||||
|
|
||||||
|
// Send confirmation message
|
||||||
|
CanSysMsg msg;
|
||||||
|
msg.header.payloadLength = 2;
|
||||||
|
msg.header.sid = MODULE_STATE_CONFIRM_CAN_ID;
|
||||||
|
msg.header.eid = 0;
|
||||||
|
msg.header.format = 0;
|
||||||
|
msg.payload[0] = MODULE_RRES;
|
||||||
|
msg.payload[1] = payload[1];
|
||||||
|
|
||||||
|
tacos::queueCanBusMsg(msg, 0);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
case MODULE_SW_RESET_CAN_ID:
|
||||||
|
if (payload[0] == MODULE_RRES)
|
||||||
|
{
|
||||||
|
HAL_NVIC_SystemReset();
|
||||||
|
}
|
||||||
|
return true; // Least useless return statement ever
|
||||||
|
|
||||||
|
// Flash Operations
|
||||||
|
case FLASH_OPERATIONS_CAN_ID:
|
||||||
|
if (payload[0] == 0x01)
|
||||||
|
rres::clearFlash();
|
||||||
|
else if (payload[0] == 0x02)
|
||||||
|
rres::dumpFlash();
|
||||||
|
return true;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif // STA_TACOS_CAN_BUS_ENABLED‚
|
42
App/Src/startup.cpp
Normal file
42
App/Src/startup.cpp
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
/*
|
||||||
|
* printable.cpp
|
||||||
|
*
|
||||||
|
* Created on: Aug 30, 2023
|
||||||
|
* Author: Dario
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sta/debug/debug.hpp>
|
||||||
|
#include <shared.hpp>
|
||||||
|
#include <tasks/sense.hpp>
|
||||||
|
#include <tasks/arming.hpp>
|
||||||
|
#include <tasks/fire.hpp>
|
||||||
|
|
||||||
|
#include <sta/rtos/debug/heap_stats.hpp>
|
||||||
|
#include <sta/devices/stm32/bus/spi.hpp>
|
||||||
|
#include <states.hpp>
|
||||||
|
|
||||||
|
#include <sta/tacos.hpp>
|
||||||
|
#include <memory>
|
||||||
|
#include <spi.h>
|
||||||
|
#include <adc.h>
|
||||||
|
|
||||||
|
namespace sta
|
||||||
|
{
|
||||||
|
namespace tacos
|
||||||
|
{
|
||||||
|
void onStatemachineInit()
|
||||||
|
{
|
||||||
|
rres::init();
|
||||||
|
|
||||||
|
sta::tacos::addThread<tasks::SenseTask>(ALL_STATES, &hadc1);
|
||||||
|
sta::tacos::addThread<tasks::ArmingTask>({stahr::ARMED});
|
||||||
|
sta::tacos::addThread<tasks::FireTask>({stahr::DROGUE, stahr::MAIN, stahr::DISREEFING});
|
||||||
|
|
||||||
|
tacos::forceState(tacos::getState(), stahr::READY_ON_PAD);
|
||||||
|
|
||||||
|
STA_DEBUG_PRINTF("The answer to everything is %d", 42);
|
||||||
|
|
||||||
|
// STA_DEBUG_HEAP_STATS();
|
||||||
|
}
|
||||||
|
} // namespace tacos
|
||||||
|
} // namespace sta
|
65
App/Src/tasks/arming.cpp
Normal file
65
App/Src/tasks/arming.cpp
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
/*
|
||||||
|
* arming.cpp
|
||||||
|
*
|
||||||
|
* Created on: Jun 17, 2024
|
||||||
|
* Author: carlos
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <tasks/arming.hpp>
|
||||||
|
#include <sta/debug/debug.hpp>
|
||||||
|
#include "can.h"
|
||||||
|
#include <sta/tacos.hpp>
|
||||||
|
|
||||||
|
#include <cmsis_os2.h>
|
||||||
|
|
||||||
|
namespace tasks
|
||||||
|
{
|
||||||
|
ArmingTask::ArmingTask() : TacosThread("ARMING", osPriorityHigh)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void ArmingTask::init()
|
||||||
|
{
|
||||||
|
// Stop shorting the igniters (NC so they are always shorted until high signal is sent)
|
||||||
|
HAL_GPIO_WritePin(SHORTING_GROUPA, SHORTING_PIN_A, GPIO_PIN_SET);
|
||||||
|
HAL_GPIO_WritePin(SHORTING_GROUPB, SHORTING_PIN_B, GPIO_PIN_SET);
|
||||||
|
HAL_GPIO_WritePin(SHORTING_GROUPC, SHORTING_PIN_C, GPIO_PIN_SET);
|
||||||
|
HAL_GPIO_WritePin(SHORTING_GROUPD, SHORTING_PIN_D, GPIO_PIN_SET);
|
||||||
|
HAL_GPIO_WritePin(SHORTING_GROUPE, SHORTING_PIN_E, GPIO_PIN_SET);
|
||||||
|
HAL_GPIO_WritePin(SHORTING_GROUPF, SHORTING_PIN_F, GPIO_PIN_SET);
|
||||||
|
|
||||||
|
this->sleep(500); // 500ms delay
|
||||||
|
|
||||||
|
// Arming the igniters
|
||||||
|
HAL_GPIO_WritePin(ARMING_GROUPA, ARMING_PIN_A, GPIO_PIN_SET);
|
||||||
|
HAL_GPIO_WritePin(ARMING_GROUPB, ARMING_PIN_B, GPIO_PIN_SET);
|
||||||
|
HAL_GPIO_WritePin(ARMING_GROUPC, ARMING_PIN_C, GPIO_PIN_SET);
|
||||||
|
HAL_GPIO_WritePin(ARMING_GROUPD, ARMING_PIN_D, GPIO_PIN_SET);
|
||||||
|
HAL_GPIO_WritePin(ARMING_GROUPE, ARMING_PIN_E, GPIO_PIN_SET);
|
||||||
|
HAL_GPIO_WritePin(ARMING_GROUPF, ARMING_PIN_F, GPIO_PIN_SET);
|
||||||
|
|
||||||
|
#ifdef STA_TACOS_CAN_BUS_ENABLED
|
||||||
|
CanSysMsg msg;
|
||||||
|
|
||||||
|
msg.payload[0] = 1; // Send 1 to indicate that the igniters are armed
|
||||||
|
|
||||||
|
msg.header.payloadLength = 1;
|
||||||
|
msg.header.sid = ARMING_CAN_ID;
|
||||||
|
msg.header.eid = 0;
|
||||||
|
msg.header.format = 0;
|
||||||
|
|
||||||
|
sta::tacos::queueCanBusMsg(msg, 0);
|
||||||
|
#endif // STA_TACOS_CAN_BUS_ENABLED
|
||||||
|
|
||||||
|
// Terminate the thread until next state
|
||||||
|
#ifdef STA_TACOS_WATCHDOG_ENABLED
|
||||||
|
this->watchdogIgnore();
|
||||||
|
#endif // STA_TACOS_WATCHDOG_ENABLED
|
||||||
|
}
|
||||||
|
|
||||||
|
void ArmingTask::func()
|
||||||
|
{
|
||||||
|
sleep(osWaitForever);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace tasks
|
131
App/Src/tasks/fire.cpp
Normal file
131
App/Src/tasks/fire.cpp
Normal file
@ -0,0 +1,131 @@
|
|||||||
|
/*
|
||||||
|
* fire.cpp
|
||||||
|
*
|
||||||
|
* Created on: Jun 17, 2024
|
||||||
|
* Author: carlos
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <tasks/fire.hpp>
|
||||||
|
#include <sta/debug/debug.hpp>
|
||||||
|
#include "can.h"
|
||||||
|
#include <sta/tacos.hpp>
|
||||||
|
#include <sta/config.hpp>
|
||||||
|
#include <shared.hpp>
|
||||||
|
|
||||||
|
#include <cmsis_os2.h>
|
||||||
|
|
||||||
|
namespace tasks
|
||||||
|
{
|
||||||
|
FireTask::FireTask() : TacosThread("IGNITOR_FIRE", osPriorityHigh)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void FireTask::init()
|
||||||
|
{
|
||||||
|
rres::setFired(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FireTask::func()
|
||||||
|
{
|
||||||
|
|
||||||
|
// Firing the igniters
|
||||||
|
|
||||||
|
CanSysMsg msg;
|
||||||
|
|
||||||
|
msg.header.sid = FIRE_CAN_ID;
|
||||||
|
msg.header.eid = 0;
|
||||||
|
msg.header.format = 0;
|
||||||
|
msg.header.payloadLength = 1;
|
||||||
|
|
||||||
|
if (sta::tacos::getState() == stahr::DROGUE)
|
||||||
|
{
|
||||||
|
// Fire
|
||||||
|
HAL_GPIO_WritePin(FIRE_HATCH_GROUP1, FIRE_HATCH_PIN_1, GPIO_PIN_SET);
|
||||||
|
HAL_GPIO_WritePin(FIRE_HATCH_GROUP2, FIRE_HATCH_PIN_2, GPIO_PIN_SET);
|
||||||
|
|
||||||
|
// Send out fire information
|
||||||
|
msg.payload[0] = 1; // Event 1 = HATCH fired / drogue deployed
|
||||||
|
sta::tacos::queueCanBusMsg(msg, 0);
|
||||||
|
|
||||||
|
rres::setFired(1);
|
||||||
|
|
||||||
|
// Only leave on for a second to avoid shorting via the igniter
|
||||||
|
this->sleep(1000); // 1 second
|
||||||
|
|
||||||
|
HAL_GPIO_WritePin(FIRE_HATCH_GROUP1, FIRE_HATCH_PIN_1, GPIO_PIN_RESET);
|
||||||
|
HAL_GPIO_WritePin(FIRE_HATCH_GROUP2, FIRE_HATCH_PIN_2, GPIO_PIN_RESET);
|
||||||
|
|
||||||
|
this->sleep(50); // Delay before disarming igniters
|
||||||
|
|
||||||
|
// Disarm the igniters
|
||||||
|
HAL_GPIO_WritePin(ARMING_GROUPE, ARMING_PIN_E, GPIO_PIN_RESET);
|
||||||
|
HAL_GPIO_WritePin(ARMING_GROUPF, ARMING_PIN_F , GPIO_PIN_RESET);
|
||||||
|
|
||||||
|
// Short ignitors
|
||||||
|
HAL_GPIO_WritePin(SHORTING_GROUPE, SHORTING_PIN_E, GPIO_PIN_RESET);
|
||||||
|
HAL_GPIO_WritePin(SHORTING_GROUPF, SHORTING_PIN_F, GPIO_PIN_RESET);
|
||||||
|
}
|
||||||
|
else if (sta::tacos::getState() == stahr::MAIN)
|
||||||
|
{
|
||||||
|
HAL_GPIO_WritePin(FIRE_MAIN_GROUP1, FIRE_MAIN_PIN_1, GPIO_PIN_SET);
|
||||||
|
HAL_GPIO_WritePin(FIRE_MAIN_GROUP2, FIRE_MAIN_PIN_2, GPIO_PIN_SET);
|
||||||
|
|
||||||
|
// Send out fire information
|
||||||
|
msg.payload[0] = 2; // Event 2 = MAIN Parachute
|
||||||
|
sta::tacos::queueCanBusMsg(msg, 0);
|
||||||
|
|
||||||
|
rres::setFired(2);
|
||||||
|
|
||||||
|
// Only leave on for a second to avoid shorting via the igniter
|
||||||
|
this->sleep(1000); // 1 second
|
||||||
|
|
||||||
|
HAL_GPIO_WritePin(FIRE_MAIN_GROUP1, FIRE_MAIN_PIN_1, GPIO_PIN_RESET);
|
||||||
|
HAL_GPIO_WritePin(FIRE_MAIN_GROUP2, FIRE_MAIN_PIN_2, GPIO_PIN_RESET);
|
||||||
|
|
||||||
|
this->sleep(50); // Delay before disarming igniters
|
||||||
|
|
||||||
|
// Disarm the igniters
|
||||||
|
HAL_GPIO_WritePin(ARMING_GROUPC, ARMING_PIN_C, GPIO_PIN_RESET);
|
||||||
|
HAL_GPIO_WritePin(ARMING_GROUPD, ARMING_PIN_D, GPIO_PIN_RESET);
|
||||||
|
|
||||||
|
// Short ignitors
|
||||||
|
HAL_GPIO_WritePin(SHORTING_GROUPC, SHORTING_PIN_C, GPIO_PIN_RESET);
|
||||||
|
HAL_GPIO_WritePin(SHORTING_GROUPD, SHORTING_PIN_D, GPIO_PIN_RESET);
|
||||||
|
}
|
||||||
|
else if (sta::tacos::getState() == stahr::DISREEFING)
|
||||||
|
{
|
||||||
|
HAL_GPIO_WritePin(FIRE_DEREEFING_GROUP1, FIRE_DEREEFING_PIN_1, GPIO_PIN_SET);
|
||||||
|
HAL_GPIO_WritePin(FIRE_DEREEFING_GROUP2, FIRE_DEREEFING_PIN_2, GPIO_PIN_SET);
|
||||||
|
|
||||||
|
// Send out fire information
|
||||||
|
msg.payload[0] = 3; // Event 3 = Drogue Parachute
|
||||||
|
sta::tacos::queueCanBusMsg(msg, 0);
|
||||||
|
|
||||||
|
rres::setFired(3);
|
||||||
|
|
||||||
|
// Only leave on for a second to avoid shorting via the igniter
|
||||||
|
this->sleep(1000); // 1 second
|
||||||
|
|
||||||
|
HAL_GPIO_WritePin(FIRE_DEREEFING_GROUP1, FIRE_DEREEFING_PIN_1, GPIO_PIN_RESET);
|
||||||
|
HAL_GPIO_WritePin(FIRE_DEREEFING_GROUP2, FIRE_DEREEFING_PIN_2, GPIO_PIN_RESET);
|
||||||
|
|
||||||
|
this->sleep(50); // Delay before disarming igniters
|
||||||
|
|
||||||
|
// Disarm the igniters
|
||||||
|
HAL_GPIO_WritePin(ARMING_GROUPA, ARMING_PIN_A, GPIO_PIN_RESET);
|
||||||
|
HAL_GPIO_WritePin(ARMING_GROUPB, ARMING_PIN_B, GPIO_PIN_RESET);
|
||||||
|
|
||||||
|
// Short ignitors
|
||||||
|
HAL_GPIO_WritePin(SHORTING_GROUPA, SHORTING_PIN_A, GPIO_PIN_RESET);
|
||||||
|
HAL_GPIO_WritePin(SHORTING_GROUPB, SHORTING_PIN_B, GPIO_PIN_RESET);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Terminate the thread until next state
|
||||||
|
#ifdef STA_TACOS_WATCHDOG_ENABLED
|
||||||
|
this->watchdogIgnore();
|
||||||
|
#endif // STA_TACOS_WATCHDOG_ENABLED
|
||||||
|
|
||||||
|
this->requestTermination();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace tasks
|
153
App/Src/tasks/sense.cpp
Normal file
153
App/Src/tasks/sense.cpp
Normal file
@ -0,0 +1,153 @@
|
|||||||
|
/*
|
||||||
|
* sense.cpp
|
||||||
|
*
|
||||||
|
* Created on: Jun 17, 2024
|
||||||
|
* Author: carlos
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <tasks/sense.hpp>
|
||||||
|
|
||||||
|
#include <sta/tacos.hpp>
|
||||||
|
#include <sta/rtos/signal.hpp>
|
||||||
|
#include <sta/devices/stm32/delay.hpp>
|
||||||
|
#include <shared.hpp>
|
||||||
|
|
||||||
|
#include <tim.h>
|
||||||
|
#include <adc.h>
|
||||||
|
|
||||||
|
namespace tasks
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @brief Signal for the ADC conversion complete interrupt to communicate with the ADCTask.
|
||||||
|
*/
|
||||||
|
sta::RtosSignal *adcCompleteSignal = nullptr;
|
||||||
|
|
||||||
|
SenseTask::SenseTask(ADC_HandleTypeDef *handle)
|
||||||
|
: sta::tacos::TacosThread{"Sense", osPriorityNormal},
|
||||||
|
adc_{handle}, result_counter_{0}
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void SenseTask::init()
|
||||||
|
{
|
||||||
|
adcCompleteSignal = new sta::RtosSignal(1);
|
||||||
|
|
||||||
|
// Init msg_
|
||||||
|
msg_.header.payloadLength = 8;
|
||||||
|
|
||||||
|
msg_.header.eid = 0;
|
||||||
|
msg_.header.format = 0;
|
||||||
|
|
||||||
|
// Start ADC timer
|
||||||
|
HAL_TIM_Base_Start(&htim3);
|
||||||
|
|
||||||
|
adc_.startDMA((uint32_t *)dmaBuffer_, bufferSize_);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SenseTask::func()
|
||||||
|
{
|
||||||
|
STA_ASSERT(adcCompleteSignal != nullptr);
|
||||||
|
|
||||||
|
// Wait for the conversion to be completed.
|
||||||
|
adcCompleteSignal->wait();
|
||||||
|
|
||||||
|
// Determine wether to send the data or not
|
||||||
|
uint16_t state = sta::tacos::getState();
|
||||||
|
bool logging = !(state == stahr::CALIBRATING || state == stahr::READY_ON_PAD);
|
||||||
|
bool send = result_counter_++ % 4 == 0;
|
||||||
|
|
||||||
|
// Sending the first 4 ADC values (limited by the CAN message size of 8 bytes)
|
||||||
|
for (size_t i = 0; i < 4; ++i)
|
||||||
|
{
|
||||||
|
// Send the MSB first.
|
||||||
|
msg_.payload[2 * i] = (uint8_t)(dmaBuffer_[i] >> 8);
|
||||||
|
|
||||||
|
// ... LSB second
|
||||||
|
msg_.payload[2 * i + 1] = (uint8_t)dmaBuffer_[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save the first 4 ADC values for logging
|
||||||
|
for (size_t i = 0; i < 4; i++)
|
||||||
|
{
|
||||||
|
result_[i] = msg_.payload[2 * i] << 8 | msg_.payload[2 * i + 1];
|
||||||
|
STA_DEBUG_PRINTF("> ADC[%d]: %d", i, result_[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (send)
|
||||||
|
{
|
||||||
|
// Send it out while on the pad. Otherwise we only log the data.
|
||||||
|
msg_.header.payloadLength = 8;
|
||||||
|
msg_.header.sid = SENSE_CAN_ID;
|
||||||
|
sta::tacos::queueCanBusMsg(msg_, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Send the last 2 ADC values (limited by the CAN message size of 8 bytes)
|
||||||
|
for (size_t i = 4; i < bufferSize_; ++i)
|
||||||
|
{
|
||||||
|
// Send the MSB first.
|
||||||
|
msg_.payload[2 * (i - 4)] = (uint8_t)(dmaBuffer_[i] >> 8);
|
||||||
|
|
||||||
|
// ... LSB second
|
||||||
|
msg_.payload[2 * (i - 4) + 1] = (uint8_t)dmaBuffer_[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save the last 2 ADC values for logging
|
||||||
|
for (size_t i = 4; i < 6; i++)
|
||||||
|
{
|
||||||
|
result_[i] = msg_.payload[2 * (i - 4)] << 8 | msg_.payload[2 * (i - 4) + 1];
|
||||||
|
STA_DEBUG_PRINTF("> ADC[%d]: %d", i, result_[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the sense pins on the fire output
|
||||||
|
uint8_t sense_fire = 0;
|
||||||
|
|
||||||
|
uint8_t sense_fire_1 = HAL_GPIO_ReadPin(SENSE_FIRE_GROUP1, SENSE_FIRE_PIN_1);
|
||||||
|
uint8_t sense_fire_2 = HAL_GPIO_ReadPin(SENSE_FIRE_GROUP2, SENSE_FIRE_PIN_2);
|
||||||
|
uint8_t sense_fire_3 = HAL_GPIO_ReadPin(SENSE_FIRE_GROUP3, SENSE_FIRE_PIN_3);
|
||||||
|
uint8_t sense_fire_4 = HAL_GPIO_ReadPin(SENSE_FIRE_GROUP4, SENSE_FIRE_PIN_4);
|
||||||
|
uint8_t sense_fire_5 = HAL_GPIO_ReadPin(SENSE_FIRE_GROUP5, SENSE_FIRE_PIN_5);
|
||||||
|
uint8_t sense_fire_6 = HAL_GPIO_ReadPin(SENSE_FIRE_GROUP6, SENSE_FIRE_PIN_6);
|
||||||
|
|
||||||
|
sense_fire = sense_fire_1 | (sense_fire_2 << 1) | (sense_fire_3 << 2) | (sense_fire_4 << 3) | (sense_fire_5 << 4) | (sense_fire_6 << 5);
|
||||||
|
|
||||||
|
STA_DEBUG_PRINTF("> Sense Fired pins: %d", sense_fire);
|
||||||
|
|
||||||
|
if (send)
|
||||||
|
{
|
||||||
|
msg_.payload[4] = sense_fire; // Send the sense pins on the fire output
|
||||||
|
|
||||||
|
// Send second half of the ADC values, via another CAN ID (+1)
|
||||||
|
msg_.header.sid = SENSE_CAN_ID_2;
|
||||||
|
msg_.header.payloadLength = 5;
|
||||||
|
|
||||||
|
// Send it out while on the pad. Otherwise we only log the data.
|
||||||
|
sta::tacos::queueCanBusMsg(msg_, 0);
|
||||||
|
|
||||||
|
HAL_GPIO_TogglePin(GPIOD, GPIO_PIN_10);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
HAL_GPIO_TogglePin(GPIOD, GPIO_PIN_9);
|
||||||
|
}
|
||||||
|
if (logging)
|
||||||
|
{
|
||||||
|
// Log the ADC values and the sense pins on the fire output
|
||||||
|
rres::setSenseFire(sense_fire);
|
||||||
|
rres::setSenseADC(result_);
|
||||||
|
|
||||||
|
HAL_GPIO_TogglePin(GPIOD, GPIO_PIN_8);
|
||||||
|
}
|
||||||
|
|
||||||
|
adc_.startDMA((uint32_t *)dmaBuffer_, bufferSize_);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace tasks
|
||||||
|
|
||||||
|
// Callback for HAL ADC
|
||||||
|
void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef *hadc)
|
||||||
|
{
|
||||||
|
if (tasks::adcCompleteSignal != nullptr && hadc == &hadc1)
|
||||||
|
{
|
||||||
|
tasks::adcCompleteSignal->notify();
|
||||||
|
}
|
||||||
|
}
|
87
CMakeLists.txt
Normal file
87
CMakeLists.txt
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.16)
|
||||||
|
set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_SOURCE_DIR}/libs/stm32-cmake/cmake/stm32_gcc.cmake)
|
||||||
|
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/libs/stm32-cmake/cmake)
|
||||||
|
|
||||||
|
project(demo C CXX ASM)
|
||||||
|
|
||||||
|
################## TOOLCHAIN SETUP ####################################
|
||||||
|
find_package(HAL COMPONENTS STM32F4 REQUIRED)
|
||||||
|
find_package(FreeRTOS COMPONENTS ARM_CM4F STM32F4 REQUIRED)
|
||||||
|
find_package(CMSIS COMPONENTS STM32F407ZG RTOS_V2 REQUIRED)
|
||||||
|
#######################################################################
|
||||||
|
|
||||||
|
set (PROJECT_SOURCES
|
||||||
|
core/src/main.c
|
||||||
|
core/src/freertos.c
|
||||||
|
core/src/adc.c
|
||||||
|
core/src/gpio.c
|
||||||
|
core/src/can.c
|
||||||
|
core/src/dma.c
|
||||||
|
core/src/spi.c
|
||||||
|
core/src/tim.c
|
||||||
|
core/src/usart.c
|
||||||
|
core/src/syscalls.c
|
||||||
|
core/src/sysmem.c
|
||||||
|
core/src/stm32f4xx_it.c
|
||||||
|
core/src/stm32f4xx_hal_msp.c
|
||||||
|
core/src/stm32f4xx_hal_timebase_tim.c
|
||||||
|
|
||||||
|
# Application specific
|
||||||
|
App/Src/shared.cpp
|
||||||
|
App/Src/startup.cpp
|
||||||
|
App/Src/tasks/arming.cpp
|
||||||
|
App/Src/tasks/fire.cpp
|
||||||
|
App/Src/tasks/sense.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
set (PROJECT_INCLUDES
|
||||||
|
core/inc/
|
||||||
|
|
||||||
|
# Application specific
|
||||||
|
App/Inc/
|
||||||
|
libs/STAHR-defs/
|
||||||
|
)
|
||||||
|
|
||||||
|
############ Libraries ###############################################
|
||||||
|
# STA-CORE
|
||||||
|
add_subdirectory(libs/sta-core)
|
||||||
|
list(APPEND PROJECT_SOURCES ${STA_CORE_SOURCES})
|
||||||
|
list(APPEND PROJECT_INCLUDES ${STA_CORE_INCLUDES})
|
||||||
|
# rtos2-utils
|
||||||
|
add_subdirectory(libs/rtos2-utils)
|
||||||
|
list(APPEND PROJECT_SOURCES ${RTOS2_UTILS_SOURCES})
|
||||||
|
list(APPEND PROJECT_INCLUDES ${RTOS2_UTILS_INCLUDES})
|
||||||
|
# TACOS
|
||||||
|
add_subdirectory(libs/TACOS)
|
||||||
|
list(APPEND PROJECT_SOURCES ${TACOS_SOURCES})
|
||||||
|
list(APPEND PROJECT_INCLUDES ${TACOS_INCLUDES})
|
||||||
|
#######################################################################
|
||||||
|
|
||||||
|
# ################## PROJECT SETUP ######################################
|
||||||
|
add_executable(demo ${PROJECT_SOURCES})
|
||||||
|
target_link_libraries(demo PRIVATE
|
||||||
|
FreeRTOS::STM32::F4::ARM_CM4F
|
||||||
|
FreeRTOS::STM32::F4::Timers
|
||||||
|
FreeRTOS::STM32::F4::Heap::4
|
||||||
|
FreeRTOS::STM32::F4::EventGroups
|
||||||
|
CMSIS::STM32::F4::RTOS_V2
|
||||||
|
CMSIS::STM32::F407ZG
|
||||||
|
HAL::STM32::F4
|
||||||
|
HAL::STM32::F4::ADC
|
||||||
|
HAL::STM32::F4::CAN
|
||||||
|
HAL::STM32::F4::GPIO
|
||||||
|
HAL::STM32::F4::UART
|
||||||
|
HAL::STM32::F4::SPI
|
||||||
|
HAL::STM32::F4::DMA
|
||||||
|
HAL::STM32::F4::RCC
|
||||||
|
HAL::STM32::F4::TIM
|
||||||
|
HAL::STM32::F4::TIMEx
|
||||||
|
HAL::STM32::F4::CORTEX
|
||||||
|
STM32::NoSys
|
||||||
|
)
|
||||||
|
target_include_directories (demo PRIVATE ${PROJECT_INCLUDES})
|
||||||
|
|
||||||
|
target_compile_definitions(demo PRIVATE
|
||||||
|
USE_CMSIS_RTOS_V2
|
||||||
|
CMSIS_RTOS_V2_DEVICE_HEADER="stm32f4xx_hal.h"
|
||||||
|
)
|
232
LICENSE
Normal file
232
LICENSE
Normal file
@ -0,0 +1,232 @@
|
|||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
Version 3, 29 June 2007
|
||||||
|
|
||||||
|
Copyright © 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||||
|
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The GNU General Public License is a free, copyleft license for software and other kinds of works.
|
||||||
|
|
||||||
|
The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things.
|
||||||
|
|
||||||
|
To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others.
|
||||||
|
|
||||||
|
For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.
|
||||||
|
|
||||||
|
Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it.
|
||||||
|
|
||||||
|
For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions.
|
||||||
|
|
||||||
|
Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users.
|
||||||
|
|
||||||
|
Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and modification follow.
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
0. Definitions.
|
||||||
|
|
||||||
|
“This License” refers to version 3 of the GNU General Public License.
|
||||||
|
|
||||||
|
“Copyright” also means copyright-like laws that apply to other kinds of works, such as semiconductor masks.
|
||||||
|
|
||||||
|
“The Program” refers to any copyrightable work licensed under this License. Each licensee is addressed as “you”. “Licensees” and “recipients” may be individuals or organizations.
|
||||||
|
|
||||||
|
To “modify” a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a “modified version” of the earlier work or a work “based on” the earlier work.
|
||||||
|
|
||||||
|
A “covered work” means either the unmodified Program or a work based on the Program.
|
||||||
|
|
||||||
|
To “propagate” a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well.
|
||||||
|
|
||||||
|
To “convey” a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying.
|
||||||
|
|
||||||
|
An interactive user interface displays “Appropriate Legal Notices” to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion.
|
||||||
|
|
||||||
|
1. Source Code.
|
||||||
|
The “source code” for a work means the preferred form of the work for making modifications to it. “Object code” means any non-source form of a work.
|
||||||
|
|
||||||
|
A “Standard Interface” means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language.
|
||||||
|
|
||||||
|
The “System Libraries” of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A “Major Component”, in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it.
|
||||||
|
|
||||||
|
The “Corresponding Source” for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work.
|
||||||
|
|
||||||
|
The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source.
|
||||||
|
|
||||||
|
The Corresponding Source for a work in source code form is that same work.
|
||||||
|
|
||||||
|
2. Basic Permissions.
|
||||||
|
All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law.
|
||||||
|
|
||||||
|
You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you.
|
||||||
|
|
||||||
|
Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary.
|
||||||
|
|
||||||
|
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||||
|
No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures.
|
||||||
|
|
||||||
|
When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures.
|
||||||
|
|
||||||
|
4. Conveying Verbatim Copies.
|
||||||
|
You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program.
|
||||||
|
|
||||||
|
You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee.
|
||||||
|
|
||||||
|
5. Conveying Modified Source Versions.
|
||||||
|
You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) The work must carry prominent notices stating that you modified it, and giving a relevant date.
|
||||||
|
|
||||||
|
b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to “keep intact all notices”.
|
||||||
|
|
||||||
|
c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it.
|
||||||
|
|
||||||
|
d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so.
|
||||||
|
|
||||||
|
A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an “aggregate” if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate.
|
||||||
|
|
||||||
|
6. Conveying Non-Source Forms.
|
||||||
|
You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways:
|
||||||
|
|
||||||
|
a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange.
|
||||||
|
|
||||||
|
b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge.
|
||||||
|
|
||||||
|
c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b.
|
||||||
|
|
||||||
|
d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements.
|
||||||
|
|
||||||
|
e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d.
|
||||||
|
|
||||||
|
A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work.
|
||||||
|
|
||||||
|
A “User Product” is either (1) a “consumer product”, which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, “normally used” refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product.
|
||||||
|
|
||||||
|
“Installation Information” for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made.
|
||||||
|
|
||||||
|
If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM).
|
||||||
|
|
||||||
|
The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network.
|
||||||
|
|
||||||
|
Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying.
|
||||||
|
|
||||||
|
7. Additional Terms.
|
||||||
|
“Additional permissions” are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions.
|
||||||
|
|
||||||
|
When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms:
|
||||||
|
|
||||||
|
a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or
|
||||||
|
|
||||||
|
b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or
|
||||||
|
|
||||||
|
c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or
|
||||||
|
|
||||||
|
d) Limiting the use for publicity purposes of names of licensors or authors of the material; or
|
||||||
|
|
||||||
|
e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or
|
||||||
|
|
||||||
|
f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors.
|
||||||
|
|
||||||
|
All other non-permissive additional terms are considered “further restrictions” within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying.
|
||||||
|
|
||||||
|
If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms.
|
||||||
|
|
||||||
|
Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way.
|
||||||
|
|
||||||
|
8. Termination.
|
||||||
|
You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11).
|
||||||
|
|
||||||
|
However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation.
|
||||||
|
|
||||||
|
Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice.
|
||||||
|
|
||||||
|
Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10.
|
||||||
|
|
||||||
|
9. Acceptance Not Required for Having Copies.
|
||||||
|
You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so.
|
||||||
|
|
||||||
|
10. Automatic Licensing of Downstream Recipients.
|
||||||
|
Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License.
|
||||||
|
|
||||||
|
An “entity transaction” is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts.
|
||||||
|
|
||||||
|
You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it.
|
||||||
|
|
||||||
|
11. Patents.
|
||||||
|
A “contributor” is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's “contributor version”.
|
||||||
|
|
||||||
|
A contributor's “essential patent claims” are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, “control” includes the right to grant patent sublicenses in a manner consistent with the requirements of this License.
|
||||||
|
|
||||||
|
Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version.
|
||||||
|
|
||||||
|
In the following three paragraphs, a “patent license” is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To “grant” such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party.
|
||||||
|
|
||||||
|
If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. “Knowingly relying” means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid.
|
||||||
|
|
||||||
|
If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it.
|
||||||
|
|
||||||
|
A patent license is “discriminatory” if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007.
|
||||||
|
|
||||||
|
Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law.
|
||||||
|
|
||||||
|
12. No Surrender of Others' Freedom.
|
||||||
|
If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program.
|
||||||
|
|
||||||
|
13. Use with the GNU Affero General Public License.
|
||||||
|
Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such.
|
||||||
|
|
||||||
|
14. Revised Versions of this License.
|
||||||
|
The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License “or any later version” applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation.
|
||||||
|
|
||||||
|
If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program.
|
||||||
|
|
||||||
|
Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version.
|
||||||
|
|
||||||
|
15. Disclaimer of Warranty.
|
||||||
|
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
16. Limitation of Liability.
|
||||||
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||||
|
|
||||||
|
17. Interpretation of Sections 15 and 16.
|
||||||
|
If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
|
If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms.
|
||||||
|
|
||||||
|
To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the “copyright” line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
|
test
|
||||||
|
Copyright (C) 2024 ALPAKA
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode:
|
||||||
|
|
||||||
|
test Copyright (C) 2024 ALPAKA
|
||||||
|
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||||
|
This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details.
|
||||||
|
|
||||||
|
The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an “about box”.
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or school, if any, to sign a “copyright disclaimer” for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read <https://www.gnu.org/philosophy/why-not-lgpl.html>.
|
13
README.md
Normal file
13
README.md
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
# Cmake Demo
|
||||||
|
|
||||||
|
This is a cmake demo for the sta-core/rtos2-utils/TACOS setup that is used in TACOS projects. The actual project is the RRES software because idk...
|
||||||
|
|
||||||
|
|
||||||
|
To build this:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cmake -S . -B build -G"Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -DSTM32_CUBE_F4_PATH=[YOUR_PATH_TO_STM32_CUBE_F4]
|
||||||
|
cmake --build build
|
||||||
|
```
|
||||||
|
|
||||||
|
My `STM32_CUBE_F4_PATH` on MacOS is: `/var/root/STM32Cube/Repository/STM32Cube_FW_F4_V1.28.1` and on MacOS I had to configure and build using sudo since var is protected.
|
1
compile_commands.json
Symbolic link
1
compile_commands.json
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
compile_commands.json
|
186
core/inc/FreeRTOSConfig.h
Normal file
186
core/inc/FreeRTOSConfig.h
Normal file
@ -0,0 +1,186 @@
|
|||||||
|
/* USER CODE BEGIN Header */
|
||||||
|
/*
|
||||||
|
* FreeRTOS Kernel V10.3.1
|
||||||
|
* Portion Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||||
|
* Portion Copyright (C) 2019 StMicroelectronics, Inc. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
* this software and associated documentation files (the "Software"), to deal in
|
||||||
|
* the Software without restriction, including without limitation the rights to
|
||||||
|
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||||
|
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
|
* subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* http://www.FreeRTOS.org
|
||||||
|
* http://aws.amazon.com/freertos
|
||||||
|
*
|
||||||
|
* 1 tab == 4 spaces!
|
||||||
|
*/
|
||||||
|
/* USER CODE END Header */
|
||||||
|
|
||||||
|
#ifndef FREERTOS_CONFIG_H
|
||||||
|
#define FREERTOS_CONFIG_H
|
||||||
|
|
||||||
|
/*-----------------------------------------------------------
|
||||||
|
* Application specific definitions.
|
||||||
|
*
|
||||||
|
* These definitions should be adjusted for your particular hardware and
|
||||||
|
* application requirements.
|
||||||
|
*
|
||||||
|
* These parameters and more are described within the 'configuration' section of the
|
||||||
|
* FreeRTOS API documentation available on the FreeRTOS.org web site.
|
||||||
|
*
|
||||||
|
* See http://www.freertos.org/a00110.html
|
||||||
|
*----------------------------------------------------------*/
|
||||||
|
|
||||||
|
/* USER CODE BEGIN Includes */
|
||||||
|
/* Section where include file can be added */
|
||||||
|
/* USER CODE END Includes */
|
||||||
|
|
||||||
|
/* Ensure definitions are only used by the compiler, and not by the assembler. */
|
||||||
|
#if defined(__ICCARM__) || defined(__CC_ARM) || defined(__GNUC__)
|
||||||
|
#include <stdint.h>
|
||||||
|
extern uint32_t SystemCoreClock;
|
||||||
|
/* USER CODE BEGIN 0 */
|
||||||
|
extern void configureTimerForRunTimeStats(void);
|
||||||
|
extern unsigned long getRunTimeCounterValue(void);
|
||||||
|
/* USER CODE END 0 */
|
||||||
|
#endif
|
||||||
|
#ifndef CMSIS_device_header
|
||||||
|
#define CMSIS_device_header "stm32f4xx.h"
|
||||||
|
#endif /* CMSIS_device_header */
|
||||||
|
|
||||||
|
#define configENABLE_FPU 0
|
||||||
|
#define configENABLE_MPU 0
|
||||||
|
|
||||||
|
#define configUSE_PREEMPTION 1
|
||||||
|
#define configSUPPORT_STATIC_ALLOCATION 1
|
||||||
|
#define configSUPPORT_DYNAMIC_ALLOCATION 1
|
||||||
|
#define configUSE_IDLE_HOOK 0
|
||||||
|
#define configUSE_TICK_HOOK 0
|
||||||
|
#define configCPU_CLOCK_HZ ( SystemCoreClock )
|
||||||
|
#define configTICK_RATE_HZ ((TickType_t)1000)
|
||||||
|
#define configMAX_PRIORITIES ( 56 )
|
||||||
|
#define configMINIMAL_STACK_SIZE ((uint16_t)700)
|
||||||
|
#define configTOTAL_HEAP_SIZE ((size_t)35000)
|
||||||
|
#define configMAX_TASK_NAME_LEN ( 16 )
|
||||||
|
#define configGENERATE_RUN_TIME_STATS 1
|
||||||
|
#define configUSE_TRACE_FACILITY 1
|
||||||
|
#define configUSE_16_BIT_TICKS 0
|
||||||
|
#define configUSE_MUTEXES 1
|
||||||
|
#define configQUEUE_REGISTRY_SIZE 8
|
||||||
|
#define configCHECK_FOR_STACK_OVERFLOW 2
|
||||||
|
#define configUSE_RECURSIVE_MUTEXES 1
|
||||||
|
#define configUSE_COUNTING_SEMAPHORES 1
|
||||||
|
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 0
|
||||||
|
#define configRECORD_STACK_HIGH_ADDRESS 1
|
||||||
|
/* USER CODE BEGIN MESSAGE_BUFFER_LENGTH_TYPE */
|
||||||
|
/* Defaults to size_t for backward compatibility, but can be changed
|
||||||
|
if lengths will always be less than the number of bytes in a size_t. */
|
||||||
|
#define configMESSAGE_BUFFER_LENGTH_TYPE size_t
|
||||||
|
/* USER CODE END MESSAGE_BUFFER_LENGTH_TYPE */
|
||||||
|
|
||||||
|
/* Co-routine definitions. */
|
||||||
|
#define configUSE_CO_ROUTINES 0
|
||||||
|
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
|
||||||
|
|
||||||
|
/* Software timer definitions. */
|
||||||
|
#define configUSE_TIMERS 1
|
||||||
|
#define configTIMER_TASK_PRIORITY ( 55 )
|
||||||
|
#define configTIMER_QUEUE_LENGTH 10
|
||||||
|
#define configTIMER_TASK_STACK_DEPTH 1400
|
||||||
|
|
||||||
|
/* The following flag must be enabled only when using newlib */
|
||||||
|
#define configUSE_NEWLIB_REENTRANT 1
|
||||||
|
|
||||||
|
/* CMSIS-RTOS V2 flags */
|
||||||
|
#define configUSE_OS2_THREAD_SUSPEND_RESUME 1
|
||||||
|
#define configUSE_OS2_THREAD_ENUMERATE 1
|
||||||
|
#define configUSE_OS2_EVENTFLAGS_FROM_ISR 1
|
||||||
|
#define configUSE_OS2_THREAD_FLAGS 1
|
||||||
|
#define configUSE_OS2_TIMER 1
|
||||||
|
#define configUSE_OS2_MUTEX 1
|
||||||
|
|
||||||
|
/* Set the following definitions to 1 to include the API function, or zero
|
||||||
|
to exclude the API function. */
|
||||||
|
#define INCLUDE_vTaskPrioritySet 1
|
||||||
|
#define INCLUDE_uxTaskPriorityGet 1
|
||||||
|
#define INCLUDE_vTaskDelete 1
|
||||||
|
#define INCLUDE_vTaskCleanUpResources 0
|
||||||
|
#define INCLUDE_vTaskSuspend 1
|
||||||
|
#define INCLUDE_vTaskDelayUntil 1
|
||||||
|
#define INCLUDE_vTaskDelay 1
|
||||||
|
#define INCLUDE_xTaskGetSchedulerState 1
|
||||||
|
#define INCLUDE_xTimerPendFunctionCall 1
|
||||||
|
#define INCLUDE_xQueueGetMutexHolder 1
|
||||||
|
#define INCLUDE_uxTaskGetStackHighWaterMark 1
|
||||||
|
#define INCLUDE_xTaskGetCurrentTaskHandle 1
|
||||||
|
#define INCLUDE_eTaskGetState 1
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The CMSIS-RTOS V2 FreeRTOS wrapper is dependent on the heap implementation used
|
||||||
|
* by the application thus the correct define need to be enabled below
|
||||||
|
*/
|
||||||
|
#define USE_FreeRTOS_HEAP_4
|
||||||
|
|
||||||
|
/* Cortex-M specific definitions. */
|
||||||
|
#ifdef __NVIC_PRIO_BITS
|
||||||
|
/* __BVIC_PRIO_BITS will be specified when CMSIS is being used. */
|
||||||
|
#define configPRIO_BITS __NVIC_PRIO_BITS
|
||||||
|
#else
|
||||||
|
#define configPRIO_BITS 4
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* The lowest interrupt priority that can be used in a call to a "set priority"
|
||||||
|
function. */
|
||||||
|
#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY 15
|
||||||
|
|
||||||
|
/* The highest interrupt priority that can be used by any interrupt service
|
||||||
|
routine that makes calls to interrupt safe FreeRTOS API functions. DO NOT CALL
|
||||||
|
INTERRUPT SAFE FREERTOS API FUNCTIONS FROM ANY INTERRUPT THAT HAS A HIGHER
|
||||||
|
PRIORITY THAN THIS! (higher priorities are lower numeric values. */
|
||||||
|
#define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 5
|
||||||
|
|
||||||
|
/* Interrupt priorities used by the kernel port layer itself. These are generic
|
||||||
|
to all Cortex-M ports, and do not rely on any particular library functions. */
|
||||||
|
#define configKERNEL_INTERRUPT_PRIORITY ( configLIBRARY_LOWEST_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
|
||||||
|
/* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!!
|
||||||
|
See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */
|
||||||
|
#define configMAX_SYSCALL_INTERRUPT_PRIORITY ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
|
||||||
|
|
||||||
|
/* Normal assert() semantics without relying on the provision of an assert.h
|
||||||
|
header file. */
|
||||||
|
/* USER CODE BEGIN 1 */
|
||||||
|
#define configASSERT( x ) if ((x) == 0) {taskDISABLE_INTERRUPTS(); for( ;; );}
|
||||||
|
/* USER CODE END 1 */
|
||||||
|
|
||||||
|
/* Definitions that map the FreeRTOS port interrupt handlers to their CMSIS
|
||||||
|
standard names. */
|
||||||
|
#define vPortSVCHandler SVC_Handler
|
||||||
|
#define xPortPendSVHandler PendSV_Handler
|
||||||
|
|
||||||
|
/* IMPORTANT: After 10.3.1 update, Systick_Handler comes from NVIC (if SYS timebase = systick), otherwise from cmsis_os2.c */
|
||||||
|
|
||||||
|
#define USE_CUSTOM_SYSTICK_HANDLER_IMPLEMENTATION 0
|
||||||
|
|
||||||
|
/* USER CODE BEGIN 2 */
|
||||||
|
/* Definitions needed when configGENERATE_RUN_TIME_STATS is on */
|
||||||
|
#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS configureTimerForRunTimeStats
|
||||||
|
#define portGET_RUN_TIME_COUNTER_VALUE getRunTimeCounterValue
|
||||||
|
/* USER CODE END 2 */
|
||||||
|
|
||||||
|
/* USER CODE BEGIN Defines */
|
||||||
|
/* Section where parameter definitions can be added (for instance, to override default ones in FreeRTOS.h) */
|
||||||
|
/* USER CODE END Defines */
|
||||||
|
|
||||||
|
#endif /* FREERTOS_CONFIG_H */
|
52
core/inc/adc.h
Normal file
52
core/inc/adc.h
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
/* USER CODE BEGIN Header */
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file adc.h
|
||||||
|
* @brief This file contains all the function prototypes for
|
||||||
|
* the adc.c file
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* Copyright (c) 2024 STMicroelectronics.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This software is licensed under terms that can be found in the LICENSE file
|
||||||
|
* in the root directory of this software component.
|
||||||
|
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
/* USER CODE END Header */
|
||||||
|
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||||
|
#ifndef __ADC_H__
|
||||||
|
#define __ADC_H__
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "main.h"
|
||||||
|
|
||||||
|
/* USER CODE BEGIN Includes */
|
||||||
|
|
||||||
|
/* USER CODE END Includes */
|
||||||
|
|
||||||
|
extern ADC_HandleTypeDef hadc1;
|
||||||
|
|
||||||
|
/* USER CODE BEGIN Private defines */
|
||||||
|
|
||||||
|
/* USER CODE END Private defines */
|
||||||
|
|
||||||
|
void MX_ADC1_Init(void);
|
||||||
|
|
||||||
|
/* USER CODE BEGIN Prototypes */
|
||||||
|
|
||||||
|
/* USER CODE END Prototypes */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __ADC_H__ */
|
||||||
|
|
52
core/inc/can.h
Normal file
52
core/inc/can.h
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
/* USER CODE BEGIN Header */
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file can.h
|
||||||
|
* @brief This file contains all the function prototypes for
|
||||||
|
* the can.c file
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* Copyright (c) 2024 STMicroelectronics.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This software is licensed under terms that can be found in the LICENSE file
|
||||||
|
* in the root directory of this software component.
|
||||||
|
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
/* USER CODE END Header */
|
||||||
|
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||||
|
#ifndef __CAN_H__
|
||||||
|
#define __CAN_H__
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "main.h"
|
||||||
|
|
||||||
|
/* USER CODE BEGIN Includes */
|
||||||
|
|
||||||
|
/* USER CODE END Includes */
|
||||||
|
|
||||||
|
extern CAN_HandleTypeDef hcan1;
|
||||||
|
|
||||||
|
/* USER CODE BEGIN Private defines */
|
||||||
|
|
||||||
|
/* USER CODE END Private defines */
|
||||||
|
|
||||||
|
void MX_CAN1_Init(void);
|
||||||
|
|
||||||
|
/* USER CODE BEGIN Prototypes */
|
||||||
|
|
||||||
|
/* USER CODE END Prototypes */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __CAN_H__ */
|
||||||
|
|
52
core/inc/dma.h
Normal file
52
core/inc/dma.h
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
/* USER CODE BEGIN Header */
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file dma.h
|
||||||
|
* @brief This file contains all the function prototypes for
|
||||||
|
* the dma.c file
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* Copyright (c) 2024 STMicroelectronics.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This software is licensed under terms that can be found in the LICENSE file
|
||||||
|
* in the root directory of this software component.
|
||||||
|
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
/* USER CODE END Header */
|
||||||
|
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||||
|
#ifndef __DMA_H__
|
||||||
|
#define __DMA_H__
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "main.h"
|
||||||
|
|
||||||
|
/* DMA memory to memory transfer handles -------------------------------------*/
|
||||||
|
|
||||||
|
/* USER CODE BEGIN Includes */
|
||||||
|
|
||||||
|
/* USER CODE END Includes */
|
||||||
|
|
||||||
|
/* USER CODE BEGIN Private defines */
|
||||||
|
|
||||||
|
/* USER CODE END Private defines */
|
||||||
|
|
||||||
|
void MX_DMA_Init(void);
|
||||||
|
|
||||||
|
/* USER CODE BEGIN Prototypes */
|
||||||
|
|
||||||
|
/* USER CODE END Prototypes */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __DMA_H__ */
|
||||||
|
|
49
core/inc/gpio.h
Normal file
49
core/inc/gpio.h
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
/* USER CODE BEGIN Header */
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file gpio.h
|
||||||
|
* @brief This file contains all the function prototypes for
|
||||||
|
* the gpio.c file
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* Copyright (c) 2024 STMicroelectronics.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This software is licensed under terms that can be found in the LICENSE file
|
||||||
|
* in the root directory of this software component.
|
||||||
|
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
/* USER CODE END Header */
|
||||||
|
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||||
|
#ifndef __GPIO_H__
|
||||||
|
#define __GPIO_H__
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "main.h"
|
||||||
|
|
||||||
|
/* USER CODE BEGIN Includes */
|
||||||
|
|
||||||
|
/* USER CODE END Includes */
|
||||||
|
|
||||||
|
/* USER CODE BEGIN Private defines */
|
||||||
|
|
||||||
|
/* USER CODE END Private defines */
|
||||||
|
|
||||||
|
void MX_GPIO_Init(void);
|
||||||
|
|
||||||
|
/* USER CODE BEGIN Prototypes */
|
||||||
|
|
||||||
|
/* USER CODE END Prototypes */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif /*__ GPIO_H__ */
|
||||||
|
|
117
core/inc/main.h
Normal file
117
core/inc/main.h
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
/* USER CODE BEGIN Header */
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file : main.h
|
||||||
|
* @brief : Header for main.c file.
|
||||||
|
* This file contains the common defines of the application.
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* Copyright (c) 2024 STMicroelectronics.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This software is licensed under terms that can be found in the LICENSE file
|
||||||
|
* in the root directory of this software component.
|
||||||
|
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
/* USER CODE END Header */
|
||||||
|
|
||||||
|
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||||
|
#ifndef __MAIN_H
|
||||||
|
#define __MAIN_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "stm32f4xx_hal.h"
|
||||||
|
|
||||||
|
/* Private includes ----------------------------------------------------------*/
|
||||||
|
/* USER CODE BEGIN Includes */
|
||||||
|
|
||||||
|
/* USER CODE END Includes */
|
||||||
|
|
||||||
|
/* Exported types ------------------------------------------------------------*/
|
||||||
|
/* USER CODE BEGIN ET */
|
||||||
|
|
||||||
|
/* USER CODE END ET */
|
||||||
|
|
||||||
|
/* Exported constants --------------------------------------------------------*/
|
||||||
|
/* USER CODE BEGIN EC */
|
||||||
|
|
||||||
|
/* USER CODE END EC */
|
||||||
|
|
||||||
|
/* Exported macro ------------------------------------------------------------*/
|
||||||
|
/* USER CODE BEGIN EM */
|
||||||
|
|
||||||
|
/* USER CODE END EM */
|
||||||
|
|
||||||
|
/* Exported functions prototypes ---------------------------------------------*/
|
||||||
|
void Error_Handler(void);
|
||||||
|
|
||||||
|
/* USER CODE BEGIN EFP */
|
||||||
|
|
||||||
|
/* USER CODE END EFP */
|
||||||
|
|
||||||
|
/* Private defines -----------------------------------------------------------*/
|
||||||
|
#define C_short_Pin GPIO_PIN_4
|
||||||
|
#define C_short_GPIO_Port GPIOA
|
||||||
|
#define C_sense_Pin GPIO_PIN_5
|
||||||
|
#define C_sense_GPIO_Port GPIOA
|
||||||
|
#define C_arm_Pin GPIO_PIN_6
|
||||||
|
#define C_arm_GPIO_Port GPIOA
|
||||||
|
#define C_fire_Pin GPIO_PIN_7
|
||||||
|
#define C_fire_GPIO_Port GPIOA
|
||||||
|
#define B_short_Pin GPIO_PIN_5
|
||||||
|
#define B_short_GPIO_Port GPIOC
|
||||||
|
#define B_sense_Pin GPIO_PIN_15
|
||||||
|
#define B_sense_GPIO_Port GPIOF
|
||||||
|
#define A_arm_Pin GPIO_PIN_0
|
||||||
|
#define A_arm_GPIO_Port GPIOG
|
||||||
|
#define A_fire_Pin GPIO_PIN_7
|
||||||
|
#define A_fire_GPIO_Port GPIOE
|
||||||
|
#define A_short_Pin GPIO_PIN_13
|
||||||
|
#define A_short_GPIO_Port GPIOE
|
||||||
|
#define A_sense_Pin GPIO_PIN_14
|
||||||
|
#define A_sense_GPIO_Port GPIOE
|
||||||
|
#define A_armE15_Pin GPIO_PIN_15
|
||||||
|
#define A_armE15_GPIO_Port GPIOE
|
||||||
|
#define A_fireB10_Pin GPIO_PIN_10
|
||||||
|
#define A_fireB10_GPIO_Port GPIOB
|
||||||
|
#define F_short_Pin GPIO_PIN_9
|
||||||
|
#define F_short_GPIO_Port GPIOG
|
||||||
|
#define F_sense_Pin GPIO_PIN_10
|
||||||
|
#define F_sense_GPIO_Port GPIOG
|
||||||
|
#define F_arm_Pin GPIO_PIN_11
|
||||||
|
#define F_arm_GPIO_Port GPIOG
|
||||||
|
#define F_fire_Pin GPIO_PIN_12
|
||||||
|
#define F_fire_GPIO_Port GPIOG
|
||||||
|
#define E_short_Pin GPIO_PIN_4
|
||||||
|
#define E_short_GPIO_Port GPIOB
|
||||||
|
#define E_sense_Pin GPIO_PIN_5
|
||||||
|
#define E_sense_GPIO_Port GPIOB
|
||||||
|
#define E_arm_Pin GPIO_PIN_6
|
||||||
|
#define E_arm_GPIO_Port GPIOB
|
||||||
|
#define E_fire_Pin GPIO_PIN_7
|
||||||
|
#define E_fire_GPIO_Port GPIOB
|
||||||
|
#define D_short_Pin GPIO_PIN_8
|
||||||
|
#define D_short_GPIO_Port GPIOB
|
||||||
|
#define D_sense_Pin GPIO_PIN_9
|
||||||
|
#define D_sense_GPIO_Port GPIOB
|
||||||
|
#define D_arm_Pin GPIO_PIN_0
|
||||||
|
#define D_arm_GPIO_Port GPIOE
|
||||||
|
#define D_fire_Pin GPIO_PIN_1
|
||||||
|
#define D_fire_GPIO_Port GPIOE
|
||||||
|
|
||||||
|
/* USER CODE BEGIN Private defines */
|
||||||
|
|
||||||
|
/* USER CODE END Private defines */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __MAIN_H */
|
55
core/inc/spi.h
Normal file
55
core/inc/spi.h
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
/* USER CODE BEGIN Header */
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file spi.h
|
||||||
|
* @brief This file contains all the function prototypes for
|
||||||
|
* the spi.c file
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* Copyright (c) 2024 STMicroelectronics.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This software is licensed under terms that can be found in the LICENSE file
|
||||||
|
* in the root directory of this software component.
|
||||||
|
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
/* USER CODE END Header */
|
||||||
|
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||||
|
#ifndef __SPI_H__
|
||||||
|
#define __SPI_H__
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "main.h"
|
||||||
|
|
||||||
|
/* USER CODE BEGIN Includes */
|
||||||
|
|
||||||
|
/* USER CODE END Includes */
|
||||||
|
|
||||||
|
extern SPI_HandleTypeDef hspi2;
|
||||||
|
|
||||||
|
extern SPI_HandleTypeDef hspi3;
|
||||||
|
|
||||||
|
/* USER CODE BEGIN Private defines */
|
||||||
|
|
||||||
|
/* USER CODE END Private defines */
|
||||||
|
|
||||||
|
void MX_SPI2_Init(void);
|
||||||
|
void MX_SPI3_Init(void);
|
||||||
|
|
||||||
|
/* USER CODE BEGIN Prototypes */
|
||||||
|
|
||||||
|
/* USER CODE END Prototypes */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __SPI_H__ */
|
||||||
|
|
495
core/inc/stm32f4xx_hal_conf.h
Normal file
495
core/inc/stm32f4xx_hal_conf.h
Normal file
@ -0,0 +1,495 @@
|
|||||||
|
/* USER CODE BEGIN Header */
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file stm32f4xx_hal_conf_template.h
|
||||||
|
* @author MCD Application Team
|
||||||
|
* @brief HAL configuration template file.
|
||||||
|
* This file should be copied to the application folder and renamed
|
||||||
|
* to stm32f4xx_hal_conf.h.
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* Copyright (c) 2017 STMicroelectronics.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This software is licensed under terms that can be found in the LICENSE file
|
||||||
|
* in the root directory of this software component.
|
||||||
|
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
/* USER CODE END Header */
|
||||||
|
|
||||||
|
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||||
|
#ifndef __STM32F4xx_HAL_CONF_H
|
||||||
|
#define __STM32F4xx_HAL_CONF_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Exported types ------------------------------------------------------------*/
|
||||||
|
/* Exported constants --------------------------------------------------------*/
|
||||||
|
|
||||||
|
/* ########################## Module Selection ############################## */
|
||||||
|
/**
|
||||||
|
* @brief This is the list of modules to be used in the HAL driver
|
||||||
|
*/
|
||||||
|
#define HAL_MODULE_ENABLED
|
||||||
|
|
||||||
|
/* #define HAL_CRYP_MODULE_ENABLED */
|
||||||
|
#define HAL_ADC_MODULE_ENABLED
|
||||||
|
#define HAL_CAN_MODULE_ENABLED
|
||||||
|
/* #define HAL_CRC_MODULE_ENABLED */
|
||||||
|
/* #define HAL_CAN_LEGACY_MODULE_ENABLED */
|
||||||
|
/* #define HAL_DAC_MODULE_ENABLED */
|
||||||
|
/* #define HAL_DCMI_MODULE_ENABLED */
|
||||||
|
/* #define HAL_DMA2D_MODULE_ENABLED */
|
||||||
|
/* #define HAL_ETH_MODULE_ENABLED */
|
||||||
|
/* #define HAL_ETH_LEGACY_MODULE_ENABLED */
|
||||||
|
/* #define HAL_NAND_MODULE_ENABLED */
|
||||||
|
/* #define HAL_NOR_MODULE_ENABLED */
|
||||||
|
/* #define HAL_PCCARD_MODULE_ENABLED */
|
||||||
|
/* #define HAL_SRAM_MODULE_ENABLED */
|
||||||
|
/* #define HAL_SDRAM_MODULE_ENABLED */
|
||||||
|
/* #define HAL_HASH_MODULE_ENABLED */
|
||||||
|
/* #define HAL_I2C_MODULE_ENABLED */
|
||||||
|
/* #define HAL_I2S_MODULE_ENABLED */
|
||||||
|
/* #define HAL_IWDG_MODULE_ENABLED */
|
||||||
|
/* #define HAL_LTDC_MODULE_ENABLED */
|
||||||
|
/* #define HAL_RNG_MODULE_ENABLED */
|
||||||
|
/* #define HAL_RTC_MODULE_ENABLED */
|
||||||
|
/* #define HAL_SAI_MODULE_ENABLED */
|
||||||
|
/* #define HAL_SD_MODULE_ENABLED */
|
||||||
|
/* #define HAL_MMC_MODULE_ENABLED */
|
||||||
|
#define HAL_SPI_MODULE_ENABLED
|
||||||
|
#define HAL_TIM_MODULE_ENABLED
|
||||||
|
#define HAL_UART_MODULE_ENABLED
|
||||||
|
/* #define HAL_USART_MODULE_ENABLED */
|
||||||
|
/* #define HAL_IRDA_MODULE_ENABLED */
|
||||||
|
/* #define HAL_SMARTCARD_MODULE_ENABLED */
|
||||||
|
/* #define HAL_SMBUS_MODULE_ENABLED */
|
||||||
|
/* #define HAL_WWDG_MODULE_ENABLED */
|
||||||
|
/* #define HAL_PCD_MODULE_ENABLED */
|
||||||
|
/* #define HAL_HCD_MODULE_ENABLED */
|
||||||
|
/* #define HAL_DSI_MODULE_ENABLED */
|
||||||
|
/* #define HAL_QSPI_MODULE_ENABLED */
|
||||||
|
/* #define HAL_QSPI_MODULE_ENABLED */
|
||||||
|
/* #define HAL_CEC_MODULE_ENABLED */
|
||||||
|
/* #define HAL_FMPI2C_MODULE_ENABLED */
|
||||||
|
/* #define HAL_FMPSMBUS_MODULE_ENABLED */
|
||||||
|
/* #define HAL_SPDIFRX_MODULE_ENABLED */
|
||||||
|
/* #define HAL_DFSDM_MODULE_ENABLED */
|
||||||
|
/* #define HAL_LPTIM_MODULE_ENABLED */
|
||||||
|
#define HAL_GPIO_MODULE_ENABLED
|
||||||
|
#define HAL_EXTI_MODULE_ENABLED
|
||||||
|
#define HAL_DMA_MODULE_ENABLED
|
||||||
|
#define HAL_RCC_MODULE_ENABLED
|
||||||
|
#define HAL_FLASH_MODULE_ENABLED
|
||||||
|
#define HAL_PWR_MODULE_ENABLED
|
||||||
|
#define HAL_CORTEX_MODULE_ENABLED
|
||||||
|
|
||||||
|
/* ########################## HSE/HSI Values adaptation ##################### */
|
||||||
|
/**
|
||||||
|
* @brief Adjust the value of External High Speed oscillator (HSE) used in your application.
|
||||||
|
* This value is used by the RCC HAL module to compute the system frequency
|
||||||
|
* (when HSE is used as system clock source, directly or through the PLL).
|
||||||
|
*/
|
||||||
|
#if !defined (HSE_VALUE)
|
||||||
|
#define HSE_VALUE 8000000U /*!< Value of the External oscillator in Hz */
|
||||||
|
#endif /* HSE_VALUE */
|
||||||
|
|
||||||
|
#if !defined (HSE_STARTUP_TIMEOUT)
|
||||||
|
#define HSE_STARTUP_TIMEOUT 100U /*!< Time out for HSE start up, in ms */
|
||||||
|
#endif /* HSE_STARTUP_TIMEOUT */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Internal High Speed oscillator (HSI) value.
|
||||||
|
* This value is used by the RCC HAL module to compute the system frequency
|
||||||
|
* (when HSI is used as system clock source, directly or through the PLL).
|
||||||
|
*/
|
||||||
|
#if !defined (HSI_VALUE)
|
||||||
|
#define HSI_VALUE ((uint32_t)16000000U) /*!< Value of the Internal oscillator in Hz*/
|
||||||
|
#endif /* HSI_VALUE */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Internal Low Speed oscillator (LSI) value.
|
||||||
|
*/
|
||||||
|
#if !defined (LSI_VALUE)
|
||||||
|
#define LSI_VALUE 32000U /*!< LSI Typical Value in Hz*/
|
||||||
|
#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz
|
||||||
|
The real value may vary depending on the variations
|
||||||
|
in voltage and temperature.*/
|
||||||
|
/**
|
||||||
|
* @brief External Low Speed oscillator (LSE) value.
|
||||||
|
*/
|
||||||
|
#if !defined (LSE_VALUE)
|
||||||
|
#define LSE_VALUE 32768U /*!< Value of the External Low Speed oscillator in Hz */
|
||||||
|
#endif /* LSE_VALUE */
|
||||||
|
|
||||||
|
#if !defined (LSE_STARTUP_TIMEOUT)
|
||||||
|
#define LSE_STARTUP_TIMEOUT 5000U /*!< Time out for LSE start up, in ms */
|
||||||
|
#endif /* LSE_STARTUP_TIMEOUT */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief External clock source for I2S peripheral
|
||||||
|
* This value is used by the I2S HAL module to compute the I2S clock source
|
||||||
|
* frequency, this source is inserted directly through I2S_CKIN pad.
|
||||||
|
*/
|
||||||
|
#if !defined (EXTERNAL_CLOCK_VALUE)
|
||||||
|
#define EXTERNAL_CLOCK_VALUE 12288000U /*!< Value of the External audio frequency in Hz*/
|
||||||
|
#endif /* EXTERNAL_CLOCK_VALUE */
|
||||||
|
|
||||||
|
/* Tip: To avoid modifying this file each time you need to use different HSE,
|
||||||
|
=== you can define the HSE value in your toolchain compiler preprocessor. */
|
||||||
|
|
||||||
|
/* ########################### System Configuration ######################### */
|
||||||
|
/**
|
||||||
|
* @brief This is the HAL system configuration section
|
||||||
|
*/
|
||||||
|
#define VDD_VALUE 3300U /*!< Value of VDD in mv */
|
||||||
|
#define TICK_INT_PRIORITY 5U /*!< tick interrupt priority */
|
||||||
|
#define USE_RTOS 0U
|
||||||
|
#define PREFETCH_ENABLE 1U
|
||||||
|
#define INSTRUCTION_CACHE_ENABLE 1U
|
||||||
|
#define DATA_CACHE_ENABLE 1U
|
||||||
|
|
||||||
|
#define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */
|
||||||
|
#define USE_HAL_CAN_REGISTER_CALLBACKS 0U /* CAN register callback disabled */
|
||||||
|
#define USE_HAL_CEC_REGISTER_CALLBACKS 0U /* CEC register callback disabled */
|
||||||
|
#define USE_HAL_CRYP_REGISTER_CALLBACKS 0U /* CRYP register callback disabled */
|
||||||
|
#define USE_HAL_DAC_REGISTER_CALLBACKS 0U /* DAC register callback disabled */
|
||||||
|
#define USE_HAL_DCMI_REGISTER_CALLBACKS 0U /* DCMI register callback disabled */
|
||||||
|
#define USE_HAL_DFSDM_REGISTER_CALLBACKS 0U /* DFSDM register callback disabled */
|
||||||
|
#define USE_HAL_DMA2D_REGISTER_CALLBACKS 0U /* DMA2D register callback disabled */
|
||||||
|
#define USE_HAL_DSI_REGISTER_CALLBACKS 0U /* DSI register callback disabled */
|
||||||
|
#define USE_HAL_ETH_REGISTER_CALLBACKS 0U /* ETH register callback disabled */
|
||||||
|
#define USE_HAL_HASH_REGISTER_CALLBACKS 0U /* HASH register callback disabled */
|
||||||
|
#define USE_HAL_HCD_REGISTER_CALLBACKS 0U /* HCD register callback disabled */
|
||||||
|
#define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */
|
||||||
|
#define USE_HAL_FMPI2C_REGISTER_CALLBACKS 0U /* FMPI2C register callback disabled */
|
||||||
|
#define USE_HAL_FMPSMBUS_REGISTER_CALLBACKS 0U /* FMPSMBUS register callback disabled */
|
||||||
|
#define USE_HAL_I2S_REGISTER_CALLBACKS 0U /* I2S register callback disabled */
|
||||||
|
#define USE_HAL_IRDA_REGISTER_CALLBACKS 0U /* IRDA register callback disabled */
|
||||||
|
#define USE_HAL_LPTIM_REGISTER_CALLBACKS 0U /* LPTIM register callback disabled */
|
||||||
|
#define USE_HAL_LTDC_REGISTER_CALLBACKS 0U /* LTDC register callback disabled */
|
||||||
|
#define USE_HAL_MMC_REGISTER_CALLBACKS 0U /* MMC register callback disabled */
|
||||||
|
#define USE_HAL_NAND_REGISTER_CALLBACKS 0U /* NAND register callback disabled */
|
||||||
|
#define USE_HAL_NOR_REGISTER_CALLBACKS 0U /* NOR register callback disabled */
|
||||||
|
#define USE_HAL_PCCARD_REGISTER_CALLBACKS 0U /* PCCARD register callback disabled */
|
||||||
|
#define USE_HAL_PCD_REGISTER_CALLBACKS 0U /* PCD register callback disabled */
|
||||||
|
#define USE_HAL_QSPI_REGISTER_CALLBACKS 0U /* QSPI register callback disabled */
|
||||||
|
#define USE_HAL_RNG_REGISTER_CALLBACKS 0U /* RNG register callback disabled */
|
||||||
|
#define USE_HAL_RTC_REGISTER_CALLBACKS 0U /* RTC register callback disabled */
|
||||||
|
#define USE_HAL_SAI_REGISTER_CALLBACKS 0U /* SAI register callback disabled */
|
||||||
|
#define USE_HAL_SD_REGISTER_CALLBACKS 0U /* SD register callback disabled */
|
||||||
|
#define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U /* SMARTCARD register callback disabled */
|
||||||
|
#define USE_HAL_SDRAM_REGISTER_CALLBACKS 0U /* SDRAM register callback disabled */
|
||||||
|
#define USE_HAL_SRAM_REGISTER_CALLBACKS 0U /* SRAM register callback disabled */
|
||||||
|
#define USE_HAL_SPDIFRX_REGISTER_CALLBACKS 0U /* SPDIFRX register callback disabled */
|
||||||
|
#define USE_HAL_SMBUS_REGISTER_CALLBACKS 0U /* SMBUS register callback disabled */
|
||||||
|
#define USE_HAL_SPI_REGISTER_CALLBACKS 0U /* SPI register callback disabled */
|
||||||
|
#define USE_HAL_TIM_REGISTER_CALLBACKS 0U /* TIM register callback disabled */
|
||||||
|
#define USE_HAL_UART_REGISTER_CALLBACKS 0U /* UART register callback disabled */
|
||||||
|
#define USE_HAL_USART_REGISTER_CALLBACKS 0U /* USART register callback disabled */
|
||||||
|
#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */
|
||||||
|
|
||||||
|
/* ########################## Assert Selection ############################## */
|
||||||
|
/**
|
||||||
|
* @brief Uncomment the line below to expanse the "assert_param" macro in the
|
||||||
|
* HAL drivers code
|
||||||
|
*/
|
||||||
|
/* #define USE_FULL_ASSERT 1U */
|
||||||
|
|
||||||
|
/* ################## Ethernet peripheral configuration ##################### */
|
||||||
|
|
||||||
|
/* Section 1 : Ethernet peripheral configuration */
|
||||||
|
|
||||||
|
/* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */
|
||||||
|
#define MAC_ADDR0 2U
|
||||||
|
#define MAC_ADDR1 0U
|
||||||
|
#define MAC_ADDR2 0U
|
||||||
|
#define MAC_ADDR3 0U
|
||||||
|
#define MAC_ADDR4 0U
|
||||||
|
#define MAC_ADDR5 0U
|
||||||
|
|
||||||
|
/* Definition of the Ethernet driver buffers size and count */
|
||||||
|
#define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */
|
||||||
|
#define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */
|
||||||
|
#define ETH_RXBUFNB 4U /* 4 Rx buffers of size ETH_RX_BUF_SIZE */
|
||||||
|
#define ETH_TXBUFNB 4U /* 4 Tx buffers of size ETH_TX_BUF_SIZE */
|
||||||
|
|
||||||
|
/* Section 2: PHY configuration section */
|
||||||
|
|
||||||
|
/* DP83848_PHY_ADDRESS Address*/
|
||||||
|
#define DP83848_PHY_ADDRESS
|
||||||
|
/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/
|
||||||
|
#define PHY_RESET_DELAY 0x000000FFU
|
||||||
|
/* PHY Configuration delay */
|
||||||
|
#define PHY_CONFIG_DELAY 0x00000FFFU
|
||||||
|
|
||||||
|
#define PHY_READ_TO 0x0000FFFFU
|
||||||
|
#define PHY_WRITE_TO 0x0000FFFFU
|
||||||
|
|
||||||
|
/* Section 3: Common PHY Registers */
|
||||||
|
|
||||||
|
#define PHY_BCR ((uint16_t)0x0000U) /*!< Transceiver Basic Control Register */
|
||||||
|
#define PHY_BSR ((uint16_t)0x0001U) /*!< Transceiver Basic Status Register */
|
||||||
|
|
||||||
|
#define PHY_RESET ((uint16_t)0x8000U) /*!< PHY Reset */
|
||||||
|
#define PHY_LOOPBACK ((uint16_t)0x4000U) /*!< Select loop-back mode */
|
||||||
|
#define PHY_FULLDUPLEX_100M ((uint16_t)0x2100U) /*!< Set the full-duplex mode at 100 Mb/s */
|
||||||
|
#define PHY_HALFDUPLEX_100M ((uint16_t)0x2000U) /*!< Set the half-duplex mode at 100 Mb/s */
|
||||||
|
#define PHY_FULLDUPLEX_10M ((uint16_t)0x0100U) /*!< Set the full-duplex mode at 10 Mb/s */
|
||||||
|
#define PHY_HALFDUPLEX_10M ((uint16_t)0x0000U) /*!< Set the half-duplex mode at 10 Mb/s */
|
||||||
|
#define PHY_AUTONEGOTIATION ((uint16_t)0x1000U) /*!< Enable auto-negotiation function */
|
||||||
|
#define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200U) /*!< Restart auto-negotiation function */
|
||||||
|
#define PHY_POWERDOWN ((uint16_t)0x0800U) /*!< Select the power down mode */
|
||||||
|
#define PHY_ISOLATE ((uint16_t)0x0400U) /*!< Isolate PHY from MII */
|
||||||
|
|
||||||
|
#define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020U) /*!< Auto-Negotiation process completed */
|
||||||
|
#define PHY_LINKED_STATUS ((uint16_t)0x0004U) /*!< Valid link established */
|
||||||
|
#define PHY_JABBER_DETECTION ((uint16_t)0x0002U) /*!< Jabber condition detected */
|
||||||
|
|
||||||
|
/* Section 4: Extended PHY Registers */
|
||||||
|
#define PHY_SR ((uint16_t)) /*!< PHY status register Offset */
|
||||||
|
|
||||||
|
#define PHY_SPEED_STATUS ((uint16_t)) /*!< PHY Speed mask */
|
||||||
|
#define PHY_DUPLEX_STATUS ((uint16_t)) /*!< PHY Duplex mask */
|
||||||
|
|
||||||
|
/* ################## SPI peripheral configuration ########################## */
|
||||||
|
|
||||||
|
/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver
|
||||||
|
* Activated: CRC code is present inside driver
|
||||||
|
* Deactivated: CRC code cleaned from driver
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define USE_SPI_CRC 0U
|
||||||
|
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
/**
|
||||||
|
* @brief Include module's header file
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAL_RCC_MODULE_ENABLED
|
||||||
|
#include "stm32f4xx_hal_rcc.h"
|
||||||
|
#endif /* HAL_RCC_MODULE_ENABLED */
|
||||||
|
|
||||||
|
#ifdef HAL_GPIO_MODULE_ENABLED
|
||||||
|
#include "stm32f4xx_hal_gpio.h"
|
||||||
|
#endif /* HAL_GPIO_MODULE_ENABLED */
|
||||||
|
|
||||||
|
#ifdef HAL_EXTI_MODULE_ENABLED
|
||||||
|
#include "stm32f4xx_hal_exti.h"
|
||||||
|
#endif /* HAL_EXTI_MODULE_ENABLED */
|
||||||
|
|
||||||
|
#ifdef HAL_DMA_MODULE_ENABLED
|
||||||
|
#include "stm32f4xx_hal_dma.h"
|
||||||
|
#endif /* HAL_DMA_MODULE_ENABLED */
|
||||||
|
|
||||||
|
#ifdef HAL_CORTEX_MODULE_ENABLED
|
||||||
|
#include "stm32f4xx_hal_cortex.h"
|
||||||
|
#endif /* HAL_CORTEX_MODULE_ENABLED */
|
||||||
|
|
||||||
|
#ifdef HAL_ADC_MODULE_ENABLED
|
||||||
|
#include "stm32f4xx_hal_adc.h"
|
||||||
|
#endif /* HAL_ADC_MODULE_ENABLED */
|
||||||
|
|
||||||
|
#ifdef HAL_CAN_MODULE_ENABLED
|
||||||
|
#include "stm32f4xx_hal_can.h"
|
||||||
|
#endif /* HAL_CAN_MODULE_ENABLED */
|
||||||
|
|
||||||
|
#ifdef HAL_CAN_LEGACY_MODULE_ENABLED
|
||||||
|
#include "stm32f4xx_hal_can_legacy.h"
|
||||||
|
#endif /* HAL_CAN_LEGACY_MODULE_ENABLED */
|
||||||
|
|
||||||
|
#ifdef HAL_CRC_MODULE_ENABLED
|
||||||
|
#include "stm32f4xx_hal_crc.h"
|
||||||
|
#endif /* HAL_CRC_MODULE_ENABLED */
|
||||||
|
|
||||||
|
#ifdef HAL_CRYP_MODULE_ENABLED
|
||||||
|
#include "stm32f4xx_hal_cryp.h"
|
||||||
|
#endif /* HAL_CRYP_MODULE_ENABLED */
|
||||||
|
|
||||||
|
#ifdef HAL_DMA2D_MODULE_ENABLED
|
||||||
|
#include "stm32f4xx_hal_dma2d.h"
|
||||||
|
#endif /* HAL_DMA2D_MODULE_ENABLED */
|
||||||
|
|
||||||
|
#ifdef HAL_DAC_MODULE_ENABLED
|
||||||
|
#include "stm32f4xx_hal_dac.h"
|
||||||
|
#endif /* HAL_DAC_MODULE_ENABLED */
|
||||||
|
|
||||||
|
#ifdef HAL_DCMI_MODULE_ENABLED
|
||||||
|
#include "stm32f4xx_hal_dcmi.h"
|
||||||
|
#endif /* HAL_DCMI_MODULE_ENABLED */
|
||||||
|
|
||||||
|
#ifdef HAL_ETH_MODULE_ENABLED
|
||||||
|
#include "stm32f4xx_hal_eth.h"
|
||||||
|
#endif /* HAL_ETH_MODULE_ENABLED */
|
||||||
|
|
||||||
|
#ifdef HAL_ETH_LEGACY_MODULE_ENABLED
|
||||||
|
#include "stm32f4xx_hal_eth_legacy.h"
|
||||||
|
#endif /* HAL_ETH_LEGACY_MODULE_ENABLED */
|
||||||
|
|
||||||
|
#ifdef HAL_FLASH_MODULE_ENABLED
|
||||||
|
#include "stm32f4xx_hal_flash.h"
|
||||||
|
#endif /* HAL_FLASH_MODULE_ENABLED */
|
||||||
|
|
||||||
|
#ifdef HAL_SRAM_MODULE_ENABLED
|
||||||
|
#include "stm32f4xx_hal_sram.h"
|
||||||
|
#endif /* HAL_SRAM_MODULE_ENABLED */
|
||||||
|
|
||||||
|
#ifdef HAL_NOR_MODULE_ENABLED
|
||||||
|
#include "stm32f4xx_hal_nor.h"
|
||||||
|
#endif /* HAL_NOR_MODULE_ENABLED */
|
||||||
|
|
||||||
|
#ifdef HAL_NAND_MODULE_ENABLED
|
||||||
|
#include "stm32f4xx_hal_nand.h"
|
||||||
|
#endif /* HAL_NAND_MODULE_ENABLED */
|
||||||
|
|
||||||
|
#ifdef HAL_PCCARD_MODULE_ENABLED
|
||||||
|
#include "stm32f4xx_hal_pccard.h"
|
||||||
|
#endif /* HAL_PCCARD_MODULE_ENABLED */
|
||||||
|
|
||||||
|
#ifdef HAL_SDRAM_MODULE_ENABLED
|
||||||
|
#include "stm32f4xx_hal_sdram.h"
|
||||||
|
#endif /* HAL_SDRAM_MODULE_ENABLED */
|
||||||
|
|
||||||
|
#ifdef HAL_HASH_MODULE_ENABLED
|
||||||
|
#include "stm32f4xx_hal_hash.h"
|
||||||
|
#endif /* HAL_HASH_MODULE_ENABLED */
|
||||||
|
|
||||||
|
#ifdef HAL_I2C_MODULE_ENABLED
|
||||||
|
#include "stm32f4xx_hal_i2c.h"
|
||||||
|
#endif /* HAL_I2C_MODULE_ENABLED */
|
||||||
|
|
||||||
|
#ifdef HAL_SMBUS_MODULE_ENABLED
|
||||||
|
#include "stm32f4xx_hal_smbus.h"
|
||||||
|
#endif /* HAL_SMBUS_MODULE_ENABLED */
|
||||||
|
|
||||||
|
#ifdef HAL_I2S_MODULE_ENABLED
|
||||||
|
#include "stm32f4xx_hal_i2s.h"
|
||||||
|
#endif /* HAL_I2S_MODULE_ENABLED */
|
||||||
|
|
||||||
|
#ifdef HAL_IWDG_MODULE_ENABLED
|
||||||
|
#include "stm32f4xx_hal_iwdg.h"
|
||||||
|
#endif /* HAL_IWDG_MODULE_ENABLED */
|
||||||
|
|
||||||
|
#ifdef HAL_LTDC_MODULE_ENABLED
|
||||||
|
#include "stm32f4xx_hal_ltdc.h"
|
||||||
|
#endif /* HAL_LTDC_MODULE_ENABLED */
|
||||||
|
|
||||||
|
#ifdef HAL_PWR_MODULE_ENABLED
|
||||||
|
#include "stm32f4xx_hal_pwr.h"
|
||||||
|
#endif /* HAL_PWR_MODULE_ENABLED */
|
||||||
|
|
||||||
|
#ifdef HAL_RNG_MODULE_ENABLED
|
||||||
|
#include "stm32f4xx_hal_rng.h"
|
||||||
|
#endif /* HAL_RNG_MODULE_ENABLED */
|
||||||
|
|
||||||
|
#ifdef HAL_RTC_MODULE_ENABLED
|
||||||
|
#include "stm32f4xx_hal_rtc.h"
|
||||||
|
#endif /* HAL_RTC_MODULE_ENABLED */
|
||||||
|
|
||||||
|
#ifdef HAL_SAI_MODULE_ENABLED
|
||||||
|
#include "stm32f4xx_hal_sai.h"
|
||||||
|
#endif /* HAL_SAI_MODULE_ENABLED */
|
||||||
|
|
||||||
|
#ifdef HAL_SD_MODULE_ENABLED
|
||||||
|
#include "stm32f4xx_hal_sd.h"
|
||||||
|
#endif /* HAL_SD_MODULE_ENABLED */
|
||||||
|
|
||||||
|
#ifdef HAL_SPI_MODULE_ENABLED
|
||||||
|
#include "stm32f4xx_hal_spi.h"
|
||||||
|
#endif /* HAL_SPI_MODULE_ENABLED */
|
||||||
|
|
||||||
|
#ifdef HAL_TIM_MODULE_ENABLED
|
||||||
|
#include "stm32f4xx_hal_tim.h"
|
||||||
|
#endif /* HAL_TIM_MODULE_ENABLED */
|
||||||
|
|
||||||
|
#ifdef HAL_UART_MODULE_ENABLED
|
||||||
|
#include "stm32f4xx_hal_uart.h"
|
||||||
|
#endif /* HAL_UART_MODULE_ENABLED */
|
||||||
|
|
||||||
|
#ifdef HAL_USART_MODULE_ENABLED
|
||||||
|
#include "stm32f4xx_hal_usart.h"
|
||||||
|
#endif /* HAL_USART_MODULE_ENABLED */
|
||||||
|
|
||||||
|
#ifdef HAL_IRDA_MODULE_ENABLED
|
||||||
|
#include "stm32f4xx_hal_irda.h"
|
||||||
|
#endif /* HAL_IRDA_MODULE_ENABLED */
|
||||||
|
|
||||||
|
#ifdef HAL_SMARTCARD_MODULE_ENABLED
|
||||||
|
#include "stm32f4xx_hal_smartcard.h"
|
||||||
|
#endif /* HAL_SMARTCARD_MODULE_ENABLED */
|
||||||
|
|
||||||
|
#ifdef HAL_WWDG_MODULE_ENABLED
|
||||||
|
#include "stm32f4xx_hal_wwdg.h"
|
||||||
|
#endif /* HAL_WWDG_MODULE_ENABLED */
|
||||||
|
|
||||||
|
#ifdef HAL_PCD_MODULE_ENABLED
|
||||||
|
#include "stm32f4xx_hal_pcd.h"
|
||||||
|
#endif /* HAL_PCD_MODULE_ENABLED */
|
||||||
|
|
||||||
|
#ifdef HAL_HCD_MODULE_ENABLED
|
||||||
|
#include "stm32f4xx_hal_hcd.h"
|
||||||
|
#endif /* HAL_HCD_MODULE_ENABLED */
|
||||||
|
|
||||||
|
#ifdef HAL_DSI_MODULE_ENABLED
|
||||||
|
#include "stm32f4xx_hal_dsi.h"
|
||||||
|
#endif /* HAL_DSI_MODULE_ENABLED */
|
||||||
|
|
||||||
|
#ifdef HAL_QSPI_MODULE_ENABLED
|
||||||
|
#include "stm32f4xx_hal_qspi.h"
|
||||||
|
#endif /* HAL_QSPI_MODULE_ENABLED */
|
||||||
|
|
||||||
|
#ifdef HAL_CEC_MODULE_ENABLED
|
||||||
|
#include "stm32f4xx_hal_cec.h"
|
||||||
|
#endif /* HAL_CEC_MODULE_ENABLED */
|
||||||
|
|
||||||
|
#ifdef HAL_FMPI2C_MODULE_ENABLED
|
||||||
|
#include "stm32f4xx_hal_fmpi2c.h"
|
||||||
|
#endif /* HAL_FMPI2C_MODULE_ENABLED */
|
||||||
|
|
||||||
|
#ifdef HAL_FMPSMBUS_MODULE_ENABLED
|
||||||
|
#include "stm32f4xx_hal_fmpsmbus.h"
|
||||||
|
#endif /* HAL_FMPSMBUS_MODULE_ENABLED */
|
||||||
|
|
||||||
|
#ifdef HAL_SPDIFRX_MODULE_ENABLED
|
||||||
|
#include "stm32f4xx_hal_spdifrx.h"
|
||||||
|
#endif /* HAL_SPDIFRX_MODULE_ENABLED */
|
||||||
|
|
||||||
|
#ifdef HAL_DFSDM_MODULE_ENABLED
|
||||||
|
#include "stm32f4xx_hal_dfsdm.h"
|
||||||
|
#endif /* HAL_DFSDM_MODULE_ENABLED */
|
||||||
|
|
||||||
|
#ifdef HAL_LPTIM_MODULE_ENABLED
|
||||||
|
#include "stm32f4xx_hal_lptim.h"
|
||||||
|
#endif /* HAL_LPTIM_MODULE_ENABLED */
|
||||||
|
|
||||||
|
#ifdef HAL_MMC_MODULE_ENABLED
|
||||||
|
#include "stm32f4xx_hal_mmc.h"
|
||||||
|
#endif /* HAL_MMC_MODULE_ENABLED */
|
||||||
|
|
||||||
|
/* Exported macro ------------------------------------------------------------*/
|
||||||
|
#ifdef USE_FULL_ASSERT
|
||||||
|
/**
|
||||||
|
* @brief The assert_param macro is used for function's parameters check.
|
||||||
|
* @param expr If expr is false, it calls assert_failed function
|
||||||
|
* which reports the name of the source file and the source
|
||||||
|
* line number of the call that failed.
|
||||||
|
* If expr is true, it returns no value.
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
#define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__))
|
||||||
|
/* Exported functions ------------------------------------------------------- */
|
||||||
|
void assert_failed(uint8_t* file, uint32_t line);
|
||||||
|
#else
|
||||||
|
#define assert_param(expr) ((void)0U)
|
||||||
|
#endif /* USE_FULL_ASSERT */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __STM32F4xx_HAL_CONF_H */
|
67
core/inc/stm32f4xx_it.h
Normal file
67
core/inc/stm32f4xx_it.h
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
/* USER CODE BEGIN Header */
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file stm32f4xx_it.h
|
||||||
|
* @brief This file contains the headers of the interrupt handlers.
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* Copyright (c) 2024 STMicroelectronics.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This software is licensed under terms that can be found in the LICENSE file
|
||||||
|
* in the root directory of this software component.
|
||||||
|
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
/* USER CODE END Header */
|
||||||
|
|
||||||
|
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||||
|
#ifndef __STM32F4xx_IT_H
|
||||||
|
#define __STM32F4xx_IT_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Private includes ----------------------------------------------------------*/
|
||||||
|
/* USER CODE BEGIN Includes */
|
||||||
|
|
||||||
|
/* USER CODE END Includes */
|
||||||
|
|
||||||
|
/* Exported types ------------------------------------------------------------*/
|
||||||
|
/* USER CODE BEGIN ET */
|
||||||
|
|
||||||
|
/* USER CODE END ET */
|
||||||
|
|
||||||
|
/* Exported constants --------------------------------------------------------*/
|
||||||
|
/* USER CODE BEGIN EC */
|
||||||
|
|
||||||
|
/* USER CODE END EC */
|
||||||
|
|
||||||
|
/* Exported macro ------------------------------------------------------------*/
|
||||||
|
/* USER CODE BEGIN EM */
|
||||||
|
|
||||||
|
/* USER CODE END EM */
|
||||||
|
|
||||||
|
/* Exported functions prototypes ---------------------------------------------*/
|
||||||
|
void NMI_Handler(void);
|
||||||
|
void HardFault_Handler(void);
|
||||||
|
void MemManage_Handler(void);
|
||||||
|
void BusFault_Handler(void);
|
||||||
|
void UsageFault_Handler(void);
|
||||||
|
void DebugMon_Handler(void);
|
||||||
|
void CAN1_RX0_IRQHandler(void);
|
||||||
|
void CAN1_RX1_IRQHandler(void);
|
||||||
|
void TIM1_UP_TIM10_IRQHandler(void);
|
||||||
|
void DMA2_Stream0_IRQHandler(void);
|
||||||
|
/* USER CODE BEGIN EFP */
|
||||||
|
|
||||||
|
/* USER CODE END EFP */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __STM32F4xx_IT_H */
|
54
core/inc/tim.h
Normal file
54
core/inc/tim.h
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
/* USER CODE BEGIN Header */
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file tim.h
|
||||||
|
* @brief This file contains all the function prototypes for
|
||||||
|
* the tim.c file
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* Copyright (c) 2024 STMicroelectronics.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This software is licensed under terms that can be found in the LICENSE file
|
||||||
|
* in the root directory of this software component.
|
||||||
|
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
/* USER CODE END Header */
|
||||||
|
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||||
|
#ifndef __TIM_H__
|
||||||
|
#define __TIM_H__
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "main.h"
|
||||||
|
|
||||||
|
/* USER CODE BEGIN Includes */
|
||||||
|
|
||||||
|
/* USER CODE END Includes */
|
||||||
|
|
||||||
|
extern TIM_HandleTypeDef htim3;
|
||||||
|
|
||||||
|
/* USER CODE BEGIN Private defines */
|
||||||
|
|
||||||
|
/* USER CODE END Private defines */
|
||||||
|
|
||||||
|
void MX_TIM3_Init(void);
|
||||||
|
|
||||||
|
void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim);
|
||||||
|
|
||||||
|
/* USER CODE BEGIN Prototypes */
|
||||||
|
|
||||||
|
/* USER CODE END Prototypes */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __TIM_H__ */
|
||||||
|
|
52
core/inc/usart.h
Normal file
52
core/inc/usart.h
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
/* USER CODE BEGIN Header */
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file usart.h
|
||||||
|
* @brief This file contains all the function prototypes for
|
||||||
|
* the usart.c file
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* Copyright (c) 2024 STMicroelectronics.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This software is licensed under terms that can be found in the LICENSE file
|
||||||
|
* in the root directory of this software component.
|
||||||
|
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
/* USER CODE END Header */
|
||||||
|
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||||
|
#ifndef __USART_H__
|
||||||
|
#define __USART_H__
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "main.h"
|
||||||
|
|
||||||
|
/* USER CODE BEGIN Includes */
|
||||||
|
|
||||||
|
/* USER CODE END Includes */
|
||||||
|
|
||||||
|
extern UART_HandleTypeDef huart1;
|
||||||
|
|
||||||
|
/* USER CODE BEGIN Private defines */
|
||||||
|
|
||||||
|
/* USER CODE END Private defines */
|
||||||
|
|
||||||
|
void MX_USART1_UART_Init(void);
|
||||||
|
|
||||||
|
/* USER CODE BEGIN Prototypes */
|
||||||
|
|
||||||
|
/* USER CODE END Prototypes */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __USART_H__ */
|
||||||
|
|
221
core/src/adc.c
Normal file
221
core/src/adc.c
Normal file
@ -0,0 +1,221 @@
|
|||||||
|
/* USER CODE BEGIN Header */
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file adc.c
|
||||||
|
* @brief This file provides code for the configuration
|
||||||
|
* of the ADC instances.
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* Copyright (c) 2024 STMicroelectronics.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This software is licensed under terms that can be found in the LICENSE file
|
||||||
|
* in the root directory of this software component.
|
||||||
|
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
/* USER CODE END Header */
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "adc.h"
|
||||||
|
|
||||||
|
/* USER CODE BEGIN 0 */
|
||||||
|
|
||||||
|
/* USER CODE END 0 */
|
||||||
|
|
||||||
|
ADC_HandleTypeDef hadc1;
|
||||||
|
DMA_HandleTypeDef hdma_adc1;
|
||||||
|
|
||||||
|
/* ADC1 init function */
|
||||||
|
void MX_ADC1_Init(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
/* USER CODE BEGIN ADC1_Init 0 */
|
||||||
|
|
||||||
|
/* USER CODE END ADC1_Init 0 */
|
||||||
|
|
||||||
|
ADC_ChannelConfTypeDef sConfig = {0};
|
||||||
|
|
||||||
|
/* USER CODE BEGIN ADC1_Init 1 */
|
||||||
|
|
||||||
|
/* USER CODE END ADC1_Init 1 */
|
||||||
|
|
||||||
|
/** Configure the global features of the ADC (Clock, Resolution, Data Alignment and number of conversion)
|
||||||
|
*/
|
||||||
|
hadc1.Instance = ADC1;
|
||||||
|
hadc1.Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV2;
|
||||||
|
hadc1.Init.Resolution = ADC_RESOLUTION_12B;
|
||||||
|
hadc1.Init.ScanConvMode = ENABLE;
|
||||||
|
hadc1.Init.ContinuousConvMode = DISABLE;
|
||||||
|
hadc1.Init.DiscontinuousConvMode = DISABLE;
|
||||||
|
hadc1.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_RISING;
|
||||||
|
hadc1.Init.ExternalTrigConv = ADC_EXTERNALTRIGCONV_T3_TRGO;
|
||||||
|
hadc1.Init.DataAlign = ADC_DATAALIGN_RIGHT;
|
||||||
|
hadc1.Init.NbrOfConversion = 6;
|
||||||
|
hadc1.Init.DMAContinuousRequests = DISABLE;
|
||||||
|
hadc1.Init.EOCSelection = ADC_EOC_SINGLE_CONV;
|
||||||
|
if (HAL_ADC_Init(&hadc1) != HAL_OK)
|
||||||
|
{
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time.
|
||||||
|
*/
|
||||||
|
sConfig.Channel = ADC_CHANNEL_9;
|
||||||
|
sConfig.Rank = 1;
|
||||||
|
sConfig.SamplingTime = ADC_SAMPLETIME_480CYCLES;
|
||||||
|
if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
|
||||||
|
{
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time.
|
||||||
|
*/
|
||||||
|
sConfig.Channel = ADC_CHANNEL_8;
|
||||||
|
sConfig.Rank = 2;
|
||||||
|
if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
|
||||||
|
{
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time.
|
||||||
|
*/
|
||||||
|
sConfig.Channel = ADC_CHANNEL_14;
|
||||||
|
sConfig.Rank = 3;
|
||||||
|
if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
|
||||||
|
{
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time.
|
||||||
|
*/
|
||||||
|
sConfig.Channel = ADC_CHANNEL_2;
|
||||||
|
sConfig.Rank = 4;
|
||||||
|
if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
|
||||||
|
{
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time.
|
||||||
|
*/
|
||||||
|
sConfig.Channel = ADC_CHANNEL_8;
|
||||||
|
sConfig.Rank = 5;
|
||||||
|
if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
|
||||||
|
{
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time.
|
||||||
|
*/
|
||||||
|
sConfig.Channel = ADC_CHANNEL_9;
|
||||||
|
sConfig.Rank = 6;
|
||||||
|
if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
|
||||||
|
{
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
/* USER CODE BEGIN ADC1_Init 2 */
|
||||||
|
|
||||||
|
/* USER CODE END ADC1_Init 2 */
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void HAL_ADC_MspInit(ADC_HandleTypeDef* adcHandle)
|
||||||
|
{
|
||||||
|
|
||||||
|
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
||||||
|
if(adcHandle->Instance==ADC1)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN ADC1_MspInit 0 */
|
||||||
|
|
||||||
|
/* USER CODE END ADC1_MspInit 0 */
|
||||||
|
/* ADC1 clock enable */
|
||||||
|
__HAL_RCC_ADC1_CLK_ENABLE();
|
||||||
|
|
||||||
|
__HAL_RCC_GPIOC_CLK_ENABLE();
|
||||||
|
__HAL_RCC_GPIOA_CLK_ENABLE();
|
||||||
|
__HAL_RCC_GPIOB_CLK_ENABLE();
|
||||||
|
/**ADC1 GPIO Configuration
|
||||||
|
PC0 ------> ADC1_IN10
|
||||||
|
PC1 ------> ADC1_IN11
|
||||||
|
PA2 ------> ADC1_IN2
|
||||||
|
PC4 ------> ADC1_IN14
|
||||||
|
PB0 ------> ADC1_IN8
|
||||||
|
PB1 ------> ADC1_IN9
|
||||||
|
*/
|
||||||
|
GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_4;
|
||||||
|
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
|
||||||
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||||
|
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
GPIO_InitStruct.Pin = GPIO_PIN_2;
|
||||||
|
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
|
||||||
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||||
|
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1;
|
||||||
|
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
|
||||||
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||||
|
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
/* ADC1 DMA Init */
|
||||||
|
/* ADC1 Init */
|
||||||
|
hdma_adc1.Instance = DMA2_Stream0;
|
||||||
|
hdma_adc1.Init.Channel = DMA_CHANNEL_0;
|
||||||
|
hdma_adc1.Init.Direction = DMA_PERIPH_TO_MEMORY;
|
||||||
|
hdma_adc1.Init.PeriphInc = DMA_PINC_DISABLE;
|
||||||
|
hdma_adc1.Init.MemInc = DMA_MINC_ENABLE;
|
||||||
|
hdma_adc1.Init.PeriphDataAlignment = DMA_PDATAALIGN_HALFWORD;
|
||||||
|
hdma_adc1.Init.MemDataAlignment = DMA_MDATAALIGN_HALFWORD;
|
||||||
|
hdma_adc1.Init.Mode = DMA_CIRCULAR;
|
||||||
|
hdma_adc1.Init.Priority = DMA_PRIORITY_LOW;
|
||||||
|
hdma_adc1.Init.FIFOMode = DMA_FIFOMODE_DISABLE;
|
||||||
|
if (HAL_DMA_Init(&hdma_adc1) != HAL_OK)
|
||||||
|
{
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
|
||||||
|
__HAL_LINKDMA(adcHandle,DMA_Handle,hdma_adc1);
|
||||||
|
|
||||||
|
/* USER CODE BEGIN ADC1_MspInit 1 */
|
||||||
|
|
||||||
|
/* USER CODE END ADC1_MspInit 1 */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void HAL_ADC_MspDeInit(ADC_HandleTypeDef* adcHandle)
|
||||||
|
{
|
||||||
|
|
||||||
|
if(adcHandle->Instance==ADC1)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN ADC1_MspDeInit 0 */
|
||||||
|
|
||||||
|
/* USER CODE END ADC1_MspDeInit 0 */
|
||||||
|
/* Peripheral clock disable */
|
||||||
|
__HAL_RCC_ADC1_CLK_DISABLE();
|
||||||
|
|
||||||
|
/**ADC1 GPIO Configuration
|
||||||
|
PC0 ------> ADC1_IN10
|
||||||
|
PC1 ------> ADC1_IN11
|
||||||
|
PA2 ------> ADC1_IN2
|
||||||
|
PC4 ------> ADC1_IN14
|
||||||
|
PB0 ------> ADC1_IN8
|
||||||
|
PB1 ------> ADC1_IN9
|
||||||
|
*/
|
||||||
|
HAL_GPIO_DeInit(GPIOC, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_4);
|
||||||
|
|
||||||
|
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_2);
|
||||||
|
|
||||||
|
HAL_GPIO_DeInit(GPIOB, GPIO_PIN_0|GPIO_PIN_1);
|
||||||
|
|
||||||
|
/* ADC1 DMA DeInit */
|
||||||
|
HAL_DMA_DeInit(adcHandle->DMA_Handle);
|
||||||
|
/* USER CODE BEGIN ADC1_MspDeInit 1 */
|
||||||
|
|
||||||
|
/* USER CODE END ADC1_MspDeInit 1 */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* USER CODE BEGIN 1 */
|
||||||
|
|
||||||
|
/* USER CODE END 1 */
|
125
core/src/can.c
Normal file
125
core/src/can.c
Normal file
@ -0,0 +1,125 @@
|
|||||||
|
/* USER CODE BEGIN Header */
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file can.c
|
||||||
|
* @brief This file provides code for the configuration
|
||||||
|
* of the CAN instances.
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* Copyright (c) 2024 STMicroelectronics.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This software is licensed under terms that can be found in the LICENSE file
|
||||||
|
* in the root directory of this software component.
|
||||||
|
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
/* USER CODE END Header */
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "can.h"
|
||||||
|
|
||||||
|
/* USER CODE BEGIN 0 */
|
||||||
|
|
||||||
|
/* USER CODE END 0 */
|
||||||
|
|
||||||
|
CAN_HandleTypeDef hcan1;
|
||||||
|
|
||||||
|
/* CAN1 init function */
|
||||||
|
void MX_CAN1_Init(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
/* USER CODE BEGIN CAN1_Init 0 */
|
||||||
|
|
||||||
|
/* USER CODE END CAN1_Init 0 */
|
||||||
|
|
||||||
|
/* USER CODE BEGIN CAN1_Init 1 */
|
||||||
|
|
||||||
|
/* USER CODE END CAN1_Init 1 */
|
||||||
|
hcan1.Instance = CAN1;
|
||||||
|
hcan1.Init.Prescaler = 8;
|
||||||
|
hcan1.Init.Mode = CAN_MODE_NORMAL;
|
||||||
|
hcan1.Init.SyncJumpWidth = CAN_SJW_1TQ;
|
||||||
|
hcan1.Init.TimeSeg1 = CAN_BS1_2TQ;
|
||||||
|
hcan1.Init.TimeSeg2 = CAN_BS2_7TQ;
|
||||||
|
hcan1.Init.TimeTriggeredMode = DISABLE;
|
||||||
|
hcan1.Init.AutoBusOff = DISABLE;
|
||||||
|
hcan1.Init.AutoWakeUp = DISABLE;
|
||||||
|
hcan1.Init.AutoRetransmission = ENABLE;
|
||||||
|
hcan1.Init.ReceiveFifoLocked = DISABLE;
|
||||||
|
hcan1.Init.TransmitFifoPriority = DISABLE;
|
||||||
|
if (HAL_CAN_Init(&hcan1) != HAL_OK)
|
||||||
|
{
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
/* USER CODE BEGIN CAN1_Init 2 */
|
||||||
|
|
||||||
|
/* USER CODE END CAN1_Init 2 */
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void HAL_CAN_MspInit(CAN_HandleTypeDef* canHandle)
|
||||||
|
{
|
||||||
|
|
||||||
|
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
||||||
|
if(canHandle->Instance==CAN1)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN CAN1_MspInit 0 */
|
||||||
|
|
||||||
|
/* USER CODE END CAN1_MspInit 0 */
|
||||||
|
/* CAN1 clock enable */
|
||||||
|
__HAL_RCC_CAN1_CLK_ENABLE();
|
||||||
|
|
||||||
|
__HAL_RCC_GPIOA_CLK_ENABLE();
|
||||||
|
/**CAN1 GPIO Configuration
|
||||||
|
PA11 ------> CAN1_RX
|
||||||
|
PA12 ------> CAN1_TX
|
||||||
|
*/
|
||||||
|
GPIO_InitStruct.Pin = GPIO_PIN_11|GPIO_PIN_12;
|
||||||
|
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||||
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||||
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
||||||
|
GPIO_InitStruct.Alternate = GPIO_AF9_CAN1;
|
||||||
|
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
/* CAN1 interrupt Init */
|
||||||
|
HAL_NVIC_SetPriority(CAN1_RX0_IRQn, 5, 0);
|
||||||
|
HAL_NVIC_EnableIRQ(CAN1_RX0_IRQn);
|
||||||
|
HAL_NVIC_SetPriority(CAN1_RX1_IRQn, 5, 0);
|
||||||
|
HAL_NVIC_EnableIRQ(CAN1_RX1_IRQn);
|
||||||
|
/* USER CODE BEGIN CAN1_MspInit 1 */
|
||||||
|
|
||||||
|
/* USER CODE END CAN1_MspInit 1 */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void HAL_CAN_MspDeInit(CAN_HandleTypeDef* canHandle)
|
||||||
|
{
|
||||||
|
|
||||||
|
if(canHandle->Instance==CAN1)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN CAN1_MspDeInit 0 */
|
||||||
|
|
||||||
|
/* USER CODE END CAN1_MspDeInit 0 */
|
||||||
|
/* Peripheral clock disable */
|
||||||
|
__HAL_RCC_CAN1_CLK_DISABLE();
|
||||||
|
|
||||||
|
/**CAN1 GPIO Configuration
|
||||||
|
PA11 ------> CAN1_RX
|
||||||
|
PA12 ------> CAN1_TX
|
||||||
|
*/
|
||||||
|
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_11|GPIO_PIN_12);
|
||||||
|
|
||||||
|
/* CAN1 interrupt Deinit */
|
||||||
|
HAL_NVIC_DisableIRQ(CAN1_RX0_IRQn);
|
||||||
|
HAL_NVIC_DisableIRQ(CAN1_RX1_IRQn);
|
||||||
|
/* USER CODE BEGIN CAN1_MspDeInit 1 */
|
||||||
|
|
||||||
|
/* USER CODE END CAN1_MspDeInit 1 */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* USER CODE BEGIN 1 */
|
||||||
|
|
||||||
|
/* USER CODE END 1 */
|
55
core/src/dma.c
Normal file
55
core/src/dma.c
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
/* USER CODE BEGIN Header */
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file dma.c
|
||||||
|
* @brief This file provides code for the configuration
|
||||||
|
* of all the requested memory to memory DMA transfers.
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* Copyright (c) 2024 STMicroelectronics.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This software is licensed under terms that can be found in the LICENSE file
|
||||||
|
* in the root directory of this software component.
|
||||||
|
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
/* USER CODE END Header */
|
||||||
|
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "dma.h"
|
||||||
|
|
||||||
|
/* USER CODE BEGIN 0 */
|
||||||
|
|
||||||
|
/* USER CODE END 0 */
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------------*/
|
||||||
|
/* Configure DMA */
|
||||||
|
/*----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/* USER CODE BEGIN 1 */
|
||||||
|
|
||||||
|
/* USER CODE END 1 */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enable DMA controller clock
|
||||||
|
*/
|
||||||
|
void MX_DMA_Init(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
/* DMA controller clock enable */
|
||||||
|
__HAL_RCC_DMA2_CLK_ENABLE();
|
||||||
|
|
||||||
|
/* DMA interrupt init */
|
||||||
|
/* DMA2_Stream0_IRQn interrupt configuration */
|
||||||
|
HAL_NVIC_SetPriority(DMA2_Stream0_IRQn, 5, 0);
|
||||||
|
HAL_NVIC_EnableIRQ(DMA2_Stream0_IRQn);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* USER CODE BEGIN 2 */
|
||||||
|
|
||||||
|
/* USER CODE END 2 */
|
||||||
|
|
159
core/src/freertos.c
Normal file
159
core/src/freertos.c
Normal file
@ -0,0 +1,159 @@
|
|||||||
|
/* USER CODE BEGIN Header */
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* File Name : freertos.c
|
||||||
|
* Description : Code for freertos applications
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* Copyright (c) 2024 STMicroelectronics.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This software is licensed under terms that can be found in the LICENSE file
|
||||||
|
* in the root directory of this software component.
|
||||||
|
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
/* USER CODE END Header */
|
||||||
|
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "FreeRTOS.h"
|
||||||
|
#include "task.h"
|
||||||
|
#include "main.h"
|
||||||
|
#include "cmsis_os.h"
|
||||||
|
|
||||||
|
/* Private includes ----------------------------------------------------------*/
|
||||||
|
/* USER CODE BEGIN Includes */
|
||||||
|
|
||||||
|
/* USER CODE END Includes */
|
||||||
|
|
||||||
|
/* Private typedef -----------------------------------------------------------*/
|
||||||
|
/* USER CODE BEGIN PTD */
|
||||||
|
|
||||||
|
/* USER CODE END PTD */
|
||||||
|
|
||||||
|
/* Private define ------------------------------------------------------------*/
|
||||||
|
/* USER CODE BEGIN PD */
|
||||||
|
|
||||||
|
/* USER CODE END PD */
|
||||||
|
|
||||||
|
/* Private macro -------------------------------------------------------------*/
|
||||||
|
/* USER CODE BEGIN PM */
|
||||||
|
|
||||||
|
/* USER CODE END PM */
|
||||||
|
|
||||||
|
/* Private variables ---------------------------------------------------------*/
|
||||||
|
/* USER CODE BEGIN Variables */
|
||||||
|
|
||||||
|
/* USER CODE END Variables */
|
||||||
|
/* Definitions for defaultTask */
|
||||||
|
osThreadId_t defaultTaskHandle;
|
||||||
|
const osThreadAttr_t defaultTask_attributes = {
|
||||||
|
.name = "defaultTask",
|
||||||
|
.stack_size = 1024 * 4,
|
||||||
|
.priority = (osPriority_t) osPriorityNormal,
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Private function prototypes -----------------------------------------------*/
|
||||||
|
/* USER CODE BEGIN FunctionPrototypes */
|
||||||
|
|
||||||
|
/* USER CODE END FunctionPrototypes */
|
||||||
|
|
||||||
|
void StartDefaultTask(void *argument);
|
||||||
|
|
||||||
|
void MX_FREERTOS_Init(void); /* (MISRA C 2004 rule 8.1) */
|
||||||
|
|
||||||
|
/* Hook prototypes */
|
||||||
|
void configureTimerForRunTimeStats(void);
|
||||||
|
unsigned long getRunTimeCounterValue(void);
|
||||||
|
void vApplicationStackOverflowHook(xTaskHandle xTask, signed char *pcTaskName);
|
||||||
|
|
||||||
|
/* USER CODE BEGIN 1 */
|
||||||
|
/* Functions needed when configGENERATE_RUN_TIME_STATS is on */
|
||||||
|
__weak void configureTimerForRunTimeStats(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
__weak unsigned long getRunTimeCounterValue(void)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* USER CODE END 1 */
|
||||||
|
|
||||||
|
/* USER CODE BEGIN 4 */
|
||||||
|
void vApplicationStackOverflowHook(xTaskHandle xTask, signed char *pcTaskName)
|
||||||
|
{
|
||||||
|
/* Run time stack overflow checking is performed if
|
||||||
|
configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook function is
|
||||||
|
called if a stack overflow is detected. */
|
||||||
|
}
|
||||||
|
/* USER CODE END 4 */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief FreeRTOS initialization
|
||||||
|
* @param None
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
void MX_FREERTOS_Init(void) {
|
||||||
|
/* USER CODE BEGIN Init */
|
||||||
|
|
||||||
|
/* USER CODE END Init */
|
||||||
|
|
||||||
|
/* USER CODE BEGIN RTOS_MUTEX */
|
||||||
|
/* add mutexes, ... */
|
||||||
|
/* USER CODE END RTOS_MUTEX */
|
||||||
|
|
||||||
|
/* USER CODE BEGIN RTOS_SEMAPHORES */
|
||||||
|
/* add semaphores, ... */
|
||||||
|
/* USER CODE END RTOS_SEMAPHORES */
|
||||||
|
|
||||||
|
/* USER CODE BEGIN RTOS_TIMERS */
|
||||||
|
/* start timers, add new ones, ... */
|
||||||
|
/* USER CODE END RTOS_TIMERS */
|
||||||
|
|
||||||
|
/* USER CODE BEGIN RTOS_QUEUES */
|
||||||
|
/* add queues, ... */
|
||||||
|
/* USER CODE END RTOS_QUEUES */
|
||||||
|
|
||||||
|
/* Create the thread(s) */
|
||||||
|
/* creation of defaultTask */
|
||||||
|
defaultTaskHandle = osThreadNew(StartDefaultTask, NULL, &defaultTask_attributes);
|
||||||
|
|
||||||
|
/* USER CODE BEGIN RTOS_THREADS */
|
||||||
|
/* add threads, ... */
|
||||||
|
/* USER CODE END RTOS_THREADS */
|
||||||
|
|
||||||
|
/* USER CODE BEGIN RTOS_EVENTS */
|
||||||
|
/* add events, ... */
|
||||||
|
/* USER CODE END RTOS_EVENTS */
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* USER CODE BEGIN Header_StartDefaultTask */
|
||||||
|
/**
|
||||||
|
* @brief Function implementing the defaultTask thread.
|
||||||
|
* @param argument: Not used
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
/* USER CODE END Header_StartDefaultTask */
|
||||||
|
void StartDefaultTask(void *argument)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN StartDefaultTask */
|
||||||
|
/* Infinite loop */
|
||||||
|
|
||||||
|
extern void startTACOS(void *);
|
||||||
|
startTACOS(argument);
|
||||||
|
for(;;)
|
||||||
|
{
|
||||||
|
osDelay(1);
|
||||||
|
}
|
||||||
|
/* USER CODE END StartDefaultTask */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Private application code --------------------------------------------------*/
|
||||||
|
/* USER CODE BEGIN Application */
|
||||||
|
|
||||||
|
/* USER CODE END Application */
|
||||||
|
|
157
core/src/gpio.c
Normal file
157
core/src/gpio.c
Normal file
@ -0,0 +1,157 @@
|
|||||||
|
/* USER CODE BEGIN Header */
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file gpio.c
|
||||||
|
* @brief This file provides code for the configuration
|
||||||
|
* of all used GPIO pins.
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* Copyright (c) 2024 STMicroelectronics.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This software is licensed under terms that can be found in the LICENSE file
|
||||||
|
* in the root directory of this software component.
|
||||||
|
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
/* USER CODE END Header */
|
||||||
|
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "gpio.h"
|
||||||
|
|
||||||
|
/* USER CODE BEGIN 0 */
|
||||||
|
|
||||||
|
/* USER CODE END 0 */
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------------*/
|
||||||
|
/* Configure GPIO */
|
||||||
|
/*----------------------------------------------------------------------------*/
|
||||||
|
/* USER CODE BEGIN 1 */
|
||||||
|
|
||||||
|
/* USER CODE END 1 */
|
||||||
|
|
||||||
|
/** Configure pins as
|
||||||
|
* Analog
|
||||||
|
* Input
|
||||||
|
* Output
|
||||||
|
* EVENT_OUT
|
||||||
|
* EXTI
|
||||||
|
*/
|
||||||
|
void MX_GPIO_Init(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
||||||
|
|
||||||
|
/* GPIO Ports Clock Enable */
|
||||||
|
__HAL_RCC_GPIOH_CLK_ENABLE();
|
||||||
|
__HAL_RCC_GPIOC_CLK_ENABLE();
|
||||||
|
__HAL_RCC_GPIOA_CLK_ENABLE();
|
||||||
|
__HAL_RCC_GPIOB_CLK_ENABLE();
|
||||||
|
__HAL_RCC_GPIOF_CLK_ENABLE();
|
||||||
|
__HAL_RCC_GPIOG_CLK_ENABLE();
|
||||||
|
__HAL_RCC_GPIOE_CLK_ENABLE();
|
||||||
|
__HAL_RCC_GPIOD_CLK_ENABLE();
|
||||||
|
|
||||||
|
/*Configure GPIO pin Output Level */
|
||||||
|
HAL_GPIO_WritePin(GPIOA, C_short_Pin|C_arm_Pin|C_fire_Pin, GPIO_PIN_RESET);
|
||||||
|
|
||||||
|
/*Configure GPIO pin Output Level */
|
||||||
|
HAL_GPIO_WritePin(B_short_GPIO_Port, B_short_Pin, GPIO_PIN_RESET);
|
||||||
|
|
||||||
|
/*Configure GPIO pin Output Level */
|
||||||
|
HAL_GPIO_WritePin(GPIOG, A_arm_Pin|F_short_Pin|F_arm_Pin|F_fire_Pin, GPIO_PIN_RESET);
|
||||||
|
|
||||||
|
/*Configure GPIO pin Output Level */
|
||||||
|
HAL_GPIO_WritePin(GPIOE, A_fire_Pin|A_short_Pin|A_armE15_Pin|D_arm_Pin
|
||||||
|
|D_fire_Pin, GPIO_PIN_RESET);
|
||||||
|
|
||||||
|
/*Configure GPIO pin Output Level */
|
||||||
|
HAL_GPIO_WritePin(GPIOB, A_fireB10_Pin|E_short_Pin|E_arm_Pin|E_fire_Pin
|
||||||
|
|D_short_Pin, GPIO_PIN_RESET);
|
||||||
|
|
||||||
|
/*Configure GPIO pin Output Level */
|
||||||
|
HAL_GPIO_WritePin(GPIOD, GPIO_PIN_0|GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10, GPIO_PIN_RESET);
|
||||||
|
|
||||||
|
/*Configure GPIO pins : PA3 PAPin */
|
||||||
|
GPIO_InitStruct.Pin = GPIO_PIN_3|C_sense_Pin;
|
||||||
|
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
||||||
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||||
|
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
/*Configure GPIO pins : PAPin PAPin PAPin */
|
||||||
|
GPIO_InitStruct.Pin = C_short_Pin|C_arm_Pin|C_fire_Pin;
|
||||||
|
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||||
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||||
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||||
|
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
/*Configure GPIO pin : PtPin */
|
||||||
|
GPIO_InitStruct.Pin = B_short_Pin;
|
||||||
|
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||||
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||||
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||||
|
HAL_GPIO_Init(B_short_GPIO_Port, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
/*Configure GPIO pin : PtPin */
|
||||||
|
GPIO_InitStruct.Pin = B_sense_Pin;
|
||||||
|
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
||||||
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||||
|
HAL_GPIO_Init(B_sense_GPIO_Port, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
/*Configure GPIO pins : PGPin PGPin PGPin PGPin */
|
||||||
|
GPIO_InitStruct.Pin = A_arm_Pin|F_short_Pin|F_arm_Pin|F_fire_Pin;
|
||||||
|
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||||
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||||
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||||
|
HAL_GPIO_Init(GPIOG, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
/*Configure GPIO pins : PEPin PEPin PEPin PEPin
|
||||||
|
PEPin */
|
||||||
|
GPIO_InitStruct.Pin = A_fire_Pin|A_short_Pin|A_armE15_Pin|D_arm_Pin
|
||||||
|
|D_fire_Pin;
|
||||||
|
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||||
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||||
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||||
|
HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
/*Configure GPIO pin : PtPin */
|
||||||
|
GPIO_InitStruct.Pin = A_sense_Pin;
|
||||||
|
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
||||||
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||||
|
HAL_GPIO_Init(A_sense_GPIO_Port, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
/*Configure GPIO pins : PBPin PBPin PBPin PBPin
|
||||||
|
PBPin */
|
||||||
|
GPIO_InitStruct.Pin = A_fireB10_Pin|E_short_Pin|E_arm_Pin|E_fire_Pin
|
||||||
|
|D_short_Pin;
|
||||||
|
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||||
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||||
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||||
|
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
/*Configure GPIO pin : PD0 */
|
||||||
|
GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10;
|
||||||
|
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||||
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||||
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||||
|
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
/*Configure GPIO pin : PtPin */
|
||||||
|
GPIO_InitStruct.Pin = F_sense_Pin;
|
||||||
|
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
||||||
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||||
|
HAL_GPIO_Init(F_sense_GPIO_Port, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
/*Configure GPIO pins : PBPin PBPin */
|
||||||
|
GPIO_InitStruct.Pin = E_sense_Pin|D_sense_Pin;
|
||||||
|
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
||||||
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||||
|
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* USER CODE BEGIN 2 */
|
||||||
|
|
||||||
|
/* USER CODE END 2 */
|
232
core/src/main.c
Normal file
232
core/src/main.c
Normal file
@ -0,0 +1,232 @@
|
|||||||
|
/* USER CODE BEGIN Header */
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file : main.c
|
||||||
|
* @brief : Main program body
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* Copyright (c) 2024 STMicroelectronics.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This software is licensed under terms that can be found in the LICENSE file
|
||||||
|
* in the root directory of this software component.
|
||||||
|
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
/* USER CODE END Header */
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "main.h"
|
||||||
|
#include "cmsis_os.h"
|
||||||
|
#include "adc.h"
|
||||||
|
#include "can.h"
|
||||||
|
#include "dma.h"
|
||||||
|
#include "spi.h"
|
||||||
|
#include "tim.h"
|
||||||
|
#include "usart.h"
|
||||||
|
#include "gpio.h"
|
||||||
|
|
||||||
|
/* Private includes ----------------------------------------------------------*/
|
||||||
|
/* USER CODE BEGIN Includes */
|
||||||
|
#include <sta/config.hpp>
|
||||||
|
/* USER CODE END Includes */
|
||||||
|
|
||||||
|
/* Private typedef -----------------------------------------------------------*/
|
||||||
|
/* USER CODE BEGIN PTD */
|
||||||
|
|
||||||
|
/* USER CODE END PTD */
|
||||||
|
|
||||||
|
/* Private define ------------------------------------------------------------*/
|
||||||
|
/* USER CODE BEGIN PD */
|
||||||
|
|
||||||
|
/* USER CODE END PD */
|
||||||
|
|
||||||
|
/* Private macro -------------------------------------------------------------*/
|
||||||
|
/* USER CODE BEGIN PM */
|
||||||
|
|
||||||
|
/* USER CODE END PM */
|
||||||
|
|
||||||
|
/* Private variables ---------------------------------------------------------*/
|
||||||
|
|
||||||
|
/* USER CODE BEGIN PV */
|
||||||
|
|
||||||
|
/* USER CODE END PV */
|
||||||
|
|
||||||
|
/* Private function prototypes -----------------------------------------------*/
|
||||||
|
void SystemClock_Config(void);
|
||||||
|
void MX_FREERTOS_Init(void);
|
||||||
|
/* USER CODE BEGIN PFP */
|
||||||
|
|
||||||
|
/* USER CODE END PFP */
|
||||||
|
|
||||||
|
/* Private user code ---------------------------------------------------------*/
|
||||||
|
/* USER CODE BEGIN 0 */
|
||||||
|
|
||||||
|
/* USER CODE END 0 */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief The application entry point.
|
||||||
|
* @retval int
|
||||||
|
*/
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
/* USER CODE BEGIN 1 */
|
||||||
|
|
||||||
|
/* USER CODE END 1 */
|
||||||
|
|
||||||
|
/* MCU Configuration--------------------------------------------------------*/
|
||||||
|
|
||||||
|
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
|
||||||
|
HAL_Init();
|
||||||
|
|
||||||
|
/* USER CODE BEGIN Init */
|
||||||
|
|
||||||
|
/* USER CODE END Init */
|
||||||
|
|
||||||
|
/* Configure the system clock */
|
||||||
|
SystemClock_Config();
|
||||||
|
|
||||||
|
/* USER CODE BEGIN SysInit */
|
||||||
|
|
||||||
|
/* USER CODE END SysInit */
|
||||||
|
|
||||||
|
/* Initialize all configured peripherals */
|
||||||
|
MX_GPIO_Init();
|
||||||
|
MX_DMA_Init();
|
||||||
|
MX_CAN1_Init();
|
||||||
|
MX_USART1_UART_Init();
|
||||||
|
MX_SPI2_Init();
|
||||||
|
MX_ADC1_Init();
|
||||||
|
MX_TIM3_Init();
|
||||||
|
MX_SPI3_Init();
|
||||||
|
/* USER CODE BEGIN 2 */
|
||||||
|
|
||||||
|
/* USER CODE END 2 */
|
||||||
|
|
||||||
|
/* Init scheduler */
|
||||||
|
osKernelInitialize();
|
||||||
|
|
||||||
|
/* Call init function for freertos objects (in cmsis_os2.c) */
|
||||||
|
MX_FREERTOS_Init();
|
||||||
|
|
||||||
|
/* Start scheduler */
|
||||||
|
osKernelStart();
|
||||||
|
|
||||||
|
/* We should never get here as control is now taken by the scheduler */
|
||||||
|
|
||||||
|
/* Infinite loop */
|
||||||
|
/* USER CODE BEGIN WHILE */
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
/* USER CODE END WHILE */
|
||||||
|
|
||||||
|
/* USER CODE BEGIN 3 */
|
||||||
|
}
|
||||||
|
/* USER CODE END 3 */
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief System Clock Configuration
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
void SystemClock_Config(void)
|
||||||
|
{
|
||||||
|
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
|
||||||
|
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
|
||||||
|
|
||||||
|
/** Configure the main internal regulator output voltage
|
||||||
|
*/
|
||||||
|
__HAL_RCC_PWR_CLK_ENABLE();
|
||||||
|
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
|
||||||
|
|
||||||
|
/** Initializes the RCC Oscillators according to the specified parameters
|
||||||
|
* in the RCC_OscInitTypeDef structure.
|
||||||
|
*/
|
||||||
|
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
|
||||||
|
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
|
||||||
|
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
|
||||||
|
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
|
||||||
|
RCC_OscInitStruct.PLL.PLLM = 4;
|
||||||
|
RCC_OscInitStruct.PLL.PLLN = 168;
|
||||||
|
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
|
||||||
|
RCC_OscInitStruct.PLL.PLLQ = 4;
|
||||||
|
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
|
||||||
|
{
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Initializes the CPU, AHB and APB buses clocks
|
||||||
|
*/
|
||||||
|
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
|
||||||
|
|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
|
||||||
|
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
|
||||||
|
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
|
||||||
|
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;
|
||||||
|
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;
|
||||||
|
|
||||||
|
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5) != HAL_OK)
|
||||||
|
{
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* USER CODE BEGIN 4 */
|
||||||
|
|
||||||
|
/* USER CODE END 4 */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Period elapsed callback in non blocking mode
|
||||||
|
* @note This function is called when TIM1 interrupt took place, inside
|
||||||
|
* HAL_TIM_IRQHandler(). It makes a direct call to HAL_IncTick() to increment
|
||||||
|
* a global variable "uwTick" used as application time base.
|
||||||
|
* @param htim : TIM handle
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN Callback 0 */
|
||||||
|
|
||||||
|
/* USER CODE END Callback 0 */
|
||||||
|
if (htim->Instance == TIM1) {
|
||||||
|
HAL_IncTick();
|
||||||
|
}
|
||||||
|
/* USER CODE BEGIN Callback 1 */
|
||||||
|
|
||||||
|
/* USER CODE END Callback 1 */
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This function is executed in case of error occurrence.
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
void Error_Handler(void)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN Error_Handler_Debug */
|
||||||
|
/* User can add his own implementation to report the HAL error return state */
|
||||||
|
#ifdef STA_ASSERT_ENABLED
|
||||||
|
__disable_irq();
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
/* USER CODE END Error_Handler_Debug */
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef USE_FULL_ASSERT
|
||||||
|
/**
|
||||||
|
* @brief Reports the name of the source file and the source line number
|
||||||
|
* where the assert_param error has occurred.
|
||||||
|
* @param file: pointer to the source file name
|
||||||
|
* @param line: assert_param error line source number
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
void assert_failed(uint8_t *file, uint32_t line)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN 6 */
|
||||||
|
/* User can add his own implementation to report the file name and line number,
|
||||||
|
ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
|
||||||
|
/* USER CODE END 6 */
|
||||||
|
}
|
||||||
|
#endif /* USE_FULL_ASSERT */
|
196
core/src/spi.c
Normal file
196
core/src/spi.c
Normal file
@ -0,0 +1,196 @@
|
|||||||
|
/* USER CODE BEGIN Header */
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file spi.c
|
||||||
|
* @brief This file provides code for the configuration
|
||||||
|
* of the SPI instances.
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* Copyright (c) 2024 STMicroelectronics.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This software is licensed under terms that can be found in the LICENSE file
|
||||||
|
* in the root directory of this software component.
|
||||||
|
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
/* USER CODE END Header */
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "spi.h"
|
||||||
|
|
||||||
|
/* USER CODE BEGIN 0 */
|
||||||
|
|
||||||
|
/* USER CODE END 0 */
|
||||||
|
|
||||||
|
SPI_HandleTypeDef hspi2;
|
||||||
|
SPI_HandleTypeDef hspi3;
|
||||||
|
|
||||||
|
/* SPI2 init function */
|
||||||
|
void MX_SPI2_Init(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
/* USER CODE BEGIN SPI2_Init 0 */
|
||||||
|
|
||||||
|
/* USER CODE END SPI2_Init 0 */
|
||||||
|
|
||||||
|
/* USER CODE BEGIN SPI2_Init 1 */
|
||||||
|
|
||||||
|
/* USER CODE END SPI2_Init 1 */
|
||||||
|
hspi2.Instance = SPI2;
|
||||||
|
hspi2.Init.Mode = SPI_MODE_MASTER;
|
||||||
|
hspi2.Init.Direction = SPI_DIRECTION_2LINES;
|
||||||
|
hspi2.Init.DataSize = SPI_DATASIZE_8BIT;
|
||||||
|
hspi2.Init.CLKPolarity = SPI_POLARITY_LOW;
|
||||||
|
hspi2.Init.CLKPhase = SPI_PHASE_1EDGE;
|
||||||
|
hspi2.Init.NSS = SPI_NSS_SOFT;
|
||||||
|
hspi2.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_2;
|
||||||
|
hspi2.Init.FirstBit = SPI_FIRSTBIT_MSB;
|
||||||
|
hspi2.Init.TIMode = SPI_TIMODE_DISABLE;
|
||||||
|
hspi2.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
|
||||||
|
hspi2.Init.CRCPolynomial = 10;
|
||||||
|
if (HAL_SPI_Init(&hspi2) != HAL_OK)
|
||||||
|
{
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
/* USER CODE BEGIN SPI2_Init 2 */
|
||||||
|
|
||||||
|
/* USER CODE END SPI2_Init 2 */
|
||||||
|
|
||||||
|
}
|
||||||
|
/* SPI3 init function */
|
||||||
|
void MX_SPI3_Init(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
/* USER CODE BEGIN SPI3_Init 0 */
|
||||||
|
|
||||||
|
/* USER CODE END SPI3_Init 0 */
|
||||||
|
|
||||||
|
/* USER CODE BEGIN SPI3_Init 1 */
|
||||||
|
|
||||||
|
/* USER CODE END SPI3_Init 1 */
|
||||||
|
hspi3.Instance = SPI3;
|
||||||
|
hspi3.Init.Mode = SPI_MODE_MASTER;
|
||||||
|
hspi3.Init.Direction = SPI_DIRECTION_2LINES;
|
||||||
|
hspi3.Init.DataSize = SPI_DATASIZE_8BIT;
|
||||||
|
hspi3.Init.CLKPolarity = SPI_POLARITY_LOW;
|
||||||
|
hspi3.Init.CLKPhase = SPI_PHASE_1EDGE;
|
||||||
|
hspi3.Init.NSS = SPI_NSS_SOFT;
|
||||||
|
hspi3.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_2;
|
||||||
|
hspi3.Init.FirstBit = SPI_FIRSTBIT_MSB;
|
||||||
|
hspi3.Init.TIMode = SPI_TIMODE_DISABLE;
|
||||||
|
hspi3.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
|
||||||
|
hspi3.Init.CRCPolynomial = 10;
|
||||||
|
if (HAL_SPI_Init(&hspi3) != HAL_OK)
|
||||||
|
{
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
/* USER CODE BEGIN SPI3_Init 2 */
|
||||||
|
|
||||||
|
/* USER CODE END SPI3_Init 2 */
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void HAL_SPI_MspInit(SPI_HandleTypeDef* spiHandle)
|
||||||
|
{
|
||||||
|
|
||||||
|
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
||||||
|
if(spiHandle->Instance==SPI2)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN SPI2_MspInit 0 */
|
||||||
|
|
||||||
|
/* USER CODE END SPI2_MspInit 0 */
|
||||||
|
/* SPI2 clock enable */
|
||||||
|
__HAL_RCC_SPI2_CLK_ENABLE();
|
||||||
|
|
||||||
|
__HAL_RCC_GPIOB_CLK_ENABLE();
|
||||||
|
/**SPI2 GPIO Configuration
|
||||||
|
PB13 ------> SPI2_SCK
|
||||||
|
PB14 ------> SPI2_MISO
|
||||||
|
PB15 ------> SPI2_MOSI
|
||||||
|
*/
|
||||||
|
GPIO_InitStruct.Pin = GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15;
|
||||||
|
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||||
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||||
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
||||||
|
GPIO_InitStruct.Alternate = GPIO_AF5_SPI2;
|
||||||
|
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
/* USER CODE BEGIN SPI2_MspInit 1 */
|
||||||
|
|
||||||
|
/* USER CODE END SPI2_MspInit 1 */
|
||||||
|
}
|
||||||
|
else if(spiHandle->Instance==SPI3)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN SPI3_MspInit 0 */
|
||||||
|
|
||||||
|
/* USER CODE END SPI3_MspInit 0 */
|
||||||
|
/* SPI3 clock enable */
|
||||||
|
__HAL_RCC_SPI3_CLK_ENABLE();
|
||||||
|
|
||||||
|
__HAL_RCC_GPIOC_CLK_ENABLE();
|
||||||
|
/**SPI3 GPIO Configuration
|
||||||
|
PC10 ------> SPI3_SCK
|
||||||
|
PC11 ------> SPI3_MISO
|
||||||
|
PC12 ------> SPI3_MOSI
|
||||||
|
*/
|
||||||
|
GPIO_InitStruct.Pin = GPIO_PIN_10|GPIO_PIN_11|GPIO_PIN_12;
|
||||||
|
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||||
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||||
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
||||||
|
GPIO_InitStruct.Alternate = GPIO_AF6_SPI3;
|
||||||
|
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
/* USER CODE BEGIN SPI3_MspInit 1 */
|
||||||
|
|
||||||
|
/* USER CODE END SPI3_MspInit 1 */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void HAL_SPI_MspDeInit(SPI_HandleTypeDef* spiHandle)
|
||||||
|
{
|
||||||
|
|
||||||
|
if(spiHandle->Instance==SPI2)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN SPI2_MspDeInit 0 */
|
||||||
|
|
||||||
|
/* USER CODE END SPI2_MspDeInit 0 */
|
||||||
|
/* Peripheral clock disable */
|
||||||
|
__HAL_RCC_SPI2_CLK_DISABLE();
|
||||||
|
|
||||||
|
/**SPI2 GPIO Configuration
|
||||||
|
PB13 ------> SPI2_SCK
|
||||||
|
PB14 ------> SPI2_MISO
|
||||||
|
PB15 ------> SPI2_MOSI
|
||||||
|
*/
|
||||||
|
HAL_GPIO_DeInit(GPIOB, GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15);
|
||||||
|
|
||||||
|
/* USER CODE BEGIN SPI2_MspDeInit 1 */
|
||||||
|
|
||||||
|
/* USER CODE END SPI2_MspDeInit 1 */
|
||||||
|
}
|
||||||
|
else if(spiHandle->Instance==SPI3)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN SPI3_MspDeInit 0 */
|
||||||
|
|
||||||
|
/* USER CODE END SPI3_MspDeInit 0 */
|
||||||
|
/* Peripheral clock disable */
|
||||||
|
__HAL_RCC_SPI3_CLK_DISABLE();
|
||||||
|
|
||||||
|
/**SPI3 GPIO Configuration
|
||||||
|
PC10 ------> SPI3_SCK
|
||||||
|
PC11 ------> SPI3_MISO
|
||||||
|
PC12 ------> SPI3_MOSI
|
||||||
|
*/
|
||||||
|
HAL_GPIO_DeInit(GPIOC, GPIO_PIN_10|GPIO_PIN_11|GPIO_PIN_12);
|
||||||
|
|
||||||
|
/* USER CODE BEGIN SPI3_MspDeInit 1 */
|
||||||
|
|
||||||
|
/* USER CODE END SPI3_MspDeInit 1 */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* USER CODE BEGIN 1 */
|
||||||
|
|
||||||
|
/* USER CODE END 1 */
|
84
core/src/stm32f4xx_hal_msp.c
Normal file
84
core/src/stm32f4xx_hal_msp.c
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
/* USER CODE BEGIN Header */
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file stm32f4xx_hal_msp.c
|
||||||
|
* @brief This file provides code for the MSP Initialization
|
||||||
|
* and de-Initialization codes.
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* Copyright (c) 2024 STMicroelectronics.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This software is licensed under terms that can be found in the LICENSE file
|
||||||
|
* in the root directory of this software component.
|
||||||
|
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
/* USER CODE END Header */
|
||||||
|
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "main.h"
|
||||||
|
/* USER CODE BEGIN Includes */
|
||||||
|
|
||||||
|
/* USER CODE END Includes */
|
||||||
|
|
||||||
|
/* Private typedef -----------------------------------------------------------*/
|
||||||
|
/* USER CODE BEGIN TD */
|
||||||
|
|
||||||
|
/* USER CODE END TD */
|
||||||
|
|
||||||
|
/* Private define ------------------------------------------------------------*/
|
||||||
|
/* USER CODE BEGIN Define */
|
||||||
|
|
||||||
|
/* USER CODE END Define */
|
||||||
|
|
||||||
|
/* Private macro -------------------------------------------------------------*/
|
||||||
|
/* USER CODE BEGIN Macro */
|
||||||
|
|
||||||
|
/* USER CODE END Macro */
|
||||||
|
|
||||||
|
/* Private variables ---------------------------------------------------------*/
|
||||||
|
/* USER CODE BEGIN PV */
|
||||||
|
|
||||||
|
/* USER CODE END PV */
|
||||||
|
|
||||||
|
/* Private function prototypes -----------------------------------------------*/
|
||||||
|
/* USER CODE BEGIN PFP */
|
||||||
|
|
||||||
|
/* USER CODE END PFP */
|
||||||
|
|
||||||
|
/* External functions --------------------------------------------------------*/
|
||||||
|
/* USER CODE BEGIN ExternalFunctions */
|
||||||
|
|
||||||
|
/* USER CODE END ExternalFunctions */
|
||||||
|
|
||||||
|
/* USER CODE BEGIN 0 */
|
||||||
|
|
||||||
|
/* USER CODE END 0 */
|
||||||
|
/**
|
||||||
|
* Initializes the Global MSP.
|
||||||
|
*/
|
||||||
|
void HAL_MspInit(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
/* USER CODE BEGIN MspInit 0 */
|
||||||
|
|
||||||
|
/* USER CODE END MspInit 0 */
|
||||||
|
|
||||||
|
__HAL_RCC_SYSCFG_CLK_ENABLE();
|
||||||
|
__HAL_RCC_PWR_CLK_ENABLE();
|
||||||
|
|
||||||
|
/* System interrupt init*/
|
||||||
|
/* PendSV_IRQn interrupt configuration */
|
||||||
|
HAL_NVIC_SetPriority(PendSV_IRQn, 15, 0);
|
||||||
|
|
||||||
|
/* USER CODE BEGIN MspInit 1 */
|
||||||
|
|
||||||
|
/* USER CODE END MspInit 1 */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* USER CODE BEGIN 1 */
|
||||||
|
|
||||||
|
/* USER CODE END 1 */
|
128
core/src/stm32f4xx_hal_timebase_tim.c
Normal file
128
core/src/stm32f4xx_hal_timebase_tim.c
Normal file
@ -0,0 +1,128 @@
|
|||||||
|
/* USER CODE BEGIN Header */
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file stm32f4xx_hal_timebase_tim.c
|
||||||
|
* @brief HAL time base based on the hardware TIM.
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* Copyright (c) 2024 STMicroelectronics.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This software is licensed under terms that can be found in the LICENSE file
|
||||||
|
* in the root directory of this software component.
|
||||||
|
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
/* USER CODE END Header */
|
||||||
|
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "stm32f4xx_hal.h"
|
||||||
|
#include "stm32f4xx_hal_tim.h"
|
||||||
|
|
||||||
|
/* Private typedef -----------------------------------------------------------*/
|
||||||
|
/* Private define ------------------------------------------------------------*/
|
||||||
|
/* Private macro -------------------------------------------------------------*/
|
||||||
|
/* Private variables ---------------------------------------------------------*/
|
||||||
|
TIM_HandleTypeDef htim1;
|
||||||
|
/* Private function prototypes -----------------------------------------------*/
|
||||||
|
/* Private functions ---------------------------------------------------------*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This function configures the TIM1 as a time base source.
|
||||||
|
* The time source is configured to have 1ms time base with a dedicated
|
||||||
|
* Tick interrupt priority.
|
||||||
|
* @note This function is called automatically at the beginning of program after
|
||||||
|
* reset by HAL_Init() or at any time when clock is configured, by HAL_RCC_ClockConfig().
|
||||||
|
* @param TickPriority: Tick interrupt priority.
|
||||||
|
* @retval HAL status
|
||||||
|
*/
|
||||||
|
HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority)
|
||||||
|
{
|
||||||
|
RCC_ClkInitTypeDef clkconfig;
|
||||||
|
uint32_t uwTimclock = 0U;
|
||||||
|
|
||||||
|
uint32_t uwPrescalerValue = 0U;
|
||||||
|
uint32_t pFLatency;
|
||||||
|
HAL_StatusTypeDef status;
|
||||||
|
|
||||||
|
/* Enable TIM1 clock */
|
||||||
|
__HAL_RCC_TIM1_CLK_ENABLE();
|
||||||
|
|
||||||
|
/* Get clock configuration */
|
||||||
|
HAL_RCC_GetClockConfig(&clkconfig, &pFLatency);
|
||||||
|
|
||||||
|
/* Compute TIM1 clock */
|
||||||
|
uwTimclock = 2*HAL_RCC_GetPCLK2Freq();
|
||||||
|
|
||||||
|
/* Compute the prescaler value to have TIM1 counter clock equal to 1MHz */
|
||||||
|
uwPrescalerValue = (uint32_t) ((uwTimclock / 1000000U) - 1U);
|
||||||
|
|
||||||
|
/* Initialize TIM1 */
|
||||||
|
htim1.Instance = TIM1;
|
||||||
|
|
||||||
|
/* Initialize TIMx peripheral as follow:
|
||||||
|
|
||||||
|
+ Period = [(TIM1CLK/1000) - 1]. to have a (1/1000) s time base.
|
||||||
|
+ Prescaler = (uwTimclock/1000000 - 1) to have a 1MHz counter clock.
|
||||||
|
+ ClockDivision = 0
|
||||||
|
+ Counter direction = Up
|
||||||
|
*/
|
||||||
|
htim1.Init.Period = (1000000U / 1000U) - 1U;
|
||||||
|
htim1.Init.Prescaler = uwPrescalerValue;
|
||||||
|
htim1.Init.ClockDivision = 0;
|
||||||
|
htim1.Init.CounterMode = TIM_COUNTERMODE_UP;
|
||||||
|
htim1.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
|
||||||
|
|
||||||
|
status = HAL_TIM_Base_Init(&htim1);
|
||||||
|
if (status == HAL_OK)
|
||||||
|
{
|
||||||
|
/* Start the TIM time Base generation in interrupt mode */
|
||||||
|
status = HAL_TIM_Base_Start_IT(&htim1);
|
||||||
|
if (status == HAL_OK)
|
||||||
|
{
|
||||||
|
/* Enable the TIM1 global Interrupt */
|
||||||
|
HAL_NVIC_EnableIRQ(TIM1_UP_TIM10_IRQn);
|
||||||
|
/* Configure the SysTick IRQ priority */
|
||||||
|
if (TickPriority < (1UL << __NVIC_PRIO_BITS))
|
||||||
|
{
|
||||||
|
/* Configure the TIM IRQ priority */
|
||||||
|
HAL_NVIC_SetPriority(TIM1_UP_TIM10_IRQn, TickPriority, 0U);
|
||||||
|
uwTickPrio = TickPriority;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
status = HAL_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Return function status */
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Suspend Tick increment.
|
||||||
|
* @note Disable the tick increment by disabling TIM1 update interrupt.
|
||||||
|
* @param None
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
void HAL_SuspendTick(void)
|
||||||
|
{
|
||||||
|
/* Disable TIM1 update Interrupt */
|
||||||
|
__HAL_TIM_DISABLE_IT(&htim1, TIM_IT_UPDATE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Resume Tick increment.
|
||||||
|
* @note Enable the tick increment by Enabling TIM1 update interrupt.
|
||||||
|
* @param None
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
void HAL_ResumeTick(void)
|
||||||
|
{
|
||||||
|
/* Enable TIM1 Update interrupt */
|
||||||
|
__HAL_TIM_ENABLE_IT(&htim1, TIM_IT_UPDATE);
|
||||||
|
}
|
||||||
|
|
222
core/src/stm32f4xx_it.c
Normal file
222
core/src/stm32f4xx_it.c
Normal file
@ -0,0 +1,222 @@
|
|||||||
|
/* USER CODE BEGIN Header */
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file stm32f4xx_it.c
|
||||||
|
* @brief Interrupt Service Routines.
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* Copyright (c) 2024 STMicroelectronics.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This software is licensed under terms that can be found in the LICENSE file
|
||||||
|
* in the root directory of this software component.
|
||||||
|
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
/* USER CODE END Header */
|
||||||
|
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "main.h"
|
||||||
|
#include "stm32f4xx_it.h"
|
||||||
|
/* Private includes ----------------------------------------------------------*/
|
||||||
|
/* USER CODE BEGIN Includes */
|
||||||
|
/* USER CODE END Includes */
|
||||||
|
|
||||||
|
/* Private typedef -----------------------------------------------------------*/
|
||||||
|
/* USER CODE BEGIN TD */
|
||||||
|
|
||||||
|
/* USER CODE END TD */
|
||||||
|
|
||||||
|
/* Private define ------------------------------------------------------------*/
|
||||||
|
/* USER CODE BEGIN PD */
|
||||||
|
|
||||||
|
/* USER CODE END PD */
|
||||||
|
|
||||||
|
/* Private macro -------------------------------------------------------------*/
|
||||||
|
/* USER CODE BEGIN PM */
|
||||||
|
|
||||||
|
/* USER CODE END PM */
|
||||||
|
|
||||||
|
/* Private variables ---------------------------------------------------------*/
|
||||||
|
/* USER CODE BEGIN PV */
|
||||||
|
|
||||||
|
/* USER CODE END PV */
|
||||||
|
|
||||||
|
/* Private function prototypes -----------------------------------------------*/
|
||||||
|
/* USER CODE BEGIN PFP */
|
||||||
|
|
||||||
|
/* USER CODE END PFP */
|
||||||
|
|
||||||
|
/* Private user code ---------------------------------------------------------*/
|
||||||
|
/* USER CODE BEGIN 0 */
|
||||||
|
|
||||||
|
/* USER CODE END 0 */
|
||||||
|
|
||||||
|
/* External variables --------------------------------------------------------*/
|
||||||
|
extern DMA_HandleTypeDef hdma_adc1;
|
||||||
|
extern CAN_HandleTypeDef hcan1;
|
||||||
|
extern TIM_HandleTypeDef htim1;
|
||||||
|
|
||||||
|
/* USER CODE BEGIN EV */
|
||||||
|
|
||||||
|
/* USER CODE END EV */
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
/* Cortex-M4 Processor Interruption and Exception Handlers */
|
||||||
|
/******************************************************************************/
|
||||||
|
/**
|
||||||
|
* @brief This function handles Non maskable interrupt.
|
||||||
|
*/
|
||||||
|
void NMI_Handler(void)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN NonMaskableInt_IRQn 0 */
|
||||||
|
|
||||||
|
/* USER CODE END NonMaskableInt_IRQn 0 */
|
||||||
|
/* USER CODE BEGIN NonMaskableInt_IRQn 1 */
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
/* USER CODE END NonMaskableInt_IRQn 1 */
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This function handles Hard fault interrupt.
|
||||||
|
*/
|
||||||
|
void HardFault_Handler(void)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN HardFault_IRQn 0 */
|
||||||
|
|
||||||
|
/* USER CODE END HardFault_IRQn 0 */
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN W1_HardFault_IRQn 0 */
|
||||||
|
/* USER CODE END W1_HardFault_IRQn 0 */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This function handles Memory management fault.
|
||||||
|
*/
|
||||||
|
void MemManage_Handler(void)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN MemoryManagement_IRQn 0 */
|
||||||
|
|
||||||
|
/* USER CODE END MemoryManagement_IRQn 0 */
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN W1_MemoryManagement_IRQn 0 */
|
||||||
|
/* USER CODE END W1_MemoryManagement_IRQn 0 */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This function handles Pre-fetch fault, memory access fault.
|
||||||
|
*/
|
||||||
|
void BusFault_Handler(void)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN BusFault_IRQn 0 */
|
||||||
|
|
||||||
|
/* USER CODE END BusFault_IRQn 0 */
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN W1_BusFault_IRQn 0 */
|
||||||
|
/* USER CODE END W1_BusFault_IRQn 0 */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This function handles Undefined instruction or illegal state.
|
||||||
|
*/
|
||||||
|
void UsageFault_Handler(void)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN UsageFault_IRQn 0 */
|
||||||
|
|
||||||
|
/* USER CODE END UsageFault_IRQn 0 */
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN W1_UsageFault_IRQn 0 */
|
||||||
|
/* USER CODE END W1_UsageFault_IRQn 0 */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This function handles Debug monitor.
|
||||||
|
*/
|
||||||
|
void DebugMon_Handler(void)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN DebugMonitor_IRQn 0 */
|
||||||
|
|
||||||
|
/* USER CODE END DebugMonitor_IRQn 0 */
|
||||||
|
/* USER CODE BEGIN DebugMonitor_IRQn 1 */
|
||||||
|
|
||||||
|
/* USER CODE END DebugMonitor_IRQn 1 */
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
/* STM32F4xx Peripheral Interrupt Handlers */
|
||||||
|
/* Add here the Interrupt Handlers for the used peripherals. */
|
||||||
|
/* For the available peripheral interrupt handler names, */
|
||||||
|
/* please refer to the startup file (startup_stm32f4xx.s). */
|
||||||
|
/******************************************************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This function handles CAN1 RX0 interrupts.
|
||||||
|
*/
|
||||||
|
void CAN1_RX0_IRQHandler(void)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN CAN1_RX0_IRQn 0 */
|
||||||
|
|
||||||
|
/* USER CODE END CAN1_RX0_IRQn 0 */
|
||||||
|
HAL_CAN_IRQHandler(&hcan1);
|
||||||
|
/* USER CODE BEGIN CAN1_RX0_IRQn 1 */
|
||||||
|
|
||||||
|
/* USER CODE END CAN1_RX0_IRQn 1 */
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This function handles CAN1 RX1 interrupt.
|
||||||
|
*/
|
||||||
|
void CAN1_RX1_IRQHandler(void)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN CAN1_RX1_IRQn 0 */
|
||||||
|
|
||||||
|
/* USER CODE END CAN1_RX1_IRQn 0 */
|
||||||
|
HAL_CAN_IRQHandler(&hcan1);
|
||||||
|
/* USER CODE BEGIN CAN1_RX1_IRQn 1 */
|
||||||
|
|
||||||
|
/* USER CODE END CAN1_RX1_IRQn 1 */
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This function handles TIM1 update interrupt and TIM10 global interrupt.
|
||||||
|
*/
|
||||||
|
void TIM1_UP_TIM10_IRQHandler(void)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN TIM1_UP_TIM10_IRQn 0 */
|
||||||
|
|
||||||
|
/* USER CODE END TIM1_UP_TIM10_IRQn 0 */
|
||||||
|
HAL_TIM_IRQHandler(&htim1);
|
||||||
|
/* USER CODE BEGIN TIM1_UP_TIM10_IRQn 1 */
|
||||||
|
|
||||||
|
/* USER CODE END TIM1_UP_TIM10_IRQn 1 */
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This function handles DMA2 stream0 global interrupt.
|
||||||
|
*/
|
||||||
|
void DMA2_Stream0_IRQHandler(void)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN DMA2_Stream0_IRQn 0 */
|
||||||
|
|
||||||
|
/* USER CODE END DMA2_Stream0_IRQn 0 */
|
||||||
|
HAL_DMA_IRQHandler(&hdma_adc1);
|
||||||
|
/* USER CODE BEGIN DMA2_Stream0_IRQn 1 */
|
||||||
|
|
||||||
|
/* USER CODE END DMA2_Stream0_IRQn 1 */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* USER CODE BEGIN 1 */
|
||||||
|
|
||||||
|
/* USER CODE END 1 */
|
176
core/src/syscalls.c
Normal file
176
core/src/syscalls.c
Normal file
@ -0,0 +1,176 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file syscalls.c
|
||||||
|
* @author Auto-generated by STM32CubeIDE
|
||||||
|
* @brief STM32CubeIDE Minimal System calls file
|
||||||
|
*
|
||||||
|
* For more information about which c-functions
|
||||||
|
* need which of these lowlevel functions
|
||||||
|
* please consult the Newlib libc-manual
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* Copyright (c) 2020-2024 STMicroelectronics.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This software is licensed under terms that can be found in the LICENSE file
|
||||||
|
* in the root directory of this software component.
|
||||||
|
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Includes */
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <signal.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <sys/times.h>
|
||||||
|
|
||||||
|
|
||||||
|
/* Variables */
|
||||||
|
extern int __io_putchar(int ch) __attribute__((weak));
|
||||||
|
extern int __io_getchar(void) __attribute__((weak));
|
||||||
|
|
||||||
|
|
||||||
|
char *__env[1] = { 0 };
|
||||||
|
char **environ = __env;
|
||||||
|
|
||||||
|
|
||||||
|
/* Functions */
|
||||||
|
void initialise_monitor_handles()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
int _getpid(void)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int _kill(int pid, int sig)
|
||||||
|
{
|
||||||
|
(void)pid;
|
||||||
|
(void)sig;
|
||||||
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void _exit (int status)
|
||||||
|
{
|
||||||
|
_kill(status, -1);
|
||||||
|
while (1) {} /* Make sure we hang here */
|
||||||
|
}
|
||||||
|
|
||||||
|
__attribute__((weak)) int _read(int file, char *ptr, int len)
|
||||||
|
{
|
||||||
|
(void)file;
|
||||||
|
int DataIdx;
|
||||||
|
|
||||||
|
for (DataIdx = 0; DataIdx < len; DataIdx++)
|
||||||
|
{
|
||||||
|
*ptr++ = __io_getchar();
|
||||||
|
}
|
||||||
|
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
|
__attribute__((weak)) int _write(int file, char *ptr, int len)
|
||||||
|
{
|
||||||
|
(void)file;
|
||||||
|
int DataIdx;
|
||||||
|
|
||||||
|
for (DataIdx = 0; DataIdx < len; DataIdx++)
|
||||||
|
{
|
||||||
|
__io_putchar(*ptr++);
|
||||||
|
}
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
|
int _close(int file)
|
||||||
|
{
|
||||||
|
(void)file;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int _fstat(int file, struct stat *st)
|
||||||
|
{
|
||||||
|
(void)file;
|
||||||
|
st->st_mode = S_IFCHR;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int _isatty(int file)
|
||||||
|
{
|
||||||
|
(void)file;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int _lseek(int file, int ptr, int dir)
|
||||||
|
{
|
||||||
|
(void)file;
|
||||||
|
(void)ptr;
|
||||||
|
(void)dir;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int _open(char *path, int flags, ...)
|
||||||
|
{
|
||||||
|
(void)path;
|
||||||
|
(void)flags;
|
||||||
|
/* Pretend like we always fail */
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int _wait(int *status)
|
||||||
|
{
|
||||||
|
(void)status;
|
||||||
|
errno = ECHILD;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int _unlink(char *name)
|
||||||
|
{
|
||||||
|
(void)name;
|
||||||
|
errno = ENOENT;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int _times(struct tms *buf)
|
||||||
|
{
|
||||||
|
(void)buf;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int _stat(char *file, struct stat *st)
|
||||||
|
{
|
||||||
|
(void)file;
|
||||||
|
st->st_mode = S_IFCHR;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int _link(char *old, char *new)
|
||||||
|
{
|
||||||
|
(void)old;
|
||||||
|
(void)new;
|
||||||
|
errno = EMLINK;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int _fork(void)
|
||||||
|
{
|
||||||
|
errno = EAGAIN;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int _execve(char *name, char **argv, char **env)
|
||||||
|
{
|
||||||
|
(void)name;
|
||||||
|
(void)argv;
|
||||||
|
(void)env;
|
||||||
|
errno = ENOMEM;
|
||||||
|
return -1;
|
||||||
|
}
|
79
core/src/sysmem.c
Normal file
79
core/src/sysmem.c
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file sysmem.c
|
||||||
|
* @author Generated by STM32CubeIDE
|
||||||
|
* @brief STM32CubeIDE System Memory calls file
|
||||||
|
*
|
||||||
|
* For more information about which C functions
|
||||||
|
* need which of these lowlevel functions
|
||||||
|
* please consult the newlib libc manual
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* Copyright (c) 2024 STMicroelectronics.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This software is licensed under terms that can be found in the LICENSE file
|
||||||
|
* in the root directory of this software component.
|
||||||
|
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Includes */
|
||||||
|
#include <errno.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pointer to the current high watermark of the heap usage
|
||||||
|
*/
|
||||||
|
static uint8_t *__sbrk_heap_end = NULL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief _sbrk() allocates memory to the newlib heap and is used by malloc
|
||||||
|
* and others from the C library
|
||||||
|
*
|
||||||
|
* @verbatim
|
||||||
|
* ############################################################################
|
||||||
|
* # .data # .bss # newlib heap # MSP stack #
|
||||||
|
* # # # # Reserved by _Min_Stack_Size #
|
||||||
|
* ############################################################################
|
||||||
|
* ^-- RAM start ^-- _end _estack, RAM end --^
|
||||||
|
* @endverbatim
|
||||||
|
*
|
||||||
|
* This implementation starts allocating at the '_end' linker symbol
|
||||||
|
* The '_Min_Stack_Size' linker symbol reserves a memory for the MSP stack
|
||||||
|
* The implementation considers '_estack' linker symbol to be RAM end
|
||||||
|
* NOTE: If the MSP stack, at any point during execution, grows larger than the
|
||||||
|
* reserved size, please increase the '_Min_Stack_Size'.
|
||||||
|
*
|
||||||
|
* @param incr Memory size
|
||||||
|
* @return Pointer to allocated memory
|
||||||
|
*/
|
||||||
|
void *_sbrk(ptrdiff_t incr)
|
||||||
|
{
|
||||||
|
extern uint8_t _end; /* Symbol defined in the linker script */
|
||||||
|
extern uint8_t _estack; /* Symbol defined in the linker script */
|
||||||
|
extern uint32_t _Min_Stack_Size; /* Symbol defined in the linker script */
|
||||||
|
const uint32_t stack_limit = (uint32_t)&_estack - (uint32_t)&_Min_Stack_Size;
|
||||||
|
const uint8_t *max_heap = (uint8_t *)stack_limit;
|
||||||
|
uint8_t *prev_heap_end;
|
||||||
|
|
||||||
|
/* Initialize heap end at first call */
|
||||||
|
if (NULL == __sbrk_heap_end)
|
||||||
|
{
|
||||||
|
__sbrk_heap_end = &_end;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Protect heap from growing into the reserved MSP stack */
|
||||||
|
if (__sbrk_heap_end + incr > max_heap)
|
||||||
|
{
|
||||||
|
errno = ENOMEM;
|
||||||
|
return (void *)-1;
|
||||||
|
}
|
||||||
|
|
||||||
|
prev_heap_end = __sbrk_heap_end;
|
||||||
|
__sbrk_heap_end += incr;
|
||||||
|
|
||||||
|
return (void *)prev_heap_end;
|
||||||
|
}
|
747
core/src/system_stm32f4xx.c
Normal file
747
core/src/system_stm32f4xx.c
Normal file
@ -0,0 +1,747 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file system_stm32f4xx.c
|
||||||
|
* @author MCD Application Team
|
||||||
|
* @brief CMSIS Cortex-M4 Device Peripheral Access Layer System Source File.
|
||||||
|
*
|
||||||
|
* This file provides two functions and one global variable to be called from
|
||||||
|
* user application:
|
||||||
|
* - SystemInit(): This function is called at startup just after reset and
|
||||||
|
* before branch to main program. This call is made inside
|
||||||
|
* the "startup_stm32f4xx.s" file.
|
||||||
|
*
|
||||||
|
* - SystemCoreClock variable: Contains the core clock (HCLK), it can be used
|
||||||
|
* by the user application to setup the SysTick
|
||||||
|
* timer or configure other parameters.
|
||||||
|
*
|
||||||
|
* - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must
|
||||||
|
* be called whenever the core clock is changed
|
||||||
|
* during program execution.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* Copyright (c) 2017 STMicroelectronics.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This software is licensed under terms that can be found in the LICENSE file
|
||||||
|
* in the root directory of this software component.
|
||||||
|
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @addtogroup CMSIS
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @addtogroup stm32f4xx_system
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @addtogroup STM32F4xx_System_Private_Includes
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "stm32f4xx.h"
|
||||||
|
|
||||||
|
#if !defined (HSE_VALUE)
|
||||||
|
#define HSE_VALUE ((uint32_t)25000000) /*!< Default value of the External oscillator in Hz */
|
||||||
|
#endif /* HSE_VALUE */
|
||||||
|
|
||||||
|
#if !defined (HSI_VALUE)
|
||||||
|
#define HSI_VALUE ((uint32_t)16000000) /*!< Value of the Internal oscillator in Hz*/
|
||||||
|
#endif /* HSI_VALUE */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @addtogroup STM32F4xx_System_Private_TypesDefinitions
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @addtogroup STM32F4xx_System_Private_Defines
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/************************* Miscellaneous Configuration ************************/
|
||||||
|
/*!< Uncomment the following line if you need to use external SRAM or SDRAM as data memory */
|
||||||
|
#if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx)\
|
||||||
|
|| defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)\
|
||||||
|
|| defined(STM32F469xx) || defined(STM32F479xx) || defined(STM32F412Zx) || defined(STM32F412Vx)
|
||||||
|
/* #define DATA_IN_ExtSRAM */
|
||||||
|
#endif /* STM32F40xxx || STM32F41xxx || STM32F42xxx || STM32F43xxx || STM32F469xx || STM32F479xx ||\
|
||||||
|
STM32F412Zx || STM32F412Vx */
|
||||||
|
|
||||||
|
#if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)\
|
||||||
|
|| defined(STM32F446xx) || defined(STM32F469xx) || defined(STM32F479xx)
|
||||||
|
/* #define DATA_IN_ExtSDRAM */
|
||||||
|
#endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F446xx || STM32F469xx ||\
|
||||||
|
STM32F479xx */
|
||||||
|
|
||||||
|
/* Note: Following vector table addresses must be defined in line with linker
|
||||||
|
configuration. */
|
||||||
|
/*!< Uncomment the following line if you need to relocate the vector table
|
||||||
|
anywhere in Flash or Sram, else the vector table is kept at the automatic
|
||||||
|
remap of boot address selected */
|
||||||
|
/* #define USER_VECT_TAB_ADDRESS */
|
||||||
|
|
||||||
|
#if defined(USER_VECT_TAB_ADDRESS)
|
||||||
|
/*!< Uncomment the following line if you need to relocate your vector Table
|
||||||
|
in Sram else user remap will be done in Flash. */
|
||||||
|
/* #define VECT_TAB_SRAM */
|
||||||
|
#if defined(VECT_TAB_SRAM)
|
||||||
|
#define VECT_TAB_BASE_ADDRESS SRAM_BASE /*!< Vector Table base address field.
|
||||||
|
This value must be a multiple of 0x200. */
|
||||||
|
#define VECT_TAB_OFFSET 0x00000000U /*!< Vector Table base offset field.
|
||||||
|
This value must be a multiple of 0x200. */
|
||||||
|
#else
|
||||||
|
#define VECT_TAB_BASE_ADDRESS FLASH_BASE /*!< Vector Table base address field.
|
||||||
|
This value must be a multiple of 0x200. */
|
||||||
|
#define VECT_TAB_OFFSET 0x00000000U /*!< Vector Table base offset field.
|
||||||
|
This value must be a multiple of 0x200. */
|
||||||
|
#endif /* VECT_TAB_SRAM */
|
||||||
|
#endif /* USER_VECT_TAB_ADDRESS */
|
||||||
|
/******************************************************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @addtogroup STM32F4xx_System_Private_Macros
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @addtogroup STM32F4xx_System_Private_Variables
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
/* This variable is updated in three ways:
|
||||||
|
1) by calling CMSIS function SystemCoreClockUpdate()
|
||||||
|
2) by calling HAL API function HAL_RCC_GetHCLKFreq()
|
||||||
|
3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency
|
||||||
|
Note: If you use this function to configure the system clock; then there
|
||||||
|
is no need to call the 2 first functions listed above, since SystemCoreClock
|
||||||
|
variable is updated automatically.
|
||||||
|
*/
|
||||||
|
uint32_t SystemCoreClock = 16000000;
|
||||||
|
const uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9};
|
||||||
|
const uint8_t APBPrescTable[8] = {0, 0, 0, 0, 1, 2, 3, 4};
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @addtogroup STM32F4xx_System_Private_FunctionPrototypes
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if defined (DATA_IN_ExtSRAM) || defined (DATA_IN_ExtSDRAM)
|
||||||
|
static void SystemInit_ExtMemCtl(void);
|
||||||
|
#endif /* DATA_IN_ExtSRAM || DATA_IN_ExtSDRAM */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @addtogroup STM32F4xx_System_Private_Functions
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Setup the microcontroller system
|
||||||
|
* Initialize the FPU setting, vector table location and External memory
|
||||||
|
* configuration.
|
||||||
|
* @param None
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
void SystemInit(void)
|
||||||
|
{
|
||||||
|
/* FPU settings ------------------------------------------------------------*/
|
||||||
|
#if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
|
||||||
|
SCB->CPACR |= ((3UL << 10*2)|(3UL << 11*2)); /* set CP10 and CP11 Full Access */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined (DATA_IN_ExtSRAM) || defined (DATA_IN_ExtSDRAM)
|
||||||
|
SystemInit_ExtMemCtl();
|
||||||
|
#endif /* DATA_IN_ExtSRAM || DATA_IN_ExtSDRAM */
|
||||||
|
|
||||||
|
/* Configure the Vector Table location -------------------------------------*/
|
||||||
|
#if defined(USER_VECT_TAB_ADDRESS)
|
||||||
|
SCB->VTOR = VECT_TAB_BASE_ADDRESS | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */
|
||||||
|
#endif /* USER_VECT_TAB_ADDRESS */
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Update SystemCoreClock variable according to Clock Register Values.
|
||||||
|
* The SystemCoreClock variable contains the core clock (HCLK), it can
|
||||||
|
* be used by the user application to setup the SysTick timer or configure
|
||||||
|
* other parameters.
|
||||||
|
*
|
||||||
|
* @note Each time the core clock (HCLK) changes, this function must be called
|
||||||
|
* to update SystemCoreClock variable value. Otherwise, any configuration
|
||||||
|
* based on this variable will be incorrect.
|
||||||
|
*
|
||||||
|
* @note - The system frequency computed by this function is not the real
|
||||||
|
* frequency in the chip. It is calculated based on the predefined
|
||||||
|
* constant and the selected clock source:
|
||||||
|
*
|
||||||
|
* - If SYSCLK source is HSI, SystemCoreClock will contain the HSI_VALUE(*)
|
||||||
|
*
|
||||||
|
* - If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(**)
|
||||||
|
*
|
||||||
|
* - If SYSCLK source is PLL, SystemCoreClock will contain the HSE_VALUE(**)
|
||||||
|
* or HSI_VALUE(*) multiplied/divided by the PLL factors.
|
||||||
|
*
|
||||||
|
* (*) HSI_VALUE is a constant defined in stm32f4xx_hal_conf.h file (default value
|
||||||
|
* 16 MHz) but the real value may vary depending on the variations
|
||||||
|
* in voltage and temperature.
|
||||||
|
*
|
||||||
|
* (**) HSE_VALUE is a constant defined in stm32f4xx_hal_conf.h file (its value
|
||||||
|
* depends on the application requirements), user has to ensure that HSE_VALUE
|
||||||
|
* is same as the real frequency of the crystal used. Otherwise, this function
|
||||||
|
* may have wrong result.
|
||||||
|
*
|
||||||
|
* - The result of this function could be not correct when using fractional
|
||||||
|
* value for HSE crystal.
|
||||||
|
*
|
||||||
|
* @param None
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
void SystemCoreClockUpdate(void)
|
||||||
|
{
|
||||||
|
uint32_t tmp = 0, pllvco = 0, pllp = 2, pllsource = 0, pllm = 2;
|
||||||
|
|
||||||
|
/* Get SYSCLK source -------------------------------------------------------*/
|
||||||
|
tmp = RCC->CFGR & RCC_CFGR_SWS;
|
||||||
|
|
||||||
|
switch (tmp)
|
||||||
|
{
|
||||||
|
case 0x00: /* HSI used as system clock source */
|
||||||
|
SystemCoreClock = HSI_VALUE;
|
||||||
|
break;
|
||||||
|
case 0x04: /* HSE used as system clock source */
|
||||||
|
SystemCoreClock = HSE_VALUE;
|
||||||
|
break;
|
||||||
|
case 0x08: /* PLL used as system clock source */
|
||||||
|
|
||||||
|
/* PLL_VCO = (HSE_VALUE or HSI_VALUE / PLL_M) * PLL_N
|
||||||
|
SYSCLK = PLL_VCO / PLL_P
|
||||||
|
*/
|
||||||
|
pllsource = (RCC->PLLCFGR & RCC_PLLCFGR_PLLSRC) >> 22;
|
||||||
|
pllm = RCC->PLLCFGR & RCC_PLLCFGR_PLLM;
|
||||||
|
|
||||||
|
if (pllsource != 0)
|
||||||
|
{
|
||||||
|
/* HSE used as PLL clock source */
|
||||||
|
pllvco = (HSE_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* HSI used as PLL clock source */
|
||||||
|
pllvco = (HSI_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6);
|
||||||
|
}
|
||||||
|
|
||||||
|
pllp = (((RCC->PLLCFGR & RCC_PLLCFGR_PLLP) >>16) + 1 ) *2;
|
||||||
|
SystemCoreClock = pllvco/pllp;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
SystemCoreClock = HSI_VALUE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
/* Compute HCLK frequency --------------------------------------------------*/
|
||||||
|
/* Get HCLK prescaler */
|
||||||
|
tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> 4)];
|
||||||
|
/* HCLK frequency */
|
||||||
|
SystemCoreClock >>= tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined (DATA_IN_ExtSRAM) && defined (DATA_IN_ExtSDRAM)
|
||||||
|
#if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)\
|
||||||
|
|| defined(STM32F469xx) || defined(STM32F479xx)
|
||||||
|
/**
|
||||||
|
* @brief Setup the external memory controller.
|
||||||
|
* Called in startup_stm32f4xx.s before jump to main.
|
||||||
|
* This function configures the external memories (SRAM/SDRAM)
|
||||||
|
* This SRAM/SDRAM will be used as program data memory (including heap and stack).
|
||||||
|
* @param None
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
void SystemInit_ExtMemCtl(void)
|
||||||
|
{
|
||||||
|
__IO uint32_t tmp = 0x00;
|
||||||
|
|
||||||
|
register uint32_t tmpreg = 0, timeout = 0xFFFF;
|
||||||
|
register __IO uint32_t index;
|
||||||
|
|
||||||
|
/* Enable GPIOC, GPIOD, GPIOE, GPIOF, GPIOG, GPIOH and GPIOI interface clock */
|
||||||
|
RCC->AHB1ENR |= 0x000001F8;
|
||||||
|
|
||||||
|
/* Delay after an RCC peripheral clock enabling */
|
||||||
|
tmp = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOCEN);
|
||||||
|
|
||||||
|
/* Connect PDx pins to FMC Alternate function */
|
||||||
|
GPIOD->AFR[0] = 0x00CCC0CC;
|
||||||
|
GPIOD->AFR[1] = 0xCCCCCCCC;
|
||||||
|
/* Configure PDx pins in Alternate function mode */
|
||||||
|
GPIOD->MODER = 0xAAAA0A8A;
|
||||||
|
/* Configure PDx pins speed to 100 MHz */
|
||||||
|
GPIOD->OSPEEDR = 0xFFFF0FCF;
|
||||||
|
/* Configure PDx pins Output type to push-pull */
|
||||||
|
GPIOD->OTYPER = 0x00000000;
|
||||||
|
/* No pull-up, pull-down for PDx pins */
|
||||||
|
GPIOD->PUPDR = 0x00000000;
|
||||||
|
|
||||||
|
/* Connect PEx pins to FMC Alternate function */
|
||||||
|
GPIOE->AFR[0] = 0xC00CC0CC;
|
||||||
|
GPIOE->AFR[1] = 0xCCCCCCCC;
|
||||||
|
/* Configure PEx pins in Alternate function mode */
|
||||||
|
GPIOE->MODER = 0xAAAA828A;
|
||||||
|
/* Configure PEx pins speed to 100 MHz */
|
||||||
|
GPIOE->OSPEEDR = 0xFFFFC3CF;
|
||||||
|
/* Configure PEx pins Output type to push-pull */
|
||||||
|
GPIOE->OTYPER = 0x00000000;
|
||||||
|
/* No pull-up, pull-down for PEx pins */
|
||||||
|
GPIOE->PUPDR = 0x00000000;
|
||||||
|
|
||||||
|
/* Connect PFx pins to FMC Alternate function */
|
||||||
|
GPIOF->AFR[0] = 0xCCCCCCCC;
|
||||||
|
GPIOF->AFR[1] = 0xCCCCCCCC;
|
||||||
|
/* Configure PFx pins in Alternate function mode */
|
||||||
|
GPIOF->MODER = 0xAA800AAA;
|
||||||
|
/* Configure PFx pins speed to 50 MHz */
|
||||||
|
GPIOF->OSPEEDR = 0xAA800AAA;
|
||||||
|
/* Configure PFx pins Output type to push-pull */
|
||||||
|
GPIOF->OTYPER = 0x00000000;
|
||||||
|
/* No pull-up, pull-down for PFx pins */
|
||||||
|
GPIOF->PUPDR = 0x00000000;
|
||||||
|
|
||||||
|
/* Connect PGx pins to FMC Alternate function */
|
||||||
|
GPIOG->AFR[0] = 0xCCCCCCCC;
|
||||||
|
GPIOG->AFR[1] = 0xCCCCCCCC;
|
||||||
|
/* Configure PGx pins in Alternate function mode */
|
||||||
|
GPIOG->MODER = 0xAAAAAAAA;
|
||||||
|
/* Configure PGx pins speed to 50 MHz */
|
||||||
|
GPIOG->OSPEEDR = 0xAAAAAAAA;
|
||||||
|
/* Configure PGx pins Output type to push-pull */
|
||||||
|
GPIOG->OTYPER = 0x00000000;
|
||||||
|
/* No pull-up, pull-down for PGx pins */
|
||||||
|
GPIOG->PUPDR = 0x00000000;
|
||||||
|
|
||||||
|
/* Connect PHx pins to FMC Alternate function */
|
||||||
|
GPIOH->AFR[0] = 0x00C0CC00;
|
||||||
|
GPIOH->AFR[1] = 0xCCCCCCCC;
|
||||||
|
/* Configure PHx pins in Alternate function mode */
|
||||||
|
GPIOH->MODER = 0xAAAA08A0;
|
||||||
|
/* Configure PHx pins speed to 50 MHz */
|
||||||
|
GPIOH->OSPEEDR = 0xAAAA08A0;
|
||||||
|
/* Configure PHx pins Output type to push-pull */
|
||||||
|
GPIOH->OTYPER = 0x00000000;
|
||||||
|
/* No pull-up, pull-down for PHx pins */
|
||||||
|
GPIOH->PUPDR = 0x00000000;
|
||||||
|
|
||||||
|
/* Connect PIx pins to FMC Alternate function */
|
||||||
|
GPIOI->AFR[0] = 0xCCCCCCCC;
|
||||||
|
GPIOI->AFR[1] = 0x00000CC0;
|
||||||
|
/* Configure PIx pins in Alternate function mode */
|
||||||
|
GPIOI->MODER = 0x0028AAAA;
|
||||||
|
/* Configure PIx pins speed to 50 MHz */
|
||||||
|
GPIOI->OSPEEDR = 0x0028AAAA;
|
||||||
|
/* Configure PIx pins Output type to push-pull */
|
||||||
|
GPIOI->OTYPER = 0x00000000;
|
||||||
|
/* No pull-up, pull-down for PIx pins */
|
||||||
|
GPIOI->PUPDR = 0x00000000;
|
||||||
|
|
||||||
|
/*-- FMC Configuration -------------------------------------------------------*/
|
||||||
|
/* Enable the FMC interface clock */
|
||||||
|
RCC->AHB3ENR |= 0x00000001;
|
||||||
|
/* Delay after an RCC peripheral clock enabling */
|
||||||
|
tmp = READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FMCEN);
|
||||||
|
|
||||||
|
FMC_Bank5_6->SDCR[0] = 0x000019E4;
|
||||||
|
FMC_Bank5_6->SDTR[0] = 0x01115351;
|
||||||
|
|
||||||
|
/* SDRAM initialization sequence */
|
||||||
|
/* Clock enable command */
|
||||||
|
FMC_Bank5_6->SDCMR = 0x00000011;
|
||||||
|
tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
|
||||||
|
while((tmpreg != 0) && (timeout-- > 0))
|
||||||
|
{
|
||||||
|
tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Delay */
|
||||||
|
for (index = 0; index<1000; index++);
|
||||||
|
|
||||||
|
/* PALL command */
|
||||||
|
FMC_Bank5_6->SDCMR = 0x00000012;
|
||||||
|
tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
|
||||||
|
timeout = 0xFFFF;
|
||||||
|
while((tmpreg != 0) && (timeout-- > 0))
|
||||||
|
{
|
||||||
|
tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Auto refresh command */
|
||||||
|
FMC_Bank5_6->SDCMR = 0x00000073;
|
||||||
|
tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
|
||||||
|
timeout = 0xFFFF;
|
||||||
|
while((tmpreg != 0) && (timeout-- > 0))
|
||||||
|
{
|
||||||
|
tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* MRD register program */
|
||||||
|
FMC_Bank5_6->SDCMR = 0x00046014;
|
||||||
|
tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
|
||||||
|
timeout = 0xFFFF;
|
||||||
|
while((tmpreg != 0) && (timeout-- > 0))
|
||||||
|
{
|
||||||
|
tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set refresh count */
|
||||||
|
tmpreg = FMC_Bank5_6->SDRTR;
|
||||||
|
FMC_Bank5_6->SDRTR = (tmpreg | (0x0000027C<<1));
|
||||||
|
|
||||||
|
/* Disable write protection */
|
||||||
|
tmpreg = FMC_Bank5_6->SDCR[0];
|
||||||
|
FMC_Bank5_6->SDCR[0] = (tmpreg & 0xFFFFFDFF);
|
||||||
|
|
||||||
|
#if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)
|
||||||
|
/* Configure and enable Bank1_SRAM2 */
|
||||||
|
FMC_Bank1->BTCR[2] = 0x00001011;
|
||||||
|
FMC_Bank1->BTCR[3] = 0x00000201;
|
||||||
|
FMC_Bank1E->BWTR[2] = 0x0fffffff;
|
||||||
|
#endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */
|
||||||
|
#if defined(STM32F469xx) || defined(STM32F479xx)
|
||||||
|
/* Configure and enable Bank1_SRAM2 */
|
||||||
|
FMC_Bank1->BTCR[2] = 0x00001091;
|
||||||
|
FMC_Bank1->BTCR[3] = 0x00110212;
|
||||||
|
FMC_Bank1E->BWTR[2] = 0x0fffffff;
|
||||||
|
#endif /* STM32F469xx || STM32F479xx */
|
||||||
|
|
||||||
|
(void)(tmp);
|
||||||
|
}
|
||||||
|
#endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx */
|
||||||
|
#elif defined (DATA_IN_ExtSRAM) || defined (DATA_IN_ExtSDRAM)
|
||||||
|
/**
|
||||||
|
* @brief Setup the external memory controller.
|
||||||
|
* Called in startup_stm32f4xx.s before jump to main.
|
||||||
|
* This function configures the external memories (SRAM/SDRAM)
|
||||||
|
* This SRAM/SDRAM will be used as program data memory (including heap and stack).
|
||||||
|
* @param None
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
void SystemInit_ExtMemCtl(void)
|
||||||
|
{
|
||||||
|
__IO uint32_t tmp = 0x00;
|
||||||
|
#if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)\
|
||||||
|
|| defined(STM32F446xx) || defined(STM32F469xx) || defined(STM32F479xx)
|
||||||
|
#if defined (DATA_IN_ExtSDRAM)
|
||||||
|
register uint32_t tmpreg = 0, timeout = 0xFFFF;
|
||||||
|
register __IO uint32_t index;
|
||||||
|
|
||||||
|
#if defined(STM32F446xx)
|
||||||
|
/* Enable GPIOA, GPIOC, GPIOD, GPIOE, GPIOF, GPIOG interface
|
||||||
|
clock */
|
||||||
|
RCC->AHB1ENR |= 0x0000007D;
|
||||||
|
#else
|
||||||
|
/* Enable GPIOC, GPIOD, GPIOE, GPIOF, GPIOG, GPIOH and GPIOI interface
|
||||||
|
clock */
|
||||||
|
RCC->AHB1ENR |= 0x000001F8;
|
||||||
|
#endif /* STM32F446xx */
|
||||||
|
/* Delay after an RCC peripheral clock enabling */
|
||||||
|
tmp = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOCEN);
|
||||||
|
|
||||||
|
#if defined(STM32F446xx)
|
||||||
|
/* Connect PAx pins to FMC Alternate function */
|
||||||
|
GPIOA->AFR[0] |= 0xC0000000;
|
||||||
|
GPIOA->AFR[1] |= 0x00000000;
|
||||||
|
/* Configure PDx pins in Alternate function mode */
|
||||||
|
GPIOA->MODER |= 0x00008000;
|
||||||
|
/* Configure PDx pins speed to 50 MHz */
|
||||||
|
GPIOA->OSPEEDR |= 0x00008000;
|
||||||
|
/* Configure PDx pins Output type to push-pull */
|
||||||
|
GPIOA->OTYPER |= 0x00000000;
|
||||||
|
/* No pull-up, pull-down for PDx pins */
|
||||||
|
GPIOA->PUPDR |= 0x00000000;
|
||||||
|
|
||||||
|
/* Connect PCx pins to FMC Alternate function */
|
||||||
|
GPIOC->AFR[0] |= 0x00CC0000;
|
||||||
|
GPIOC->AFR[1] |= 0x00000000;
|
||||||
|
/* Configure PDx pins in Alternate function mode */
|
||||||
|
GPIOC->MODER |= 0x00000A00;
|
||||||
|
/* Configure PDx pins speed to 50 MHz */
|
||||||
|
GPIOC->OSPEEDR |= 0x00000A00;
|
||||||
|
/* Configure PDx pins Output type to push-pull */
|
||||||
|
GPIOC->OTYPER |= 0x00000000;
|
||||||
|
/* No pull-up, pull-down for PDx pins */
|
||||||
|
GPIOC->PUPDR |= 0x00000000;
|
||||||
|
#endif /* STM32F446xx */
|
||||||
|
|
||||||
|
/* Connect PDx pins to FMC Alternate function */
|
||||||
|
GPIOD->AFR[0] = 0x000000CC;
|
||||||
|
GPIOD->AFR[1] = 0xCC000CCC;
|
||||||
|
/* Configure PDx pins in Alternate function mode */
|
||||||
|
GPIOD->MODER = 0xA02A000A;
|
||||||
|
/* Configure PDx pins speed to 50 MHz */
|
||||||
|
GPIOD->OSPEEDR = 0xA02A000A;
|
||||||
|
/* Configure PDx pins Output type to push-pull */
|
||||||
|
GPIOD->OTYPER = 0x00000000;
|
||||||
|
/* No pull-up, pull-down for PDx pins */
|
||||||
|
GPIOD->PUPDR = 0x00000000;
|
||||||
|
|
||||||
|
/* Connect PEx pins to FMC Alternate function */
|
||||||
|
GPIOE->AFR[0] = 0xC00000CC;
|
||||||
|
GPIOE->AFR[1] = 0xCCCCCCCC;
|
||||||
|
/* Configure PEx pins in Alternate function mode */
|
||||||
|
GPIOE->MODER = 0xAAAA800A;
|
||||||
|
/* Configure PEx pins speed to 50 MHz */
|
||||||
|
GPIOE->OSPEEDR = 0xAAAA800A;
|
||||||
|
/* Configure PEx pins Output type to push-pull */
|
||||||
|
GPIOE->OTYPER = 0x00000000;
|
||||||
|
/* No pull-up, pull-down for PEx pins */
|
||||||
|
GPIOE->PUPDR = 0x00000000;
|
||||||
|
|
||||||
|
/* Connect PFx pins to FMC Alternate function */
|
||||||
|
GPIOF->AFR[0] = 0xCCCCCCCC;
|
||||||
|
GPIOF->AFR[1] = 0xCCCCCCCC;
|
||||||
|
/* Configure PFx pins in Alternate function mode */
|
||||||
|
GPIOF->MODER = 0xAA800AAA;
|
||||||
|
/* Configure PFx pins speed to 50 MHz */
|
||||||
|
GPIOF->OSPEEDR = 0xAA800AAA;
|
||||||
|
/* Configure PFx pins Output type to push-pull */
|
||||||
|
GPIOF->OTYPER = 0x00000000;
|
||||||
|
/* No pull-up, pull-down for PFx pins */
|
||||||
|
GPIOF->PUPDR = 0x00000000;
|
||||||
|
|
||||||
|
/* Connect PGx pins to FMC Alternate function */
|
||||||
|
GPIOG->AFR[0] = 0xCCCCCCCC;
|
||||||
|
GPIOG->AFR[1] = 0xCCCCCCCC;
|
||||||
|
/* Configure PGx pins in Alternate function mode */
|
||||||
|
GPIOG->MODER = 0xAAAAAAAA;
|
||||||
|
/* Configure PGx pins speed to 50 MHz */
|
||||||
|
GPIOG->OSPEEDR = 0xAAAAAAAA;
|
||||||
|
/* Configure PGx pins Output type to push-pull */
|
||||||
|
GPIOG->OTYPER = 0x00000000;
|
||||||
|
/* No pull-up, pull-down for PGx pins */
|
||||||
|
GPIOG->PUPDR = 0x00000000;
|
||||||
|
|
||||||
|
#if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)\
|
||||||
|
|| defined(STM32F469xx) || defined(STM32F479xx)
|
||||||
|
/* Connect PHx pins to FMC Alternate function */
|
||||||
|
GPIOH->AFR[0] = 0x00C0CC00;
|
||||||
|
GPIOH->AFR[1] = 0xCCCCCCCC;
|
||||||
|
/* Configure PHx pins in Alternate function mode */
|
||||||
|
GPIOH->MODER = 0xAAAA08A0;
|
||||||
|
/* Configure PHx pins speed to 50 MHz */
|
||||||
|
GPIOH->OSPEEDR = 0xAAAA08A0;
|
||||||
|
/* Configure PHx pins Output type to push-pull */
|
||||||
|
GPIOH->OTYPER = 0x00000000;
|
||||||
|
/* No pull-up, pull-down for PHx pins */
|
||||||
|
GPIOH->PUPDR = 0x00000000;
|
||||||
|
|
||||||
|
/* Connect PIx pins to FMC Alternate function */
|
||||||
|
GPIOI->AFR[0] = 0xCCCCCCCC;
|
||||||
|
GPIOI->AFR[1] = 0x00000CC0;
|
||||||
|
/* Configure PIx pins in Alternate function mode */
|
||||||
|
GPIOI->MODER = 0x0028AAAA;
|
||||||
|
/* Configure PIx pins speed to 50 MHz */
|
||||||
|
GPIOI->OSPEEDR = 0x0028AAAA;
|
||||||
|
/* Configure PIx pins Output type to push-pull */
|
||||||
|
GPIOI->OTYPER = 0x00000000;
|
||||||
|
/* No pull-up, pull-down for PIx pins */
|
||||||
|
GPIOI->PUPDR = 0x00000000;
|
||||||
|
#endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx */
|
||||||
|
|
||||||
|
/*-- FMC Configuration -------------------------------------------------------*/
|
||||||
|
/* Enable the FMC interface clock */
|
||||||
|
RCC->AHB3ENR |= 0x00000001;
|
||||||
|
/* Delay after an RCC peripheral clock enabling */
|
||||||
|
tmp = READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FMCEN);
|
||||||
|
|
||||||
|
/* Configure and enable SDRAM bank1 */
|
||||||
|
#if defined(STM32F446xx)
|
||||||
|
FMC_Bank5_6->SDCR[0] = 0x00001954;
|
||||||
|
#else
|
||||||
|
FMC_Bank5_6->SDCR[0] = 0x000019E4;
|
||||||
|
#endif /* STM32F446xx */
|
||||||
|
FMC_Bank5_6->SDTR[0] = 0x01115351;
|
||||||
|
|
||||||
|
/* SDRAM initialization sequence */
|
||||||
|
/* Clock enable command */
|
||||||
|
FMC_Bank5_6->SDCMR = 0x00000011;
|
||||||
|
tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
|
||||||
|
while((tmpreg != 0) && (timeout-- > 0))
|
||||||
|
{
|
||||||
|
tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Delay */
|
||||||
|
for (index = 0; index<1000; index++);
|
||||||
|
|
||||||
|
/* PALL command */
|
||||||
|
FMC_Bank5_6->SDCMR = 0x00000012;
|
||||||
|
tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
|
||||||
|
timeout = 0xFFFF;
|
||||||
|
while((tmpreg != 0) && (timeout-- > 0))
|
||||||
|
{
|
||||||
|
tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Auto refresh command */
|
||||||
|
#if defined(STM32F446xx)
|
||||||
|
FMC_Bank5_6->SDCMR = 0x000000F3;
|
||||||
|
#else
|
||||||
|
FMC_Bank5_6->SDCMR = 0x00000073;
|
||||||
|
#endif /* STM32F446xx */
|
||||||
|
tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
|
||||||
|
timeout = 0xFFFF;
|
||||||
|
while((tmpreg != 0) && (timeout-- > 0))
|
||||||
|
{
|
||||||
|
tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* MRD register program */
|
||||||
|
#if defined(STM32F446xx)
|
||||||
|
FMC_Bank5_6->SDCMR = 0x00044014;
|
||||||
|
#else
|
||||||
|
FMC_Bank5_6->SDCMR = 0x00046014;
|
||||||
|
#endif /* STM32F446xx */
|
||||||
|
tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
|
||||||
|
timeout = 0xFFFF;
|
||||||
|
while((tmpreg != 0) && (timeout-- > 0))
|
||||||
|
{
|
||||||
|
tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set refresh count */
|
||||||
|
tmpreg = FMC_Bank5_6->SDRTR;
|
||||||
|
#if defined(STM32F446xx)
|
||||||
|
FMC_Bank5_6->SDRTR = (tmpreg | (0x0000050C<<1));
|
||||||
|
#else
|
||||||
|
FMC_Bank5_6->SDRTR = (tmpreg | (0x0000027C<<1));
|
||||||
|
#endif /* STM32F446xx */
|
||||||
|
|
||||||
|
/* Disable write protection */
|
||||||
|
tmpreg = FMC_Bank5_6->SDCR[0];
|
||||||
|
FMC_Bank5_6->SDCR[0] = (tmpreg & 0xFFFFFDFF);
|
||||||
|
#endif /* DATA_IN_ExtSDRAM */
|
||||||
|
#endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F446xx || STM32F469xx || STM32F479xx */
|
||||||
|
|
||||||
|
#if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx)\
|
||||||
|
|| defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)\
|
||||||
|
|| defined(STM32F469xx) || defined(STM32F479xx) || defined(STM32F412Zx) || defined(STM32F412Vx)
|
||||||
|
|
||||||
|
#if defined(DATA_IN_ExtSRAM)
|
||||||
|
/*-- GPIOs Configuration -----------------------------------------------------*/
|
||||||
|
/* Enable GPIOD, GPIOE, GPIOF and GPIOG interface clock */
|
||||||
|
RCC->AHB1ENR |= 0x00000078;
|
||||||
|
/* Delay after an RCC peripheral clock enabling */
|
||||||
|
tmp = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIODEN);
|
||||||
|
|
||||||
|
/* Connect PDx pins to FMC Alternate function */
|
||||||
|
GPIOD->AFR[0] = 0x00CCC0CC;
|
||||||
|
GPIOD->AFR[1] = 0xCCCCCCCC;
|
||||||
|
/* Configure PDx pins in Alternate function mode */
|
||||||
|
GPIOD->MODER = 0xAAAA0A8A;
|
||||||
|
/* Configure PDx pins speed to 100 MHz */
|
||||||
|
GPIOD->OSPEEDR = 0xFFFF0FCF;
|
||||||
|
/* Configure PDx pins Output type to push-pull */
|
||||||
|
GPIOD->OTYPER = 0x00000000;
|
||||||
|
/* No pull-up, pull-down for PDx pins */
|
||||||
|
GPIOD->PUPDR = 0x00000000;
|
||||||
|
|
||||||
|
/* Connect PEx pins to FMC Alternate function */
|
||||||
|
GPIOE->AFR[0] = 0xC00CC0CC;
|
||||||
|
GPIOE->AFR[1] = 0xCCCCCCCC;
|
||||||
|
/* Configure PEx pins in Alternate function mode */
|
||||||
|
GPIOE->MODER = 0xAAAA828A;
|
||||||
|
/* Configure PEx pins speed to 100 MHz */
|
||||||
|
GPIOE->OSPEEDR = 0xFFFFC3CF;
|
||||||
|
/* Configure PEx pins Output type to push-pull */
|
||||||
|
GPIOE->OTYPER = 0x00000000;
|
||||||
|
/* No pull-up, pull-down for PEx pins */
|
||||||
|
GPIOE->PUPDR = 0x00000000;
|
||||||
|
|
||||||
|
/* Connect PFx pins to FMC Alternate function */
|
||||||
|
GPIOF->AFR[0] = 0x00CCCCCC;
|
||||||
|
GPIOF->AFR[1] = 0xCCCC0000;
|
||||||
|
/* Configure PFx pins in Alternate function mode */
|
||||||
|
GPIOF->MODER = 0xAA000AAA;
|
||||||
|
/* Configure PFx pins speed to 100 MHz */
|
||||||
|
GPIOF->OSPEEDR = 0xFF000FFF;
|
||||||
|
/* Configure PFx pins Output type to push-pull */
|
||||||
|
GPIOF->OTYPER = 0x00000000;
|
||||||
|
/* No pull-up, pull-down for PFx pins */
|
||||||
|
GPIOF->PUPDR = 0x00000000;
|
||||||
|
|
||||||
|
/* Connect PGx pins to FMC Alternate function */
|
||||||
|
GPIOG->AFR[0] = 0x00CCCCCC;
|
||||||
|
GPIOG->AFR[1] = 0x000000C0;
|
||||||
|
/* Configure PGx pins in Alternate function mode */
|
||||||
|
GPIOG->MODER = 0x00085AAA;
|
||||||
|
/* Configure PGx pins speed to 100 MHz */
|
||||||
|
GPIOG->OSPEEDR = 0x000CAFFF;
|
||||||
|
/* Configure PGx pins Output type to push-pull */
|
||||||
|
GPIOG->OTYPER = 0x00000000;
|
||||||
|
/* No pull-up, pull-down for PGx pins */
|
||||||
|
GPIOG->PUPDR = 0x00000000;
|
||||||
|
|
||||||
|
/*-- FMC/FSMC Configuration --------------------------------------------------*/
|
||||||
|
/* Enable the FMC/FSMC interface clock */
|
||||||
|
RCC->AHB3ENR |= 0x00000001;
|
||||||
|
|
||||||
|
#if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)
|
||||||
|
/* Delay after an RCC peripheral clock enabling */
|
||||||
|
tmp = READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FMCEN);
|
||||||
|
/* Configure and enable Bank1_SRAM2 */
|
||||||
|
FMC_Bank1->BTCR[2] = 0x00001011;
|
||||||
|
FMC_Bank1->BTCR[3] = 0x00000201;
|
||||||
|
FMC_Bank1E->BWTR[2] = 0x0fffffff;
|
||||||
|
#endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */
|
||||||
|
#if defined(STM32F469xx) || defined(STM32F479xx)
|
||||||
|
/* Delay after an RCC peripheral clock enabling */
|
||||||
|
tmp = READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FMCEN);
|
||||||
|
/* Configure and enable Bank1_SRAM2 */
|
||||||
|
FMC_Bank1->BTCR[2] = 0x00001091;
|
||||||
|
FMC_Bank1->BTCR[3] = 0x00110212;
|
||||||
|
FMC_Bank1E->BWTR[2] = 0x0fffffff;
|
||||||
|
#endif /* STM32F469xx || STM32F479xx */
|
||||||
|
#if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx)|| defined(STM32F417xx)\
|
||||||
|
|| defined(STM32F412Zx) || defined(STM32F412Vx)
|
||||||
|
/* Delay after an RCC peripheral clock enabling */
|
||||||
|
tmp = READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FSMCEN);
|
||||||
|
/* Configure and enable Bank1_SRAM2 */
|
||||||
|
FSMC_Bank1->BTCR[2] = 0x00001011;
|
||||||
|
FSMC_Bank1->BTCR[3] = 0x00000201;
|
||||||
|
FSMC_Bank1E->BWTR[2] = 0x0FFFFFFF;
|
||||||
|
#endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F412Zx || STM32F412Vx */
|
||||||
|
|
||||||
|
#endif /* DATA_IN_ExtSRAM */
|
||||||
|
#endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F427xx || STM32F437xx ||\
|
||||||
|
STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx || STM32F412Zx || STM32F412Vx */
|
||||||
|
(void)(tmp);
|
||||||
|
}
|
||||||
|
#endif /* DATA_IN_ExtSRAM && DATA_IN_ExtSDRAM */
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
145
core/src/tim.c
Normal file
145
core/src/tim.c
Normal file
@ -0,0 +1,145 @@
|
|||||||
|
/* USER CODE BEGIN Header */
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file tim.c
|
||||||
|
* @brief This file provides code for the configuration
|
||||||
|
* of the TIM instances.
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* Copyright (c) 2024 STMicroelectronics.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This software is licensed under terms that can be found in the LICENSE file
|
||||||
|
* in the root directory of this software component.
|
||||||
|
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
/* USER CODE END Header */
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "tim.h"
|
||||||
|
|
||||||
|
/* USER CODE BEGIN 0 */
|
||||||
|
|
||||||
|
/* USER CODE END 0 */
|
||||||
|
|
||||||
|
TIM_HandleTypeDef htim3;
|
||||||
|
|
||||||
|
/* TIM3 init function */
|
||||||
|
void MX_TIM3_Init(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
/* USER CODE BEGIN TIM3_Init 0 */
|
||||||
|
|
||||||
|
/* USER CODE END TIM3_Init 0 */
|
||||||
|
|
||||||
|
TIM_ClockConfigTypeDef sClockSourceConfig = {0};
|
||||||
|
TIM_MasterConfigTypeDef sMasterConfig = {0};
|
||||||
|
TIM_OC_InitTypeDef sConfigOC = {0};
|
||||||
|
|
||||||
|
/* USER CODE BEGIN TIM3_Init 1 */
|
||||||
|
|
||||||
|
/* USER CODE END TIM3_Init 1 */
|
||||||
|
htim3.Instance = TIM3;
|
||||||
|
htim3.Init.Prescaler = 6719;
|
||||||
|
htim3.Init.CounterMode = TIM_COUNTERMODE_UP;
|
||||||
|
htim3.Init.Period = 2500;
|
||||||
|
htim3.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
|
||||||
|
htim3.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_ENABLE;
|
||||||
|
if (HAL_TIM_Base_Init(&htim3) != HAL_OK)
|
||||||
|
{
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
|
||||||
|
if (HAL_TIM_ConfigClockSource(&htim3, &sClockSourceConfig) != HAL_OK)
|
||||||
|
{
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
if (HAL_TIM_OC_Init(&htim3) != HAL_OK)
|
||||||
|
{
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
sMasterConfig.MasterOutputTrigger = TIM_TRGO_UPDATE;
|
||||||
|
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
|
||||||
|
if (HAL_TIMEx_MasterConfigSynchronization(&htim3, &sMasterConfig) != HAL_OK)
|
||||||
|
{
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
sConfigOC.OCMode = TIM_OCMODE_TOGGLE;
|
||||||
|
sConfigOC.Pulse = 0;
|
||||||
|
sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH;
|
||||||
|
sConfigOC.OCFastMode = TIM_OCFAST_DISABLE;
|
||||||
|
if (HAL_TIM_OC_ConfigChannel(&htim3, &sConfigOC, TIM_CHANNEL_1) != HAL_OK)
|
||||||
|
{
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
/* USER CODE BEGIN TIM3_Init 2 */
|
||||||
|
|
||||||
|
/* USER CODE END TIM3_Init 2 */
|
||||||
|
HAL_TIM_MspPostInit(&htim3);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* tim_baseHandle)
|
||||||
|
{
|
||||||
|
|
||||||
|
if(tim_baseHandle->Instance==TIM3)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN TIM3_MspInit 0 */
|
||||||
|
|
||||||
|
/* USER CODE END TIM3_MspInit 0 */
|
||||||
|
/* TIM3 clock enable */
|
||||||
|
__HAL_RCC_TIM3_CLK_ENABLE();
|
||||||
|
/* USER CODE BEGIN TIM3_MspInit 1 */
|
||||||
|
|
||||||
|
/* USER CODE END TIM3_MspInit 1 */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void HAL_TIM_MspPostInit(TIM_HandleTypeDef* timHandle)
|
||||||
|
{
|
||||||
|
|
||||||
|
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
||||||
|
if(timHandle->Instance==TIM3)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN TIM3_MspPostInit 0 */
|
||||||
|
|
||||||
|
/* USER CODE END TIM3_MspPostInit 0 */
|
||||||
|
|
||||||
|
__HAL_RCC_GPIOC_CLK_ENABLE();
|
||||||
|
/**TIM3 GPIO Configuration
|
||||||
|
PC6 ------> TIM3_CH1
|
||||||
|
*/
|
||||||
|
GPIO_InitStruct.Pin = GPIO_PIN_6;
|
||||||
|
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||||
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||||
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||||
|
GPIO_InitStruct.Alternate = GPIO_AF2_TIM3;
|
||||||
|
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
/* USER CODE BEGIN TIM3_MspPostInit 1 */
|
||||||
|
|
||||||
|
/* USER CODE END TIM3_MspPostInit 1 */
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* tim_baseHandle)
|
||||||
|
{
|
||||||
|
|
||||||
|
if(tim_baseHandle->Instance==TIM3)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN TIM3_MspDeInit 0 */
|
||||||
|
|
||||||
|
/* USER CODE END TIM3_MspDeInit 0 */
|
||||||
|
/* Peripheral clock disable */
|
||||||
|
__HAL_RCC_TIM3_CLK_DISABLE();
|
||||||
|
/* USER CODE BEGIN TIM3_MspDeInit 1 */
|
||||||
|
|
||||||
|
/* USER CODE END TIM3_MspDeInit 1 */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* USER CODE BEGIN 1 */
|
||||||
|
|
||||||
|
/* USER CODE END 1 */
|
114
core/src/usart.c
Normal file
114
core/src/usart.c
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
/* USER CODE BEGIN Header */
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file usart.c
|
||||||
|
* @brief This file provides code for the configuration
|
||||||
|
* of the USART instances.
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* Copyright (c) 2024 STMicroelectronics.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This software is licensed under terms that can be found in the LICENSE file
|
||||||
|
* in the root directory of this software component.
|
||||||
|
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
/* USER CODE END Header */
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "usart.h"
|
||||||
|
|
||||||
|
/* USER CODE BEGIN 0 */
|
||||||
|
|
||||||
|
/* USER CODE END 0 */
|
||||||
|
|
||||||
|
UART_HandleTypeDef huart1;
|
||||||
|
|
||||||
|
/* USART1 init function */
|
||||||
|
|
||||||
|
void MX_USART1_UART_Init(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
/* USER CODE BEGIN USART1_Init 0 */
|
||||||
|
|
||||||
|
/* USER CODE END USART1_Init 0 */
|
||||||
|
|
||||||
|
/* USER CODE BEGIN USART1_Init 1 */
|
||||||
|
|
||||||
|
/* USER CODE END USART1_Init 1 */
|
||||||
|
huart1.Instance = USART1;
|
||||||
|
huart1.Init.BaudRate = 115200;
|
||||||
|
huart1.Init.WordLength = UART_WORDLENGTH_8B;
|
||||||
|
huart1.Init.StopBits = UART_STOPBITS_1;
|
||||||
|
huart1.Init.Parity = UART_PARITY_NONE;
|
||||||
|
huart1.Init.Mode = UART_MODE_TX_RX;
|
||||||
|
huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE;
|
||||||
|
huart1.Init.OverSampling = UART_OVERSAMPLING_16;
|
||||||
|
if (HAL_UART_Init(&huart1) != HAL_OK)
|
||||||
|
{
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
/* USER CODE BEGIN USART1_Init 2 */
|
||||||
|
|
||||||
|
/* USER CODE END USART1_Init 2 */
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void HAL_UART_MspInit(UART_HandleTypeDef* uartHandle)
|
||||||
|
{
|
||||||
|
|
||||||
|
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
||||||
|
if(uartHandle->Instance==USART1)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN USART1_MspInit 0 */
|
||||||
|
|
||||||
|
/* USER CODE END USART1_MspInit 0 */
|
||||||
|
/* USART1 clock enable */
|
||||||
|
__HAL_RCC_USART1_CLK_ENABLE();
|
||||||
|
|
||||||
|
__HAL_RCC_GPIOA_CLK_ENABLE();
|
||||||
|
/**USART1 GPIO Configuration
|
||||||
|
PA9 ------> USART1_TX
|
||||||
|
PA10 ------> USART1_RX
|
||||||
|
*/
|
||||||
|
GPIO_InitStruct.Pin = GPIO_PIN_9|GPIO_PIN_10;
|
||||||
|
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||||
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||||
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
||||||
|
GPIO_InitStruct.Alternate = GPIO_AF7_USART1;
|
||||||
|
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
/* USER CODE BEGIN USART1_MspInit 1 */
|
||||||
|
|
||||||
|
/* USER CODE END USART1_MspInit 1 */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void HAL_UART_MspDeInit(UART_HandleTypeDef* uartHandle)
|
||||||
|
{
|
||||||
|
|
||||||
|
if(uartHandle->Instance==USART1)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN USART1_MspDeInit 0 */
|
||||||
|
|
||||||
|
/* USER CODE END USART1_MspDeInit 0 */
|
||||||
|
/* Peripheral clock disable */
|
||||||
|
__HAL_RCC_USART1_CLK_DISABLE();
|
||||||
|
|
||||||
|
/**USART1 GPIO Configuration
|
||||||
|
PA9 ------> USART1_TX
|
||||||
|
PA10 ------> USART1_RX
|
||||||
|
*/
|
||||||
|
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_9|GPIO_PIN_10);
|
||||||
|
|
||||||
|
/* USER CODE BEGIN USART1_MspDeInit 1 */
|
||||||
|
|
||||||
|
/* USER CODE END USART1_MspDeInit 1 */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* USER CODE BEGIN 1 */
|
||||||
|
|
||||||
|
/* USER CODE END 1 */
|
1
libs/STAHR-defs
Submodule
1
libs/STAHR-defs
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit 7ee21a8ecf574513688b5911b034bd55ab4f6e87
|
1
libs/TACOS
Submodule
1
libs/TACOS
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit 60ac80c7cffd2e082deabdd0aeb904ea9025b078
|
1
libs/rtos2-utils
Submodule
1
libs/rtos2-utils
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit 7da4daeb204b5064130aa9e8b62c2d32fa29cf99
|
1
libs/sta-core
Submodule
1
libs/sta-core
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit 4f3b9953eab63f0a55519ccc7fcb0f3d73eeb1f8
|
1
libs/stm32-cmake
Submodule
1
libs/stm32-cmake
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit 5f5c92c1a0a88dd5d214f60402d4244af4e3b795
|
Loading…
x
Reference in New Issue
Block a user