Browse Source

增加对ACC_MOTINOVA、ACC_WELLING_EN管脚的初始化配置,并在接收到上电指令后,将ACC_MOTINOVA置高,ACC_WELLING_EN置高3s后置低;接收到下电指令后,将ACC_MOTINOVA置低,ACC_WELLING_EN置高1s后置低;
CAN波特率由125k更改为250k;

Ye Jin 1 year ago
parent
commit
b408de780d

+ 4 - 0
MOTINOVA_CDL_App/Inc/main.h

@@ -53,6 +53,10 @@
 #define PowerSwitch_GPIO_Port GPIOA
 #define SwitchOnOrOff_Pin GPIO_PIN_6
 #define SwitchOnOrOff_GPIO_Port GPIOA
+#define ACC_MOTINOVA_EN_Pin GPIO_PIN_7
+#define ACC_MOTINOVA_EN_GPIO_Port GPIOA
+#define ACC_WELLING_EN_Pin GPIO_PIN_0
+#define ACC_WELLING_EN_GPIO_Port GPIOB
 #define LED_MCU_Pin GPIO_PIN_12
 #define LED_MCU_GPIO_Port GPIOB
 #define LED_Display_Pin GPIO_PIN_13

+ 3 - 0
MOTINOVA_CDL_App/Inc/uart_process.h

@@ -11,7 +11,10 @@
 #define MODE_WRITE (uint8_t)0x16
 #define MODE_REPORT (uint8_t)0x0C
 
+extern uint8_t Power_mode;//0-default,1-off,2-on
+
 extern void Uart_RxData_Process(USART_Buf_TypeDef* ptUartRx, uint16_t TimeOut);
 extern void SendCmdData(USART_Buf_TypeDef * ptTx, uint8_t Mode, uint16_t Cmd, uint8_t* Data);
+extern void PowerOnOff(uint8_t *mode);
 
 #endif

+ 36 - 0
MOTINOVA_CDL_App/MDK-ARM/DebugConfig/MOTINOVA_CDL_STM32F103C8_1.0.0.dbgconf

@@ -0,0 +1,36 @@
+// File: STM32F101_102_103_105_107.dbgconf
+// Version: 1.0.0
+// Note: refer to STM32F101xx STM32F102xx STM32F103xx STM32F105xx STM32F107xx Reference manual (RM0008)
+//                STM32F101xx STM32F102xx STM32F103xx STM32F105xx STM32F107xx datasheets
+
+// <<< Use Configuration Wizard in Context Menu >>>
+
+// <h> Debug MCU configuration register (DBGMCU_CR)
+//                                   <i> Reserved bits must be kept at reset value
+//   <o.30> DBG_TIM11_STOP           <i> TIM11 counter stopped when core is halted
+//   <o.29> DBG_TIM10_STOP           <i> TIM10 counter stopped when core is halted
+//   <o.28> DBG_TIM9_STOP            <i> TIM9 counter stopped when core is halted
+//   <o.27> DBG_TIM14_STOP           <i> TIM14 counter stopped when core is halted
+//   <o.26> DBG_TIM13_STOP           <i> TIM13 counter stopped when core is halted
+//   <o.25> DBG_TIM12_STOP           <i> TIM12 counter stopped when core is halted
+//   <o.21> DBG_CAN2_STOP            <i> Debug CAN2 stopped when core is halted
+//   <o.20> DBG_TIM7_STOP            <i> TIM7 counter stopped when core is halted
+//   <o.19> DBG_TIM6_STOP            <i> TIM6 counter stopped when core is halted
+//   <o.18> DBG_TIM5_STOP            <i> TIM5 counter stopped when core is halted
+//   <o.17> DBG_TIM8_STOP            <i> TIM8 counter stopped when core is halted
+//   <o.16> DBG_I2C2_SMBUS_TIMEOUT   <i> SMBUS timeout mode stopped when core is halted
+//   <o.15> DBG_I2C1_SMBUS_TIMEOUT   <i> SMBUS timeout mode stopped when core is halted
+//   <o.14> DBG_CAN1_STOP            <i> Debug CAN1 stopped when Core is halted
+//   <o.13> DBG_TIM4_STOP            <i> TIM4 counter stopped when core is halted
+//   <o.12> DBG_TIM3_STOP            <i> TIM3 counter stopped when core is halted
+//   <o.11> DBG_TIM2_STOP            <i> TIM2 counter stopped when core is halted
+//   <o.10> DBG_TIM1_STOP            <i> TIM1 counter stopped when core is halted
+//   <o.9>  DBG_WWDG_STOP            <i> Debug window watchdog stopped when core is halted
+//   <o.8>  DBG_IWDG_STOP            <i> Debug independent watchdog stopped when core is halted
+//   <o.2>  DBG_STANDBY              <i> Debug standby mode
+//   <o.1>  DBG_STOP                 <i> Debug stop mode
+//   <o.0>  DBG_SLEEP                <i> Debug sleep mode
+// </h>
+DbgMCU_CR = 0x00000007;
+
+// <<< end of configuration section >>>

