K74B/app_Indie/usr/common/applicationTask.c

111 lines
2.1 KiB
C
Raw Normal View History

2024-01-16 10:46:17 +08:00
/**
* @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 <applicationTask.h>
#include <measureTask.h>
#include <pdsTask.h>
#include <linStackTask.h>
2024-01-18 17:01:45 +08:00
#include "PINdef.h"
2024-01-16 10:46:17 +08:00
/*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)
{
}
/***************************************************************/
2024-01-18 17:01:45 +08:00
static uint16_t keydelay[KEY_NUM]={0};
static uint8_t keyflag[KEY_NUM]={0};
void KeyScanTimerExpired(SoftTimer_t *timer);
2024-01-16 10:46:17 +08:00
static SoftTimer_t KeyScanTimer = {
.mode = TIMER_PERIODIC_MODE,
.interval = 5U,
.handler = KeyScanTimerExpired
};
2024-01-18 17:01:45 +08:00
#define KEY_DELAY_TIME 6
2024-01-16 10:46:17 +08:00
void KeyScanTimerExpired(SoftTimer_t *timer)
{
2024-01-18 17:01:45 +08:00
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;
}
}
2024-01-16 10:46:17 +08:00
}