K67A/hwCtrl.c
2024-10-12 15:36:29 +08:00

142 lines
2.2 KiB
C

#include "hwCtrl.h"
#include "r_cg_port.h"
#include "iodefine.h"
#include "appTask.h"
#define K74L 1
#define K74R 2
#define BOARD K74L
#if BOARD == K74R
//RIGHT
#define LEDF1 P1_bit.no1
#define LEDF2 P1_bit.no2
#define LEDF3 P1_bit.no3
#define LEDH1 P4_bit.no2
#define LEDH2 P1_bit.no0
#define LEDH3 P4_bit.no1
#define LEDM1 P2_bit.no1
#else
//LEFT
#define LEDH1 P1_bit.no1
#define LEDH2 P1_bit.no2
#define LEDH3 P1_bit.no3
#define LEDF1 P4_bit.no2
#define LEDF2 P1_bit.no0
#define LEDF3 P4_bit.no1
#define LEDM1 P1_bit.no4
#endif
#define IO_KEYFAN P2_bit.no0
#define IO_KEYANMO P2_bit.no1
#define IO_KEYHEAT P2_bit.no2
extern uint16_t g_AdVal[3];
void AnmoLED_Ctrl(uint8_t state)
{
switch (state)
{
case 0:
LEDM1 = LED_OFF;
break;
case 1:
LEDM1 = LED_ON;
break;
default:
break;
}
}
void FanLED_Ctrl(uint8_t state)
{
switch (state)
{
case 0:
LEDF1 = LED_OFF;
LEDF2 = LED_OFF;
LEDF3 = LED_OFF;
break;
case 3:
LEDF1 = LED_ON;
LEDF2 = LED_OFF;
LEDF3 = LED_OFF;
break;
case 2:
LEDF1 = LED_ON;
LEDF2 = LED_ON;
LEDF3 = LED_OFF;
break;
case 1:
LEDF1 = LED_ON;
LEDF2 = LED_ON;
LEDF3 = LED_ON;
break;
default:
break;
}
}
void HeatLED_Ctrl(uint8_t state)
{
switch (state)
{
case 0:
LEDH1 = LED_OFF;
LEDH2 = LED_OFF;
LEDH3 = LED_OFF;
break;
case 3:
LEDH1 = LED_ON;
LEDH2 = LED_OFF;
LEDH3 = LED_OFF;
break;
case 2:
LEDH1 = LED_ON;
LEDH2 = LED_ON;
LEDH3 = LED_OFF;
break;
case 1:
LEDH1 = LED_ON;
LEDH2 = LED_ON;
LEDH3 = LED_ON;
break;
default:
break;
}
}
uint8_t GetKeyState(uint8_t keyno)
{
switch (keyno)
{
case KEY_AM:
return IO_KEYANMO==0?1:0;
break;
case KEY_JR:
return IO_KEYHEAT==0?1:0;
break;
case KEY_FAN:
return IO_KEYFAN==0?1:0;
break;
default:
return 0;
break;
}
}