+ 36 - 0
MOTINOVA_CDL_App/MDK-ARM/DebugConfig/MOTINOVA_CDL_STM32F103CB_1.0.0.dbgconf

@@ -0,0 +1,36 @@
+// File: STM32F101_102_103_105_107.dbgconf
+// Version: 1.0.0
+// Note: refer to STM32F101xx STM32F102xx STM32F103xx STM32F105xx STM32F107xx Reference manual (RM0008)
+//                STM32F101xx STM32F102xx STM32F103xx STM32F105xx STM32F107xx datasheets
+
+// <<< Use Configuration Wizard in Context Menu >>>
+
+// <h> Debug MCU configuration register (DBGMCU_CR)
+//                                   <i> Reserved bits must be kept at reset value
+//   <o.30> DBG_TIM11_STOP           <i> TIM11 counter stopped when core is halted
+//   <o.29> DBG_TIM10_STOP           <i> TIM10 counter stopped when core is halted
+//   <o.28> DBG_TIM9_STOP            <i> TIM9 counter stopped when core is halted
+//   <o.27> DBG_TIM14_STOP           <i> TIM14 counter stopped when core is halted
+//   <o.26> DBG_TIM13_STOP           <i> TIM13 counter stopped when core is halted
+//   <o.25> DBG_TIM12_STOP           <i> TIM12 counter stopped when core is halted
+//   <o.21> DBG_CAN2_STOP            <i> Debug CAN2 stopped when core is halted
+//   <o.20> DBG_TIM7_STOP            <i> TIM7 counter stopped when core is halted
+//   <o.19> DBG_TIM6_STOP            <i> TIM6 counter stopped when core is halted
+//   <o.18> DBG_TIM5_STOP            <i> TIM5 counter stopped when core is halted
+//   <o.17> DBG_TIM8_STOP            <i> TIM8 counter stopped when core is halted
+//   <o.16> DBG_I2C2_SMBUS_TIMEOUT   <i> SMBUS timeout mode stopped when core is halted
+//   <o.15> DBG_I2C1_SMBUS_TIMEOUT   <i> SMBUS timeout mode stopped when core is halted
+//   <o.14> DBG_CAN1_STOP            <i> Debug CAN1 stopped when Core is halted
+//   <o.13> DBG_TIM4_STOP            <i> TIM4 counter stopped when core is halted
+//   <o.12> DBG_TIM3_STOP            <i> TIM3 counter stopped when core is halted
+//   <o.11> DBG_TIM2_STOP            <i> TIM2 counter stopped when core is halted
+//   <o.10> DBG_TIM1_STOP            <i> TIM1 counter stopped when core is halted
+//   <o.9>  DBG_WWDG_STOP            <i> Debug window watchdog stopped when core is halted
+//   <o.8>  DBG_IWDG_STOP            <i> Debug independent watchdog stopped when core is halted
+//   <o.2>  DBG_STANDBY              <i> Debug standby mode
+//   <o.1>  DBG_STOP                 <i> Debug stop mode
+//   <o.0>  DBG_SLEEP                <i> Debug sleep mode
+// </h>
+DbgMCU_CR = 0x00000007;
+
+// <<< end of configuration section >>>

+ 12 - 12
MOTINOVA_CDL_App/MDK-ARM/MOTINOVA_CDL.uvprojx

@@ -14,14 +14,14 @@
         <TargetCommonOption>
           <Device>STM32F103CB</Device>
           <Vendor>STMicroelectronics</Vendor>
-          <PackID>Keil.STM32F1xx_DFP.1.1.0</PackID>
+          <PackID>Keil.STM32F1xx_DFP.2.3.0</PackID>
           <PackURL>http://www.keil.com/pack/</PackURL>
