summaryrefslogtreecommitdiff
path: root/Project/src
diff options
context:
space:
mode:
authorOxore <oxore@protonmail.com>2023-03-03 00:02:25 +0300
committerOxore <oxore@protonmail.com>2023-03-03 00:24:54 +0300
commit2a260911f5abc4e03cb41474a49e01a571395155 (patch)
treea2342b619430d52c06cc90f37ad19b1eba3b7a10 /Project/src
parentd16620e6ba7467e9ef99bf61336ccd8fb4dfd813 (diff)
Remove precious comments, change encoding to utf-8
Diffstat (limited to 'Project/src')
-rw-r--r--Project/src/main.c100
-rw-r--r--Project/src/platform/stm32f0-gcc/freertos/FreeRTOSConfig.h92
-rw-r--r--Project/src/stm32f0xx_it.c58
3 files changed, 120 insertions, 130 deletions
diff --git a/Project/src/main.c b/Project/src/main.c
index d831fbf..41e5f86 100644
--- a/Project/src/main.c
+++ b/Project/src/main.c
@@ -1,6 +1,6 @@
/**
******************************************************************************
- * @file STM32L152_Ex01_3TKeys_EVAL\src\main.c
+ * @file STM32L152_Ex01_3TKeys_EVAL\src\main.c
* @author MCD Application Team
* @version V1.1.0
* @date 24-February-2014
@@ -16,34 +16,32 @@
*
* http://www.st.com/software_license_agreement_liberty_v2
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************
- */
+ */
/*
- .
- . ,
- STM32CubeMX.
+ Здесь необходимо создать большой комментарий о характеристиках железа МК. Или
+же лучше создать отдельный файл и сделать на него ссылку. Кстати, такой файл
+создает программа STM32CubeMX.
- , ,
- ( , , , )
+И вообще, нужно создать глобальную папку проекта, где будет лежать все по
+полочкам ( схема, программа, текстовые файлы, документация и тд )
*/
-//#define LED_DRIVER
-
-// NixieClock_v2,
+// Это программа для версии NixieClock_v2, которая является модифицированной версией предыдущей
// NixieLUT
/* Includes ------------------------------------------------------------------*/
#include "time.h"
#include "main.h"
-// FreeRTOS includes
+// FreeRTOS includes
#include "FreeRTOS.h"
#include "task.h"
#include "queue.h"
@@ -69,26 +67,26 @@
/* Private defines -----------------------------------------------------------*/
/* Private macros ------------------------------------------------------------*/
-//
-// - ?
+// Задаем размеры кучи для каждой задачи отдельно
+// - как правильно определить необходимый минимум для кучи задачи?
-#define STACK_SIZE_HEAD ( (unsigned short) 230 )
-#define STACK_SIZE_NIXIE_DRIVER ( (unsigned short) 80 )
-#define STACK_SIZE_BUTTON ( (unsigned short) 200 )
+#define STACK_SIZE_HEAD ( (unsigned short) 230 )
+#define STACK_SIZE_NIXIE_DRIVER ( (unsigned short) 80 )
+#define STACK_SIZE_BUTTON ( (unsigned short) 200 )
#define STACK_SIZE_LIGHT_SENSOR ( (unsigned short) 70 )
#ifdef LED_DRIVER
-#define STACK_SIZE_LED_DRIVER ( (unsigned short) 70 )
+#define STACK_SIZE_LED_DRIVER ( (unsigned short) 70 )
#endif
-#define STACK_SIZE_INDICATE_MODES ( (unsigned short) 250 )
+#define STACK_SIZE_INDICATE_MODES ( (unsigned short) 250 )
/* Private functions prototype ---------------------------------------------- */
// ----------------------------------------------------------------------------
-//
+// Инициализация до создания задач
// ----------------------------------------------------------------------------
void InitAll ( void )
-{
+{
InitLTimers ();
NixieDriverInit ();
LightSensorInit();
@@ -102,47 +100,44 @@ void InitAll ( void )
ButtonInit ();
}
+BaseType_t TaskSuccess = NULL;
-BaseType_t TaskSuccess = NULL;
-
-// ------------------------------------------------------------- //
+// Главный цикл ------------------------------------------------------------- //
int main ()
-{
+{
InitAll ();
-
- // FreeRTOS ----------------------------------------------- //
-
- // !!!
- // ! ( )
-
- // ,
- // , .
- //
-
- //BaseType_t TaskSuccess = NULL;
-
- TaskSuccess = xTaskCreate ( Head_Task, "Head_Task", STACK_SIZE_HEAD, NULL, tskIDLE_PRIORITY + 2, NULL );
+
+ // Создаем задачи FreeRTOS ----------------------------------------------- //
+
+ // ВНИМАНИЕ !!!
+ // Необходимо проверять кучу при создании задачи! ( и очереди )
+
+ // Если в программе используется подключаемая библиотека, которая использует
+ // ОСРВ, то задача должна там и создаватья. То есть это нужно оформить в
+ // в виде специальной функции
+
+ TaskSuccess = xTaskCreate ( Head_Task, "Head_Task", STACK_SIZE_HEAD, NULL, tskIDLE_PRIORITY + 2, NULL );
configASSERT( TaskSuccess );
-
- TaskSuccess = xTaskCreate ( IndicateModes_Task, "IndicateModes_Task", STACK_SIZE_INDICATE_MODES, NULL, tskIDLE_PRIORITY + 2, NULL );
+
+ TaskSuccess = xTaskCreate ( IndicateModes_Task, "IndicateModes_Task", STACK_SIZE_INDICATE_MODES, NULL, tskIDLE_PRIORITY + 2, NULL );
configASSERT( TaskSuccess );
- TaskSuccess = xTaskCreate ( Button_Task, "Button_Task", STACK_SIZE_BUTTON, NULL, tskIDLE_PRIORITY + 2, NULL );
+ TaskSuccess = xTaskCreate ( Button_Task, "Button_Task", STACK_SIZE_BUTTON, NULL, tskIDLE_PRIORITY + 2, NULL );
configASSERT( TaskSuccess );
- TaskSuccess = xTaskCreate ( LightSensor_Task, "LightSensor_Task", STACK_SIZE_LIGHT_SENSOR, NULL, tskIDLE_PRIORITY + 2, NULL );
+ TaskSuccess = xTaskCreate ( LightSensor_Task, "LightSensor_Task", STACK_SIZE_LIGHT_SENSOR, NULL, tskIDLE_PRIORITY + 2, NULL );
configASSERT( TaskSuccess );
-
- TaskSuccess = xTaskCreate ( NixieDriver_Task, "NixieDriver_Task", STACK_SIZE_NIXIE_DRIVER, NULL, tskIDLE_PRIORITY + 2, NULL );
+
+ TaskSuccess = xTaskCreate ( NixieDriver_Task, "NixieDriver_Task", STACK_SIZE_NIXIE_DRIVER, NULL, tskIDLE_PRIORITY + 2, NULL );
configASSERT( TaskSuccess );
-
+
#ifdef LED_DRIVER
- TaskSuccess = xTaskCreate ( LED_Driver_Task, "LED_Driver_Task", STACK_SIZE_LED_DRIVER, NULL, tskIDLE_PRIORITY + 2, NULL );
+ TaskSuccess = xTaskCreate ( LED_Driver_Task, "LED_Driver_Task", STACK_SIZE_LED_DRIVER, NULL, tskIDLE_PRIORITY + 2, NULL );
configASSERT( TaskSuccess );
#endif
- vTaskStartScheduler (); // ( )
-
+ vTaskStartScheduler (); // И запускаем диспетчер задач ( он же планировщик )
+
} // end of main
@@ -156,7 +151,7 @@ int main ()
* @retval None
*/
void assert_failed ( uint8_t* file, uint32_t line )
-{
+{
/* 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) */
@@ -168,12 +163,9 @@ void assert_failed ( uint8_t* file, uint32_t line )
#endif
-// - FreeRTOS ------------------------------------------------ //
+// Специальные ф-ии FreeRTOS ------------------------------------------------ //
void vApplicationMallocFailedHook ( void ) { for( ;; ); }
void vApplicationStackOverflowHook ( TaskHandle_t pxTask, char *pcTaskName ) { for( ;; ); }
void vApplicationIdleHook ( void ) { }
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
-
-
-
diff --git a/Project/src/platform/stm32f0-gcc/freertos/FreeRTOSConfig.h b/Project/src/platform/stm32f0-gcc/freertos/FreeRTOSConfig.h
index 0f23839..031cb01 100644
--- a/Project/src/platform/stm32f0-gcc/freertos/FreeRTOSConfig.h
+++ b/Project/src/platform/stm32f0-gcc/freertos/FreeRTOSConfig.h
@@ -1,5 +1,5 @@
/*
- FreeRTOS V8.0.0 - Copyright (C) 2014 Real Time Engineers Ltd.
+ FreeRTOS V8.0.0 - Copyright (C) 2014 Real Time Engineers Ltd.
All rights reserved
VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
@@ -65,8 +65,8 @@
/* The following #error directive is to remind users that a batch file must be
- * executed prior to this project being built. The batch file *cannot* be
- * executed from within CCS4! Once it has been executed, re-open or refresh
+ * executed prior to this project being built. The batch file *cannot* be
+ * executed from within CCS4! Once it has been executed, re-open or refresh
* the CCS4 project and remove the #error line below.
*/
//#error Ensure CreateProjectDirectoryStructure.bat has been executed before building. See comment immediately above.
@@ -87,68 +87,68 @@
* See http://www.freertos.org/a00110.html.
*----------------------------------------------------------*/
-#define configUSE_PREEMPTION 1 // 1 - , 0 -
-#define configUSE_IDLE_HOOK 1
-#define configUSE_TICK_HOOK 0
-#define configCPU_CLOCK_HZ ( 48000000UL ) // tros 24000000UL
-#define configTICK_RATE_HZ ( ( TickType_t ) 1000 )
-#define configMAX_PRIORITIES ( 5 )
-
-#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 70 ) // trots, was 70
-#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 10 * 1024 ) ) // trots, was 10 // MEM_SIZE lwipopts.h
-
-#define configMAX_TASK_NAME_LEN ( 10 )
-#define configUSE_TRACE_FACILITY 0
-#define configUSE_16_BIT_TICKS 0
-#define configIDLE_SHOULD_YIELD 1
-#define configUSE_MUTEXES 1
-#define configQUEUE_REGISTRY_SIZE 0
-#define configGENERATE_RUN_TIME_STATS 0
-#define configCHECK_FOR_STACK_OVERFLOW 2 // trots was 2
-#define configUSE_RECURSIVE_MUTEXES 0
-#define configUSE_MALLOC_FAILED_HOOK 1
-#define configUSE_APPLICATION_TASK_TAG 0
-#define configUSE_COUNTING_SEMAPHORES 0
+#define configUSE_PREEMPTION 1 // 1 - Вытесняющаяя многозадачность, 0 - Кооперативная
+#define configUSE_IDLE_HOOK 1
+#define configUSE_TICK_HOOK 0
+#define configCPU_CLOCK_HZ ( 48000000UL ) // tros было 24000000UL
+#define configTICK_RATE_HZ ( ( TickType_t ) 1000 )
+#define configMAX_PRIORITIES ( 5 )
+
+#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 70 ) // trots, was 70
+#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 10 * 1024 ) ) // trots, was 10 // Уменьшил MEM_SIZE в файле lwipopts.h
+
+#define configMAX_TASK_NAME_LEN ( 10 )
+#define configUSE_TRACE_FACILITY 0
+#define configUSE_16_BIT_TICKS 0
+#define configIDLE_SHOULD_YIELD 1
+#define configUSE_MUTEXES 1
+#define configQUEUE_REGISTRY_SIZE 0
+#define configGENERATE_RUN_TIME_STATS 0
+#define configCHECK_FOR_STACK_OVERFLOW 2 // trots was 2
+#define configUSE_RECURSIVE_MUTEXES 0
+#define configUSE_MALLOC_FAILED_HOOK 1
+#define configUSE_APPLICATION_TASK_TAG 0
+#define configUSE_COUNTING_SEMAPHORES 0
/* Co-routine definitions. */
-#define configUSE_CO_ROUTINES 0 // , ( )
+#define configUSE_CO_ROUTINES 0 // Чтобы использовать программные таймеры, нужно единичку (там прототипы содержатся)
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
/* Software timer definitions. */
-#define configUSE_TIMERS 1
-#define configTIMER_TASK_PRIORITY ( 3 )
-#define configTIMER_QUEUE_LENGTH 5
-#define configTIMER_TASK_STACK_DEPTH ( configMINIMAL_STACK_SIZE )
+#define configUSE_TIMERS 1
+#define configTIMER_TASK_PRIORITY ( 3 )
+#define configTIMER_QUEUE_LENGTH 5
+#define configTIMER_TASK_STACK_DEPTH ( configMINIMAL_STACK_SIZE )
/* Set the following definitions to 1 to include the API function, or zero
to exclude the API function. */
-#define INCLUDE_vTaskPrioritySet 1
-#define INCLUDE_uxTaskPriorityGet 1
-#define INCLUDE_vTaskDelete 1
-#define INCLUDE_vTaskCleanUpResources 1
-#define INCLUDE_vTaskSuspend 1
-#define INCLUDE_vTaskDelayUntil 1
-#define INCLUDE_vTaskDelay 1
+#define INCLUDE_vTaskPrioritySet 1
+#define INCLUDE_uxTaskPriorityGet 1
+#define INCLUDE_vTaskDelete 1
+#define INCLUDE_vTaskCleanUpResources 1
+#define INCLUDE_vTaskSuspend 1
+#define INCLUDE_vTaskDelayUntil 1
+#define INCLUDE_vTaskDelay 1
/* Use the system definition, if there is one */
#ifdef __NVIC_PRIO_BITS
- #define configPRIO_BITS __NVIC_PRIO_BITS
+ #define configPRIO_BITS __NVIC_PRIO_BITS
#else
- #define configPRIO_BITS 4 /* 15 priority levels */
+ #define configPRIO_BITS 4 /* 15 priority levels */
#endif
-#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY 15
-#define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 11
+#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY 15
+#define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 11
/* The lowest priority. */
-#define configKERNEL_INTERRUPT_PRIORITY ( configLIBRARY_LOWEST_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
+#define configKERNEL_INTERRUPT_PRIORITY ( configLIBRARY_LOWEST_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
/* Priority 5, or 95 as only the top four bits are implemented. */
/* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!!
See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */
-#define configMAX_SYSCALL_INTERRUPT_PRIORITY ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
-
-#define configASSERT( x ) if( ( x ) == 0 ) { taskDISABLE_INTERRUPTS(); for( ;; ); }
-
+#define configMAX_SYSCALL_INTERRUPT_PRIORITY ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
+
+#define configASSERT( x ) if( ( x ) == 0 ) { taskDISABLE_INTERRUPTS(); for( ;; ); }
+
#define vPortSVCHandler SVCALL_handler
#define xPortPendSVHandler PENDSV_handler
#define xPortSysTickHandler SYSTICK_handler
diff --git a/Project/src/stm32f0xx_it.c b/Project/src/stm32f0xx_it.c
index b628455..9327bed 100644
--- a/Project/src/stm32f0xx_it.c
+++ b/Project/src/stm32f0xx_it.c
@@ -1,11 +1,11 @@
/**
******************************************************************************
- * @file Projects\Demonstration\stm32f0xx_it.c
+ * @file Projects\Demonstration\stm32f0xx_it.c
* @author MCD Application Team
* @version V1.0.0
* @date 17-January-2014
* @brief Main Interrupt Service Routines.
- * This file provides template for all exceptions handler and
+ * This file provides template for all exceptions handler and
* peripherals interrupt service routine.
******************************************************************************
* @attention
@@ -18,14 +18,14 @@
*
* http://www.st.com/software_license_agreement_liberty_v2
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************
- */
+ */
/* Includes ------------------------------------------------------------------*/
#include "stm32f0xx_it.h"
@@ -86,7 +86,7 @@ void HardFault_Handler(void)
* @brief This function handles SVCall exception.
* @param None
* @retval None
- * @ portasm.s
+ * @ Используется в файле portasm.s
*/
//void SVC_Handler(void)
//{
@@ -96,7 +96,7 @@ void HardFault_Handler(void)
* @brief This function handles PendSVC exception.
* @param None
* @retval None
- * @ portasm.s
+ * @ Используется в файле portasm.s
*/
//void PendSV_Handler(void)
//{
@@ -121,16 +121,15 @@ void HardFault_Handler(void)
/******************************************************************************/
// ----------------------------------------------------------------------------
-// 1
+// Обработчик прерывания таймера общего назначения для тиков в 1 мс
// ----------------------------------------------------------------------------
void LTIMER_IRQHandler ( void )
{
if ( TIM_GetITStatus ( LTIMER_TIMx, TIM_IT_Update ) != RESET )
- {
+ {
TIM_ClearITPendingBit ( LTIMER_TIMx, TIM_IT_Update );
-
+
ProcessLTimers ();
- //NIX_TEST_PIN_PB11_TOGGLE;
}
}
@@ -138,16 +137,16 @@ void TIM17_handler(void) { LTIMER_IRQHandler(); }
// ----------------------------------------------------------------------------
-// NixieDriver
-// ,
-// Nixie
+// Обработчик прерывания таймера для работы NixieDriver
+// Это прерывание имеет самый высокий приоритет, чтобы обеспечить стабильную
+// частоту динамической индикации ламп Nixie
// ----------------------------------------------------------------------------
void NIX_DRIVER_TIM_IRQHandler ( void )
{
if ( TIM_GetITStatus ( NIX_DRIVER_TIMx, TIM_IT_Update ) != RESET )
- {
+ {
TIM_ClearITPendingBit ( NIX_DRIVER_TIMx, TIM_IT_Update );
-
+
ProcessNixieDriverFromISR ();
}
}
@@ -156,14 +155,14 @@ void TIM16_handler(void) { NIX_DRIVER_TIM_IRQHandler(); }
// ----------------------------------------------------------------------------
-// LED_Driver
+// Обработчик прерывания таймера для работы LED_Driver
// ----------------------------------------------------------------------------
void LED_TIM_IRQHandler ( void )
{
if ( TIM_GetITStatus ( LED_TIMx, TIM_IT_Update ) != RESET )
- {
+ {
TIM_ClearITPendingBit ( LED_TIMx, TIM_IT_Update );
-
+
LEDDriverProcessFromISR ();
}
}
@@ -172,21 +171,20 @@ void TIM3_handler(void) { LED_TIM_IRQHandler(); }
// ----------------------------------------------------------------------------
-// - , 2
-// ( ?
-// ?)
+// - поставить этому прерыванию наивысший приоритет, чтобы передавать 2 байта
+// подряд гарантированно без промежутка времени (или не так важно? может ли
+// между двумя байтами задержка повлиять на вывод данных на лампы?)
// ----------------------------------------------------------------------------
-//static uint16_t empty_data;
void NIX_SPIx_IRQHandler ( void )
-{
+{
/* SPI in Master Receiver mode--------------------------------------- */
if ( SPI_I2S_GetITStatus ( NIX_SPIx, SPI_I2S_IT_TXE ) == SET )
{
- // ,
+ // Обязательно надо считать, чтобы сбросить флаг
SPI_I2S_ReceiveData16 ( NIX_SPIx );
SPI_I2S_ITConfig ( NIX_SPIx, SPI_I2S_IT_TXE, DISABLE );
- //NixieDriverCheckDPPins();
+ //NixieDriverCheckDPPins();
NIX_DRIVER_SET_ST_PIN;
}
}
@@ -199,13 +197,13 @@ void SPI1_handler(void) { NIX_SPIx_IRQHandler(); }
// ----------------------------------------------------------------------------
#ifdef LED_DRIVER
void LED_SPIx_IRQHandler ( void )
-{
+{
/* SPI in Master Receiver mode--------------------------------------- */
if ( SPI_I2S_GetITStatus ( LED_SPIx, SPI_I2S_IT_RXNE ) == SET )
{
- //empty_data = SPI_I2S_ReceiveData16 ( LED_SPIx );
- // ,
- SPI_I2S_ReceiveData16 ( LED_SPIx );
+ //empty_data = SPI_I2S_ReceiveData16 ( LED_SPIx );
+ // Обязательно надо считать, чтобы сбросить флаг
+ SPI_I2S_ReceiveData16 ( LED_SPIx );
LED_ST_PIN_SET;
}
}