Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Neyzoter committed Apr 25, 2019
1 parent e4e9bad commit c61ed72
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion HARDWARE/CAN/can1.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ void CAN1_RX0_IRQHandler(void){
{
if((Wifi_Send_EN == 1) && ((CAN_Get_EN & CAN1_ENABLE_BIT_SLC) != 0)){
/* 如果队列空了,时间戳更新*/
if(queue_empty(can_queue)){
if(queue_empty(&can_queue)){
can_queue.HeadTime = SYSTEMTIME;
can_queue.YYYY_MM_DD = YYMMDD;
}
Expand Down
2 changes: 1 addition & 1 deletion HARDWARE/CAN/can2.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ void CAN2_RX1_IRQHandler(void)
if (CAN_GetITStatus(CAN2,CAN_IT_FMP1)!= RESET){
if((Wifi_Send_EN == 1) && ((CAN_Get_EN & CAN2_ENABLE_BIT_SLC) != 0)){
/* 如果队列空了,时间戳更新*/
if(queue_empty(can_queue)){
if(queue_empty(&can_queue)){
can_queue.HeadTime = SYSTEMTIME;
can_queue.YYYY_MM_DD = YYMMDD;
}
Expand Down
12 changes: 6 additions & 6 deletions HARDWARE/QUEUE/queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,9 @@ void queue_oversize(volatile Queue * pQueue,u32 length)
* @param queue:队列
* @retval 是否空队列(1:空队列;0:非空队列)
*/
u8 queue_empty(volatile Queue queue)
u8 queue_empty(volatile Queue * queue)
{
if(queue.head == queue.tail)
if(queue->head == queue->tail)
return 1;
return 0;
}
Expand All @@ -165,19 +165,19 @@ u8 queue_empty(volatile Queue queue)
* @param queue:队列
* @retval 队列长度
*/
u32 queue_length(volatile Queue queue)
u32 queue_length(volatile Queue * queue)
{
return (queue.tail-queue.head+QUEUE_SIZE)%QUEUE_SIZE;
return (queue->tail-queue->head+QUEUE_SIZE)%QUEUE_SIZE;
}

/**
* @brief 查看队列是否满
* @param queue:队列
* @retval 是否满队列(1:满队列;0:非满队列)
*/
u8 queue_full(volatile Queue queue)
u8 queue_full(volatile Queue * queue)
{
if((queue.tail + 20) % QUEUE_SIZE >= queue.head)
if((queue->tail + 20) % QUEUE_SIZE >= queue->head)
return 1;
return 0;
}
Expand Down
14 changes: 7 additions & 7 deletions HARDWARE/QUEUE/queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
* @note 队列存储ADC和CAN数据,数据长度以ADC长度设置
* @{
*/
#define ADC_SEND_SIZE (8*50 + PACKAGE_HEAD_FRAME_LENGTH) /*!< ADC数据包最大大小 540 = 8 * 60 + PACKAGE_HEAD_FRAME_LENGTH>*/
#define CAN_SEND_SIZE (25 * 16 + PACKAGE_HEAD_FRAME_LENGTH) /*!< CAN数据包最大大小 540 = 8 * 60 + PACKAGE_HEAD_FRAME_LENGTH>*/
#define QUEUE_SIZE 700 /*!< 队列正常容量,必须比ADC_SEND_SIZE大一些,不然会在被后面的信息覆盖>*/
#define ARR_SIZE (QUEUE_SIZE + ADC_SEND_SIZE+52) /*!< 队列最大容量>*/
#define ADC_SEND_SIZE (8*50 + PACKAGE_HEAD_FRAME_LENGTH) /*!< ADC数据包最大大小 480 = 8 * 50 + PACKAGE_HEAD_FRAME_LENGTH UDP包尽量不要超过576-20-8=548个>*/
#define CAN_SEND_SIZE (25 * 16 + PACKAGE_HEAD_FRAME_LENGTH) /*!< CAN数据包最大大小 480 = 25* 16 + PACKAGE_HEAD_FRAME_LENGTH UDP包尽量不要超过576-20-8=548个>*/
#define QUEUE_SIZE 800 /*!< 队列正常容量,必须比ADC_SEND_SIZE大一些,不然会在被后面的信息覆盖>*/
#define ARR_SIZE (QUEUE_SIZE + ADC_SEND_SIZE+52) /*!< 队列最大容量>*/
/**
* @}
*/
Expand Down Expand Up @@ -87,9 +87,9 @@ void queue_arr_memcpy(Queue * pQueue, u8 * buf , u8 len);
void queue_addtime_addIO(volatile Queue * pQueue, u32 count, u8 id, u8 IO_input1, u8 IO_input2,u8 dataType);
void queue_oversize(volatile Queue * pQueue,u32 length);
void queue_clear(volatile Queue * pQueue);
u8 queue_empty(volatile Queue queue);
u8 queue_full(volatile Queue queue);
u32 queue_length(volatile Queue queue);
u8 queue_empty(volatile Queue * queue);
u8 queue_full(volatile Queue * queue);
u32 queue_length(volatile Queue * queue);
static void queue_add_name(volatile Queue * pQueue,volatile u8 testname[MAX_TEST_NAME_LENGTH]);

#endif
2 changes: 1 addition & 1 deletion HARDWARE/TIMER/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ void TIM3_IRQHandler(void)
*/
if(BOARD_STA == BOARD_RUNNING){
/* 如果队列空了,时间戳更新*/
if(queue_empty(adc_queue)){
if(queue_empty(&adc_queue)){
adc_queue.HeadTime = SYSTEMTIME;
adc_queue.YYYY_MM_DD = YYMMDD;
}
Expand Down
20 changes: 10 additions & 10 deletions HARDWARE/WIFI/userwifi.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ void wifi_send_package_test()
queue_put(&adc_queue,i);
}

Length = queue_length(adc_queue);
Length = queue_length(&adc_queue);
queue_addtime_addIO(&adc_queue,Length, nodeId, DIGITAL_INPUT1,DIGITAL_INPUT2,ADC_DATA_PACKAGE);
if(adc_queue.head + ADC_SEND_SIZE > QUEUE_SIZE ) queue_oversize(&adc_queue,adc_queue.head + ADC_SEND_SIZE - QUEUE_SIZE);
Head = adc_queue.head;
Expand Down Expand Up @@ -138,8 +138,8 @@ u8 wifi_send_package()
/* 有同步时钟到来*/
if(Time_Sync_Flag==1)
{
Adc_Length = queue_length(adc_queue);
Can_Length = queue_length(can_queue);
Adc_Length = queue_length(&adc_queue);
Can_Length = queue_length(&can_queue);

/* ADC Queue加入帧头*/
//1.加入帧头
Expand Down Expand Up @@ -193,9 +193,9 @@ u8 wifi_send_package()
Time_Sync_Flag = 0;//时钟同步位清零
}
/* ADC队列已满*/
if(queue_length(adc_queue) >= (ADC_SEND_SIZE - PACKAGE_HEAD_FRAME_LENGTH )){
if(queue_length(&adc_queue) >= (ADC_SEND_SIZE - PACKAGE_HEAD_FRAME_LENGTH )){

Adc_Length = queue_length(adc_queue);
Adc_Length = queue_length(&adc_queue);
queue_addtime_addIO(&adc_queue,Adc_Length,nodeId, DIGITAL_INPUT1,DIGITAL_INPUT2,ADC_DATA_PACKAGE); // head <- head-10;
Adc_Head = adc_queue.head;
adc_queue.head = adc_queue.tail;
Expand All @@ -218,8 +218,8 @@ u8 wifi_send_package()
delay_ms(WIFI_MODUEL_WAIT_MSTIME);
}
/* CAN队列已满*/
if( queue_length(can_queue) >= (CAN_SEND_SIZE - PACKAGE_HEAD_FRAME_LENGTH )){
Can_Length = queue_length(can_queue);
if( queue_length(&can_queue) >= (CAN_SEND_SIZE - PACKAGE_HEAD_FRAME_LENGTH )){
Can_Length = queue_length(&can_queue);
queue_addtime_addIO(&can_queue,Can_Length, nodeId, DIGITAL_INPUT1,DIGITAL_INPUT2,CAN_DATA_PACKAGE);
Can_Head = can_queue.head;
can_queue.head = can_queue.tail;
Expand Down Expand Up @@ -256,18 +256,18 @@ u8 wifi_send_package()
}
//校验数据长度

u32 count = can_queue.arr[(Can_Head+8)%QUEUE_SIZE] + 255 * can_queue.arr[(Can_Head+9)%QUEUE_SIZE];
u32 count = can_queue.arr[(Can_Head+8)%QUEUE_SIZE] + 256 * can_queue.arr[(Can_Head+9)%QUEUE_SIZE] + 256 * 256 * can_queue.arr[(Can_Head+10)%QUEUE_SIZE];
printf("count : %d ?= Can_Length : %d\r\n",count,Can_Length);
if(count != Can_Length){
printf("Len Check Error\r\n");
}
#endif
rsi_send_ludp_data(localSocketDescriptor_txrx, &can_queue.arr[Can_Head],Can_Length+PACKAGE_HEAD_FRAME_LENGTH, RSI_PROTOCOL_UDP_V4, (uint8 *)localDestIp_txrx, localDestSocket_txrx, &bytes_sent);
DATA_AUTO_CHECK_EN = temp;
}else if(queue_length(can_queue) > 0){ /* CAN队列中数据存储时间过长,以us为单位,就发出来*/
}else if(queue_length(&can_queue) > 0){ /* CAN队列中数据存储时间过长,以us为单位,就发出来*/
if(((SYSTEMTIME - ((u32)(can_queue.arr[can_queue.head+1]&0xff)|((u32)(can_queue.arr[can_queue.head+2]&0xff)<<8)|((u32)(can_queue.arr[can_queue.head+3]&0xff)<<16)
|((u32)(can_queue.arr[can_queue.head+4]&0xff)<<24)))*(TIM4_ARR + 1)*(TIM4_PSC + 1) / TIM3_4_PCLK_MHZ) > CAN_OVERTIME_SEND_TIME){
Can_Length = queue_length(can_queue);
Can_Length = queue_length(&can_queue);
queue_addtime_addIO(&can_queue,Can_Length, nodeId, DIGITAL_INPUT1,DIGITAL_INPUT2,CAN_DATA_PACKAGE);
Can_Head = can_queue.head;
can_queue.head = can_queue.tail;
Expand Down

0 comments on commit c61ed72

Please sign in to comment.