/* * application.c * * Created on: 22.09.2022 * Author: jonas */ #include "fsl_debug_console.h" #include "platform.h" #include "application.h" #include "McuWait.h" #include "McuLED.h" #include "McuLog.h" #define APP_DEBUG /* blue led pins */ #define LED_BLUE_GPIO GPIOC #define LED_BLUE_PORT PORTC #define LED_BLUE_PIN 2U /* vars */ static McuLED_Handle_t LED_blue; static McuGPIO_Handle_t GPIO_PowerRaspi; static uint32_t taskParameter1 = 5; static TaskHandle_t appTaskHandle = NULL; static QueueHandle_t eventQueueHandle = NULL; /* function declaration */ /* Application initialization */ void App_Init(void){ /* configure blue LED */ McuLED_Config_t config; McuLED_GetDefaultConfig(&config); config.isLowActive = true; config.isOnInit = false; config.hw.gpio = LED_BLUE_GPIO; config.hw.port = LED_BLUE_PORT; config.hw.pin = LED_BLUE_PIN; LED_blue = McuLED_InitLed(&config); /* configure gpio raspi power disable */ McuGPIO_Config_t config_gpio; McuGPIO_GetDefaultConfig(&config_gpio); config.isOnInit = true; config.hw.gpio = GPIOD; config.hw.port = PORTD; config.hw.pin = 6U; GPIO_PowerRaspi = McuGPIO_InitGPIO(&config_gpio); // get the event queue handle from debounce eventQueueHandle = Debounce_GetEventQueueHandle(); } /* App Task */ static void App_Task(void* pv){ McuLog_info("Application Task starting"); Debounce_event_e event = Event_None; while(1){ // get event data from queue if it can be reached if(eventQueueHandle != NULL) { // ignore errors, since it is very well possible that the queue is empty xQueueReceive(eventQueueHandle, &event, pdMS_TO_TICKS(20)); } if(event == Button_Center_Pressed){ McuGPIO_SetLow(GPIO_PowerRaspi); vTaskDelay(pdMS_TO_TICKS(5000)); McuGPIO_SetHigh(GPIO_PowerRaspi); } vTaskDelay(pdMS_TO_TICKS(100)); } } /* Application run */ void App_Run(void){ BaseType_t res; res = xTaskCreate( App_Task, "appTask", 900/sizeof(StackType_t), &taskParameter1, tskIDLE_PRIORITY, &appTaskHandle); if(res != pdPASS) // task creation not successful? { PRINTF("Task creation of app task failed"); for(;;) {} // Endless loop } vTaskStartScheduler(); } /* Application de-initialization */ void App_Deinit(void){ }