瀏覽代碼

SelfTest On OFF 기능 추가 / PE43711 Data To HEX Convert Function 기능 완성

PYJ 5 年之前
父節點
當前提交
d938d45a26
共有 4 個文件被更改,包括 62 次插入15 次删除
  1. 2 2
      .settings/language.settings.xml
  2. 2 1
      Bluecell_Inc/PE43711.h
  3. 42 4
      Bluecell_Src/Bluecell_operate.c
  4. 16 8
      Bluecell_Src/PE43711.c

+ 2 - 2
.settings/language.settings.xml

@@ -4,7 +4,7 @@
4
 		<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
4
 		<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
5
 			<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
5
 			<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
6
 			<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
6
 			<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
7
-			<provider class="com.atollic.truestudio.mbs.GCCSpecsDetectorAtollicArm" console="false" env-hash="564629063996780829" id="com.atollic.truestudio.mbs.provider" keep-relative-paths="false" name="Atollic ARM Tools Language Settings" parameter="${COMMAND} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
7
+			<provider class="com.atollic.truestudio.mbs.GCCSpecsDetectorAtollicArm" console="false" env-hash="1681877287601945682" id="com.atollic.truestudio.mbs.provider" keep-relative-paths="false" name="Atollic ARM Tools Language Settings" parameter="${COMMAND} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
8
 				<language-scope id="org.eclipse.cdt.core.gcc"/>
8
 				<language-scope id="org.eclipse.cdt.core.gcc"/>
9
 				<language-scope id="org.eclipse.cdt.core.g++"/>
9
 				<language-scope id="org.eclipse.cdt.core.g++"/>
10
 			</provider>
10
 			</provider>
@@ -14,7 +14,7 @@
14
 		<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
14
 		<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
15
 			<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
15
 			<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
16
 			<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
16
 			<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
17
-			<provider class="com.atollic.truestudio.mbs.GCCSpecsDetectorAtollicArm" console="false" env-hash="564629063996780829" id="com.atollic.truestudio.mbs.provider" keep-relative-paths="false" name="Atollic ARM Tools Language Settings" parameter="${COMMAND} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
17
+			<provider class="com.atollic.truestudio.mbs.GCCSpecsDetectorAtollicArm" console="false" env-hash="1681877287601945682" id="com.atollic.truestudio.mbs.provider" keep-relative-paths="false" name="Atollic ARM Tools Language Settings" parameter="${COMMAND} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
18
 				<language-scope id="org.eclipse.cdt.core.gcc"/>
18
 				<language-scope id="org.eclipse.cdt.core.gcc"/>
19
 				<language-scope id="org.eclipse.cdt.core.g++"/>
19
 				<language-scope id="org.eclipse.cdt.core.g++"/>
20
 			</provider>
20
 			</provider>

+ 2 - 1
Bluecell_Inc/PE43711.h

@@ -9,6 +9,7 @@
9
 #define PE43711_H_
9
 #define PE43711_H_
10
 #include "main.h"
10
 #include "main.h"
11
  void PE43711_PinInit(void);
11
  void PE43711_PinInit(void);
12
+ uint8_t PE43711_DataToHexConvert(double val);
12
 
13
 
13
 
14
 
14
  typedef struct{
15
  typedef struct{
@@ -43,7 +44,7 @@
43
    PE43711_st ATT_UL4;
44
    PE43711_st ATT_UL4;
44
    uint8_t    data_UL4;
45
    uint8_t    data_UL4;
45
  }ALL_PE43711_st;
46
  }ALL_PE43711_st;
46
-ALL_PE43711_st ALL_ATT;
47
+extern ALL_PE43711_st ALL_ATT;
47
 
48
 
48
 
49
 
49
 
50
 

+ 42 - 4
Bluecell_Src/Bluecell_operate.c

@@ -1,7 +1,7 @@
1
 #include <stdio.h>
1
 #include <stdio.h>
2
 #include "main.h"
2
 #include "main.h"
3
 #include "Bluecell_operate.h"
3
 #include "Bluecell_operate.h"
4
-
4
+#include "PE43711.h"
5
 extern volatile uint32_t LedTimerCnt;
5
 extern volatile uint32_t LedTimerCnt;
6
 
6
 
7
 uint8_t Alarm_Status[MAX_ALARM_Len] = {0,};
