tdse-tp2_01-model_integration

Index Commits Files Refs README
commit 26374b3b721e00b146eaabb705ef98fe0f311a03
parent dba0b2b6c6af99451986c8703fd6a0b3931cba5a
Author: Martin Kloeckner <mjkloeckner@gmail.com>
Date:   Mon, 29 Sep 2025 12:42:47 -0300

Change tabs for spaces, set unix ff (instead of dos)

Diffstat:
Mapp/inc/board.h | 250++++++++++++++++++++++++++++++++++++++++----------------------------------------
Mapp/inc/dwt.h | 280++++++++++++++++++++++++++++++++++++++++----------------------------------------
Mapp/inc/task_sensor_attribute.h | 267+++++++++++++++++++++++++++++++++++++++++--------------------------------------
Mapp/src/app.c | 402+++++++++++++++++++++++++++++++++++++++----------------------------------------
Mapp/src/logger.c | 4++--
Mapp/src/systick.c | 188++++++++++++++++++++++++++++++++++++++++----------------------------------------
Mapp/src/task_sensor.c | 1-
7 files changed, 699 insertions(+), 693 deletions(-)
diff --git a/app/inc/board.h b/app/inc/board.h
@@ -1,125 +1,125 @@
-/*
- * Copyright (c) 2023 Juan Manuel Cruz <jcruz@fi.uba.ar>.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the copyright holder nor the names of its
- *    contributors may be used to endorse or promote products derived from
- *    this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * @file   : board.h
- * @date   : Set 26, 2023
- * @author : Juan Manuel Cruz <jcruz@fi.uba.ar> <jcruz@frba.utn.edu.ar>
- * @version    v1.0.0
- */
-
-#ifndef BOARD_INC_BOARD_H_
-#define BOARD_INC_BOARD_H_
-
-/********************** CPP guard ********************************************/
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/********************** inclusions *******************************************/
-
-/********************** macros ***********************************************/
-#define NUCLEO_F103RC        (0)
-#define NUCLEO_F303R8        (1)
-#define NUCLEO_F401RE        (2)
-#define NUCLEO_F446RE        (3)
-#define NUCLEO_F413ZH        (4)
-#define NUCLEO_F429ZI        (5)
-#define NUCLEO_F439ZI        (6)
-#define NUCLEO_F767ZI        (7)
-#define STM32F407G_DISC1    (8)
-#define STM32F429I_DISC1    (9)
-
-#define BOARD (NUCLEO_F103RC)
-
-/* STM32 Nucleo Boards - 32 Pins */
-#if (BOARD == NUCLEO_F303R8)
-
-#endif
-
-/* STM32 Nucleo Boards - 64 Pins */
-#if ((BOARD == NUCLEO_F103RC) || (BOARD == NUCLEO_F401RE) || (BOARD == NUCLEO_F446RE))
-
-#define BTN_A_PIN        B1_Pin
-#define BTN_A_PORT        B1_GPIO_Port
-#define BTN_A_PRESSED    GPIO_PIN_RESET
-#define BTN_A_HOVER        GPIO_PIN_SET
-
-#define LED_A_PIN        LD2_Pin
-#define LED_A_PORT        LD2_GPIO_Port
-#define LED_A_ON        GPIO_PIN_SET
-#define LED_A_OFF        GPIO_PIN_RESET
-
-#endif
-
-/* STM32 Nucleo Boards - 144 Pins */
-#if ((BOARD == NUCLEO_F413ZH) || (BOARD == NUCLEO_F429ZI) || (BOARD == NUCLEO_F439ZI) || (BOARD == NUCLEO_F767ZI))
-
-#define BTN_A_PIN        USER_Btn_Pin
-#define BTN_A_PORT        USER_Btn_GPIO_Port
-#define BTN_A_PRESSED    GPIO_PIN_SET
-#define BTN_A_HOVER        GPIO_PIN_RESET
-
-#define LED_A_PIN        LD1_Pin
-#define LED_A_PORT        LD1_GPIO_Port
-#define LED_A_ON        GPIO_PIN_SET
-#define LED_A_OFF        GPIO_PIN_RESET
-
-#endif
-
-/* STM32 Discovery Kits */
-#if ((BOARD == STM32F407G_DISC1) || (BOARD == STM32F429I_DISC1))
-
-#define BTN_A_PIN        B1_Pin
-#define BTN_A_PORT        B1_GPIO_Port
-#define BTN_A_PRESSED    GPIO_PIN_SET
-#define BTN_A_HOVER        GPIO_PIN_RESET
-
-#define LED_A_PIN        LD3_Pin
-#define LED_A_PORT        LD3_GPIO_Port
-#define LED_A_ON        GPIO_PIN_SET
-#define LED_A_OFF        GPIO_PIN_RESET
-
-#endif
-
-/********************** typedef **********************************************/
-
-/********************** external data declaration ****************************/
-
-/********************** external functions declaration ***********************/
-
-/********************** End of CPP guard *************************************/
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BOARD_INC_BOARD_H_ */
-
-/********************** end of file ******************************************/
+/*
+ * Copyright (c) 2023 Juan Manuel Cruz <jcruz@fi.uba.ar>.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its
+ *    contributors may be used to endorse or promote products derived from
+ *    this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * @file   : board.h
+ * @date   : Set 26, 2023
+ * @author : Juan Manuel Cruz <jcruz@fi.uba.ar> <jcruz@frba.utn.edu.ar>
+ * @version v1.0.0
+ */
+
+#ifndef BOARD_INC_BOARD_H_
+#define BOARD_INC_BOARD_H_
+
+/********************** CPP guard ********************************************/
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/********************** inclusions *******************************************/
+
+/********************** macros ***********************************************/
+#define NUCLEO_F103RC    (0)
+#define NUCLEO_F303R8    (1)
+#define NUCLEO_F401RE    (2)
+#define NUCLEO_F446RE    (3)
+#define NUCLEO_F413ZH    (4)
+#define NUCLEO_F429ZI    (5)
+#define NUCLEO_F439ZI    (6)
+#define NUCLEO_F767ZI    (7)
+#define STM32F407G_DISC1 (8)
+#define STM32F429I_DISC1 (9)
+
+#define BOARD (NUCLEO_F103RC)
+
+/* STM32 Nucleo Boards - 32 Pins */
+#if (BOARD == NUCLEO_F303R8)
+
+#endif
+
+/* STM32 Nucleo Boards - 64 Pins */
+#if ((BOARD == NUCLEO_F103RC) || (BOARD == NUCLEO_F401RE) || (BOARD == NUCLEO_F446RE))
+
+#define BTN_A_PIN     B1_Pin
+#define BTN_A_PORT    B1_GPIO_Port
+#define BTN_A_PRESSED GPIO_PIN_RESET
+#define BTN_A_HOVER   GPIO_PIN_SET
+
+#define LED_A_PIN     LD2_Pin
+#define LED_A_PORT    LD2_GPIO_Port
+#define LED_A_ON      GPIO_PIN_SET
+#define LED_A_OFF     GPIO_PIN_RESET
+
+#endif
+
+/* STM32 Nucleo Boards - 144 Pins */
+#if ((BOARD == NUCLEO_F413ZH) || (BOARD == NUCLEO_F429ZI) || (BOARD == NUCLEO_F439ZI) || (BOARD == NUCLEO_F767ZI))
+
+#define BTN_A_PIN     USER_Btn_Pin
+#define BTN_A_PORT    USER_Btn_GPIO_Port
+#define BTN_A_PRESSED GPIO_PIN_SET
+#define BTN_A_HOVER   GPIO_PIN_RESET
+
+#define LED_A_PIN     LD1_Pin
+#define LED_A_PORT    LD1_GPIO_Port
+#define LED_A_ON      GPIO_PIN_SET
+#define LED_A_OFF     GPIO_PIN_RESET
+
+#endif
+
+/* STM32 Discovery Kits */
+#if ((BOARD == STM32F407G_DISC1) || (BOARD == STM32F429I_DISC1))
+
+#define BTN_A_PIN     B1_Pin
+#define BTN_A_PORT    B1_GPIO_Port
+#define BTN_A_PRESSED GPIO_PIN_SET
+#define BTN_A_HOVER   GPIO_PIN_RESET
+
+#define LED_A_PIN     LD3_Pin
+#define LED_A_PORT    LD3_GPIO_Port
+#define LED_A_ON      GPIO_PIN_SET
+#define LED_A_OFF     GPIO_PIN_RESET
+
+#endif
+
+/********************** typedef **********************************************/
+
+/********************** external data declaration ****************************/
+
+/********************** external functions declaration ***********************/
+
+/********************** End of CPP guard *************************************/
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BOARD_INC_BOARD_H_ */
+
+/********************** end of file ******************************************/
diff --git a/app/inc/dwt.h b/app/inc/dwt.h
@@ -1,140 +1,140 @@
-/*
- * Copyright (c) 2023 Juan Manuel Cruz <jcruz@fi.uba.ar> <jcruz@frba.utn.edu.ar>.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the copyright holder nor the names of its
- *    contributors may be used to endorse or promote products derived from
- *    this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * @file   : dwt.h
- * @date   : Set 26, 2023
- * @author : Juan Manuel Cruz <jcruz@fi.uba.ar> <jcruz@frba.utn.edu.ar>
- * @version v1.0.0
- */
-
-#ifndef DWT_INC_DWT_H_
-#define DWT_INC_DWT_H_
-
-/********************** CPP guard ********************************************/
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/********************** inclusions *******************************************/
-
-/********************** macros ***********************************************/
-
-/* init cycle counter */
-/* DWT (Data Watchpoint and Trace) registers, only exists on ARM Cortex with a DWT unit */
-/*!< DEMCR: Debug Exception and Monitor Control Register */
-/*!< TRCENA: Enable trace and debug block DEMCR (Debug Exception and Monitor Control Register) */
-/*!< DWT Cycle Counter register */
-/*!< CYCCNTENA bit in DWT_CONTROL register */
-static inline void cycle_counter_init(void) __attribute__((always_inline));
-static inline void cycle_counter_init(void)
-{
-    CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk; /* enable DWT hardware */
-    DWT->CYCCNT = 0;                                /* reset cycle counter */
-    DWT->CTRL |= DWT_CTRL_CYCCNTENA_Msk;            /* start counting */
-}
-
-/* reset cycle counter */
-/*!< DWT Cycle Counter register */
-static inline void cycle_counter_reset(void) __attribute__((always_inline));
-static inline void cycle_counter_reset(void)
-{
-    DWT->CYCCNT = 0;
-}
-
-/* enable counting */
-/*!< CYCCNTENA bit in DWT_CONTROL register */
-static inline void cycle_counter_enable(void) __attribute__((always_inline));
-static inline void cycle_counter_enable(void)
-{
-    DWT->CTRL |= DWT_CTRL_CYCCNTENA_Msk;
-}
-
-/* disable counting */
-/*!< CYCCNTENA bit in DWT_CONTROL register */
-static inline void cycle_counter_disable(void) __attribute__((always_inline));
-static inline void cycle_counter_disable(void)
-{
-    DWT->CTRL &= ~DWT_CTRL_CYCCNTENA_Msk;
-}
-
-/* read cycle counter */
-/*!< DWT Cycle Counter register */
-static inline uint32_t cycle_counter_get(void) __attribute__((always_inline));
-static inline uint32_t cycle_counter_get(void)
-{
-    return (DWT->CYCCNT);
-}
-
-static inline uint32_t cycle_counter_get_time_us(void) __attribute__((always_inline));
-static inline uint32_t cycle_counter_get_time_us(void)
-{
-    return (DWT->CYCCNT / (SystemCoreClock / 1000000));
-}
-
-/*  uint32_t cycle_counter = 0;
- *  uint32_t cycle_counter_time_us = 0;
- *                                                            // PC8 (GPIO)
- *  HAL_GPIO_WritePin(GPIOC, GPIO_PIN_8, GPIO_PIN_RESET);    // => ______
- *  cycle_counter_init();
- *
- *  ...
- *  ...                                                        // => ______
- *                                                            //         ___
- *  HAL_GPIO_WritePin(GPIOC, GPIO_PIN_8, GPIO_PIN_SET);     // => __/
- *  // or => HAL_GPIO_TogglePin(GPIOC, GPIO_PIN_8);
- *  cycle_counter_reset();
- *                                                            //      ______
- *  ...                                                        // =>
- *
- *  cycle_counter = cycle_counter_get();
- *  cycle_counter_time_us = cycle_counter_get_time_us();    //      __
- *  HAL_GPIO_WritePin(GPIOC, GPIO_PIN_8, GPIO_PIN_RESET);    // =>   \___
- *  // or => HAL_GPIO_TogglePin(GPIOC, GPIO_PIN_8);
- *
- *                                                          // => ______
- *
- *  LOGGER_LOG("Cycles: %lu - Time %lu uS\r\n", cycle_counter, cycle_counter_time_us);
- */
-
-/********************** typedef **********************************************/
-
-/********************** external data declaration ****************************/
-
-/********************** external functions declaration ***********************/
-
-/********************** End of CPP guard *************************************/
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* DWT_INC_DWT_H_ */
-
-/********************** end of file ******************************************/
+/*
+ * Copyright (c) 2023 Juan Manuel Cruz <jcruz@fi.uba.ar> <jcruz@frba.utn.edu.ar>.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its
+ *    contributors may be used to endorse or promote products derived from
+ *    this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * @file   : dwt.h
+ * @date   : Set 26, 2023
+ * @author : Juan Manuel Cruz <jcruz@fi.uba.ar> <jcruz@frba.utn.edu.ar>
+ * @version v1.0.0
+ */
+
+#ifndef DWT_INC_DWT_H_
+#define DWT_INC_DWT_H_
+
+/********************** CPP guard ********************************************/
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/********************** inclusions *******************************************/
+
+/********************** macros ***********************************************/
+
+/* init cycle counter */
+/* DWT (Data Watchpoint and Trace) registers, only exists on ARM Cortex with a DWT unit */
+/*!< DEMCR: Debug Exception and Monitor Control Register */
+/*!< TRCENA: Enable trace and debug block DEMCR (Debug Exception and Monitor Control Register) */
+/*!< DWT Cycle Counter register */
+/*!< CYCCNTENA bit in DWT_CONTROL register */
+static inline void cycle_counter_init(void) __attribute__((always_inline));
+static inline void cycle_counter_init(void)
+{
+    CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk; /* enable DWT hardware */
+    DWT->CYCCNT = 0;                                /* reset cycle counter */
+    DWT->CTRL |= DWT_CTRL_CYCCNTENA_Msk;            /* start counting */
+}
+
+/* reset cycle counter */
+/*!< DWT Cycle Counter register */
+static inline void cycle_counter_reset(void) __attribute__((always_inline));
+static inline void cycle_counter_reset(void)
+{
+    DWT->CYCCNT = 0;
+}
+
+/* enable counting */
+/*!< CYCCNTENA bit in DWT_CONTROL register */
+static inline void cycle_counter_enable(void) __attribute__((always_inline));
+static inline void cycle_counter_enable(void)
+{
+    DWT->CTRL |= DWT_CTRL_CYCCNTENA_Msk;
+}
+
+/* disable counting */
+/*!< CYCCNTENA bit in DWT_CONTROL register */
+static inline void cycle_counter_disable(void) __attribute__((always_inline));
+static inline void cycle_counter_disable(void)
+{
+    DWT->CTRL &= ~DWT_CTRL_CYCCNTENA_Msk;
+}
+
+/* read cycle counter */
+/*!< DWT Cycle Counter register */
+static inline uint32_t cycle_counter_get(void) __attribute__((always_inline));
+static inline uint32_t cycle_counter_get(void)
+{
+    return (DWT->CYCCNT);
+}
+
+static inline uint32_t cycle_counter_get_time_us(void) __attribute__((always_inline));
+static inline uint32_t cycle_counter_get_time_us(void)
+{
+    return (DWT->CYCCNT / (SystemCoreClock / 1000000));
+}
+
+/*  uint32_t cycle_counter = 0;
+ *  uint32_t cycle_counter_time_us = 0;
+ *                                                        // PC8 (GPIO)
+ *  HAL_GPIO_WritePin(GPIOC, GPIO_PIN_8, GPIO_PIN_RESET); // => ______
+ *  cycle_counter_init();
+ *
+ *  ...
+ *  ...                                                   // => ______
+ *                                                        //    ___
+ *  HAL_GPIO_WritePin(GPIOC, GPIO_PIN_8, GPIO_PIN_SET);   // => __/
+ *  // or => HAL_GPIO_TogglePin(GPIOC, GPIO_PIN_8);
+ *  cycle_counter_reset();
+ *                                                        //      ______
+ *  ...                                                   // =>
+ *
+ *  cycle_counter = cycle_counter_get();
+ *  cycle_counter_time_us = cycle_counter_get_time_us();  //      __
+ *  HAL_GPIO_WritePin(GPIOC, GPIO_PIN_8, GPIO_PIN_RESET); // =>   \___
+ *  // or => HAL_GPIO_TogglePin(GPIOC, GPIO_PIN_8);
+ *
+ *                                                        // => ______
+ *
+ *  LOGGER_LOG("Cycles: %lu - Time %lu uS\r\n", cycle_counter, cycle_counter_time_us);
+ */
+
+/********************** typedef **********************************************/
+
+/********************** external data declaration ****************************/
+
+/********************** external functions declaration ***********************/
+
+/********************** End of CPP guard *************************************/
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* DWT_INC_DWT_H_ */
+
+/********************** end of file ******************************************/
diff --git a/app/inc/task_sensor_attribute.h b/app/inc/task_sensor_attribute.h
@@ -1,129 +1,138 @@
-/*
- * Copyright (c) 2023 Juan Manuel Cruz <jcruz@fi.uba.ar> <jcruz@frba.utn.edu.ar>.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the copyright holder nor the names of its
- *    contributors may be used to endorse or promote products derived from
- *    this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * @file   : task_sensor_attribute.h
- * @date   : Set 26, 2023
- * @author : Juan Manuel Cruz <jcruz@fi.uba.ar> <jcruz@frba.utn.edu.ar>
- * @version    v1.0.0
- */
-
-#ifndef TASK_INC_TASK_SENSOR_ATTRIBUTE_H_
-#define TASK_INC_TASK_SENSOR_ATTRIBUTE_H_
-
-/********************** CPP guard ********************************************/
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/********************** inclusions *******************************************/
-
-/********************** macros ***********************************************/
-
-/********************** typedef **********************************************/
-/* Sensor Statechart - State Transition Table */
-/*     ------------------------+-----------------------+-----------------------+-----------------------+------------------------
- *     | Current               | Event                 |                       | Next                  |                       |
- *     | State                 | (Parameters)          | [Guard]               | State                 | Actions               |
- *     |=======================+=======================+=======================+=======================+=======================|
- *     | INICIAL               |                       |                       | ST_BTN_XX_UP          |                       |
- *     |-----------------------+-----------------------+-----------------------+-----------------------+-----------------------|
- *     | ST_BTN_XX_UP          | EV_BTN_XX_UP          |                       | ST_BTN_XX_UP          |                       |
- *     |                       +-----------------------+-----------------------+-----------------------+-----------------------|
- *     |                       | EV_BTN_XX_DOWN        |                       | ST_BTN_XX_FALLING     | tick = TICK_MAX       |
- *     |-----------------------+-----------------------+-----------------------+-----------------------+-----------------------|
- *     | ST_BTN_XX_FALLING     | EV_BTN_XX_UP          | [tick == 0]           | ST_BTN_XX_UP          |                       |
- *     |                       |                       +-----------------------+-----------------------+-----------------------|
- *     |                       |                       | [tick >  0]           | ST_BTN_XX_FALLING     | tick--                |
- *     |                       +-----------------------+-----------------------+-----------------------+-----------------------|
- *     |                       | EV_BTN_XX_DOWN        | [tick == 0]           | ST_BTN_XX_DOWN        | put_event_task_system |
- *     |                       |                       |                       |                       |  (event)              |
- *     |                       |                        +-----------------------+-----------------------+-----------------------|
- *     |                       |                       | [tick >  0]           | ST_BTN_XX_FALLING     | tick--                |
- *     |-----------------------+-----------------------+-----------------------+-----------------------+-----------------------|
- *    | ST_BTN_XX_DOWN        | EV_BTN_XX_UP          |                       | ST_BTN_XX_RISING      | tick = TICK_MAX       |
- *     |                       +-----------------------+-----------------------+-----------------------+-----------------------|
- *     |                       | EV_BTN_XX_DOWN        |                       | ST_BTN_XX_DOWN        |                       |
- *     |-----------------------+-----------------------+-----------------------+-----------------------+-----------------------|
- *     | ST_BTN_XX_RISING      | EV_BTN_XX_UP          | [tick == 0]           | ST_BTN_XX_UP          | put_event_task_system |
- *     |                       |                       |                       |                       |  (event)              |
- *     |                       |                        +-----------------------+-----------------------+-----------------------|
- *     |                       |                       | [tick >  0]           | ST_BTN_XX_RISING      | tick--                |
- *     |                       +-----------------------+-----------------------+-----------------------+-----------------------|
- *     |                       | EV_BTN_XX_DOWN        | [tick == 0]           | ST_BTN_XX_DOWN        |                       |
- *     |                       |                        +-----------------------+-----------------------+-----------------------|
- *     |                       |                       | [tick >  0]           | ST_BTN_XX_RISING      | tick--                |
- *     ------------------------+-----------------------+-----------------------+-----------------------+------------------------
- */
-
-/* Events to excite Task Sensor */
-typedef enum task_sensor_ev {EV_BTN_XX_UP,
-                             EV_BTN_XX_DOWN} task_sensor_ev_t;
-
-/* States of Task Sensor */
-typedef enum task_sensor_st {ST_BTN_XX_UP,
-                             ST_BTN_XX_FALLING,
-                             ST_BTN_XX_DOWN,
-                             ST_BTN_XX_RISING} task_sensor_st_t;
-
-/* Identifier of Task Sensor */
-typedef enum task_sensor_id {ID_BTN_A} task_sensor_id_t;
-
-typedef struct
-{
-    task_sensor_id_t    identifier;
-    GPIO_TypeDef *        gpio_port;
-    uint16_t            pin;
-    GPIO_PinState        pressed;
-    uint32_t            tick_max;
-    task_sensor_ev_t    signal_up;
-    task_sensor_ev_t    signal_down;
-} task_sensor_cfg_t;
-
-typedef struct
-{
-    uint32_t            tick;
-    task_sensor_st_t    state;
-    task_sensor_ev_t    event;
-} task_sensor_dta_t;
-
-/********************** external data declaration ****************************/
-extern task_sensor_dta_t task_sensor_dta_list[];
-
-/********************** external functions declaration ***********************/
-
-/********************** End of CPP guard *************************************/
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* TASK_INC_TASK_SENSOR_ATTRIBUTE_H_ */
-
-/********************** end of file ******************************************/
+/*
+ * Copyright (c) 2023 Juan Manuel Cruz <jcruz@fi.uba.ar> <jcruz@frba.utn.edu.ar>.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its
+ *    contributors may be used to endorse or promote products derived from
+ *    this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * @file   : task_sensor_attribute.h
+ * @date   : Set 26, 2023
+ * @author : Juan Manuel Cruz <jcruz@fi.uba.ar> <jcruz@frba.utn.edu.ar>
+ * @version    v1.0.0
+ */
+
+#ifndef TASK_INC_TASK_SENSOR_ATTRIBUTE_H_
+#define TASK_INC_TASK_SENSOR_ATTRIBUTE_H_
+
+/********************** CPP guard ********************************************/
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/********************** inclusions *******************************************/
+
+/********************** macros ***********************************************/
+
+/********************** typedef **********************************************/
+/* Sensor Statechart - State Transition Table */
+/* +-------------------+----------------+-------------+-------------------+-----------------------+
+ * | Current           | Event          |             | Next              |                       |
+ * | State             | (Parameters)   | [Guard]     | State             | Actions               |
+ * |===================+================+=============+===================+=======================|
+ * | INICIAL           |                |             | ST_BTN_XX_UP      |                       |
+ * |-------------------+----------------+-------------+-------------------+-----------------------|
+ * | ST_BTN_XX_UP      | EV_BTN_XX_UP   |             | ST_BTN_XX_UP      |                       |
+ * |                   +----------------+-------------+-------------------+-----------------------|
+ * |                   | EV_BTN_XX_DOWN |             | ST_BTN_XX_FALLING | tick = TICK_MAX       |
+ * |-------------------+----------------+-------------+-------------------+-----------------------|
+ * | ST_BTN_XX_FALLING | EV_BTN_XX_UP   | [tick == 0] | ST_BTN_XX_UP      |                       |
+ * |                   |                +-------------+-------------------+-----------------------|
+ * |                   |                | [tick >  0] | ST_BTN_XX_FALLING | tick--                |
+ * |                   +----------------+-------------+-------------------+-----------------------|
+ * |                   | EV_BTN_XX_DOWN | [tick == 0] | ST_BTN_XX_DOWN    | put_event_task_system |
+ * |                   |                |             |                   |  (event)              |
+ * |                   |                +-------------+-------------------+-----------------------|
+ * |                   |                | [tick >  0] | ST_BTN_XX_FALLING | tick--                |
+ * |-------------------+----------------+-------------+-------------------+-----------------------|
+ * | ST_BTN_XX_DOWN    | EV_BTN_XX_UP   |             | ST_BTN_XX_RISING  | tick = TICK_MAX       |
+ * |                   +----------------+-------------+-------------------+-----------------------|
+ * |                   | EV_BTN_XX_DOWN |             | ST_BTN_XX_DOWN    |                       |
+ * |-------------------+----------------+-------------+-------------------+-----------------------|
+ * | ST_BTN_XX_RISING  | EV_BTN_XX_UP   | [tick == 0] | ST_BTN_XX_UP      | put_event_task_system |
+ * |                   |                |             |                   |  (event)              |
+ * |                   |                +-------------+-------------------+-----------------------|
+ * |                   |                | [tick >  0] | ST_BTN_XX_RISING  | tick--                |
+ * |                   +----------------+-------------+-------------------+-----------------------|
+ * |                   | EV_BTN_XX_DOWN | [tick == 0] | ST_BTN_XX_DOWN    |                       |
+ * |                   |                +-------------+-------------------+-----------------------|
+ * |                   |                | [tick >  0] | ST_BTN_XX_RISING  | tick--                |
+ * +-------------------+----------------+-------------+-------------------+-----------------------+
+ */
+
+/* Events to excite Task Sensor */
+typedef enum
+{
+    EV_BTN_XX_UP,
+    EV_BTN_XX_DOWN
+} task_sensor_ev_t;
+
+/* States of Task Sensor */
+typedef enum
+{
+    ST_BTN_XX_UP,
+    ST_BTN_XX_FALLING,
+    ST_BTN_XX_DOWN,
+    ST_BTN_XX_RISINr
+} task_sensor_st_t;
+
+/* Identifier of Task Sensor */
+typedef enum
+{
+    ID_BTN_A
+} task_sensor_id_t;
+
+typedef struct
+{
+    task_sensor_id_t identifier;
+    GPIO_TypeDef *   gpio_port;
+    uint16_t         pin;
+    GPIO_PinState    pressed;
+    uint32_t         tick_max;
+    task_sensor_ev_t signal_up;
+    task_sensor_ev_t signal_down;
+} task_sensor_cfg_t;
+
+typedef struct
+{
+    uint32_t         tick;
+    task_sensor_st_t state;
+    task_sensor_ev_t event;
+} task_sensor_dta_t;
+
+/********************** external data declaration ****************************/
+extern task_sensor_dta_t task_sensor_dta_list[];
+
+/********************** external functions declaration ***********************/
+
+/********************** End of CPP guard *************************************/
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* TASK_INC_TASK_SENSOR_ATTRIBUTE_H_ */
+
+/********************** end of file ******************************************/
diff --git a/app/src/app.c b/app/src/app.c
@@ -1,202 +1,200 @@
-/*
- * Copyright (c) 2023 Juan Manuel Cruz <jcruz@fi.uba.ar> <jcruz@frba.utn.edu.ar>.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the copyright holder nor the names of its
- *    contributors may be used to endorse or promote products derived from
- *    this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * @file   : app.c
- * @date   : Set 26, 2023
- * @author : Juan Manuel Cruz <jcruz@fi.uba.ar> <jcruz@frba.utn.edu.ar>
- * @version    v1.0.0
- */
-
-/********************** inclusions *******************************************/
-/* Project includes */
-#include "main.h"
-
-/* Demo includes */
-#include "logger.h"
-#include "dwt.h"
-
-/* Application & Tasks includes */
-#include "board.h"
-#include "task_system.h"
-#include "task_actuator.h"
-#include "task_sensor.h"
-
-/********************** macros and definitions *******************************/
-#define G_APP_CNT_INI        0ul
-#define G_APP_TICK_CNT_INI    0ul
-
-#define TASK_X_WCET_INI        0ul
-#define TASK_X_DELAY_MIN    0ul
-
-typedef struct {
-    void (*task_init)(void *);        // Pointer to task (must be a
-                                    // 'void (void *)' function)
-    void (*task_update)(void *);    // Pointer to task (must be a
-                                    // 'void (void *)' function)
-    void *parameters;                // Pointer to parameters
-} task_cfg_t;
-
-typedef struct {
-    uint32_t WCET;            // Worst-case execution time (microseconds)
-} task_dta_t;
-
-/********************** internal data declaration ****************************/
-const task_cfg_t task_cfg_list[]    = {
-        {task_sensor_init,         task_sensor_update,     NULL},
-        {task_system_init,         task_system_update,     NULL},
-        {task_actuator_init,    task_actuator_update,     NULL}
-};
-
-#define TASK_QTY    (sizeof(task_cfg_list)/sizeof(task_cfg_t))
-
-/********************** internal functions declaration ***********************/
-
-/********************** internal data definition *****************************/
-const char *p_sys    = " Bare Metal - Event-Triggered Systems (ETS)";
-const char *p_app    = " App - Model Integration - C codig";
-
-/********************** external data declaration ****************************/
-uint32_t g_app_cnt;
-uint32_t g_app_runtime_us;
-
-volatile uint32_t g_app_tick_cnt;
-
-task_dta_t task_dta_list[TASK_QTY];
-
-/********************** external functions definition ************************/
-void app_init(void)
-{
-    uint32_t index;
-
-    /* Print out: Application Initialized */
-    LOGGER_INFO(" ");
-    LOGGER_INFO("%s is running - Tick [mS] = %lu", GET_NAME(app_init), HAL_GetTick());
-
-    LOGGER_INFO(p_sys);
-    LOGGER_INFO(p_app);
-
-    /* Init & Print out: Application execution counter */
-    g_app_cnt = G_APP_CNT_INI;
-    LOGGER_INFO(" %s = %lu", GET_NAME(g_app_cnt), g_app_cnt);
-
-    /* Init Cycle Counter */
-    cycle_counter_init();
-
-    /* Go through the task arrays */
-    for (index = 0; TASK_QTY > index; index++)
-    {
-        /* Run task_x_init */
-        (*task_cfg_list[index].task_init)(task_cfg_list[index].parameters);
-
-        /* Init variables */
-        task_dta_list[index].WCET = TASK_X_WCET_INI;
-    }
-
-    /* Protect shared resource */
-    __asm("CPSID i");    /* disable interrupts */
-    /* Init Tick Counter */
-    g_app_tick_cnt = G_APP_TICK_CNT_INI;
-
-    g_task_sensor_tick_cnt = G_APP_TICK_CNT_INI;
-    g_task_system_tick_cnt = G_APP_TICK_CNT_INI;
-    g_task_actuator_tick_cnt = G_APP_TICK_CNT_INI;
-    __asm("CPSIE i");    /* enable interrupts */
-}
-
-void app_update(void)
-{
-    uint32_t index;
-    bool b_time_update_required = false;
-    uint32_t cycle_counter_time_us;
-
-    /* Protect shared resource */
-    __asm("CPSID i");    /* disable interrupts */
-    if (G_APP_TICK_CNT_INI < g_app_tick_cnt)
-    {
-        /* Update Tick Counter */
-        g_app_tick_cnt--;
-        b_time_update_required = true;
-    }
-    __asm("CPSIE i");    /* enable interrupts */
-
-    /* Check if it's time to run tasks */
-    while (b_time_update_required)
-    {
-        /* Update App Counter */
-        g_app_cnt++;
-        g_app_runtime_us = 0;
-
-        /* Go through the task arrays */
-        for (index = 0; TASK_QTY > index; index++)
-        {
-            cycle_counter_reset();
-
-            /* Run task_x_update */
-            (*task_cfg_list[index].task_update)(task_cfg_list[index].parameters);
-
-            cycle_counter_time_us = cycle_counter_get_time_us();
-
-            /* Update variables */
-            g_app_runtime_us += cycle_counter_time_us;
-
-            if (task_dta_list[index].WCET < cycle_counter_time_us)
-            {
-                task_dta_list[index].WCET = cycle_counter_time_us;
-            }
-        }
-
-        /* Protect shared resource */
-        __asm("CPSID i");    /* disable interrupts */
-        if (G_APP_TICK_CNT_INI < g_app_tick_cnt)
-        {
-            /* Update Tick Counter */
-            g_app_tick_cnt--;
-            b_time_update_required = true;
-        }
-        else
-        {
-            b_time_update_required = false;
-        }
-        __asm("CPSIE i");    /* enable interrupts */
-    }
-}
-
-void HAL_SYSTICK_Callback(void)
-{
-    /* Update Tick Counter */
-    g_app_tick_cnt++;
-
-    g_task_sensor_tick_cnt++;
-    g_task_system_tick_cnt++;
-    g_task_actuator_tick_cnt++;
-}
-
-/********************** end of file ******************************************/
+/*
+ * Copyright (c) 2023 Juan Manuel Cruz <jcruz@fi.uba.ar> <jcruz@frba.utn.edu.ar>.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its
+ *    contributors may be used to endorse or promote products derived from
+ *    this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * @file   : app.c
+ * @date   : Set 26, 2023
+ * @author : Juan Manuel Cruz <jcruz@fi.uba.ar> <jcruz@frba.utn.edu.ar>
+ * @version    v1.0.0
+ */
+
+/********************** inclusions *******************************************/
+/* Project includes */
+#include "main.h"
+
+/* Demo includes */
+#include "logger.h"
+#include "dwt.h"
+
+/* Application & Tasks includes */
+#include "board.h"
+#include "task_system.h"
+#include "task_actuator.h"
+#include "task_sensor.h"
+
+/********************** macros and definitions *******************************/
+#define G_APP_CNT_INI        0ul
+#define G_APP_TICK_CNT_INI    0ul
+
+#define TASK_X_WCET_INI        0ul
+#define TASK_X_DELAY_MIN    0ul
+
+typedef struct {
+    void (*task_init)(void *);   // Pointer to task (must be a
+    void (*task_update)(void *); // Pointer to task (must be a
+    void *parameters;            // Pointer to parameters
+} task_cfg_t;
+
+typedef struct {
+    uint32_t WCET; // Worst-case execution time (microseconds)
+} task_dta_t;
+
+/********************** internal data declaration ****************************/
+const task_cfg_t task_cfg_list[] = {
+    {task_sensor_init,   task_sensor_update,   NULL},
+    {task_system_init,   task_system_update,   NULL},
+    {task_actuator_init, task_actuator_update, NULL}
+};
+
+#define TASK_QTY (sizeof(task_cfg_list)/sizeof(task_cfg_t))
+
+/********************** internal functions declaration ***********************/
+
+/********************** internal data definition *****************************/
+const char *p_sys = " Bare Metal - Event-Triggered Systems (ETS)";
+const char *p_app = " App - Model Integration - C codig";
+
+/********************** external data declaration ****************************/
+uint32_t g_app_cnt;
+uint32_t g_app_runtime_us;
+
+volatile uint32_t g_app_tick_cnt;
+
+task_dta_t task_dta_list[TASK_QTY];
+
+/********************** external functions definition ************************/
+void app_init(void)
+{
+    uint32_t index;
+
+    /* Print out: Application Initialized */
+    LOGGER_INFO(" ");
+    LOGGER_INFO("%s is running - Tick [mS] = %lu", GET_NAME(app_init), HAL_GetTick());
+
+    LOGGER_INFO(p_sys);
+    LOGGER_INFO(p_app);
+
+    /* Init & Print out: Application execution counter */
+    g_app_cnt = G_APP_CNT_INI;
+    LOGGER_INFO(" %s = %lu", GET_NAME(g_app_cnt), g_app_cnt);
+
+    /* Init Cycle Counter */
+    cycle_counter_init();
+
+    /* Go through the task arrays */
+    for (index = 0; TASK_QTY > index; index++)
+    {
+        /* Run task_x_init */
+        (*task_cfg_list[index].task_init)(task_cfg_list[index].parameters);
+
+        /* Init variables */
+        task_dta_list[index].WCET = TASK_X_WCET_INI;
+    }
+
+    /* Protect shared resource */
+    __asm("CPSID i");    /* disable interrupts */
+    /* Init Tick Counter */
+    g_app_tick_cnt = G_APP_TICK_CNT_INI;
+
+    g_task_sensor_tick_cnt = G_APP_TICK_CNT_INI;
+    g_task_system_tick_cnt = G_APP_TICK_CNT_INI;
+    g_task_actuator_tick_cnt = G_APP_TICK_CNT_INI;
+    __asm("CPSIE i");    /* enable interrupts */
+}
+
+void app_update(void)
+{
+    uint32_t index;
+    bool b_time_update_required = false;
+    uint32_t cycle_counter_time_us;
+
+    /* Protect shared resource */
+    __asm("CPSID i");    /* disable interrupts */
+    if (G_APP_TICK_CNT_INI < g_app_tick_cnt)
+    {
+        /* Update Tick Counter */
+        g_app_tick_cnt--;
+        b_time_update_required = true;
+    }
+    __asm("CPSIE i");    /* enable interrupts */
+
+    /* Check if it's time to run tasks */
+    while (b_time_update_required)
+    {
+        /* Update App Counter */
+        g_app_cnt++;
+        g_app_runtime_us = 0;
+
+        /* Go through the task arrays */
+        for (index = 0; TASK_QTY > index; index++)
+        {
+            cycle_counter_reset();
+
+            /* Run task_x_update */
+            (*task_cfg_list[index].task_update)(task_cfg_list[index].parameters);
+
+            cycle_counter_time_us = cycle_counter_get_time_us();
+
+            /* Update variables */
+            g_app_runtime_us += cycle_counter_time_us;
+
+            if (task_dta_list[index].WCET < cycle_counter_time_us)
+            {
+                task_dta_list[index].WCET = cycle_counter_time_us;
+            }
+        }
+
+        /* Protect shared resource */
+        __asm("CPSID i");    /* disable interrupts */
+        if (G_APP_TICK_CNT_INI < g_app_tick_cnt)
+        {
+            /* Update Tick Counter */
+            g_app_tick_cnt--;
+            b_time_update_required = true;
+        }
+        else
+        {
+            b_time_update_required = false;
+        }
+        __asm("CPSIE i");    /* enable interrupts */
+    }
+}
+
+void HAL_SYSTICK_Callback(void)
+{
+    /* Update Tick Counter */
+    g_app_tick_cnt++;
+
+    g_task_sensor_tick_cnt++;
+    g_task_system_tick_cnt++;
+    g_task_actuator_tick_cnt++;
+}
+
+/********************** end of file ******************************************/
diff --git a/app/src/logger.c b/app/src/logger.c
@@ -69,8 +69,8 @@ int logger_msg_len;
 #if 1 == LOGGER_CONFIG_USE_SEMIHOSTING
 void logger_log_print_(char* const msg)
 {
-    printf(msg);
-    fflush(stdout);
+    printf(msg);
+    fflush(stdout);
 }
 #else
 void logger_log_print_(char* const msg)
