/** * @copyright 2015 Indie Semiconductor. * * This file is proprietary to Indie Semiconductor. * All rights reserved. Reproduction or distribution, in whole * or in part, is forbidden except by express written permission * of Indie Semiconductor. * * @file applicationTask.c * @Author: Jack.Pan * @E-mail:jack.pan@indiemicro.com * @Date: 2020/09/10 */ #include #include #include #include #include "PINdef.h" /*static uint8_t ledNum = LED0;*/ static TaskState_t applState = TASK_STATE_INIT; void ApplTimerExpired(SoftTimer_t *timer); static uint8_t LED_State = 0U; uint8_t APPL_GetLEDState(void) { return LED_State; } static SoftTimer_t ApplTimer = { .mode = TIMER_PERIODIC_MODE, .interval = 50U, .handler = ApplTimerExpired }; void ApplTimerExpired(SoftTimer_t *timer) { static uint8_t index = 0U; if (index == 0U){ index = 1U; }else{ index = 0; } } void APPL_TaskHandler(void) { switch(applState){ case TASK_STATE_INIT: SoftTimer_Start(&ApplTimer); applState = TASK_STATE_ACTIVE; break; case TASK_STATE_ACTIVE: break; default: break; } } void APPL_HandleControlCommands(LIN_Device_Frame_t const *frame) { } /***************************************************************/ static uint16_t keydelay[KEY_NUM]={0}; static uint8_t keyflag[KEY_NUM]={0}; void KeyScanTimerExpired(SoftTimer_t *timer); static SoftTimer_t KeyScanTimer = { .mode = TIMER_PERIODIC_MODE, .interval = 5U, .handler = KeyScanTimerExpired }; #define KEY_DELAY_TIME 6 void KeyScanTimerExpired(SoftTimer_t *timer) { uint8_t keyval,i; for (i = 0; i < KEY_NUM; i++) { keyval = GetKeyState(i); if (keyval == 1 && keyflag[i] == 0) { keydelay[i]++; if (keydelay[i] > KEY_DELAY_TIME)//30ms { keyflag[i] = 1; keydelay[i] = KEY_DELAY_TIME; } } else if (keyval == 0) { keyflag[i] = 0; keydelay[i] = 0; } } }