7
 uint8_t Alarm_Status[MAX_ALARM_Len] = {0,};
@@ -59,11 +59,13 @@ BLUECELL_LENGTH,
59
 BLUECELL_CRCINDEX,
59
 BLUECELL_CRCINDEX,
60
 BLUECELL_DATA,
60
 BLUECELL_DATA,
61
 };
61
 };
62
+
63
+extern ALL_PE43711_st ALL_ATT;
62
 bool Bluecell_Operate(uint8_t* data){
64
 bool Bluecell_Operate(uint8_t* data){
63
   uint8_t datatype = data[BLUECELL_TYPE];
65
   uint8_t datatype = data[BLUECELL_TYPE];
64
   uint16_t tmp_h = 0,tmp_l = 0;
66
   uint16_t tmp_h = 0,tmp_l = 0;
65
   double ret = 0 ,tmp = 0.1;
67
   double ret = 0 ,tmp = 0.1;
66
-
68
+  uint8_t val = 0;
67
   switch(datatype){
69
   switch(datatype){
68
 	case ATTDL1 				 :
70
 	case ATTDL1 				 :
69
 		printf("Function : %s Line %d \r\n",__func__,__LINE__);
71
 		printf("Function : %s Line %d \r\n",__func__,__LINE__);
@@ -72,8 +74,10 @@ bool Bluecell_Operate(uint8_t* data){
72
 		ret += ((tmp_h << 8) & 0xFF00);
74
 		ret += ((tmp_h << 8) & 0xFF00);
73
 		ret += (tmp_l & 0x00FF);
75
 		ret += (tmp_l & 0x00FF);
74
 		ret /= 100;
76
 		ret /= 100;
75
-
76
-		printf("tmp_h : %x tmp_l : %x , ret : %x ,%f ,tmp %f \r\n",tmp_h,tmp_l,ret,tmp );
77
+        val = PE43711_DataToHexConvert(ret);
78
+        PE43711_atten_ctrl(ALL_ATT.ATT_DL1,val);
79
+        
80
+		printf("ret : %f ,tmp %f \r\n",ret,tmp );
77
 		break;
81
 		break;
78
 	case ATT_DL1_PATH_OFF 		 :
82
 	case ATT_DL1_PATH_OFF 		 :
79
 		printf("Function : %s Line %d \r\n",__func__,__LINE__);
83
 		printf("Function : %s Line %d \r\n",__func__,__LINE__);
@@ -88,6 +92,8 @@ bool Bluecell_Operate(uint8_t* data){
88
 		ret += ((tmp_h << 8) & 0xFF00);
92
 		ret += ((tmp_h << 8) & 0xFF00);
89
 		ret += (tmp_l & 0x00FF);
93
 		ret += (tmp_l & 0x00FF);
90
 		ret /= 100;
94
 		ret /= 100;
95
+        val = PE43711_DataToHexConvert(ret);
96
+        PE43711_atten_ctrl(ALL_ATT.ATT_UL1,val);
91
 
97
 
92
 		printf("tmp_h : %x tmp_l : %x , ret : %x ,%f ,tmp %f \r\n",tmp_h,tmp_l,ret,tmp );
98
 		printf("tmp_h : %x tmp_l : %x , ret : %x ,%f ,tmp %f \r\n",tmp_h,tmp_l,ret,tmp );
93
 
99
 
@@ -99,9 +105,13 @@ bool Bluecell_Operate(uint8_t* data){
99
 		printf("Function : %s Line %d \r\n",__func__,__LINE__);
105
 		printf("Function : %s Line %d \r\n",__func__,__LINE__);
100
 		break;
106
 		break;
101
 	case ATT_SelfTest1_OFF		 :
107
 	case ATT_SelfTest1_OFF		 :
108
+        HAL_GPIO_WritePin(_PATH_SW1_GPIO_Port,_PATH_SW1_Pin,GPIO_PIN_RESET);//CLOCK
109
+        HAL_GPIO_WritePin(PATH_SW1_GPIO_Port,PATH_SW1_Pin,GPIO_PIN_SET);//CLOCK
102
 		printf("Function : %s Line %d \r\n",__func__,__LINE__);
110
 		printf("Function : %s Line %d \r\n",__func__,__LINE__);
103
 		break;
111
 		break;
104
 	case ATT_SelfTest1_ON 		 :
112
 	case ATT_SelfTest1_ON 		 :
113
+        HAL_GPIO_WritePin(_PATH_SW1_GPIO_Port,_PATH_SW1_Pin,GPIO_PIN_SET);//CLOCK
114
+        HAL_GPIO_WritePin(PATH_SW1_GPIO_Port,PATH_SW1_Pin,GPIO_PIN_RESET);//CLOCK
105
 		printf("Function : %s Line %d \r\n",__func__,__LINE__);
115
 		printf("Function : %s Line %d \r\n",__func__,__LINE__);
106
 		break;
116
 		break;
107
 	case ATTDL2  				 :
117
 	case ATTDL2  				 :
@@ -111,6 +121,8 @@ bool Bluecell_Operate(uint8_t* data){
111
 		ret += ((tmp_h << 8) & 0xFF00);
121
 		ret += ((tmp_h << 8) & 0xFF00);
112
 		ret += (tmp_l & 0x00FF);
122
 		ret += (tmp_l & 0x00FF);
113
 		ret /= 100;
123
 		ret /= 100;
124
+        val = PE43711_DataToHexConvert(ret);
125
+        PE43711_atten_ctrl(ALL_ATT.ATT_DL2,val);
114
 
126
 
115
 		printf("tmp_h : %x tmp_l : %x , ret : %x ,%f ,tmp %f \r\n",tmp_h,tmp_l,ret,tmp );
127
 		printf("tmp_h : %x tmp_l : %x , ret : %x ,%f ,tmp %f \r\n",tmp_h,tmp_l,ret,tmp );
116
 
128
 
@@ -128,6 +140,8 @@ bool Bluecell_Operate(uint8_t* data){
128
 		ret += ((tmp_h << 8) & 0xFF00);
140
 		ret += ((tmp_h << 8) & 0xFF00);
129
 		ret += (tmp_l & 0x00FF);
141
 		ret += (tmp_l & 0x00FF);
130
 		ret /= 100;
142
 		ret /= 100;
143
+        val = PE43711_DataToHexConvert(ret);
144
+        PE43711_atten_ctrl(ALL_ATT.ATT_UL2,val);
131
 
145
 
132
 		printf("tmp_h : %x tmp_l : %x , ret : %x ,%f ,tmp %f \r\n",tmp_h,tmp_l,ret,tmp );
146
 		printf("tmp_h : %x tmp_l : %x , ret : %x ,%f ,tmp %f \r\n",tmp_h,tmp_l,ret,tmp );
133
 
147
 
@@ -139,9 +153,14 @@ bool Bluecell_Operate(uint8_t* data){
139
 		printf("Function : %s Line %d \r\n",__func__,__LINE__);
153
 		printf("Function : %s Line %d \r\n",__func__,__LINE__);
140
 		break;
154
 		break;
141
 	case ATT_SelfTest2_OFF		 :
155
 	case ATT_SelfTest2_OFF		 :
156
+        HAL_GPIO_WritePin(_PATH_SW2_GPIO_Port,_PATH_SW2_Pin,GPIO_PIN_RESET);//CLOCK
157
+        HAL_GPIO_WritePin(PATH_SW2_GPIO_Port,PATH_SW2_Pin,GPIO_PIN_SET);//CLOCK
142
 		printf("Function : %s Line %d \r\n",__func__,__LINE__);
158
 		printf("Function : %s Line %d \r\n",__func__,__LINE__);
143
 		break;
159
 		break;
144
 	case ATT_SelfTest2_ON :
160
 	case ATT_SelfTest2_ON :
161
+        HAL_GPIO_WritePin(PATH_SW2_GPIO_Port,PATH_SW2_Pin,GPIO_PIN_RESET);//CLOCK
162
+        HAL_GPIO_WritePin(_PATH_SW2_GPIO_Port,_PATH_SW2_Pin,GPIO_PIN_SET);//CLOCK
163
+        
145
 		printf("Function : %s Line %d \r\n",__func__,__LINE__);
164
 		printf("Function : %s Line %d \r\n",__func__,__LINE__);
146
 		break;
165
 		break;
147
 	case ATTDL3  :
166
 	case ATTDL3  :
@@ -151,6 +170,8 @@ bool Bluecell_Operate(uint8_t* data){
151
 		ret += ((tmp_h << 8) & 0xFF00);
170
 		ret += ((tmp_h << 8) & 0xFF00);
152
 		ret += (tmp_l & 0x00FF);
171
 		ret += (tmp_l & 0x00FF);
153
 		ret /= 100;
172
 		ret /= 100;
173
+        val = PE43711_DataToHexConvert(ret);
174
+        PE43711_atten_ctrl(ALL_ATT.ATT_DL3,val);
154
 
175
 
155
 		printf("tmp_h : %x tmp_l : %x , ret : %x ,%f ,tmp %f \r\n",tmp_h,tmp_l,ret,tmp );
176
 		printf("tmp_h : %x tmp_l : %x , ret : %x ,%f ,tmp %f \r\n",tmp_h,tmp_l,ret,tmp );
156
 
177
 
@@ -168,6 +189,8 @@ bool Bluecell_Operate(uint8_t* data){
168
 		ret += ((tmp_h << 8) & 0xFF00);
189
 		ret += ((tmp_h << 8) & 0xFF00);
169
 		ret += (tmp_l & 0x00FF);
190
 		ret += (tmp_l & 0x00FF);
170
 		ret /= 100;
191
 		ret /= 100;
192
+        val = PE43711_DataToHexConvert(ret);
193
+        PE43711_atten_ctrl(ALL_ATT.ATT_UL3,val);
171
 
194
 
172
 		printf("tmp_h : %x tmp_l : %x , ret : %x ,%f ,tmp %f \r\n",tmp_h,tmp_l,ret,tmp );
195
 		printf("tmp_h : %x tmp_l : %x , ret : %x ,%f ,tmp %f \r\n",tmp_h,tmp_l,ret,tmp );
173
 
196
 
@@ -179,9 +202,15 @@ bool Bluecell_Operate(uint8_t* data){
179
 		printf("Function : %s Line %d \r\n",__func__,__LINE__);
202
 		printf("Function : %s Line %d \r\n",__func__,__LINE__);
180
 		break;
203
 		break;
181
 	case ATT_SelfTest3_OFF :
204
 	case ATT_SelfTest3_OFF :
205
+        HAL_GPIO_WritePin(_PATH_SW3_GPIO_Port,_PATH_SW3_Pin,GPIO_PIN_RESET);//CLOCK
206
+        HAL_GPIO_WritePin(PATH_SW3_GPIO_Port,PATH_SW3_Pin,GPIO_PIN_SET);//CLOCK
207
+        
182
 		printf("Function : %s Line %d \r\n",__func__,__LINE__);
208
 		printf("Function : %s Line %d \r\n",__func__,__LINE__);
183
 		break;
209
 		break;
184
 	case ATT_SelfTest3_ON :
210
 	case ATT_SelfTest3_ON :
211
+        HAL_GPIO_WritePin(PATH_SW3_GPIO_Port,PATH_SW3_Pin,GPIO_PIN_RESET);//CLOCK
212
+        HAL_GPIO_WritePin(_PATH_SW3_GPIO_Port,_PATH_SW3_Pin,GPIO_PIN_SET);//CLOCK
213
+        
185
 		printf("Function : %s Line %d \r\n",__func__,__LINE__);
214
 		printf("Function : %s Line %d \r\n",__func__,__LINE__);
186
 		break;
215
 		break;
187
 	case ATTDL4  :
216
 	case ATTDL4  :
@@ -191,14 +220,21 @@ bool Bluecell_Operate(uint8_t* data){
191
 		ret += ((tmp_h << 8) & 0xFF00);
220
 		ret += ((tmp_h << 8) & 0xFF00);
192
 		ret += (tmp_l & 0x00FF);
221
 		ret += (tmp_l & 0x00FF);
193
 		ret /= 100;
222
 		ret /= 100;
223
+        val = PE43711_DataToHexConvert(ret);
224
+        PE43711_atten_ctrl(ALL_ATT.ATT_DL4,val);
194
 
225
 
195
 		printf("tmp_h : %x tmp_l : %x , ret : %x ,%f ,tmp %f \r\n",tmp_h,tmp_l,ret,tmp );
226
 		printf("tmp_h : %x tmp_l : %x , ret : %x ,%f ,tmp %f \r\n",tmp_h,tmp_l,ret,tmp );
196
 
227
 
197
 		break;
228
 		break;
198
 	case ATT_DL4_PATH_OFF :
229
 	case ATT_DL4_PATH_OFF :
230
+        HAL_GPIO_WritePin(_PATH_SW4_GPIO_Port,_PATH_SW4_Pin,GPIO_PIN_RESET);//CLOCK
231
+        HAL_GPIO_WritePin(PATH_SW4_GPIO_Port,PATH_SW4_Pin,GPIO_PIN_SET);//CLOCK
199
 		printf("Function : %s Line %d \r\n",__func__,__LINE__);
232
 		printf("Function : %s Line %d \r\n",__func__,__LINE__);
200
 		break;
233
 		break;
201
 	case ATT_DL4_PATH_ON :
234
 	case ATT_DL4_PATH_ON :
235
+        HAL_GPIO_WritePin(_PATH_SW4_GPIO_Port,_PATH_SW4_Pin,GPIO_PIN_SET);//CLOCK
236
+        HAL_GPIO_WritePin(PATH_SW4_GPIO_Port,PATH_SW4_Pin,GPIO_PIN_RESET);//CLOCK
237
+        
202
 		printf("Function : %s Line %d \r\n",__func__,__LINE__);
238
 		printf("Function : %s Line %d \r\n",__func__,__LINE__);
203
 		break;
239
 		break;
204
 	case ATTUL4  :
240
 	case ATTUL4  :
@@ -208,6 +244,8 @@ bool Bluecell_Operate(uint8_t* data){
208
 		ret += ((tmp_h << 8) & 0xFF00);
244
 		ret += ((tmp_h << 8) & 0xFF00);
209
 		ret += (tmp_l & 0x00FF);
245
 		ret += (tmp_l & 0x00FF);
210
 		ret /= 100;
246
 		ret /= 100;
247
+        val = PE43711_DataToHexConvert(ret);
248
+        PE43711_atten_ctrl(ALL_ATT.ATT_UL4,val);
211
 
249
 
212
 		printf("tmp_h : %x tmp_l : %x , ret : %x ,%f ,tmp %f \r\n",tmp_h,tmp_l,ret,tmp );
250
 		printf("tmp_h : %x tmp_l : %x , ret : %x ,%f ,tmp %f \r\n",tmp_h,tmp_l,ret,tmp );
213
 
251
 

+ 16 - 8
Bluecell_Src/PE43711.c

@@ -112,24 +112,32 @@ void Bit_Compare(PE43711_st ATT,uint8_t data,uint8_t Shift_Index){
112
 }
112
 }
113
 
113
 
114
 uint8_t PE43711_DataToHexConvert(double val){
114
 uint8_t PE43711_DataToHexConvert(double val){
115
-	double ref = 0.25;
116
-	uint8_t ret = 0,shift = 0x01;
115
+	double ref = 16;
116
+	uint8_t ret = 0,shift = 0x40;
117
 
117
 
118
+//    printf("val : %f \r\n",val);
119
+    
118
 	for(int i = 0; i < 8; i++){
120
 	for(int i = 0; i < 8; i++){
119
 		if(val == 0)
121
 		if(val == 0)
120
 			break;
122
 			break;
121
 
123
 
122
 		if(val < 31.25){
124
 		if(val < 31.25){
123
-			val -= 16;
124
-
125
+            if(val >= ref){
126
+    			val -= ref;
127
+                ret |= shift;
128
+//                printf("ret : %x \r\n",ret);
129
+            }
130
+            ref /= 2;
125
 		}
131
 		}
126
 		else{
132
 		else{
127
-			return 0b01111111;
133
+			ret =  0b01111111;
134
+            break;
128
 		}
135
 		}
129
-
130
-		ref *= 2;
136
+        shift >>= 1;
131
 	}
137
 	}
132
-	return;
138
+//    printf("\r\nPE43711_DataToHexConvert Result : %x\r\n",ret);
139
+    
140
+	return ret;
133
 }
141
 }
134
 
142
 
135
 #if 0 // PYJ.2020.04.17_BEGIN -- 
143
 #if 0 // PYJ.2020.04.17_BEGIN --