-          <Cpu>IRAM(0x20000000-0x20004FFF) IROM(0x8000000-0x801FFFF) CLOCK(8000000) CPUTYPE("Cortex-M3")</Cpu>
+          <Cpu>IROM(0x08000000,0x00020000) IRAM(0x20000000,0x00005000) CPUTYPE("Cortex-M3") CLOCK(12000000) ELITTLE</Cpu>
           <FlashUtilSpec></FlashUtilSpec>
           <StartupFile></StartupFile>
-          <FlashDriverDll></FlashDriverDll>
-          <DeviceId></DeviceId>
-          <RegisterFile></RegisterFile>
+          <FlashDriverDll>UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0STM32F10x_128 -FS08000000 -FL020000 -FP0($$Device:STM32F103CB$Flash\STM32F10x_128.FLM))</FlashDriverDll>
+          <DeviceId>0</DeviceId>
+          <RegisterFile>$$Device:STM32F103CB$Device\Include\stm32f10x.h</RegisterFile>
           <MemoryEnv></MemoryEnv>
           <Cmp></Cmp>
           <Asm></Asm>
@@ -80,7 +80,7 @@
           <AfterMake>
             <RunUserProg1>1</RunUserProg1>
             <RunUserProg2>0</RunUserProg2>
-            <UserProg1Name>C:\Keil_v5\ARM\ARMCC\bin\fromelf.exe --bin --output ./bin/MOTINOVA_CDL_APP.bin ./MOTINOVA_CDL/MOTINOVA_CDL.axf</UserProg1Name>
+            <UserProg1Name>D:\software\keil\ARM\ARMCC\bin\fromelf.exe --bin --output ./bin/MOTINOVA_CDL_APP.bin ./MOTINOVA_CDL/MOTINOVA_CDL.axf</UserProg1Name>
             <UserProg2Name></UserProg2Name>
             <UserProg1Dos16Mode>0</UserProg1Dos16Mode>
             <UserProg2Dos16Mode>0</UserProg2Dos16Mode>
@@ -108,7 +108,7 @@
         </CommonProperty>
         <DllOption>
           <SimDllName>SARMCM3.DLL</SimDllName>
-          <SimDllArguments>-REMAP</SimDllArguments>
+          <SimDllArguments> -REMAP</SimDllArguments>
           <SimDlgDll>DCM.DLL</SimDlgDll>
           <SimDlgDllArguments>-pCM3</SimDlgDllArguments>
           <TargetDllName>SARMCM3.DLL</TargetDllName>
@@ -149,7 +149,7 @@
             <RestoreSysVw>1</RestoreSysVw>
           </Target>
           <RunDebugAfterBuild>0</RunDebugAfterBuild>
-          <TargetSelection>6</TargetSelection>
+          <TargetSelection>1</TargetSelection>
           <SimDlls>
             <CpuDll></CpuDll>
             <CpuDllArguments></CpuDllArguments>
@@ -163,7 +163,7 @@
             <PeripheralDll></PeripheralDll>
             <PeripheralDllArguments></PeripheralDllArguments>
             <InitializationFile></InitializationFile>
-            <Driver>Segger\JL2CM3.dll</Driver>
+            <Driver>BIN\UL2CM3.DLL</Driver>
           </TargetDlls>
         </DebugOption>
         <Utilities>
@@ -176,7 +176,7 @@
             <DriverSelection>4107</DriverSelection>
           </Flash1>
           <bUseTDR>1</bUseTDR>
-          <Flash2>STLink\ST-LINKIII-KEIL_SWO.dll</Flash2>
+          <Flash2>BIN\UL2CM3.DLL</Flash2>
           <Flash3></Flash3>
           <Flash4></Flash4>
           <pFcarmOut></pFcarmOut>
@@ -614,8 +614,8 @@
   <RTE>
     <apis/>
     <components>
-      <component Cclass="CMSIS" Cgroup="CORE" Cvendor="ARM" Cversion="4.3.0" condition="CMSIS Core">
-        <package name="CMSIS" schemaVersion="1.3" url="http://www.keil.com/pack/" vendor="ARM" version="4.5.0"/>
+      <component Cclass="CMSIS" Cgroup="CORE" Cvendor="ARM" Cversion="4.1.0" condition="CMSIS Core">
+        <package name="CMSIS" schemaVersion="1.3" url="http://www.keil.com/pack/" vendor="ARM" version="4.3.0"/>
         <targetInfos>
           <targetInfo name="MOTINOVA_CDL"/>
         </targetInfos>

File diff suppressed because it is too large
+ 383 - 383
MOTINOVA_CDL_App/MDK-ARM/MOTINOVA_CDL/MOTINOVA_CDL.hex


