Meco Man 4 жил өмнө
parent
commit
a90d0ffc4d
2 өөрчлөгдсөн 53 нэмэгдсэн , 53 устгасан
  1. 43 43
      samples/rti_uart_sample.c
  2. 10 10
      src/rti.c

+ 43 - 43
samples/rti_uart_sample.c

@@ -63,52 +63,52 @@ rt_err_t rt_ind(rt_device_t dev, rt_size_t size)
 {
     //rti_data_new_data_notify_set_hook(rti_data_new_data_notify);
     //rti_start();
-	rt_sem_release(&rx_sem);
+    rt_sem_release(&rx_sem);
     return 0;
 }
 
 static void rti_rx_entry(void *param)
 {
-	char ch;
-
-	rt_uint8_t rx_cnt = 0;	
-	rt_uint8_t rx_buff[REV_START_FIRST_FARAM_SIZE];
-
-	while(1)
-	{
-		while (rt_device_read(rti_dev, -1, &ch, 1) != 1)
-		{
-			rx_cnt = 0;		
-			rt_sem_take(&rx_sem, RT_WAITING_FOREVER);		
-		}
-		
-		//rt_kprintf("%02X ",ch);
-		
-		rx_buff[rx_cnt++] = ch;			
-		
-		if(rx_cnt==REV_START_FIRST_FARAM_SIZE)
-		{
-			if(rx_buff[0] == REV_START_FIRSE_FARAM_BYTE0 && rx_buff[1] == REV_START_FIRSE_FARAM_BYTE1)
-			{
-				rti_data_new_data_notify_set_hook(rti_data_new_data_notify);
-				rti_start();
-			}
-			
-			rx_cnt = 0;
-		}		
-		
-		if(ch == REV_START_SECOND_FARAM_BYTE)
-		{
-			rti_data_new_data_notify_set_hook(rti_data_new_data_notify);
-			rti_start();
-		}
-		
-		if(ch == REV_STOP_FARAM_BYTE)
-		{					
-			rti_stop();
-			rti_data_new_data_notify_set_hook(NULL);
-		}
-	}
+    char ch;
+
+    rt_uint8_t rx_cnt = 0;
+    rt_uint8_t rx_buff[REV_START_FIRST_FARAM_SIZE];
+
+    while(1)
+    {
+        while (rt_device_read(rti_dev, -1, &ch, 1) != 1)
+        {
+            rx_cnt = 0;
+            rt_sem_take(&rx_sem, RT_WAITING_FOREVER);
+        }
+
+        //rt_kprintf("%02X ",ch);
+
+        rx_buff[rx_cnt++] = ch;
+
+        if(rx_cnt==REV_START_FIRST_FARAM_SIZE)
+        {
+            if(rx_buff[0] == REV_START_FIRSE_FARAM_BYTE0 && rx_buff[1] == REV_START_FIRSE_FARAM_BYTE1)
+            {
+                rti_data_new_data_notify_set_hook(rti_data_new_data_notify);
+                rti_start();
+            }
+
+            rx_cnt = 0;
+        }
+
+        if(ch == REV_START_SECOND_FARAM_BYTE)
+        {
+            rti_data_new_data_notify_set_hook(rti_data_new_data_notify);
+            rti_start();
+        }
+
+        if(ch == REV_STOP_FARAM_BYTE)
+        {
+            rti_stop();
+            rti_data_new_data_notify_set_hook(NULL);
+        }
+    }
 }
 
 void rti_uart_sample(void)
@@ -129,8 +129,8 @@ void rti_uart_sample(void)
 
     rt_device_set_rx_indicate(rti_dev, rt_ind);
     rt_device_open(rti_dev, RT_DEVICE_OFLAG_RDWR | RT_DEVICE_FLAG_INT_RX);
-	
-	rt_thread_init(&rti_rx_th,"rti_rx",rti_rx_entry,RT_NULL,&rti_rx_stack[0],sizeof(rti_rx_stack),20 - 1, 20);
+
+    rt_thread_init(&rti_rx_th,"rti_rx",rti_rx_entry,RT_NULL,&rti_rx_stack[0],sizeof(rti_rx_stack),20 - 1, 20);
     rt_thread_startup(&rti_rx_th);
 }
 #ifdef RT_USING_FINSH

+ 10 - 10
src/rti.c

@@ -40,16 +40,16 @@
 static struct
 {
     rt_uint32_t time_stamp_last;
-    
+
     /* rti overflow packet count*/
     rt_uint32_t packet_count;
-    
+
     /* rti enable status*/
     rt_uint8_t  enable;
-    
+
     /* event disable nest*/
     rt_uint8_t  disable_nest[RTI_TRACE_NUM];
-    
+
 } rti_status;
 
 struct rt_ringbuffer *tx_ringbuffer = RT_NULL;
@@ -713,12 +713,12 @@ void rti_start(void)
 
 void rti_stop(void)
 {
-	rti_send_packet_void(RTI_ID_STOP);
-	rt_thread_delay(50);
-	RT_OBJECT_HOOK_CALL(rti_data_new_data_notify, ());	
-	rt_thread_delay(50);
-	RT_OBJECT_HOOK_CALL(rti_data_new_data_notify, ());
-	
+    rti_send_packet_void(RTI_ID_STOP);
+    rt_thread_delay(50);
+    RT_OBJECT_HOOK_CALL(rti_data_new_data_notify, ());
+    rt_thread_delay(50);
+    RT_OBJECT_HOOK_CALL(rti_data_new_data_notify, ());
+
     rti_status.enable = RTI_DISABLE;
     rt_kprintf("rti stop\n");
     if (rti_thread != RT_NULL)