|
@@ -57,6 +57,7 @@
|
|
|
#include "UserGpio_Config.h"
|
|
|
//#include "api.h"
|
|
|
//#include "board_config.h"
|
|
|
+
|
|
|
/* Private variables ---------------接收缓存区------------------------------------------*/
|
|
|
|
|
|
UBYTE UART_RxBuff_OBC[UART_BUFF_SIZE];
|
|
@@ -896,38 +897,46 @@ void DataProcess(USART_Buf_TypeDef* ptUartTx, UWORD ID, UBYTE Mode, UWORD Cmd, U
|
|
|
case 0x4104: //写入力矩传感器参数
|
|
|
{
|
|
|
UWORD SAVETemp[2];
|
|
|
+ SWORD Temp;
|
|
|
+ ULONG TempSum = 0;
|
|
|
+ ULONG TimeDelayTick = 0;
|
|
|
memcpy(&SAVETemp, Data, DataLength);
|
|
|
- if (SAVETemp[0] == 1)
|
|
|
+
|
|
|
+ for(UBYTE i = 0; i < 128; i++)
|
|
|
{
|
|
|
- MC_UpcInfo.stSensorInfo.uwBikeTor1StepRealNm = SAVETemp[1];
|
|
|
- MC_UpcInfo.stSensorInfo.uwBikeTor1StepADC = ((TORQUEVOLREG1() - torsensor_stTorSensorCof.uwTorqueOffsetNow1) +
|
|
|
+ #ifdef TORSENSOR3NUM
|
|
|
+ Temp = ((TORQUEVOLREG1() - torsensor_stTorSensorCof.uwTorqueOffsetNow1) +
|
|
|
(TORQUEVOLREG2() - torsensor_stTorSensorCof.uwTorqueOffsetNow2) +
|
|
|
(TORQUEVOLREG3() - torsensor_stTorSensorCof.uwTorqueOffsetNow3)) / 3;
|
|
|
- SendData(ptUartTx, ID_MC_BC, MODE_REPORT, 0xA903, (uint8_t *)"ACK");
|
|
|
+ #else
|
|
|
+ Temp = TORQUEVOLREG1() - torsensor_stTorSensorCof.uwTorqueOffsetNow1;
|
|
|
+ #endif
|
|
|
+ TempSum += (Temp < 0) ? 0 : Temp;
|
|
|
+ TimeDelayTick = cp_ulSystickCnt;
|
|
|
+ while((cp_ulSystickCnt - TimeDelayTick) < 10)
|
|
|
+ {
|
|
|
+ asm("NOP");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (SAVETemp[0] == 1)
|
|
|
+ {
|
|
|
+ MC_UpcInfo.stSensorInfo.uwBikeTor1StepRealNm = SAVETemp[1];
|
|
|
+ MC_UpcInfo.stSensorInfo.uwBikeTor1StepADC = TempSum >> 7;
|
|
|
}
|
|
|
else if (SAVETemp[0] == 2)
|
|
|
{
|
|
|
MC_UpcInfo.stSensorInfo.uwBikeTor2StepRealNm = SAVETemp[1];
|
|
|
- MC_UpcInfo.stSensorInfo.uwBikeTor2StepADC = ((TORQUEVOLREG1() - torsensor_stTorSensorCof.uwTorqueOffsetNow1) +
|
|
|
- (TORQUEVOLREG2() - torsensor_stTorSensorCof.uwTorqueOffsetNow2) +
|
|
|
- (TORQUEVOLREG3() - torsensor_stTorSensorCof.uwTorqueOffsetNow3)) / 3;
|
|
|
- SendData(ptUartTx, ID_MC_BC, MODE_REPORT, 0xA903, (uint8_t *)"ACK");
|
|
|
+ MC_UpcInfo.stSensorInfo.uwBikeTor2StepADC = TempSum >> 7;
|
|
|
}
|
|
|
else if (SAVETemp[0] == 3)
|
|
|
{
|
|
|
MC_UpcInfo.stSensorInfo.uwBikeTor3StepRealNm = SAVETemp[1];
|
|
|
- MC_UpcInfo.stSensorInfo.uwBikeTor3StepADC = ((TORQUEVOLREG2() - torsensor_stTorSensorCof.uwTorqueOffsetNow1) +
|
|
|
- (TORQUEVOLREG2() - torsensor_stTorSensorCof.uwTorqueOffsetNow2) +
|
|
|
- (TORQUEVOLREG3() - torsensor_stTorSensorCof.uwTorqueOffsetNow3)) / 3;
|
|
|
- SendData(ptUartTx, ID_MC_BC, MODE_REPORT, 0xA903, (uint8_t *)"ACK");
|
|
|
+ MC_UpcInfo.stSensorInfo.uwBikeTor3StepADC = TempSum >> 7;
|
|
|
}
|
|
|
else if (SAVETemp[0] == 4)
|
|
|
{
|
|
|
MC_UpcInfo.stSensorInfo.uwBikeTor4StepRealNm = SAVETemp[1];
|
|
|
- MC_UpcInfo.stSensorInfo.uwBikeTor4StepADC = ((TORQUEVOLREG3() - torsensor_stTorSensorCof.uwTorqueOffsetNow1) +
|
|
|
- (TORQUEVOLREG2() - torsensor_stTorSensorCof.uwTorqueOffsetNow2) +
|
|
|
- (TORQUEVOLREG3() - torsensor_stTorSensorCof.uwTorqueOffsetNow3)) / 3;
|
|
|
- SendData(ptUartTx, ID_MC_BC, MODE_REPORT, 0xA903, (uint8_t *)"ACK");
|
|
|
+ MC_UpcInfo.stSensorInfo.uwBikeTor4StepADC = TempSum >> 7;
|
|
|
}
|
|
|
else
|
|
|
{}
|
|
@@ -936,6 +945,7 @@ void DataProcess(USART_Buf_TypeDef* ptUartTx, UWORD ID, UBYTE Mode, UWORD Cmd, U
|
|
|
cp_stFlg.ParaUpdateFlg = TRUE;
|
|
|
cp_stFlg.ParaSensorInfoUpdateFlg = TRUE;
|
|
|
cp_stFlg.ParaAssistUpdateFinishFlg = TRUE;
|
|
|
+ SendData(ptUartTx, ID_MC_BC, MODE_REPORT, 0xA903, (uint8_t *)"ACK");
|
|
|
break;
|
|
|
}
|
|
|
case 0x420E: //写入其它传感器参数
|
|
@@ -1132,7 +1142,7 @@ void DataProcess(USART_Buf_TypeDef* ptUartTx, UWORD ID, UBYTE Mode, UWORD Cmd, U
|
|
|
SendData(ptUartTx, ID_MC_BC, MODE_REPORT, 0xBC20, (uint8_t *)&MC_UpcInfo.stWriteResistanceCalibInfo.MOSResA);
|
|
|
break;
|
|
|
}
|
|
|
- case 0x4B22: //上位机设置骑行参数
|
|
|
+ case 0x4B22: //上位机设置骑行参数
|
|
|
{
|
|
|
memcpy(&MC_UpcInfo.stRideParaInfo.uwSaveFlg, Data, DataLength);
|
|
|
if (MC_UpcInfo.stRideParaInfo.uwSaveFlg == 1)
|
|
@@ -1145,7 +1155,7 @@ void DataProcess(USART_Buf_TypeDef* ptUartTx, UWORD ID, UBYTE Mode, UWORD Cmd, U
|
|
|
SendData(ptUartTx,ID_MC_TO_CDL, MODE_REPORT, 0x5303, (uint8_t*)"ACK");
|
|
|
break;
|
|
|
}
|
|
|
- case 0x4C00:
|
|
|
+ case 0x4C00:
|
|
|
{
|
|
|
SendData(ptUartTx,ID_MC_BC, MODE_REPORT, 0xBD20, (UBYTE *)&MC_UpcInfo.stBikeInfo2.uwNoneOBCEnable);
|
|
|
break;
|