diff --git a/app/src/systick.c b/app/src/systick.c
@@ -1,94 +1,94 @@
-/*
- * Copyright (c) 2023 Juan Manuel Cruz <jcruz@fi.uba.ar> <jcruz@frba.utn.edu.ar>.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the copyright holder nor the names of its
- *    contributors may be used to endorse or promote products derived from
- *    this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * @file   : systick.c
- * @date   : Set 26, 2023
- * @author : Juan Manuel Cruz <jcruz@fi.uba.ar> <jcruz@frba.utn.edu.ar>
- * @version    v1.0.0
- */
-
-/********************** inclusions *******************************************/
-/* Project includes */
-#include "main.h"
-
-/********************** macros and definitions *******************************/
-
-/********************** internal data declaration ****************************/
-
-/********************** internal functions declaration ***********************/
-
-/********************** internal data definition *****************************/
-
-/********************** external data declaration ****************************/
-
-/********************** external functions definition ************************/
-/* Provides a blocking delay in microseconds using the SysTick timer */
-void systick_delay_us(uint32_t delay_us)
-{
-    uint32_t start, current, target, elapsed;
-
-    if (0 == delay_us)
-        return;
-
-    /* Get the start value of the SysTick counter */
-    start = SysTick->VAL;
-
-    /* Calculate the total number of SysTick counts required for the delay */
-    target = delay_us * (SystemCoreClock / 1000000UL);
-
-    /* Loop until the required counts have elapsed */
-    while (1)
-    {
-        /* Get the current value of the SysTick counter */
-        current = SysTick->VAL;
-
-        /* Handle the case where the SysTick counter wraps around, */
-        /* counts down to 0 and reloads */
-        if (current <= start)
-        {
-            elapsed = start - current;
-        }
-        else
-        {
-            /* Counter wrapped around, */
-            /* add the reload value to account for the wrap */
-            elapsed = SysTick->LOAD + start - current;
-        }
-
-        /* Exit the loop when the desired delay is reached */
-        if (elapsed >= target)
-        {
-            break;
-        }
-    }
-}
-
-/********************** end of file ******************************************/
+/*
+ * Copyright (c) 2023 Juan Manuel Cruz <jcruz@fi.uba.ar> <jcruz@frba.utn.edu.ar>.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its
+ *    contributors may be used to endorse or promote products derived from
+ *    this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * @file   : systick.c
+ * @date   : Set 26, 2023
+ * @author : Juan Manuel Cruz <jcruz@fi.uba.ar> <jcruz@frba.utn.edu.ar>
+ * @version    v1.0.0
+ */
+
+/********************** inclusions *******************************************/
+/* Project includes */
+#include "main.h"
+
+/********************** macros and definitions *******************************/
+
+/********************** internal data declaration ****************************/
+
+/********************** internal functions declaration ***********************/
+
+/********************** internal data definition *****************************/
+
+/********************** external data declaration ****************************/
+
+/********************** external functions definition ************************/
+/* Provides a blocking delay in microseconds using the SysTick timer */
+void systick_delay_us(uint32_t delay_us)
+{
+    uint32_t start, current, target, elapsed;
+
+    if (0 == delay_us)
+        return;
+
+    /* Get the start value of the SysTick counter */
+    start = SysTick->VAL;
+
+    /* Calculate the total number of SysTick counts required for the delay */
+    target = delay_us * (SystemCoreClock / 1000000UL);
+
+    /* Loop until the required counts have elapsed */
+    while (1)
+    {
+        /* Get the current value of the SysTick counter */
+        current = SysTick->VAL;
+
+        /* Handle the case where the SysTick counter wraps around, */
+        /* counts down to 0 and reloads */
+        if (current <= start)
+        {
+            elapsed = start - current;
+        }
+        else
+        {
+            /* Counter wrapped around, */
+            /* add the reload value to account for the wrap */
+            elapsed = SysTick->LOAD + start - current;
+        }
+
+        /* Exit the loop when the desired delay is reached */
+        if (elapsed >= target)
+        {
+            break;
+        }
+    }
+}
+
+/********************** end of file ******************************************/
diff --git a/app/src/task_sensor.c b/app/src/task_sensor.c
@@ -186,7 +186,6 @@ void task_sensor_statechart(void)
             case ST_BTN_XX_UP:
                 if (EV_BTN_XX_DOWN == p_task_sensor_dta->event)
                 {
-                    // put_event_task_system(p_task_sensor_cfg->signal_down);
                     p_task_sensor_dta->state = ST_BTN_XX_FALLING;
                     p_task_sensor_dta->tick  = DEL_BTN_XX_MAX;
                 }