summaryrefslogtreecommitdiff
path: root/Project/src/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'Project/src/main.c')
-rw-r--r--Project/src/main.c178
1 files changed, 178 insertions, 0 deletions
diff --git a/Project/src/main.c b/Project/src/main.c
new file mode 100644
index 0000000..bf1c5b0
--- /dev/null
+++ b/Project/src/main.c
@@ -0,0 +1,178 @@
+/**
+ ******************************************************************************
+ * @file STM32L152_Ex01_3TKeys_EVAL\src\main.c
+ * @author MCD Application Team
+ * @version V1.1.0
+ * @date 24-February-2014
+ * @brief Basic example of how to use the STMTouch Driver.
+ ******************************************************************************
+ * @attention
+ *
+ * <h2><center>&copy; COPYRIGHT 2014 STMicroelectronics</center></h2>
+ *
+ * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
+ * You may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * 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,
+ * 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.
+
+И вообще, нужно создать глобальную папку проекта, где будет лежать все по
+полочкам ( схема, программа, текстовые файлы, документация и тд )
+*/
+
+//#define LED_DRIVER
+
+// Это программа для версии NixieClock_v2, которая является модифицированной версией предыдущей
+// NixieLUT
+
+/* Includes ------------------------------------------------------------------*/
+#include "main.h"
+
+// FreeRTOS includes
+#include "FreeRTOS.h"
+#include "task.h"
+#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"
+
+#ifdef LED_DRIVER
+#include "led_driver_task.h"
+#endif
+
+#include "indicate_modes_task.h"
+#include "tsl_user.h"
+#include "time.h"
+
+
+/* Private typedefs ----------------------------------------------------------*/
+/* 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_LIGHT_SENSOR ( (unsigned short) 70 )
+#ifdef LED_DRIVER
+#define STACK_SIZE_LED_DRIVER ( (unsigned short) 70 )
+#endif
+#define STACK_SIZE_INDICATE_MODES ( (unsigned short) 250 )
+
+/* Private functions prototype ---------------------------------------------- */
+
+
+// ----------------------------------------------------------------------------
+// Инициализация до создания задач
+// ----------------------------------------------------------------------------
+void InitAll ( void )
+{
+ InitLTimers ();
+ NixieDriverInit ();
+ LightSensorInit();
+#ifdef LED_DRIVER
+ LED_DriverInit ();
+#endif
+ TSL_user_Init ();
+ TimeInit ();
+ HeadTaskInit ();
+ IndicateModesInit ();
+ ButtonInit ();
+}
+
+
+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 );
+ configASSERT( TaskSuccess );
+
+ 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 );
+ configASSERT( TaskSuccess );
+
+ 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 );
+ configASSERT( TaskSuccess );
+
+#ifdef LED_DRIVER
+ TaskSuccess = xTaskCreate ( LED_Driver_Task, "LED_Driver_Task", STACK_SIZE_LED_DRIVER, NULL, tskIDLE_PRIORITY + 2, NULL );
+ configASSERT( TaskSuccess );
+#endif
+
+ vTaskStartScheduler (); // И запускаем диспетчер задач ( он же планировщик )
+
+} // end of main
+
+
+
+#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 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) */
+
+ /* Infinite loop */
+ for (;;)
+ {
+ }
+}
+#endif
+
+
+// Специальные ф-ии FreeRTOS ------------------------------------------------ //
+void vApplicationMallocFailedHook ( void ) { for( ;; ); }
+void vApplicationStackOverflowHook ( TaskHandle_t pxTask, char *pcTaskName ) { for( ;; ); }
+void vApplicationIdleHook ( void ) { }
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
+
+
+