1- /* Copyright 2019-2020 Nuclei, Inc */
21/*
32 FreeRTOS V9.0.0 - Copyright (C) 2016 Real Time Engineers Ltd.
43 All rights reserved
7574#include "task.h" /* RTOS task related API prototypes. */
7675#include "timers.h" /* Software timer related API prototypes. */
7776
78- /* TODO Add any manufacture supplied header files can be included
79- here. */
8077#include <stdio.h>
8178#include <stdlib.h>
8279#include <unistd.h>
8380
8481#include "nuclei_sdk_soc.h"
8582
86- #define mainQUEUE_RECEIVE_TASK_PRIORITY (tskIDLE_PRIORITY + 2)
87- #define mainQUEUE_SEND_TASK_PRIORITY (tskIDLE_PRIORITY + 1)
88- #define mainEVENT_SEMAPHORE_TASK_PRIORITY (configMAX_PRIORITIES - 1)
89-
90- #define NBIT_DEFAULT 3
91- #define REG_LEN 8
92-
9383/* The period of the example software timer, specified in milliseconds, and
9484converted to ticks using the pdMS_TO_TICKS() macro. */
95- #define mainSOFTWARE_TIMER_PERIOD_MS pdMS_TO_TICKS(1000)
85+ #define mainSOFTWARE_TIMER_PERIOD_MS pdMS_TO_TICKS(1000)
86+ #define mainQUEUE_LENGTH (1)
9687
97- #define mainQUEUE_LENGTH (1)
9888static void prvSetupHardware (void );
9989extern void idle_task (void );
10090static void vExampleTimerCallback (TimerHandle_t xTimer );
10191
10292/* The queue used by the queue send and queue receive tasks. */
10393static QueueHandle_t xQueue = NULL ;
10494
105- void prvSetupHardware (void )
106- {
107- }
95+ static TaskHandle_t StartTask1_Handler ;
96+ static TaskHandle_t StartTask2_Handler ;
10897
109- TaskHandle_t StartTask_Handler ;
110- TaskHandle_t StartTask2_Handler ;
98+ void prvSetupHardware (void ) {}
11199
112- void start_task (void * pvParameters );
100+ void start_task1 (void * pvParameters );
113101void start_task2 (void * pvParameters );
114102
115103int main (void )
@@ -126,11 +114,12 @@ int main(void)
126114 sizeof (uint32_t ));
127115
128116 if (xQueue == NULL ) {
129- for (;;) ;
117+ for (;;)
118+ ;
130119 }
131- xTaskCreate ((TaskFunction_t )start_task , (const char * )"start_task " ,
120+ xTaskCreate ((TaskFunction_t )start_task1 , (const char * )"start_task1 " ,
132121 (uint16_t )256 , (void * )NULL , (UBaseType_t )2 ,
133- (TaskHandle_t * )& StartTask_Handler );
122+ (TaskHandle_t * )& StartTask1_Handler );
134123
135124 xTaskCreate ((TaskFunction_t )start_task2 , (const char * )"start_task2" ,
136125 (uint16_t )256 , (void * )NULL , (UBaseType_t )1 ,
@@ -153,27 +142,22 @@ int main(void)
153142 };
154143}
155144
156- void start_task (void * pvParameters )
145+ void start_task1 (void * pvParameters )
157146{
158- TickType_t xNextWakeTime ;
159- int x ;
160- printf ("task_1\r\n" );
147+ int cnt = 0 ;
148+ printf ("Enter to task_1\r\n" );
161149 while (1 ) {
162- printf ("task1_running..... \r\n" );
163-
150+ printf ("task1 is running %d.....\r\n" , cnt ++ );
164151 vTaskDelay (200 );
165152 }
166153}
167154
168155void start_task2 (void * pvParameters )
169156{
170- uint32_t ulReceivedValue ;
171- printf ("task_2\r\n" );
172- /* Initialise xNextWakeTime - this only needs to be done once. */
173-
157+ int cnt = 0 ;
158+ printf ("Enter to task_2\r\n" );
174159 while (1 ) {
175- printf ("task2_running..... \r\n" );
176-
160+ printf ("task2 is running %d.....\r\n" , cnt ++ );
177161 vTaskDelay (200 );
178162 }
179163}
@@ -183,21 +167,19 @@ static void vExampleTimerCallback(TimerHandle_t xTimer)
183167 /* The timer has expired. Count the number of times this happens. The
184168 timer that calls this function is an auto re-load timer, so it will
185169 execute periodically. */
186-
187- printf ("timers Callback\r\n" );
170+ static int cnt = 0 ;
171+ printf ("timers Callback %d \r\n" , cnt ++ );
188172}
189173
190174void vApplicationTickHook (void )
191175{
192- BaseType_t xHigherPriorityTaskWoken = pdFALSE ;
193- static uint32_t ulCount = 0 ;
176+ // BaseType_t xHigherPriorityTaskWoken = pdFALSE;
194177
195178 /* The RTOS tick hook function is enabled by setting configUSE_TICK_HOOK to
196179 1 in FreeRTOSConfig.h.
197180
198181 "Give" the semaphore on every 500th tick interrupt. */
199182
200-
201183 /* If xHigherPriorityTaskWoken is pdTRUE then a context switch should
202184 normally be performed before leaving the interrupt (because during the
203185 execution of the interrupt a task of equal or higher priority than the
@@ -229,9 +211,6 @@ void vApplicationMallocFailedHook(void)
229211
230212void vApplicationStackOverflowHook (TaskHandle_t xTask , signed char * pcTaskName )
231213{
232- // ( void ) pcTaskName;
233- // ( void ) xTask;
234-
235214 /* Run time stack overflow checking is performed if
236215 configconfigCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook
237216 function is called if a stack overflow is detected. pxCurrentTCB can be
@@ -246,7 +225,7 @@ void vApplicationStackOverflowHook(TaskHandle_t xTask, signed char *pcTaskName)
246225extern UBaseType_t uxCriticalNesting ;
247226void vApplicationIdleHook (void )
248227{
249- volatile size_t xFreeStackSpace ;
228+ // volatile size_t xFreeStackSpace;
250229 /* The idle task hook is enabled by setting configUSE_IDLE_HOOK to 1 in
251230 FreeRTOSConfig.h.
252231
0 commit comments