diff --git a/.cproject b/.cproject
index 3bf5458..97a996a 100644
--- a/.cproject
+++ b/.cproject
@@ -52,6 +52,8 @@
+
+
@@ -98,10 +100,10 @@
-
-
+
+
@@ -195,10 +197,10 @@
-
-
+
+
diff --git a/.settings/stm32cubeide.project.prefs b/.settings/stm32cubeide.project.prefs
index 5d2dbc6..80ac6f9 100644
--- a/.settings/stm32cubeide.project.prefs
+++ b/.settings/stm32cubeide.project.prefs
@@ -1,4 +1,5 @@
635E684B79701B039C64EA45C3F84D30=C96BA6CC9F20E1205A6EBDFF40205165
66BE74F758C12D739921AEA421D593D3=4
+8DF89ED150041C4CBC7CB9A9CAA90856=C37D8D153607683CBCB65A289104E87E
DC22A860405A8BF2F2C095E5B6529F12=C37D8D153607683CBCB65A289104E87E
eclipse.preferences.version=1
diff --git a/App/Inc/sta/config.hpp b/App/Inc/sta/config.hpp
index 666a8fd..7bc5507 100644
--- a/App/Inc/sta/config.hpp
+++ b/App/Inc/sta/config.hpp
@@ -11,6 +11,19 @@
// Use the STM32F411 microprocessor.
#include
+// 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_ */
diff --git a/App/Src/startup.cpp b/App/Src/startup.cpp
new file mode 100644
index 0000000..cbe8a74
--- /dev/null
+++ b/App/Src/startup.cpp
@@ -0,0 +1,40 @@
+/*
+ * printable.cpp
+ *
+ * Created on: Aug 30, 2023
+ * Author: Dario
+ */
+
+#include
+
+#include
+#include
+#include
+#include
+#include
+
+// 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
+
diff --git a/Core/Src/freertos.c b/Core/Src/freertos.c
index 5a1ff45..2cc7d3e 100644
--- a/Core/Src/freertos.c
+++ b/Core/Src/freertos.c
@@ -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);
diff --git a/Libs/rtos2-utils b/Libs/rtos2-utils
index 652aea8..ad6c4fd 160000
--- a/Libs/rtos2-utils
+++ b/Libs/rtos2-utils
@@ -1 +1 @@
-Subproject commit 652aea896f0372a4831788f6cd152c1459e3a15f
+Subproject commit ad6c4fd297865cb697037052d3b354b6d2405fe1
diff --git a/TACOS-Demo.ioc b/TACOS-Demo.ioc
index 2991cdc..c6618d4 100644
--- a/TACOS-Demo.ioc
+++ b/TACOS-Demo.ioc
@@ -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