Modified config.hpp + enabled UART + added startUpExtras

This commit is contained in:
dario 2023-08-30 22:14:39 +02:00
parent 7c46e30161
commit d7d80c2288
7 changed files with 77 additions and 11 deletions

View File

@ -52,6 +52,8 @@
<listOptionValue builtIn="false" value="../Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2"/>
<listOptionValue builtIn="false" value="../Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/TACOS-Demo/App/Inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/TACOS-Demo/Libs/sta-core/include}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/TACOS-Demo/Libs/rtos2-utils/include}&quot;"/>
</option>
<inputType id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.input.c.929924471" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.input.c"/>
</tool>
@ -98,10 +100,10 @@
</folderInfo>
<sourceEntries>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="App"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Core"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Drivers"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Libs"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Core"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Middlewares"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Drivers"/>
</sourceEntries>
</configuration>
</storageModule>
@ -195,10 +197,10 @@
</folderInfo>
<sourceEntries>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="App"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Core"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Drivers"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Libs"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Core"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Middlewares"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Drivers"/>
</sourceEntries>
</configuration>
</storageModule>

View File

@ -1,4 +1,5 @@
635E684B79701B039C64EA45C3F84D30=C96BA6CC9F20E1205A6EBDFF40205165
66BE74F758C12D739921AEA421D593D3=4
8DF89ED150041C4CBC7CB9A9CAA90856=C37D8D153607683CBCB65A289104E87E
DC22A860405A8BF2F2C095E5B6529F12=C37D8D153607683CBCB65A289104E87E
eclipse.preferences.version=1

View File

@ -11,6 +11,19 @@
// Use the STM32F411 microprocessor.
#include <sta/devices/stm32/mcu/STM32F411xE.hpp>
// Doesn't really do too much right now. Has to be added for successful compilation.
#define STA_PRINTF_USE_STDLIB
// 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
#endif /* INC_STA_CONFIG_HPP_ */

40
App/Src/startup.cpp Normal file
View File

@ -0,0 +1,40 @@
/*
* printable.cpp
*
* Created on: Aug 30, 2023
* Author: Dario
*/
#include <cmsis_os2.h>
#include <usart.h>
#include <sta/rtos/mutex.hpp>
#include <sta/devices/stm32/bus/uart.hpp>
#include <sta/debug/printing/printable_uart.hpp>
#include <sta/debug/debug.hpp>
// The UART mutex defined in freertos.c
extern osMutexId_t uartMutexHandle;
namespace sta
{
// Here the printable used for debugging is defined.
Printable * Debug;
namespace rtos
{
// Override the weak implementation of startupExtras provided in rtos2-utils.
void startupExtras(void * argument)
{
// Initialize the mutex for UART communication.
RtosMutex * mutex = new RtosMutex(&uartMutexHandle);
// Initialize the UART interface and printable object.
UARTSettings settings = { .mode = UARTMode::RX_TX };
STM32UART * intf_ptr = new STM32UART(&huart2, settings, mutex);
Debug = new PrintableUART(intf_ptr);
}
} // namespace rtos
} // namespace sta

View File

@ -29,6 +29,7 @@
/* USER CODE END Includes */
/* Private typedef -----------------------------------------------------------*/
typedef StaticSemaphore_t osStaticMutexDef_t;
/* USER CODE BEGIN PTD */
/* USER CODE END PTD */
@ -54,6 +55,14 @@ const osThreadAttr_t defaultTask_attributes = {
.stack_size = 128 * 4,
.priority = (osPriority_t) osPriorityNormal,
};
/* Definitions for uartMutex */
osMutexId_t uartMutexHandle;
osStaticMutexDef_t uartMutex_cb;
const osMutexAttr_t uartMutex_attributes = {
.name = "uartMutex",
.cb_mem = &uartMutex_cb,
.cb_size = sizeof(uartMutex_cb),
};
/* Private function prototypes -----------------------------------------------*/
/* USER CODE BEGIN FunctionPrototypes */
@ -85,6 +94,9 @@ void MX_FREERTOS_Init(void) {
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* Create the mutex(es) */
/* creation of uartMutex */
uartMutexHandle = osMutexNew(&uartMutex_attributes);
/* USER CODE BEGIN RTOS_MUTEX */
/* add mutexes, ... */
@ -126,10 +138,6 @@ void MX_FREERTOS_Init(void) {
void StartDefaultTask(void *argument)
{
/* USER CODE BEGIN StartDefaultTask */
#define STA_RTOS_SYSTEM_EVENTS_ENABLE
#define STA_RTOS_WATCHDOG_ENABLE
extern void startALPAKA(void *);
startALPAKA(argument);

@ -1 +1 @@
Subproject commit 652aea896f0372a4831788f6cd152c1459e3a15f
Subproject commit ad6c4fd297865cb697037052d3b354b6d2405fe1

View File

@ -2,7 +2,8 @@
CAD.formats=
CAD.pinconfig=
CAD.provider=
FREERTOS.IPParameters=Tasks01,configUSE_NEWLIB_REENTRANT,configRECORD_STACK_HIGH_ADDRESS,configCHECK_FOR_STACK_OVERFLOW
FREERTOS.IPParameters=Tasks01,configUSE_NEWLIB_REENTRANT,configRECORD_STACK_HIGH_ADDRESS,configCHECK_FOR_STACK_OVERFLOW,Mutexes01
FREERTOS.Mutexes01=uartMutex,Static,uartMutex_cb
FREERTOS.Tasks01=defaultTask,24,128,StartDefaultTask,Default,NULL,Dynamic,NULL,NULL
FREERTOS.configCHECK_FOR_STACK_OVERFLOW=1
FREERTOS.configRECORD_STACK_HIGH_ADDRESS=1
@ -74,7 +75,7 @@ ProjectManager.StackSize=0x400
ProjectManager.TargetToolchain=STM32CubeIDE
ProjectManager.ToolChainLocation=
ProjectManager.UnderRoot=true
ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false
ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_USART2_UART_Init-USART2-false-HAL-true
RCC.AHBFreq_Value=16000000
RCC.APB1Freq_Value=16000000
RCC.APB2Freq_Value=16000000
@ -101,4 +102,5 @@ USART2.VirtualMode=VM_ASYNC
VP_FREERTOS_VS_CMSIS_V2.Mode=CMSIS_V2
VP_FREERTOS_VS_CMSIS_V2.Signal=FREERTOS_VS_CMSIS_V2
board=custom
rtos.0.ip=FREERTOS
isbadioc=false