|
@@ -37,9 +37,9 @@ WHEN WHO WHAT, WHERE, WHY
|
|
|
|
|
|
|
|
|
uint8_t OTA_FLAG = 1;
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+output_control_t output_control_t_info = {0};
|
|
|
+sleep_control_t sleep_control_t_info = {0};
|
|
|
+communication_control_t communication_control_t_info = {0};
|
|
|
/**
|
|
|
* 使用SPI DMA注意事项:
|
|
|
* 8910:
|
|
@@ -355,28 +355,27 @@ static void ql_spi_demo_task_pthread(void *ctx)
|
|
|
ql_rtos_task_sleep_s(2);
|
|
|
#endif
|
|
|
static uint8_t cmd_type = 0;
|
|
|
- OTA_FLAG = 0;
|
|
|
+ OTA_FLAG = 1;
|
|
|
while(1)
|
|
|
{
|
|
|
- if(0 == OTA_FLAG)
|
|
|
+ if(0)
|
|
|
{
|
|
|
OTA_FLAG = 1;
|
|
|
QL_SPI_DEMO_LOG("ota test mode");
|
|
|
data_mpu_pack(outdata, &outlen, 0X60, 0X03, spiclk);;
|
|
|
}
|
|
|
- else if(1 == OTA_FLAG)
|
|
|
- QL_SPI_DEMO_LOG("ota test 0 0 0 0 0 0 0 0");
|
|
|
- else
|
|
|
- QL_SPI_DEMO_LOG("ota test 2 22 2 2 2 2 22 ");
|
|
|
|
|
|
cmd_type = cmd_type + 1 > 4 ? 1 : cmd_type + 1;
|
|
|
data_mpu_pack(outdata, &outlen, 0X50, cmd_type, spiclk);;
|
|
|
-
|
|
|
- spi_dma_write_hc(QL_CUR_SPI_PORT, outdata, 256, spiclk);
|
|
|
+ spi_dma_write_hc(QL_CUR_SPI_PORT, outdata, 512, spiclk);
|
|
|
+ ql_spi_flash_data_printf(outdata, 256);
|
|
|
spi_dma_read_hc(QL_CUR_SPI_PORT, indata, 512, spiclk);
|
|
|
unsigned short sendLen = 0;
|
|
|
- data_decode_mpu(indata, 256, outdata, &sendLen, spiclk);
|
|
|
-
|
|
|
+ ql_spi_flash_data_printf(indata, 512);
|
|
|
+ data_decode_mpu(indata, 512, outdata, &sendLen, spiclk);
|
|
|
+
|
|
|
+ data_mpu_pack(outdata, &outlen, 0X60, cmd_type, spiclk);;
|
|
|
+ spi_dma_write_hc(QL_CUR_SPI_PORT, outdata, 512, spiclk);
|
|
|
ql_rtos_task_sleep_ms(500);
|
|
|
}
|
|
|
ql_spi_release(QL_CUR_SPI_PORT);
|
|
@@ -473,10 +472,18 @@ uint8_t data_mpu_pack(uint8_t* output, uint16_t* output_data_len, uint8_t cmd, u
|
|
|
switch (cmd_type)
|
|
|
{
|
|
|
case 0X01:
|
|
|
- frame_tmp.cmd_type = 0X01;
|
|
|
+ frame_tmp.cmd_type = 0X01;
|
|
|
+ output_control_t_info.output_number = 6;
|
|
|
+ output_control_t_info.pwm_number = 2;
|
|
|
+ memcpy(output, &output_control_t_info, sizeof(output_control_t));
|
|
|
+ *output_data_len += sizeof(output_control_t_info);
|
|
|
break;
|
|
|
case 0X02:
|
|
|
- frame_tmp.cmd_type = 0X02;
|
|
|
+ frame_tmp.cmd_type = 0X02;
|
|
|
+ sleep_control_t_info.control_type = 1;
|
|
|
+ sleep_control_t_info.sleep_time = 256;
|
|
|
+ memcpy(output, &sleep_control_t_info, sizeof(sleep_control_t));
|
|
|
+ *output_data_len += sizeof(sleep_control_t_info);
|
|
|
break;
|
|
|
case 0X03:
|
|
|
frame_tmp.cmd_type = 0X03;
|
|
@@ -504,11 +511,9 @@ uint8_t data_mpu_pack(uint8_t* output, uint16_t* output_data_len, uint8_t cmd, u
|
|
|
static uint16 frame_index = 0;
|
|
|
uint8* indata_tmp = (unsigned char *)malloc(QL_SPI_DMA_ADDR_ALIN + FLASH_READ_LEN);
|
|
|
uint8*indata = (unsigned char *)OSI_ALIGN_UP(indata_tmp, QL_SPI_DMA_ADDR_ALIN);
|
|
|
- #define DELAY_TIME_FLASH_TEST (200)
|
|
|
+ #define DELAY_TIME_FLASH_TEST (150)
|
|
|
while((readLen) > 0)
|
|
|
{
|
|
|
-
|
|
|
-
|
|
|
*output_data_len = sizeof(frame_pack_t);
|
|
|
frame_tmp.data_lenth = sizeof(frame_pack_t) + FLASH_HEAD_0X6003 + readLen + 2 + 2;
|
|
|
memcpy(output, &frame_tmp, sizeof(frame_pack_t));
|
|
@@ -550,7 +555,7 @@ uint8_t data_mpu_pack(uint8_t* output, uint16_t* output_data_len, uint8_t cmd, u
|
|
|
spi_dma_read_hc(QL_CUR_SPI_PORT, indata, FLASH_READ_LEN, spiclk);
|
|
|
orIndex = data_decode_mpu(indata, FLASH_READ_LEN, tmp, &len_tmp, spiclk);
|
|
|
errorNum++;
|
|
|
- if(errorNum > 10)
|
|
|
+ if(errorNum > 20)
|
|
|
{
|
|
|
//升级失败
|
|
|
ql_fclose(fd_updata_file);
|
|
@@ -593,8 +598,13 @@ uint8_t data_mpu_pack(uint8_t* output, uint16_t* output_data_len, uint8_t cmd, u
|
|
|
free(indata_tmp);
|
|
|
*output_data_len = 0;
|
|
|
return 0;
|
|
|
-
|
|
|
break;
|
|
|
+ case 0X04:
|
|
|
+ frame_tmp.cmd_type = 0X04;
|
|
|
+ communication_control_t_info.can_send_data_type = 1;
|
|
|
+ memcpy(output, &communication_control_t_info, sizeof(communication_control_t));
|
|
|
+ *output_data_len += sizeof(communication_control_t);
|
|
|
+ break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
@@ -633,6 +643,7 @@ uint16_t data_decode_mpu(uint8_t *input_data, uint16_t input_data_len, uint8_t*
|
|
|
*output_data_len += sizeof(frame_pack_t);
|
|
|
//QL_SPI_DEMO_LOG("cmd :%d %dxxxxxx",input_data[frame_start + FRAME_CMD_INDEX], frame_start);
|
|
|
uint8_t *pack_data = input_data + frame_start + sizeof(frame_pack_t);
|
|
|
+
|
|
|
switch(input_data[frame_start + FRAME_CMD_INDEX])
|
|
|
{
|
|
|
case 0X50:
|
|
@@ -640,13 +651,30 @@ uint16_t data_decode_mpu(uint8_t *input_data, uint16_t input_data_len, uint8_t*
|
|
|
switch(input_data[frame_start + FRAME_CMD_TYPE_INDEX])
|
|
|
{
|
|
|
case 0X01:
|
|
|
+ // // uint8_t temperatures_number;
|
|
|
+ // int8_t temperatures_data[TEMP_NUMBER];
|
|
|
QL_SPI_DEMO_LOG("cmd :0X01----");
|
|
|
+ cmd_05_01_device_status_t* tmp_read1 = (cmd_05_01_device_status_t * )(input_data + frame_start + sizeof(frame_pack_t));
|
|
|
+ QL_SPI_DEMO_LOG("work_status %d, backup_voltage:%d, backup_temperature:%d,high_driver_number:%d,\n\
|
|
|
+ high_driver_status:%d, low_driver_number:%d low_driver_status:%d last_wake_up_source %d location_status:%d", tmp_read1->work_status, tmp_read1->backup_voltage,\
|
|
|
+ tmp_read1->backup_temperature,tmp_read1->high_driver_number,tmp_read1->high_driver_status,\
|
|
|
+ tmp_read1->low_driver_number,tmp_read1->low_driver_status, tmp_read1->last_wake_up_source,tmp_read1->location_status\
|
|
|
+ );
|
|
|
+ (void)tmp_read1;
|
|
|
break;
|
|
|
- case 0X02:
|
|
|
+ case 0X02:;
|
|
|
QL_SPI_DEMO_LOG("cmd :0X02----");
|
|
|
+ gps_info_t* tmp_read2 = (gps_info_t *)(input_data + frame_start + sizeof(frame_pack_t));
|
|
|
+ QL_SPI_DEMO_LOG("gps locate_mark %d,satellite_num %d,", tmp_read2->locate_mark, tmp_read2->satellite_num);
|
|
|
+ (void)tmp_read2;
|
|
|
break;
|
|
|
case 0X03:
|
|
|
QL_SPI_DEMO_LOG("cmd :0X03----");
|
|
|
+ cmd_05_03_communication_data_t* tmp_read = (cmd_05_03_communication_data_t *)(input_data + frame_start + sizeof(frame_pack_t));
|
|
|
+ QL_SPI_DEMO_LOG("%d, %d,%d, %d,%d, %d,%d, %d,%d, %d,%d,",\
|
|
|
+ tmp_read->x_data,tmp_read->y_data,tmp_read->z_data,tmp_read-> can0_data_status,tmp_read-> can0_fault_status,tmp_read->can0_data_lenth,\
|
|
|
+ tmp_read-> can1_data_status,tmp_read-> can1_fault_status,tmp_read->can1_data_lenth,tmp_read-> rs485_data_status,tmp_read->rs485_data_lenth);
|
|
|
+ (void)tmp_read;
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
@@ -662,7 +690,6 @@ uint16_t data_decode_mpu(uint8_t *input_data, uint16_t input_data_len, uint8_t*
|
|
|
break;
|
|
|
case 0X02:
|
|
|
///
|
|
|
-
|
|
|
break;
|
|
|
case 0X03:
|
|
|
QL_SPI_DEMO_LOG("cmd60 03----flash\nframe_index :%d\n", (pack_data[0] + (pack_data[1] << 8)));
|