Suppression de la tache par defaut créé par Cube MX qui pose probleme quand elle se termine, passage de la memoire dynamique de 1024 octets à 10240 octets, ajout du support du temps d'execution des taches et de la visualisation des queues et semaphore, reduction du nombre de priorité à 12

This commit is contained in:
dimercur 2024-01-12 16:58:43 +01:00
parent 1d1b2a7e52
commit bbc6c85192
11 changed files with 210 additions and 38 deletions

View file

@ -22,6 +22,7 @@
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_coreid.1508870668" name="Core" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_coreid" useByScannerDiscovery="false" value="0" valueType="string"/> <option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_coreid.1508870668" name="Core" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_coreid" useByScannerDiscovery="false" value="0" valueType="string"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_board.475855176" name="Board" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_board" useByScannerDiscovery="false" value="genericBoard" valueType="string"/> <option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_board.475855176" name="Board" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_board" useByScannerDiscovery="false" value="genericBoard" valueType="string"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults.802392362" name="Defaults" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults" useByScannerDiscovery="false" value="com.st.stm32cube.ide.common.services.build.inputs.revA.1.0.5 || Debug || true || Executable || com.st.stm32cube.ide.mcu.gnu.managedbuild.option.toolchain.value.workspace || STM32L071CBTx || 0 || 0 || arm-none-eabi- || ${gnu_tools_for_stm32_compiler_path} || ../Middlewares/Third_Party/FreeRTOS/Source/include | ../Drivers/CMSIS/Include | ../Core/Inc | ../Drivers/STM32L0xx_HAL_Driver/Inc | ../Drivers/CMSIS/Device/ST/STM32L0xx/Include | ../Drivers/STM32L0xx_HAL_Driver/Inc/Legacy | ../Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2 | ../Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM0 || || || USE_HAL_DRIVER | STM32L010x6 || || Drivers | Core/Startup | Middlewares | Core || || || ${workspace_loc:/${ProjName}/STM32L071CBTx_FLASH.ld} || true || NonSecure || || secure_nsclib.o || || None || " valueType="string"/> <option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults.802392362" name="Defaults" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults" useByScannerDiscovery="false" value="com.st.stm32cube.ide.common.services.build.inputs.revA.1.0.5 || Debug || true || Executable || com.st.stm32cube.ide.mcu.gnu.managedbuild.option.toolchain.value.workspace || STM32L071CBTx || 0 || 0 || arm-none-eabi- || ${gnu_tools_for_stm32_compiler_path} || ../Middlewares/Third_Party/FreeRTOS/Source/include | ../Drivers/CMSIS/Include | ../Core/Inc | ../Drivers/STM32L0xx_HAL_Driver/Inc | ../Drivers/CMSIS/Device/ST/STM32L0xx/Include | ../Drivers/STM32L0xx_HAL_Driver/Inc/Legacy | ../Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2 | ../Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM0 || || || USE_HAL_DRIVER | STM32L010x6 || || Drivers | Core/Startup | Middlewares | Core || || || ${workspace_loc:/${ProjName}/STM32L071CBTx_FLASH.ld} || true || NonSecure || || secure_nsclib.o || || None || " valueType="string"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.runtimelibrary_c.1064254422" name="Runtime library" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.runtimelibrary_c" useByScannerDiscovery="true" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.runtimelibrary_c.value.nano_c" valueType="enumerated"/>
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.targetplatform.1582271634" isAbstract="false" osList="all" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.targetplatform"/> <targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.targetplatform.1582271634" isAbstract="false" osList="all" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.targetplatform"/>
<builder buildPath="${workspace_loc:/Dumber3}/Debug" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.builder.1329460993" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" parallelBuildOn="true" parallelizationNumber="optimal" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.builder"/> <builder buildPath="${workspace_loc:/Dumber3}/Debug" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.builder.1329460993" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" parallelBuildOn="true" parallelizationNumber="optimal" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.builder"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.635805233" name="MCU GCC Assembler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler"> <tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.635805233" name="MCU GCC Assembler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler">
@ -33,7 +34,7 @@
</tool> </tool>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.1474341646" name="MCU GCC Compiler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler"> <tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.1474341646" name="MCU GCC Compiler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler">
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.debuglevel.620486962" name="Debug level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.debuglevel" useByScannerDiscovery="false" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.debuglevel.value.g3" valueType="enumerated"/> <option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.debuglevel.620486962" name="Debug level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.debuglevel" useByScannerDiscovery="false" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.debuglevel.value.g3" valueType="enumerated"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level.2040942504" name="Optimization level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level" useByScannerDiscovery="false" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level.value.o2" valueType="enumerated"/> <option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level.2040942504" name="Optimization level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level" useByScannerDiscovery="false" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level.value.o0" valueType="enumerated"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.definedsymbols.1441075970" name="Define symbols (-D)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.definedsymbols" useByScannerDiscovery="false" valueType="definedSymbols"> <option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.definedsymbols.1441075970" name="Define symbols (-D)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.definedsymbols" useByScannerDiscovery="false" valueType="definedSymbols">
<listOptionValue builtIn="false" value="DEBUG"/> <listOptionValue builtIn="false" value="DEBUG"/>
<listOptionValue builtIn="false" value="USE_HAL_DRIVER"/> <listOptionValue builtIn="false" value="USE_HAL_DRIVER"/>
@ -74,17 +75,6 @@
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.symbolsrec.1896077029" name="MCU Output Converter Motorola S-rec with symbols" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.symbolsrec"/> <tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.symbolsrec.1896077029" name="MCU Output Converter Motorola S-rec with symbols" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.symbolsrec"/>
</toolChain> </toolChain>
</folderInfo> </folderInfo>
<fileInfo id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.debug.1504381080.16019415" name="application.c" rcbsApplicability="disable" resourcePath="Application/application.c" toolsToInvoke="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.1474341646.81377361">
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.1474341646.81377361" name="MCU GCC Compiler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.1474341646">
<inputType id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.input.c.2042394482" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.input.c"/>
</tool>
<tool customBuildStep="true" id="org.eclipse.cdt.managedbuilder.ui.rcbs.381948089" name="Resource Custom Build Step">
<inputType id="org.eclipse.cdt.managedbuilder.ui.rcbs.inputtype.2085933829" name="Resource Custom Build Step Input Type">
<additionalInput kind="additionalinputdependency"/>
</inputType>
<outputType id="org.eclipse.cdt.managedbuilder.ui.rcbs.outputtype.1128986474" name="Resource Custom Build Step Output Type"/>
</tool>
</fileInfo>
<sourceEntries> <sourceEntries>
<entry excluding="Xbee-API|XBEE" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Application"/> <entry excluding="Xbee-API|XBEE" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Application"/>
<entry excluding="XBEE" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Core"/> <entry excluding="XBEE" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Core"/>