+ 2 - 2
MOTINOVA_CDL_App/MDK-ARM/MOTINOVA_CDL/MOTINOVA_CDL_sct.Bak

@@ -2,8 +2,8 @@
 ; *** Scatter-Loading Description File generated by uVision ***
 ; *************************************************************
 
-LR_IROM1 0x08003000 0x00020000  {    ; load region size_region
-  ER_IROM1 0x08003000 0x00020000  {  ; load address = execution address
+LR_IROM1 0x08000000 0x00020000  {    ; load region size_region
+  ER_IROM1 0x08000000 0x00020000  {  ; load address = execution address
    *.o (RESET, +First)
    *(InRoot$$Sections)
    .ANY (+RO)

BIN
MOTINOVA_CDL_App/MDK-ARM/bin/MOTINOVA_CDL_APP_2r1r0_20230718_250K.bin


+ 6 - 6
MOTINOVA_CDL_App/MDK-ARM/startup_stm32f103xb.lst

@@ -497,11 +497,11 @@ ARM Macro Assembler    Page 8
               00000000 
 Command Line: --debug --xref --diag_suppress=9931 --cpu=Cortex-M3 --apcs=interw
 ork --depend=motinova_cdl\startup_stm32f103xb.d -omotinova_cdl\startup_stm32f10
-3xb.o -ID:\SoftDesign\20190820_MOTINOVA_CDL\MOTINOVA_CDL_App\MDK-ARM\RTE -IC:\K
-eil_v5\ARM\PACK\ARM\CMSIS\4.4.0\CMSIS\Include -IC:\Keil_v5\ARM\PACK\Keil\STM32F
-1xx_DFP\1.1.0\Device\Include --predefine="__MICROLIB SETA 1" --predefine="__UVI
-SION_VERSION SETA 515" --predefine="_RTE_ SETA 1" --predefine="STM32F10X_MD SET
-A 1" --list=startup_stm32f103xb.lst startup_stm32f103xb.s
+3xb.o -IG:\0.project\MOTINOVA_CDL\MOTINOVA_CDL_App\MDK-ARM\RTE -ID:\software\ke
+il\ARM\CMSIS\4.3.0\CMSIS\Include -ID:\software\keil\Keil\STM32F1xx_DFP\2.3.0\De
+vice\Include --predefine="__EVAL SETA 1" --predefine="__MICROLIB SETA 1" --pred
+efine="__UVISION_VERSION SETA 515" --predefine="_RTE_ SETA 1" --predefine="STM3
+2F10X_MD SETA 1" --list=startup_stm32f103xb.lst startup_stm32f103xb.s
 
 
 
@@ -1208,4 +1208,4 @@ Symbol: __main
       At line 152 in file startup_stm32f103xb.s
 Comment: __main used once
 2 symbols
-406 symbols in table
+407 symbols in table

+ 1 - 1
MOTINOVA_CDL_App/Src/can.c

@@ -89,7 +89,7 @@ void MX_CAN_Init(void)
 {
 
   hcan.Instance = CAN1;
-  hcan.Init.Prescaler = 48;
+  hcan.Init.Prescaler = 24;
   hcan.Init.Mode = CAN_MODE_NORMAL;
   hcan.Init.SJW = CAN_SJW_1TQ;
   hcan.Init.BS1 = CAN_BS1_4TQ;

+ 4 - 3
MOTINOVA_CDL_App/Src/gpio.c

@@ -71,18 +71,19 @@ void MX_GPIO_Init(void)
   /*Configure GPIO pin Output Level */
   HAL_GPIO_WritePin(GPIOA, PowerSwitch_Pin, GPIO_PIN_RESET);
 	HAL_GPIO_WritePin(GPIOA, SwitchOnOrOff_Pin, GPIO_PIN_RESET);
+	HAL_GPIO_WritePin(GPIOA, ACC_MOTINOVA_EN_Pin, GPIO_PIN_RESET);
 
   /*Configure GPIO pin Output Level */
-  HAL_GPIO_WritePin(GPIOB, LED_MCU_Pin|LED_Display_Pin, GPIO_PIN_RESET);
+  HAL_GPIO_WritePin(GPIOB, LED_MCU_Pin|LED_Display_Pin|ACC_WELLING_EN_Pin, GPIO_PIN_RESET);
 
   /*Configure GPIO pins : PAPin PAPin */
-  GPIO_InitStruct.Pin = PowerSwitch_Pin|SwitchOnOrOff_Pin;
+  GPIO_InitStruct.Pin = PowerSwitch_Pin|SwitchOnOrOff_Pin|ACC_MOTINOVA_EN_Pin;
   GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
   GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
   HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
 
   /*Configure GPIO pins : PBPin PBPin */
-  GPIO_InitStruct.Pin = LED_MCU_Pin|LED_Display_Pin;
+  GPIO_InitStruct.Pin = LED_MCU_Pin|LED_Display_Pin|ACC_WELLING_EN_Pin;
   GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
   GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
   HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);

+ 3 - 0
MOTINOVA_CDL_App/Src/main.c

@@ -140,6 +140,9 @@ int main(void)
 		//UART3数据解析
 		Uart_RxData_Process(&UART_RxBuff_Struct3, 200);
 		
+		//控制上下电
+		PowerOnOff(&Power_mode);
+		
 		if(IsCtfFlag == TRUE)
 		{
 			//CAN数据解析

+ 41 - 1
MOTINOVA_CDL_App/Src/uart_process.c

@@ -8,6 +8,28 @@
 #include "Update.h"
 #include "ctf_process.h"
 
+uint8_t Power_mode = 0;//0-default,1-off,2-on
+uint32_t T_startPowerOnOff = 0;
+
+void PowerOnOff(uint8_t *mode)
+{
+	if(*mode == 1)
+	{
+		if((HAL_GetTick() - T_startPowerOnOff) >= 1000)//Off延时1s
+		{
+			HAL_GPIO_WritePin(ACC_WELLING_EN_GPIO_Port, ACC_WELLING_EN_Pin, GPIO_PIN_RESET);//Off
+			*mode = 0;
+		}
+	}
+	else if(*mode == 2)
+	{
+		if((HAL_GetTick() - T_startPowerOnOff) >= 3000)//On延时3s
+		{
+			HAL_GPIO_WritePin(ACC_WELLING_EN_GPIO_Port, ACC_WELLING_EN_Pin, GPIO_PIN_RESET);//Off
+			*mode = 0;
+		}
+	}
+}
 //命令处理
 static void UART_DataProcess(uint8_t Mode, uint16_t Command, uint8_t* Data)
 {
@@ -22,13 +44,31 @@ static void UART_DataProcess(uint8_t Mode, uint16_t Command, uint8_t* Data)
 		//设备开关机
 		case 0x2201:
 		{
+			if(Power_mode == 0)
+			{
+				T_startPowerOnOff = HAL_GetTick();
+				
+				if(Data[0] == 0xF0)//关机
+				{			
+					Power_mode = 1;
+					HAL_GPIO_WritePin(ACC_WELLING_EN_GPIO_Port, ACC_WELLING_EN_Pin, GPIO_PIN_SET);//On
+				}
+				else if(Data[0] == 0xF1)//开机
+				{
+					Power_mode = 2;
+					HAL_GPIO_WritePin(ACC_WELLING_EN_GPIO_Port, ACC_WELLING_EN_Pin, GPIO_PIN_SET);//On
+				}
+			}
+			
 		  if(Data[0] == 0xF0)//关机
 			{
 			  HAL_GPIO_WritePin(SwitchOnOrOff_GPIO_Port, SwitchOnOrOff_Pin, GPIO_PIN_RESET);
+			  HAL_GPIO_WritePin(ACC_MOTINOVA_EN_GPIO_Port, ACC_MOTINOVA_EN_Pin, GPIO_PIN_RESET);
 			}
 			else if(Data[0] == 0xF1)//开机
 			{
 			  HAL_GPIO_WritePin(SwitchOnOrOff_GPIO_Port, SwitchOnOrOff_Pin, GPIO_PIN_SET);
+			  HAL_GPIO_WritePin(ACC_MOTINOVA_EN_GPIO_Port, ACC_MOTINOVA_EN_Pin, GPIO_PIN_SET);
 			}
 			break;
 		}
@@ -52,7 +92,7 @@ static void UART_DataProcess(uint8_t Mode, uint16_t Command, uint8_t* Data)
 			memcpy(InputKey, Data + 12, 8);
 			CheckCodeCal(InputCode, InputKey, OutputCode);
 			memcpy(SendData, OutputCode, 12);
-			memcpy(SendData + 12, (uint8_t*)"V1.5.1_20200702", 15);
+			memcpy(SendData + 12, (uint8_t*)"V2.1.0_20230718", 15);
 			
 			SendCmdData(&UART_TxBuff_Struct3, MODE_REPORT, 0x551B, SendData);
 			break;

Some files were not shown because too many files changed in this diff