Grisha Boga / Mbed 2 deprecated Prog_rele_with_tft

Dependencies:   mbed mbed-rtos

Files at this revision

API Documentation at this revision

Comitter:
grisha_b13
Date:
Thu Sep 23 18:18:05 2021 +0000
Parent:
0:aa53c09fba30
Commit message:
23_09_21

Changed in this revision

mbed_app.json Show annotated file Show diff for this revision Revisions of this file
src/main.cpp Show annotated file Show diff for this revision Revisions of this file
src/task.cpp Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed_app.json	Thu Sep 23 18:18:05 2021 +0000
@@ -0,0 +1,9 @@
+{
+    "target_overrides": {
+        "NUCLEO_F103RB": {
+            "target.clock_source": "USE_PLL_HSE_XTAL",
+            "target.default_lib": "std"
+        }
+    }
+}
+
--- a/src/main.cpp	Mon Sep 20 13:06:41 2021 +0000
+++ b/src/main.cpp	Thu Sep 23 18:18:05 2021 +0000
@@ -44,20 +44,16 @@
 void	logic_tasks();			// логические задачи
 void  	timers();				// обработка таймеров
 int   	read_val(); 			// вычитывание значения из строки
+void	pc_rd();				// работа с serial портом 
+
+/*********************  Threads  **************************************/
+Thread	read_uart;
 
 //--------  for SERIAL interface ---------------------------------------
 Serial pc(PB_10, PB_11);		// tx, rx
 int    pc_i = 99;
 int    pc_m = 0;
 char   pc_buffer[100];
- 
-void  pc_interrupt(void) {
-	if (pc_i < 100) { 
-	   pc_buffer[pc_i++] = pc.getc(); 
-	} else { 
-		pc_buffer[MAX_LEN] = pc.getc(); 
-	}
-}
 
 //----------- Local vars -----------------------------------------------
 int delay_time = 10;
@@ -116,11 +112,13 @@
 {		
 	//----- настраиваем порт serial  ------ 
 	pc.baud(UART_BAUD);
-	pc.attach(&pc_interrupt);
 	
 	//--- запускаем логич.задач по таймеру  delay_time msec ------
     RtosTimer t_msec(&logic_tasks); 
     t_msec.start(delay_time); 	
+    
+    //-------  запускаем  потоки  Thread  ------
+    read_uart.start(pc_rd); // чтение UART
 	
     while(true)
     {
@@ -128,8 +126,7 @@
 		
 		// проверяем usb
        	if (pc_i > 1 && pc_i == pc_m) {            
-            pc_buffer[pc_i++] = 0; pc_i = 0;
-            y01 = 1; 
+            pc_buffer[pc_i++] = 0; pc_i = 0; 
 			// ---  устанавливаем значение  переменных ----
             if(strstr(pc_buffer, "=")) {
 				if(strstr(pc_buffer, "pr001")) { pr001 = read_val(); pc.printf("ok\n"); check_par1 = 1; }
@@ -158,7 +155,7 @@
 				if(strstr(pc_buffer, "al000?")) { pc.printf("al000:%d\n", al000); }
 			}
 			
-		 } else { pc_m = pc_i; y01 = 0;} 
+		 } else { pc_m = pc_i; } 
 
 		Thread::wait(250);
     }
@@ -279,4 +276,20 @@
 	return val;
 }
 
+//----------------------------------------
+// посимвольный прием из USB и  сохранение  
+// информации в буфере, обрабатывается после того как все принято
+void pc_rd()
+{
+	sprintf(pc_buffer, "buff_ok");
+	while(1) 
+	{
+		if(pc.readable()) {
+			pc_buffer[pc_i] = pc.getc();
+			if(pc_i < MAX_LEN) { pc_i++; }
+			pc_buffer[pc_i] = 0; 
+		}
+	}
+}
 
+
--- a/src/task.cpp	Mon Sep 20 13:06:41 2021 +0000
+++ b/src/task.cpp	Thu Sep 23 18:18:05 2021 +0000
@@ -5,7 +5,6 @@
 int task(){     
     int  sts = 0; 
     
-    
 	sts = 1; 
     return sts;
 }