|
@@ -46,29 +46,29 @@
|
|
|
/* Private variables ---------------------------------------------------------*/
|
|
|
|
|
|
/* USER CODE BEGIN PV */
|
|
|
-uint8_t data_to_send[50];
|
|
|
-uint16_t CRC_value = 0;
|
|
|
+
|
|
|
+int spr000;
|
|
|
+uint8_t data_to_send[50];
|
|
|
+uint16_t CRC_value = 0;
|
|
|
uint16_t initial_address = 0x00C1;
|
|
|
-uint32_t System_version = Version_sys;
|
|
|
-uint16_t BaudrateValue = 0x0000;
|
|
|
+uint16_t BaudrateValue = 0x0000;
|
|
|
uint16_t Adc2_CalibrationValue ;
|
|
|
uint16_t Adc3_CalibrationValue ;
|
|
|
+uint32_t System_version = Version_sys;
|
|
|
|
|
|
-uint8_t Rx_Flag = 0;
|
|
|
-uint16_t Rx_Len = 0;
|
|
|
-uint8_t Rx_Buf[Rx_Max] = {0};
|
|
|
-uint8_t gpioaStatus = 0;
|
|
|
-uint8_t gpiobStatus = 0;
|
|
|
+uint8_t Rx_Flag = 0;
|
|
|
+uint8_t gpioaStatus = 0;
|
|
|
+uint8_t gpiobStatus = 0;
|
|
|
+uint8_t bufMain[128] = {0};
|
|
|
+uint8_t Rx_Buf[Rx_Max] = {0};
|
|
|
+uint16_t Rx_Len = 0;
|
|
|
|
|
|
-uint8_t bufMain[128];
|
|
|
-int spr000;
|
|
|
/* USER CODE END PV */
|
|
|
|
|
|
/* Private function prototypes -----------------------------------------------*/
|
|
|
void SystemClock_Config(void);
|
|
|
/* USER CODE BEGIN PFP */
|
|
|
#ifdef iap_
|
|
|
-
|
|
|
typedef struct _T2C_RemoteCaliData
|
|
|
{
|
|
|
uint16_t FrameHead; //帧头 0-1
|
|
@@ -94,9 +94,7 @@ typedef struct{
|
|
|
uint8_t data_buf[70]; //下发数据缓存
|
|
|
}KZQ_Inf;
|
|
|
#define ADDR_Is_In_ElecFence 0x05D0 // 1488 车是否在电子围栏内
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
sT2C_RemoteCaliDat T2C_RemoteCaliDat001 =
|
|
|
{
|
|
|
|
|
@@ -105,28 +103,33 @@ typedef struct{
|
|
|
0x0003,
|
|
|
ADDR_Is_In_ElecFence,//0x0000,
|
|
|
0x0001, //操作的数据个数
|
|
|
- 0x55aa55aa, //保留字4字节
|
|
|
+ 0x55AA55AA, //保留字4字节
|
|
|
{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,\
|
|
|
25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44},
|
|
|
0x7788,//保留字2字节
|
|
|
- 0x99aa //校验2字节
|
|
|
+ 0x99AA //校验2字节
|
|
|
};
|
|
|
sT2C_RemoteCaliDat *pT2C_RemoteCaliData = &T2C_RemoteCaliDat001;
|
|
|
|
|
|
uint8_t CMD_KZQ[256] =
|
|
|
{0x39,0x01,0x95,0x50,0x00,0x01,0x00,0x03,
|
|
|
- 0x00,0x00,0x00,0x00,0x95,0x05,0xaa,0xaa,
|
|
|
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
|
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
|
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
|
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
|
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
|
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
|
+ 0x00,0x00,0x00,0x00,0x95,0x05,0xAA,0xAA,
|
|
|
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
|
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
|
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
|
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
|
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
|
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
|
};
|
|
|
int flagU2Rx=0;
|
|
|
int data_lengthU2;
|
|
|
uint8_t* ptx = CMD_KZQ;
|
|
|
- uint16_t ModbusCRC = 0,SetSuccess = 0,ModbusCRC1 = 0,SetSuccess1 = 0,SetSuccess2=0,SetSuccess3=0;
|
|
|
+ uint16_t ModbusCRC = 0;
|
|
|
+ uint16_t SetSuccess = 0;
|
|
|
+ uint16_t ModbusCRC1 = 0;
|
|
|
+ uint16_t SetSuccess1 = 0;
|
|
|
+ uint16_t SetSuccess2 = 0;
|
|
|
+ uint16_t SetSuccess3 = 0;
|
|
|
|
|
|
int i000;
|
|
|
uint8_t* send_ptr;
|
|
@@ -209,9 +212,8 @@ int main(void)
|
|
|
update_baudrate(read_flash_16(ADDR_FLASH_PAGE_114));
|
|
|
AdcCalibration_init();
|
|
|
|
|
|
-
|
|
|
- spr000=sprintf((char*)bufMain,"system reset...%5d",5);
|
|
|
- HAL_UART_Transmit(&huart1,bufMain,spr000,300);
|
|
|
+ spr000 = sprintf((char*)bufMain, "system reboot...");
|
|
|
+ HAL_UART_Transmit(&huart1, bufMain, spr000, 300);
|
|
|
|
|
|
HAL_UART_Receive_DMA(&huart1,USART2_RX_BUF,Uart2_BUF_SIZE);
|
|
|
__HAL_UART_ENABLE_IT(&huart1, UART_IT_IDLE);
|
|
@@ -223,10 +225,9 @@ int main(void)
|
|
|
{
|
|
|
ModBus();
|
|
|
#ifdef iap_
|
|
|
- if (flagU2Rx == 1 && (USART2_RX_BUF002[0] == 0xa5) && (USART2_RX_BUF002[1] == 0x5a))
|
|
|
- {
|
|
|
+ if (flagU2Rx == 1) {
|
|
|
flagU2Rx = 0;
|
|
|
- if ((data_lengthU2 > 300) || ((USART2_RX_BUF002[0] == 0xa5) && (USART2_RX_BUF002[1] == 0x5a)))
|
|
|
+ if ((data_lengthU2 > 300) || ((USART2_RX_BUF002[0] == 0xA5) && (USART2_RX_BUF002[1] == 0x5A)))
|
|
|
{
|
|
|
tmpU32 = (USART2_RX_BUF002[0] << 24) | (USART2_RX_BUF002[1] << 16) | (USART2_RX_BUF002[2] << 8) | (USART2_RX_BUF002[3]);
|
|
|
if (StartBytes_IAP == tmpU32)
|
|
@@ -235,37 +236,6 @@ int main(void)
|
|
|
continue;
|
|
|
}
|
|
|
}
|
|
|
- // KZQ_RTerror = 0;
|
|
|
- // ASC转换为16进制,收到数据为:3901开头的数据总长度131字节
|
|
|
- if ((USART2_RX_BUF002[0] == 0x3A) && (USART2_RX_BUF002[1] == 0x33) && (USART2_RX_BUF002[2] == 0x39) && (USART2_RX_BUF002[3] == 0x30)) //判断帧头
|
|
|
- {
|
|
|
- if (data_lengthU2 != 131)
|
|
|
- {
|
|
|
- ++KZQ_RTerror;
|
|
|
- continue;
|
|
|
- }
|
|
|
- for (i000 = 0; i000 < (data_lengthU2 - 3) / 2; i000++)
|
|
|
- {
|
|
|
- T2C_RemoteCaliDat001.PayLoadData[i000] = MODBUS_ASCII_AsciiToHex(USART2_RX_BUF002 + 1 + 0 + i000 * 2);
|
|
|
-
|
|
|
- USART2_RX_BUF003[i000] = MODBUS_ASCII_AsciiToHex(USART2_RX_BUF002 + 1 + 0 + i000 * 2);
|
|
|
- }
|
|
|
- //解析后的数据拷贝过来
|
|
|
- memcpy(USART2_RX_BUF002, USART2_RX_BUF003, (data_lengthU2 - 3) / 2);
|
|
|
- data_lengthU2 = (data_lengthU2 - 3) / 2;
|
|
|
- }
|
|
|
- if (data_lengthU2 < 5)
|
|
|
- continue;
|
|
|
- ModbusCRC = USART2_RX_BUF002[data_lengthU2 - 1] << 8;
|
|
|
- ModbusCRC |= USART2_RX_BUF002[data_lengthU2 - 2];
|
|
|
- ModbusCRC1 = LIB_CRC_MODBUS(USART2_RX_BUF002, data_lengthU2 - 2);
|
|
|
-
|
|
|
- if ((USART2_RX_BUF002[0] != 0x39) && (USART2_RX_BUF002[1] <= 0x01) && (USART2_RX_BUF002[2] <= 0x95) && (USART2_RX_BUF002[3] <= 0x50)) //判断帧头
|
|
|
- {
|
|
|
- RstCPU();
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
#endif
|
|
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_0, GPIO_PIN_SET);
|
|
@@ -441,10 +411,8 @@ void delay_sys_us(uint32_t Delay)//1
|
|
|
|
|
|
|
|
|
void ModBus(void) {
|
|
|
-
|
|
|
if (Rx_Flag == 1 && (calculate_crc(Rx_Buf,6) == (Rx_Buf[7] << 8 | Rx_Buf[6])) && data_lengthU2 < 10) {
|
|
|
if(Rx_Buf[0] == (uint8_t)initial_address && Rx_Buf[1] == 0x03 && Rx_Buf[2] == 0x00 && Rx_Buf[3] == 0x01 && Rx_Buf[4] == 0x00 && Rx_Buf[5] == 0x01){
|
|
|
-
|
|
|
uint8_t data_to_send[] = {(uint8_t)initial_address, 0x03, 0x02, 0x00, gpioaStatus, 0x00, 0x00};
|
|
|
uint16_t CRC_value = calculate_crc(data_to_send, 5);
|
|
|
data_to_send[5] = (uint8_t)(CRC_value & 0xFF);
|
|
@@ -458,7 +426,6 @@ void ModBus(void) {
|
|
|
}
|
|
|
|
|
|
else if(Rx_Buf[0] == (uint8_t)initial_address && Rx_Buf[1] == 0x03 && Rx_Buf[2] == 0x00 && Rx_Buf[3] == 0x02 && Rx_Buf[4] == 0x00 && Rx_Buf[5] == 0x01){
|
|
|
-
|
|
|
uint8_t data_to_send[] = {(uint8_t)initial_address, 0x03, 0x02, 0x00, gpiobStatus, 0x00, 0x00};
|
|
|
uint16_t CRC_value = calculate_crc(data_to_send, 5);
|
|
|
data_to_send[5] = (uint8_t)(CRC_value & 0xFF);
|
|
@@ -472,7 +439,6 @@ void ModBus(void) {
|
|
|
}
|
|
|
|
|
|
else if(Rx_Buf[0] == (uint8_t)initial_address && Rx_Buf[1] == 0x03 && Rx_Buf[2] == 0x00 && Rx_Buf[3] == 0x03 && Rx_Buf[4] == 0x00 && Rx_Buf[5] == 0x01){
|
|
|
-
|
|
|
uint8_t data_to_send[] = {(uint8_t)initial_address, 0x03, 0x02, adc2_byte1, adc2_byte2, 0x00, 0x00};
|
|
|
uint16_t CRC_value = calculate_crc(data_to_send, 5);
|
|
|
data_to_send[5] = (uint8_t)(CRC_value & 0xFF);
|
|
@@ -486,7 +452,6 @@ void ModBus(void) {
|
|
|
}
|
|
|
|
|
|
else if(Rx_Buf[0] == (uint8_t)initial_address && Rx_Buf[1] == 0x03 && Rx_Buf[2] == 0x00 && Rx_Buf[3] == 0x04 && Rx_Buf[4] == 0x00 && Rx_Buf[5] == 0x01){
|
|
|
-
|
|
|
uint8_t data_to_send[] = {(uint8_t)initial_address, 0x03, 0x02, adc3_byte1, adc3_byte2, 0x00, 0x00};
|
|
|
uint16_t CRC_value = calculate_crc(data_to_send, 5);
|
|
|
data_to_send[5] = (uint8_t)(CRC_value & 0xFF);
|
|
@@ -500,7 +465,6 @@ void ModBus(void) {
|
|
|
}
|
|
|
|
|
|
else if(Rx_Buf[0] == (uint8_t)initial_address && Rx_Buf[1] == 0x03 && Rx_Buf[2] == 0x00 && Rx_Buf[3] == 0x05 && Rx_Buf[4] == 0x00 && Rx_Buf[5] == 0x01){
|
|
|
-
|
|
|
uint8_t data_to_send[] = {(uint8_t)initial_address, 0x03, 0x02, adc1_byte1, adc1_byte2, 0x00, 0x00};
|
|
|
uint16_t CRC_value = calculate_crc(data_to_send, 5);
|
|
|
data_to_send[5] = (uint8_t)(CRC_value & 0xFF);
|
|
@@ -514,7 +478,6 @@ void ModBus(void) {
|
|
|
}
|
|
|
|
|
|
else if(Rx_Buf[0] == (uint8_t)initial_address && Rx_Buf[1] == 0x03 && Rx_Buf[2] == 0x00 && Rx_Buf[3] == 0x01 && Rx_Buf[4] == 0x00 && Rx_Buf[5] == 0x02){
|
|
|
-
|
|
|
uint8_t data_to_send[] = {(uint8_t)initial_address, 0x03, 0x04, 0x00, gpioaStatus, 0x00, gpiobStatus, 0x00, 0x00};
|
|
|
uint16_t CRC_value = calculate_crc(data_to_send, 7);
|
|
|
data_to_send[7] = (uint8_t)(CRC_value & 0xFF);
|
|
@@ -528,7 +491,6 @@ void ModBus(void) {
|
|
|
}
|
|
|
|
|
|
else if(Rx_Buf[0] == (uint8_t)initial_address && Rx_Buf[1] == 0x03 && Rx_Buf[2] == 0x00 && Rx_Buf[3] == 0x01 && Rx_Buf[4] == 0x00 && Rx_Buf[5] == 0x03){
|
|
|
-
|
|
|
uint8_t data_to_send[] = {(uint8_t)initial_address, 0x03, 0x06, 0x00, gpioaStatus, 0x00, gpiobStatus, adc2_byte1, adc2_byte2, 0x00, 0x00};
|
|
|
uint16_t CRC_value = calculate_crc(data_to_send, 9);
|
|
|
data_to_send[9] = (uint8_t)(CRC_value & 0xFF);
|
|
@@ -542,7 +504,6 @@ void ModBus(void) {
|
|
|
}
|
|
|
|
|
|
else if(Rx_Buf[0] == (uint8_t)initial_address && Rx_Buf[1] == 0x03 && Rx_Buf[2] == 0x00 && Rx_Buf[3] == 0x01 && Rx_Buf[4] == 0x00 && Rx_Buf[5] == 0x04){
|
|
|
-
|
|
|
uint8_t data_to_send[] = {(uint8_t)initial_address, 0x03, 0x08, 0x00, gpioaStatus, 0x00, gpiobStatus, adc2_byte1, adc2_byte2, adc3_byte1, adc3_byte2, 0x00, 0x00};
|
|
|
uint16_t CRC_value = calculate_crc(data_to_send, 11);
|
|
|
data_to_send[11] = (uint8_t)(CRC_value & 0xFF);
|
|
@@ -556,7 +517,6 @@ void ModBus(void) {
|
|
|
}
|
|
|
|
|
|
else if(Rx_Buf[0] == (uint8_t)initial_address && Rx_Buf[1] == 0x03 && Rx_Buf[2] == 0x00 && Rx_Buf[3] == 0x01 && Rx_Buf[4] == 0x00 && Rx_Buf[5] == 0x05){
|
|
|
-
|
|
|
uint8_t data_to_send[] = {(uint8_t)initial_address, 0x03, 0x0A, 0x00, gpioaStatus, 0x00, gpiobStatus, adc2_byte1, adc2_byte2, adc3_byte1, adc3_byte2, adc1_byte1, adc1_byte2, 0x00, 0x00};
|
|
|
uint16_t CRC_value = calculate_crc(data_to_send, 13);
|
|
|
data_to_send[13] = (uint8_t)(CRC_value & 0xFF);
|
|
@@ -570,7 +530,6 @@ void ModBus(void) {
|
|
|
}
|
|
|
|
|
|
else if(Rx_Buf[0] == (uint8_t)initial_address && Rx_Buf[1] == 0x03 && Rx_Buf[2] == 0x00 && Rx_Buf[3] == 0x02 && Rx_Buf[4] == 0x00 && Rx_Buf[5] == 0x02){
|
|
|
-
|
|
|
uint8_t data_to_send[] = {(uint8_t)initial_address, 0x03, 0x04, 0x00, gpiobStatus, adc2_byte1, adc2_byte2, 0x00, 0x00};
|
|
|
uint16_t CRC_value = calculate_crc(data_to_send, 7);
|
|
|
data_to_send[7] = (uint8_t)(CRC_value & 0xFF);
|
|
@@ -584,7 +543,6 @@ void ModBus(void) {
|
|
|
}
|
|
|
|
|
|
else if(Rx_Buf[0] == (uint8_t)initial_address && Rx_Buf[1] == 0x03 && Rx_Buf[2] == 0x00 && Rx_Buf[3] == 0x02 && Rx_Buf[4] == 0x00 && Rx_Buf[5] == 0x03){
|
|
|
-
|
|
|
uint8_t data_to_send[] = {(uint8_t)initial_address, 0x03, 0x06, 0x00, gpiobStatus, adc2_byte1, adc2_byte2, adc3_byte1, adc3_byte2, 0x00, 0x00};
|
|
|
uint16_t CRC_value = calculate_crc(data_to_send, 9);
|
|
|
data_to_send[9] = (uint8_t)(CRC_value & 0xFF);
|
|
@@ -598,7 +556,6 @@ void ModBus(void) {
|
|
|
}
|
|
|
|
|
|
else if(Rx_Buf[0] == (uint8_t)initial_address && Rx_Buf[1] == 0x03 && Rx_Buf[2] == 0x00 && Rx_Buf[3] == 0x02 && Rx_Buf[4] == 0x00 && Rx_Buf[5] == 0x04){
|
|
|
-
|
|
|
uint8_t data_to_send[] = {(uint8_t)initial_address, 0x03, 0x08, 0x00, gpiobStatus, adc2_byte1, adc2_byte2, adc3_byte1, adc3_byte2, adc1_byte1, adc1_byte2, 0x00, 0x00};
|
|
|
uint16_t CRC_value = calculate_crc(data_to_send, 11);
|
|
|
data_to_send[11] = (uint8_t)(CRC_value & 0xFF);
|
|
@@ -612,7 +569,6 @@ void ModBus(void) {
|
|
|
}
|
|
|
|
|
|
else if(Rx_Buf[0] == (uint8_t)initial_address && Rx_Buf[1] == 0x03 && Rx_Buf[2] == 0x00 && Rx_Buf[3] == 0x03 && Rx_Buf[4] == 0x00 && Rx_Buf[5] == 0x02){
|
|
|
-
|
|
|
uint8_t data_to_send[] = {(uint8_t)initial_address, 0x03, 0x04, adc2_byte1, adc2_byte2, adc3_byte1, adc3_byte2, 0x00, 0x00};
|
|
|
uint16_t CRC_value = calculate_crc(data_to_send, 7);
|
|
|
data_to_send[7] = (uint8_t)(CRC_value & 0xFF);
|
|
@@ -626,7 +582,6 @@ void ModBus(void) {
|
|
|
}
|
|
|
|
|
|
else if(Rx_Buf[0] == (uint8_t)initial_address && Rx_Buf[1] == 0x03 && Rx_Buf[2] == 0x00 && Rx_Buf[3] == 0x03 && Rx_Buf[4] == 0x00 && Rx_Buf[5] == 0x03){
|
|
|
-
|
|
|
uint8_t data_to_send[] = {(uint8_t)initial_address, 0x03, 0x06, adc2_byte1, adc2_byte2, adc3_byte1, adc3_byte2, adc1_byte1, adc1_byte2, 0x00, 0x00};
|
|
|
uint16_t CRC_value = calculate_crc(data_to_send, 9);
|
|
|
data_to_send[9] = (uint8_t)(CRC_value & 0xFF);
|
|
@@ -640,7 +595,6 @@ void ModBus(void) {
|
|
|
}
|
|
|
|
|
|
else if(Rx_Buf[0] == (uint8_t)initial_address && Rx_Buf[1] == 0x03 && Rx_Buf[2] == 0x00 && Rx_Buf[3] == 0x04 && Rx_Buf[4] == 0x00 && Rx_Buf[5] == 0x02){
|
|
|
-
|
|
|
uint8_t data_to_send[] = {(uint8_t)initial_address, 0x03, 0x04, adc3_byte1, adc3_byte2, adc1_byte1, adc1_byte2, 0x00, 0x00};
|
|
|
uint16_t CRC_value = calculate_crc(data_to_send, 7);
|
|
|
data_to_send[7] = (uint8_t)(CRC_value & 0xFF);
|
|
@@ -654,7 +608,6 @@ void ModBus(void) {
|
|
|
}
|
|
|
|
|
|
else if(Rx_Buf[0] == 0xFA && Rx_Buf[1] == 0x03 && Rx_Buf[2] == 0x00 && Rx_Buf[3] == 0xAA && Rx_Buf[4] == 0x00 && Rx_Buf[5] == 0x01){
|
|
|
-
|
|
|
uint8_t data_to_send[] = {0xFA, 0x03, 0x02, 0x00, (uint8_t)initial_address, 0x00, 0x00};
|
|
|
uint16_t CRC_value = calculate_crc(data_to_send, 5);
|
|
|
data_to_send[5] = (uint8_t)(CRC_value & 0xFF);
|
|
@@ -668,7 +621,6 @@ void ModBus(void) {
|
|
|
}
|
|
|
|
|
|
else if(Rx_Buf[0] == (uint8_t)initial_address && Rx_Buf[1] == 0x03 && Rx_Buf[2] == 0x00 && Rx_Buf[3] == 0xBB && Rx_Buf[4] == 0x00 && Rx_Buf[5] == 0x02){
|
|
|
-
|
|
|
uint8_t data_to_send[] = {(uint8_t)initial_address, 0x03, 0x04, (uint8_t)(System_version >> 24), (uint8_t)(System_version >> 16), (uint8_t)(System_version >> 8), (uint8_t)(System_version ), 0x00, 0x00};
|
|
|
uint16_t CRC_value = calculate_crc(data_to_send, 7);
|
|
|
data_to_send[7] = (uint8_t)(CRC_value & 0xFF);
|
|
@@ -682,7 +634,6 @@ void ModBus(void) {
|
|
|
}
|
|
|
|
|
|
else if(Rx_Buf[0] == (uint8_t)initial_address && Rx_Buf[1] == 0x06 && Rx_Buf[2] == 0x00 && Rx_Buf[3] == 0x02 && Rx_Buf[4] == 0x00){
|
|
|
-
|
|
|
updatePbStatus(Rx_Buf[5]);
|
|
|
Write_Information(ADDR_FLASH_PAGE_104, Rx_Buf, 5); // 写入Flash
|
|
|
uint8_t data_to_send[] = {(uint8_t)initial_address, 0x06, 0x02, 0x00, Rx_Buf[5], 0x00, 0x00};
|
|
@@ -697,7 +648,6 @@ void ModBus(void) {
|
|
|
HAL_UART_Receive_DMA(&huart1, USART2_RX_BUF, Uart2_BUF_SIZE);
|
|
|
}
|
|
|
else if(Rx_Buf[0] == (uint8_t)initial_address && Rx_Buf[1] == 0x06 && Rx_Buf[2] == 0x00 && Rx_Buf[3] == 0x0A && Rx_Buf[4] == 0x00 && Rx_Buf[5] == 0x01){
|
|
|
-
|
|
|
Write_Information(ADDR_FLASH_PAGE_124, Rx_Buf, 0);
|
|
|
uint16_t now_calibrationValue = Adc2_CalibrationValue;
|
|
|
uint8_t data_to_send[] = {(uint8_t)initial_address, 0x06, 0x02, (uint8_t)((now_calibrationValue >> 8) & 0xFF), (uint8_t)(now_calibrationValue & 0xFF), 0x00, 0x00};
|
|
@@ -713,7 +663,6 @@ void ModBus(void) {
|
|
|
}
|
|
|
|
|
|
else if(Rx_Buf[0] == (uint8_t)initial_address && Rx_Buf[1] == 0x06 && Rx_Buf[2] == 0x00 && Rx_Buf[3] == 0x0B && Rx_Buf[4] == 0x00 && Rx_Buf[5] == 0x01){
|
|
|
-
|
|
|
Write_Information(ADDR_FLASH_PAGE_134, Rx_Buf, 0);
|
|
|
uint16_t now_calibrationValue = Adc3_CalibrationValue;
|
|
|
uint8_t data_to_send[] = {(uint8_t)initial_address, 0x06, 0x02, (uint8_t)((now_calibrationValue >> 8) & 0xFF), (uint8_t)(now_calibrationValue & 0xFF), 0x00, 0x00};
|
|
@@ -729,7 +678,6 @@ void ModBus(void) {
|
|
|
}
|
|
|
|
|
|
else if(Rx_Buf[0] == (uint8_t)initial_address && Rx_Buf[1] == 0x06 && Rx_Buf[2] == 0x00 && Rx_Buf[3] == 0x0C && Rx_Buf[4] == 0x00){
|
|
|
-
|
|
|
update_baudrate(Rx_Buf[5]);
|
|
|
Write_Information(ADDR_FLASH_PAGE_114, Rx_Buf, 5); // 写入Flash
|
|
|
uint8_t data_to_send[] = {(uint8_t)initial_address, 0x06, 0x00, 0x0C, 0x00, Rx_Buf[5], 0x00, 0x00};
|
|
@@ -745,7 +693,6 @@ void ModBus(void) {
|
|
|
}
|
|
|
|
|
|
else if(Rx_Buf[0] == (uint8_t)initial_address && Rx_Buf[1] == 0x06 && Rx_Buf[2] == 0x00 && Rx_Buf[3] == 0xAA && Rx_Buf[4] == 0x00){
|
|
|
-
|
|
|
Write_Information(ADDR_FLASH_PAGE_94, Rx_Buf, 5); // 写入Flash
|
|
|
uint8_t data_to_send[] = {(uint8_t)initial_address, 0x06, 0x02, 0x00, (uint8_t)initial_address, 0x00, 0x00};
|
|
|
uint16_t CRC_value = calculate_crc(data_to_send, 5);
|
|
@@ -773,7 +720,6 @@ void ModBus(void) {
|
|
|
HAL_UART_Receive_DMA(&huart1, USART2_RX_BUF, Uart2_BUF_SIZE);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
/* USER CODE END 4 */
|
|
|
|