From 53b057bb051a836cf64b27b3ea8b753f4fcd0faa Mon Sep 17 00:00:00 2001 From: sunbeam Date: Sat, 12 Oct 2024 15:36:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=B3=E4=BE=A7OK?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- K80.mtpj | 12 ++-- K80.rcpe | 12 ++-- appTask.c | 16 ++--- hwCtrl.c | 145 +++++++-------------------------------------- r_cg_cgc.c | 2 +- r_cg_cgc.h | 2 +- r_cg_cgc_user.c | 2 +- r_cg_macrodriver.h | 2 +- r_cg_port.c | 5 +- r_cg_port.h | 2 +- r_cg_port_user.c | 2 +- r_cg_serial.c | 2 +- r_cg_serial.h | 2 +- r_cg_serial_user.c | 2 +- r_cg_timer.c | 2 +- r_cg_timer.h | 2 +- r_cg_timer_user.c | 2 +- r_cg_userdefine.h | 2 +- r_cg_wdt.c | 2 +- r_cg_wdt.h | 2 +- r_cg_wdt_user.c | 2 +- r_main.c | 2 +- r_systeminit.c | 2 +- 23 files changed, 59 insertions(+), 167 deletions(-) diff --git a/K80.mtpj b/K80.mtpj index 0824e81..33aba31 100644 --- a/K80.mtpj +++ b/K80.mtpj @@ -3024,7 +3024,7 @@ </Effect> </IICA0> <ProjectName Name="PrjName" Text="K80" /> - <ProjectPath Name="PrjPath" Text="F:\FCB_project\temp\K80\code\K80_CODE" /> + <ProjectPath Name="PrjPath" Text="F:\FCB_project\temp\K67A\K67_CODE" /> <ProjectKind Name="PrjKind" Text="Project78K0R" /> <DeviceName Name="DeviceName" Fixed="" Text="RL78G12" /> <MCUName Name="MCUName" Text="RL78G12_20pin" /> @@ -3095,7 +3095,7 @@ <P20 Name="P20/ANI0/AVREFP" AltFunc="P20" Point="I/O" /> <P21 Name="P21/ANI1/AVREFM" AltFunc="P21" Point="I/O" /> <P22 Name="P22/ANI2" AltFunc="P22" Point="I/O" /> - <P23 Name="P23/ANI3" AltFunc="P23" Point="I/O" /> + <P23 Name="P23/ANI3" AltFunc="" Point="I/O" /> </Port2> <Port4 Chip="RL78G12_20pin,RL78G12_24pin" Pullup="true"> <P40 Name="P40/KR0/TOOL0" AltFunc="" Point="I/O" /> @@ -3108,7 +3108,7 @@ </Port6> <Port12 Chip="RL78G12_20pin,RL78G12_24pin"> <P121 Name="P121/KR3/X1" AltFunc="" Point="I" /> - <P122 Name="P122/KR2/X2/EXCLK" AltFunc="P122" Point="I" /> + <P122 Name="P122/KR2/X2/EXCLK" AltFunc="" Point="I" /> <P125 Name="P125/KR1/SI01/_RESET" Pullup="true" AltFunc="" Point="I" /> </Port12> <Port13> @@ -3885,14 +3885,14 @@ <setting name="Output_value" value="0" /> </P21> <P22> - <setting name="Operation" value="output" /> + <setting name="Operation" value="input" /> <setting name="Pull_up" value="unused" /> <setting name="TTL_buffer" value="unused" /> <setting name="N-ch_open-drain" value="unused" /> <setting name="Output_value" value="0" /> </P22> <P23> - <setting name="Operation" value="output" /> + <setting name="Operation" value="unused" /> <setting name="Pull_up" value="unused" /> <setting name="TTL_buffer" value="unused" /> <setting name="N-ch_open-drain" value="unused" /> @@ -3947,7 +3947,7 @@ <setting name="Output_value" value="0" /> </P121> <P122> - <setting name="Operation" value="input" /> + <setting name="Operation" value="unused" /> <setting name="Pull_up" value="unused" /> <setting name="TTL_buffer" value="unused" /> <setting name="N-ch_open-drain" value="unused" /> diff --git a/K80.rcpe b/K80.rcpe index 043a162..7516c8c 100644 --- a/K80.rcpe +++ b/K80.rcpe @@ -226,7 +226,7 @@ </Effect> </IICA0> <ProjectName Name="PrjName" Text="K80" /> - <ProjectPath Name="PrjPath" Text="F:\FCB_project\temp\K80\code\K80_CODE" /> + <ProjectPath Name="PrjPath" Text="F:\FCB_project\temp\K67A\K67_CODE" /> <ProjectKind Name="PrjKind" Text="Project78K0R" /> <DeviceName Name="DeviceName" Fixed="" Text="RL78G12" /> <MCUName Name="MCUName" Text="RL78G12_20pin" /> @@ -297,7 +297,7 @@ <P20 Name="P20/ANI0/AVREFP" AltFunc="P20" Point="I/O" /> <P21 Name="P21/ANI1/AVREFM" AltFunc="P21" Point="I/O" /> <P22 Name="P22/ANI2" AltFunc="P22" Point="I/O" /> - <P23 Name="P23/ANI3" AltFunc="P23" Point="I/O" /> + <P23 Name="P23/ANI3" AltFunc="" Point="I/O" /> </Port2> <Port4 Chip="RL78G12_20pin,RL78G12_24pin" Pullup="true"> <P40 Name="P40/KR0/TOOL0" AltFunc="" Point="I/O" /> @@ -310,7 +310,7 @@ </Port6> <Port12 Chip="RL78G12_20pin,RL78G12_24pin"> <P121 Name="P121/KR3/X1" AltFunc="" Point="I" /> - <P122 Name="P122/KR2/X2/EXCLK" AltFunc="P122" Point="I" /> + <P122 Name="P122/KR2/X2/EXCLK" AltFunc="" Point="I" /> <P125 Name="P125/KR1/SI01/_RESET" Pullup="true" AltFunc="" Point="I" /> </Port12> <Port13> @@ -1087,14 +1087,14 @@ <setting name="Output_value" value="0" /> </P21> <P22> - <setting name="Operation" value="output" /> + <setting name="Operation" value="input" /> <setting name="Pull_up" value="unused" /> <setting name="TTL_buffer" value="unused" /> <setting name="N-ch_open-drain" value="unused" /> <setting name="Output_value" value="0" /> </P22> <P23> - <setting name="Operation" value="output" /> + <setting name="Operation" value="unused" /> <setting name="Pull_up" value="unused" /> <setting name="TTL_buffer" value="unused" /> <setting name="N-ch_open-drain" value="unused" /> @@ -1149,7 +1149,7 @@ <setting name="Output_value" value="0" /> </P121> <P122> - <setting name="Operation" value="input" /> + <setting name="Operation" value="unused" /> <setting name="Pull_up" value="unused" /> <setting name="TTL_buffer" value="unused" /> <setting name="N-ch_open-drain" value="unused" /> diff --git a/appTask.c b/appTask.c index 4846412..f8877ca 100644 --- a/appTask.c +++ b/appTask.c @@ -179,13 +179,9 @@ void MsgPro(uint8_t len) switch (Rxdata[1]) { case 0x1a: - motor_state = 1; - break; case 0x1b: - motor_state = 2; - break; case 0x1c: - motor_state = 3; + motor_state = 1; break; case 0x1d: motor_state = 0; @@ -225,12 +221,8 @@ void keyLogic(uint8_t keyno) break; case KEY_AM: - motor_txstate = motor_state + 1; - if (motor_txstate > 3) - { - motor_txstate = 0; - } - else + motor_txstate = !motor_state; + if (motor_txstate != 0) { am_counter = 0; } @@ -281,7 +273,7 @@ void LED_Ctrl(void) { FanLED_Ctrl(fan_state); HeatLED_Ctrl(heat_state); - AnmoLED_Ctrl(motor_state); + AnmoLED_Ctrl(motor_state?1:0); } void AppTask(void) diff --git a/hwCtrl.c b/hwCtrl.c index 26227b2..ea15802 100644 --- a/hwCtrl.c +++ b/hwCtrl.c @@ -12,38 +12,34 @@ #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 P1_bit.no1 +#define LEDH3 P4_bit.no1 -#define LEDM1 P1_bit.no2 -#define LEDM2 P1_bit.no3 -#define LEDM3 P1_bit.no4 - -#define LEDF1 P4_bit.no1 -#define LEDF2 P2_bit.no3 -#define LEDF3 P2_bit.no2 +#define LEDM1 P2_bit.no1 #else //LEFT -#define LEDH1 P4_bit.no2 -#define LEDH2 P1_bit.no0 -#define LEDH3 P1_bit.no1 +#define LEDH1 P1_bit.no1 +#define LEDH2 P1_bit.no2 +#define LEDH3 P1_bit.no3 -#define LEDF1 P1_bit.no2 -#define LEDF2 P1_bit.no3 -#define LEDF3 P1_bit.no4 +#define LEDF1 P4_bit.no2 +#define LEDF2 P1_bit.no0 +#define LEDF3 P4_bit.no1 -#define LEDM1 P4_bit.no1 -#define LEDM2 P2_bit.no3 -#define LEDM3 P2_bit.no2 +#define LEDM1 P1_bit.no4 #endif -#define IO_KEY1 P2_bit.no0 -#define IO_KEY2 P2_bit.no1 -#define IO_KEY5 P12_bit.no2 -#define IO_KEY6 P13_bit.no7 +#define IO_KEYFAN P2_bit.no0 +#define IO_KEYANMO P2_bit.no1 +#define IO_KEYHEAT P2_bit.no2 + @@ -51,87 +47,15 @@ extern uint16_t g_AdVal[3]; -#if BOARD == K74R -void FanLED_Ctrl(uint8_t state) -{ - switch (state) - { - case 0: - LEDF1 = LED_OFF; - LEDF2 = LED_ON; - LEDF3 = LED_ON; - break; - case 3: - LEDF1 = LED_ON; - LEDF2 = LED_ON; - LEDF3 = LED_ON; - break; - case 2: - LEDF1 = LED_ON; - LEDF2 = LED_OFF; - LEDF3 = LED_ON; - break; - case 1: - LEDF1 = LED_ON; - LEDF2 = LED_OFF; - LEDF3 = LED_OFF; - break; - default: - break; - } -} void AnmoLED_Ctrl(uint8_t state) { switch (state) { case 0: LEDM1 = LED_OFF; - LEDM2 = LED_OFF; - LEDM3 = LED_OFF; - break; - case 3: - LEDM1 = LED_ON; - LEDM2 = LED_OFF; - LEDM3 = LED_OFF; - break; - case 2: - LEDM1 = LED_ON; - LEDM2 = LED_ON; - LEDM3 = LED_OFF; break; case 1: LEDM1 = LED_ON; - LEDM2 = LED_ON; - LEDM3 = LED_ON; - break; - default: - break; - } -} -#else -void AnmoLED_Ctrl(uint8_t state) -{ - switch (state) - { - case 0: - LEDM1 = LED_OFF; - LEDM2 = LED_ON; - LEDM3 = LED_ON; - break; - case 3: - LEDM1 = LED_ON; - LEDM2 = LED_ON; - LEDM3 = LED_ON; - break; - case 2: - LEDM1 = LED_ON; - LEDM2 = LED_OFF; - LEDM3 = LED_ON; - break; - case 1: - LEDM1 = LED_ON; - LEDM2 = LED_OFF; - LEDM3 = LED_OFF; break; default: break; @@ -165,7 +89,7 @@ void FanLED_Ctrl(uint8_t state) break; } } -#endif + void HeatLED_Ctrl(uint8_t state) { @@ -197,43 +121,20 @@ void HeatLED_Ctrl(uint8_t state) } - - -#define KEY_AD_V1 690 -#define KEY_AD_V2 510 -#define KEY_AD_TH 50 -#define KEY5_AD_V1 KEY_AD_TH //0 -#define KEY5_AD_V2 254 -#define KEY5_AD_V3 455 -#define KEY5_AD_V4 658 -#define KEY5_AD_V5 902 uint8_t GetKeyState(uint8_t keyno) { switch (keyno) { -#if BOARD == K74R - //RIGHT - case KEY_FAN: - return IO_KEY1==0?1:0; + + case KEY_AM: + return IO_KEYANMO==0?1:0; break; case KEY_JR: - return IO_KEY2==0?1:0; - break; - case KEY_AM: - return (IO_KEY5==0)?1:0; - break; -#else - //left - case KEY_AM: - return IO_KEY1==0?1:0; - break; - case KEY_JR: - return IO_KEY2==0?1:0; + return IO_KEYHEAT==0?1:0; break; case KEY_FAN: - return (IO_KEY5==0)?1:0; + return IO_KEYFAN==0?1:0; break; -#endif default: return 0; break; diff --git a/r_cg_cgc.c b/r_cg_cgc.c index b7144ac..702ba15 100644 --- a/r_cg_cgc.c +++ b/r_cg_cgc.c @@ -23,7 +23,7 @@ * Device(s) : R5F10268 * Tool-Chain : CCRL * Description : This file implements device driver for CGC module. -* Creation Date: 2024-05-24 +* Creation Date: 2024-10-10 ***********************************************************************************************************************/ /*********************************************************************************************************************** diff --git a/r_cg_cgc.h b/r_cg_cgc.h index a141060..e96d965 100644 --- a/r_cg_cgc.h +++ b/r_cg_cgc.h @@ -23,7 +23,7 @@ * Device(s) : R5F10268 * Tool-Chain : CCRL * Description : This file implements device driver for CGC module. -* Creation Date: 2024-05-24 +* Creation Date: 2024-10-10 ***********************************************************************************************************************/ #ifndef CGC_H diff --git a/r_cg_cgc_user.c b/r_cg_cgc_user.c index dee2715..a89f536 100644 --- a/r_cg_cgc_user.c +++ b/r_cg_cgc_user.c @@ -23,7 +23,7 @@ * Device(s) : R5F10268 * Tool-Chain : CCRL * Description : This file implements device driver for CGC module. -* Creation Date: 2024-05-24 +* Creation Date: 2024-10-10 ***********************************************************************************************************************/ /*********************************************************************************************************************** diff --git a/r_cg_macrodriver.h b/r_cg_macrodriver.h index 1ced8ce..bca92fb 100644 --- a/r_cg_macrodriver.h +++ b/r_cg_macrodriver.h @@ -23,7 +23,7 @@ * Device(s) : R5F10268 * Tool-Chain : CCRL * Description : This file implements general head file. -* Creation Date: 2024-05-24 +* Creation Date: 2024-10-10 ***********************************************************************************************************************/ #ifndef STATUS_H diff --git a/r_cg_port.c b/r_cg_port.c index b6f0f30..bbe5dd2 100644 --- a/r_cg_port.c +++ b/r_cg_port.c @@ -23,7 +23,7 @@ * Device(s) : R5F10268 * Tool-Chain : CCRL * Description : This file implements device driver for PORT module. -* Creation Date: 2024-05-24 +* Creation Date: 2024-10-10 ***********************************************************************************************************************/ /*********************************************************************************************************************** @@ -56,14 +56,13 @@ Global variables and functions void R_PORT_Create(void) { P1 = _01_Pn0_OUTPUT_1 | _02_Pn1_OUTPUT_1 | _04_Pn2_OUTPUT_1 | _08_Pn3_OUTPUT_1 | _10_Pn4_OUTPUT_1; - P2 = _00_Pn2_OUTPUT_0 | _00_Pn3_OUTPUT_0; P4 = _02_Pn1_OUTPUT_1 | _04_Pn2_OUTPUT_1; PMC1 = _00_PMCn0_DI_ON | _00_PMCn1_DI_ON | _00_PMCn2_DI_ON | _00_PMCn3_DI_ON | _00_PMCn4_DI_ON | _E0_PMC1_DEFAULT; PMC4 = _00_PMCn1_DI_ON | _00_PMCn2_DI_ON | _F9_PMC4_DEFAULT; ADPC = _01_ADPC_DI_ON; PM1 = _00_PMn0_MODE_OUTPUT | _00_PMn1_MODE_OUTPUT | _00_PMn2_MODE_OUTPUT | _00_PMn3_MODE_OUTPUT | _00_PMn4_MODE_OUTPUT | _E0_PM1_DEFAULT; - PM2 = _01_PMn0_MODE_INPUT | _02_PMn1_MODE_INPUT | _00_PMn2_MODE_OUTPUT | _00_PMn3_MODE_OUTPUT | _F0_PM2_DEFAULT; + PM2 = _01_PMn0_MODE_INPUT | _02_PMn1_MODE_INPUT | _04_PMn2_MODE_INPUT | _08_PMn3_NOT_USE | _F0_PM2_DEFAULT; PM4 = _01_PMn0_NOT_USE | _00_PMn1_MODE_OUTPUT | _00_PMn2_MODE_OUTPUT | _F8_PM4_DEFAULT; } diff --git a/r_cg_port.h b/r_cg_port.h index 89e2dfe..7e06665 100644 --- a/r_cg_port.h +++ b/r_cg_port.h @@ -23,7 +23,7 @@ * Device(s) : R5F10268 * Tool-Chain : CCRL * Description : This file implements device driver for PORT module. -* Creation Date: 2024-05-24 +* Creation Date: 2024-10-10 ***********************************************************************************************************************/ #ifndef PORT_H diff --git a/r_cg_port_user.c b/r_cg_port_user.c index 61653e1..2857bbc 100644 --- a/r_cg_port_user.c +++ b/r_cg_port_user.c @@ -23,7 +23,7 @@ * Device(s) : R5F10268 * Tool-Chain : CCRL * Description : This file implements device driver for PORT module. -* Creation Date: 2024-05-24 +* Creation Date: 2024-10-10 ***********************************************************************************************************************/ /*********************************************************************************************************************** diff --git a/r_cg_serial.c b/r_cg_serial.c index 5a2845b..4b24cda 100644 --- a/r_cg_serial.c +++ b/r_cg_serial.c @@ -23,7 +23,7 @@ * Device(s) : R5F10268 * Tool-Chain : CCRL * Description : This file implements device driver for Serial module. -* Creation Date: 2024-05-24 +* Creation Date: 2024-10-10 ***********************************************************************************************************************/ /*********************************************************************************************************************** diff --git a/r_cg_serial.h b/r_cg_serial.h index 69ed97d..86ddb38 100644 --- a/r_cg_serial.h +++ b/r_cg_serial.h @@ -23,7 +23,7 @@ * Device(s) : R5F10268 * Tool-Chain : CCRL * Description : This file implements device driver for Serial module. -* Creation Date: 2024-05-24 +* Creation Date: 2024-10-10 ***********************************************************************************************************************/ #ifndef SERIAL_H diff --git a/r_cg_serial_user.c b/r_cg_serial_user.c index 03fb0a2..bf66694 100644 --- a/r_cg_serial_user.c +++ b/r_cg_serial_user.c @@ -23,7 +23,7 @@ * Device(s) : R5F10268 * Tool-Chain : CCRL * Description : This file implements device driver for Serial module. -* Creation Date: 2024-05-24 +* Creation Date: 2024-10-10 ***********************************************************************************************************************/ /*********************************************************************************************************************** diff --git a/r_cg_timer.c b/r_cg_timer.c index 218dbe9..859276e 100644 --- a/r_cg_timer.c +++ b/r_cg_timer.c @@ -23,7 +23,7 @@ * Device(s) : R5F10268 * Tool-Chain : CCRL * Description : This file implements device driver for TAU module. -* Creation Date: 2024-05-24 +* Creation Date: 2024-10-10 ***********************************************************************************************************************/ /*********************************************************************************************************************** diff --git a/r_cg_timer.h b/r_cg_timer.h index aded12b..89e141f 100644 --- a/r_cg_timer.h +++ b/r_cg_timer.h @@ -23,7 +23,7 @@ * Device(s) : R5F10268 * Tool-Chain : CCRL * Description : This file implements device driver for TAU module. -* Creation Date: 2024-05-24 +* Creation Date: 2024-10-10 ***********************************************************************************************************************/ #ifndef TAU_H diff --git a/r_cg_timer_user.c b/r_cg_timer_user.c index b8b2a7b..25b9ba1 100644 --- a/r_cg_timer_user.c +++ b/r_cg_timer_user.c @@ -23,7 +23,7 @@ * Device(s) : R5F10268 * Tool-Chain : CCRL * Description : This file implements device driver for TAU module. -* Creation Date: 2024-05-24 +* Creation Date: 2024-10-10 ***********************************************************************************************************************/ /*********************************************************************************************************************** diff --git a/r_cg_userdefine.h b/r_cg_userdefine.h index c549e0a..c852ee1 100644 --- a/r_cg_userdefine.h +++ b/r_cg_userdefine.h @@ -23,7 +23,7 @@ * Device(s) : R5F10268 * Tool-Chain : CCRL * Description : This file includes user definition. -* Creation Date: 2024-05-24 +* Creation Date: 2024-10-10 ***********************************************************************************************************************/ #ifndef _USER_DEF_H diff --git a/r_cg_wdt.c b/r_cg_wdt.c index 5b43ee0..0dce880 100644 --- a/r_cg_wdt.c +++ b/r_cg_wdt.c @@ -23,7 +23,7 @@ * Device(s) : R5F10268 * Tool-Chain : CCRL * Description : This file implements device driver for WDT module. -* Creation Date: 2024-05-24 +* Creation Date: 2024-10-10 ***********************************************************************************************************************/ /*********************************************************************************************************************** diff --git a/r_cg_wdt.h b/r_cg_wdt.h index 99163f4..54c32ea 100644 --- a/r_cg_wdt.h +++ b/r_cg_wdt.h @@ -23,7 +23,7 @@ * Device(s) : R5F10268 * Tool-Chain : CCRL * Description : This file implements device driver for WDT module. -* Creation Date: 2024-05-24 +* Creation Date: 2024-10-10 ***********************************************************************************************************************/ #ifndef WDT_H diff --git a/r_cg_wdt_user.c b/r_cg_wdt_user.c index f1fa65e..e7dc61e 100644 --- a/r_cg_wdt_user.c +++ b/r_cg_wdt_user.c @@ -23,7 +23,7 @@ * Device(s) : R5F10268 * Tool-Chain : CCRL * Description : This file implements device driver for WDT module. -* Creation Date: 2024-05-24 +* Creation Date: 2024-10-10 ***********************************************************************************************************************/ /*********************************************************************************************************************** diff --git a/r_main.c b/r_main.c index 626a703..3a3b5cd 100644 --- a/r_main.c +++ b/r_main.c @@ -23,7 +23,7 @@ * Device(s) : R5F10268 * Tool-Chain : CCRL * Description : This file implements main function. -* Creation Date: 2024-05-24 +* Creation Date: 2024-10-10 ***********************************************************************************************************************/ /*********************************************************************************************************************** diff --git a/r_systeminit.c b/r_systeminit.c index a220cbb..c4b2139 100644 --- a/r_systeminit.c +++ b/r_systeminit.c @@ -23,7 +23,7 @@ * Device(s) : R5F10268 * Tool-Chain : CCRL * Description : This file implements system initializing function. -* Creation Date: 2024-05-24 +* Creation Date: 2024-10-10 ***********************************************************************************************************************/ /***********************************************************************************************************************