初版调试完成
This commit is contained in:
+36
-89
@@ -103,7 +103,7 @@
|
||||
<bEvRecOn>1</bEvRecOn>
|
||||
<bSchkAxf>0</bSchkAxf>
|
||||
<bTchkAxf>0</bTchkAxf>
|
||||
<nTsel>12</nTsel>
|
||||
<nTsel>3</nTsel>
|
||||
<sDll></sDll>
|
||||
<sDllPa></sDllPa>
|
||||
<sDlgDll></sDlgDll>
|
||||
@@ -145,7 +145,7 @@
|
||||
<SetRegEntry>
|
||||
<Number>0</Number>
|
||||
<Key>CMSIS_AGDI</Key>
|
||||
<Name>-X"Any" -UAny -O206 -S0 -C0 -P00000000 -N00("") -D00(00000000) -L00(0) -TO65554 -TC10000000 -TT10000000 -TP20 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO15 -FD1FFF8000 -FC1000 -FN2 -FF0HC32F460_512K.FLM -FS00 -FL080000 -FP0($$Device:HC32F460JETA$FlashARM\HC32F460_512K.FLM) -FF1HC32F460_otp.FLM -FS13000C00 -FL13FC -FP1($$Device:HC32F460JETA$FlashARM\HC32F460_otp.FLM)</Name>
|
||||
<Name>-X"Any" -UAny -O206 -S0 -C0 -P00000000 -N00("ARM CoreSight SW-DP") -D00(2BA01477) -L00(0) -TO65554 -TC10000000 -TT10000000 -TP20 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO15 -FD1FFF8000 -FC1000 -FN2 -FF0HC32F460_512K.FLM -FS00 -FL080000 -FP0($$Device:HC32F460JETA$FlashARM\HC32F460_512K.FLM) -FF1HC32F460_otp.FLM -FS13000C00 -FL13FC -FP1($$Device:HC32F460JETA$FlashARM\HC32F460_otp.FLM)</Name>
|
||||
</SetRegEntry>
|
||||
<SetRegEntry>
|
||||
<Number>0</Number>
|
||||
@@ -153,40 +153,7 @@
|
||||
<Name>UL2CM3(-S0 -C0 -P0 -FD1FFF8000 -FC1000 -FN2 -FF0HC32F460_512K -FS00 -FL080000 -FF1HC32F460_otp -FS13000C00 -FL13FC -FP0($$Device:HC32F460JETA$FlashARM\HC32F460_512K.FLM) -FP1($$Device:HC32F460JETA$FlashARM\HC32F460_otp.FLM))</Name>
|
||||
</SetRegEntry>
|
||||
</TargetDriverDllRegistry>
|
||||
<Breakpoint>
|
||||
<Bp>
|
||||
<Number>0</Number>
|
||||
<Type>0</Type>
|
||||
<LineNumber>1118</LineNumber>
|
||||
<EnabledFlag>1</EnabledFlag>
|
||||
<Address>4658</Address>
|
||||
<ByteObject>0</ByteObject>
|
||||
<HtxType>0</HtxType>
|
||||
<ManyObjects>0</ManyObjects>
|
||||
<SizeOfObject>0</SizeOfObject>
|
||||
<BreakByAccess>0</BreakByAccess>
|
||||
<BreakIfRCount>1</BreakIfRCount>
|
||||
<Filename>..\source\User\Src\main.c</Filename>
|
||||
<ExecCommand></ExecCommand>
|
||||
<Expression>\\BombSensor\../source/User/Src/main.c\1118</Expression>
|
||||
</Bp>
|
||||
<Bp>
|
||||
<Number>1</Number>
|
||||
<Type>0</Type>
|
||||
<LineNumber>1156</LineNumber>
|
||||
<EnabledFlag>1</EnabledFlag>
|
||||
<Address>5298</Address>
|
||||
<ByteObject>0</ByteObject>
|
||||
<HtxType>0</HtxType>
|
||||
<ManyObjects>0</ManyObjects>
|
||||
<SizeOfObject>0</SizeOfObject>
|
||||
<BreakByAccess>0</BreakByAccess>
|
||||
<BreakIfRCount>1</BreakIfRCount>
|
||||
<Filename>..\source\User\Src\main.c</Filename>
|
||||
<ExecCommand></ExecCommand>
|
||||
<Expression>\\BombSensor\../source/User/Src/main.c\1156</Expression>
|
||||
</Bp>
|
||||
</Breakpoint>
|
||||
<Breakpoint/>
|
||||
<WatchWindow1>
|
||||
<Ww>
|
||||
<count>0</count>
|
||||
@@ -251,97 +218,57 @@
|
||||
<Ww>
|
||||
<count>12</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>App.SlopeCollDelay1mSCnt,0x0A</ItemText>
|
||||
<ItemText>App.EmergencyDelay1mSCnt,0x0A</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>13</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>App.EmergencyDelay1mSCnt,0x0A</ItemText>
|
||||
<ItemText>App.MotorPara.Current_height,0x0A</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>14</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>App.MotorPara.LU_HeightStress,0x0A</ItemText>
|
||||
<ItemText>App.RightUpCS1237_SlopeArray[0],0x0A</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>15</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>App.MotorPara.LL_HeightStress,0x0A</ItemText>
|
||||
<ItemText>App.RightLowCS1237_SlopeArray[0],0x0A</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>16</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>App.MotorPara.RU_HeightStress,0x0A</ItemText>
|
||||
<ItemText>Olu_diff1,0x0A</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>17</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>App.MotorPara.RL_HeightStress,0x0A</ItemText>
|
||||
<ItemText>Olu_diff2,0x0A</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>18</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>App.TD1mSDelayCnt,0x0A</ItemText>
|
||||
<ItemText>Olu_diff3,0x0A</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>19</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>App.RxUart3Data.RxBuff,0x10</ItemText>
|
||||
<ItemText>Oru_diff1,0x0A</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>20</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>App.RxUart3Data.RxLen,0x0A</ItemText>
|
||||
<ItemText>Oru_diff2,0x0A</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>21</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>App.Status</ItemText>
|
||||
<ItemText>Oru_diff3,0x0A</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>22</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>App.MotorPara.CaliNum,0x0A</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>23</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>App.CailUp1mSCnt,0x0A</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>24</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>Oru_diff1,0x0A</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>25</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>Orl_diff1,0x0A</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>26</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>App.ADTrack.Stop_VPT,0x0A</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>27</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>ru_ad[0],0x0A</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>28</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>App.MotorPara.RestFlag,0x0A</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>29</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>App.MotorPara.Current_height,0x0A</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>30</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>App.HeightContRolCnt,0x0A</ItemText>
|
||||
<ItemText>App.CentCollDelay1mSCnt,0x0A</ItemText>
|
||||
</Ww>
|
||||
</WatchWindow1>
|
||||
<Tracepoint>
|
||||
@@ -1010,7 +937,7 @@
|
||||
|
||||
<Group>
|
||||
<GroupName>CS1237</GroupName>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<cbSel>0</cbSel>
|
||||
<RteFlg>0</RteFlg>
|
||||
@@ -1065,7 +992,7 @@
|
||||
</Group>
|
||||
|
||||
<Group>
|
||||
<GroupName>dc_motor</GroupName>
|
||||
<GroupName>BeepAndLed</GroupName>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<cbSel>0</cbSel>
|
||||
@@ -1077,6 +1004,26 @@
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\source\Module\BeepAndLed\BeepAndLed.c</PathWithFileName>
|
||||
<FilenameWithoutPath>BeepAndLed.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
</Group>
|
||||
|
||||
<Group>
|
||||
<GroupName>dc_motor</GroupName>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<cbSel>0</cbSel>
|
||||
<RteFlg>0</RteFlg>
|
||||
<File>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>55</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\source\Module\dc_motor\dc_motor.c</PathWithFileName>
|
||||
<FilenameWithoutPath>dc_motor.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
|
||||
@@ -10,14 +10,14 @@
|
||||
<TargetName>Release</TargetName>
|
||||
<ToolsetNumber>0x4</ToolsetNumber>
|
||||
<ToolsetName>ARM-ADS</ToolsetName>
|
||||
<pArmCC>5060960::V5.06 update 7 (build 960)::ARMCC</pArmCC>
|
||||
<pCCUsed>5060960::V5.06 update 7 (build 960)::ARMCC</pCCUsed>
|
||||
<pArmCC>5060960::V5.06 update 7 (build 960)::.\ARMCC</pArmCC>
|
||||
<pCCUsed>5060960::V5.06 update 7 (build 960)::.\ARMCC</pCCUsed>
|
||||
<uAC6>0</uAC6>
|
||||
<TargetOption>
|
||||
<TargetCommonOption>
|
||||
<Device>HC32F460JETA</Device>
|
||||
<Vendor>HDSC</Vendor>
|
||||
<PackID>HDSC.HC32F460.1.0.12</PackID>
|
||||
<PackID>HDSC.HC32F460.1.0.11</PackID>
|
||||
<PackURL>https://raw.githubusercontent.com/hdscmcu/pack/master/</PackURL>
|
||||
<Cpu>IRAM(0x1FFF8000,0x2F000) IRAM2(0x200F0000,0x1000) IROM(0x00000000,0x80000) IROM2(0x03000C00,0x003FC) CPUTYPE("Cortex-M4") FPU2 CLOCK(12000000) ELITTLE</Cpu>
|
||||
<FlashUtilSpec></FlashUtilSpec>
|
||||
@@ -341,7 +341,7 @@
|
||||
<MiscControls></MiscControls>
|
||||
<Define>__DEBUG,HC32F460,USE_DEVICE_DRIVER_LIB,JEUA</Define>
|
||||
<Undefine></Undefine>
|
||||
<IncludePath>..\..\mcu\common;..\source\Module\CS1237;..\source\Module\dc_motor;..\source\User\Src;..\source\User\Inc;..\..\driver\src;..\..\driver\inc</IncludePath>
|
||||
<IncludePath>..\..\mcu\common;..\source\Module\CS1237;..\source\Module\dc_motor;..\source\User\Src;..\source\User\Inc;..\..\driver\src;..\..\driver\inc;..\source\Module\BeepAndLed</IncludePath>
|
||||
</VariousControls>
|
||||
</Cads>
|
||||
<Aads>
|
||||
@@ -667,6 +667,16 @@
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>BeepAndLed</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>BeepAndLed.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\source\Module\BeepAndLed\BeepAndLed.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>dc_motor</GroupName>
|
||||
<Files>
|
||||
|
||||
@@ -0,0 +1,177 @@
|
||||
#include "BeepAndLed.h"
|
||||
#include "beepAndLed.h"
|
||||
#include "main.h" // 包含BUZZER_ON/OFF, LED等宏定义
|
||||
|
||||
// ========== 变量定义 ==========
|
||||
static BeeperCtrl_t g_beeper = {
|
||||
.state = BEEPER_STATE_IDLE,
|
||||
.is_active = 0,
|
||||
.repeat = 0,
|
||||
.repeat_done = 0,
|
||||
.on_ms = 0,
|
||||
.off_ms = 0
|
||||
};
|
||||
|
||||
// 延时计数器(供滴答定时器使用)
|
||||
uint32_t BeepAndLedCollDelay1mSCnt = 0;
|
||||
|
||||
// ========== 硬件控制函数(根据您的实际宏定义修改)==========
|
||||
static void Beeper_HW_On(void)
|
||||
{
|
||||
BUZZER_ON(); // 请替换为您的实际宏
|
||||
LED_GREEN_OFF(); // 请替换为您的实际宏
|
||||
LED_RED_ON(); // 请替换为您的实际宏
|
||||
}
|
||||
|
||||
static void Beeper_HW_Off(void)
|
||||
{
|
||||
BUZZER_OFF(); // 请替换为您的实际宏
|
||||
LED_GREEN_ON(); // 请替换为您的实际宏
|
||||
LED_RED_OFF(); // 请替换为您的实际宏
|
||||
}
|
||||
|
||||
// ========== 实现函数 ==========
|
||||
|
||||
/**
|
||||
* @brief 蜂鸣器初始化
|
||||
*/
|
||||
void Beeper_Init(void)
|
||||
{
|
||||
Beeper_Stop();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 开始鸣响(非阻塞)
|
||||
* @param on_ms 鸣响时间(ms)
|
||||
* @param off_ms 间隔时间(ms)
|
||||
* @param repeat 重复次数(0表示无效)
|
||||
*
|
||||
* @example Beeper_Start(200, 100, 3); // 鸣200ms,停100ms,重复3次
|
||||
*/
|
||||
void Beeper_Start(uint16_t on_ms, uint16_t off_ms, uint8_t repeat)
|
||||
{
|
||||
if (repeat == 0) return;
|
||||
|
||||
// 如果已经在鸣响,可以选择停止并重新开始
|
||||
if (g_beeper.is_active) {
|
||||
Beeper_Stop(); // 停止当前,重新开始新的
|
||||
// return; // 或者选择忽略新请求
|
||||
}
|
||||
|
||||
// 保存参数
|
||||
g_beeper.on_ms = on_ms;
|
||||
g_beeper.off_ms = off_ms;
|
||||
g_beeper.repeat = repeat;
|
||||
g_beeper.repeat_done = 0;
|
||||
g_beeper.is_active = 1;
|
||||
|
||||
// 开启蜂鸣器
|
||||
Beeper_HW_On();
|
||||
|
||||
// 设置延时计数器(开启状态延时)
|
||||
BeepAndLedCollDelay1mSCnt = on_ms;
|
||||
g_beeper.state = BEEPER_STATE_ON;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 停止鸣响
|
||||
*/
|
||||
void Beeper_Stop(void)
|
||||
{
|
||||
// 关闭硬件
|
||||
Beeper_HW_Off();
|
||||
|
||||
// 重置状态机
|
||||
g_beeper.state = BEEPER_STATE_IDLE;
|
||||
g_beeper.is_active = 0;
|
||||
g_beeper.repeat = 0;
|
||||
g_beeper.repeat_done = 0;
|
||||
BeepAndLedCollDelay1mSCnt = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 蜂鸣器状态机更新(放在main.c的while(1)中循环调用)
|
||||
* @note 必须在滴答定时器更新BeepAndLedCollDelay1mSCnt后才能正确工作
|
||||
*/
|
||||
void BeeperLoopHandler(void)
|
||||
{
|
||||
if (!g_beeper.is_active) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (g_beeper.state) {
|
||||
case BEEPER_STATE_ON:
|
||||
// 蜂鸣器开启状态,等待计数器归零
|
||||
if (BeepAndLedCollDelay1mSCnt == 0) {
|
||||
// 延时结束,关闭蜂鸣器
|
||||
Beeper_HW_Off();
|
||||
|
||||
g_beeper.repeat_done++;
|
||||
|
||||
// 检查是否完成所有重复
|
||||
if (g_beeper.repeat_done >= g_beeper.repeat) {
|
||||
// 全部完成,结束
|
||||
g_beeper.is_active = 0;
|
||||
g_beeper.state = BEEPER_STATE_IDLE;
|
||||
} else {
|
||||
// 还有下次,进入等待状态
|
||||
BeepAndLedCollDelay1mSCnt = g_beeper.off_ms;
|
||||
g_beeper.state = BEEPER_STATE_OFF;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case BEEPER_STATE_OFF:
|
||||
// 蜂鸣器关闭等待状态(间隔时间)
|
||||
if (BeepAndLedCollDelay1mSCnt == 0) {
|
||||
// 间隔结束,开启下一次鸣响
|
||||
Beeper_HW_On();
|
||||
|
||||
BeepAndLedCollDelay1mSCnt = g_beeper.on_ms;
|
||||
g_beeper.state = BEEPER_STATE_ON;
|
||||
}
|
||||
break;
|
||||
|
||||
case BEEPER_STATE_WAIT:
|
||||
case BEEPER_STATE_IDLE:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 查询是否正在鸣响
|
||||
* @return true:正在鸣响, false:空闲
|
||||
*/
|
||||
bool Beeper_IsPlaying(void)
|
||||
{
|
||||
return g_beeper.is_active;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 手动开启蜂鸣器(不计入状态机)
|
||||
*/
|
||||
void Beeper_On(void)
|
||||
{
|
||||
Beeper_HW_On();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 手动关闭蜂鸣器(不计入状态机)
|
||||
*/
|
||||
void Beeper_Off(void)
|
||||
{
|
||||
Beeper_HW_Off();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 清除延时计数器(由滴答定时器调用)
|
||||
* @note 这个函数放在滴答定时器的1ms中断中调用
|
||||
*/
|
||||
void Beeper_ClearDelay(void)
|
||||
{
|
||||
if (BeepAndLedCollDelay1mSCnt > 0) {
|
||||
BeepAndLedCollDelay1mSCnt--;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
#ifndef __BEEPANDLED_H
|
||||
#define __BEEPANDLED_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "bsp.h"
|
||||
|
||||
// ========== 蜂鸣器状态机状态定义 ==========
|
||||
typedef enum {
|
||||
BEEPER_STATE_IDLE = 0, // 空闲
|
||||
BEEPER_STATE_ON, // 蜂鸣器开启延时中
|
||||
BEEPER_STATE_OFF, // 蜂鸣器关闭延时中
|
||||
BEEPER_STATE_WAIT // 等待下一次鸣响
|
||||
} BeeperState_t;
|
||||
|
||||
// ========== 蜂鸣器控制结构体 ==========
|
||||
typedef struct {
|
||||
BeeperState_t state; // 当前状态
|
||||
uint16_t on_ms; // 鸣响时间(ms)
|
||||
uint16_t off_ms; // 间隔时间(ms)
|
||||
uint8_t repeat; // 重复次数
|
||||
uint8_t repeat_done; // 已完成次数
|
||||
uint8_t is_active; // 是否激活
|
||||
} BeeperCtrl_t;
|
||||
|
||||
// ========== 外部可访问变量 ==========
|
||||
extern uint32_t BeepAndLedCollDelay1mSCnt; // 延时计数器(在beepAndLed.c中定义)
|
||||
|
||||
// ========== API函数 ==========
|
||||
void Beeper_Init(void); // 初始化
|
||||
void Beeper_Start(uint16_t on_ms, uint16_t off_ms, uint8_t repeat); // 开始鸣响(非阻塞)
|
||||
void Beeper_Stop(void); // 停止鸣响
|
||||
void BeeperLoopHandler(void); // 状态机更新(放在while(1)中)
|
||||
bool Beeper_IsPlaying(void); // 查询是否正在鸣响
|
||||
void Beeper_On(void); // 手动开启蜂鸣器
|
||||
void Beeper_Off(void); // 手动关闭蜂鸣器
|
||||
void Beeper_ClearDelay(void); // 清除延时计数器(供滴答定时器使用)
|
||||
#endif /* _BEEP_AND_LED_H_ */
|
||||
|
||||
@@ -221,12 +221,12 @@
|
||||
|
||||
//< LED
|
||||
#define LED_GREEN_PORTx (PortA)
|
||||
#define LED_GREEN_PINx (Pin09)
|
||||
#define LED_GREEN_PINx (Pin08)
|
||||
#define LED_GREEN_ON() PORT_SetBits(LED_GREEN_PORTx, LED_GREEN_PINx)//拉高
|
||||
#define LED_GREEN_OFF() PORT_ResetBits(LED_GREEN_PORTx, LED_GREEN_PINx)//拉低
|
||||
|
||||
#define LED_RED_PORTx (PortA)
|
||||
#define LED_RED_PINx (Pin08)
|
||||
#define LED_RED_PINx (Pin09)
|
||||
#define LED_RED_ON() PORT_SetBits(LED_RED_PORTx, LED_RED_PINx)//拉高
|
||||
#define LED_RED_OFF() PORT_ResetBits(LED_RED_PORTx, LED_RED_PINx)//拉低
|
||||
|
||||
|
||||
@@ -3,34 +3,25 @@
|
||||
#include <stdlib.h>
|
||||
#include "bsp.h"
|
||||
|
||||
|
||||
#define USE_FILE_SYSTEM 1
|
||||
#define SDCARD_BLOCK_MAX (10000)
|
||||
|
||||
#define OSC_CNT 40
|
||||
#define SLOPE_CNT 20
|
||||
|
||||
#define SLOPE_VPT 1000
|
||||
#define PRESS_VPT 3
|
||||
#define FOLLOW_VPT 10
|
||||
#define SHIELD_VPT 5000
|
||||
#define SHIELD_VPT 8000
|
||||
#define EME_STOP_VPT 4000
|
||||
#define CENTRE_VPT 2000
|
||||
#define CENTRE_VPT 8000
|
||||
#define CENTRE_SHIELD_VPT 2000
|
||||
|
||||
#define STOP_TIME_MS 500
|
||||
#define CENT_TIME_MS 200
|
||||
#define RUN_TIME_MS 0
|
||||
#define EME_START_MS 0
|
||||
#define EME_STOP_MS 2000
|
||||
#define SLOPE_START_MS 3000
|
||||
|
||||
#define TRAVEL_TIME_MS 30000
|
||||
|
||||
#define PEAK 1200 //1200mm
|
||||
#define VALLEY 720 //720mm
|
||||
|
||||
#define BDC_STOP() (SET_TWIN_BIT0(),SET_TWIN_BIT1())
|
||||
#define BDC_DOWN() (SET_TWIN_BIT0(),CLR_TWIN_BIT1())
|
||||
#define BDC_UP() (SET_TWIN_BIT1(),CLR_TWIN_BIT0())
|
||||
#define BDC_STOP() (SET_TWIN_BIT0(),SET_TWIN_BIT1())
|
||||
#define BDC_DOWN() (SET_TWIN_BIT0(),CLR_TWIN_BIT1())
|
||||
#define BDC_UP() (SET_TWIN_BIT1(),CLR_TWIN_BIT0())
|
||||
|
||||
//#define BDC_STOP() Motor_Control(MOTOR_CMD_STOP)
|
||||
//#define BDC_UP() Motor_Control(MOTOR_CMD_FORWARD)
|
||||
@@ -47,7 +38,6 @@ typedef enum {
|
||||
|
||||
/*设备阈值*/
|
||||
typedef struct{
|
||||
int32_t Slope_VPT;
|
||||
int32_t Stop_VPT;
|
||||
|
||||
int32_t LeftUpVPT;//左上设备阈值
|
||||
@@ -66,16 +56,8 @@ typedef struct{
|
||||
int32_t RightLow_Org_AdZero;//右下设备原始AD零点
|
||||
}ADTrack_t;
|
||||
typedef struct{//电机参数
|
||||
bool InitialFlag;//初始标志位
|
||||
bool RestFlag;
|
||||
bool CaliFlag;
|
||||
bool LoopOne;//循环一次标志位
|
||||
int16_t Current_height;//当前高度mm
|
||||
int16_t CaliNum;//标校数量
|
||||
int32_t LU_HeightStress[488];//左上传感器对应高度应力
|
||||
int32_t LL_HeightStress[488];//左下传感器对应高度应力
|
||||
int32_t RU_HeightStress[488];//右上传感器对应高度应力
|
||||
int32_t RL_HeightStress[488];//右上传感器对应高度应力
|
||||
}MotorPara_t;
|
||||
/*数据读取状态机*/
|
||||
typedef enum {
|
||||
@@ -97,22 +79,9 @@ typedef enum {
|
||||
APP_STATUS_IDLE,
|
||||
APP_STATUS_ON,
|
||||
APP_STATUS_OFF,
|
||||
APP_STATUS_MOTOR_INIT,
|
||||
APP_STATUS_WAIT_MOTOR_INIT,
|
||||
APP_STATUS_WAIT_MOTOR_CALI_UP,
|
||||
APP_STATUS_WAIT_MOTOR_CALI_DOWN,
|
||||
APP_STATUS_WAIT_STEADY,
|
||||
APP_STATUS_ZERO_MARKING,
|
||||
APP_STATUS_HEIGHT_CONTROL,
|
||||
}AppStatus_m;
|
||||
|
||||
typedef struct{
|
||||
__IO uint16_t rPayLen;
|
||||
__IO bool HeaderFrame;
|
||||
__IO uint16_t RxLen;
|
||||
uint8_t RxBuff[10];
|
||||
}Uart1Rx_t;
|
||||
|
||||
typedef struct{
|
||||
__IO uint16_t rPayLen;
|
||||
__IO bool HeaderFrame;
|
||||
@@ -124,25 +93,20 @@ typedef struct {
|
||||
AppStatus_m Status;//状态
|
||||
ReadStatus_m RStatus;
|
||||
AppPara_T Para;
|
||||
Uart1Rx_t RxUart1Data;
|
||||
Uart3Rx_t RxUart3Data;
|
||||
|
||||
ADTrack_t ADTrack;
|
||||
MotorPara_t MotorPara;
|
||||
uint32_t TD1mSDelayCnt;
|
||||
uint32_t Read1mSDelayCnt;
|
||||
uint32_t Uart1Delay1mSCnt;
|
||||
uint32_t Uart3RxTimeOut1mSCnt;
|
||||
uint32_t StopCollDelay1mSCnt;
|
||||
uint32_t RunCollDelay1mSCnt;
|
||||
uint32_t CentCollDelay1mSCnt;
|
||||
uint32_t EmergencyDelay1mSCnt;
|
||||
uint32_t SlopeCollDelay1mSCnt;
|
||||
uint32_t CailUp1mSCnt;
|
||||
uint32_t HeightContRolCnt;
|
||||
uint8_t FeedDogDlyCnt;
|
||||
|
||||
bool CaliZeroFlag;//校零标志位
|
||||
bool SideFlag;//侧压标志位
|
||||
bool UpFlag;//上升标志位
|
||||
bool DownFlag;//下降标志位
|
||||
bool StopFlag;//停止标志位
|
||||
@@ -165,8 +129,6 @@ typedef struct {
|
||||
int32_t LeftLowCS1237_SlopeArray[SLOPE_CNT];
|
||||
int32_t RightUpCS1237_SlopeArray[SLOPE_CNT];
|
||||
int32_t RightLowCS1237_SlopeArray[SLOPE_CNT];
|
||||
|
||||
bool WaitFlag;
|
||||
}AppDetect_t;
|
||||
extern AppDetect_t App;
|
||||
|
||||
|
||||
+225
-501
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user