瀏覽代碼

ESP8266 Wifi Data 못가져오는 버그 수정

Data 딜레이로 인한 Data 손실 특정 헤더 검색 시  data 가져오기
YJ 5 年之前
父節點
當前提交
e29a58d68d
共有 29 個文件被更改,包括 8865 次插入7364 次删除
  1. 二進制
      Debug/STM32F103_WifiAttenCtrlTest.binary
  2. 二進制
      Debug/STM32F103_WifiAttenCtrlTest.elf
  3. 1050 1013
      Debug/STM32F103_WifiAttenCtrlTest.hex
  4. 5995 5704
      Debug/STM32F103_WifiAttenCtrlTest.list
  5. 656 611
      Debug/STM32F103_WifiAttenCtrlTest.map
  6. 4 3
      Debug/Src/esp8266.su
  7. 6 6
      Debug/Src/main.su
  8. 二進制
      Debug/Src/uart.o
  9. 8 6
      Debug/Src/uart.su
  10. 1 1
      Inc/esp8266.h
  11. 3 2
      Inc/uart.h
  12. 45 14
      Src/esp8266.c
  13. 7 2
      Src/main.c
  14. 16 2
      Src/uart.c
  15. 76 0
      insight/STM32F103_WifiAttenCtrlTest.si4project/Backup/esp8266(1154).c
  16. 99 0
      insight/STM32F103_WifiAttenCtrlTest.si4project/Backup/esp8266(1956).c
  17. 17 0
      insight/STM32F103_WifiAttenCtrlTest.si4project/Backup/esp8266(6222).h
  18. 655 0
      insight/STM32F103_WifiAttenCtrlTest.si4project/Backup/main(1134).c
  19. 95 0
      insight/STM32F103_WifiAttenCtrlTest.si4project/Backup/uart(6080).c
  20. 95 0
      insight/STM32F103_WifiAttenCtrlTest.si4project/Backup/uart(6947).c
  21. 37 0
      insight/STM32F103_WifiAttenCtrlTest.si4project/Backup/uart(905).h
  22. 二進制
      insight/STM32F103_WifiAttenCtrlTest.si4project/STM32F103_WifiAttenCtrlTest.sip_sym
  23. 二進制
      insight/STM32F103_WifiAttenCtrlTest.si4project/STM32F103_WifiAttenCtrlTest.siwork
  24. 二進制
      insight/STM32F103_WifiAttenCtrlTest.si4project/cache/parse/.._Drivers_STM32F1xx_HAL_Driver_Src_stm32f1xx_hal_uart.c.sisc
  25. 二進制
      insight/STM32F103_WifiAttenCtrlTest.si4project/cache/parse/.._Inc_esp8266.h.sisc
  26. 二進制
      insight/STM32F103_WifiAttenCtrlTest.si4project/cache/parse/.._Inc_uart.h.sisc
  27. 二進制
      insight/STM32F103_WifiAttenCtrlTest.si4project/cache/parse/.._Src_esp8266.c.sisc
  28. 二進制
      insight/STM32F103_WifiAttenCtrlTest.si4project/cache/parse/.._Src_main.c.sisc
  29. 二進制
      insight/STM32F103_WifiAttenCtrlTest.si4project/cache/parse/.._Src_uart.c.sisc

二進制
Debug/STM32F103_WifiAttenCtrlTest.binary


二進制
Debug/STM32F103_WifiAttenCtrlTest.elf


File diff suppressed because it is too large
+ 1050 - 1013
Debug/STM32F103_WifiAttenCtrlTest.hex


File diff suppressed because it is too large
+ 5995 - 5704
Debug/STM32F103_WifiAttenCtrlTest.list


File diff suppressed because it is too large
+ 656 - 611
Debug/STM32F103_WifiAttenCtrlTest.map


+ 4 - 3
Debug/Src/esp8266.su

@@ -1,3 +1,4 @@
1
-esp8266.c:12:6:ESP8266_Initialize	8	static
2
-esp8266.c:62:9:ESP8266_Strindex	8	static
3
-esp8266.c:65:9:ESP8266_StrFilter	16	static
1
+esp8266.c:13:6:ESP8266_Initialize	8	static
2
+esp8266.c:63:9:ESP8266_StrLength	8	static
3
+esp8266.c:66:9:ESP8266_StrIndexSearch	16	static
4
+esp8266.c:75:9:ESP8266_StrFilter	32	static

+ 6 - 6
Debug/Src/main.su

@@ -1,6 +1,6 @@
1
-main.c:87:6:HAL_TIM_PeriodElapsedCallback	0	static
2
-main.c:97:5:_write	8	static
3
-main.c:102:10:ADC_Value_RetFunc	0	static
4
-main.c:196:6:SystemClock_Config	96	static
5
-main.c:113:5:main	96	static
6
-main.c:630:6:Error_Handler	0	static
1
+main.c:88:6:HAL_TIM_PeriodElapsedCallback	0	static
2
+main.c:98:5:_write	8	static
3
+main.c:103:10:ADC_Value_RetFunc	0	static
4
+main.c:201:6:SystemClock_Config	96	static
5
+main.c:114:5:main	96	static
6
+main.c:635:6:Error_Handler	0	static

二進制
Debug/Src/uart.o


+ 8 - 6
Debug/Src/uart.su

@@ -1,6 +1,8 @@
1
-uart.c:12:6:InitUartQueue	8	static
2
-uart.c:56:6:GetDataFromUartQueue	16	static
3
-uart.c:24:6:HAL_UART_RxCpltCallback	16	static
4
-uart.c:37:6:PutDataToUartQueue	16	static
5
-uart.c:88:6:Uart1_Data_Send	0	static
6
-uart.c:91:6:Uart2_Data_Send	0	static
1
+uart.c:14:6:InitUartQueue	8	static
2
+uart.c:40:6:UartDataRecvSet	0	static
3
+uart.c:43:6:UartDataRecvGet	0	static
4
+uart.c:67:6:GetDataFromUartQueue	16	static
5
+uart.c:26:6:HAL_UART_RxCpltCallback	16	static
6
+uart.c:47:6:PutDataToUartQueue	16	static
7
+uart.c:102:6:Uart1_Data_Send	0	static
8
+uart.c:105:6:Uart2_Data_Send	0	static

+ 1 - 1
Inc/esp8266.h

@@ -10,7 +10,7 @@
10 10
 
11 11
 #include "main.h"
12 12
 
13
-uint8_t ESP8266_Strindex(uint8_t* str);
13
+uint8_t ESP8266_StrLength(uint8_t* str);
14 14
 void ESP8266_Initialize(void);
15 15
 uint8_t ESP8266_StrFilter(uint8_t* str);
16 16
 

+ 3 - 2
Inc/uart.h

@@ -31,7 +31,8 @@ extern UARTQUEUE WifiQueue;
31 31
 void PutDataToUartQueue(UART_HandleTypeDef *huart, uint8_t data);
32 32
 void InitUartQueue(UART_HandleTypeDef *huart,pUARTQUEUE pQueue);
33 33
 void GetDataFromUartQueue(UART_HandleTypeDef *huart);
34
-bool Get_UartRcv(void);
35
-void Set_UartRcv(bool);
34
+void UartDataRecvSet(bool);
35
+bool UartDataRecvGet(void);
36
+
36 37
 
37 38
 #endif /* UART_H_ */

+ 45 - 14
Src/esp8266.c

@@ -6,6 +6,7 @@
6 6
  */
7 7
 
8 8
 #include <string.h>
9
+#include <stdlib.h>
9 10
 #include "esp8266.h"
10 11
 
11 12
 
