/* USER CODE BEGIN 0 */
TaskHandle_t Led_GateKeeperHandle = NULL;
TaskHandle_t myTask2Handle = NULL;
void Led_GateKeeper(void *pvParameters)
{
int count = (int*) pvParameters;
//TickType_t xDelay = 500 / portTICK_PERIOD_MS;
TickType_t xDelay = pdMS_TO_TICKS(1000);
TickType_t myLastUnblock;
myLastUnblock = xTaskGetTickCount();
for(;;)
{
HAL_GPIO_WritePin(GPIOD, LD4_Pin|LD3_Pin|LD5_Pin|LD6_Pin, GPIO_PIN_RESET);
//vTaskDelay(xDelay); //ms가 아닌 number of ticks, (the number of CPU takes that the kernel runs on
vTaskDelayUntil( &myLastUnblock, xDelay );
HAL_GPIO_WritePin(GPIOD, LD4_Pin|LD3_Pin|LD5_Pin|LD6_Pin, GPIO_PIN_SET);
//vTaskDelay(xDelay);
vTaskDelayUntil( &myLastUnblock, xDelay );
//printf("count : %d\r\n", count);
if(count == 100){
vTaskDelete(Led_GateKeeperHandle);
}
count++;
}
}
void myTask2(void *pvParameters)
{
TickType_t xDelay = pdMS_TO_TICKS(1000);
TickType_t myLastUnblock;
myLastUnblock = xTaskGetTickCount();
for(;;)
{
vTaskDelayUntil( &myLastUnblock, 5*xDelay );
vTaskSuspend(Led_GateKeeperHandle);
vTaskDelayUntil( &myLastUnblock, 5*xDelay );
vTaskResume(Led_GateKeeperHandle);
}
}
/* USER CODE END 0 */
int main(void)
{
/* USER CODE BEGIN 1 */
/* 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 */
/* USER CODE BEGIN 2 */
int pass = 8;
//printf("count : %d\r\n", pass);
xTaskCreate(Led_GateKeeper, //Task Pointer
(const char* const)"led_gate", //Task Name
configMINIMAL_STACK_SIZE + 200, //Stack Depth
(void *)pass, //Parameters to pass to task
2, //Task Priority
&Led_GateKeeperHandle); //Pass Handle to created task
xTaskCreate(myTask2, //Task Pointer
(const char* const)"task2", //Task Name
configMINIMAL_STACK_SIZE + 200, //Stack Depth
(void *)pass, //Parameters to pass to task
tskIDLE_PRIORITY, //Task Priority
&myTask2Handle); //Pass Handle to created task
//
/* USER CODE END 2 */