diff --git a/app_Indie/application.ewp b/app_Indie/application.ewp index 9ac1fa5..39e550e 100644 --- a/app_Indie/application.ewp +++ b/app_Indie/application.ewp @@ -659,7 +659,7 @@ OOCOutputFormat 3 - 3 + 1 OCOutputOverride @@ -667,7 +667,7 @@ OOCOutputFile - META_Test.bin + application.hex OOCCommandLineProducer diff --git a/app_Indie/settings/application.Release.cspy.bat b/app_Indie/settings/application.Release.cspy.bat index 7578a38..a3bf5ad 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\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" +"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\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" +"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 c7ae9ea..16c6c9c 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\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" +& "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\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" +& "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 73cdf1e..6b5af70 100644 --- a/app_Indie/settings/application.Release.general.xcl +++ b/app_Indie/settings/application.Release.general.xcl @@ -1,12 +1,12 @@ -"E:\IAR Systems\Embedded Workbench 8.3\arm\bin\armproc.dll" +"e:\IAR Systems\Embedded Workbench 8.3\arm\bin\armproc.dll" -"E:\IAR Systems\Embedded Workbench 8.3\arm\bin\armjlink2.dll" +"e:\IAR Systems\Embedded Workbench 8.3\arm\bin\armjlink2.dll" "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" +--plugin="e:\IAR Systems\Embedded Workbench 8.3\arm\bin\armbat.dll" ---flash_loader="E:\IAR Systems\Embedded Workbench 8.3\arm\config\flashloader\IndieSemi\FlashLoader_metaLite.board" +--flash_loader="e:\IAR Systems\Embedded Workbench 8.3\arm\config\flashloader\IndieSemi\FlashLoader_metaLite.board" diff --git a/app_Indie/settings/application_Release.jlink b/app_Indie/settings/application_Release.jlink new file mode 100644 index 0000000..39b6d05 --- /dev/null +++ b/app_Indie/settings/application_Release.jlink @@ -0,0 +1,39 @@ +[BREAKPOINTS] +ForceImpTypeAny = 0 +ShowInfoWin = 1 +EnableFlashBP = 2 +BPDuringExecution = 0 +[CFI] +CFISize = 0x00 +CFIAddr = 0x00 +[CPU] +MonModeVTableAddr = 0xFFFFFFFF +MonModeDebug = 0 +MaxNumAPs = 0 +LowPowerHandlingMode = 0 +OverrideMemMap = 0 +AllowSimulation = 1 +ScriptFile="" +[FLASH] +CacheExcludeSize = 0x00 +CacheExcludeAddr = 0x00 +MinNumBytesFlashDL = 0 +SkipProgOnCRCMatch = 1 +VerifyDownload = 1 +AllowCaching = 1 +EnableFlashDL = 2 +Override = 0 +Device="ARM7" +[GENERAL] +WorkRAMSize = 0x00 +WorkRAMAddr = 0x00 +RAMUsageLimit = 0x00 +[SWO] +SWOLogFile="" +[MEM] +RdOverrideOrMask = 0x00 +RdOverrideAndMask = 0xFFFFFFFF +RdOverrideAddr = 0xFFFFFFFF +WrOverrideOrMask = 0x00 +WrOverrideAndMask = 0xFFFFFFFF +WrOverrideAddr = 0xFFFFFFFF diff --git a/app_Indie/usr/common/applicationTask.c b/app_Indie/usr/common/applicationTask.c index e496f83..074176a 100644 --- a/app_Indie/usr/common/applicationTask.c +++ b/app_Indie/usr/common/applicationTask.c @@ -17,10 +17,21 @@ #include #include #include "PINdef.h" +#include "hwCtrl.h" /*static uint8_t ledNum = LED0;*/ static TaskState_t applState = TASK_STATE_INIT; void ApplTimerExpired(SoftTimer_t *timer); +void KeyScanTimerExpired(SoftTimer_t *timer); +void TxMsgPro(void); + + +static SoftTimer_t KeyScanTimer = { + .mode = TIMER_PERIODIC_MODE, + .interval = 5U, + .handler = KeyScanTimerExpired +}; + static uint8_t LED_State = 0U; @@ -55,6 +66,7 @@ void APPL_TaskHandler(void) switch(applState){ case TASK_STATE_INIT: SoftTimer_Start(&ApplTimer); + SoftTimer_Start(&KeyScanTimer); applState = TASK_STATE_ACTIVE; break; case TASK_STATE_ACTIVE: @@ -72,15 +84,36 @@ void APPL_HandleControlCommands(LIN_Device_Frame_t const *frame) /***************************************************************/ +typedef struct +{ + //BYTE 0 + uint8_t HG:2;//»¬¹ì + uint8_t AM:2;//°´Ä¦ + uint8_t KB:2;//¿¿±³ + uint8_t REVERSE01:2; + //BYTE 1 + uint8_t TT:2; + uint8_t REVERSE11:2; + uint8_t ZY:2; + uint8_t REVERSE12:2; + //BYTE 2 + uint8_t REVERSE21:4; + uint8_t FW:1;//¸´Î» + uint8_t REVERSE22:3; + //3-7 + uint8_t REVERSE3; + uint8_t REVERSE4; + uint8_t REVERSE5; + uint8_t REVERSE6; + uint8_t REVERSE7; +}LIN_MSG_TYPE; + +LIN_MSG_TYPE LIN_msg_buf; +const uint8_t LIN_Init_data[] = {0x00,0x00,0x80,0xff,0xff,0xff,0xff,0x0f}; + 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) @@ -106,5 +139,64 @@ void KeyScanTimerExpired(SoftTimer_t *timer) } } - + TxMsgPro(); +} +extern uint16_t g_AdVal[3]; +uint8_t fan_state,heat_state; +void LED_Ctrl(void) +{ + //fan_state = (g_rxbuf[0]&0xc0)>>6; + //heat_state = (g_rxbuf[0]&0x30)>>4; + FanLED_Ctrl(fan_state); + HeatLED_Ctrl(heat_state); +} + +uint8_t GetKeyFlag(uint8_t keyid) +{ + if (keyid > 0 && keyid <= KEY_NUM) + { + return keyflag[keyid-1]?1:0; + } + else + { + return 0; + } +} +uint8_t g_rxbuf[8],g_txbuf1[8],g_txbuf2[8]; +void TxMsgPro(void) +{ + uint8_t temp=0,i; + temp = 0xf0; +#if BOARDCFG == LEFT_BOARD + LIN_msg_buf.FW = GetKeyFlag(SIGID_KEY13); + LIN_msg_buf.TT = GetKeyFlag(SIGID_KEY6)<<1|GetKeyFlag(SIGID_KEY5); + LIN_msg_buf.HG = GetKeyFlag(SIGID_KEY3)<<1|GetKeyFlag(SIGID_KEY4); + LIN_msg_buf.AM = GetKeyFlag(SIGID_KEY8)<<1|GetKeyFlag(SIGID_KEY7); + LIN_msg_buf.KB = GetKeyFlag(SIGID_KEY9)<<1|GetKeyFlag(SIGID_KEY11); + LIN_msg_buf.ZY = GetKeyFlag(SIGID_KEY12)<<1|GetKeyFlag(SIGID_KEY10); + temp |= GetKeyFlag(SIGID_KEY1)<<1; + temp |= GetKeyFlag(SIGID_KEY2)<<0; +#else + LIN_msg_buf.FW = GetKeyFlag(SIGID_KEY13); + LIN_msg_buf.HG = GetKeyFlag(SIGID_KEY5)<<1|GetKeyFlag(SIGID_KEY6); + LIN_msg_buf.TT = GetKeyFlag(SIGID_KEY4)<<1|GetKeyFlag(SIGID_KEY3); + LIN_msg_buf.AM = GetKeyFlag(SIGID_KEY7)<<1|GetKeyFlag(SIGID_KEY8); + LIN_msg_buf.KB = GetKeyFlag(SIGID_KEY9)<<1|GetKeyFlag(SIGID_KEY11); + LIN_msg_buf.ZY = GetKeyFlag(SIGID_KEY10)<<1|GetKeyFlag(SIGID_KEY12); + temp |= GetKeyFlag(SIGID_KEY1)<<0; + temp |= GetKeyFlag(SIGID_KEY2)<<1; +#endif + LIN_msg_buf.REVERSE01 = LIN_msg_buf.KB?1:0; + + LIN_msg_buf.REVERSE4 = g_AdVal[0]>>8; + LIN_msg_buf.REVERSE5 = g_AdVal[0]&0xff; + LIN_msg_buf.REVERSE6 = g_AdVal[1]>>8; + LIN_msg_buf.REVERSE7 = g_AdVal[1]&0xff; + + for (i = 0; i < 8; i++) + { + g_txbuf1[i] = ((uint8_t *)(&LIN_msg_buf))[i]; + } + g_txbuf2[0] = temp; + g_txbuf2[1] = 0x0b; } diff --git a/app_Indie/usr/common/linslaveTask.c b/app_Indie/usr/common/linslaveTask.c index 95776b2..3a13d7e 100644 --- a/app_Indie/usr/common/linslaveTask.c +++ b/app_Indie/usr/common/linslaveTask.c @@ -295,33 +295,23 @@ void UnconditionalPublishedCmdsTxFinishedISR(uint8_t fid, uint8_t resvd) User defined published frame callback function which from LINS ISR please fill frame data[0-7] only, please don't do any changes on the left info except data[x]!!!! *///TODO +extern uint8_t g_txbuf1[8]; +extern uint8_t g_txbuf2[8]; void UnconditionalPublishedCmdsISR(LIN_Device_Frame_t *const frame) { /* feed buffer to frame */ + uint8_t i; if (frame->frame_id == UnconditionalCmdsTable[FID_TFJR_INDEX].frame_id){ /* status management frame */ -// lin_status_t status = ls_ifc_read_status(); -// frame->data[0] = (uint8_t)status.payload; -// frame->data[1] = LINS_GetPIDFromFID(status.pid); -// frame->data[2] = ls_read_error_code_log(); -// for (uint8_t i = 2U; i < 8U; i++){ -// frame->data[i] = 0xFFU; -// } - lin_status_t status = ls_ifc_read_status(); - frame->data[0] = (uint8_t)status.payload; - frame->data[1] = SAFM_TransferState(); - frame->data[2] = (uint8_t)SAFM_GetMotorcurrent(); - frame->data[3] = (uint8_t)SAFM_GetMotorcurrent()>>8; - frame->data[4] = (uint8_t)SAFM_GetMotorcurrent(); - frame->data[5] = (uint8_t)SAFM_GetMotorcurrent()>>8; - frame->data[6] = Motor_GetCurrentPosition(); - frame->data[7] = Motor_GetCurrentPosition() >> 8; + for (i = 0; i < 8; i++) + { + frame->data[i] = g_txbuf2[i]; + } }else if (frame->frame_id == UnconditionalCmdsTable[FID_KEY_INDEX].frame_id){ /* user defined data report */ - frame->data[0] = (APPL_GetLEDState()) | (eventTriggeredLedOn << 1U) | 0xF8U; - for (uint8_t i = 1U; i < LIN_BUFF_SIZE; i++){ - frame->data[i] = 0xFFU; + for (i = 1U; i < LIN_BUFF_SIZE; i++){ + frame->data[i] = g_txbuf1[i]; } }else{ /* intent to empty */ diff --git a/app_Indie/usr/common/systemInit.c b/app_Indie/usr/common/systemInit.c index 378cebb..cf64d44 100644 --- a/app_Indie/usr/common/systemInit.c +++ b/app_Indie/usr/common/systemInit.c @@ -31,12 +31,12 @@ void pmu_init(void); void gpios_init(void) { - 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); + GPIO_Init(IO_KEY3,GPIO_DIR_INPUT,GPIO_PULL_UP); + GPIO_Init(IO_KEY4,GPIO_DIR_INPUT,GPIO_PULL_UP); + GPIO_Init(IO_KEY5,GPIO_DIR_INPUT,GPIO_PULL_UP); + GPIO_Init(IO_KEY6,GPIO_DIR_INPUT,GPIO_PULL_UP); + GPIO_Init(IO_KEY7,GPIO_DIR_INPUT,GPIO_PULL_UP); + GPIO_Init(IO_KEY8,GPIO_DIR_INPUT,GPIO_PULL_UP); GPIO_Init(IO_LED1,GPIO_DIR_OUTPUT,GPIO_PULL_NONE); GPIO_Init(IO_LED2,GPIO_DIR_OUTPUT,GPIO_PULL_NONE);