View file

@ -5,7 +5,7 @@
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/> <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.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" 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="117839523036237333" 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 &quot;${INPUTS}&quot;" prefer-non-shared="true"> <provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="-1052077282282430101" 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 &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/> <language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/> <language-scope id="org.eclipse.cdt.core.g++"/>
</provider> </provider>
@ -16,7 +16,7 @@
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/> <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.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" 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="117839523036237333" 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 &quot;${INPUTS}&quot;" prefer-non-shared="true"> <provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="-1052077282282430101" 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 &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/> <language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/> <language-scope id="org.eclipse.cdt.core.g++"/>
</provider> </provider>
@ -27,7 +27,7 @@
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/> <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.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" 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="117839523036237333" 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 &quot;${INPUTS}&quot;" prefer-non-shared="true"> <provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="-1052077282282430101" 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 &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/> <language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/> <language-scope id="org.eclipse.cdt.core.g++"/>
</provider> </provider>

View file

@ -70,6 +70,7 @@
#include "battery.h" #include "battery.h"
#include "panic.h" #include "panic.h"
#include "rtos_support.h"
/** @addtogroup Application_Software /** @addtogroup Application_Software
* @{ * @{
@ -127,7 +128,7 @@ StaticTask_t xTaskApplicationMain;
/* Buffer that the task being created will use as its stack. Note this is /* Buffer that the task being created will use as its stack. Note this is
an array of StackType_t variables. The size of StackType_t is dependent on an array of StackType_t variables. The size of StackType_t is dependent on
the RTOS port. */ the RTOS port. */
StackType_t xStackApplicationMain[ STACK_SIZE ]; StackType_t xStackApplicationMain[ STACK_SIZE*2 ];
TaskHandle_t xHandleApplicationMain = NULL; TaskHandle_t xHandleApplicationMain = NULL;
StaticTimer_t xBufferTimerTimeout; StaticTimer_t xBufferTimerTimeout;
@ -148,6 +149,9 @@ APPLICATION_Timeout systemTimeout = {0};
* @return None * @return None
*/ */
void APPLICATION_Init(void) { void APPLICATION_Init(void) {
/* Init du support RTOS (notamment le timer de run time) */
//RTOS_SUPPORT_Init(); /* <- used for freertos run time usage */
/* Init des messages box */ /* Init des messages box */
MESSAGE_Init(); MESSAGE_Init();
@ -163,7 +167,7 @@ void APPLICATION_Init(void) {
xHandleApplicationMain = xTaskCreateStatic( xHandleApplicationMain = xTaskCreateStatic(
APPLICATION_Thread, /* Function that implements the task. */ APPLICATION_Thread, /* Function that implements the task. */
"APPLICATION Thread", /* Text name for the task. */ "APPLICATION Thread", /* Text name for the task. */
STACK_SIZE, /* Number of indexes in the xStack array. */ STACK_SIZE*2, /* Number of indexes in the xStack array. */
NULL, /* Parameter passed into the task. */ NULL, /* Parameter passed into the task. */
PriorityApplicationHandler,/* Priority at which the task is created. */ PriorityApplicationHandler,/* Priority at which the task is created. */
xStackApplicationMain, /* Array to use as the task's stack. */ xStackApplicationMain, /* Array to use as the task's stack. */

View file

@ -41,6 +41,8 @@
#include "xbee.h" #include "xbee.h"
#include "commands.h" #include "commands.h"
#include "rtos_support.h"
#include "main.h" #include "main.h"
/** @addtogroup Application_Software /** @addtogroup Application_Software

View file

@ -44,11 +44,11 @@
* Version in plain text and as a numeric value * Version in plain text and as a numeric value
*/ */
///@{ ///@{
#define SYSTEM_VERSION_STR "2.2" #define SYSTEM_VERSION_STR "2.3"
#define SYSTEM_VERSION 0x0202 // Upper byte: major version, lower byte: minor version #define SYSTEM_VERSION 0x0203 // Upper byte: major version, lower byte: minor version
///@} ///@}
#define STACK_SIZE 0x100 #define STACK_SIZE 64
/** @name Tasks priority constants /** @name Tasks priority constants
* Priority is based on configMAX_PRIORITIES which represent highest task priority. * Priority is based on configMAX_PRIORITIES which represent highest task priority.

View file

@ -62,6 +62,12 @@ void MESSAGE_Init(void) {
MOTORS_Mailbox = xQueueCreate(QUEUE_SIZE, sizeof(MESSAGE_Typedef)); MOTORS_Mailbox = xQueueCreate(QUEUE_SIZE, sizeof(MESSAGE_Typedef));
APPLICATION_Mailbox = xQueueCreate(QUEUE_SIZE, sizeof(MESSAGE_Typedef)); APPLICATION_Mailbox = xQueueCreate(QUEUE_SIZE, sizeof(MESSAGE_Typedef));
XBEE_Mailbox = xQueueCreate(QUEUE_SIZE, sizeof(MESSAGE_Typedef)); XBEE_Mailbox = xQueueCreate(QUEUE_SIZE, sizeof(MESSAGE_Typedef));
/* Add queues to registry in order to view them in stm32cube ide */
vQueueAddToRegistry(LEDS_Mailbox,"LEDS Mailbox");
vQueueAddToRegistry(MOTORS_Mailbox,"MOTORS Mailbox");
vQueueAddToRegistry(APPLICATION_Mailbox,"APPLICATION Mailbox");
vQueueAddToRegistry(XBEE_Mailbox,"XBEE Mailbox");
} }
/** /**

View file

@ -0,0 +1,115 @@
/**
******************************************************************************
* @file motors.c
* @brief motors driver body
* @author S. DI MERCURIO (dimercur@insa-toulouse.fr)
* @date December 2023
*
******************************************************************************
* @copyright Copyright 2023 INSA-GEI, Toulouse, France. All rights reserved.
* @copyright This project is released under the Lesser GNU Public License (LGPL-3.0-only).
*
* @copyright This file is part of "Dumber" project
*
* @copyright This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* @copyright 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
* Lesser General Public License for more details.
* @copyright You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
******************************************************************************
*/
#include "rtos_support.h"
#include "stm32l0xx_ll_tim.h"
/** @addtogroup Application_Software
* @{
*/
/** @addtogroup RTOS_SUPPORT
* RTOS support module provide several functions for task run time measurement.
* @{
*/
/** @addtogroup RTOS_SUPPORT_Private Private
* @{
*/
uint16_t RTOS_SUPPORT_counter16bitUpper=0;
/**
* @brief TIM7 Initialization Function
*/
void RTOS_SUPPORT_Init(void) {
TIM_ClockConfigTypeDef sClockSourceConfig = { 0 };
TIM_HandleTypeDef htim7;
__HAL_RCC_TIM7_CLK_ENABLE();
htim7.Instance = TIM7;
htim7.Init.Prescaler = 0;
htim7.Init.CounterMode = TIM_COUNTERMODE_UP;
htim7.Init.Period = 65535;
htim7.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
htim7.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
if (HAL_TIM_Base_Init(&htim7) != HAL_OK)
{
Error_Handler();
}
sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
if (HAL_TIM_ConfigClockSource(&htim7, &sClockSourceConfig) != HAL_OK) {
Error_Handler();
}
/* TIM7 interrupt Init */
LL_TIM_EnableIT_UPDATE(TIM7);
HAL_NVIC_SetPriority(TIM7_IRQn, 1, 0);
HAL_NVIC_EnableIRQ(TIM7_IRQn);
RTOS_SUPPORT_counter16bitUpper=0;
LL_TIM_EnableCounter(TIM7);
}
/**
* @brief Get 32bit emulated timer based on TIM7
*
* @return 32bit timer
*/
uint32_t RTOS_SUPPORT_GetTimer(void) {
uint16_t currentVal=LL_TIM_GetCounter(TIM7);
return (uint32_t)((((uint32_t)RTOS_SUPPORT_counter16bitUpper)<<16) + (uint32_t)currentVal);
}
/**
* @brief This function handles TIM7 update interrupt for 32bit
*/
void TIM7_IRQHandler(void) {
LL_TIM_ClearFlag_UPDATE(TIM7);
RTOS_SUPPORT_counter16bitUpper++;
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/

View file

@ -0,0 +1,40 @@
/*
* rtos_support.h
*
* Created on: Jan 12, 2024
* Author: dimercur
*/
#ifndef RTOS_SUPPORT_H_
#define RTOS_SUPPORT_H_
#include "application.h"
/** @addtogroup Application_Software
* @{
*/
/** @addtogroup RTOS_SUPPORT
* @{
*/
/** @addtogroup RTOS_SUPPORT_Public Public
* @{
*/
void RTOS_SUPPORT_Init(void);
uint32_t RTOS_SUPPORT_GetTimer(void);
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#endif /* RTOS_SUPPORT_H_ */

View file

@ -103,7 +103,6 @@ StackType_t xStackXbeeRX[ STACK_SIZE ];
TaskHandle_t xHandleXbeeRX = NULL; TaskHandle_t xHandleXbeeRX = NULL;
uint8_t rxBuffer[XBEE_RX_BUFFER_MAX_LENGTH]={0}; uint8_t rxBuffer[XBEE_RX_BUFFER_MAX_LENGTH]={0};
//uint8_t rxWaitForACK =0;
uint8_t rxPhase; uint8_t rxPhase;
uint16_t rxCmdLength; uint16_t rxCmdLength;
uint16_t rxDataToReceive; uint16_t rxDataToReceive;
@ -129,6 +128,10 @@ void XBEE_Init(void) {
xHandleSemaphoreRX = xSemaphoreCreateBinaryStatic( &xSemaphoreRx ); xHandleSemaphoreRX = xSemaphoreCreateBinaryStatic( &xSemaphoreRx );
/* Add semaphores to registry in order to view them in stm32cube ide */
vQueueAddToRegistry(xHandleSemaphoreTX,"XBEE TX sem");
vQueueAddToRegistry(xHandleSemaphoreRX,"XBEE RX sem");
/* Create the task without using any dynamic memory allocation. */ /* Create the task without using any dynamic memory allocation. */
xHandleXbeeRX = xTaskCreateStatic( xHandleXbeeRX = xTaskCreateStatic(
XBEE_RxThread, /* Function that implements the task. */ XBEE_RxThread, /* Function that implements the task. */

View file

@ -31,6 +31,9 @@
#ifndef FREERTOS_CONFIG_H #ifndef FREERTOS_CONFIG_H
#define FREERTOS_CONFIG_H #define FREERTOS_CONFIG_H
extern void RTOS_SUPPORT_Init(void);
extern uint32_t RTOS_SUPPORT_GetTimer(void);
/*----------------------------------------------------------- /*-----------------------------------------------------------
* Application specific definitions. * Application specific definitions.
* *
@ -62,9 +65,9 @@
#define configUSE_TICK_HOOK 0 #define configUSE_TICK_HOOK 0
#define configCPU_CLOCK_HZ ( SystemCoreClock ) #define configCPU_CLOCK_HZ ( SystemCoreClock )
#define configTICK_RATE_HZ ((TickType_t)1000) #define configTICK_RATE_HZ ((TickType_t)1000)
#define configMAX_PRIORITIES ( 56 ) #define configMAX_PRIORITIES ( 12 )
#define configMINIMAL_STACK_SIZE ((uint16_t)128) #define configMINIMAL_STACK_SIZE ((uint16_t)128)
#define configTOTAL_HEAP_SIZE ((size_t)1024) #define configTOTAL_HEAP_SIZE ((size_t)10240)
#define configMAX_TASK_NAME_LEN ( 25 ) #define configMAX_TASK_NAME_LEN ( 25 )
#define configUSE_TRACE_FACILITY 1 #define configUSE_TRACE_FACILITY 1
#define configUSE_16_BIT_TICKS 0 #define configUSE_16_BIT_TICKS 0
@ -82,13 +85,13 @@
/* Co-routine definitions. */ /* Co-routine definitions. */
#define configUSE_CO_ROUTINES 0 #define configUSE_CO_ROUTINES 0
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 ) #define configMAX_CO_ROUTINE_PRIORITIES ( 1 )
/* Software timer definitions. */ /* Software timer definitions. */
#define configUSE_TIMERS 1 #define configUSE_TIMERS 1
#define configTIMER_TASK_PRIORITY ( 3 ) #define configTIMER_TASK_PRIORITY ( 1 )
#define configTIMER_QUEUE_LENGTH 10 #define configTIMER_QUEUE_LENGTH 10
#define configTIMER_TASK_STACK_DEPTH 256 #define configTIMER_TASK_STACK_DEPTH 64
/* The following flag must be enabled only when using newlib */ /* The following flag must be enabled only when using newlib */
#define configUSE_NEWLIB_REENTRANT 1 #define configUSE_NEWLIB_REENTRANT 1
@ -152,4 +155,8 @@ placed into the low power state respectively. */
#define configPOST_SLEEP_PROCESSING PostSleepProcessing #define configPOST_SLEEP_PROCESSING PostSleepProcessing
#endif /* configUSE_TICKLESS_IDLE == 1 */ #endif /* configUSE_TICKLESS_IDLE == 1 */
#define configGENERATE_RUN_TIME_STATS 1
#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() RTOS_SUPPORT_Init()
#define portGET_RUN_TIME_COUNTER_VALUE() RTOS_SUPPORT_GetTimer()
#endif /* FREERTOS_CONFIG_H */ #endif /* FREERTOS_CONFIG_H */

View file

@ -55,12 +55,12 @@ TIM_HandleTypeDef htim3;
TIM_HandleTypeDef htim21; TIM_HandleTypeDef htim21;
/* Definitions for defaultTask */ /* Definitions for defaultTask */
osThreadId_t defaultTaskHandle; //osThreadId_t defaultTaskHandle;
const osThreadAttr_t defaultTask_attributes = { //const osThreadAttr_t defaultTask_attributes = {
.name = "defaultTask", // .name = "defaultTask",
.stack_size = 128 * 4, // .stack_size = 128 * 4,
.priority = (osPriority_t) osPriorityNormal, // .priority = (osPriority_t) osPriorityNormal,
}; //};
/* USER CODE BEGIN PV */ /* USER CODE BEGIN PV */
/* USER CODE END PV */ /* USER CODE END PV */
@ -146,7 +146,7 @@ int main(void)
/* Create the thread(s) */ /* Create the thread(s) */
/* creation of defaultTask */ /* creation of defaultTask */
defaultTaskHandle = osThreadNew(StartDefaultTask, NULL, &defaultTask_attributes); //defaultTaskHandle = osThreadNew(StartDefaultTask, NULL, &defaultTask_attributes);
/* USER CODE BEGIN RTOS_THREADS */ /* USER CODE BEGIN RTOS_THREADS */
/* add threads, ... */ /* add threads, ... */
@ -644,9 +644,9 @@ TickType_t msToTicks(TickType_t ms) {
* @retval None * @retval None
*/ */
/* USER CODE END Header_StartDefaultTask */ /* USER CODE END Header_StartDefaultTask */
void StartDefaultTask(void *argument) //void StartDefaultTask(void *argument)
{ //{
/* USER CODE BEGIN 5 */ // /* USER CODE BEGIN 5 */
// LEDS_State state = leds_off; // LEDS_State state = leds_off;
// //
// /* Infinite loop */ // /* Infinite loop */
@ -660,8 +660,13 @@ void StartDefaultTask(void *argument)
// //
// vTaskDelay(pdMS_TO_TICKS(5000)); // vTaskDelay(pdMS_TO_TICKS(5000));
// } // }
/* USER CODE END 5 */ // /* USER CODE END 5 */
} //
// while (1)
// {
// //vTaskDelay(pdMS_TO_TICKS(50));
// }
//}
/** /**
* @brief Period elapsed callback in non blocking mode * @brief Period elapsed callback in non blocking mode