diff --git a/app_Indie/application.ewp b/app_Indie/application.ewp index 75ae296..9ac1fa5 100644 --- a/app_Indie/application.ewp +++ b/app_Indie/application.ewp @@ -66,7 +66,7 @@ OGLastSavedByProductVersion - 8.30.1.17146 + 8.40.1.21529 GeneralEnableMisra @@ -116,7 +116,7 @@ GBECoreSlave - 26 + 27 34 @@ -133,7 +133,7 @@ CoreVariant - 26 + 27 34 @@ -156,7 +156,7 @@ GFPUCoreSlave2 - 26 + 27 34 @@ -215,7 +215,7 @@ ICCARM 2 - 34 + 35 1 0 @@ -363,6 +363,7 @@ $PROJ_DIR$\lib\downloader\inc $TOOLKIT_DIR$\CMSIS\Include $TOOLKIT_DIR$\CMSIS\Core\Include + $PROJ_DIR$\usr\fcode CCStdIncCheck @@ -458,11 +459,11 @@ CCEncSource - 0 + 2 CCEncOutput - 0 + 2 CCEncOutputBom @@ -470,7 +471,7 @@ CCEncInput - 0 + 1 IccExceptions2 @@ -480,6 +481,10 @@ IccRTTI2 0 + + OICompilerExtraOption + 1 + @@ -700,7 +705,7 @@ ILINK 0 - 21 + 23 1 0 @@ -1016,6 +1021,26 @@ IlinkTrustzoneImportLibraryOut realplumPro_app_import_lib.o + + OILinkExtraOption + 1 + + + IlinkRawBinaryFile2 + + + + IlinkRawBinarySymbol2 + + + + IlinkRawBinarySegment2 + + + + IlinkRawBinaryAlign2 + + @@ -1053,6 +1078,18 @@ $PROJ_DIR$\usr\common\appConfig.h + + fcode + + $PROJ_DIR$\usr\fcode\hwCtrl.c + + + $PROJ_DIR$\usr\fcode\hwCtrl.h + + + $PROJ_DIR$\usr\fcode\PINdef.h + + include @@ -1068,7 +1105,7 @@ $PROJ_DIR$\usr\common\linMasterTask.h - $PROJ_DIR$\usr\common\linslaveTask.h + $PROJ_DIR$\usr\common\linSlaveTask.h $PROJ_DIR$\usr\common\linsNodeCfgIdentify.h @@ -1089,7 +1126,7 @@ $PROJ_DIR$\usr\common\safetyMonitorTask.h - $PROJ_DIR$\usr\library\SoftTimerTask.h + $PROJ_DIR$\usr\library\softTimerTask.h $PROJ_DIR$\usr\common\systemInit.h diff --git a/app_Indie/application.ewt b/app_Indie/application.ewt index 18938c9..b8e140b 100644 --- a/app_Indie/application.ewt +++ b/app_Indie/application.ewt @@ -1193,6 +1193,18 @@ $PROJ_DIR$\usr\common\appConfig.h + + fcode + + $PROJ_DIR$\usr\fcode\hwCtrl.c + + + $PROJ_DIR$\usr\fcode\hwCtrl.h + + + $PROJ_DIR$\usr\fcode\PINdef.h + + include @@ -1208,7 +1220,7 @@ $PROJ_DIR$\usr\common\linMasterTask.h - $PROJ_DIR$\usr\common\linslaveTask.h + $PROJ_DIR$\usr\common\linSlaveTask.h $PROJ_DIR$\usr\common\linsNodeCfgIdentify.h @@ -1229,7 +1241,7 @@ $PROJ_DIR$\usr\common\safetyMonitorTask.h - $PROJ_DIR$\usr\library\SoftTimerTask.h + $PROJ_DIR$\usr\library\softTimerTask.h $PROJ_DIR$\usr\common\systemInit.h diff --git a/app_Indie/drivers/hal/src/adc_device.c b/app_Indie/drivers/hal/src/adc_device.c index ad7e5ee..8f2199d 100644 --- a/app_Indie/drivers/hal/src/adc_device.c +++ b/app_Indie/drivers/hal/src/adc_device.c @@ -53,7 +53,7 @@ void ADC_GeneralInit(void) for (uint8_t i = 0U; i < 10U; i++){ SAR_CTRL_SFRS->ADCCHCTRL2R.WORD &= ~((uint32_t)0x03UL << (i*2+8U));//clear - SAR_CTRL_SFRS->ADCCHCTRL2R.WORD |= ((uint32_t)ADC_REF_VBG_2TIMES << (i*2+8U));//set + SAR_CTRL_SFRS->ADCCHCTRL2R.WORD |= ((uint32_t)ADC_REF_VDD_3V3 << (i*2+8U));//set vref 3v3 SAR_CTRL_SFRS->ADCCHCTRL0R.WORD &= ~((uint32_t)0x03UL << (i*2+0U)); SAR_CTRL_SFRS->ADCCHCTRL0R.WORD |= ((uint32_t)ADC_AFE_INPUT_ALL_EXT << (i*2+0U)); @@ -88,19 +88,19 @@ void ADC_Init(AdcMeasureItem_t item, uint8_t channel) source.channel = ADC_PWMAUX_CHN0; source.pwmAux = ADC_PWMAUX_TRIG_SRC_PWM_PERIOD0; source.general = ADC_TRIG_SRC_PWM_CMP0; - + /* SYSCTRLA_SFRS->CSACTRLR.CSAGAINSEL = 0U;//5 gain SYSCTRLA_SFRS->CSACTRLR.CSAZEROEN = 0U; SYSCTRLA_SFRS->CSACTRLR.CSAPOWEN = 1U; - + */ SAR_CTRL_SFRS->AFECTRL.SARAFEEN = 1;//ADC AFE Enable. adc afe enable. If vinp, vinn and vin vcm all choose external, adc afe should be disabled: adc_adc_en=0, otherwise, adc afe must be enabled: adc_afe_en=1. SAR_CTRL_SFRS->AFECTRL.ADCSELVINVCMEXT = 0;//Select External Inputs to ADC. choose ADC input common voltage. 0: choose internal vin_vcm, equals to (vinp+vinn)/2; 1: choose external vin_vcm, for PN detect. SAR_CTRL_SFRS->AFECTRL.SARPREAMPEN = 1;// adc pre-amp enable. - SAR_CTRL_SFRS->ADCCHCONF.CH1SEL = ADC_CH_SEL_CSA_Filter_OUT_GND;//0x9: adc_vinp=CSA_Filter_OUT , adc_vinn=vref_gnd + SAR_CTRL_SFRS->ADCCHCONF.CH1SEL = ADC_CH_SEL_TSENSOR_GND;// SAR_CTRL_SFRS->ADCCHCONF.CH2SEL = ADC_CH_SEL_VBAT_GND; - SAR_CTRL_SFRS->ADCCHCONF.CH3SEL = ADC_CH_SEL_PB3_GND; - SAR_CTRL_SFRS->ADCCHCONF.CH4SEL = ADC_CH_SEL_PC4_GND; + SAR_CTRL_SFRS->ADCCHCONF.CH3SEL = ADC_CH_SEL_PB6_GND; + SAR_CTRL_SFRS->ADCCHCONF.CH4SEL = ADC_CH_SEL_PB7_GND; SAR_CTRL_SFRS->ADCCHCTRL1R.SAMPCYCCH1 = 15U;//max 15 SAR_CTRL_SFRS->SARCTRL.DIGRESET = 0X1U; diff --git a/app_Indie/settings/application.Release.cspy.bat b/app_Indie/settings/application.Release.cspy.bat index 3108c56..7578a38 100644 --- a/app_Indie/settings/application.Release.cspy.bat +++ b/app_Indie/settings/application.Release.cspy.bat @@ -25,7 +25,7 @@ if not "%~1" == "" goto debugFile @echo on -"E:\IAR Systems\Embedded Workbench 8.3\common\bin\cspybat" -f "F:\FCB_project\temp\K74\K74B_CODE\libdev_metaLite_app.00.00.00.00.0003_liu\settings\application.Release.general.xcl" --backend -f "F:\FCB_project\temp\K74\K74B_CODE\libdev_metaLite_app.00.00.00.00.0003_liu\settings\application.Release.driver.xcl" +"E:\IAR Systems\Embedded Workbench 8.3\common\bin\cspybat" -f "F:\FCB_project\temp\K74\K74B_CODE\K74B\app_Indie\settings\application.Release.general.xcl" --backend -f "F:\FCB_project\temp\K74\K74B_CODE\K74B\app_Indie\settings\application.Release.driver.xcl" @echo off goto end @@ -34,7 +34,7 @@ goto end @echo on -"E:\IAR Systems\Embedded Workbench 8.3\common\bin\cspybat" -f "F:\FCB_project\temp\K74\K74B_CODE\libdev_metaLite_app.00.00.00.00.0003_liu\settings\application.Release.general.xcl" "--debug_file=%~1" --backend -f "F:\FCB_project\temp\K74\K74B_CODE\libdev_metaLite_app.00.00.00.00.0003_liu\settings\application.Release.driver.xcl" +"E:\IAR Systems\Embedded Workbench 8.3\common\bin\cspybat" -f "F:\FCB_project\temp\K74\K74B_CODE\K74B\app_Indie\settings\application.Release.general.xcl" "--debug_file=%~1" --backend -f "F:\FCB_project\temp\K74\K74B_CODE\K74B\app_Indie\settings\application.Release.driver.xcl" @echo off :end \ No newline at end of file diff --git a/app_Indie/settings/application.Release.cspy.ps1 b/app_Indie/settings/application.Release.cspy.ps1 index 32f1ff1..c7ae9ea 100644 --- a/app_Indie/settings/application.Release.cspy.ps1 +++ b/app_Indie/settings/application.Release.cspy.ps1 @@ -23,9 +23,9 @@ if ($debugfile -eq "") { -& "E:\IAR Systems\Embedded Workbench 8.3\common\bin\cspybat" -f "F:\FCB_project\temp\K74\K74B_CODE\libdev_metaLite_app.00.00.00.00.0003_liu\settings\application.Release.general.xcl" --backend -f "F:\FCB_project\temp\K74\K74B_CODE\libdev_metaLite_app.00.00.00.00.0003_liu\settings\application.Release.driver.xcl" +& "E:\IAR Systems\Embedded Workbench 8.3\common\bin\cspybat" -f "F:\FCB_project\temp\K74\K74B_CODE\K74B\app_Indie\settings\application.Release.general.xcl" --backend -f "F:\FCB_project\temp\K74\K74B_CODE\K74B\app_Indie\settings\application.Release.driver.xcl" } else { -& "E:\IAR Systems\Embedded Workbench 8.3\common\bin\cspybat" -f "F:\FCB_project\temp\K74\K74B_CODE\libdev_metaLite_app.00.00.00.00.0003_liu\settings\application.Release.general.xcl" --debug_file=$debugfile --backend -f "F:\FCB_project\temp\K74\K74B_CODE\libdev_metaLite_app.00.00.00.00.0003_liu\settings\application.Release.driver.xcl" +& "E:\IAR Systems\Embedded Workbench 8.3\common\bin\cspybat" -f "F:\FCB_project\temp\K74\K74B_CODE\K74B\app_Indie\settings\application.Release.general.xcl" --debug_file=$debugfile --backend -f "F:\FCB_project\temp\K74\K74B_CODE\K74B\app_Indie\settings\application.Release.driver.xcl" } diff --git a/app_Indie/settings/application.Release.general.xcl b/app_Indie/settings/application.Release.general.xcl index 9981adf..73cdf1e 100644 --- a/app_Indie/settings/application.Release.general.xcl +++ b/app_Indie/settings/application.Release.general.xcl @@ -2,7 +2,7 @@ "E:\IAR Systems\Embedded Workbench 8.3\arm\bin\armjlink2.dll" -"F:\FCB_project\temp\K74\K74B_CODE\libdev_metaLite_app.00.00.00.00.0003_liu\Release\Exe\realplumPro_app.out" +"F:\FCB_project\temp\K74\K74B_CODE\K74B\app_Indie\Release\Exe\realplumPro_app.out" --plugin="E:\IAR Systems\Embedded Workbench 8.3\arm\bin\armbat.dll" diff --git a/app_Indie/usr/common/applicationTask.c b/app_Indie/usr/common/applicationTask.c index 5542710..e496f83 100644 --- a/app_Indie/usr/common/applicationTask.c +++ b/app_Indie/usr/common/applicationTask.c @@ -16,7 +16,7 @@ #include #include #include - +#include "PINdef.h" /*static uint8_t ledNum = LED0;*/ static TaskState_t applState = TASK_STATE_INIT; void ApplTimerExpired(SoftTimer_t *timer); @@ -72,14 +72,39 @@ 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; + } + + } } diff --git a/app_Indie/usr/common/measureTask.c b/app_Indie/usr/common/measureTask.c index 0dd2b60..a56a67b 100644 --- a/app_Indie/usr/common/measureTask.c +++ b/app_Indie/usr/common/measureTask.c @@ -190,17 +190,12 @@ int16_t get_chip_temperature(int16_t vTemp) } return (int16_t)stemp; } - +extern uint16_t g_AdVal[3]; void updateSystemInfo(void) { - /* calculate chip temperature */ - adcResult.vChipTemp.target = get_volt(&adcResult.vChipTemp); - adcResult.chipTemperature = get_chip_temperature(adcResult.vChipTemp.target); - adcResult.vBatt.target = get_volt(&adcResult.vBatt); - adcResult.vPB3.target = get_volt(&adcResult.vPB3); - adcResult.vPC4.target = get_volt(&adcResult.vPC4); - adcResult.vAmp.target = get_volt(&adcResult.vAmp); - vAmpbuff[Motor_GetMotorStep()] = adcResult.vAmp.target; + g_AdVal[0] = measGeneralAdcCode[2]; + g_AdVal[1] = measGeneralAdcCode[3]; + // TM_PostTask(TASK_ID_SAFETY_MONITOR); updateSystemInfocnt++; diff --git a/app_Indie/usr/common/systemInit.c b/app_Indie/usr/common/systemInit.c index d3df03a..378cebb 100644 --- a/app_Indie/usr/common/systemInit.c +++ b/app_Indie/usr/common/systemInit.c @@ -22,6 +22,7 @@ #include #include #include +#include "PINdef.h" void gpios_init(void); void pmu_init(void); @@ -30,45 +31,19 @@ void pmu_init(void); void gpios_init(void) { -#if control_type == Divide_2 - GPIO_Init(GROUP_GPIOA,GPIO_PORT_3, GPIO_DIR_OUTPUT,GPIO_PULL_DOWN); //Downpwm_ACoil Pos side upper arm: GPIO - GPIO_Init(GROUP_GPIOA,GPIO_PORT_2, GPIO_DIR_OUTPUT,GPIO_PULL_NONE);//Downpwm_ACoil Pos side down arm: PWM - - GPIO_Init(GROUP_GPIOA,GPIO_PORT_6, GPIO_DIR_OUTPUT,GPIO_PULL_NONE);//Downpwm_ACoil NEG side upper arm: GPIO - GPIO_Init(GROUP_GPIOA,GPIO_PORT_5, GPIO_DIR_OUTPUT,GPIO_PULL_DOWN); //Downpwm_ACoil Neg side down arm: PWM - - - GPIO_Init(GROUP_GPIOB,GPIO_PORT_2, GPIO_DIR_OUTPUT,GPIO_PULL_NONE);//Downpwm_BCoil Pos side upper arm: GPIO - GPIO_Init(GROUP_GPIOB,GPIO_PORT_1, GPIO_DIR_OUTPUT,GPIO_PULL_NONE);//Downpwm_BCoil Pos side down arm: PWM - - GPIO_Init(GROUP_GPIOA,GPIO_PORT_4, GPIO_DIR_OUTPUT,GPIO_PULL_DOWN); //Downpwm_BCoil Neg side upper arm: GPIO - GPIO_Init(GROUP_GPIOB,GPIO_PORT_0, GPIO_DIR_OUTPUT,GPIO_PULL_NONE);//Downpwm_BCoil Neg side down arm: PWM + GPIO_Init(IO_KEY3,GPIO_DIR_INPUT,GPIO_PULL_NONE); + GPIO_Init(IO_KEY4,GPIO_DIR_INPUT,GPIO_PULL_NONE); + GPIO_Init(IO_KEY5,GPIO_DIR_INPUT,GPIO_PULL_NONE); + GPIO_Init(IO_KEY6,GPIO_DIR_INPUT,GPIO_PULL_NONE); + GPIO_Init(IO_KEY7,GPIO_DIR_INPUT,GPIO_PULL_NONE); + GPIO_Init(IO_KEY8,GPIO_DIR_INPUT,GPIO_PULL_NONE); -#elif control_type == Divide_6 - - GPIO_Init(GROUP_GPIOA,GPIO_PORT_3, GPIO_DIR_OUTPUT,GPIO_PULL_DOWN); //Downpwm_ACoil Pos side upper arm: GPIO - GPIO_Init(GROUP_GPIOA,GPIO_PORT_6, GPIO_DIR_OUTPUT,GPIO_PULL_NONE);//Downpwm_ACoil NEG side upper arm: GPIO - GPIO_Init(GROUP_GPIOB,GPIO_PORT_2, GPIO_DIR_OUTPUT,GPIO_PULL_NONE);//Downpwm_BCoil Pos side upper arm: GPIO - GPIO_Init(GROUP_GPIOA,GPIO_PORT_4, GPIO_DIR_OUTPUT,GPIO_PULL_DOWN); //Downpwm_BCoil Neg side upper arm: GPIO - - PWMAUX_Init(GROUP_GPIOA,GPIO_PORT_2,PWMAUX_CH5,PWMAUX_BASE_0,PWMAUX_CLK_DIV_1,PWMAUX_Period); //Downpwm_ACoil Pos side down arm: PWMAUX5 - PWMAUX_Init(GROUP_GPIOA,GPIO_PORT_5,PWMAUX_CH0,PWMAUX_BASE_0,PWMAUX_CLK_DIV_1,PWMAUX_Period); //Downpwm_ACoil Neg side down arm: PWMAUX0 - - PWMAUX_Init(GROUP_GPIOB,GPIO_PORT_1,PWMAUX_CH2,PWMAUX_BASE_0,PWMAUX_CLK_DIV_1,PWMAUX_Period); //Downpwm_BCoil Neg side down arm: PWMAUX2 - PWMAUX_Init(GROUP_GPIOB,GPIO_PORT_0,PWMAUX_CH1,PWMAUX_BASE_0,PWMAUX_CLK_DIV_1,PWMAUX_Period); //Downpwm_BCoil Pos side down arm: PWMAUX1 - -// PWM_AUX_SFRS->INVERT = 0X3FU; -// -// PWMAUX_SetMatchValue(PWMAUX_CH5, 0, PWMAUX_Period/2);//PWMAUX5:PA2 -// PWMAUX_SetMatchValue(PWMAUX_CH0, 0, PWMAUX_Period/4);//PWMAUX0:PA5 -// PWMAUX_SetMatchValue(PWMAUX_CH2, 0, PWMAUX_Period/6);//PWMAUX2:PB1 -// PWMAUX_SetMatchValue(PWMAUX_CH1, 0, PWMAUX_Period/8);//PWMAUX1:PB0 - -#endif - - GPIO_Init(GROUP_GPIOB,GPIO_PORT_3, GPIO_DIR_INPUT,GPIO_PULL_NONE);//ADC Postion: Full scale - GPIO_Init(GROUP_GPIOC,GPIO_PORT_4, GPIO_DIR_INPUT,GPIO_PULL_NONE);//ADC Postion: Resistance partial voltage value - GPIO_Init(GROUP_GPIOC,GPIO_PORT_3, GPIO_DIR_OUTPUT,GPIO_PULL_DOWN); + GPIO_Init(IO_LED1,GPIO_DIR_OUTPUT,GPIO_PULL_NONE); + GPIO_Init(IO_LED2,GPIO_DIR_OUTPUT,GPIO_PULL_NONE); + GPIO_Init(IO_LED3,GPIO_DIR_OUTPUT,GPIO_PULL_NONE); + GPIO_Init(IO_LED4,GPIO_DIR_OUTPUT,GPIO_PULL_NONE); + GPIO_Init(IO_LED5,GPIO_DIR_OUTPUT,GPIO_PULL_NONE); + GPIO_Init(IO_LED6,GPIO_DIR_OUTPUT,GPIO_PULL_NONE); } void pmu_init(void) diff --git a/app_Indie/usr/fcode/PINdef.h b/app_Indie/usr/fcode/PINdef.h new file mode 100644 index 0000000..e0850f4 --- /dev/null +++ b/app_Indie/usr/fcode/PINdef.h @@ -0,0 +1,45 @@ +#ifndef __PINDEF_H__ +#define __PINDEF_H__ +#include "gpio_device.h" + + +#define SIGID_KEY1 1 +#define SIGID_KEY2 2 +#define SIGID_KEY3 3 +#define SIGID_KEY4 4 +#define SIGID_KEY5 5 +#define SIGID_KEY6 6 +#define SIGID_KEY7 7 +#define SIGID_KEY8 8 +#define SIGID_KEY9 9 +#define SIGID_KEY10 10 +#define SIGID_KEY11 11 +#define SIGID_KEY12 12 +#define SIGID_KEY13 13 +#define KEY_NUM 13 + + + + +#define ADCH_KEYAD1 1 +#define ADCH_KEYAD2 0 + +#define IO_KEY3 GROUP_GPIOB,GPIO_PORT_0 +#define IO_KEY4 GROUP_GPIOB,GPIO_PORT_1 +#define IO_KEY5 GROUP_GPIOB,GPIO_PORT_5 +#define IO_KEY6 GROUP_GPIOB,GPIO_PORT_4 +#define IO_KEY7 GROUP_GPIOB,GPIO_PORT_2 +#define IO_KEY8 GROUP_GPIOB,GPIO_PORT_3 + +#define IO_LED1 GROUP_GPIOC,GPIO_PORT_4 +#define IO_LED2 GROUP_GPIOC,GPIO_PORT_3 +#define IO_LED3 GROUP_GPIOA,GPIO_PORT_6 +#define IO_LED4 GROUP_GPIOA,GPIO_PORT_5 +#define IO_LED5 GROUP_GPIOA,GPIO_PORT_4 +#define IO_LED6 GROUP_GPIOA,GPIO_PORT_3 + + + + +#endif + diff --git a/app_Indie/usr/fcode/hwCtrl.c b/app_Indie/usr/fcode/hwCtrl.c new file mode 100644 index 0000000..60ca4ad --- /dev/null +++ b/app_Indie/usr/fcode/hwCtrl.c @@ -0,0 +1,152 @@ + +#include "hwCtrl.h" +#include "PINdef.h" + + +#define IO_INPUT 0x01 +#define IO_OUTPUT 0x00 + +void IO_Init(void) +{ + +} + +void Output_Ctrl(uint8_t state) +{ + +} + +#define KEY_AD_TH 30 +uint8_t isKeyMatchAd(uint16_t val,uint16_t match) +{ + if ( val >= (match - KEY_AD_TH) && val <= (match + KEY_AD_TH)) + { + return 1; + } + return 0; +} + +#define KEY_AD_V0 30 +#define KEY_AD_V1 254 +#define KEY_AD_V2 455 +#define KEY_AD_V3 658 +#define KEY_AD_V4 896 + +#define KEY_AD_V5 511 +#define KEY_AD_V6 696 + +uint16_t g_AdVal[3]; + +uint8_t GetKeyState(uint8_t keyno) +{ + switch (keyno) + { + case SIGID_KEY1: + return isKeyMatchAd(g_AdVal[ADCH_KEYAD1],KEY_AD_V5); + case SIGID_KEY2: + return isKeyMatchAd(g_AdVal[ADCH_KEYAD1],KEY_AD_V6); + case SIGID_KEY3: + return GPIO_Read(IO_KEY3)?1:0; + case SIGID_KEY4: + return GPIO_Read(IO_KEY4)?1:0; + case SIGID_KEY5: + return GPIO_Read(IO_KEY5)?1:0; + case SIGID_KEY6: + return GPIO_Read(IO_KEY6)?1:0; + case SIGID_KEY7: + return GPIO_Read(IO_KEY7)?1:0; + case SIGID_KEY8: + return GPIO_Read(IO_KEY8)?1:0; + case SIGID_KEY9: + return isKeyMatchAd(g_AdVal[ADCH_KEYAD2],KEY_AD_V0); + case SIGID_KEY10: + return isKeyMatchAd(g_AdVal[ADCH_KEYAD2],KEY_AD_V1); + case SIGID_KEY13: + return isKeyMatchAd(g_AdVal[ADCH_KEYAD2],KEY_AD_V2); + case SIGID_KEY11: + return isKeyMatchAd(g_AdVal[ADCH_KEYAD2],KEY_AD_V3); + case SIGID_KEY12: + return isKeyMatchAd(g_AdVal[ADCH_KEYAD2],KEY_AD_V4); + default: + return 0; + } +} + + +#define LED_OFF GPIO_HIGH +#define LED_ON GPIO_LOW + +#if BOARDCFG == LEFT_BOARD +#define LEDF1 IO_LED4 +#define LEDF2 IO_LED5 +#define LEDF3 IO_LED6 + +#define LEDH1 IO_LED1 +#define LEDH2 IO_LED2 +#define LEDH3 IO_LED3 +#else +#define LEDF1 IO_LED1 +#define LEDF2 IO_LED2 +#define LEDF3 IO_LED3 + +#define LEDH1 IO_LED4 +#define LEDH2 IO_LED5 +#define LEDH3 IO_LED6 +#endif + +void FanLED_Ctrl(uint8_t state) +{ + switch (state) + { + case 0: + GPIO_Set(LEDF1,LED_OFF); + GPIO_Set(LEDF2,LED_OFF); + GPIO_Set(LEDF3,LED_OFF); + break; + case 1: + GPIO_Set(LEDF1,LED_ON); + GPIO_Set(LEDF2,LED_OFF); + GPIO_Set(LEDF3,LED_OFF); + break; + case 2: + GPIO_Set(LEDF1,LED_ON); + GPIO_Set(LEDF2,LED_ON); + GPIO_Set(LEDF3,LED_OFF); + break; + case 3: + GPIO_Set(LEDF1,LED_ON); + GPIO_Set(LEDF2,LED_ON); + GPIO_Set(LEDF3,LED_ON); + break; + default: + break; + } +} +void HeatLED_Ctrl(uint8_t state) +{ + switch (state) + { + case 0: + GPIO_Set(LEDH1,LED_OFF); + GPIO_Set(LEDH2,LED_OFF); + GPIO_Set(LEDH3,LED_OFF); + break; + case 1: + GPIO_Set(LEDH1,LED_ON); + GPIO_Set(LEDH2,LED_OFF); + GPIO_Set(LEDH3,LED_OFF); + break; + case 2: + GPIO_Set(LEDH1,LED_ON); + GPIO_Set(LEDH2,LED_ON); + GPIO_Set(LEDH3,LED_OFF); + break; + case 3: + GPIO_Set(LEDH1,LED_ON); + GPIO_Set(LEDH2,LED_ON); + GPIO_Set(LEDH3,LED_ON); + break; + default: + break; + } +} diff --git a/app_Indie/usr/fcode/hwCtrl.h b/app_Indie/usr/fcode/hwCtrl.h new file mode 100644 index 0000000..66c9ed5 --- /dev/null +++ b/app_Indie/usr/fcode/hwCtrl.h @@ -0,0 +1,16 @@ + +#ifndef __HWCTRL_H__ +#define __HWCTRL_H__ +#include "gpio_device.h" + +#define OUTPUT_ON 1 +#define OUTPUT_OFF 0 + + +uint8_t GetKeyState(uint8_t keyno); +void Output_Ctrl(uint8_t state); +void IO_Init(void); +void FanLED_Ctrl(uint8_t state); +void HeatLED_Ctrl(uint8_t state); + +#endif