Module | File | Macro | Function | Default | Status |
@@ -52,37 +52,60 @@
| | | void R_PORT_Create_UserInit(void) | R_PORT_Create_UserInit | Unused |
| r_cg_port.h | | | r_cg_port.h | Used |
Interrupt | | | | | |
- | r_cg_intc.c | | | r_cg_intc.c | Unused |
+ | r_cg_intc.c | | | r_cg_intc.c | Used |
| | INTP | | | |
- | | | void R_INTC_Create(void) | R_INTC_Create | Unused |
+ | | | void R_INTC_Create(void) | R_INTC_Create | Used |
| | INTP0 | | | |
- | | | void R_INTC0_Start(void) | R_INTC0_Start | Unused |
- | | | void R_INTC0_Stop(void) | R_INTC0_Stop | Unused |
+ | | | void R_INTC0_Start(void) | R_INTC0_Start | Used |
+ | | | void R_INTC0_Stop(void) | R_INTC0_Stop | Used |
| | INTP1 | | | |
- | | | void R_INTC1_Start(void) | R_INTC1_Start | Unused |
- | | | void R_INTC1_Stop(void) | R_INTC1_Stop | Unused |
+ | | | void R_INTC1_Start(void) | R_INTC1_Start | Used |
+ | | | void R_INTC1_Stop(void) | R_INTC1_Stop | Used |
| | INTP2 | | | |
- | | | void R_INTC2_Start(void) | R_INTC2_Start | Unused |
- | | | void R_INTC2_Stop(void) | R_INTC2_Stop | Unused |
+ | | | void R_INTC2_Start(void) | R_INTC2_Start | Used |
+ | | | void R_INTC2_Stop(void) | R_INTC2_Stop | Used |
| | INTP3 | | | |
| | | void R_INTC3_Start(void) | R_INTC3_Start | Unused |
| | | void R_INTC3_Stop(void) | R_INTC3_Stop | Unused |
| | INTP4 | | | |
- | | | void R_INTC4_Start(void) | R_INTC4_Start | Unused |
- | | | void R_INTC4_Stop(void) | R_INTC4_Stop | Unused |
+ | | | void R_INTC4_Start(void) | R_INTC4_Start | Used |
+ | | | void R_INTC4_Stop(void) | R_INTC4_Stop | Used |
| | INTP5 | | | |
| | | void R_INTC5_Start(void) | R_INTC5_Start | Unused |
| | | void R_INTC5_Stop(void) | R_INTC5_Stop | Unused |
- | r_cg_intc_user.c | | | r_cg_intc_user.c | Unused |
+ | | INTP6 | | | |
+ | | | void R_INTC6_Start(void) | R_INTC6_Start | Used |
+ | | | void R_INTC6_Stop(void) | R_INTC6_Stop | Used |
+ | | INTP7 | | | |
+ | | | void R_INTC7_Start(void) | R_INTC7_Start | Used |
+ | | | void R_INTC7_Stop(void) | R_INTC7_Stop | Used |
+ | | INTP8 | | | |
+ | | | void R_INTC8_Start(void) | R_INTC8_Start | Used |
+ | | | void R_INTC8_Stop(void) | R_INTC8_Stop | Used |
+ | | INTP9 | | | |
+ | | | void R_INTC9_Start(void) | R_INTC9_Start | Unused |
+ | | | void R_INTC9_Stop(void) | R_INTC9_Stop | Unused |
+ | | KEY | | | |
+ | | | void R_KEY_Create(void) | R_KEY_Create | Unused |
+ | | | void R_KEY_Start(void) | R_KEY_Start | Unused |
+ | | | void R_KEY_Stop(void) | R_KEY_Stop | Unused |
+ | r_cg_intc_user.c | | | r_cg_intc_user.c | Used |
| | INTP | | | |
| | | void R_INTC_Create_UserInit(void) | R_INTC_Create_UserInit | Unused |
- | | | __interrupt static void r_intc0_interrupt(void) | r_intc0_interrupt | Unused |
- | | | __interrupt static void r_intc1_interrupt(void) | r_intc1_interrupt | Unused |
- | | | __interrupt static void r_intc2_interrupt(void) | r_intc2_interrupt | Unused |
+ | | | __interrupt static void r_intc0_interrupt(void) | r_intc0_interrupt | Used |
+ | | | __interrupt static void r_intc1_interrupt(void) | r_intc1_interrupt | Used |
+ | | | __interrupt static void r_intc2_interrupt(void) | r_intc2_interrupt | Used |
| | | __interrupt static void r_intc3_interrupt(void) | r_intc3_interrupt | Unused |
- | | | __interrupt static void r_intc4_interrupt(void) | r_intc4_interrupt | Unused |
+ | | | __interrupt static void r_intc4_interrupt(void) | r_intc4_interrupt | Used |
| | | __interrupt static void r_intc5_interrupt(void) | r_intc5_interrupt | Unused |
- | r_cg_intc.h | | | r_cg_intc.h | Unused |
+ | | | __interrupt static void r_intc6_interrupt(void) | r_intc6_interrupt | Used |
+ | | | __interrupt static void r_intc7_interrupt(void) | r_intc7_interrupt | Used |
+ | | | __interrupt static void r_intc8_interrupt(void) | r_intc8_interrupt | Used |
+ | | | __interrupt static void r_intc9_interrupt(void) | r_intc9_interrupt | Unused |
+ | | KEY | | | |
+ | | | void R_KEY_Create_UserInit(void) | R_KEY_Create_UserInit | Unused |
+ | | | __interrupt static void r_key_interrupt(void) | r_key_interrupt | Unused |
+ | r_cg_intc.h | | | r_cg_intc.h | Used |
Serial | | | | | |
| r_cg_serial.c | | | r_cg_serial.c | Unused |
| | SAU0 | | | |
@@ -140,6 +163,13 @@
| | | MD_STATUS R_CSI10_Send(uint8_t const * tx_buf, uint16_t tx_num) | R_CSI10_Send | Unused |
| | | MD_STATUS R_CSI10_Receive(uint8_t const * rx_buf, uint16_t rx_num) | R_CSI10_Receive | Unused |
| | | MD_STATUS R_CSI10_Send_Receive(uint8_t const * tx_buf, uint16_t tx_num, uint8_t const * rx_buf) | R_CSI10_Send_Receive | Unused |
+ | | CSI11 | | | |
+ | | | void R_CSI11_Create(void) | R_CSI11_Create | Unused |
+ | | | void R_CSI11_Start(void) | R_CSI11_Start | Unused |
+ | | | void R_CSI11_Stop(void) | R_CSI11_Stop | Unused |
+ | | | MD_STATUS R_CSI11_Send(uint8_t const * tx_buf, uint16_t tx_num) | R_CSI11_Send | Unused |
+ | | | MD_STATUS R_CSI11_Receive(uint8_t const * rx_buf, uint16_t rx_num) | R_CSI11_Receive | Unused |
+ | | | MD_STATUS R_CSI11_Send_Receive(uint8_t const * tx_buf, uint16_t tx_num, uint8_t const * rx_buf) | R_CSI11_Send_Receive | Unused |
| | IIC10 | | | |
| | | void R_IIC10_Create(void) | R_IIC10_Create | Unused |
| | | void R_IIC10_Master_Send(uint8_t adr, uint8_t const * tx_buf, uint16_t txnum) | R_IIC10_Master_Send | Unused |
@@ -147,6 +177,13 @@
| | | void R_IIC10_Stop(void) | R_IIC10_Stop | Unused |
| | | void R_IIC10_StartCondition(void) | R_IIC10_StartCondition | Unused |
| | | void R_IIC10_StopCondition(void) | R_IIC10_StopCondition | Unused |
+ | | IIC11 | | | |
+ | | | void R_IIC11_Create(void) | R_IIC11_Create | Unused |
+ | | | void R_IIC11_Master_Send(uint8_t adr, uint8_t const * tx_buf, uint16_t txnum) | R_IIC11_Master_Send | Unused |
+ | | | void R_IIC11_Master_Receive(uint8_t adr, uint8_t const * rx_buf, uint16_t rx_num) | R_IIC11_Master_Receive | Unused |
+ | | | void R_IIC11_Stop(void) | R_IIC11_Stop | Unused |
+ | | | void R_IIC11_StartCondition(void) | R_IIC11_StartCondition | Unused |
+ | | | void R_IIC11_StopCondition(void) | R_IIC11_StopCondition | Unused |
| | IICA0 | | | |
| | | void R_IICA0_Create(void) | R_IICA0_Create | Unused |
| | | MD_STATUS R_IICA0_Master_Send(uint8_t adr, uint8_t * const tx_buf, uint16_t tx_num, uint8_t wait) | R_IICA0_Master_Send | Unused |
@@ -202,11 +239,21 @@
| | | void r_csi10_callback_receiveend(void) | r_csi10_callback_receiveend | Unused |
| | | void r_csi10_callback_error(uint16_t err_type) | r_csi10_callback_error | Unused |
| | | void r_csi10_callback_sendend(void) | r_csi10_callback_sendend | Unused |
+ | | CSI11 | | | |
+ | | | __interrupt void r_csi11_interrupt(void) | r_csi11_interrupt | Unused |
+ | | | void r_csi11_callback_receiveend(void) | r_csi11_callback_receiveend | Unused |
+ | | | void r_csi11_callback_error(uint16_t err_type) | r_csi11_callback_error | Unused |
+ | | | void r_csi11_callback_sendend(void) | r_csi11_callback_sendend | Unused |
| | IIC10 | | | |
| | | __interrupt void r_iic10_interrupt(void) | r_iic10_interrupt | Unused |
| | | void r_iic10_callback_master_receiveend(void) | r_iic10_callback_master_receiveend | Unused |
| | | void r_iic10_callback_master_sendend(void) | r_iic10_callback_master_sendend | Unused |
| | | void r_iic10_callback_master_error(MD_STATUS flag) | r_iic10_callback_master_error | Unused |
+ | | IIC11 | | | |
+ | | | __interrupt void r_iic11_interrupt(void) | r_iic11_interrupt | Unused |
+ | | | void r_iic11_callback_master_receiveend(void) | r_iic11_callback_master_receiveend | Unused |
+ | | | void r_iic11_callback_master_sendend(void) | r_iic11_callback_master_sendend | Unused |
+ | | | void r_iic11_callback_master_error(MD_STATUS flag) | r_iic11_callback_master_error | Unused |
| | IICA0 | | | |
| | | void R_IICA0_Create_UserInit(void) | R_IICA0_Create_UserInit | Unused |
| | | __interrupt static r_iica0_interrupt(void) | r_iica0_interrupt | Unused |
@@ -417,6 +464,16 @@
| r_cg_dtc_user.c | | | r_cg_dtc_user.c | Unused |
| | | void R_DTC_Create_UserInit(void) | R_DTC_Create_UserInit | Unused |
| r_cg_dtc.h | | | r_cg_dtc.h | Unused |
+Clock Output/Buzzer Output | | | | | |
+ | r_cg_pclbuz.c | | | r_cg_pclbuz.c | Unused |
+ | | PCLBUZ0 | | | |
+ | | | void R_PCLBUZ0_Create(void) | R_PCLBUZ0_Create | Unused |
+ | | | void R_PCLBUZ0_Start(void) | R_PCLBUZ0_Start | Unused |
+ | | | void R_PCLBUZ0_Stop(void) | R_PCLBUZ0_Stop | Unused |
+ | r_cg_pclbuz_user.c | | | r_cg_pclbuz_user.c | Unused |
+ | | PCLBUZ0 | | | |
+ | | | void R_PCLBUZ0_Create_UserInit(void) | R_PCLBUZ0_Create_UserInit | Unused |
+ | r_cg_pclbuz.h | | | r_cg_pclbuz.h | Unused |
Voltage Detector | | | | | |
| r_cg_lvd.c | | | r_cg_lvd.c | Unused |
| | | void R_LVD_Create(void) | R_LVD_Create | Unused |
diff --git a/ECU_APP/macro.html b/ECU_APP/macro.html
index 4534d41..7dcbcc9 100644
--- a/ECU_APP/macro.html
+++ b/ECU_APP/macro.html
@@ -4,13 +4,29 @@
Macro list
- MCU name: RL78/F13(ROM:128KB)
Chip name: R5F10BBG
+ MCU name: RL78/F13(ROM:128KB)
Chip name: R5F10BGG
Module | Macro | Sub | Setting | Status |
Clock Generator | | | | Used |
| CGC | | | Used |
+ | | | PIOR00 / TI00 | P17 |
+ | | | PIOR01 / TI01 | P30 |
+ | | | PIOR02 / TI02 | P16 |
+ | | | PIOR03 / TI03 | P125 |
+ | | | PIOR04 / TI04 | P13 |
+ | | | PIOR05 / TI05 | P15 |
+ | | | PIOR06 / TI06 | P14 |
+ | | | PIOR07 / TI07 | P120 |
+ | | | PIOR10 / TO00 | P17 |
+ | | | PIOR11 / TO01 | P30 |
+ | | | PIOR12 / TO02 | P16 |
+ | | | PIOR13 / TO03 | P125 |
+ | | | PIOR14 / TO04 | P13 |
+ | | | PIOR15 / TO05 | P15 |
+ | | | PIOR16 / TO06 | P14 |
+ | | | PIOR17 / TO07 | P120 |
| | | PIOR40 / RXD0/SI00/SDA00 | P16 |
| | | PIOR40 / TXD0/SO00 | P15 |
| | | PIOR40 / _SCK00/SCL00 | P17 |
@@ -28,17 +44,25 @@
| | | PIOR42 / _SCK10 | P10 |
| | | PIOR42 / SCL10 | P10 |
| | | PIOR42 / SDA10 | P11 |
+ | | | PIOR43 / SO11 | P72 |
+ | | | PIOR43 / SI11 | P70 |
+ | | | PIOR43 / _SCK11 | P71 |
+ | | | PIOR43 / _SSI11 | P73 |
+ | | | PIOR43 / SCL11 | P71 |
+ | | | PIOR43 / SDA11 | P70 |
| | | PIOR44 / LTxD0 | P13 |
| | | PIOR44 / LRxD0 | P14 |
| | | PIOR46 / CTxD0 | P10 |
| | | PIOR46 / CRxD0 | P11 |
- | | | PIOR50 / KR0 | - |
- | | | PIOR50 / KR1 | - |
- | | | PIOR50 / KR2 | - |
- | | | PIOR50 / KR3 | - |
+ | | | PIOR50 / KR0 | P70 |
+ | | | PIOR50 / KR1 | P71 |
+ | | | PIOR50 / KR2 | P72 |
+ | | | PIOR50 / KR3 | P73 |
| | | PIOR50 / KR4 | - |
| | | PIOR50 / KR5 | - |
- | | | PIOR52 / INTP2 | P30 |
+ | | | PIOR50 / KR6 | - |
+ | | | PIOR50 / KR7 | - |
+ | | | PIOR52 / INTP2 | P31 |
| | | PIOR53 / INTP3 | P17 |
| | | PIOR70 / TRDCLK0/TRDIOA0 | P13 |
| | | PIOR71 / TRDIOB0 | P125 |
@@ -55,6 +79,7 @@
| | | fPLL frequency | 32(MHz) |
| | | Lockup wait counter | 64 (2^9/fMAIN)(s) |
| | | PLL output for main system clock (fMP) setting | 32 (fPLL)(MHz) |
+ | | | fSUB operation | Unused |
| | | Internal low-speed oscillation clock (fIL) setting | 15(kHz) |
| | | Low speed on-chip oscillator clock (fSL) setting | 15 (fIL)(kHz) |
| | | WDT operation clock (fWDT) setting | 15(kHz) |
@@ -78,41 +103,32 @@
| | | Setting of data flash library | Unused |
Port | | | | Used |
| PORT | | | Used |
+ | | P00 | | |
+ | | | Mode | Out |
+ | | | output value | 0 |
| | P12 | | |
+ | | | Mode | In |
+ | | | Pull-up | Unused |
+ | | P13 | | |
| | | Mode | Out |
| | | N-ch | Unused |
| | | output value | 0 |
- | | P13 | | |
- | | | Mode | In |
- | | | Pull-up | Unused |
- | | | Schmitt1 buffer | Used |
| | P14 | | |
- | | | Mode | In |
- | | | Pull-up | Unused |
- | | | Schmitt1 buffer | Used |
+ | | | Mode | Out |
+ | | | N-ch | Unused |
+ | | | output value | 0 |
| | P15 | | |
- | | | Mode | In |
- | | | Pull-up | Unused |
- | | P16 | | |
- | | | Mode | In |
- | | | Pull-up | Unused |
- | | | Schmitt1 buffer | Used |
+ | | | Mode | Out |
+ | | | N-ch | Unused |
+ | | | output value | 0 |
| | P17 | | |
- | | | Mode | In |
- | | | Pull-up | Unused |
- | | | Schmitt1 buffer | Used |
+ | | | Mode | Out |
+ | | | N-ch | Unused |
+ | | | output value | 0 |
| | P30 | | |
| | | Mode | In |
| | | Pull-up | Unused |
| | | Schmitt1 buffer | Used |
- | | P34 | | |
- | | | Mode | In |
- | | P40 | | |
- | | | Mode | Assistant function |
- | | | Pull-up | Unused |
- | | P41 | | |
- | | | Mode | In |
- | | | Pull-up | Unused |
| | P60 | | |
| | | Mode | In |
| | | Pull-up | Unused |
@@ -129,26 +145,45 @@
| | | Mode | In |
| | | Pull-up | Unused |
| | | Schmitt1 buffer | Used |
- | | P80 | | |
- | | | Mode | In |
- | | P81 | | |
- | | | Mode | In |
- | | P82 | | |
- | | | Mode | In |
- | | P83 | | |
- | | | Mode | In |
- | | P84 | | |
- | | | Mode | In |
- | | P85 | | |
- | | | Mode | In |
- | | P120 | | |
- | | | Mode | In |
- | | | Pull-up | Unused |
- | | P125 | | |
- | | | Mode | In |
- | | | Pull-up | Unused |
- | | | Schmitt1 buffer | Used |
-Interrupt | | | | Unused |
+ | | P72 | | |
+ | | | Mode | Out |
+ | | | N-ch | Unused |
+ | | | output value | 0 |
+ | | P73 | | |
+ | | | Mode | Out |
+ | | | output value | 0 |
+ | | P130 | | |
+ | | | Mode | Out |
+ | | | output value | 0 |
+ | | P140 | | |
+ | | | Mode | Out |
+ | | | output value | 0 |
+Interrupt | | | | Used |
+ | INTP | | | Used |
+ | | INTP0 | | |
+ | | | Valid edge | Rising |
+ | | | Priority | Low |
+ | | INTP1 | | |
+ | | | Valid edge | Rising |
+ | | | Priority | Low |
+ | | INTP2 | | |
+ | | | Valid edge | Rising |
+ | | | Priority | Low |
+ | | INTP4 | | |
+ | | | Valid edge | Rising |
+ | | | Priority | Low |
+ | | | Requests to the interrupt control circuit are enabled | Used |
+ | | INTP6 | | |
+ | | | Valid edge | Rising |
+ | | | Priority | Low |
+ | | | Requests to the interrupt control circuit are enabled | Used |
+ | | INTP7 | | |
+ | | | Valid edge | Rising |
+ | | | Priority | Low |
+ | | INTP8 | | |
+ | | | Valid edge | Falling |
+ | | | Priority | Low |
+ | KEY | | | Unused |
Serial | | | | Unused |
A/D Converter | | | | Used |
| ADC | | | Used |
@@ -157,14 +192,14 @@
| | | Resolution setting | 10 bits |
| | | VREF(+) setting | VDD |
| | | VREF(-) setting | VSS |
- | | | Trigger mode setting | Hardware trigger no wait mode |
- | | | Hardware trigger no wait mode | INTTM01 |
+ | | | Trigger mode setting | Hardware trigger wait mode |
+ | | | Hardware trigger wait mode | INTTM01 |
| | | Operation mode setting | One-shot select mode |
- | | | ANI0 - ANI7 analog input selection | ANI0 |
+ | | | ANI0 - ANI12 analog input selection | ANI0 - ANI10 |
| | | ANI24 - ANI25 analog input selection | ANI26, ANI27, ANI28, ANI29, ANI30 |
- | | | A/D channel selection | ANI0 |
+ | | | A/D channel selection | ANI2 |
| | | Conversion time mode | Normal 1 |
- | | | Conversion time | 38 (1216/fCLK)(s) |
+ | | | Conversion time | 27 (864/fCLK)(s) |
| | | Conversion result upper/lower bound value setting | Generates an interrupt request (INTAD) when ADLL ADCRH ADUL |
| | | Upper bound (ADUL) value | 255 |
| | | Lower bound (ADLL) value | 0 |
@@ -181,7 +216,7 @@
| | Channel1 | | |
| | | Channel 1 | Interval timer |
| | | Operation mode setting | 16 bits |
- | | | Interval value (16 bits) | 1000s, (Actual value: 1000) |
+ | | | Interval value (16 bits) | 100s, (Actual value: 100) |
| | | Generates INTTM01 when counting is started | Unused |
| | | End of timer channel 1 count, generate an interrupt (INTTM01) | Used |
| | | Priority (INTTM01) | Low |
@@ -192,6 +227,7 @@
Watchdog Timer | | | | Unused |
Real-time Clock | | | | Unused |
Data Transfer Controller | | | | Unused |
+Clock Output/Buzzer Output | | | | Unused |
Voltage Detector | | | | Used |
| LVD | | | Used |
| | | Low voltage detector operation setting | Used |
diff --git a/ECU_APP/r_cg_adc.c b/ECU_APP/r_cg_adc.c
index d4ee915..060b96f 100644
--- a/ECU_APP/r_cg_adc.c
+++ b/ECU_APP/r_cg_adc.c
@@ -20,10 +20,10 @@
/***********************************************************************************************************************
* File Name : r_cg_adc.c
* Version : CodeGenerator for RL78/F13 V2.03.07.02 [08 Nov 2021]
-* Device(s) : R5F10BBG
+* Device(s) : R5F10BGG
* Tool-Chain : CCRL
* Description : This file implements device driver for ADC module.
-* Creation Date: 2024-05-23
+* Creation Date: 2024/5/26
***********************************************************************************************************************/
/***********************************************************************************************************************
@@ -63,8 +63,8 @@ void R_ADC_Create(void)
ADPR1 = 1U;
ADPR0 = 1U;
/* The reset status of ADPC is analog input, so it's unnecessary to set. */
- /* Set ANI0 pin as analog input */
- PM3 |= 0x08U;
+ /* Set ANI0 - ANI1 pin as analog input */
+ PM3 |= 0x18U;
ADM0 = _00_AD_CONVERSION_CLOCK_64 | _00_AD_TIME_MODE_NORMAL_1 | _00_AD_OPERMODE_SELECT;
ADM1 = _80_AD_TRIGGER_HARDWARE_NOWAIT | _20_AD_CONVMODE_ONESELECT | _00_AD_TRIGGER_INTTM01;
ADM2 = _00_AD_POSITIVE_VDD | _00_AD_NEGATIVE_VSS | _00_AD_AREA_MODE_1 | _00_AD_RESOLUTION_10BIT;
diff --git a/ECU_APP/r_cg_adc.h b/ECU_APP/r_cg_adc.h
index 9785dc2..9264750 100644
--- a/ECU_APP/r_cg_adc.h
+++ b/ECU_APP/r_cg_adc.h
@@ -20,10 +20,10 @@
/***********************************************************************************************************************
* File Name : r_cg_adc.h
* Version : CodeGenerator for RL78/F13 V2.03.07.02 [08 Nov 2021]
-* Device(s) : R5F10BBG
+* Device(s) : R5F10BGG
* Tool-Chain : CCRL
* Description : This file implements device driver for ADC module.
-* Creation Date: 2024-05-23
+* Creation Date: 2024/5/26
***********************************************************************************************************************/
#ifndef ADC_H
@@ -78,6 +78,11 @@ Macro definitions (Register bit)
#define _05_AD_INPUT_CHANNEL_5 (0x05U) /* ANI5 */
#define _06_AD_INPUT_CHANNEL_6 (0x06U) /* ANI6 */
#define _07_AD_INPUT_CHANNEL_7 (0x07U) /* ANI7 */
+#define _08_AD_INPUT_CHANNEL_8 (0x08U) /* ANI8 */
+#define _09_AD_INPUT_CHANNEL_9 (0x09U) /* ANI9 */
+#define _0A_AD_INPUT_CHANNEL_10 (0x0AU) /* ANI10 */
+#define _0B_AD_INPUT_CHANNEL_11 (0x0BU) /* ANI11 */
+#define _0C_AD_INPUT_CHANNEL_12 (0x0CU) /* ANI12 */
#define _18_AD_INPUT_CHANNEL_24 (0x18U) /* ANI24 */
#define _19_AD_INPUT_CHANNEL_25 (0x19U) /* ANI25 */
#define _80_AD_INPUT_TEMPERSENSOR_0 (0x80U) /* temperature sensor 0 output is used to be the input channel */
@@ -88,6 +93,11 @@ Macro definitions (Register bit)
#define _02_AD_INPUT_CHANNEL_2_5 (0x02U) /* ANI2 - ANI5 */
#define _03_AD_INPUT_CHANNEL_3_6 (0x03U) /* ANI3 - ANI6 */
#define _04_AD_INPUT_CHANNEL_4_7 (0x04U) /* ANI4 - ANI7 */
+#define _05_AD_INPUT_CHANNEL_5_8 (0x05U) /* ANI5 - ANI8 */
+#define _06_AD_INPUT_CHANNEL_6_9 (0x06U) /* ANI6 - ANI9 */
+#define _07_AD_INPUT_CHANNEL_7_10 (0x07U) /* ANI7 - ANI10 */
+#define _08_AD_INPUT_CHANNEL_8_11 (0x08U) /* ANI8 - ANI11 */
+#define _09_AD_INPUT_CHANNEL_9_12 (0x09U) /* ANI9 - ANI12 */
/*
AD converter mode register 1 (ADM1)
@@ -158,7 +168,8 @@ Typedef definitions
typedef enum
{
ADCHANNEL0, ADCHANNEL1, ADCHANNEL2, ADCHANNEL3, ADCHANNEL4, ADCHANNEL5, ADCHANNEL6,
- ADCHANNEL7, ADCHANNEL24 = 24U, ADCHANNEL25, ADTEMPERSENSOR0 = 128U, ADINTERREFVOLT
+ ADCHANNEL7, ADCHANNEL8, ADCHANNEL9, ADCHANNEL10, ADCHANNEL11, ADCHANNEL12,
+ ADCHANNEL24 = 24U, ADCHANNEL25, ADTEMPERSENSOR0 = 128U, ADINTERREFVOLT
} ad_channel_t;
typedef enum
{
diff --git a/ECU_APP/r_cg_adc_user.c b/ECU_APP/r_cg_adc_user.c
index 54ec699..a45bfe1 100644
--- a/ECU_APP/r_cg_adc_user.c
+++ b/ECU_APP/r_cg_adc_user.c
@@ -20,10 +20,10 @@
/***********************************************************************************************************************
* File Name : r_cg_adc_user.c
* Version : CodeGenerator for RL78/F13 V2.03.07.02 [08 Nov 2021]
-* Device(s) : R5F10BBG
+* Device(s) : R5F10BGG
* Tool-Chain : CCRL
* Description : This file implements device driver for ADC module.
-* Creation Date: 2024-05-23
+* Creation Date: 2024/5/26
***********************************************************************************************************************/
/***********************************************************************************************************************
diff --git a/ECU_APP/r_cg_cgc.c b/ECU_APP/r_cg_cgc.c
index e4c75a0..de84be9 100644
--- a/ECU_APP/r_cg_cgc.c
+++ b/ECU_APP/r_cg_cgc.c
@@ -20,10 +20,10 @@
/***********************************************************************************************************************
* File Name : r_cg_cgc.c
* Version : CodeGenerator for RL78/F13 V2.03.07.02 [08 Nov 2021]
-* Device(s) : R5F10BBG
+* Device(s) : R5F10BGG
* Tool-Chain : CCRL
* Description : This file implements device driver for CGC module.
-* Creation Date: 2024-05-23
+* Creation Date: 2024/5/26
***********************************************************************************************************************/
/***********************************************************************************************************************
@@ -62,7 +62,7 @@ void R_CGC_Create(void)
/* Set fSL */
SELLOSC = 1U;
/* Set fMX */
- CMC = _40_CGC_HISYS_OSC | _00_CGC_SYSOSC_UNDER10M;
+ CMC = _40_CGC_HISYS_OSC | _00_CGC_SUB_PORT | _00_CGC_SYSOSC_UNDER10M | _00_CGC_SUBMODE_DEFAULT;
OSTS = _07_CGC_OSCSTAB_SEL18;
MSTOP = 0U;
temp_stab_set = _FF_CGC_OSCSTAB_STA18;
@@ -107,6 +107,8 @@ void R_CGC_Create(void)
;
}
+ /* Set fSUB */
+ XTSTOP = 1U;
/* Set fCLK */
CSS = 0U;
/* Set fIH */
diff --git a/ECU_APP/r_cg_cgc.h b/ECU_APP/r_cg_cgc.h
index d6321ba..4e67252 100644
--- a/ECU_APP/r_cg_cgc.h
+++ b/ECU_APP/r_cg_cgc.h
@@ -20,10 +20,10 @@
/***********************************************************************************************************************
* File Name : r_cg_cgc.h
* Version : CodeGenerator for RL78/F13 V2.03.07.02 [08 Nov 2021]
-* Device(s) : R5F10BBG
+* Device(s) : R5F10BGG
* Tool-Chain : CCRL
* Description : This file implements device driver for CGC module.
-* Creation Date: 2024-05-23
+* Creation Date: 2024/5/26
***********************************************************************************************************************/
#ifndef CGC_H
@@ -41,6 +41,17 @@ Macro definitions (Register bit)
#define _40_CGC_HISYS_OSC (0x40U) /* X1, X2 as crystal/ceramic resonator connection */
#define _80_CGC_HISYS_PORT1 (0x80U) /* X1, X2 as I/O port */
#define _C0_CGC_HISYS_EXT (0xC0U) /* X1 as I/O port, X2 as external clock input */
+/* Subsystem clock pin operation mode (EXCLKS, OSCSELS) */
+#define _30_CGC_SUB_PIN (0x30U)
+#define _00_CGC_SUB_PORT (0x00U) /* XT1, XT2 as I/O port */
+#define _10_CGC_SUB_OSC (0x10U) /* XT1, XT2 as crystal connection */
+#define _20_CGC_SUB_PORT1 (0x20U) /* XT1, XT2 as I/O port */
+#define _30_CGC_SUB_EXT (0x30U) /* XT1 as I/O port, XT2 as external clock input */
+/* XT1 oscillator oscillation mode selection (AMPHS1, AMPHS0) */
+#define _00_CGC_SUBMODE_DEFAULT (0x00U)
+#define _00_CGC_SUBMODE_LOW (0x00U) /* low power consumption oscillation */
+#define _02_CGC_SUBMODE_NORMAL (0x02U) /* normal oscillation */
+#define _04_CGC_SUBMODE_ULOW (0x04U) /* ultra-low power consumption oscillation */
/* Control of X1 high-speed system clock oscillation frequency (AMPH) */
#define _00_CGC_SYSOSC_DEFAULT (0x00U)
#define _00_CGC_SYSOSC_UNDER10M (0x00U) /* fX <= 10MHz */
@@ -52,6 +63,9 @@ Macro definitions (Register bit)
/* Control of high-speed system clock operation (MSTOP) */
#define _00_CGC_HISYS_OPER (0x00U) /* X1 oscillator/external clock operating */
#define _80_CGC_HISYS_STOP (0x80U) /* X1 oscillator/external clock stopped */
+/* Subsystem clock operation (XTSTOP) */
+#define _00_CGC_SUB_OPER (0x00U) /* XT1 oscillator operating */
+#define _40_CGC_SUB_STOP (0x40U) /* XT1 oscillator stopped */
/* High-speed OCO operation (HIOSTOP) */
#define _00_CGC_HIO_OPER (0x00U) /* high-speed OCO operating */
#define _01_CGC_HIO_STOP (0x01U) /* high-speed OCO stopped */
@@ -128,6 +142,12 @@ Macro definitions (Register bit)
/*
System clock control register (CKC)
*/
+/* Status of CPU/peripheral hardware clock fCLK (CLS) */
+#define _00_CGC_CPUCLK_MAIN (0x00U) /* main system clock (fMAIN) */
+#define _80_CGC_CPUCLK_SUB (0x80U) /* subsystem clock (fSUB) */
+/* Selection of CPU/peripheral hardware clock fCLK (CSS) */
+#define _00_CGC_CPUCLK_SELMAIN (0x00U) /* main system clock (fMAIN) */
+#define _40_CGC_CPUCLK_SELSUB (0x40U) /* subsystem clock (fSUB) */
/* Status of Main system clock fMAIN (MCS) */
#define _00_CGC_MAINCLK_HIO (0x00U) /* high-speed OCO clock (fIH) */
#define _20_CGC_MAINCLK_HISYS (0x20U) /* high-speed system clock (fMX) */
@@ -192,7 +212,9 @@ typedef enum
{
HIOCLK,
SYSX1CLK,
- SYSEXTCLK
+ SYSEXTCLK,
+ SUBXT1CLK,
+ SUBEXTCLK
} clock_mode_t;
/***********************************************************************************************************************
diff --git a/ECU_APP/r_cg_cgc_user.c b/ECU_APP/r_cg_cgc_user.c
index 0fa4eec..e66b6f4 100644
--- a/ECU_APP/r_cg_cgc_user.c
+++ b/ECU_APP/r_cg_cgc_user.c
@@ -20,10 +20,10 @@
/***********************************************************************************************************************
* File Name : r_cg_cgc_user.c
* Version : CodeGenerator for RL78/F13 V2.03.07.02 [08 Nov 2021]
-* Device(s) : R5F10BBG
+* Device(s) : R5F10BGG
* Tool-Chain : CCRL
* Description : This file implements device driver for CGC module.
-* Creation Date: 2024-05-23
+* Creation Date: 2024/5/26
***********************************************************************************************************************/
/***********************************************************************************************************************
diff --git a/ECU_APP/r_cg_intc.c b/ECU_APP/r_cg_intc.c
index 1b6b3bc..b7728ae 100644
--- a/ECU_APP/r_cg_intc.c
+++ b/ECU_APP/r_cg_intc.c
@@ -23,7 +23,7 @@
* Device(s) : R5F10BGG
* Tool-Chain : CCRL
* Description : This file implements device driver for INTC module.
-* Creation Date: 2023-05-03
+* Creation Date: 2022/7/8
***********************************************************************************************************************/
/***********************************************************************************************************************
@@ -75,8 +75,218 @@ void R_INTC_Create(void)
PIF8 = 0U; /* clear INTP8 interrupt flag */
PMK9 = 1U; /* disable INTP9 operation */
PIF9 = 0U; /* clear INTP9 interrupt flag */
- INTMSK = _00_INTP4_CONTROL_ENABLE | _02_INTP5_CONTROL_DISABLE | _04_INTP6_CONTROL_DISABLE |
+ /* Set INTP0 low priority */
+ PPR10 = 1U;
+ PPR00 = 1U;
+ /* Set INTP1 low priority */
+ PPR11 = 1U;
+ PPR01 = 1U;
+ /* Set INTP2 low priority */
+ PPR12 = 1U;
+ PPR02 = 1U;
+ /* Set INTP4 low priority */
+ PPR14 = 1U;
+ PPR04 = 1U;
+ /* Set INTP6 low priority */
+ PPR16 = 1U;
+ PPR06 = 1U;
+ /* Set INTP7 low priority */
+ PPR17 = 1U;
+ PPR07 = 1U;
+ /* Set INTP8 low priority */
+ PPR18 = 1U;
+ PPR08 = 1U;
+ EGP0 = _01_INTP0_EDGE_RISING_SEL | _02_INTP1_EDGE_RISING_SEL | _04_INTP2_EDGE_RISING_SEL |
+ _10_INTP4_EDGE_RISING_SEL | _40_INTP6_EDGE_RISING_SEL | _80_INTP7_EDGE_RISING_SEL;
+ EGN1 = _01_INTP8_EDGE_FALLING_SEL;
+ INTFLG0 &= _C2_INTFLG0_MASK_VALUE;
+ INTMSK = _00_INTP4_CONTROL_ENABLE | _02_INTP5_CONTROL_DISABLE | _00_INTP6_CONTROL_ENABLE |
_F8_INTP_INTMSK_INIT_VALUE;
+ /* Set INTP1 pin */
+ PIM12 &= 0xDFU;
+ PMC12 &= 0xDFU;
+ PM12 |= 0x20U;
+ /* Set INTP2 pin */
+ PM3 |= 0x02U;
+ /* Set INTP4 pin */
+ PMC12 &= 0xFEU;
+ PM12 |= 0x01U;
+ /* Set INTP6 pin */
+ PIM7 &= 0xFDU;
+ PM7 |= 0x02U;
+ /* Set INTP7 pin */
+ PM3 |= 0x04U;
+ /* Set INTP8 pin */
+ PIM7 &= 0xFEU;
+ PM7 |= 0x01U;
+}
+
+/***********************************************************************************************************************
+* Function Name: R_INTC0_Start
+* Description : This function clears INTP0 interrupt flag and enables interrupt.
+* Arguments : None
+* Return Value : None
+***********************************************************************************************************************/
+void R_INTC0_Start(void)
+{
+ PIF0 = 0U; /* clear INTP0 interrupt flag */
+ PMK0 = 0U; /* enable INTP0 interrupt */
+}
+
+/***********************************************************************************************************************
+* Function Name: R_INTC0_Stop
+* Description : This function disables INTP0 interrupt and clears interrupt flag.
+* Arguments : None
+* Return Value : None
+***********************************************************************************************************************/
+void R_INTC0_Stop(void)
+{
+ PMK0 = 1U; /* disable INTP0 interrupt */
+ PIF0 = 0U; /* clear INTP0 interrupt flag */
+}
+
+/***********************************************************************************************************************
+* Function Name: R_INTC1_Start
+* Description : This function clears INTP1 interrupt flag and enables interrupt.
+* Arguments : None
+* Return Value : None
+***********************************************************************************************************************/
+void R_INTC1_Start(void)
+{
+ PIF1 = 0U; /* clear INTP1 interrupt flag */
+ PMK1 = 0U; /* enable INTP1 interrupt */
+}
+
+/***********************************************************************************************************************
+* Function Name: R_INTC1_Stop
+* Description : This function disables INTP1 interrupt and clears interrupt flag.
+* Arguments : None
+* Return Value : None
+***********************************************************************************************************************/
+void R_INTC1_Stop(void)
+{
+ PMK1 = 1U; /* disable INTP1 interrupt */
+ PIF1 = 0U; /* clear INTP1 interrupt flag */
+}
+
+/***********************************************************************************************************************
+* Function Name: R_INTC2_Start
+* Description : This function clears INTP2 interrupt flag and enables interrupt.
+* Arguments : None
+* Return Value : None
+***********************************************************************************************************************/
+void R_INTC2_Start(void)
+{
+ PIF2 = 0U; /* clear INTP2 interrupt flag */
+ PMK2 = 0U; /* enable INTP2 interrupt */
+}
+
+/***********************************************************************************************************************
+* Function Name: R_INTC2_Stop
+* Description : This function disables INTP2 interrupt and clears interrupt flag.
+* Arguments : None
+* Return Value : None
+***********************************************************************************************************************/
+void R_INTC2_Stop(void)
+{
+ PMK2 = 1U; /* disable INTP2 interrupt */
+ PIF2 = 0U; /* clear INTP2 interrupt flag */
+}
+
+/***********************************************************************************************************************
+* Function Name: R_INTC4_Start
+* Description : This function clears INTP4 interrupt flag and enables interrupt.
+* Arguments : None
+* Return Value : None
+***********************************************************************************************************************/
+void R_INTC4_Start(void)
+{
+ PIF4 = 0U; /* clear INTP4 interrupt flag */
+ PMK4 = 0U; /* enable INTP4 interrupt */
+}
+
+/***********************************************************************************************************************
+* Function Name: R_INTC4_Stop
+* Description : This function disables INTP4 interrupt and clears interrupt flag.
+* Arguments : None
+* Return Value : None
+***********************************************************************************************************************/
+void R_INTC4_Stop(void)
+{
+ PMK4 = 1U; /* disable INTP4 interrupt */
+ PIF4 = 0U; /* clear INTP4 interrupt flag */
+}
+
+/***********************************************************************************************************************
+* Function Name: R_INTC6_Start
+* Description : This function clears INTP6 interrupt flag and enables interrupt.
+* Arguments : None
+* Return Value : None
+***********************************************************************************************************************/
+void R_INTC6_Start(void)
+{
+ PIF6 = 0U; /* clear INTP6 interrupt flag */
+ PMK6 = 0U; /* enable INTP6 interrupt */
+}
+
+/***********************************************************************************************************************
+* Function Name: R_INTC6_Stop
+* Description : This function disables INTP6 interrupt and clears interrupt flag.
+* Arguments : None
+* Return Value : None
+***********************************************************************************************************************/
+void R_INTC6_Stop(void)
+{
+ PMK6 = 1U; /* disable INTP6 interrupt */
+ PIF6 = 0U; /* clear INTP6 interrupt flag */
+}
+
+/***********************************************************************************************************************
+* Function Name: R_INTC7_Start
+* Description : This function clears INTP7 interrupt flag and enables interrupt.
+* Arguments : None
+* Return Value : None
+***********************************************************************************************************************/
+void R_INTC7_Start(void)
+{
+ PIF7 = 0U; /* clear INTP7 interrupt flag */
+ PMK7 = 0U; /* enable INTP7 interrupt */
+}
+
+/***********************************************************************************************************************
+* Function Name: R_INTC7_Stop
+* Description : This function disables INTP7 interrupt and clears interrupt flag.
+* Arguments : None
+* Return Value : None
+***********************************************************************************************************************/
+void R_INTC7_Stop(void)
+{
+ PMK7 = 1U; /* disable INTP7 interrupt */
+ PIF7 = 0U; /* clear INTP7 interrupt flag */
+}
+
+/***********************************************************************************************************************
+* Function Name: R_INTC8_Start
+* Description : This function clears INTP8 interrupt flag and enables interrupt.
+* Arguments : None
+* Return Value : None
+***********************************************************************************************************************/
+void R_INTC8_Start(void)
+{
+ PIF8 = 0U; /* clear INTP8 interrupt flag */
+ PMK8 = 0U; /* enable INTP8 interrupt */
+}
+
+/***********************************************************************************************************************
+* Function Name: R_INTC8_Stop
+* Description : This function disables INTP8 interrupt and clears interrupt flag.
+* Arguments : None
+* Return Value : None
+***********************************************************************************************************************/
+void R_INTC8_Stop(void)
+{
+ PMK8 = 1U; /* disable INTP8 interrupt */
+ PIF8 = 0U; /* clear INTP8 interrupt flag */
}
/* Start user code for adding. Do not edit comment generated here */
diff --git a/ECU_APP/r_cg_intc.h b/ECU_APP/r_cg_intc.h
index 4052aef..7d4a98e 100644
--- a/ECU_APP/r_cg_intc.h
+++ b/ECU_APP/r_cg_intc.h
@@ -23,7 +23,7 @@
* Device(s) : R5F10BGG
* Tool-Chain : CCRL
* Description : This file implements device driver for INTC module.
-* Creation Date: 2023-05-03
+* Creation Date: 2022/7/8
***********************************************************************************************************************/
#ifndef INTC_H
@@ -126,6 +126,7 @@ Macro definitions (Register bit)
/***********************************************************************************************************************
Macro definitions
***********************************************************************************************************************/
+#define _C2_INTFLG0_MASK_VALUE (0xC2U) /* set interrupt factor distinction flag */
/***********************************************************************************************************************
Typedef definitions
@@ -135,6 +136,20 @@ Typedef definitions
Global functions
***********************************************************************************************************************/
void R_INTC_Create(void);
+void R_INTC0_Start(void);
+void R_INTC0_Stop(void);
+void R_INTC1_Start(void);
+void R_INTC1_Stop(void);
+void R_INTC2_Start(void);
+void R_INTC2_Stop(void);
+void R_INTC4_Start(void);
+void R_INTC4_Stop(void);
+void R_INTC6_Start(void);
+void R_INTC6_Stop(void);
+void R_INTC7_Start(void);
+void R_INTC7_Stop(void);
+void R_INTC8_Start(void);
+void R_INTC8_Stop(void);
/* Start user code for function. Do not edit comment generated here */
/* End user code. Do not edit comment generated here */
diff --git a/ECU_APP/r_cg_intc_user.c b/ECU_APP/r_cg_intc_user.c
index 13a8ab1..5eef9a9 100644
--- a/ECU_APP/r_cg_intc_user.c
+++ b/ECU_APP/r_cg_intc_user.c
@@ -23,7 +23,7 @@
* Device(s) : R5F10BGG
* Tool-Chain : CCRL
* Description : This file implements device driver for INTC module.
-* Creation Date: 2023-05-03
+* Creation Date: 2022/7/8
***********************************************************************************************************************/
/***********************************************************************************************************************
@@ -38,6 +38,13 @@ Includes
/***********************************************************************************************************************
Pragma directive
***********************************************************************************************************************/
+#pragma interrupt r_intc0_interrupt(vect=INTP0)
+#pragma interrupt r_intc1_interrupt(vect=INTP1)
+#pragma interrupt r_intc2_interrupt(vect=INTP2)
+#pragma interrupt r_intc4_interrupt(vect=INTP4)
+#pragma interrupt r_intc6_interrupt(vect=INTP6)
+#pragma interrupt r_intc7_interrupt(vect=INTP7)
+#pragma interrupt r_intc8_interrupt(vect=INTP8)
/* Start user code for pragma. Do not edit comment generated here */
/* End user code. Do not edit comment generated here */
@@ -47,5 +54,89 @@ Global variables and functions
/* Start user code for global. Do not edit comment generated here */
/* End user code. Do not edit comment generated here */
+/***********************************************************************************************************************
+* Function Name: r_intc0_interrupt
+* Description : This function is INTP0 interrupt service routine.
+* Arguments : None
+* Return Value : None
+***********************************************************************************************************************/
+static void __near r_intc0_interrupt(void)
+{
+ /* Start user code. Do not edit comment generated here */
+ /* End user code. Do not edit comment generated here */
+}
+
+/***********************************************************************************************************************
+* Function Name: r_intc1_interrupt
+* Description : This function is INTP1 interrupt service routine.
+* Arguments : None
+* Return Value : None
+***********************************************************************************************************************/
+static void __near r_intc1_interrupt(void)
+{
+ /* Start user code. Do not edit comment generated here */
+ /* End user code. Do not edit comment generated here */
+}
+
+/***********************************************************************************************************************
+* Function Name: r_intc2_interrupt
+* Description : This function is INTP2 interrupt service routine.
+* Arguments : None
+* Return Value : None
+***********************************************************************************************************************/
+static void __near r_intc2_interrupt(void)
+{
+ /* Start user code. Do not edit comment generated here */
+ /* End user code. Do not edit comment generated here */
+}
+
+/***********************************************************************************************************************
+* Function Name: r_intc4_interrupt
+* Description : This function is INTP4 interrupt service routine.
+* Arguments : None
+* Return Value : None
+***********************************************************************************************************************/
+static void __near r_intc4_interrupt(void)
+{
+ /* Start user code. Do not edit comment generated here */
+ /* End user code. Do not edit comment generated here */
+}
+
+/***********************************************************************************************************************
+* Function Name: r_intc6_interrupt
+* Description : This function is INTP6 interrupt service routine.
+* Arguments : None
+* Return Value : None
+***********************************************************************************************************************/
+static void __near r_intc6_interrupt(void)
+{
+ /* Start user code. Do not edit comment generated here */
+ /* End user code. Do not edit comment generated here */
+}
+
+/***********************************************************************************************************************
+* Function Name: r_intc7_interrupt
+* Description : This function is INTP7 interrupt service routine.
+* Arguments : None
+* Return Value : None
+***********************************************************************************************************************/
+static void __near r_intc7_interrupt(void)
+{
+ /* Start user code. Do not edit comment generated here */
+ /* End user code. Do not edit comment generated here */
+}
+
+/***********************************************************************************************************************
+* Function Name: r_intc8_interrupt
+* Description : This function is INTP8 interrupt service routine.
+* Arguments : None
+* Return Value : None
+***********************************************************************************************************************/
+static void __near r_intc8_interrupt(void)
+{
+ /* Start user code. Do not edit comment generated here */
+ /* End user code. Do not edit comment generated here */
+}
+
/* Start user code for adding. Do not edit comment generated here */
/* End user code. Do not edit comment generated here */
diff --git a/ECU_APP/r_cg_macrodriver.h b/ECU_APP/r_cg_macrodriver.h
index e0881ef..a40e4d1 100644
--- a/ECU_APP/r_cg_macrodriver.h
+++ b/ECU_APP/r_cg_macrodriver.h
@@ -20,10 +20,10 @@
/***********************************************************************************************************************
* File Name : r_cg_macrodriver.h
* Version : CodeGenerator for RL78/F13 V2.03.07.02 [08 Nov 2021]
-* Device(s) : R5F10BBG
+* Device(s) : R5F10BGG
* Tool-Chain : CCRL
* Description : This file implements general head file.
-* Creation Date: 2024-05-23
+* Creation Date: 2024/5/26
***********************************************************************************************************************/
#ifndef STATUS_H
diff --git a/ECU_APP/r_cg_port.c b/ECU_APP/r_cg_port.c
index f5e1244..b1fae71 100644
--- a/ECU_APP/r_cg_port.c
+++ b/ECU_APP/r_cg_port.c
@@ -20,10 +20,10 @@
/***********************************************************************************************************************
* File Name : r_cg_port.c
* Version : CodeGenerator for RL78/F13 V2.03.07.02 [08 Nov 2021]
-* Device(s) : R5F10BBG
+* Device(s) : R5F10BGG
* Tool-Chain : CCRL
* Description : This file implements device driver for PORT module.
-* Creation Date: 2024-05-23
+* Creation Date: 2024/5/26
***********************************************************************************************************************/
/***********************************************************************************************************************
@@ -55,19 +55,15 @@ Global variables and functions
***********************************************************************************************************************/
void R_PORT_Create(void)
{
- P1 = _00_Pn2_OUTPUT_0;
- PU4 = _00_PUn0_PULLUP_OFF;
- PMC12 = _00_PMCn0_DI_ON | _00_PMCn5_DI_ON | _DE_PMC12_DEFAULT;
- PSRSEL = _00_PSR14_NORMAL | _00_PSR120_NORMAL | _00_PSR30_NORMAL | _00_PSR12_NORMAL;
- ADPC = _02_ADPC_DI_ON;
- PM1 = _01_PMn0_NOT_USE | _02_PMn1_NOT_USE | _00_PMn2_MODE_OUTPUT | _08_PMn3_MODE_INPUT | _10_PMn4_MODE_INPUT |
- _20_PMn5_MODE_INPUT | _40_PMn6_MODE_INPUT | _80_PMn7_MODE_INPUT;
- PM3 = _01_PMn0_MODE_INPUT | _08_PMn3_NOT_USE | _10_PMn4_MODE_INPUT | _E6_PM3_DEFAULT;
- PM4 = _01_PMn0_NOT_USE | _02_PMn1_MODE_INPUT | _FC_PM4_DEFAULT;
- PM6 = _01_PMn0_MODE_INPUT | _02_PMn1_MODE_INPUT | _04_PMn2_MODE_INPUT | _08_PMn3_MODE_INPUT | _F0_PM6_DEFAULT;
- PM8 = _01_PMn0_MODE_INPUT | _02_PMn1_MODE_INPUT | _04_PMn2_MODE_INPUT | _08_PMn3_MODE_INPUT | _10_PMn4_MODE_INPUT |
- _20_PMn5_MODE_INPUT | _C0_PM8_DEFAULT;
- PM12 = _01_PMn0_MODE_INPUT | _20_PMn5_MODE_INPUT | _DE_PM12_DEFAULT;
+ P1 = _00_Pn2_OUTPUT_0 | _00_Pn5_OUTPUT_0;
+ P3 = _00_Pn0_OUTPUT_0 | _00_Pn2_OUTPUT_0;
+ P7 = _00_Pn0_OUTPUT_0 | _00_Pn1_OUTPUT_0 | _00_Pn2_OUTPUT_0;
+ PSRSEL = _00_PSR14_NORMAL | _00_PSR30_NORMAL | _00_PSR12_NORMAL;
+ PM1 = _01_PMn0_NOT_USE | _02_PMn1_NOT_USE | _00_PMn2_MODE_OUTPUT | _08_PMn3_NOT_USE | _10_PMn4_MODE_INPUT |
+ _00_PMn5_MODE_OUTPUT | _40_PMn6_NOT_USE | _80_PMn7_NOT_USE;
+ PM3 = _00_PMn0_MODE_OUTPUT | _02_PMn1_MODE_INPUT | _00_PMn2_MODE_OUTPUT | _08_PMn3_NOT_USE | _10_PMn4_NOT_USE |
+ _E0_PM3_DEFAULT;
+ PM7 = _00_PMn0_MODE_OUTPUT | _00_PMn1_MODE_OUTPUT | _00_PMn2_MODE_OUTPUT | _08_PMn3_NOT_USE | _F0_PM7_DEFAULT;
}
/* Start user code for adding. Do not edit comment generated here */
diff --git a/ECU_APP/r_cg_port.h b/ECU_APP/r_cg_port.h
index 12c7516..f6bb6b4 100644
--- a/ECU_APP/r_cg_port.h
+++ b/ECU_APP/r_cg_port.h
@@ -20,10 +20,10 @@
/***********************************************************************************************************************
* File Name : r_cg_port.h
* Version : CodeGenerator for RL78/F13 V2.03.07.02 [08 Nov 2021]
-* Device(s) : R5F10BBG
+* Device(s) : R5F10BGG
* Tool-Chain : CCRL
* Description : This file implements device driver for PORT module.
-* Creation Date: 2024-05-23
+* Creation Date: 2024/5/26
***********************************************************************************************************************/
#ifndef PORT_H
@@ -214,24 +214,32 @@ Macro definitions (Register bit)
AD port configuration register (ADPC)
*/
/* Analog input/digital input switching (ADPC4 - ADPC0) */
-#define _00_ADPC_DI_OFF (0x00U) /* use P33, P34, P80 - P85 as analog input */
-#define _08_ADPC_DI_ON (0x08U) /* use P85 as digital input */
-#define _07_ADPC_DI_ON (0x07U) /* use P84 - P85 as digital input */
-#define _06_ADPC_DI_ON (0x06U) /* use P83 - P85 as digital input */
-#define _05_ADPC_DI_ON (0x05U) /* use P82 - P85 as digital input */
-#define _04_ADPC_DI_ON (0x04U) /* use P81 - P85 as digital input */
-#define _03_ADPC_DI_ON (0x03U) /* use P80 - P85 as digital input */
-#define _02_ADPC_DI_ON (0x02U) /* use P34, P80 - P85 as digital input */
-#define _01_ADPC_DI_ON (0x01U) /* use P33, P34, P85 as digital input */
+#define _00_ADPC_DI_OFF (0x00U) /* use P33, P34, P80 - P87, P90 - P92 as analog input */
+#define _0D_ADPC_DI_ON (0x0DU) /* use P92 as digital input */
+#define _0C_ADPC_DI_ON (0x0CU) /* use P91 - P92 as digital input */
+#define _0B_ADPC_DI_ON (0x0BU) /* use P90 - P92 as digital input */
+#define _0A_ADPC_DI_ON (0x0AU) /* use P87, P90 - P92 as digital input */
+#define _09_ADPC_DI_ON (0x09U) /* use P86 - P87, P90 - P92 as digital input */
+#define _08_ADPC_DI_ON (0x08U) /* use P85 - P87, P90 - P92 as digital input */
+#define _07_ADPC_DI_ON (0x07U) /* use P84 - P87, P90 - P92 as digital input */
+#define _06_ADPC_DI_ON (0x06U) /* use P83 - P87, P90 - P92 as digital input */
+#define _05_ADPC_DI_ON (0x05U) /* use P82 - P87, P90 - P92 as digital input */
+#define _04_ADPC_DI_ON (0x04U) /* use P81 - P87, P90 - P92 as digital input */
+#define _03_ADPC_DI_ON (0x03U) /* use P80 - P87, P90 - P92 as digital input */
+#define _02_ADPC_DI_ON (0x02U) /* use P34, P80 - P87, P90 - P92 as digital input */
+#define _01_ADPC_DI_ON (0x01U) /* use P33, P34, P80 - P87, P90 - P92 as digital input */
/***********************************************************************************************************************
Macro definitions
***********************************************************************************************************************/
-#define _E6_PM3_DEFAULT (0xE6U) /* PM3 default value */
+#define _FE_PM0_DEFAULT (0xFEU) /* PM0 default value */
+#define _E0_PM3_DEFAULT (0xE0U) /* PM3 default value */
#define _FC_PM4_DEFAULT (0xFCU) /* PM4 default value */
#define _F0_PM6_DEFAULT (0xF0U) /* PM6 default value */
-#define _C0_PM8_DEFAULT (0xC0U) /* PM8 default value */
+#define _F0_PM7_DEFAULT (0xF0U) /* PM7 default value */
+#define _F8_PM9_DEFAULT (0xF8U) /* PM9 default value */
#define _DE_PM12_DEFAULT (0xDEU) /* PM12 default value */
+#define _FE_PM14_DEFAULT (0xFEU) /* PM14 default value */
#define _DE_PMC12_DEFAULT (0xDEU) /* PMC12 default value */
diff --git a/ECU_APP/r_cg_port_user.c b/ECU_APP/r_cg_port_user.c
index aadc5d8..a56515f 100644
--- a/ECU_APP/r_cg_port_user.c
+++ b/ECU_APP/r_cg_port_user.c
@@ -20,10 +20,10 @@
/***********************************************************************************************************************
* File Name : r_cg_port_user.c
* Version : CodeGenerator for RL78/F13 V2.03.07.02 [08 Nov 2021]
-* Device(s) : R5F10BBG
+* Device(s) : R5F10BGG
* Tool-Chain : CCRL
* Description : This file implements device driver for PORT module.
-* Creation Date: 2024-05-23
+* Creation Date: 2024/5/26
***********************************************************************************************************************/
/***********************************************************************************************************************
diff --git a/ECU_APP/r_cg_serial_user.c b/ECU_APP/r_cg_serial_user.c
index 452389b..f1cbc6b 100644
--- a/ECU_APP/r_cg_serial_user.c
+++ b/ECU_APP/r_cg_serial_user.c
@@ -59,6 +59,8 @@ extern volatile uint8_t * gp_iica0_tx_address; /* iica0 send buffer addr
extern volatile uint16_t g_iica0_tx_cnt; /* iica0 send data count */
/* Start user code for global. Do not edit comment generated here */
+extern volatile uint8_t flag_IIC_SendEnd;
+extern volatile uint8_t flag_IIC_ReceiveEnd;
/* End user code. Do not edit comment generated here */
/***********************************************************************************************************************
@@ -198,6 +200,7 @@ static void r_iica0_callback_master_receiveend(void)
{
SPT0 = 1U;
/* Start user code. Do not edit comment generated here */
+ flag_IIC_ReceiveEnd = 1;
/* End user code. Do not edit comment generated here */
}
@@ -211,6 +214,7 @@ static void r_iica0_callback_master_sendend(void)
{
SPT0 = 1U;
/* Start user code. Do not edit comment generated here */
+ flag_IIC_SendEnd = 1;
/* End user code. Do not edit comment generated here */
}
diff --git a/ECU_APP/r_cg_timer.c b/ECU_APP/r_cg_timer.c
index 22cfc77..c1cd99b 100644
--- a/ECU_APP/r_cg_timer.c
+++ b/ECU_APP/r_cg_timer.c
@@ -20,10 +20,10 @@
/***********************************************************************************************************************
* File Name : r_cg_timer.c
* Version : CodeGenerator for RL78/F13 V2.03.07.02 [08 Nov 2021]
-* Device(s) : R5F10BBG
+* Device(s) : R5F10BGG
* Tool-Chain : CCRL
* Description : This file implements device driver for TAU module.
-* Creation Date: 2024-05-23
+* Creation Date: 2024/5/26
***********************************************************************************************************************/
/***********************************************************************************************************************
diff --git a/ECU_APP/r_cg_timer.h b/ECU_APP/r_cg_timer.h
index ae9739e..c71bed6 100644
--- a/ECU_APP/r_cg_timer.h
+++ b/ECU_APP/r_cg_timer.h
@@ -20,10 +20,10 @@
/***********************************************************************************************************************
* File Name : r_cg_timer.h
* Version : CodeGenerator for RL78/F13 V2.03.07.02 [08 Nov 2021]
-* Device(s) : R5F10BBG
+* Device(s) : R5F10BGG
* Tool-Chain : CCRL
* Description : This file implements device driver for TAU module.
-* Creation Date: 2024-05-23
+* Creation Date: 2024/5/26
***********************************************************************************************************************/
#ifndef TAU_H
diff --git a/ECU_APP/r_cg_timer_user.c b/ECU_APP/r_cg_timer_user.c
index d5027ef..bcb81a8 100644
--- a/ECU_APP/r_cg_timer_user.c
+++ b/ECU_APP/r_cg_timer_user.c
@@ -20,10 +20,10 @@
/***********************************************************************************************************************
* File Name : r_cg_timer_user.c
* Version : CodeGenerator for RL78/F13 V2.03.07.02 [08 Nov 2021]
-* Device(s) : R5F10BBG
+* Device(s) : R5F10BGG
* Tool-Chain : CCRL
* Description : This file implements device driver for TAU module.
-* Creation Date: 2024-05-23
+* Creation Date: 2024/5/26
***********************************************************************************************************************/
/***********************************************************************************************************************
@@ -85,6 +85,7 @@ void __near r_tau0_channel0_interrupt(void)
void __near r_tau0_channel1_interrupt(void)
{
/* Start user code. Do not edit comment generated here */
+ //ADCS = 1;
/* End user code. Do not edit comment generated here */
}
@@ -145,7 +146,7 @@ void Timer_Pro(void)
Count_Down_Timer_16Bit(&DiagCnt);
uiNwTimCnt++;
- uiNwToutCnt++; //���������ʱ��
+ uiNwToutCnt++; //
if(uiNwRMSCnt > 0)
uiNwRMSCnt--;
if(uiNwLocWkpOffCnt > 0)
diff --git a/ECU_APP/r_cg_userdefine.h b/ECU_APP/r_cg_userdefine.h
index 16e0202..bcb15ce 100644
--- a/ECU_APP/r_cg_userdefine.h
+++ b/ECU_APP/r_cg_userdefine.h
@@ -20,10 +20,10 @@
/***********************************************************************************************************************
* File Name : r_cg_userdefine.h
* Version : CodeGenerator for RL78/F13 V2.03.07.02 [08 Nov 2021]
-* Device(s) : R5F10BBG
+* Device(s) : R5F10BGG
* Tool-Chain : CCRL
* Description : This file includes user definition.
-* Creation Date: 2024-05-23
+* Creation Date: 2024/5/26
***********************************************************************************************************************/
#ifndef _USER_DEF_H
@@ -61,10 +61,10 @@ typedef struct{
#define DID_F180_ADDR 0x19C20
#define DID_F193_ADDR 0x19C00
-#define DIAGNOSE_STD_V_H (0x03) /* 客户诊断标准版本?*/
+#define DIAGNOSE_STD_V_H (0x03) /* ͻϱ汾 */
#define DIAGNOSE_STD_V_L (0x02)
-#define DIAGNOSE_PARAMETER_V_H (0x01) /* 诊断调查表版本号 */
+#define DIAGNOSE_PARAMETER_V_H (0x01) /* ϵ汾 */
#define DIAGNOSE_PARAMETER_V_L (0x08)
extern KamData_t KamData;
diff --git a/ECU_APP/r_cg_wdt.c b/ECU_APP/r_cg_wdt.c
index 7b944d6..fd96751 100644
--- a/ECU_APP/r_cg_wdt.c
+++ b/ECU_APP/r_cg_wdt.c
@@ -20,10 +20,10 @@
/***********************************************************************************************************************
* File Name : r_cg_wdt.c
* Version : CodeGenerator for RL78/F13 V2.03.07.02 [08 Nov 2021]
-* Device(s) : R5F10BBG
+* Device(s) : R5F10BGG
* Tool-Chain : CCRL
* Description : This file implements device driver for WDT module.
-* Creation Date: 2024-05-23
+* Creation Date: 2022/7/6
***********************************************************************************************************************/
/***********************************************************************************************************************
@@ -57,6 +57,10 @@ void R_WDT_Create(void)
{
WDTIMK = 1U; /* disable INTWDTI interrupt */
WDTIIF = 0U; /* clear INTWDTI interrupt flag */
+ /* Set INTWDTI low priority */
+ WDTIPR1 = 1U;
+ WDTIPR0 = 1U;
+ WDTIMK = 0U; /* enable INTWDTI interrupt */
}
/***********************************************************************************************************************
diff --git a/ECU_APP/r_cg_wdt.h b/ECU_APP/r_cg_wdt.h
index 953990f..9228aa0 100644
--- a/ECU_APP/r_cg_wdt.h
+++ b/ECU_APP/r_cg_wdt.h
@@ -20,10 +20,10 @@
/***********************************************************************************************************************
* File Name : r_cg_wdt.h
* Version : CodeGenerator for RL78/F13 V2.03.07.02 [08 Nov 2021]
-* Device(s) : R5F10BBG
+* Device(s) : R5F10BGG
* Tool-Chain : CCRL
* Description : This file implements device driver for WDT module.
-* Creation Date: 2024-05-23
+* Creation Date: 2022/7/6
***********************************************************************************************************************/
#ifndef WDT_H
diff --git a/ECU_APP/r_cg_wdt_user.c b/ECU_APP/r_cg_wdt_user.c
index 2ef04ec..129ed21 100644
--- a/ECU_APP/r_cg_wdt_user.c
+++ b/ECU_APP/r_cg_wdt_user.c
@@ -20,10 +20,10 @@
/***********************************************************************************************************************
* File Name : r_cg_wdt_user.c
* Version : CodeGenerator for RL78/F13 V2.03.07.02 [08 Nov 2021]
-* Device(s) : R5F10BBG
+* Device(s) : R5F10BGG
* Tool-Chain : CCRL
* Description : This file implements device driver for WDT module.
-* Creation Date: 2024-05-23
+* Creation Date: 2022/7/6
***********************************************************************************************************************/
/***********************************************************************************************************************
@@ -38,6 +38,7 @@ Includes
/***********************************************************************************************************************
Pragma directive
***********************************************************************************************************************/
+#pragma interrupt r_wdt_interrupt(vect=INTWDTI)
/* Start user code for pragma. Do not edit comment generated here */
/* End user code. Do not edit comment generated here */
@@ -47,5 +48,17 @@ Global variables and functions
/* Start user code for global. Do not edit comment generated here */
/* End user code. Do not edit comment generated here */
+/***********************************************************************************************************************
+* Function Name: r_wdt_interrupt
+* Description : This function is INTWDTI interrupt service routine.
+* Arguments : None
+* Return Value : None
+***********************************************************************************************************************/
+static void __near r_wdt_interrupt(void)
+{
+ /* Start user code. Do not edit comment generated here */
+ /* End user code. Do not edit comment generated here */
+}
+
/* Start user code for adding. Do not edit comment generated here */
/* End user code. Do not edit comment generated here */
diff --git a/ECU_APP/r_main.c b/ECU_APP/r_main.c
index c64c88d..fc12b37 100644
--- a/ECU_APP/r_main.c
+++ b/ECU_APP/r_main.c
@@ -20,10 +20,10 @@
/***********************************************************************************************************************
* File Name : r_main.c
* Version : CodeGenerator for RL78/F13 V2.03.07.02 [08 Nov 2021]
-* Device(s) : R5F10BBG
+* Device(s) : R5F10BGG
* Tool-Chain : CCRL
* Description : This file implements main function.
-* Creation Date: 2024-05-23
+* Creation Date: 2024/5/26
***********************************************************************************************************************/
/***********************************************************************************************************************
@@ -34,7 +34,6 @@ Includes
#include "r_cg_port.h"
#include "r_cg_adc.h"
#include "r_cg_timer.h"
-#include "r_cg_wdt.h"
/* Start user code for include. Do not edit comment generated here */
#include "r_rl78_can_drv.h"
#include "r_rl78_can_sfr.h"
@@ -75,12 +74,41 @@ void main(void)
{
R_MAIN_UserInit();
/* Start user code. Do not edit comment generated here */
+ //ADCE = 1U; //ADM0寄存器,1时允许A/D电压比较器的运行
+
+ /*
+ POWER_UP_DELAY_CNT=POWER_UP_DELAY_TIME; //压缩机和鼓风机的启动延时
+ POWER_UP_STATUS=1;
+ EEL_READ(); //读取数据闪存
+ R_TAU0_Channel0_Start();
+ R_TAU0_Channel2_Start();
+
+ TB9102_Enable=1;
+ TB9102_MODE=1;
+ RecFreSetOld=0xff; //初始化循环电机的旧�?
+ ModeSetOld=0xff;
+ TempSetOld=0xff;
+ Can_Msg_Change_1(); //can信息初始�?
+ */
+ /*
+ R_TAU0_Channel0_Start();//timer
+
+
+
+ C0CTRH &= ~0x0300; // 设置正常模式
+ TransmitCAN_Message(0x7FB,8,KamData.RspData); //诊断信息发�?
+
+ C0CTRH &= ~0x0300; // 设置正常模式
+
+
+
+ */
if(KamData.AckReq == ACK_REQ)
{
//FlgTemp = 1;
- C0CTRH &= ~0x0300; //
- TransmitCAN_Message(CANTP_RESP_CANID,8,KamData.RspData); //???????????????????
+ C0CTRH &= ~0x0300; // 设置正常模式
+ TransmitCAN_Message(CANTP_RESP_CANID,8,KamData.RspData); //诊断信息发�?
}
value_init();
while (1U)
@@ -102,12 +130,12 @@ void R_MAIN_UserInit(void)
/* Start user code. Do not edit comment generated here */
//hdwinit();
- DID_data_save_init(); //??????
+ DID_data_save_init(); //诊断
InitDcm_Parameter();
InitCanTp_Parameter();
CAN_Pin_init();
CAN_TX_MESSAGE_INIT();
- CanNwInit();//
+ CanNwInit();//重要!相关顺序说明:CanNwInit(); 必须在CanUserInit(); 前面初始�?否则CAN接收不到报文
R_TAU0_Channel0_Start();
CAN_STB = 0;
CanUserInit();
@@ -116,7 +144,7 @@ void R_MAIN_UserInit(void)
R_ADC_Start();
R_TAU0_Channel1_Start();
- //C0CTRHH = 0x03;
+ //C0CTRHH = 0x03; //初始化默认设置成监听模式
//C0CTRLL = 0x00;
EI();
diff --git a/ECU_APP/r_systeminit.c b/ECU_APP/r_systeminit.c
index 13dca7a..2bf55b5 100644
--- a/ECU_APP/r_systeminit.c
+++ b/ECU_APP/r_systeminit.c
@@ -20,10 +20,10 @@
/***********************************************************************************************************************
* File Name : r_systeminit.c
* Version : CodeGenerator for RL78/F13 V2.03.07.02 [08 Nov 2021]
-* Device(s) : R5F10BBG
+* Device(s) : R5F10BGG
* Tool-Chain : CCRL
* Description : This file implements system initializing function.
-* Creation Date: 2024-05-23
+* Creation Date: 2024/5/26
***********************************************************************************************************************/
/***********************************************************************************************************************
@@ -34,7 +34,6 @@ Includes
#include "r_cg_port.h"
#include "r_cg_adc.h"
#include "r_cg_timer.h"
-#include "r_cg_wdt.h"
/* Start user code for include. Do not edit comment generated here */
/* End user code. Do not edit comment generated here */
#include "r_cg_userdefine.h"
@@ -60,15 +59,16 @@ Global variables and functions
void R_Systeminit(void)
{
/* Set periperal I/O redirection */
+ PIOR0 = 0x00U;
+ PIOR1 = 0x00U;
PIOR4 = 0x00U;
- PIOR5 = 0x00U;
+ PIOR5 = 0x04U;
PIOR7 = 0x00U;
R_CGC_Get_ResetSource();
R_CGC_Create();
R_PORT_Create();
R_ADC_Create();
R_TAU0_Create();
- R_WDT_Create();
/* Set invalid memory access detection control */
IAWCTL = 0x00U;
diff --git a/ECU_APP/user/CRC.c b/ECU_APP/user/CRC.c
index eba3aba..3dd3d19 100644
--- a/ECU_APP/user/CRC.c
+++ b/ECU_APP/user/CRC.c
@@ -2,24 +2,25 @@
#include "crc.h"
//#include //用于验证和生成CRC_Table
+//X8+X4+X3+X2+1 -> 0X1D -> POLY=B8
static const unsigned char crc_table[] =
{
-0x00, 0x1d, 0x3a, 0x27, 0x74, 0x69, 0x4e, 0x53, 0xe8, 0xf5, 0xd2, 0xcf, 0x9c, 0x81, 0xa6, 0xbb,
-0xcd, 0xd0, 0xf7, 0xea, 0xb9, 0xa4, 0x83, 0x9e, 0x25, 0x38, 0x1f, 0x02, 0x51, 0x4c, 0x6b, 0x76,
-0x87, 0x9a, 0xbd, 0xa0, 0xf3, 0xee, 0xc9, 0xd4, 0x6f, 0x72, 0x55, 0x48, 0x1b, 0x06, 0x21, 0x3c,
-0x4a, 0x57, 0x70, 0x6d, 0x3e, 0x23, 0x04, 0x19, 0xa2, 0xbf, 0x98, 0x85, 0xd6, 0xcb, 0xec, 0xf1,
-0x13, 0x0e, 0x29, 0x34, 0x67, 0x7a, 0x5d, 0x40, 0xfb, 0xe6, 0xc1, 0xdc, 0x8f, 0x92, 0xb5, 0xa8,
-0xde, 0xc3, 0xe4, 0xf9, 0xaa, 0xb7, 0x90, 0x8d, 0x36, 0x2b, 0x0c, 0x11, 0x42, 0x5f, 0x78, 0x65,
-0x94, 0x89, 0xae, 0xb3, 0xe0, 0xfd, 0xda, 0xc7, 0x7c, 0x61, 0x46, 0x5b, 0x08, 0x15, 0x32, 0x2f,
-0x59, 0x44, 0x63, 0x7e, 0x2d, 0x30, 0x17, 0x0a, 0xb1, 0xac, 0x8b, 0x96, 0xc5, 0xd8, 0xff, 0xe2,
-0x26, 0x3b, 0x1c, 0x01, 0x52, 0x4f, 0x68, 0x75, 0xce, 0xd3, 0xf4, 0xe9, 0xba, 0xa7, 0x80, 0x9d,
-0xeb, 0xf6, 0xd1, 0xcc, 0x9f, 0x82, 0xa5, 0xb8, 0x03, 0x1e, 0x39, 0x24, 0x77, 0x6a, 0x4d, 0x50,
-0xa1, 0xbc, 0x9b, 0x86, 0xd5, 0xc8, 0xef, 0xf2, 0x49, 0x54, 0x73, 0x6e, 0x3d, 0x20, 0x07, 0x1a,
-0x6c, 0x71, 0x56, 0x4b, 0x18, 0x05, 0x22, 0x3f, 0x84, 0x99, 0xbe, 0xa3, 0xf0, 0xed, 0xca, 0xd7,
-0x35, 0x28, 0x0f, 0x12, 0x41, 0x5c, 0x7b, 0x66, 0xdd, 0xc0, 0xe7, 0xfa, 0xa9, 0xb4, 0x93, 0x8e,
-0xf8, 0xe5, 0xc2, 0xdf, 0x8c, 0x91, 0xb6, 0xab, 0x10, 0x0d, 0x2a, 0x37, 0x64, 0x79, 0x5e, 0x43,
-0xb2, 0xaf, 0x88, 0x95, 0xc6, 0xdb, 0xfc, 0xe1, 0x5a, 0x47, 0x60, 0x7d, 0x2e, 0x33, 0x14, 0x09,
-0x7f, 0x62, 0x45, 0x58, 0x0b, 0x16, 0x31, 0x2c, 0x97, 0x8a, 0xad, 0xb0, 0xe3, 0xfe, 0xd9, 0xc4
+0x00, 0xb8, 0xc8, 0x70, 0x28, 0x90, 0xe0, 0x58, 0x50, 0xe8, 0x98, 0x20, 0x78, 0xc0, 0xb0, 0x08,
+0xa0, 0x18, 0x68, 0xd0, 0x88, 0x30, 0x40, 0xf8, 0xf0, 0x48, 0x38, 0x80, 0xd8, 0x60, 0x10, 0xa8,
+0xf8, 0x40, 0x30, 0x88, 0xd0, 0x68, 0x18, 0xa0, 0xa8, 0x10, 0x60, 0xd8, 0x80, 0x38, 0x48, 0xf0,
+0x58, 0xe0, 0x90, 0x28, 0x70, 0xc8, 0xb8, 0x00, 0x08, 0xb0, 0xc0, 0x78, 0x20, 0x98, 0xe8, 0x50,
+0x48, 0xf0, 0x80, 0x38, 0x60, 0xd8, 0xa8, 0x10, 0x18, 0xa0, 0xd0, 0x68, 0x30, 0x88, 0xf8, 0x40,
+0xe8, 0x50, 0x20, 0x98, 0xc0, 0x78, 0x08, 0xb0, 0xb8, 0x00, 0x70, 0xc8, 0x90, 0x28, 0x58, 0xe0,
+0xb0, 0x08, 0x78, 0xc0, 0x98, 0x20, 0x50, 0xe8, 0xe0, 0x58, 0x28, 0x90, 0xc8, 0x70, 0x00, 0xb8,
+0x10, 0xa8, 0xd8, 0x60, 0x38, 0x80, 0xf0, 0x48, 0x40, 0xf8, 0x88, 0x30, 0x68, 0xd0, 0xa0, 0x18,
+0x90, 0x28, 0x58, 0xe0, 0xb8, 0x00, 0x70, 0xc8, 0xc0, 0x78, 0x08, 0xb0, 0xe8, 0x50, 0x20, 0x98,
+0x30, 0x88, 0xf8, 0x40, 0x18, 0xa0, 0xd0, 0x68, 0x60, 0xd8, 0xa8, 0x10, 0x48, 0xf0, 0x80, 0x38,
+0x68, 0xd0, 0xa0, 0x18, 0x40, 0xf8, 0x88, 0x30, 0x38, 0x80, 0xf0, 0x48, 0x10, 0xa8, 0xd8, 0x60,
+0xc8, 0x70, 0x00, 0xb8, 0xe0, 0x58, 0x28, 0x90, 0x98, 0x20, 0x50, 0xe8, 0xb0, 0x08, 0x78, 0xc0,
+0xd8, 0x60, 0x10, 0xa8, 0xf0, 0x48, 0x38, 0x80, 0x88, 0x30, 0x40, 0xf8, 0xa0, 0x18, 0x68, 0xd0,
+0x78, 0xc0, 0xb0, 0x08, 0x50, 0xe8, 0x98, 0x20, 0x28, 0x90, 0xe0, 0x58, 0x00, 0xb8, 0xc8, 0x70,
+0x20, 0x98, 0xe8, 0x50, 0x08, 0xb0, 0xc0, 0x78, 0x70, 0xc8, 0xb8, 0x00, 0x58, 0xe0, 0x90, 0x28,
+0x80, 0x38, 0x48, 0xf0, 0xa8, 0x10, 0x60, 0xd8, 0xd0, 0x68, 0x18, 0xa0, 0xf8, 0x40, 0x30, 0x88,
};
unsigned char CRC_Calc(unsigned char * dataptr,unsigned char len)
@@ -35,7 +36,8 @@ unsigned char CRC_Calc(unsigned char * dataptr,unsigned char len)
if (crc & 0x80) // 判断最高位是否为1
// 最高位为1,不需要异或,往左移一位,然后与0x31异或
// 0x31(多项式:x8+x5+x4+1,100110001),最高位不需要异或,直接去掉
- crc = (crc << 1) ^ 0x1D;
+ //X8+X4+X3+X2+1 -> 0X1D -> B8
+ crc = (crc << 1) ^ 0xB8;
else
crc = (crc << 1);
}
@@ -71,7 +73,8 @@ unsigned char cal_table_high_first(unsigned char value)
{
//最高位为1,不需要异或,往左移一位,然后与0x31异或
//0x31(多项式:x8+x5+x4+1,100110001),最高位不需要异或,直接去掉
- crc = (crc << 1) ^ 0x1D; }
+ //X8+X4+X3+X2+1 -> 0X1D -> B8
+ crc = (crc << 1) ^ 0xB8; }
else
{
//最高位为0时,不需要异或,整体数据往左移一位
@@ -96,6 +99,7 @@ void create_crc_table(void)
j = i&0xFF;
printf("0x%.2x, ", cal_table_high_first (j)); //依次计算每个字节的crc校验值
}
+ printf("\n");
}
@@ -103,6 +107,7 @@ int main()
{
unsigned char TestArr[] = {0x00,0x15,0x22,0x11,0xff,0x13,0x66};
unsigned char crc;
+ create_crc_table();
printf("crc_data = {0x00,0x15,0x22,0x11,0xff,0x13,0x66}\n");
crc = CRC_Calc(TestArr,7);
printf("CRC_Calc = 0x%x \n",crc);
diff --git a/ECU_APP/user/PINdef.h b/ECU_APP/user/PINdef.h
index ab1ba2e..ccf4cac 100644
--- a/ECU_APP/user/PINdef.h
+++ b/ECU_APP/user/PINdef.h
@@ -3,39 +3,30 @@
#include "iodefine.h"
-#define CAN_STB P1_bit.no2 //
-#define KEY_1 P12_bit.no5 //左手把-雾灯开关;右手把-后桥差速锁开关
-#define KEY_2 P3_bit.no4 //左手把-座椅加热;右手把-右转向
-#define KEY_3 P8_bit.no1
-#define KEY_4 P8_bit.no2
-#define KEY_5 P8_bit.no3
-#define KEY_6 P8_bit.no0
-#define KEY_7 P6_bit.no3
-#define KEY_8 P1_bit.no7
-#define KEY_9 P3_bit.no0
+#define CAN_STB P1_bit.no2
+#define O_BL_CTRL P1_bit.no5
+#define O_IND_CTRL P3_bit.no0
+#define O_IND1_CTRL P7_bit.no0
+#define O_IND2_CTRL P3_bit.no2
+#define O_IND3_CTRL P7_bit.no2
+#define O_IND4_CTRL P7_bit.no1
+
+#define I_SW_LOCK_IN P1_bit.no4
+#define I_SW_L_IN P3_bit.no1
typedef enum
{
- KEYID_1_P125,
- KEYID_2_P34,
- KEYID_3_P81,
- KEYID_4_P82,
- KEYID_5_P83,
- KEYID_6_P80,
- KEYID_7_P63,
- KEYID_8_P17,
- KEYID_9_P30,
- KEY_NUM,
-}KEYID_Type;
+ SIGID_SW_LOCK_IN,
+ SIGID_SW_L_IN,
+ SIG_NUM,
+}SIGID_type;
-#define ADCH_IGN 0
+#define ADCH_IGN 1
+#define ADCH_HALL 0
-#define LEFT_BOARD 1
-#define RIGHT_BOARD 2
-#define NOW_BOARD RIGHT_BOARD
#endif
diff --git a/ECU_APP/user/appTask.c b/ECU_APP/user/appTask.c
index 6487ba1..da38c5c 100644
--- a/ECU_APP/user/appTask.c
+++ b/ECU_APP/user/appTask.c
@@ -1,4 +1,4 @@
-#include "appTask.h"
+#include "appTask.h"
#include "iodefine.h"
#include "extern.h"
#include "r_cg_adc.h"
@@ -11,10 +11,11 @@
u8 can_data_init_flag = 0;
unsigned long Can_1ms_count_alive;
-unsigned char rollingcounter = 0;
-unsigned char IGN_Voltage_error_flag, IGN_Voltage_error_count;
+
+unsigned char IGN_Voltage_error_flag;
+uint16_t IGN_Voltage_error_count;
unsigned char Timer_1ms_flag;
@@ -35,23 +36,16 @@ unsigned char ucBusOffModeState; // 0:Normal 1~4:Fast Rec 5:Slow Rec
unsigned char BusoffFlag;
/***************************************************/
-
-
-
uint16_t VehicleSpeedRaw,VehicleSpeed;
uint8_t nouse;//Relocation value is odd number
-
-
-
void Apply_task(void)
{
// DiagnosticSession_Present=MngDcm_GetDiagnosticSession();
- App28sTxRxStatus = GetNormalMsgSts();
- Nw28sTxRxStatus = GetNetworkMsgSts();
+
// DiagnosticSession_Present=MngDcm_GetDiagnosticSession();
if(CAN_STB == 0 && ucBusOffModeState == 0)//Tx enable
@@ -63,37 +57,47 @@ void Apply_task(void)
Timer_1ms_flag = 0;
MngDcm_MainFunction();
MngCanTp_MainFunction();
+ App28sTxRxStatus = GetNormalMsgSts();
+ Nw28sTxRxStatus = GetNetworkMsgSts();
if (BusOff_Detect_delay_count == 0 /*&& (ad_voltage_fact[2]>=85 && ad_voltage_fact[2]<=165)*/)
{
BusOff_Detect();
}
KeyScan();
+
+ //IGN_Detect();
+ //CanNwHandle();
}
if (Timer_5ms_flag == 1)
{
Timer_5ms_flag = 0;
CAN_RX_Data_Handle();
- Can_Msg_Change();
- KeyPro();
+
+ // IGN_Detect();
+
}
if (Timer_10ms_flag == 1)
{
Timer_10ms_flag = 0;
-
+ KeyPro();
+ Can_Msg_Change();
+
+
}
if (Timer_20ms_flag == 1)
{
Timer_20ms_flag = 0;
+
IGN_Voltage_Detect();
}
if (Timer_50ms_flag == 1)
{
Timer_50ms_flag = 0;
-
- TxTestMsg();
+ BL_Ctrl(1);
+ //TxTestMsg();
//SleepDetect();//TODO
}
}
@@ -101,53 +105,40 @@ void Apply_task(void)
-#define KEY_LONGPRESS_500MS 100
-void KeyPro(void)//5ms
-{
-
-}
-void Can_Msg_Change(void)//
+
+void KeyPro(void)
{
- uint8_t i;
-
- if (IGN_Voltage_error_flag != 0)
+ //按下
+ if (getKeyPressFlag(SIGID_SW_LOCK_IN) == KEY_PRESSED)
{
- for (i = 0; i < 7; i++)
- {
- CAN_101.Msg_Byte[i] = 0x00;
- CAN_220.Msg_Byte[i] = 0x00;
- }
- CAN_101.Msg_Bit.checksum = CRC_Calc_Table(CAN_101.Msg_Byte, 7);
- CAN_220.Msg_Bit.checksum = CRC_Calc_Table(CAN_220.Msg_Byte, 7);
+
}
- else
+ if (getKeyPressFlag(SIGID_SW_L_IN) == KEY_PRESSED)
{
- CAN_101.Msg_Bit.TCS_TractionControl = GetKeyState(KEYID_4_P82);
- CAN_101.Msg_Bit.reverse11 = GetKeyState(KEYID_9_P30);
- CAN_101.Msg_Bit.reverse12 = GetKeyState(KEYID_7_P63);
- CAN_101.Msg_Bit.HandleHeating = GetKeyState(KEYID_5_P83);
- CAN_101.Msg_Bit.DifferentialLock = GetKeyState(KEYID_1_P125);
- CAN_101.Msg_Bit.RightSteering = GetKeyState(KEYID_2_P34);
- CAN_101.Msg_Bit.EngineIgnitionStopControl = GetKeyState(KEYID_3_P81);
- CAN_101.Msg_Bit.CrankingMotor = GetKeyState(KEYID_6_P80);
- CAN_101.Msg_Bit.DIST_SET = GetKeyState(KEYID_8_P17);
- CAN_101.Msg_Bit.checksum = CRC_Calc_Table(CAN_101.Msg_Byte, 7);
-
- CAN_220.Msg_Bit.SwitchButton_NearOrFarLight = GetKeyState(KEYID_4_P82);
- CAN_220.Msg_Bit.FogLampSwitch = GetKeyState(KEYID_1_P125);
- CAN_220.Msg_Bit.HeadLampSwitch = GetKeyState(KEYID_3_P81);
- CAN_220.Msg_Bit.FAxle_2_4WD_DifLock = GetKeyState(KEYID_6_P80);
- CAN_220.Msg_Bit.Trumpet = GetKeyState(KEYID_7_P63);
- CAN_220.Msg_Bit.LeftSteering = GetKeyState(KEYID_9_P30);
- CAN_220.Msg_Bit.WarningAgainstDanger = GetKeyState(KEYID_8_P17);
- CAN_220.Msg_Bit.TurnOnTheHeater = GetKeyState(KEYID_2_P34);
- CAN_220.Msg_Bit.MODEL_SEL = GetKeyState(KEYID_5_P83);
- CAN_220.Msg_Bit.checksum = CRC_Calc_Table(CAN_220.Msg_Byte, 7);
+
}
}
+void Can_Msg_Change(void)
+{
+ //CAN_45A.Msg_Part.SCM_PsngrSeatBeltWarnSts = sbrWarnState;
+ CAN_188.Msg_Part.SL_Fswitch = 0;
+ CAN_188.Msg_Part.SL_Hswitch = 0;
+ CAN_188.Msg_Part.SL_Lswitch = 0;
+ CAN_188.Msg_Part.SL_Nswitch = 0;
+ CAN_188.Msg_Part.SL_Rswitch = 0;
+ CAN_188.Msg_Part.err1 = 0;
+ CAN_188.Msg_Part.err2 = 0;
+ CAN_188.Msg_Part.err3 = 0;
+ CAN_188.Msg_Part.err4 = 0;
+ CAN_188.Msg_Part.err5 = 0;
+ CAN_188.Msg_Part.err6 = 0;
+ CAN_188.Msg_Part.err7 = 0;
+ CAN_188.Msg_Part.err8 = 0;
+ CAN_188.Msg_Part.CRC = CRC_Calc_Table(CAN_188.Msg_Byte,7);
+}
void EEL_READ(void)
{
@@ -164,7 +155,7 @@ void EEL_WRITE(void)
void EEL_Write_Enable_Check(void)
{
-
+ //EEL_SAVE_ENABLE = 1;
}
void DID_data_save_init(void)
@@ -322,33 +313,43 @@ void BusOff_Recovery(void)
C0CTRL &= 0xfffc; // bus off
}
uint16_t SupplyVoltage;
-void IGN_Voltage_Detect(void)
+uint32_t IGN_Voltage;
+void IGN_Voltage_Detect(void)//20ms
{
uint32_t adval;
adval = getAdval(ADCH_IGN);
- SupplyVoltage = (adval*57*5)>>10;
- if (adval <= 305 )
+ SupplyVoltage = (adval*57*5)>>10; //100mV
+ //adval / 1024 * 5 * 5.7
+ IGN_Voltage = ((adval*57*500)>>10) + 700;//1mv
+ if (IGN_Voltage <= 8500 )
{
IGN_Voltage_error_count++;
if (IGN_Voltage_error_count >= 250)
{
- IGN_Voltage_error_count = 0;
+ IGN_Voltage_error_count = 250;
IGN_Voltage_error_flag = 1;
}
}
- else if (adval >= 592 )//16.5
+ else if (IGN_Voltage >= 16500 )//16.5
{
IGN_Voltage_error_count++;
if (IGN_Voltage_error_count >= 250)
{
- IGN_Voltage_error_count = 0;
+ IGN_Voltage_error_count = 250;
IGN_Voltage_error_flag = 2;
}
}
- else if (adval >= 323 && adval <= 574)
+ else if (IGN_Voltage >= 9000 && IGN_Voltage <= 16000)
{
- IGN_Voltage_error_count = 0;
- IGN_Voltage_error_flag = 0;
+ if (IGN_Voltage_error_count > 0)
+ {
+ IGN_Voltage_error_count--;
+ }
+ else
+ {
+ IGN_Voltage_error_count = 0;
+ IGN_Voltage_error_flag = 0;
+ }
}
@@ -361,22 +362,15 @@ void IGN_Voltage_Detect(void)
void value_init(void)
{
- uint8_t i;
+
CAN_LostCount = 500;
BusOff_Detect_delay_count = 2000;
ucIgnStus = IGN_OFF;
-
- for (i = 0; i < 8; i++)
- {
- CAN_101.Msg_Byte[i] = 0;
- CAN_220.Msg_Byte[i] = 0;
- }
-
}
void CAN_RX_Data_Handle(void)
{
-
+
}
@@ -491,10 +485,7 @@ void IGN_Detect(void)
}
}
-void LED_Light_Ctrl(void)
-{
-}
/*****************diagnostic******************/
diff --git a/ECU_APP/user/appTask.h b/ECU_APP/user/appTask.h
index 220d5ca..1b99782 100644
--- a/ECU_APP/user/appTask.h
+++ b/ECU_APP/user/appTask.h
@@ -3,7 +3,7 @@
#include "r_cg_macrodriver.h"
-#include "r_cg_timer.h"
+
#include "r_cg_userdefine.h"
#include "r_rl78_can_sfr.h"
#include "r_rl78_can_drv.h"
@@ -14,6 +14,18 @@
/***********************************************/
+typedef struct{
+ unsigned int start;
+ unsigned int zysoft1;
+ unsigned int zysoft2;
+ unsigned int zynow;
+ unsigned int kbsoft1;
+ unsigned int kbsoft2;
+ unsigned int kbnow;
+ unsigned int checksum;
+ unsigned int stop;
+}MotorStateEE_Type;
+extern MotorStateEE_Type MotorStateEE;
@@ -24,7 +36,8 @@
typedef unsigned char u8;
typedef unsigned int u16;
-
+extern unsigned char TB9102_Enable,TB9102_Disable_count;
+extern unsigned char Motor_init_15s_count;
extern u16 ad[8];
extern u8 ad_voltage_fact[8];
@@ -32,11 +45,20 @@ extern u8 ad_voltage_fact[8];
extern unsigned long Can_1ms_count_alive;
+extern u8 RES_CYC_SET,RES_RDEF_SET,RES_CYC_SET_last;
+extern u8 RES_MODE_SET,RES_MODE_SET_last;
+extern u8 LAST_FAN_SET;
+
+extern unsigned int EEL_SAVE_CNT_DOWN_TIMER;
extern unsigned char AppliTick;
extern unsigned char AppliSchedule;
+extern u8 RDEF_OUT_FLAG,RDEF_CNT;
+extern u16 key_dither;
+extern u16 RecurrenceRunTime;
-
+extern unsigned char OFF_state,OFF_to_Fre,OFF_Fan_0,OFF_AC_off,OFF_Temp_0;
+extern unsigned char FrontDef,FrontDef_to_Fre,FrontDef_AC_on,FrontDef_Fan_6;
/*********************Network Manage****************************/
extern unsigned char ucIgnStus;
@@ -89,7 +111,6 @@ void SleepDetect(void);
void WakeUP(void);
void Signal_Lost_Detect(unsigned char Pin,unsigned char Lost_state,unsigned char *Signal_Lost,unsigned char *Signal_Lost_count,unsigned char Lost_time);
void IGN_Detect(void);
-void LED_Light_Ctrl(void);
void value_init(void);
void R_MAIN_UserInit(void);
diff --git a/ECU_APP/user/can_user.c b/ECU_APP/user/can_user.c
index d5c3bd6..77a435c 100644
--- a/ECU_APP/user/can_user.c
+++ b/ECU_APP/user/can_user.c
@@ -10,35 +10,37 @@
#include "hwCtrl.h"
-#define C_100MS_1MS 100
+#define C_50MS_1MS 50
+uint8_t rolling = 0;
unsigned char App28sTxRxStatus = 3;
unsigned char Nw28sTxRxStatus = 3;
+Can_Msg_Type_188 CAN_188;
can_frame_t TxCanMessage;
can_frame_t TxCanMessage1;
can_frame_t RxCanMessage;
unsigned char CAN_SEND_COMPLETE;
-uint16_t air_req_timer = C_100MS_1MS;
+uint16_t air_req_timer = C_50MS_1MS;
unsigned char BusOff_flag = 0;
unsigned char BusOff_IGN_cycle_count = 0;
unsigned int BusOff_Detect_delay_count = 2000;
+unsigned char Engine_Temperature, Engine_Temperature_temp;
+unsigned int Vehicle_Speed, Vehicle_Speed_temp;
+unsigned char Engine_Temperature_already, Vehicle_Speed_already;
+
+
-unsigned char Can_2F_SET_run = 0;
unsigned char DiagnosticSession_Present = 1; //
unsigned char Tx_Rx_Enable = 3; // 0:none 1:Tx 2:Rx 3:Tx Rx
-Can_Msg_Type_101 CAN_101;
-Can_Msg_Type_220 CAN_220;
extern uint16_t g_adval[12];
-extern uint16_t ZYMotorLocation;
-extern uint16_t KBMotorLocation;
void Copy_Array_to_Array(unsigned char *dest, unsigned char *src, unsigned char count)
{
@@ -53,11 +55,8 @@ void Copy_Array_to_Array(unsigned char *dest, unsigned char *src, unsigned char
void Can_Msg_Change_Bcm(void)
{
-#if NOW_BOARD == RIGHT_BOARD
- Copy_Array_to_Array(TxCanMessage.DB, CAN_101.Msg_Byte, 8);
-#else
- Copy_Array_to_Array(TxCanMessage.DB, CAN_220.Msg_Byte, 8);
-#endif
+ //CAN_45A.Msg_Part.SCM_MsgCounter = rolling;
+ Copy_Array_to_Array(TxCanMessage.DB, CAN_188.Msg_Byte, 8);
}
void CAN_TX_MESSAGE_INIT(void)
@@ -66,39 +65,36 @@ void CAN_TX_MESSAGE_INIT(void)
TxCanMessage.IDE = 0; /* IDE 0:Standard 1:Extend */
TxCanMessage.RTR = 0; /* RTR 0:Data 1:Remote */
TxCanMessage.THDSE = 0; /* Transmit History Data Store Enable */
-#if NOW_BOARD == LEFT_BOARD
- TxCanMessage.IDL = 0x220; /* ID Data (low) */
-#else
- TxCanMessage.IDL = 0x101; /* ID Data (low) */
-#endif
+ TxCanMessage.IDL = 0x188; /* ID Data (low) */
TxCanMessage.IDH = 0; /* ID Data (high) */
TxCanMessage.DLC = 8; /* DLC Data */
TxCanMessage.LBL = 0; /* Label Data */
TxCanMessage.TS = 0; /* Timestamp Data */
+ rolling = 0;
Can_Msg_Change_Bcm();
}
//extern uint8_t flagOverCurrentKB,flagOverCurrentZY;
-uint8_t txbuf1[8],txbuf2[8],txbuf3[8];
+uint8 txbuf1[8],txbuf2[8],txbuf3[8];
void TxTestMsg(void)
{
+ uint8 i;
+ uint16_t temp;
if ((App28sTxRxStatus & DCM28S_MASK_TX_DISABLE) == 0)
{
return;
}
+ txbuf1[0] = 0xff;
+
+ TransmitCAN_Message(0x336,8,txbuf1);
+
}
-//立即发送
-void ClearTxCounter(void)
-{
- Can_Msg_Change();
- air_req_timer = 0;
-}
-extern unsigned char rollingcounter;
+
void TxServe(void)
{
- //Can_RtnType re_flag;
+ Can_RtnType re_flag;
static unsigned char sucNwSendCnt = 0;
////////////////////////////////////////////////////////////////////////
@@ -146,11 +142,15 @@ void TxServe(void)
{
Can_Msg_Change_Bcm();
- R_CAN_TrmByTRFIFO0_CH0(&TxCanMessage);
+ re_flag = R_CAN_TrmByTRFIFO0_CH0(&TxCanMessage);
+ rolling++;
+ if (rolling > 0x0F)
+ {
+ rolling = 0;
+ }
//TxTestMsg();
- air_req_timer = C_100MS_1MS;
-
+ air_req_timer = C_50MS_1MS;
}
}
diff --git a/ECU_APP/user/can_user.h b/ECU_APP/user/can_user.h
index 73a156f..0f66eea 100644
--- a/ECU_APP/user/can_user.h
+++ b/ECU_APP/user/can_user.h
@@ -5,23 +5,43 @@
typedef union{
- unsigned int Msg_Word[4];
- unsigned char Msg_Byte[8];
+ unsigned int Msg_Word[2];
+ unsigned char Msg_Byte[4];
struct{
- unsigned char MSW_PsdBtnReq:2;//byte1
- unsigned char MSW_RotReq:2;
- unsigned char MSW_TogReq:4;
- unsigned char MSW_BtnFltSts:1;//byte2
- unsigned char Reserve_1:7;
- unsigned char MSW_RotStep:8;//byte3
- unsigned char Reserve_3:8;//byte4
- unsigned char Reserve_4:8;//byte5
- unsigned char Reserve_5:8;//byte6
- unsigned char Reserve_6:8;//byte7
- unsigned char Reserve_7:8;//byte8
- }Msg_Part;
-}Can_Msg_Type_212;
+ //byte 0
+ unsigned char SL_Lswitch:1;
+ unsigned char SL_Hswitch:1;
+ unsigned char SL_Fswitch:1;
+ unsigned char SL_Nswitch:1;
+ unsigned char SL_Rswitch:1;
+ unsigned char Reserve_1:3;
+
+ //byte 1
+ unsigned char Reserve_2:8;
+
+ //byte 2
+ unsigned char err1:1;
+ unsigned char err2:1;
+ unsigned char err3:1;
+ unsigned char err4:1;
+ unsigned char err5:1;
+ unsigned char err6:1;
+ unsigned char err7:1;
+ unsigned char err8:1;
+
+ //byte 3 - 6
+ unsigned char Reserve_3:8;
+ unsigned char Reserve_4:8;
+ unsigned char Reserve_5:8;
+ unsigned char Reserve_6:8;
+ //byte 7
+ unsigned char CRC:8;
+
+ }Msg_Part;
+}Can_Msg_Type_188;
+
+extern Can_Msg_Type_188 CAN_188;
@@ -39,7 +59,6 @@ extern unsigned char Engine_Temperature_already,Vehicle_Speed_already;
extern uint16_t air_req_timer;
extern unsigned char CAN_SEND_COMPLETE;
-extern unsigned char Can_2F_SET_run;
extern unsigned char DiagnosticSession_Present;//1,2,3
extern unsigned char Tx_Rx_Enable;//0:none 1:Tx 2:Rx 3:Tx Rx
@@ -55,131 +74,11 @@ void Copy_Array_to_Array(unsigned char *dest, unsigned char *src,unsigned char c
-
-/*************************VF12***********************************/
-
-typedef union{
- unsigned int Msg_Word[4];
- unsigned char Msg_Byte[8];
- struct{
- unsigned char :8; //1 0-7
- unsigned char :8; //2 8-15
- unsigned char :8; //3 16-23
- unsigned char :8; //4 24-31
- unsigned char :3; //5 32-34
- unsigned char Backlightadjust:5;//5 35-39
- unsigned char :8; //6 40-47
- unsigned char :8; //7 48-55
- unsigned char :8; //8 56-63
- }Msg_Bit;
-}Can_Msg_Type_26D;
-
-
-typedef union{
- unsigned int Msg_Word[4];
- unsigned char Msg_Byte[8];
- struct{
- unsigned char :8;//1
- unsigned char VCU_VehSpd1:3;//2
- unsigned char :5;
- unsigned char VCU_VehSpd2:8;//3
- unsigned char :6;//4
- unsigned char VCU_VehSpd3:2;
-
- unsigned char :8;//5
- unsigned char :8;//6
- unsigned char :8;//7
- unsigned char :8;//8
- }Msg_Bit;
-}Can_Msg_Type_403;
-
-
-
-typedef union{
- unsigned int Msg_Word[4];
- unsigned char Msg_Byte[8];
- struct{
- //BYTE 1
- unsigned char reverse10:4;
- unsigned char SwitchButton_NearOrFarLight:1; //(P82)远近光切换按钮
- unsigned char reverse11:1;
- unsigned char FogLampSwitch:1; //(P125)雾灯开关
- unsigned char HeadLampSwitch:1; //(P81)自动感应大灯开关
-
- //BYTE 2
- unsigned char FAxle_2_4WD_DifLock:1; //(P80)前桥2/4WD、差速锁开关
- unsigned char reverse20:3;
- unsigned char Trumpet:1; //(P63)喇叭
- unsigned char reverse21:3;
-
- //BYTE 3
- unsigned char LeftSteering:1;//(P30)左转向
- unsigned char reverse30:7;//
-
- //BYTE 4
- unsigned char WarningAgainstDanger:1;//(P17)应急灯开关
- unsigned char TurnOnTheHeater:1;//(P34)座椅加热
- unsigned char reverse40:2;//
- unsigned char MODEL_SEL:1;//(P83)MODE
- unsigned char reverse41:3;//
- //BYTE 5/6/7
- unsigned char reverse5:8;//
- unsigned char reverse6:8;//
- unsigned char reverse7:8;//
- //BYTE 8
- unsigned char checksum:8;//
- }Msg_Bit;
-}Can_Msg_Type_220;
-
-typedef union{
- unsigned int Msg_Word[4];
- unsigned char Msg_Byte[8];
- struct{
- //BYTE 1 bit 0
- unsigned char reverse10:3; //喇叭开关
- unsigned char TCS_TractionControl:1; //左转向开关
- unsigned char reverse11:1; //(P30)预留15
- unsigned char reverse12:1; //(P63)预留16
- unsigned char reverse13:2; //
-
- //BYTE 2 bit 8
- unsigned char reverse20:2; //
- unsigned char HandleHeating:1; //(P83)手把加热
- unsigned char reverse21:3; //
- unsigned char DifferentialLock:1; //(P125)后桥差速锁开关
- unsigned char reverse22:1; //
-
- //BYTE 3 bit 16
- unsigned char reverse3:8;//
-
- //BYTE 4 bit 24
- unsigned char reverse40:6;//
- unsigned char RightSteering:1;//(P34)右转向
- unsigned char reverse41:1;//
-
- //BYTE 5 bit 32
- unsigned char reverse50:4;//
- unsigned char EngineIgnitionStopControl:1;//(P81)熄火
- unsigned char reverse1:3;//
-
- //BYTE 6 bit 40
- unsigned char CrankingMotor:1;//(P80)启动
- unsigned char DIST_SET:1;//(P17)SET
- unsigned char reverse60:6;//
-
- //BYTE 7 bit 48
- unsigned char reverse7:8;//
- //BYTE 8
- unsigned char checksum:8;//5
- }Msg_Bit;
-}Can_Msg_Type_101;
-
-
extern unsigned int CAN_LostCount;
-extern Can_Msg_Type_101 CAN_101;
-extern Can_Msg_Type_220 CAN_220;
+
+
@@ -190,7 +89,5 @@ extern Can_Msg_Type_220 CAN_220;
extern void Can_init_id(can_frame_t *TxMessage,unsigned int canid);
void TxTestMsg(void);
-void ClearTxCounter(void);
-
#endif
\ No newline at end of file
diff --git a/ECU_APP/user/hwCtrl.c b/ECU_APP/user/hwCtrl.c
index d2333d4..2006e2b 100644
--- a/ECU_APP/user/hwCtrl.c
+++ b/ECU_APP/user/hwCtrl.c
@@ -4,36 +4,32 @@
#include "iodefine.h"
#include "PINdef.h"
#include "r_cg_adc.h"
-static uint8_t keystate[KEY_NUM] = {0};
-static uint8_t keyPressFlag[KEY_NUM] = {0};
-static uint8_t keyReleaseFlag[KEY_NUM] = {0};
-static uint16_t keydelay[KEY_NUM] = {0};
+static uint8_t keystate[SIG_NUM] = {0};
+static uint8_t keyPressFlag[SIG_NUM] = {0};
+static uint8_t keyReleaseFlag[SIG_NUM] = {0};
+static uint16_t keydelay[SIG_NUM] = {0};
uint16_t g_adval[12];
#define KEY_DELAY_TIMES 20 //20Ms
-#define KEY_LONG_TIMES 500 //500Ms
void ClearKeyState(void)
{
uint8_t i;
- for (i = 0; i < KEY_NUM; i++)
+ for (i = 0; i < SIG_NUM; i++)
{
keystate[i] = 0;
- keyPressFlag[i] = 0;
- keyReleaseFlag[i] = 0;
}
}
void setKeyPressFlag(uint8_t id)
{
-
- if (id < KEY_NUM)
+ if (id < SIG_NUM)
{
keyPressFlag[id] = KEY_PRESSED;
}
}
void setKeyReleaseFlag(uint8_t id)
{
-
- if (id < KEY_NUM)
+
+ if (id < SIG_NUM)
{
keyReleaseFlag[id] = KEY_PRESSED;
}
@@ -41,8 +37,7 @@ void setKeyReleaseFlag(uint8_t id)
uint8_t getKeyPressFlag(uint8_t id)
{
uint8_t retVal = KEY_NOPRESSED;
-
- if (id < KEY_NUM)
+ if (id < SIG_NUM)
{
retVal = keyPressFlag[id];
keyPressFlag[id] = KEY_NOPRESSED;
@@ -52,8 +47,7 @@ uint8_t getKeyPressFlag(uint8_t id)
uint8_t getKeyReleaseFlag(uint8_t id)
{
uint8_t retVal = KEY_NOPRESSED;
-
- if (id < KEY_NUM)
+ if (id < SIG_NUM)
{
retVal = keyReleaseFlag[id];
keyReleaseFlag[id] = KEY_NOPRESSED;
@@ -61,34 +55,43 @@ uint8_t getKeyReleaseFlag(uint8_t id)
return retVal;
}
-void KeyScan(void)//1ms
+void KeyScan(void)
{
- uint8_t i,key;
- for (i = 0; i < KEY_NUM; i++)
+ uint8_t i,key,key_nopress;
+ key_nopress = 0;
+ for (i = 0; i < SIG_NUM; i++)
{
key = GetIOState(i);
- if (key == KEY_PRESSED)
+ if (key == KEY_PRESSED && keystate[i] == KEY_NOPRESSED)
{
keydelay[i]++;
if (keydelay[i] >= KEY_DELAY_TIMES)
{
keystate[i] = KEY_PRESSED;
-
+ setKeyPressFlag(i);
}
}
else if(key == KEY_NOPRESSED)
{
- if(keydelay[i] > 5)keydelay[i] = 5;
if (keydelay[i] > 0)
{
keydelay[i]--;
}
else
{
+ if (keystate[i] == KEY_PRESSED)
+ {
+ setKeyReleaseFlag(i);
+ }
keystate[i] = KEY_NOPRESSED;
+ key_nopress++;
}
}
}
+ if (key_nopress == 6)
+ {
+ //
+ }
}
@@ -98,33 +101,10 @@ uint8_t GetIOState(uint8_t keyno)
switch (keyno)
{
//KEY
- case KEYID_1_P125 :
- return KEY_1==0?1:0;
-
- case KEYID_2_P34 :
- return KEY_2==0?1:0;
-
- case KEYID_3_P81 :
- return KEY_3==0?1:0;
-
- case KEYID_4_P82 :
- return KEY_4==0?1:0;
-
- case KEYID_5_P83 :
- return KEY_5==0?1:0;
-
- case KEYID_6_P80 :
- return KEY_6==0?1:0;
-
- case KEYID_7_P63 :
- return KEY_7==0?1:0;
-
- case KEYID_8_P17 :
- return KEY_8==0?1:0;
-
- case KEYID_9_P30 :
- return KEY_9==0?1:0;
-
+ case SIGID_SW_LOCK_IN:
+ return I_SW_LOCK_IN==0?1:0;
+ case SIGID_SW_L_IN:
+ return I_SW_L_IN==0?1:0;
default:
return 0;
}
@@ -132,17 +112,77 @@ uint8_t GetIOState(uint8_t keyno)
uint8_t GetKeyState(uint8_t keyno)
{
- if (keyno < KEY_NUM)
+ if (keyno < SIG_NUM)
{
- return keystate[keyno];
+ return keystate[keyno-1];
}
return KEY_NOPRESSED;
}
+void BL_Ctrl(uint8_t bl_state)
+{
+ if (bl_state != 0)
+ {
+ O_BL_CTRL = 1;
+ }
+ else
+ {
+ O_BL_CTRL = 0;
+ }
+
+}
+
+void IND_Ctrl(uint8_t ind_state)
+{
+ switch (ind_state)
+ {
+ case 0:
+ O_IND_CTRL = 0;
+ O_IND1_CTRL = 0;
+ O_IND2_CTRL = 0;
+ O_IND3_CTRL = 0;
+ O_IND4_CTRL = 0;
+ break;
+ case 1:
+ O_IND_CTRL = 1;
+ O_IND1_CTRL = 1;
+ O_IND2_CTRL = 0;
+ O_IND3_CTRL = 0;
+ O_IND4_CTRL = 0;
+ break;
+
+ case 2:
+ O_IND_CTRL = 1;
+ O_IND1_CTRL = 0;
+ O_IND2_CTRL = 1;
+ O_IND3_CTRL = 0;
+ O_IND4_CTRL = 0;
+ break;
+
+ case 3:
+ O_IND_CTRL = 1;
+ O_IND1_CTRL = 0;
+ O_IND2_CTRL = 0;
+ O_IND3_CTRL = 1;
+ O_IND4_CTRL = 0;
+ break;
+
+ case 4:
+ O_IND_CTRL = 1;
+ O_IND1_CTRL = 0;
+ O_IND2_CTRL = 0;
+ O_IND3_CTRL = 0;
+ O_IND4_CTRL = 1;
+ break;
+ default:
+ break;
+ }
+}
+
uint16_t getAdval(uint8_t ch)
{
- if (ch < 1)
+ if (ch < 12)
{
return g_adval[ch];
}
@@ -152,21 +192,30 @@ uint16_t getAdval(uint8_t ch)
void ad_handle(void)
{
- //uint8_t adch=0;
- //adch = ADS - 2;
- R_ADC_Get_Result(&g_adval[0]);//adch
- /*
- adch++;
- if (adch > 6)
+ switch (ADS)
{
- adch = 0;
+ case _00_AD_INPUT_CHANNEL_0:
+ R_ADC_Get_Result(g_adval);
+ ADS = _01_AD_INPUT_CHANNEL_1;
+ break;
+ case _01_AD_INPUT_CHANNEL_1:
+ R_ADC_Get_Result(g_adval+1);
+ ADS = _00_AD_INPUT_CHANNEL_0;
+ break;
+
+ default:
+ ADS = _00_AD_INPUT_CHANNEL_0;
+ break;
}
-
- ADS = adch + 2;
- */
}
/*****************diagnostic******************/
+void getInputStatus(unsigned char* data)
+{
+ data[0] = 0;
+
+}
+
diff --git a/ECU_APP/user/hwCtrl.h b/ECU_APP/user/hwCtrl.h
index e1862ea..b85d5ce 100644
--- a/ECU_APP/user/hwCtrl.h
+++ b/ECU_APP/user/hwCtrl.h
@@ -5,22 +5,23 @@
-#define KEY_Long_PRESSED 2
-#define KEY_PRESSED 1
-#define KEY_NOPRESSED 0
+#define KEY_PRESSED 1
+#define KEY_NOPRESSED 0
uint8_t GetKeyState(uint8_t keyno);
void KeyScan(void);
uint8_t GetIOState(uint8_t keyno);
+
void ad_handle(void);
uint16_t getAdval(uint8_t ch);
void ClearKeyState(void);
uint8_t getKeyReleaseFlag(uint8_t id);
uint8_t getKeyPressFlag(uint8_t id);
-
-
+void getInputStatus(unsigned char* data);
+void BL_Ctrl(uint8_t bl_state);
+void IND_Ctrl(uint8_t ind_state);
#endif