@@ -35,21 +36,21 @@ void ESP8266_Initialize(void){
35 36
 #if 1 // PYJ.2019.12.13_BEGIN -- 
36 37
 	  switch(seq){
37 38
     	  case 0:
38
-              Uart2_Data_Send("AT+CWMODE=3\r\n",ESP8266_Strindex("AT+CWMODE=3\r\n"));
39
+              Uart2_Data_Send("AT+CWMODE=3\r\n",ESP8266_StrLength("AT+CWMODE=3\r\n"));
39 40
     		  seq++;
40 41
     		  break;
41 42
     	  case 1:
42
-              Uart2_Data_Send("AT+CIPMUX=1\r\n",ESP8266_Strindex("AT+CIPMUX=1\r\n"));
43
+              Uart2_Data_Send("AT+CIPMUX=1\r\n",ESP8266_StrLength("AT+CIPMUX=1\r\n"));
43 44
     		  seq++;
44 45
     		  break;
45 46
     	  case 2:
46
-              Uart2_Data_Send("AT+CWSAP=\"BLUE_TEST\",\"\",5,0\r\n",ESP8266_Strindex("AT+CWSAP=\"BLUE_TEST\",\"\",5,0\r\n"));
47
+              Uart2_Data_Send("AT+CWSAP=\"BLUE_TEST\",\"\",5,0\r\n",ESP8266_StrLength("AT+CWSAP=\"BLUE_TEST\",\"\",5,0\r\n"));
47 48
     		  seq++;
48 49
     		  break;
49 50
     	  case 3:
50
-              Uart2_Data_Send("AT+CIPSERVER=1,4000\r\n",ESP8266_Strindex("AT+CIPSERVER=1,4000\r\n"));
51
+              Uart2_Data_Send("AT+CIPSERVER=1,4000\r\n",ESP8266_StrLength("AT+CIPSERVER=1,4000\r\n"));
51 52
               HAL_Delay(5);
52
-              Uart2_Data_Send("AT+CIFSR\r\n",ESP8266_Strindex("AT+CIFSR\r\n"));
53
+              Uart2_Data_Send("AT+CIFSR\r\n",ESP8266_StrLength("AT+CIFSR\r\n"));
53 54
     		  printf("ESP Setting Complete \r\n");
54 55
     		  seq++;
55 56
     		  break;
@@ -59,18 +60,48 @@ void ESP8266_Initialize(void){
59 60
 #endif // PYJ.2019.12.13_END -- 
60 61
 
61 62
 }
62
-uint8_t ESP8266_Strindex(uint8_t* str){
63
+uint8_t ESP8266_StrLength(uint8_t* str){
63 64
     return strlen(str);
64 65
 }
66
+uint8_t ESP8266_StrIndexSearch(uint8_t* str,uint8_t* searchstr){
67
+    for(int i = 0; i < ESP8266_StrLength(str); i++){
68
+        if(*(str + i) == *searchstr){
69
+//            printf("\"%s \" index : %d \r\n",*searchstr, i);
70
+            return i;
71
+        }
72
+    }
73
+    return 0;
74
+}
65 75
 uint8_t ESP8266_StrFilter(uint8_t* str){
66
-    char *ptr = strstr(str, ":");      // den으로 시작하는 문자열 검색, 포인터 반환
67
-    
76
+    uint8_t *ptr = strstr(str, "+IPD,0,30:");      // den으로 시작하는 문자열 검색, 포인터 반환
77
+    uint8_t temp_index;
78
+    uint8_t temp_length;
79
+    uint8_t temp_str[5] = {NULL,};
68 80
     //printf("first : %s\n", ptr);    // den Diary
69
-    
70
-    printf("\r\nResult : ");
71
-    for(int i = 0; i < ESP8266_Strindex(ptr); i++)
72
-        printf("%d", ptr[i]);    // den Diary
73
-
74
-    printf("\r\n");
81
+    if(strstr(ptr, "+IPD,0,30:") != NULL){
82
+        temp_index= ESP8266_StrIndexSearch(ptr,":"); 
83
+        if(temp_index == 0 || *(ptr + (temp_index + 1)) != 0xbe){
84
+            return 0;
85
+        }else{
86
+            temp_str[0] = ptr[temp_index - 2];
87
+            temp_str[1] = ptr[temp_index - 1];
88
+        
89
+            temp_length = atoi(temp_str);
90
+    //        temp_length += atoi(ptr[temp_index - 1]);
91
+    //        printf("(+IPD,0,)Length%d \r\n",ESP8266_StrLength("+IPD,0,"));
92
+    //        printf("Length Result : %d \r\n",temp_length);
93
+            //if(ptr != NULL){
94
+                printf("\r\n %d Result : ",ESP8266_StrLength(ptr));
95
+                for(int i = (temp_index + 1); i < temp_length + (temp_index + 1) + 9; i++)
96
+                    printf("%d ", *(ptr + i));    // den Diary
97
+                printf("\r\n");
98
+            //}
99
+        }
100
+    }else{
101
+  //      for(int i = 0; i < ESP8266_StrLength(ptr); i++) 
102
+//            printf("%c",*(ptr+ i));
103
+        printf("I am not found\r\n");
104
+    }
75 105
 
106
+    return 0;
76 107
 }

+ 7 - 2
Src/main.c

@@ -21,6 +21,7 @@
21 21
 /* Includes ------------------------------------------------------------------*/
22 22
 #include <stdio.h>
23 23
 #include <string.h>
24
+#include <stdbool.h>
24 25
 #include "main.h"
25 26
 
26 27
 /* Private includes ----------------------------------------------------------*/
@@ -179,8 +180,12 @@ int main(void)
179 180
 //	      printf("ADC Vale : %f \r\n",temp_tmp * temp_val);
180 181
 	      AdcTimerCnt = 0;
181 182
 	  }
182
-	   while (TerminalQueue.data > 0) GetDataFromUartQueue(&hTerminal);
183
-	   while (WifiQueue.data > 0) GetDataFromUartQueue(&hWifi);
183
+      if(UartTimerCnt > 300 && UartDataRecvGet()){
184
+          while (TerminalQueue.data > 0) GetDataFromUartQueue(&hTerminal);
185
+          while (WifiQueue.data > 0) GetDataFromUartQueue(&hWifi);
186
+          UartTimerCnt = 0;
187
+          UartDataRecvSet(false);
188
+      }
184 189
        HAL_Delay(1);
185 190
     /* USER CODE END WHILE */
186 191
 

+ 16 - 2
Src/uart.c

@@ -6,9 +6,11 @@
6 6
  */
7 7
 
8 8
 #include "uart.h"
9
-
9
+#include <stdbool.h>
10 10
 UARTQUEUE TerminalQueue;
11 11
 UARTQUEUE WifiQueue;
12
+bool UartDataisReved;
13
+
12 14
 void InitUartQueue(UART_HandleTypeDef *huart,pUARTQUEUE pQueue)
13 15
 {
14 16
     UART_HandleTypeDef *dst = (huart->Instance == USART2 ? &hWifi:&hTerminal);
@@ -32,8 +34,16 @@ void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
32 34
     if (pQueue->data >= QUEUE_BUFFER_LENGTH)
33 35
         GetDataFromUartQueue(huart);
34 36
     HAL_UART_Receive_DMA(dst, pQueue->Buffer + pQueue->head, 1);
37
+    UartDataRecvSet(true);
35 38
    // Set_UartRcv(true);
36 39
 }
40
+void UartDataRecvSet(bool val){
41
+    UartDataisReved = val;
42
+}
43
+bool UartDataRecvGet(void){
44
+    return UartDataisReved;
45
+}
46
+
37 47
 void PutDataToUartQueue(UART_HandleTypeDef *huart, uint8_t data)
38 48
 {
39 49
     pUARTQUEUE pQueue = (huart->Instance == USART2 ? &WifiQueue:&TerminalQueue);
@@ -52,6 +62,7 @@ typedef enum{
52 62
 }Bluecell_Prot_p;
53 63
 
54 64
 uint8_t uart_buf[QUEUE_BUFFER_LENGTH];
65
+bool GoodDataStatus = false;
55 66
 
56 67
 void GetDataFromUartQueue(UART_HandleTypeDef *huart)
57 68
 {
@@ -67,6 +78,8 @@ if(huart->Instance == USART1){
67 78
 #endif // PYJ.2019.12.13_END -- 
68 79
     printf("%c",*(pQueue->Buffer + pQueue->tail));
69 80
     uart_buf[cnt++] = *(pQueue->Buffer + pQueue->tail); 
81
+    if(*(pQueue->Buffer + pQueue->tail) == 0xbe)
82
+        GoodDataStatus = true;
70 83
     
71 84
 
72 85
 //    printf("Function : %s : ",__func__);
@@ -79,10 +92,11 @@ if(huart->Instance == USART1){
79 92
     pQueue->tail++;
80 93
     if (pQueue->tail >= QUEUE_BUFFER_LENGTH) pQueue->tail = 0;
81 94
     pQueue->data--;
82
-    if(pQueue->data == 0){
95
+    if(pQueue->data == 0 && GoodDataStatus == true){
83 96
         ESP8266_StrFilter(&uart_buf[Header]);
84 97
         memset(uart_buf,NULL,cnt);
85 98
         cnt = 0;
99
+        GoodDataStatus = false;
86 100
     }
87 101
 }
88 102
 void Uart1_Data_Send(uint8_t* data,uint8_t size){

+ 76 - 0
insight/STM32F103_WifiAttenCtrlTest.si4project/Backup/esp8266(1154).c

@@ -0,0 +1,76 @@
1
+/*
2
+ * esp8266.c
3
+ *
4
+ *  Created on: Jul 9, 2019
5
+ *      Author: parkyj
6
+ */
7
+
8
+#include <string.h>
9
+#include "esp8266.h"
10
+
11
+
12
+void ESP8266_Initialize(void){
13
+	  volatile static bool init = false;
14
+	  volatile static uint8_t seq = 0;
15
+    uint8_t str[100] = {0,};
16
+	  if(init == false ||  seq < 4){
17
+		  init = true;
18
+	  }else{
19
+	  /* * * * *DATA SEND COMMADN * * * * * */
20
+#if 0 // PYJ.2019.08.06_BEGIN --
21
+    Uart2_Data_Send("AT+CIPSEND=0,4\r\n",ESP8266_Strindex("AT+CIPSEND=0,4\r\n"));
22
+    HAL_Delay(1000);
23
+    sprintf(str,"%d", ADC_Value_RetFunc());
24
+    Uart2_Data_Send(str,ESP8266_Strindex(str));
25
+    printf("%s\r\n INDEX : %d",str,ESP8266_Strindex(str));
26
+    HAL_Delay(500);
27
+//          Uart2_Data_Send("be\r\n",ESP8266_Strindex("123456789\r\n"));
28
+          
29
+#endif // PYJ.2019.08.06_END -- 
30
+//          Uart2_Data_Send("AT+CIPSEND=1,1\r\n",ESP8266_Strindex("AT+CIPSEND=1,1\r\n"));
31
+//          HAL_Delay(5); 
32
+//          Uart2_Data_Send("1\r\n",ESP8266_Strindex("1\r\n"));              
33
+        return;
34
+	  }
35
+#if 1 // PYJ.2019.12.13_BEGIN -- 
36
+	  switch(seq){
37
+    	  case 0:
38
+              Uart2_Data_Send("AT+CWMODE=3\r\n",ESP8266_Strindex("AT+CWMODE=3\r\n"));
39
+    		  seq++;
40
+    		  break;
41
+    	  case 1:
42
+              Uart2_Data_Send("AT+CIPMUX=1\r\n",ESP8266_Strindex("AT+CIPMUX=1\r\n"));
43
+    		  seq++;
44
+    		  break;
45
+    	  case 2:
46
+              Uart2_Data_Send("AT+CWSAP=\"BLUE_TEST\",\"\",5,0\r\n",ESP8266_Strindex("AT+CWSAP=\"BLUE_TEST\",\"\",5,0\r\n"));
47
+    		  seq++;
48
+    		  break;
49
+    	  case 3:
50
+              Uart2_Data_Send("AT+CIPSERVER=1,4000\r\n",ESP8266_Strindex("AT+CIPSERVER=1,4000\r\n"));
51
+              HAL_Delay(5);
52
+              Uart2_Data_Send("AT+CIFSR\r\n",ESP8266_Strindex("AT+CIFSR\r\n"));
53
+    		  printf("ESP Setting Complete \r\n");
54
+    		  seq++;
55
+    		  break;
56
+    	  default:
57
+    		  break;
58
+	  }
59
+#endif // PYJ.2019.12.13_END -- 
60
+
61
+}
62
+uint8_t ESP8266_Strindex(uint8_t* str){
63
+    return strlen(str);
64
+}
65
+uint8_t ESP8266_StrFilter(uint8_t* str){
66
+    char *ptr = strstr(str, ":");      // den으로 시작하는 문자열 검색, 포인터 반환
67
+    
68
+    //printf("first : %s\n", ptr);    // den Diary
69
+    
70
+    printf("\r\nResult : ");
71
+    for(int i = 0; i < ESP8266_Strindex(ptr); i++)
72
+        printf("%d", *(ptr + i));    // den Diary
73
+
74
+    printf("\r\n");
75
+
76
+}

+ 99 - 0
insight/STM32F103_WifiAttenCtrlTest.si4project/Backup/esp8266(1956).c

@@ -0,0 +1,99 @@
1
+/*
2
+ * esp8266.c
3
+ *
4
+ *  Created on: Jul 9, 2019
5
+ *      Author: parkyj
6
+ */
7
+
8
+#include <string.h>
9
+#include <stdlib.h>
10
+#include "esp8266.h"
11
+
12
+
13
+void ESP8266_Initialize(void){
14
+	  volatile static bool init = false;
15
+	  volatile static uint8_t seq = 0;
16
+    uint8_t str[100] = {0,};
17
+	  if(init == false ||  seq < 4){
18
+		  init = true;
19
+	  }else{
20
+	  /* * * * *DATA SEND COMMADN * * * * * */
21
+#if 0 // PYJ.2019.08.06_BEGIN --
22
+    Uart2_Data_Send("AT+CIPSEND=0,4\r\n",ESP8266_Strindex("AT+CIPSEND=0,4\r\n"));
23
+    HAL_Delay(1000);
24
+    sprintf(str,"%d", ADC_Value_RetFunc());
25
+    Uart2_Data_Send(str,ESP8266_Strindex(str));
26
+    printf("%s\r\n INDEX : %d",str,ESP8266_Strindex(str));
27
+    HAL_Delay(500);
28
+//          Uart2_Data_Send("be\r\n",ESP8266_Strindex("123456789\r\n"));
29
+          
30
+#endif // PYJ.2019.08.06_END -- 
31
+//          Uart2_Data_Send("AT+CIPSEND=1,1\r\n",ESP8266_Strindex("AT+CIPSEND=1,1\r\n"));
32
+//          HAL_Delay(5); 
33
+//          Uart2_Data_Send("1\r\n",ESP8266_Strindex("1\r\n"));              
34
+        return;
35
+	  }
36
+#if 1 // PYJ.2019.12.13_BEGIN -- 
37
+	  switch(seq){
38
+    	  case 0:
39
+              Uart2_Data_Send("AT+CWMODE=3\r\n",ESP8266_StrLength("AT+CWMODE=3\r\n"));
40
+    		  seq++;
41
+    		  break;
42
+    	  case 1:
43
+              Uart2_Data_Send("AT+CIPMUX=1\r\n",ESP8266_StrLength("AT+CIPMUX=1\r\n"));
44
+    		  seq++;
45
+    		  break;
46
+    	  case 2:
47
+              Uart2_Data_Send("AT+CWSAP=\"BLUE_TEST\",\"\",5,0\r\n",ESP8266_StrLength("AT+CWSAP=\"BLUE_TEST\",\"\",5,0\r\n"));
48
+    		  seq++;
49
+    		  break;
50
+    	  case 3:
51
+              Uart2_Data_Send("AT+CIPSERVER=1,4000\r\n",ESP8266_StrLength("AT+CIPSERVER=1,4000\r\n"));
52
+              HAL_Delay(5);
53
+              Uart2_Data_Send("AT+CIFSR\r\n",ESP8266_StrLength("AT+CIFSR\r\n"));
54
+    		  printf("ESP Setting Complete \r\n");
55
+    		  seq++;
56
+    		  break;
57
+    	  default:
58
+    		  break;
59
+	  }
60
+#endif // PYJ.2019.12.13_END -- 
61
+
62
+}
63
+uint8_t ESP8266_StrLength(uint8_t* str){
64
+    return strlen(str);
65
+}
66
+uint8_t ESP8266_StrIndexSearch(uint8_t* str,uint8_t* searchstr){
67
+    for(int i = 0; i < ESP8266_StrLength(str); i++){
68
+        if(*(str + i) == *searchstr){
69
+//            printf("\"%s \" index : %d \r\n",*searchstr, i);
70
+            return i;
71
+        }
72
+    }
73
+    return 0;
74
+}
75
+uint8_t ESP8266_StrFilter(uint8_t* str){
76
+    uint8_t *ptr = strstr(str, "+IPD,0,");      // den으로 시작하는 문자열 검색, 포인터 반환
77
+    uint8_t temp_index;
78
+    uint8_t temp_length;
79
+    uint8_t temp_str[5] = {NULL,};
80
+    //printf("first : %s\n", ptr);    // den Diary
81
+    if(strstr(ptr, "+IPD,0,") != NULL){
82
+        temp_index= ESP8266_StrIndexSearch(ptr,":"); 
83
+        temp_str[0] = ptr[temp_index - 2];
84
+        temp_str[1] = ptr[temp_index - 1];
85
+    
86
+        temp_length = atoi(temp_str);
87
+//        temp_length += atoi(ptr[temp_index - 1]);
88
+//        printf("(+IPD,0,)Length%d \r\n",ESP8266_StrLength("+IPD,0,"));
89
+//        printf("Length Result : %d \r\n",temp_length);
90
+        if(ptr != NULL){
91
+            printf("\r\n %d Result : ",ESP8266_StrLength(ptr));
92
+            for(int i = (temp_index + 1); i < temp_length + (temp_index + 1) + 9; i++)
93
+                printf("%d ", *(ptr + i));    // den Diary
94
+            printf("\r\n");
95
+        }
96
+    }
97
+
98
+
99
+}

+ 17 - 0
insight/STM32F103_WifiAttenCtrlTest.si4project/Backup/esp8266(6222).h

@@ -0,0 +1,17 @@
1
+/*
2
+ * esp8266.h
3
+ *
4
+ *  Created on: Jul 9, 2019
5
+ *      Author: parkyj
6
+ */
7
+
8
+#ifndef ESP8266_H_
9
+#define ESP8266_H_
10
+
11
+#include "main.h"
12
+
13
+uint8_t ESP8266_Strindex(uint8_t* str);
14
+void ESP8266_Initialize(void);
15
+uint8_t ESP8266_StrFilter(uint8_t* str);
16
+
17
+#endif /* ESP8266_H_ */

+ 655 - 0
insight/STM32F103_WifiAttenCtrlTest.si4project/Backup/main(1134).c

@@ -0,0 +1,655 @@
1
+/* USER CODE BEGIN Header */
2
+/**
3
+  ******************************************************************************
4
+  * @file           : main.c
5
+  * @brief          : Main program body
6
+  ******************************************************************************
7
+  * @attention
8
+  *
9
+  * <h2><center>&copy; Copyright (c) 2019 STMicroelectronics.
10
+  * All rights reserved.</center></h2>
11
+  *
12
+  * This software component is licensed by ST under BSD 3-Clause license,
13
+  * the "License"; You may not use this file except in compliance with the
14
+  * License. You may obtain a copy of the License at:
15
+  *                        opensource.org/licenses/BSD-3-Clause
16
+  *
17
+  ******************************************************************************
18
+  */
19
+/* USER CODE END Header */
20
+
21
+/* Includes ------------------------------------------------------------------*/
22
+#include <stdio.h>
23
+#include <string.h>
24
+#include "main.h"
25
+
26
+/* Private includes ----------------------------------------------------------*/
27
+/* USER CODE BEGIN Includes */
28
+
29
+/* USER CODE END Includes */
30
+
31
+/* Private typedef -----------------------------------------------------------*/
32
+/* USER CODE BEGIN PTD */
33
+
34
+/* USER CODE END PTD */
35
+
36
+/* Private define ------------------------------------------------------------*/
37
+/* USER CODE BEGIN PD */
38
+
39
+/* USER CODE END PD */
40
+
41
+/* Private macro -------------------------------------------------------------*/
42
+/* USER CODE BEGIN PM */
43
+
44
+/* USER CODE END PM */
45
+
46
+/* Private variables ---------------------------------------------------------*/
47
+ADC_HandleTypeDef hadc1;
48
+ADC_HandleTypeDef hadc2;
49
+ADC_HandleTypeDef hadc3;
50
+DMA_HandleTypeDef hdma_adc1;
51
+
52
+TIM_HandleTypeDef htim6;
53
+
54
+UART_HandleTypeDef huart4;
55
+UART_HandleTypeDef huart1;
56
+UART_HandleTypeDef huart2;
57
+DMA_HandleTypeDef hdma_usart1_rx;
58
+DMA_HandleTypeDef hdma_usart1_tx;
59
+DMA_HandleTypeDef hdma_usart2_rx;
60
+DMA_HandleTypeDef hdma_usart2_tx;
61
+
62
+/* USER CODE BEGIN PV */
63
+volatile uint32_t UartTimerCnt = 0;
64
+volatile uint32_t LedTimerCnt = 0;
65
+volatile uint32_t InitTimerCnt = 0;
66
+volatile uint32_t AdcTimerCnt = 0;
67
+/* USER CODE END PV */
68
+
69
+/* Private function prototypes -----------------------------------------------*/
70
+void SystemClock_Config(void);
71
+static void MX_GPIO_Init(void);
72
+static void MX_DMA_Init(void);
73
+static void MX_ADC1_Init(void);
74
+static void MX_ADC2_Init(void);
75
+static void MX_ADC3_Init(void);
76
+static void MX_TIM6_Init(void);
77
+static void MX_USART1_UART_Init(void);
78
+static void MX_USART2_UART_Init(void);
79
+static void MX_UART4_Init(void);
80
+static void MX_NVIC_Init(void);
81
+/* USER CODE BEGIN PFP */
82
+
83
+/* USER CODE END PFP */
84
+
85
+/* Private user code ---------------------------------------------------------*/
86
+/* USER CODE BEGIN 0 */
87
+void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
88
+{
89
+
90
+    if(htim->Instance == TIM6){
91
+        UartTimerCnt++;
92
+        LedTimerCnt++;
93
+        InitTimerCnt++;
94
+        AdcTimerCnt++;
95
+    }
96
+}
97
+int _write (int file, uint8_t *ptr, uint16_t len)
98
+{
99
+    HAL_UART_Transmit (&huart1, ptr, len, 10);
100
+    return len;
101
+}
102
+uint16_t ADC_Value_RetFunc(void){
103
+  return ADCvalue[0];
104
+}
105
+extern UARTQUEUE TerminalQueue;
106
+uint32_t ADCvalue[ADC_EA];
107
+/* USER CODE END 0 */
108
+
109
+/**
110
+  * @brief  The application entry point.
111
+  * @retval int
112
+  */
113
+int main(void)
114
+{
115
+  /* USER CODE BEGIN 1 */
116
+	uint8_t tempdata[] = {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A};
117
+  /* USER CODE END 1 */
118
+  
119
+
120
+  /* MCU Configuration--------------------------------------------------------*/
121
+
122
+  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
123
+  HAL_Init();
124
+
125
+  /* USER CODE BEGIN Init */
126
+
127
+  /* USER CODE END Init */
128
+
129
+  /* Configure the system clock */
130
+  SystemClock_Config();
131
+
132
+  /* USER CODE BEGIN SysInit */
133
+
134
+  /* USER CODE END SysInit */
135
+
136
+  /* Initialize all configured peripherals */
137
+  MX_GPIO_Init();
138
+  MX_DMA_Init();
139
+  MX_ADC1_Init();
140
+  MX_ADC2_Init();
141
+  MX_ADC3_Init();
142
+  MX_TIM6_Init();
143
+  MX_USART1_UART_Init();
144
+  MX_USART2_UART_Init();
145
+  MX_UART4_Init();
146
+
147
+  /* Initialize interrupts */
148
+  MX_NVIC_Init();
149
+  /* USER CODE BEGIN 2 */
150
+  HAL_TIM_Base_Start_IT(&htim6);
151
+  setbuf(stdout, NULL);
152
+  printf("Uart Start \r\n");
153
+  printf("Crc generate %x \r\n",CRC16_Generate(tempdata,11));
154
+  InitUartQueue(&hTerminal,&TerminalQueue);
155
+  InitUartQueue(&hWifi,&WifiQueue);
156
+
157
+  double temp_tmp = 3.3/4095;
158
+  uint16_t temp_val = 0;
159
+  HAL_ADC_Start_DMA(&hadc1, (uint32_t*)ADCvalue, 1);
160
+  /* USER CODE END 2 */
161
+
162
+  /* Infinite loop */
163
+  /* USER CODE BEGIN WHILE */
164
+  while (1)
165
+  {
166
+	  if(LedTimerCnt > 500){
167
+		  HAL_GPIO_TogglePin(LED_UL_G_B_GPIO_Port,LED_UL_G_B_Pin);
168
+		  LedTimerCnt = 0;
169
+	  }
170
+	  if(InitTimerCnt >1000){
171
+		  ESP8266_Initialize();
172
+		  InitTimerCnt = 0;
173
+	  }
174
+	  if(AdcTimerCnt > 3000){
175
+//		  temp_val = ((ADCvalue[0] & 0xFF00)) | (ADCvalue[0] & 0x00FF);
176
+	      temp_val = ADCvalue[0];
177
+//          printf("\r\n");
178
+//	      printf("ADC Vale : %d \r\n",temp_val);
179
+//	      printf("ADC Vale : %f \r\n",temp_tmp * temp_val);
180
+	      AdcTimerCnt = 0;
181
+	  }
182
+	   while (TerminalQueue.data > 0) GetDataFromUartQueue(&hTerminal);
183
+	   while (WifiQueue.data > 0) GetDataFromUartQueue(&hWifi);
184
+       HAL_Delay(1);
185
+    /* USER CODE END WHILE */
186
+
187
+    /* USER CODE BEGIN 3 */
188
+  }
189
+  /* USER CODE END 3 */
190
+}
191
+
192
+/**
193
+  * @brief System Clock Configuration
194
+  * @retval None
195
+  */
196
+void SystemClock_Config(void)
197
+{
198
+  RCC_OscInitTypeDef RCC_OscInitStruct = {0};
199
+  RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
200
+  RCC_PeriphCLKInitTypeDef PeriphClkInit = {0};
201
+
202
+  /** Initializes the CPU, AHB and APB busses clocks 
203
+  */
204
+  RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
205
+  RCC_OscInitStruct.HSIState = RCC_HSI_ON;
206
+  RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
207
+  RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
208
+  RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI_DIV2;
209
+  RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL16;
210
+  if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
211
+  {
212
+    Error_Handler();
213
+  }
214
+  /** Initializes the CPU, AHB and APB busses clocks 
215
+  */
216
+  RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
217
+                              |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
218
+  RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
219
+  RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
220
+  RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
221
+  RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
222
+
223
+  if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK)
224
+  {
225
+    Error_Handler();
226
+  }
227
+  PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_ADC;
228
+  PeriphClkInit.AdcClockSelection = RCC_ADCPCLK2_DIV6;
229
+  if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)
230
+  {
231
+    Error_Handler();
232
+  }
233
+}
234
+
235
+/**
236
+  * @brief NVIC Configuration.
237
+  * @retval None
238
+  */
239
+static void MX_NVIC_Init(void)
240
+{
241
+  /* DMA1_Channel6_IRQn interrupt configuration */
242
+  HAL_NVIC_SetPriority(DMA1_Channel6_IRQn, 0, 0);
243
+  HAL_NVIC_EnableIRQ(DMA1_Channel6_IRQn);
244
+  /* DMA1_Channel5_IRQn interrupt configuration */
245
+  HAL_NVIC_SetPriority(DMA1_Channel5_IRQn, 0, 0);
246
+  HAL_NVIC_EnableIRQ(DMA1_Channel5_IRQn);
247
+  /* DMA1_Channel4_IRQn interrupt configuration */
248
+  HAL_NVIC_SetPriority(DMA1_Channel4_IRQn, 0, 0);
249
+  HAL_NVIC_EnableIRQ(DMA1_Channel4_IRQn);
250
+  /* DMA1_Channel7_IRQn interrupt configuration */
251
+  HAL_NVIC_SetPriority(DMA1_Channel7_IRQn, 0, 0);
252
+  HAL_NVIC_EnableIRQ(DMA1_Channel7_IRQn);
253
+  /* ADC3_IRQn interrupt configuration */
254
+  HAL_NVIC_SetPriority(ADC3_IRQn, 0, 0);
255
+  HAL_NVIC_EnableIRQ(ADC3_IRQn);
256
+  /* UART4_IRQn interrupt configuration */
257
+  HAL_NVIC_SetPriority(UART4_IRQn, 0, 0);
258
+  HAL_NVIC_EnableIRQ(UART4_IRQn);
259
+  /* TIM6_IRQn interrupt configuration */
260
+  HAL_NVIC_SetPriority(TIM6_IRQn, 0, 0);
261
+  HAL_NVIC_EnableIRQ(TIM6_IRQn);
262
+  /* ADC1_2_IRQn interrupt configuration */
263
+  HAL_NVIC_SetPriority(ADC1_2_IRQn, 0, 0);
264
+  HAL_NVIC_EnableIRQ(ADC1_2_IRQn);
265
+  /* USART1_IRQn interrupt configuration */
266
+  HAL_NVIC_SetPriority(USART1_IRQn, 0, 0);
267
+  HAL_NVIC_EnableIRQ(USART1_IRQn);
268
+  /* USART2_IRQn interrupt configuration */
269
+  HAL_NVIC_SetPriority(USART2_IRQn, 0, 0);
270
+  HAL_NVIC_EnableIRQ(USART2_IRQn);
271
+  /* DMA1_Channel1_IRQn interrupt configuration */
272
+  HAL_NVIC_SetPriority(DMA1_Channel1_IRQn, 0, 0);
273
+  HAL_NVIC_EnableIRQ(DMA1_Channel1_IRQn);
274
+}
275
+
276
+/**
277
+  * @brief ADC1 Initialization Function
278
+  * @param None
279
+  * @retval None
280
+  */
281
+static void MX_ADC1_Init(void)
282
+{
283
+
284
+  /* USER CODE BEGIN ADC1_Init 0 */
285
+
286
+  /* USER CODE END ADC1_Init 0 */
287
+
288
+  ADC_ChannelConfTypeDef sConfig = {0};
289
+
290
+  /* USER CODE BEGIN ADC1_Init 1 */
291
+
292
+  /* USER CODE END ADC1_Init 1 */
293
+  /** Common config 
294
+  */
295
+  hadc1.Instance = ADC1;
296
+  hadc1.Init.ScanConvMode = ADC_SCAN_DISABLE;
297
+  hadc1.Init.ContinuousConvMode = ENABLE;
298
+  hadc1.Init.DiscontinuousConvMode = DISABLE;
299
+  hadc1.Init.ExternalTrigConv = ADC_SOFTWARE_START;
300
+  hadc1.Init.DataAlign = ADC_DATAALIGN_RIGHT;
301
+  hadc1.Init.NbrOfConversion = 1;
302
+  if (HAL_ADC_Init(&hadc1) != HAL_OK)
303
+  {
304
+    Error_Handler();
305
+  }
306
+  /** Configure Regular Channel 
307
+  */
308
+  sConfig.Channel = ADC_CHANNEL_9;
309
+  sConfig.Rank = ADC_REGULAR_RANK_1;
310
+  sConfig.SamplingTime = ADC_SAMPLETIME_239CYCLES_5;
311
+  if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
312
+  {
313
+    Error_Handler();
314
+  }
315
+  /* USER CODE BEGIN ADC1_Init 2 */
316
+
317
+  /* USER CODE END ADC1_Init 2 */
318
+
319
+}
320
+
321
+/**
322
+  * @brief ADC2 Initialization Function
323
+  * @param None
324
+  * @retval None
325
+  */
326
+static void MX_ADC2_Init(void)
327
+{
328
+
329
+  /* USER CODE BEGIN ADC2_Init 0 */
330
+
331
+  /* USER CODE END ADC2_Init 0 */
332
+
333
+  ADC_ChannelConfTypeDef sConfig = {0};
334
+
335
+  /* USER CODE BEGIN ADC2_Init 1 */
336
+
337
+  /* USER CODE END ADC2_Init 1 */
338
+  /** Common config 
339
+  */
340
+  hadc2.Instance = ADC2;
341
+  hadc2.Init.ScanConvMode = ADC_SCAN_DISABLE;
342
+  hadc2.Init.ContinuousConvMode = DISABLE;
343
+  hadc2.Init.DiscontinuousConvMode = DISABLE;
344
+  hadc2.Init.ExternalTrigConv = ADC_SOFTWARE_START;
345
+  hadc2.Init.DataAlign = ADC_DATAALIGN_RIGHT;
346
+  hadc2.Init.NbrOfConversion = 1;
347
+  if (HAL_ADC_Init(&hadc2) != HAL_OK)
348
+  {
349
+    Error_Handler();
350
+  }
351
+  /** Configure Regular Channel 
352
+  */
353
+  sConfig.Channel = ADC_CHANNEL_10;
354
+  sConfig.Rank = ADC_REGULAR_RANK_1;
355
+  sConfig.SamplingTime = ADC_SAMPLETIME_1CYCLE_5;
356
+  if (HAL_ADC_ConfigChannel(&hadc2, &sConfig) != HAL_OK)
357
+  {
358
+    Error_Handler();
359
+  }
360
+  /* USER CODE BEGIN ADC2_Init 2 */
361
+
362
+  /* USER CODE END ADC2_Init 2 */
363
+
364
+}
365
+
366
+/**
367
+  * @brief ADC3 Initialization Function
368
+  * @param None
369
+  * @retval None
370
+  */
371
+static void MX_ADC3_Init(void)
372
+{
373
+
374
+  /* USER CODE BEGIN ADC3_Init 0 */
375
+
376
+  /* USER CODE END ADC3_Init 0 */
377
+
378
+  ADC_ChannelConfTypeDef sConfig = {0};
379
+
380
+  /* USER CODE BEGIN ADC3_Init 1 */
381
+
382
+  /* USER CODE END ADC3_Init 1 */
383
+  /** Common config 
384
+  */
385
+  hadc3.Instance = ADC3;
386
+  hadc3.Init.ScanConvMode = ADC_SCAN_DISABLE;
387
+  hadc3.Init.ContinuousConvMode = DISABLE;
388
+  hadc3.Init.DiscontinuousConvMode = DISABLE;
389
+  hadc3.Init.ExternalTrigConv = ADC_SOFTWARE_START;
390
+  hadc3.Init.DataAlign = ADC_DATAALIGN_RIGHT;
391
+  hadc3.Init.NbrOfConversion = 1;
392
+  if (HAL_ADC_Init(&hadc3) != HAL_OK)
393
+  {
394
+    Error_Handler();
395
+  }
396
+  /** Configure Regular Channel 
397
+  */
398
+  sConfig.Channel = ADC_CHANNEL_11;
399
+  sConfig.Rank = ADC_REGULAR_RANK_1;
400
+  sConfig.SamplingTime = ADC_SAMPLETIME_1CYCLE_5;
401
+  if (HAL_ADC_ConfigChannel(&hadc3, &sConfig) != HAL_OK)
402
+  {
403
+    Error_Handler();
404
+  }
405
+  /* USER CODE BEGIN ADC3_Init 2 */
406
+
407
+  /* USER CODE END ADC3_Init 2 */
408
+
409
+}
410
+
411
+/**
412
+  * @brief TIM6 Initialization Function
413
+  * @param None
414
+  * @retval None
415
+  */
416
+static void MX_TIM6_Init(void)
417
+{
418
+
419
+  /* USER CODE BEGIN TIM6_Init 0 */
420
+
421
+  /* USER CODE END TIM6_Init 0 */
422
+
423
+  TIM_MasterConfigTypeDef sMasterConfig = {0};
424
+
425
+  /* USER CODE BEGIN TIM6_Init 1 */
426
+
427
+  /* USER CODE END TIM6_Init 1 */
428
+  htim6.Instance = TIM6;
429
+  htim6.Init.Prescaler = 6400-1;
430
+  htim6.Init.CounterMode = TIM_COUNTERMODE_UP;
431
+  htim6.Init.Period = 10-1;
432
+  htim6.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
433
+  if (HAL_TIM_Base_Init(&htim6) != HAL_OK)
434
+  {
435
+    Error_Handler();
436
+  }
437
+  sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
438
+  sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
439
+  if (HAL_TIMEx_MasterConfigSynchronization(&htim6, &sMasterConfig) != HAL_OK)
440
+  {
441
+    Error_Handler();
442
+  }
443
+  /* USER CODE BEGIN TIM6_Init 2 */
444
+
445
+  /* USER CODE END TIM6_Init 2 */
446
+
447
+}
448
+
449
+/**
450
+  * @brief UART4 Initialization Function
451
+  * @param None
452
+  * @retval None
453
+  */
454
+static void MX_UART4_Init(void)
455
+{
456
+
457
+  /* USER CODE BEGIN UART4_Init 0 */
458
+
459
+  /* USER CODE END UART4_Init 0 */
460
+
461
+  /* USER CODE BEGIN UART4_Init 1 */
462
+
463
+  /* USER CODE END UART4_Init 1 */
464
+  huart4.Instance = UART4;
465
+  huart4.Init.BaudRate = 115200;
466
+  huart4.Init.WordLength = UART_WORDLENGTH_8B;
467
+  huart4.Init.StopBits = UART_STOPBITS_1;
468
+  huart4.Init.Parity = UART_PARITY_NONE;
469
+  huart4.Init.Mode = UART_MODE_TX_RX;
470
+  huart4.Init.HwFlowCtl = UART_HWCONTROL_NONE;
471
+  huart4.Init.OverSampling = UART_OVERSAMPLING_16;
472
+  if (HAL_UART_Init(&huart4) != HAL_OK)
473
+  {
474
+    Error_Handler();
475
+  }
476
+  /* USER CODE BEGIN UART4_Init 2 */
477
+
478
+  /* USER CODE END UART4_Init 2 */
479
+
480
+}
481
+
482
+/**
483
+  * @brief USART1 Initialization Function
484
+  * @param None
485
+  * @retval None
486
+  */
487
+static void MX_USART1_UART_Init(void)
488
+{
489
+
490
+  /* USER CODE BEGIN USART1_Init 0 */
491
+
492
+  /* USER CODE END USART1_Init 0 */
493
+
494
+  /* USER CODE BEGIN USART1_Init 1 */
495
+
496
+  /* USER CODE END USART1_Init 1 */
497
+  huart1.Instance = USART1;
498
+  huart1.Init.BaudRate = 115200;
499
+  huart1.Init.WordLength = UART_WORDLENGTH_8B;
500
+  huart1.Init.StopBits = UART_STOPBITS_1;
501
+  huart1.Init.Parity = UART_PARITY_NONE;
502
+  huart1.Init.Mode = UART_MODE_TX_RX;
503
+  huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE;
504
+  huart1.Init.OverSampling = UART_OVERSAMPLING_16;
505
+  if (HAL_UART_Init(&huart1) != HAL_OK)
506
+  {
507
+    Error_Handler();
508
+  }
509
+  /* USER CODE BEGIN USART1_Init 2 */
510
+
511
+  /* USER CODE END USART1_Init 2 */
512
+
513
+}
514
+
515
+/**
516
+  * @brief USART2 Initialization Function
517
+  * @param None
518
+  * @retval None
519
+  */
520
+static void MX_USART2_UART_Init(void)
521
+{
522
+
523
+  /* USER CODE BEGIN USART2_Init 0 */
524
+
525
+  /* USER CODE END USART2_Init 0 */
526
+
527
+  /* USER CODE BEGIN USART2_Init 1 */
528
+
529
+  /* USER CODE END USART2_Init 1 */
530
+  huart2.Instance = USART2;
531
+  huart2.Init.BaudRate = 115200;
532
+  huart2.Init.WordLength = UART_WORDLENGTH_8B;
533
+  huart2.Init.StopBits = UART_STOPBITS_1;
534
+  huart2.Init.Parity = UART_PARITY_NONE;
535
+  huart2.Init.Mode = UART_MODE_TX_RX;
536
+  huart2.Init.HwFlowCtl = UART_HWCONTROL_NONE;
537
+  huart2.Init.OverSampling = UART_OVERSAMPLING_16;
538
+  if (HAL_UART_Init(&huart2) != HAL_OK)
539
+  {
540
+    Error_Handler();
541
+  }
542
+  /* USER CODE BEGIN USART2_Init 2 */
543
+
544
+  /* USER CODE END USART2_Init 2 */
545
+
546
+}
547
+
548
+/** 
549
+  * Enable DMA controller clock
550
+  */
551
+static void MX_DMA_Init(void) 
552
+{
553
+
554
+  /* DMA controller clock enable */
555
+  __HAL_RCC_DMA1_CLK_ENABLE();
556
+
557
+}
558
+
559
+/**
560
+  * @brief GPIO Initialization Function
561
+  * @param None
562
+  * @retval None
563
+  */
564
+static void MX_GPIO_Init(void)
565
+{
566
+  GPIO_InitTypeDef GPIO_InitStruct = {0};
567
+
568
+  /* GPIO Ports Clock Enable */
569
+  __HAL_RCC_GPIOC_CLK_ENABLE();
570
+  __HAL_RCC_GPIOA_CLK_ENABLE();
571
+  __HAL_RCC_GPIOB_CLK_ENABLE();
572
+  __HAL_RCC_GPIOD_CLK_ENABLE();
573
+
574
+  /*Configure GPIO pin Output Level */
575
+  HAL_GPIO_WritePin(GPIOC, BOOT_LED_Pin|PLL_LD_B_Pin|PLL_EN_B_Pin, GPIO_PIN_RESET);
576
+
577
+  /*Configure GPIO pin Output Level */
578
+  HAL_GPIO_WritePin(GPIOA, LED_UL_G_B_Pin|LED_SD_R_B_Pin|PWR_LED_B_Pin|LED_DL_G_B_Pin 
579
+                          |LED_DL_R_B_Pin|ATT_DATA_B_Pin|ATT_EN1_B_Pin|ATT_EN2_B_Pin, GPIO_PIN_RESET);
580
+
581
+  /*Configure GPIO pin Output Level */
582
+  HAL_GPIO_WritePin(GPIOB, RST_WIFI_B_Pin|PA_EN_B_Pin|EXT_PA_EN_B_Pin|PLL_CLK_B_Pin 
583
+                          |PLL_DATA_B_Pin, GPIO_PIN_RESET);
584
+
585
+  /*Configure GPIO pin Output Level */
586
+  HAL_GPIO_WritePin(ATT_CLK_B_GPIO_Port, ATT_CLK_B_Pin, GPIO_PIN_RESET);
587
+
588
+  /*Configure GPIO pins : BOOT_LED_Pin PLL_LD_B_Pin PLL_EN_B_Pin */
589
+  GPIO_InitStruct.Pin = BOOT_LED_Pin|PLL_LD_B_Pin|PLL_EN_B_Pin;
590
+  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
591
+  GPIO_InitStruct.Pull = GPIO_NOPULL;
592
+  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
593
+  HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
594
+
595
+  /*Configure GPIO pins : LED_UL_G_B_Pin LED_SD_R_B_Pin PWR_LED_B_Pin LED_DL_G_B_Pin 
596
+                           LED_DL_R_B_Pin ATT_DATA_B_Pin ATT_EN1_B_Pin ATT_EN2_B_Pin */
597
+  GPIO_InitStruct.Pin = LED_UL_G_B_Pin|LED_SD_R_B_Pin|PWR_LED_B_Pin|LED_DL_G_B_Pin 
598
+                          |LED_DL_R_B_Pin|ATT_DATA_B_Pin|ATT_EN1_B_Pin|ATT_EN2_B_Pin;
599
+  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
600
+  GPIO_InitStruct.Pull = GPIO_NOPULL;
601
+  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
602
+  HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
603
+
604
+  /*Configure GPIO pins : RST_WIFI_B_Pin PA_EN_B_Pin EXT_PA_EN_B_Pin PLL_CLK_B_Pin 
605
+                           PLL_DATA_B_Pin */
606
+  GPIO_InitStruct.Pin = RST_WIFI_B_Pin|PA_EN_B_Pin|EXT_PA_EN_B_Pin|PLL_CLK_B_Pin 
607
+                          |PLL_DATA_B_Pin;
608
+  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
609
+  GPIO_InitStruct.Pull = GPIO_NOPULL;
610
+  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
611
+  HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
612
+
613
+  /*Configure GPIO pin : ATT_CLK_B_Pin */
614
+  GPIO_InitStruct.Pin = ATT_CLK_B_Pin;
615
+  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
616
+  GPIO_InitStruct.Pull = GPIO_NOPULL;
617
+  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
618
+  HAL_GPIO_Init(ATT_CLK_B_GPIO_Port, &GPIO_InitStruct);
619
+
620
+}
621
+
622
+/* USER CODE BEGIN 4 */
623
+
624
+/* USER CODE END 4 */
625
+
626
+/**
627
+  * @brief  This function is executed in case of error occurrence.
628
+  * @retval None
629
+  */
630
+void Error_Handler(void)
631
+{
632
+  /* USER CODE BEGIN Error_Handler_Debug */
633
+  /* User can add his own implementation to report the HAL error return state */
634
+
635
+  /* USER CODE END Error_Handler_Debug */
636
+}
637
+
638
+#ifdef  USE_FULL_ASSERT
639
+/**
640
+  * @brief  Reports the name of the source file and the source line number
641
+  *         where the assert_param error has occurred.
642
+  * @param  file: pointer to the source file name
643
+  * @param  line: assert_param error line source number
644
+  * @retval None
645
+  */
646
+void assert_failed(uint8_t *file, uint32_t line)
647
+{ 
648
+  /* USER CODE BEGIN 6 */
649
+  /* User can add his own implementation to report the file name and line number,
650
+     tex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
651
+  /* USER CODE END 6 */
652
+}
653
+#endif /* USE_FULL_ASSERT */
654
+
655
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

+ 95 - 0
insight/STM32F103_WifiAttenCtrlTest.si4project/Backup/uart(6080).c

@@ -0,0 +1,95 @@
1
+/*
2
+ * uart.c
3
+ *
4
+ *  Created on: 2019. 5. 27.
5
+ *      Author: parkyj
6
+ */
7
+
8
+#include "uart.h"
9
+
10
+UARTQUEUE TerminalQueue;
11
+UARTQUEUE WifiQueue;
12
+void InitUartQueue(UART_HandleTypeDef *huart,pUARTQUEUE pQueue)
13
+{
14
+    UART_HandleTypeDef *dst = (huart->Instance == USART2 ? &hWifi:&hTerminal);
15
+    pQueue->data = pQueue->head = pQueue->tail = 0;
16
+
17
+    if (HAL_UART_Receive_DMA(dst, pQueue->Buffer, 1) != HAL_OK)
18
+    {
19
+//      _Error_Handler(__FILE__, __LINE__);
20
+    }
21
+    //HAL_UART_Receive_DMA(&hTerminal,  TerminalQueue.Buffer, 1);
22
+    //HAL_UART_Receive_IT(hTerminal, pQueue->Buffer + pQueue->head, 1);
23
+}
24
+void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
25
+{
26
+    pUARTQUEUE pQueue = (huart->Instance == USART2 ? &WifiQueue:&TerminalQueue);
27
+    UART_HandleTypeDef *dst = (huart->Instance == USART2 ? &hWifi:&hTerminal);
28
+
29
+    pQueue->head++;
30
+    if (pQueue->head >= QUEUE_BUFFER_LENGTH) pQueue->head = 0;
31
+    pQueue->data++;
32
+    if (pQueue->data >= QUEUE_BUFFER_LENGTH)
33
+        GetDataFromUartQueue(huart);
34
+    HAL_UART_Receive_DMA(dst, pQueue->Buffer + pQueue->head, 1);
35
+   // Set_UartRcv(true);
36
+}
37
+void PutDataToUartQueue(UART_HandleTypeDef *huart, uint8_t data)
38
+{
39
+    pUARTQUEUE pQueue = (huart->Instance == USART2 ? &WifiQueue:&TerminalQueue);
40
+    if (pQueue->data >= QUEUE_BUFFER_LENGTH)
41
+        GetDataFromUartQueue(huart);
42
+    pQueue->Buffer[pQueue->head++] = data;
43
+    if (pQueue->head == QUEUE_BUFFER_LENGTH) pQueue->head = 0;
44
+    pQueue->data++;
45
+   // HAL_UART_Receive_DMA(&hTerminal,  pQueue->Buffer + pQueue->head, 10);
46
+}
47
+typedef enum{
48
+    Header = 0,
49
+    Type,
50
+    Length,
51
+    Crcindex,
52
+}Bluecell_Prot_p;
53
+
54
+uint8_t uart_buf[QUEUE_BUFFER_LENGTH];
55
+
56
+void GetDataFromUartQueue(UART_HandleTypeDef *huart)
57
+{
58
+    UART_HandleTypeDef *dst = (huart->Instance == USART2 ? &hWifi:&hTerminal);
59
+    pUARTQUEUE pQueue = (huart->Instance == USART2 ? &WifiQueue:&TerminalQueue);
60
+    volatile static int cnt;
61
+#if 0 // PYJ.2019.12.13_BEGIN -- 
62
+if(huart->Instance == USART1){
63
+    HAL_UART_Transmit_DMA(&hWifi, pQueue->Buffer + pQueue->tail, 1);
64
+}else{
65
+    printf("%c",*(pQueue->Buffer + pQueue->tail));
66
+}
67
+#endif // PYJ.2019.12.13_END -- 
68
+    printf("%c",*(pQueue->Buffer + pQueue->tail));
69
+    uart_buf[cnt++] = *(pQueue->Buffer + pQueue->tail); 
70
+    
71
+
72
+//    printf("Function : %s : ",__func__);
73
+//    if (HAL_UART_Transmit_DMA(dst, pQueue->Buffer + pQueue->tail, 1) != HAL_OK)
74
+    //if (HAL_UART_Transmit_DMA(&hTerminal, pQueue->Buffer + pQueue->tail, 1) != HAL_OK)
75
+    //{
76
+//       _Error_Handler(__FILE__, __LINE__);
77
+    //}
78
+//    printf("\r\n");
79
+    pQueue->tail++;
80
+    if (pQueue->tail >= QUEUE_BUFFER_LENGTH) pQueue->tail = 0;
81
+    pQueue->data--;
82
+    if(pQueue->data == 0){
83
+        ESP8266_StrFilter(&uart_buf[Header]);
84
+        memset(uart_buf,NULL,cnt);
85
+        cnt = 0;
86
+    }
87
+}
88
+void Uart1_Data_Send(uint8_t* data,uint8_t size){
89
+    HAL_UART_Transmit_DMA(&huart1, data,size); 
90
+}
91
+void Uart2_Data_Send(uint8_t* data,uint8_t size){
92
+    HAL_UART_Transmit_DMA(&huart2, data,size); 
93
+}
94
+
95
+

+ 95 - 0
insight/STM32F103_WifiAttenCtrlTest.si4project/Backup/uart(6947).c

@@ -0,0 +1,95 @@
1
+/*
2
+ * uart.c
3
+ *
4
+ *  Created on: 2019. 5. 27.
5
+ *      Author: parkyj
6
+ */
7
+
8
+#include "uart.h"
9
+
10
+UARTQUEUE TerminalQueue;
11
+UARTQUEUE WifiQueue;
12
+void InitUartQueue(UART_HandleTypeDef *huart,pUARTQUEUE pQueue)
13
+{
14
+    UART_HandleTypeDef *dst = (huart->Instance == USART2 ? &hWifi:&hTerminal);
15
+    pQueue->data = pQueue->head = pQueue->tail = 0;
16
+
17
+    if (HAL_UART_Receive_DMA(dst, pQueue->Buffer, 1) != HAL_OK)
18
+    {
19
+//      _Error_Handler(__FILE__, __LINE__);
20
+    }
21
+    //HAL_UART_Receive_DMA(&hTerminal,  TerminalQueue.Buffer, 1);
22
+    //HAL_UART_Receive_IT(hTerminal, pQueue->Buffer + pQueue->head, 1);
23
+}
24
+void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
25
+{
26
+    pUARTQUEUE pQueue = (huart->Instance == USART2 ? &WifiQueue:&TerminalQueue);
27
+    UART_HandleTypeDef *dst = (huart->Instance == USART2 ? &hWifi:&hTerminal);
28
+
29
+    pQueue->head++;
30
+    if (pQueue->head >= QUEUE_BUFFER_LENGTH) pQueue->head = 0;
31
+    pQueue->data++;
32
+    if (pQueue->data >= QUEUE_BUFFER_LENGTH)
33
+        GetDataFromUartQueue(huart);
34
+    HAL_UART_Receive_DMA(dst, pQueue->Buffer + pQueue->head, 1);
35
+   // Set_UartRcv(true);
36
+}
37
+void PutDataToUartQueue(UART_HandleTypeDef *huart, uint8_t data)
38
+{
39
+    pUARTQUEUE pQueue = (huart->Instance == USART2 ? &WifiQueue:&TerminalQueue);
40
+    if (pQueue->data >= QUEUE_BUFFER_LENGTH)
41
+        GetDataFromUartQueue(huart);
42
+    pQueue->Buffer[pQueue->head++] = data;
43
+    if (pQueue->head == QUEUE_BUFFER_LENGTH) pQueue->head = 0;
44
+    pQueue->data++;
45
+   // HAL_UART_Receive_DMA(&hTerminal,  pQueue->Buffer + pQueue->head, 10);
46
+}
47
+typedef enum{
48
+    Header = 0,
49
+    Type,
50
+    Length,
51
+    Crcindex,
52
+}Bluecell_Prot_p;
53
+
54
+uint8_t uart_buf[QUEUE_BUFFER_LENGTH];
55
+
56
+void GetDataFromUartQueue(UART_HandleTypeDef *huart)
57
+{
58
+    UART_HandleTypeDef *dst = (huart->Instance == USART2 ? &hWifi:&hTerminal);
59
+    pUARTQUEUE pQueue = (huart->Instance == USART2 ? &WifiQueue:&TerminalQueue);
60
+    volatile static int cnt;
61
+#if 0 // PYJ.2019.12.13_BEGIN -- 
62
+if(huart->Instance == USART1){
63
+    HAL_UART_Transmit_DMA(&hWifi, pQueue->Buffer + pQueue->tail, 1);
64
+}else{
65
+    printf("%c",*(pQueue->Buffer + pQueue->tail));
66
+}
67
+#endif // PYJ.2019.12.13_END -- 
68
+    printf("%c",*(pQueue->Buffer + pQueue->tail));
69
+    uart_buf[cnt++] = *(pQueue->Buffer + pQueue->tail); 
70
+    
71
+
72
+//    printf("Function : %s : ",__func__);
73
+//    if (HAL_UART_Transmit_DMA(dst, pQueue->Buffer + pQueue->tail, 1) != HAL_OK)
74
+    //if (HAL_UART_Transmit_DMA(&hTerminal, pQueue->Buffer + pQueue->tail, 1) != HAL_OK)
75
+    //{
76
+//       _Error_Handler(__FILE__, __LINE__);
77
+    //}
78
+//    printf("\r\n");
79
+    pQueue->tail++;
80
+    if (pQueue->tail >= QUEUE_BUFFER_LENGTH) pQueue->tail = 0;
81
+    pQueue->data--;
82
+    if(pQueue->data == 0){
83
+        ESP8266_StrFilter(&uart_buf[Header]);
84
+        memset(uart_buf,NULL,cnt);
85
+        cnt = 0;
86
+    }
87
+}
88
+void Uart1_Data_Send(uint8_t* data,uint8_t size){
89
+    HAL_UART_Transmit_DMA(&huart1, data,size); 
90
+}
91
+void Uart2_Data_Send(uint8_t* data,uint8_t size){
92
+    HAL_UART_Transmit_DMA(&huart2, data,size); 
93
+}
94
+
95
+

+ 37 - 0
insight/STM32F103_WifiAttenCtrlTest.si4project/Backup/uart(905).h

@@ -0,0 +1,37 @@
1
+/*
2
+ * uart.h
3
+ *
4
+ *  Created on: 2019. 5. 27.
5
+ *      Author: parkyj
6
+ */
7
+
8
+#ifndef UART_H_
9
+#define UART_H_
10
+
11
+#include "main.h"
12
+
13
+#define hTerminal    huart1
14
+#define hWifi        huart2
15
+
16
+#define QUEUE_BUFFER_LENGTH 1024
17
+
18
+typedef struct
19
+{
20
+    int head, tail, data;
21
+    uint8_t Buffer[QUEUE_BUFFER_LENGTH];
22
+}UARTQUEUE, *pUARTQUEUE;
23
+
24
+extern UART_HandleTypeDef huart1;
25
+extern UART_HandleTypeDef huart2;
26
+extern UART_HandleTypeDef huart3;
27
+
28
+
29
+extern UARTQUEUE TerminalQueue;
30
+extern UARTQUEUE WifiQueue;
31
+void PutDataToUartQueue(UART_HandleTypeDef *huart, uint8_t data);
32
+void InitUartQueue(UART_HandleTypeDef *huart,pUARTQUEUE pQueue);
33
+void GetDataFromUartQueue(UART_HandleTypeDef *huart);
34
+bool Get_UartRcv(void);
35
+void Set_UartRcv(bool);
36
+
37
+#endif /* UART_H_ */

二進制
insight/STM32F103_WifiAttenCtrlTest.si4project/STM32F103_WifiAttenCtrlTest.sip_sym


二進制
insight/STM32F103_WifiAttenCtrlTest.si4project/STM32F103_WifiAttenCtrlTest.siwork


二進制
insight/STM32F103_WifiAttenCtrlTest.si4project/cache/parse/.._Drivers_STM32F1xx_HAL_Driver_Src_stm32f1xx_hal_uart.c.sisc


二進制
insight/STM32F103_WifiAttenCtrlTest.si4project/cache/parse/.._Inc_esp8266.h.sisc


二進制
insight/STM32F103_WifiAttenCtrlTest.si4project/cache/parse/.._Inc_uart.h.sisc


二進制
insight/STM32F103_WifiAttenCtrlTest.si4project/cache/parse/.._Src_esp8266.c.sisc


二進制
insight/STM32F103_WifiAttenCtrlTest.si4project/cache/parse/.._Src_main.c.sisc


二進制
insight/STM32F103_WifiAttenCtrlTest.si4project/cache/parse/.._Src_uart.c.sisc