commit 6bc6eae6f994cba9682f5eac33d4f6b25883ddd9
parent a911da71d223e535dab2c550fa18ddf8cdaf0604
Author: Martin Kloeckner <mjkloeckner@gmail.com>
Date: Wed, 8 Oct 2025 14:25:44 -0300
`set ff=unix`
Diffstat:
| M | Core/Src/main.c | | | 586 | ++++++++++++++++++++++++++++++++++++++++---------------------------------------- |
| M | app/inc/app.h | | | 148 | ++++++++++++++++++++++++++++++++++++++++---------------------------------------- |
| M | app/inc/display.h | | | 26 | +++++++++++++------------- |
| M | app/src/app.c | | | 388 | ++++++++++++++++++++++++++++++++++++++++---------------------------------------- |
| M | app/src/display.c | | | 462 | ++++++++++++++++++++++++++++++++++++++++---------------------------------------- |
| M | app/src/systick.c | | | 188 | ++++++++++++++++++++++++++++++++++++++++---------------------------------------- |
| M | app/src/task_test.c | | | 316 | ++++++++++++++++++++++++++++++++++++++++---------------------------------------- |
7 files changed, 1057 insertions(+), 1057 deletions(-)
diff --git a/Core/Src/main.c b/Core/Src/main.c
@@ -1,293 +1,293 @@
-/* USER CODE BEGIN Header */
-/**
- ******************************************************************************
- * @file : main.c
- * @brief : Main program body
- ******************************************************************************
- * @attention
- *
- * Copyright (c) 2025 STMicroelectronics.
- * All rights reserved.
- *
- * This software is licensed under terms that can be found in the LICENSE file
- * in the root directory of this software component.
- * If no LICENSE file comes with this software, it is provided AS-IS.
- *
- ******************************************************************************
- */
-/* USER CODE END Header */
-/* Includes ------------------------------------------------------------------*/
-#include "main.h"
-
-/* Private includes ----------------------------------------------------------*/
-/* USER CODE BEGIN Includes */
-
-/* Application includes. */
-#include "logger.h"
-#include "app.h"
-
-/* USER CODE END Includes */
-
-/* Private typedef -----------------------------------------------------------*/
-/* USER CODE BEGIN PTD */
-
-/* USER CODE END PTD */
-
-/* Private define ------------------------------------------------------------*/
-/* USER CODE BEGIN PD */
-
-/* USER CODE END PD */
-
-/* Private macro -------------------------------------------------------------*/
-/* USER CODE BEGIN PM */
-
-/* USER CODE END PM */
-
-/* Private variables ---------------------------------------------------------*/
-UART_HandleTypeDef huart2;
-
-/* USER CODE BEGIN PV */
-
-/* USER CODE END PV */
-
-/* Private function prototypes -----------------------------------------------*/
-void SystemClock_Config(void);
-static void MX_GPIO_Init(void);
-static void MX_USART2_UART_Init(void);
-/* USER CODE BEGIN PFP */
-
-/* USER CODE END PFP */
-
-/* Private user code ---------------------------------------------------------*/
-/* USER CODE BEGIN 0 */
-#if (1 == LOGGER_CONFIG_USE_SEMIHOSTING)
-
-extern void initialise_monitor_handles(void);
-
-#endif
-
-/* USER CODE END 0 */
-
-/**
- * @brief The application entry point.
- * @retval int
- */
-int main(void)
-{
-
- /* USER CODE BEGIN 1 */
- #if (1 == LOGGER_CONFIG_USE_SEMIHOSTING)
-
- initialise_monitor_handles();
-
- #endif
-
- /* USER CODE END 1 */
-
- /* MCU Configuration--------------------------------------------------------*/
-
- /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
- HAL_Init();
-
- /* USER CODE BEGIN Init */
-
- /* USER CODE END Init */
-
- /* Configure the system clock */
- SystemClock_Config();
-
- /* USER CODE BEGIN SysInit */
-
- /* USER CODE END SysInit */
-
- /* Initialize all configured peripherals */
- MX_GPIO_Init();
- MX_USART2_UART_Init();
- /* USER CODE BEGIN 2 */
-
- /* Application Init */
- app_init();
-
- /* USER CODE END 2 */
-
- /* Infinite loop */
- /* USER CODE BEGIN WHILE */
- while (1)
- {
- /* USER CODE END WHILE */
-
- /* USER CODE BEGIN 3 */
-
- /* Application Update */
- app_update();
- }
- /* USER CODE END 3 */
-}
-
-/**
- * @brief System Clock Configuration
- * @retval None
- */
-void SystemClock_Config(void)
-{
- RCC_OscInitTypeDef RCC_OscInitStruct = {0};
- RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
-
- /** Initializes the RCC Oscillators according to the specified parameters
- * in the RCC_OscInitTypeDef structure.
- */
- RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
- RCC_OscInitStruct.HSIState = RCC_HSI_ON;
- RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
- RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
- RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI_DIV2;
- RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL16;
- if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
- {
- Error_Handler();
- }
-
- /** Initializes the CPU, AHB and APB buses clocks
- */
- RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
- |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
- RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
- RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
- RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
- RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
-
- if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK)
- {
- Error_Handler();
- }
-}
-
-/**
- * @brief USART2 Initialization Function
- * @param None
- * @retval None
- */
-static void MX_USART2_UART_Init(void)
-{
-
- /* USER CODE BEGIN USART2_Init 0 */
-
- /* USER CODE END USART2_Init 0 */
-
- /* USER CODE BEGIN USART2_Init 1 */
-
- /* USER CODE END USART2_Init 1 */
- huart2.Instance = USART2;
- huart2.Init.BaudRate = 115200;
- huart2.Init.WordLength = UART_WORDLENGTH_8B;
- huart2.Init.StopBits = UART_STOPBITS_1;
- huart2.Init.Parity = UART_PARITY_NONE;
- huart2.Init.Mode = UART_MODE_TX_RX;
- huart2.Init.HwFlowCtl = UART_HWCONTROL_NONE;
- huart2.Init.OverSampling = UART_OVERSAMPLING_16;
- if (HAL_UART_Init(&huart2) != HAL_OK)
- {
- Error_Handler();
- }
- /* USER CODE BEGIN USART2_Init 2 */
-
- /* USER CODE END USART2_Init 2 */
-
-}
-
-/**
- * @brief GPIO Initialization Function
- * @param None
- * @retval None
- */
-static void MX_GPIO_Init(void)
-{
- GPIO_InitTypeDef GPIO_InitStruct = {0};
-/* USER CODE BEGIN MX_GPIO_Init_1 */
-/* USER CODE END MX_GPIO_Init_1 */
-
- /* GPIO Ports Clock Enable */
- __HAL_RCC_GPIOC_CLK_ENABLE();
- __HAL_RCC_GPIOD_CLK_ENABLE();
- __HAL_RCC_GPIOA_CLK_ENABLE();
- __HAL_RCC_GPIOB_CLK_ENABLE();
-
- /*Configure GPIO pin Output Level */
- HAL_GPIO_WritePin(GPIOA, LD2_Pin|D7_Pin|D8_Pin, GPIO_PIN_RESET);
-
- /*Configure GPIO pin Output Level */
- HAL_GPIO_WritePin(GPIOB, D6_Pin|D5_Pin|D4_Pin, GPIO_PIN_RESET);
-
- /*Configure GPIO pin Output Level */
- HAL_GPIO_WritePin(D9_GPIO_Port, D9_Pin, GPIO_PIN_RESET);
-
- /*Configure GPIO pin : B1_Pin */
- GPIO_InitStruct.Pin = B1_Pin;
- GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;
- GPIO_InitStruct.Pull = GPIO_NOPULL;
- HAL_GPIO_Init(B1_GPIO_Port, &GPIO_InitStruct);
-
- /*Configure GPIO pins : LD2_Pin D7_Pin D8_Pin */
- GPIO_InitStruct.Pin = LD2_Pin|D7_Pin|D8_Pin;
- GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
- GPIO_InitStruct.Pull = GPIO_NOPULL;
- GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
- HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
-
- /*Configure GPIO pins : D6_Pin D5_Pin D4_Pin */
- GPIO_InitStruct.Pin = D6_Pin|D5_Pin|D4_Pin;
- GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
- GPIO_InitStruct.Pull = GPIO_NOPULL;
- GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
- HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
-
- /*Configure GPIO pin : D9_Pin */
- GPIO_InitStruct.Pin = D9_Pin;
- GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
- GPIO_InitStruct.Pull = GPIO_NOPULL;
- GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
- HAL_GPIO_Init(D9_GPIO_Port, &GPIO_InitStruct);
-
- /* EXTI interrupt init*/
- HAL_NVIC_SetPriority(EXTI15_10_IRQn, 0, 0);
- HAL_NVIC_EnableIRQ(EXTI15_10_IRQn);
-
-/* USER CODE BEGIN MX_GPIO_Init_2 */
-/* USER CODE END MX_GPIO_Init_2 */
-}
-
-/* USER CODE BEGIN 4 */
-
-/* USER CODE END 4 */
-
-/**
- * @brief This function is executed in case of error occurrence.
- * @retval None
- */
-void Error_Handler(void)
-{
- /* USER CODE BEGIN Error_Handler_Debug */
- /* User can add his own implementation to report the HAL error return state */
- __disable_irq();
- while (1)
- {
- }
- /* USER CODE END Error_Handler_Debug */
-}
-
-#ifdef USE_FULL_ASSERT
-/**
- * @brief Reports the name of the source file and the source line number
- * where the assert_param error has occurred.
- * @param file: pointer to the source file name
- * @param line: assert_param error line source number
- * @retval None
- */
-void assert_failed(uint8_t *file, uint32_t line)
-{
- /* USER CODE BEGIN 6 */
- /* User can add his own implementation to report the file name and line number,
- ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
- /* USER CODE END 6 */
-}
-#endif /* USE_FULL_ASSERT */
+/* USER CODE BEGIN Header */
+/**
+ ******************************************************************************
+ * @file : main.c
+ * @brief : Main program body
+ ******************************************************************************
+ * @attention
+ *
+ * Copyright (c) 2025 STMicroelectronics.
+ * All rights reserved.
+ *
+ * This software is licensed under terms that can be found in the LICENSE file
+ * in the root directory of this software component.
+ * If no LICENSE file comes with this software, it is provided AS-IS.
+ *
+ ******************************************************************************
+ */
+/* USER CODE END Header */
+/* Includes ------------------------------------------------------------------*/
+#include "main.h"
+
+/* Private includes ----------------------------------------------------------*/
+/* USER CODE BEGIN Includes */
+
+/* Application includes. */
+#include "logger.h"
+#include "app.h"
+
+/* USER CODE END Includes */
+
+/* Private typedef -----------------------------------------------------------*/
+/* USER CODE BEGIN PTD */
+
+/* USER CODE END PTD */
+
+/* Private define ------------------------------------------------------------*/
+/* USER CODE BEGIN PD */
+
+/* USER CODE END PD */
+
+/* Private macro -------------------------------------------------------------*/
+/* USER CODE BEGIN PM */
+
+/* USER CODE END PM */
+
+/* Private variables ---------------------------------------------------------*/
+UART_HandleTypeDef huart2;
+
+/* USER CODE BEGIN PV */
+
+/* USER CODE END PV */
+
+/* Private function prototypes -----------------------------------------------*/
+void SystemClock_Config(void);
+static void MX_GPIO_Init(void);
+static void MX_USART2_UART_Init(void);
+/* USER CODE BEGIN PFP */
+
+/* USER CODE END PFP */
+
+/* Private user code ---------------------------------------------------------*/
+/* USER CODE BEGIN 0 */
+#if (1 == LOGGER_CONFIG_USE_SEMIHOSTING)
+
+extern void initialise_monitor_handles(void);
+
+#endif
+
+/* USER CODE END 0 */
+
+/**
+ * @brief The application entry point.
+ * @retval int
+ */
+int main(void)
+{
+
+ /* USER CODE BEGIN 1 */
+ #if (1 == LOGGER_CONFIG_USE_SEMIHOSTING)
+
+ initialise_monitor_handles();
+
+ #endif
+
+ /* USER CODE END 1 */
+
+ /* MCU Configuration--------------------------------------------------------*/
+
+ /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
+ HAL_Init();
+
+ /* USER CODE BEGIN Init */
+
+ /* USER CODE END Init */
+
+ /* Configure the system clock */
+ SystemClock_Config();
+
+ /* USER CODE BEGIN SysInit */
+
+ /* USER CODE END SysInit */
+
+ /* Initialize all configured peripherals */
+ MX_GPIO_Init();
+ MX_USART2_UART_Init();
+ /* USER CODE BEGIN 2 */
+
+ /* Application Init */
+ app_init();
+
+ /* USER CODE END 2 */
+
+ /* Infinite loop */
+ /* USER CODE BEGIN WHILE */
+ while (1)
+ {
+ /* USER CODE END WHILE */
+
+ /* USER CODE BEGIN 3 */
+
+ /* Application Update */
+ app_update();
+ }
+ /* USER CODE END 3 */
+}
+
+/**
+ * @brief System Clock Configuration
+ * @retval None
+ */
+void SystemClock_Config(void)
+{
+ RCC_OscInitTypeDef RCC_OscInitStruct = {0};
+ RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
+
+ /** Initializes the RCC Oscillators according to the specified parameters
+ * in the RCC_OscInitTypeDef structure.
+ */
+ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
+ RCC_OscInitStruct.HSIState = RCC_HSI_ON;
+ RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
+ RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
+ RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI_DIV2;
+ RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL16;
+ if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
+ {
+ Error_Handler();
+ }
+
+ /** Initializes the CPU, AHB and APB buses clocks
+ */
+ RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
+ |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
+ RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
+ RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
+ RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
+ RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
+
+ if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK)
+ {
+ Error_Handler();
+ }
+}
+
+/**
+ * @brief USART2 Initialization Function
+ * @param None
+ * @retval None
+ */
+static void MX_USART2_UART_Init(void)
+{
+
+ /* USER CODE BEGIN USART2_Init 0 */
+
+ /* USER CODE END USART2_Init 0 */
+
+ /* USER CODE BEGIN USART2_Init 1 */
+
+ /* USER CODE END USART2_Init 1 */
+ huart2.Instance = USART2;
+ huart2.Init.BaudRate = 115200;
+ huart2.Init.WordLength = UART_WORDLENGTH_8B;
+ huart2.Init.StopBits = UART_STOPBITS_1;
+ huart2.Init.Parity = UART_PARITY_NONE;
+ huart2.Init.Mode = UART_MODE_TX_RX;
+ huart2.Init.HwFlowCtl = UART_HWCONTROL_NONE;
+ huart2.Init.OverSampling = UART_OVERSAMPLING_16;
+ if (HAL_UART_Init(&huart2) != HAL_OK)
+ {
+ Error_Handler();
+ }
+ /* USER CODE BEGIN USART2_Init 2 */
+
+ /* USER CODE END USART2_Init 2 */
+
+}
+
+/**
+ * @brief GPIO Initialization Function
+ * @param None
+ * @retval None
+ */
+static void MX_GPIO_Init(void)
+{
+ GPIO_InitTypeDef GPIO_InitStruct = {0};
+/* USER CODE BEGIN MX_GPIO_Init_1 */
+/* USER CODE END MX_GPIO_Init_1 */
+
+ /* GPIO Ports Clock Enable */
+ __HAL_RCC_GPIOC_CLK_ENABLE();
+ __HAL_RCC_GPIOD_CLK_ENABLE();
+ __HAL_RCC_GPIOA_CLK_ENABLE();
+ __HAL_RCC_GPIOB_CLK_ENABLE();
+
+ /*Configure GPIO pin Output Level */
+ HAL_GPIO_WritePin(GPIOA, LD2_Pin|D7_Pin|D8_Pin, GPIO_PIN_RESET);
+
+ /*Configure GPIO pin Output Level */
+ HAL_GPIO_WritePin(GPIOB, D6_Pin|D5_Pin|D4_Pin, GPIO_PIN_RESET);
+
+ /*Configure GPIO pin Output Level */
+ HAL_GPIO_WritePin(D9_GPIO_Port, D9_Pin, GPIO_PIN_RESET);
+
+ /*Configure GPIO pin : B1_Pin */
+ GPIO_InitStruct.Pin = B1_Pin;
+ GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ HAL_GPIO_Init(B1_GPIO_Port, &GPIO_InitStruct);
+
+ /*Configure GPIO pins : LD2_Pin D7_Pin D8_Pin */
+ GPIO_InitStruct.Pin = LD2_Pin|D7_Pin|D8_Pin;
+ GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
+ HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
+
+ /*Configure GPIO pins : D6_Pin D5_Pin D4_Pin */
+ GPIO_InitStruct.Pin = D6_Pin|D5_Pin|D4_Pin;
+ GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
+ HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
+
+ /*Configure GPIO pin : D9_Pin */
+ GPIO_InitStruct.Pin = D9_Pin;
+ GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
+ HAL_GPIO_Init(D9_GPIO_Port, &GPIO_InitStruct);
+
+ /* EXTI interrupt init*/
+ HAL_NVIC_SetPriority(EXTI15_10_IRQn, 0, 0);
+ HAL_NVIC_EnableIRQ(EXTI15_10_IRQn);
+
+/* USER CODE BEGIN MX_GPIO_Init_2 */
+/* USER CODE END MX_GPIO_Init_2 */
+}
+
+/* USER CODE BEGIN 4 */
+
+/* USER CODE END 4 */
+
+/**
+ * @brief This function is executed in case of error occurrence.
+ * @retval None
+ */
+void Error_Handler(void)
+{
+ /* USER CODE BEGIN Error_Handler_Debug */
+ /* User can add his own implementation to report the HAL error return state */
+ __disable_irq();
+ while (1)
+ {
+ }
+ /* USER CODE END Error_Handler_Debug */
+}
+
+#ifdef USE_FULL_ASSERT
+/**
+ * @brief Reports the name of the source file and the source line number
+ * where the assert_param error has occurred.
+ * @param file: pointer to the source file name
+ * @param line: assert_param error line source number
+ * @retval None
+ */
+void assert_failed(uint8_t *file, uint32_t line)
+{
+ /* USER CODE BEGIN 6 */
+ /* User can add his own implementation to report the file name and line number,
+ ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+ /* USER CODE END 6 */
+}
+#endif /* USE_FULL_ASSERT */
diff --git a/app/inc/app.h b/app/inc/app.h
@@ -1,74 +1,74 @@
-/*
- * 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.h
- * @date : Set 26, 2023
- * @author : Juan Manuel Cruz <jcruz@fi.uba.ar> <jcruz@frba.utn.edu.ar>
- * @version v1.0.0
- */
-
-#ifndef APP_INC_APP_H_
-#define APP_INC_APP_H_
-
-/********************** CPP guard ********************************************/
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/********************** inclusions *******************************************/
-
-/********************** macros ***********************************************/
-#define TEST_0 (0)
-#define TEST_1 (1)
-#define TEST_2 (2)
-
-#define TEST_X (TEST_0)
-
-/********************** typedef **********************************************/
-
-/********************** external data declaration ****************************/
-extern uint32_t g_app_cnt;
-extern uint32_t g_app_runtime_us;
-
-extern volatile uint32_t g_app_tick_cnt;
-
-/********************** external functions declaration ***********************/
-extern void app_init(void);
-extern void app_update(void);
-
-/********************** End of CPP guard *************************************/
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* APP_INC_APP_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 : app.h
+ * @date : Set 26, 2023
+ * @author : Juan Manuel Cruz <jcruz@fi.uba.ar> <jcruz@frba.utn.edu.ar>
+ * @version v1.0.0
+ */
+
+#ifndef APP_INC_APP_H_
+#define APP_INC_APP_H_
+
+/********************** CPP guard ********************************************/
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/********************** inclusions *******************************************/
+
+/********************** macros ***********************************************/
+#define TEST_0 (0)
+#define TEST_1 (1)
+#define TEST_2 (2)
+
+#define TEST_X (TEST_0)
+
+/********************** typedef **********************************************/
+
+/********************** external data declaration ****************************/
+extern uint32_t g_app_cnt;
+extern uint32_t g_app_runtime_us;
+
+extern volatile uint32_t g_app_tick_cnt;
+
+/********************** external functions declaration ***********************/
+extern void app_init(void);
+extern void app_update(void);
+
+/********************** End of CPP guard *************************************/
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* APP_INC_APP_H_ */
+
+/********************** end of file ******************************************/
diff --git a/app/inc/display.h b/app/inc/display.h
@@ -1,13 +1,13 @@
-#ifndef _DISPLAY_H_
-#define _DISPLAY_H_
-
-#include <stdint.h>
-
-void display_init(void);
-void display_char_position_write(uint8_t x, uint8_t y);
-void display_string_write(const char *str);
-
-void display_cursor_off(void);
-void display_cursor_on(void);
-
-#endif // _DISPLAY_H_
+#ifndef _DISPLAY_H_
+#define _DISPLAY_H_
+
+#include <stdint.h>
+
+void display_init(void);
+void display_char_position_write(uint8_t x, uint8_t y);
+void display_string_write(const char *str);
+
+void display_cursor_off(void);
+void display_cursor_on(void);
+
+#endif // _DISPLAY_H_
diff --git a/app/src/app.c b/app/src/app.c
@@ -1,194 +1,194 @@
-/*
- * 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_test.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_test_init, task_test_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 - Code Integration";
-
-/********************** 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_test_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_test_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_test.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_test_init, task_test_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 - Code Integration";
+
+/********************** 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_test_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_test_tick_cnt++;
+}
+
+/********************** end of file ******************************************/
diff --git a/app/src/display.c b/app/src/display.c
@@ -1,231 +1,231 @@
-#include "display.h"
-#include "main.h"
-#include <stdbool.h>
-
-// Demo includes
-#include "logger.h"
-#include "dwt.h"
-#include "systick.h"
-
-// Functional states
-#ifndef OFF
-#define OFF 0
-#endif
-#ifndef ON
-#define ON ( !OFF )
-#endif
-
-// Electrical states
-#ifndef LOW
-#define LOW 0
-#endif
-#ifndef HIGH
-#define HIGH ( !LOW )
-#endif
-
-#define DISPLAY_IR_CLEAR_DISPLAY 0b00000001
-#define DISPLAY_IR_ENTRY_MODE_SET 0b00000100
-#define DISPLAY_IR_DISPLAY_CONTROL 0b00001000
-#define DISPLAY_IR_FUNCTION_SET 0b00100000
-#define DISPLAY_IR_SET_DDRAM_ADDR 0b10000000
-
-#define DISPLAY_IR_ENTRY_MODE_SET_INCREMENT 0b00000010
-#define DISPLAY_IR_ENTRY_MODE_SET_DECREMENT 0b00000000
-#define DISPLAY_IR_ENTRY_MODE_SET_SHIFT 0b00000001
-#define DISPLAY_IR_ENTRY_MODE_SET_NO_SHIFT 0b00000000
-
-#define DISPLAY_IR_DISPLAY_CONTROL_DISPLAY_ON 0b00000100
-#define DISPLAY_IR_DISPLAY_CONTROL_DISPLAY_OFF 0b00000000
-#define DISPLAY_IR_DISPLAY_CONTROL_CURSOR_ON 0b00000010
-#define DISPLAY_IR_DISPLAY_CONTROL_CURSOR_OFF 0b00000000
-#define DISPLAY_IR_DISPLAY_CONTROL_BLINK_ON 0b00000001
-#define DISPLAY_IR_DISPLAY_CONTROL_BLINK_OFF 0b00000000
-
-#define DISPLAY_IR_FUNCTION_SET_8BITS 0b00010000
-#define DISPLAY_IR_FUNCTION_SET_4BITS 0b00000000
-#define DISPLAY_IR_FUNCTION_SET_2LINES 0b00001000
-#define DISPLAY_IR_FUNCTION_SET_1LINE 0b00000000
-#define DISPLAY_IR_FUNCTION_SET_5x10DOTS 0b00000100
-#define DISPLAY_IR_FUNCTION_SET_5x8DOTS 0b00000000
-
-#define DISPLAY_20x4_LINE1_FIRST_CHARACTER_ADDRESS 0
-#define DISPLAY_20x4_LINE2_FIRST_CHARACTER_ADDRESS 64
-#define DISPLAY_20x4_LINE3_FIRST_CHARACTER_ADDRESS 20
-#define DISPLAY_20x4_LINE4_FIRST_CHARACTER_ADDRESS 84
-
-#define DISPLAY_RS_INSTRUCTION 0
-#define DISPLAY_RS_DATA 1
-
-#define DISPLAY_RW_WRITE 0
-#define DISPLAY_RW_READ 1
-
-#define DISPLAY_PIN_RS 8
-#define DISPLAY_PIN_EN 9
-#define DISPLAY_PIN_D4 4
-#define DISPLAY_PIN_D5 5
-#define DISPLAY_PIN_D6 6
-#define DISPLAY_PIN_D7 7
-
-#define DISPLAY_DEL_37US 37ul
-#define DISPLAY_DEL_01US 01ul
-
-// private global vars
-static bool display_initialized;
-
-// declaration of private functions
-static void display_pin_write(uint8_t pin_name, int value);
-static void display_data_bus_write(uint8_t data_byte);
-static void display_code_write(bool type, uint8_t data_bus);
-
-// public functions
-
-void display_init(void)
-{
- display_initialized = false;
-
- display_code_write(DISPLAY_RS_INSTRUCTION,
- DISPLAY_IR_FUNCTION_SET |
- DISPLAY_IR_FUNCTION_SET_4BITS |
- DISPLAY_IR_FUNCTION_SET_2LINES |
- DISPLAY_IR_FUNCTION_SET_5x8DOTS);
-
- display_code_write(DISPLAY_RS_INSTRUCTION,
- DISPLAY_IR_DISPLAY_CONTROL |
- DISPLAY_IR_DISPLAY_CONTROL_DISPLAY_OFF |
- DISPLAY_IR_DISPLAY_CONTROL_CURSOR_ON |
- DISPLAY_IR_DISPLAY_CONTROL_BLINK_ON);
-
- display_code_write(DISPLAY_RS_INSTRUCTION,
- DISPLAY_IR_CLEAR_DISPLAY);
-
- display_code_write(DISPLAY_RS_INSTRUCTION,
- DISPLAY_IR_ENTRY_MODE_SET |
- DISPLAY_IR_ENTRY_MODE_SET_INCREMENT |
- DISPLAY_IR_ENTRY_MODE_SET_NO_SHIFT);
-
- display_code_write(DISPLAY_RS_INSTRUCTION,
- DISPLAY_IR_DISPLAY_CONTROL |
- DISPLAY_IR_DISPLAY_CONTROL_DISPLAY_ON |
- DISPLAY_IR_DISPLAY_CONTROL_CURSOR_ON |
- DISPLAY_IR_DISPLAY_CONTROL_BLINK_ON);
-
- display_initialized = true;
-}
-
-void display_char_position_write(uint8_t x, uint8_t y)
-{
- switch(x)
- {
- case 0:
- display_code_write(DISPLAY_RS_INSTRUCTION,
- DISPLAY_IR_SET_DDRAM_ADDR |
- (DISPLAY_20x4_LINE1_FIRST_CHARACTER_ADDRESS + x));
- break;
-
- case 1:
- display_code_write(DISPLAY_RS_INSTRUCTION,
- DISPLAY_IR_SET_DDRAM_ADDR |
- (DISPLAY_20x4_LINE2_FIRST_CHARACTER_ADDRESS + x));
- break;
-
- case 2:
- display_code_write(DISPLAY_RS_INSTRUCTION,
- DISPLAY_IR_SET_DDRAM_ADDR |
- (DISPLAY_20x4_LINE3_FIRST_CHARACTER_ADDRESS + x));
- break;
-
- case 3:
- display_code_write(DISPLAY_RS_INSTRUCTION,
- DISPLAY_IR_SET_DDRAM_ADDR |
- (DISPLAY_20x4_LINE4_FIRST_CHARACTER_ADDRESS + x));
- break;
- default: break;
- }
-}
-
-void display_string_write(const char * str)
-{
- while (*str) {
- display_code_write(DISPLAY_RS_DATA, *str++);
- }
-}
-
-void display_cursor_off(void)
-{
- display_code_write(DISPLAY_RS_INSTRUCTION,
- DISPLAY_IR_DISPLAY_CONTROL |
- DISPLAY_IR_DISPLAY_CONTROL_DISPLAY_ON |
- DISPLAY_IR_DISPLAY_CONTROL_CURSOR_OFF |
- DISPLAY_IR_DISPLAY_CONTROL_BLINK_OFF);
-}
-
-void display_cursor_on(void)
-{
- display_code_write(DISPLAY_RS_INSTRUCTION,
- DISPLAY_IR_DISPLAY_CONTROL |
- DISPLAY_IR_DISPLAY_CONTROL_DISPLAY_ON |
- DISPLAY_IR_DISPLAY_CONTROL_CURSOR_ON |
- DISPLAY_IR_DISPLAY_CONTROL_BLINK_ON);
-}
-
-// private functions
-
-static void display_code_write( bool type, uint8_t data_bus )
-{
- if (type == DISPLAY_RS_INSTRUCTION) {
- display_pin_write( DISPLAY_PIN_RS, DISPLAY_RS_INSTRUCTION );
- }
- else {
- display_pin_write(DISPLAY_PIN_RS, DISPLAY_RS_DATA);
- }
-
- display_data_bus_write(data_bus);
-}
-
-static void display_pin_write(uint8_t pin_name, int value)
-{
- switch(pin_name)
- {
- case DISPLAY_PIN_D4:
- HAL_GPIO_WritePin(D4_GPIO_Port, D4_Pin, value);
- break;
- case DISPLAY_PIN_D5:
- HAL_GPIO_WritePin(D5_GPIO_Port, D5_Pin, value);
- break;
- case DISPLAY_PIN_D6:
- HAL_GPIO_WritePin(D6_GPIO_Port, D6_Pin, value);
- break;
- case DISPLAY_PIN_D7:
- HAL_GPIO_WritePin(D7_GPIO_Port, D7_Pin, value);
- break;
- case DISPLAY_PIN_RS:
- HAL_GPIO_WritePin(D8_GPIO_Port, D8_Pin, value);
- break;
- case DISPLAY_PIN_EN:
- HAL_GPIO_WritePin(D9_GPIO_Port, D9_Pin, value);
- break;
- default: break;
- }
-}
-
-static void display_data_bus_write( uint8_t data_bus )
-{
- display_pin_write( DISPLAY_PIN_EN, OFF );
- display_pin_write( DISPLAY_PIN_D7, data_bus & 0b10000000 );
- display_pin_write( DISPLAY_PIN_D6, data_bus & 0b01000000 );
- display_pin_write( DISPLAY_PIN_D5, data_bus & 0b00100000 );
- display_pin_write( DISPLAY_PIN_D4, data_bus & 0b00010000 );
-
- if ( display_initialized == true) {
- display_pin_write( DISPLAY_PIN_EN, ON );
- display_pin_write( DISPLAY_PIN_EN, OFF );
- display_pin_write( DISPLAY_PIN_D7, data_bus & 0b00001000 );
- display_pin_write( DISPLAY_PIN_D6, data_bus & 0b00000100 );
- display_pin_write( DISPLAY_PIN_D5, data_bus & 0b00000010 );
- display_pin_write( DISPLAY_PIN_D4, data_bus & 0b00000001 );
- }
-
- display_pin_write( DISPLAY_PIN_EN, ON );
- display_pin_write( DISPLAY_PIN_EN, OFF );
- HAL_Delay(1);
-}
+#include "display.h"
+#include "main.h"
+#include <stdbool.h>
+
+// Demo includes
+#include "logger.h"
+#include "dwt.h"
+#include "systick.h"
+
+// Functional states
+#ifndef OFF
+#define OFF 0
+#endif
+#ifndef ON
+#define ON ( !OFF )
+#endif
+
+// Electrical states
+#ifndef LOW
+#define LOW 0
+#endif
+#ifndef HIGH
+#define HIGH ( !LOW )
+#endif
+
+#define DISPLAY_IR_CLEAR_DISPLAY 0b00000001
+#define DISPLAY_IR_ENTRY_MODE_SET 0b00000100
+#define DISPLAY_IR_DISPLAY_CONTROL 0b00001000
+#define DISPLAY_IR_FUNCTION_SET 0b00100000
+#define DISPLAY_IR_SET_DDRAM_ADDR 0b10000000
+
+#define DISPLAY_IR_ENTRY_MODE_SET_INCREMENT 0b00000010
+#define DISPLAY_IR_ENTRY_MODE_SET_DECREMENT 0b00000000
+#define DISPLAY_IR_ENTRY_MODE_SET_SHIFT 0b00000001
+#define DISPLAY_IR_ENTRY_MODE_SET_NO_SHIFT 0b00000000
+
+#define DISPLAY_IR_DISPLAY_CONTROL_DISPLAY_ON 0b00000100
+#define DISPLAY_IR_DISPLAY_CONTROL_DISPLAY_OFF 0b00000000
+#define DISPLAY_IR_DISPLAY_CONTROL_CURSOR_ON 0b00000010
+#define DISPLAY_IR_DISPLAY_CONTROL_CURSOR_OFF 0b00000000
+#define DISPLAY_IR_DISPLAY_CONTROL_BLINK_ON 0b00000001
+#define DISPLAY_IR_DISPLAY_CONTROL_BLINK_OFF 0b00000000
+
+#define DISPLAY_IR_FUNCTION_SET_8BITS 0b00010000
+#define DISPLAY_IR_FUNCTION_SET_4BITS 0b00000000
+#define DISPLAY_IR_FUNCTION_SET_2LINES 0b00001000
+#define DISPLAY_IR_FUNCTION_SET_1LINE 0b00000000
+#define DISPLAY_IR_FUNCTION_SET_5x10DOTS 0b00000100
+#define DISPLAY_IR_FUNCTION_SET_5x8DOTS 0b00000000
+
+#define DISPLAY_20x4_LINE1_FIRST_CHARACTER_ADDRESS 0
+#define DISPLAY_20x4_LINE2_FIRST_CHARACTER_ADDRESS 64
+#define DISPLAY_20x4_LINE3_FIRST_CHARACTER_ADDRESS 20
+#define DISPLAY_20x4_LINE4_FIRST_CHARACTER_ADDRESS 84
+
+#define DISPLAY_RS_INSTRUCTION 0
+#define DISPLAY_RS_DATA 1
+
+#define DISPLAY_RW_WRITE 0
+#define DISPLAY_RW_READ 1
+
+#define DISPLAY_PIN_RS 8
+#define DISPLAY_PIN_EN 9
+#define DISPLAY_PIN_D4 4
+#define DISPLAY_PIN_D5 5
+#define DISPLAY_PIN_D6 6
+#define DISPLAY_PIN_D7 7
+
+#define DISPLAY_DEL_37US 37ul
+#define DISPLAY_DEL_01US 01ul
+
+// private global vars
+static bool display_initialized;
+
+// declaration of private functions
+static void display_pin_write(uint8_t pin_name, int value);
+static void display_data_bus_write(uint8_t data_byte);
+static void display_code_write(bool type, uint8_t data_bus);
+
+// public functions
+
+void display_init(void)
+{
+ display_initialized = false;
+
+ display_code_write(DISPLAY_RS_INSTRUCTION,
+ DISPLAY_IR_FUNCTION_SET |
+ DISPLAY_IR_FUNCTION_SET_4BITS |
+ DISPLAY_IR_FUNCTION_SET_2LINES |
+ DISPLAY_IR_FUNCTION_SET_5x8DOTS);
+
+ display_code_write(DISPLAY_RS_INSTRUCTION,
+ DISPLAY_IR_DISPLAY_CONTROL |
+ DISPLAY_IR_DISPLAY_CONTROL_DISPLAY_OFF |
+ DISPLAY_IR_DISPLAY_CONTROL_CURSOR_ON |
+ DISPLAY_IR_DISPLAY_CONTROL_BLINK_ON);
+
+ display_code_write(DISPLAY_RS_INSTRUCTION,
+ DISPLAY_IR_CLEAR_DISPLAY);
+
+ display_code_write(DISPLAY_RS_INSTRUCTION,
+ DISPLAY_IR_ENTRY_MODE_SET |
+ DISPLAY_IR_ENTRY_MODE_SET_INCREMENT |
+ DISPLAY_IR_ENTRY_MODE_SET_NO_SHIFT);
+
+ display_code_write(DISPLAY_RS_INSTRUCTION,
+ DISPLAY_IR_DISPLAY_CONTROL |
+ DISPLAY_IR_DISPLAY_CONTROL_DISPLAY_ON |
+ DISPLAY_IR_DISPLAY_CONTROL_CURSOR_ON |
+ DISPLAY_IR_DISPLAY_CONTROL_BLINK_ON);
+
+ display_initialized = true;
+}
+
+void display_char_position_write(uint8_t x, uint8_t y)
+{
+ switch(x)
+ {
+ case 0:
+ display_code_write(DISPLAY_RS_INSTRUCTION,
+ DISPLAY_IR_SET_DDRAM_ADDR |
+ (DISPLAY_20x4_LINE1_FIRST_CHARACTER_ADDRESS + x));
+ break;
+
+ case 1:
+ display_code_write(DISPLAY_RS_INSTRUCTION,
+ DISPLAY_IR_SET_DDRAM_ADDR |
+ (DISPLAY_20x4_LINE2_FIRST_CHARACTER_ADDRESS + x));
+ break;
+
+ case 2:
+ display_code_write(DISPLAY_RS_INSTRUCTION,
+ DISPLAY_IR_SET_DDRAM_ADDR |
+ (DISPLAY_20x4_LINE3_FIRST_CHARACTER_ADDRESS + x));
+ break;
+
+ case 3:
+ display_code_write(DISPLAY_RS_INSTRUCTION,
+ DISPLAY_IR_SET_DDRAM_ADDR |
+ (DISPLAY_20x4_LINE4_FIRST_CHARACTER_ADDRESS + x));
+ break;
+ default: break;
+ }
+}
+
+void display_string_write(const char * str)
+{
+ while (*str) {
+ display_code_write(DISPLAY_RS_DATA, *str++);
+ }
+}
+
+void display_cursor_off(void)
+{
+ display_code_write(DISPLAY_RS_INSTRUCTION,
+ DISPLAY_IR_DISPLAY_CONTROL |
+ DISPLAY_IR_DISPLAY_CONTROL_DISPLAY_ON |
+ DISPLAY_IR_DISPLAY_CONTROL_CURSOR_OFF |
+ DISPLAY_IR_DISPLAY_CONTROL_BLINK_OFF);
+}
+
+void display_cursor_on(void)
+{
+ display_code_write(DISPLAY_RS_INSTRUCTION,
+ DISPLAY_IR_DISPLAY_CONTROL |
+ DISPLAY_IR_DISPLAY_CONTROL_DISPLAY_ON |
+ DISPLAY_IR_DISPLAY_CONTROL_CURSOR_ON |
+ DISPLAY_IR_DISPLAY_CONTROL_BLINK_ON);
+}
+
+// private functions
+
+static void display_code_write( bool type, uint8_t data_bus )
+{
+ if (type == DISPLAY_RS_INSTRUCTION) {
+ display_pin_write( DISPLAY_PIN_RS, DISPLAY_RS_INSTRUCTION );
+ }
+ else {
+ display_pin_write(DISPLAY_PIN_RS, DISPLAY_RS_DATA);
+ }
+
+ display_data_bus_write(data_bus);
+}
+
+static void display_pin_write(uint8_t pin_name, int value)
+{
+ switch(pin_name)
+ {
+ case DISPLAY_PIN_D4:
+ HAL_GPIO_WritePin(D4_GPIO_Port, D4_Pin, value);
+ break;
+ case DISPLAY_PIN_D5:
+ HAL_GPIO_WritePin(D5_GPIO_Port, D5_Pin, value);
+ break;
+ case DISPLAY_PIN_D6:
+ HAL_GPIO_WritePin(D6_GPIO_Port, D6_Pin, value);
+ break;
+ case DISPLAY_PIN_D7:
+ HAL_GPIO_WritePin(D7_GPIO_Port, D7_Pin, value);
+ break;
+ case DISPLAY_PIN_RS:
+ HAL_GPIO_WritePin(D8_GPIO_Port, D8_Pin, value);
+ break;
+ case DISPLAY_PIN_EN:
+ HAL_GPIO_WritePin(D9_GPIO_Port, D9_Pin, value);
+ break;
+ default: break;
+ }
+}
+
+static void display_data_bus_write( uint8_t data_bus )
+{
+ display_pin_write( DISPLAY_PIN_EN, OFF );
+ display_pin_write( DISPLAY_PIN_D7, data_bus & 0b10000000 );
+ display_pin_write( DISPLAY_PIN_D6, data_bus & 0b01000000 );
+ display_pin_write( DISPLAY_PIN_D5, data_bus & 0b00100000 );
+ display_pin_write( DISPLAY_PIN_D4, data_bus & 0b00010000 );
+
+ if ( display_initialized == true) {
+ display_pin_write( DISPLAY_PIN_EN, ON );
+ display_pin_write( DISPLAY_PIN_EN, OFF );
+ display_pin_write( DISPLAY_PIN_D7, data_bus & 0b00001000 );
+ display_pin_write( DISPLAY_PIN_D6, data_bus & 0b00000100 );
+ display_pin_write( DISPLAY_PIN_D5, data_bus & 0b00000010 );
+ display_pin_write( DISPLAY_PIN_D4, data_bus & 0b00000001 );
+ }
+
+ display_pin_write( DISPLAY_PIN_EN, ON );
+ display_pin_write( DISPLAY_PIN_EN, OFF );
+ HAL_Delay(1);
+}
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_test.c b/app/src/task_test.c
@@ -1,158 +1,158 @@
-/*
- * 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_test.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 "app.h"
-#include "task_test_attribute.h"
-#include "display.h"
-
-/********************** macros and definitions *******************************/
-#define G_TASK_TEST_CNT_INIT 0ul
-#define G_TASK_TEST_TICK_CNT_INI 0ul
-
-#define DEL_TEST_XX_MIN 0ul
-#define DEL_TEST_XX_MED 500ul
-#define DEL_TEST_XX_MAX 1000ul
-
-/********************** internal data declaration ****************************/
-task_test_dta_t task_test_dta =
-{DEL_TEST_XX_MIN};
-
-/********************** internal functions declaration ***********************/
-void task_test_statechart(void);
-
-/********************** internal data definition *****************************/
-const char *p_task_test = "Task Test (Test Code Integration)";
-const char *p_task_test_ = "Non-Blocking & Update By Time Code";
-
-/********************** external data declaration ****************************/
-uint32_t g_task_test_cnt;
-volatile uint32_t g_task_test_tick_cnt;
-
-/********************** external functions definition ************************/
-void task_test_init(void *parameters)
-{
- task_test_dta_t *p_task_test_dta;
- uint32_t tick;
-
- /* Print out: Task Initialized */
- LOGGER_INFO(" ");
- LOGGER_INFO(" %s is running - %s", GET_NAME(task_test_init), p_task_test);
- LOGGER_INFO(" %s is a %s", GET_NAME(task_test), p_task_test_);
-
- /* Init & Print out: Task execution counter */
- g_task_test_cnt = G_TASK_TEST_CNT_INIT;
- LOGGER_INFO(" %s = %lu", GET_NAME(g_task_test_cnt), g_task_test_cnt);
-
- /* Update Task Test Configuration & Data Pointer */
- p_task_test_dta = &task_test_dta;
-
- tick = DEL_TEST_XX_MAX;
- p_task_test_dta->tick = tick;
- LOGGER_INFO(" %s = %lu", GET_NAME(tick), (uint32_t)tick);
-
- /* Init & Print out: LCD Display */
- display_init();
- display_cursor_off();
-
- display_char_position_write(0, 0);
- display_string_write("Hello, World!");
-}
-
-void task_test_update(void *parameters)
-{
- bool b_time_update_required = false;
-
- /* Protect shared resource */
- __asm("CPSID i"); /* disable interrupts */
- if (G_TASK_TEST_TICK_CNT_INI < g_task_test_tick_cnt)
- {
- /* Update Tick Counter */
- g_task_test_tick_cnt--;
- b_time_update_required = true;
- }
- __asm("CPSIE i"); /* enable interrupts */
-
- while (b_time_update_required)
- {
- /* Update Task Counter */
- g_task_test_cnt++;
-
- /* Run Task Statechart */
- task_test_statechart();
-
- /* Protect shared resource */
- __asm("CPSID i"); /* disable interrupts */
- if (G_TASK_TEST_TICK_CNT_INI < g_task_test_tick_cnt)
- {
- /* Update Tick Counter */
- g_task_test_tick_cnt--;
- b_time_update_required = true;
- }
- else
- {
- b_time_update_required = false;
- }
- __asm("CPSIE i"); /* enable interrupts */
- }
-}
-
-void task_test_statechart(void)
-{
- task_test_dta_t *p_task_test_dta;
-
- /* Update Task Test Configuration & Data Pointer */
- p_task_test_dta = &task_test_dta;
-
- if (DEL_TEST_XX_MIN < p_task_test_dta->tick)
- {
- p_task_test_dta->tick--;
- }
- else
- {
- }
-}
+/*
+ * 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_test.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 "app.h"
+#include "task_test_attribute.h"
+#include "display.h"
+
+/********************** macros and definitions *******************************/
+#define G_TASK_TEST_CNT_INIT 0ul
+#define G_TASK_TEST_TICK_CNT_INI 0ul
+
+#define DEL_TEST_XX_MIN 0ul
+#define DEL_TEST_XX_MED 500ul
+#define DEL_TEST_XX_MAX 1000ul
+
+/********************** internal data declaration ****************************/
+task_test_dta_t task_test_dta =
+{DEL_TEST_XX_MIN};
+
+/********************** internal functions declaration ***********************/
+void task_test_statechart(void);
+
+/********************** internal data definition *****************************/
+const char *p_task_test = "Task Test (Test Code Integration)";
+const char *p_task_test_ = "Non-Blocking & Update By Time Code";
+
+/********************** external data declaration ****************************/
+uint32_t g_task_test_cnt;
+volatile uint32_t g_task_test_tick_cnt;
+
+/********************** external functions definition ************************/
+void task_test_init(void *parameters)
+{
+ task_test_dta_t *p_task_test_dta;
+ uint32_t tick;
+
+ /* Print out: Task Initialized */
+ LOGGER_INFO(" ");
+ LOGGER_INFO(" %s is running - %s", GET_NAME(task_test_init), p_task_test);
+ LOGGER_INFO(" %s is a %s", GET_NAME(task_test), p_task_test_);
+
+ /* Init & Print out: Task execution counter */
+ g_task_test_cnt = G_TASK_TEST_CNT_INIT;
+ LOGGER_INFO(" %s = %lu", GET_NAME(g_task_test_cnt), g_task_test_cnt);
+
+ /* Update Task Test Configuration & Data Pointer */
+ p_task_test_dta = &task_test_dta;
+
+ tick = DEL_TEST_XX_MAX;
+ p_task_test_dta->tick = tick;
+ LOGGER_INFO(" %s = %lu", GET_NAME(tick), (uint32_t)tick);
+
+ /* Init & Print out: LCD Display */
+ display_init();
+ display_cursor_off();
+
+ display_char_position_write(0, 0);
+ display_string_write("Hello, World!");
+}
+
+void task_test_update(void *parameters)
+{
+ bool b_time_update_required = false;
+
+ /* Protect shared resource */
+ __asm("CPSID i"); /* disable interrupts */
+ if (G_TASK_TEST_TICK_CNT_INI < g_task_test_tick_cnt)
+ {
+ /* Update Tick Counter */
+ g_task_test_tick_cnt--;
+ b_time_update_required = true;
+ }
+ __asm("CPSIE i"); /* enable interrupts */
+
+ while (b_time_update_required)
+ {
+ /* Update Task Counter */
+ g_task_test_cnt++;
+
+ /* Run Task Statechart */
+ task_test_statechart();
+
+ /* Protect shared resource */
+ __asm("CPSID i"); /* disable interrupts */
+ if (G_TASK_TEST_TICK_CNT_INI < g_task_test_tick_cnt)
+ {
+ /* Update Tick Counter */
+ g_task_test_tick_cnt--;
+ b_time_update_required = true;
+ }
+ else
+ {
+ b_time_update_required = false;
+ }
+ __asm("CPSIE i"); /* enable interrupts */
+ }
+}
+
+void task_test_statechart(void)
+{
+ task_test_dta_t *p_task_test_dta;
+
+ /* Update Task Test Configuration & Data Pointer */
+ p_task_test_dta = &task_test_dta;
+
+ if (DEL_TEST_XX_MIN < p_task_test_dta->tick)
+ {
+ p_task_test_dta->tick--;
+ }
+ else
+ {
+ }
+}