From dfcf63dded68e7bf1eea2112feb6e993d75c9907 Mon Sep 17 00:00:00 2001 From: Oxore Date: Mon, 6 Mar 2023 11:30:08 +0300 Subject: Reduce include path pollution --- CMakeLists.txt | 11 +-- app/button/button_handler.c | 3 +- app/button/button_task.c | 5 +- app/head_task/head_task.c | 8 +- app/indicate/indicate_modes_task.c | 3 +- app/indicate/indicate_modes_task.h | 2 +- app/light_sensor/light_sensor_task.c | 2 +- app/main.c | 16 ++-- app/nixie_driver/nixie_driver_process.c | 3 +- app/stm32f0xx_it.c | 12 +-- app/time/time.c | 160 ++++++++++++++++++++++++++++++++ app/time/time.h | 6 ++ third_party/Time/time.c | 160 -------------------------------- third_party/Time/time.h | 6 -- 14 files changed, 193 insertions(+), 204 deletions(-) create mode 100644 app/time/time.c create mode 100644 app/time/time.h delete mode 100644 third_party/Time/time.c delete mode 100644 third_party/Time/time.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 113b3a1..19748b0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -57,7 +57,7 @@ set(nixie_clock_sources "third_party/STM32F0xx_StdPeriph_Driver/src/stm32f0xx_adc.c" #"third_party/STM32F0xx_StdPeriph_Driver/src/stm32f0xx_i2c.c" "third_party/STM32F0xx_StdPeriph_Driver/src/stm32f0xx_usart.c" - "third_party/Time/time.c" + "app/time/time.c" "app/indicate/indicate_modes_task.c" "app/button/button_handler.c" "app/button/button_task.c" @@ -95,15 +95,8 @@ target_include_directories(${PROJECT_NAME} PRIVATE "third_party/FreeRTOS/include" "third_party/TouchSense" "third_party/STM32F0xx_StdPeriph_Driver/inc" - "third_party/Time" + "app/time" "app" - "app/nixie_driver" - "app/ltimers" - "app/head_task" - "app/indicate" - "app/light_sensor" - "app/button" - "app/led_driver" "app/platform/stm32f0-gcc/freertos" ) diff --git a/app/button/button_handler.c b/app/button/button_handler.c index 7c3ea91..e989d2b 100644 --- a/app/button/button_handler.c +++ b/app/button/button_handler.c @@ -1,7 +1,6 @@ #include "button_handler.h" -#include "ltimers.h" +#include "ltimers/ltimers.h" -#include "nixie_driver_process.h" // FreeRTOS includes #include "FreeRTOS.h" diff --git a/app/button/button_task.c b/app/button/button_task.c index 7a2b9fc..589f43b 100644 --- a/app/button/button_task.c +++ b/app/button/button_task.c @@ -1,9 +1,8 @@ -#include "head_task.h" #include "tsl_user.h" -#include "nixie_driver_process.h" +#include "nixie_driver/nixie_driver_process.h" #include "button_handler.h" -#include "ltimers.h" +#include "ltimers/ltimers.h" #include "FreeRTOS.h" #include "task.h" diff --git a/app/head_task/head_task.c b/app/head_task/head_task.c index a01166a..bc9eb6e 100644 --- a/app/head_task/head_task.c +++ b/app/head_task/head_task.c @@ -6,11 +6,11 @@ #include "queue.h" #include "semphr.h" -#include "ltimers.h" +#include "ltimers/ltimers.h" -#include "indicate_modes_task.h" -#include "nixie_driver_process.h" -#include "button_handler.h" +#include "indicate/indicate_modes_task.h" +#include "nixie_driver/nixie_driver_process.h" +#include "button/button_handler.h" #include "stm32f0xx_rtc.h" diff --git a/app/indicate/indicate_modes_task.c b/app/indicate/indicate_modes_task.c index 10a8c26..aba6107 100644 --- a/app/indicate/indicate_modes_task.c +++ b/app/indicate/indicate_modes_task.c @@ -1,6 +1,5 @@ #include "indicate_modes_task.h" -#include "nixie_driver_process.h" -#include "ltimers.h" +#include "ltimers/ltimers.h" // FreeRTOS includes #include "FreeRTOS.h" diff --git a/app/indicate/indicate_modes_task.h b/app/indicate/indicate_modes_task.h index e37406f..31ecba1 100644 --- a/app/indicate/indicate_modes_task.h +++ b/app/indicate/indicate_modes_task.h @@ -2,7 +2,7 @@ #define INDICATE_MODES_TASK_INCLUDED #include -#include "nixie_driver_process.h" +#include "nixie_driver/nixie_driver_process.h" // Номера режимов индикации typedef enum { diff --git a/app/light_sensor/light_sensor_task.c b/app/light_sensor/light_sensor_task.c index 642d9e9..140a93a 100644 --- a/app/light_sensor/light_sensor_task.c +++ b/app/light_sensor/light_sensor_task.c @@ -1,5 +1,5 @@ #include "light_sensor_task.h" -#include "ltimers.h" +#include "ltimers/ltimers.h" // FreeRTOS includes #include "FreeRTOS.h" diff --git a/app/main.c b/app/main.c index 4c0881f..e857a38 100644 --- a/app/main.c +++ b/app/main.c @@ -46,18 +46,18 @@ #include "queue.h" #include "semphr.h" -#include "ltimers.h" -#include "head_task.h" -#include "button_task.h" -#include "button_handler.h" -#include "nixie_driver_task.h" -#include "light_sensor_task.h" +#include "ltimers/ltimers.h" +#include "head_task/head_task.h" +#include "button/button_task.h" +#include "button/button_handler.h" +#include "nixie_driver/nixie_driver_task.h" +#include "light_sensor/light_sensor_task.h" #ifdef LED_DRIVER -#include "led_driver_task.h" +#include "led_driver/led_driver_task.h" #endif -#include "indicate_modes_task.h" +#include "indicate/indicate_modes_task.h" #include "tsl_user.h" #include "time.h" #include "stm32f0xx_usart.h" diff --git a/app/nixie_driver/nixie_driver_process.c b/app/nixie_driver/nixie_driver_process.c index d2c96f4..ed70c85 100644 --- a/app/nixie_driver/nixie_driver_process.c +++ b/app/nixie_driver/nixie_driver_process.c @@ -1,7 +1,6 @@ #include "nixie_driver_process.h" #include "nixie_driver_config.h" -#include "indicate_modes_task.h" -#include "light_sensor_task.h" +#include "light_sensor/light_sensor_task.h" #include diff --git a/app/stm32f0xx_it.c b/app/stm32f0xx_it.c index 9327bed..46cb8dd 100644 --- a/app/stm32f0xx_it.c +++ b/app/stm32f0xx_it.c @@ -31,13 +31,13 @@ #include "stm32f0xx_it.h" #include "stm32f0xx_conf.h" -#include "ltimers.h" -#include "ltimers_config.h" +#include "ltimers/ltimers.h" +#include "ltimers/ltimers_config.h" -#include "nixie_driver_config.h" -#include "nixie_driver_process.h" -#include "led_driver_process.h" -#include "led_driver_config.h" +#include "nixie_driver/nixie_driver_config.h" +#include "nixie_driver/nixie_driver_process.h" +#include "led_driver/led_driver_process.h" +#include "led_driver/led_driver_config.h" #include "tsl_types.h" #include "tsl_user.h" diff --git a/app/time/time.c b/app/time/time.c new file mode 100644 index 0000000..4159f44 --- /dev/null +++ b/app/time/time.c @@ -0,0 +1,160 @@ + +#include "time.h" +#include "stm32f0xx_conf.h" + +/* Uncomment the corresponding line to select the RTC Clock source */ +#define RTC_CLOCK_SOURCE_LSE /* LSE used as RTC source clock */ +//#define RTC_CLOCK_SOURCE_LSI // LSI used as RTC source clock. The RTC Clock + // may varies due to LSI frequency dispersion + +#define BKP_VALUE 0x32F0 +/* Private macro -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +__IO uint32_t AsynchPrediv = 0, SynchPrediv = 0; + +/* Private function prototypes -----------------------------------------------*/ +static void RTC_Config(void); +static void RTC_TimeRegulate(void); + + +// - RTC ? + + +// ---------------------------------------------------------------------------- +// +// ---------------------------------------------------------------------------- +void TimeInit (void) +{ + RTC_InitTypeDef RTC_InitStructure; + + if (RTC_ReadBackupRegister(RTC_BKP_DR0) != BKP_VALUE) + //if (SynchPrediv == 0) + { + /* RTC configuration */ + RTC_Config(); + + /* Configure the RTC data register and RTC prescaler */ + RTC_InitStructure.RTC_AsynchPrediv = AsynchPrediv; + RTC_InitStructure.RTC_SynchPrediv = SynchPrediv; + RTC_InitStructure.RTC_HourFormat = RTC_HourFormat_24; + + /* Check on RTC init */ + if (RTC_Init(&RTC_InitStructure) == ERROR) + { + // printf("\n\r /!\\***** RTC Prescaler Config failed ********/!\\ \n\r"); + } + + /* Configure the time register */ + RTC_TimeRegulate(); + } + else + { + /* Check if the Power On Reset flag is set */ + if (RCC_GetFlagStatus(RCC_FLAG_PORRST) != RESET) + { + //printf("\r\n Power On Reset occurred....\n\r"); + } + /* Check if the Pin Reset flag is set */ + else if (RCC_GetFlagStatus(RCC_FLAG_PINRST) != RESET) + { + // printf("\r\n External Reset occurred....\n\r"); + } + + //printf("\n\r No need to configure RTC....\n\r"); + + /* Enable the PWR clock */ + RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE); + + /* Allow access to RTC */ + PWR_BackupAccessCmd(ENABLE); + + #ifdef RTC_CLOCK_SOURCE_LSI + /* Enable the LSI OSC */ + RCC_LSICmd(ENABLE); + #endif /* RTC_CLOCK_SOURCE_LSI */ + + /* Wait for RTC APB registers synchronisation */ + RTC_WaitForSynchro(); + + /* Clear the RTC Alarm Flag */ + RTC_ClearFlag(RTC_FLAG_ALRAF); + + /* Clear the EXTI Line 17 Pending bit (Connected internally to RTC Alarm) */ + //EXTI_ClearITPendingBit(EXTI_Line17); + + /* Display the RTC Time and Alarm */ + //RTC_TimeShow(); + //RTC_AlarmShow(); + } +} + + +// ---------------------------------------------------------------------------- +// +// ---------------------------------------------------------------------------- +static void RTC_Config(void) +{ + /* Enable the PWR clock */ + RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE); + + /* Allow access to RTC */ + PWR_BackupAccessCmd(ENABLE); + +#if defined (RTC_CLOCK_SOURCE_LSI) /* LSI used as RTC source clock*/ +/* The RTC Clock may varies due to LSI frequency dispersion. */ + /* Enable the LSI OSC */ + RCC_LSICmd(ENABLE); + + /* Wait till LSI is ready */ + while(RCC_GetFlagStatus(RCC_FLAG_LSIRDY) == RESET) + { + } + + /* Select the RTC Clock Source */ + RCC_RTCCLKConfig(RCC_RTCCLKSource_LSI); + + SynchPrediv = 0x18F; + AsynchPrediv = 0x63; + +#elif defined (RTC_CLOCK_SOURCE_LSE) /* LSE used as RTC source clock */ + /* Enable the LSE OSC */ + RCC_LSEConfig(RCC_LSE_ON); + + /* Wait till LSE is ready */ + while(RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET) + { + } + + /* Select the RTC Clock Source */ + RCC_RTCCLKConfig(RCC_RTCCLKSource_LSE); + + SynchPrediv = 0xFF; + AsynchPrediv = 0x7F; + +#else + #error Please select the RTC Clock source inside the main.c file +#endif /* RTC_CLOCK_SOURCE_LSI */ + + /* Enable the RTC Clock */ + RCC_RTCCLKCmd(ENABLE); + + /* Wait for RTC APB registers synchronisation */ + RTC_WaitForSynchro(); +} + + +// ---------------------------------------------------------------------------- +// +// ---------------------------------------------------------------------------- +static void RTC_TimeRegulate ( void ) +{ + RTC_TimeTypeDef RTC_TimeStructure; + + RTC_TimeStructure.RTC_Hours = 14; + RTC_TimeStructure.RTC_Minutes = 01; + RTC_TimeStructure.RTC_Seconds = 00; + + RTC_SetTime(RTC_Format_BIN, &RTC_TimeStructure); + /* Indicator for the RTC configuration */ + RTC_WriteBackupRegister(RTC_BKP_DR0, BKP_VALUE); +} diff --git a/app/time/time.h b/app/time/time.h new file mode 100644 index 0000000..ea1f265 --- /dev/null +++ b/app/time/time.h @@ -0,0 +1,6 @@ +#ifndef TIME_INCLUDED +#define TIME_INCLUDED + +void TimeInit (void); + +#endif // TIME_INCLUDED diff --git a/third_party/Time/time.c b/third_party/Time/time.c deleted file mode 100644 index 4159f44..0000000 --- a/third_party/Time/time.c +++ /dev/null @@ -1,160 +0,0 @@ - -#include "time.h" -#include "stm32f0xx_conf.h" - -/* Uncomment the corresponding line to select the RTC Clock source */ -#define RTC_CLOCK_SOURCE_LSE /* LSE used as RTC source clock */ -//#define RTC_CLOCK_SOURCE_LSI // LSI used as RTC source clock. The RTC Clock - // may varies due to LSI frequency dispersion - -#define BKP_VALUE 0x32F0 -/* Private macro -------------------------------------------------------------*/ -/* Private variables ---------------------------------------------------------*/ -__IO uint32_t AsynchPrediv = 0, SynchPrediv = 0; - -/* Private function prototypes -----------------------------------------------*/ -static void RTC_Config(void); -static void RTC_TimeRegulate(void); - - -// - RTC ? - - -// ---------------------------------------------------------------------------- -// -// ---------------------------------------------------------------------------- -void TimeInit (void) -{ - RTC_InitTypeDef RTC_InitStructure; - - if (RTC_ReadBackupRegister(RTC_BKP_DR0) != BKP_VALUE) - //if (SynchPrediv == 0) - { - /* RTC configuration */ - RTC_Config(); - - /* Configure the RTC data register and RTC prescaler */ - RTC_InitStructure.RTC_AsynchPrediv = AsynchPrediv; - RTC_InitStructure.RTC_SynchPrediv = SynchPrediv; - RTC_InitStructure.RTC_HourFormat = RTC_HourFormat_24; - - /* Check on RTC init */ - if (RTC_Init(&RTC_InitStructure) == ERROR) - { - // printf("\n\r /!\\***** RTC Prescaler Config failed ********/!\\ \n\r"); - } - - /* Configure the time register */ - RTC_TimeRegulate(); - } - else - { - /* Check if the Power On Reset flag is set */ - if (RCC_GetFlagStatus(RCC_FLAG_PORRST) != RESET) - { - //printf("\r\n Power On Reset occurred....\n\r"); - } - /* Check if the Pin Reset flag is set */ - else if (RCC_GetFlagStatus(RCC_FLAG_PINRST) != RESET) - { - // printf("\r\n External Reset occurred....\n\r"); - } - - //printf("\n\r No need to configure RTC....\n\r"); - - /* Enable the PWR clock */ - RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE); - - /* Allow access to RTC */ - PWR_BackupAccessCmd(ENABLE); - - #ifdef RTC_CLOCK_SOURCE_LSI - /* Enable the LSI OSC */ - RCC_LSICmd(ENABLE); - #endif /* RTC_CLOCK_SOURCE_LSI */ - - /* Wait for RTC APB registers synchronisation */ - RTC_WaitForSynchro(); - - /* Clear the RTC Alarm Flag */ - RTC_ClearFlag(RTC_FLAG_ALRAF); - - /* Clear the EXTI Line 17 Pending bit (Connected internally to RTC Alarm) */ - //EXTI_ClearITPendingBit(EXTI_Line17); - - /* Display the RTC Time and Alarm */ - //RTC_TimeShow(); - //RTC_AlarmShow(); - } -} - - -// ---------------------------------------------------------------------------- -// -// ---------------------------------------------------------------------------- -static void RTC_Config(void) -{ - /* Enable the PWR clock */ - RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE); - - /* Allow access to RTC */ - PWR_BackupAccessCmd(ENABLE); - -#if defined (RTC_CLOCK_SOURCE_LSI) /* LSI used as RTC source clock*/ -/* The RTC Clock may varies due to LSI frequency dispersion. */ - /* Enable the LSI OSC */ - RCC_LSICmd(ENABLE); - - /* Wait till LSI is ready */ - while(RCC_GetFlagStatus(RCC_FLAG_LSIRDY) == RESET) - { - } - - /* Select the RTC Clock Source */ - RCC_RTCCLKConfig(RCC_RTCCLKSource_LSI); - - SynchPrediv = 0x18F; - AsynchPrediv = 0x63; - -#elif defined (RTC_CLOCK_SOURCE_LSE) /* LSE used as RTC source clock */ - /* Enable the LSE OSC */ - RCC_LSEConfig(RCC_LSE_ON); - - /* Wait till LSE is ready */ - while(RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET) - { - } - - /* Select the RTC Clock Source */ - RCC_RTCCLKConfig(RCC_RTCCLKSource_LSE); - - SynchPrediv = 0xFF; - AsynchPrediv = 0x7F; - -#else - #error Please select the RTC Clock source inside the main.c file -#endif /* RTC_CLOCK_SOURCE_LSI */ - - /* Enable the RTC Clock */ - RCC_RTCCLKCmd(ENABLE); - - /* Wait for RTC APB registers synchronisation */ - RTC_WaitForSynchro(); -} - - -// ---------------------------------------------------------------------------- -// -// ---------------------------------------------------------------------------- -static void RTC_TimeRegulate ( void ) -{ - RTC_TimeTypeDef RTC_TimeStructure; - - RTC_TimeStructure.RTC_Hours = 14; - RTC_TimeStructure.RTC_Minutes = 01; - RTC_TimeStructure.RTC_Seconds = 00; - - RTC_SetTime(RTC_Format_BIN, &RTC_TimeStructure); - /* Indicator for the RTC configuration */ - RTC_WriteBackupRegister(RTC_BKP_DR0, BKP_VALUE); -} diff --git a/third_party/Time/time.h b/third_party/Time/time.h deleted file mode 100644 index ea1f265..0000000 --- a/third_party/Time/time.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef TIME_INCLUDED -#define TIME_INCLUDED - -void TimeInit (void); - -#endif // TIME_INCLUDED -- cgit v1.2.3