Selaa lähdekoodia

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

PYJ 5 vuotta sitten
vanhempi
commit
d938d45a26

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

@@ -4,7 +4,7 @@
4 4
 		<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
5 5
 			<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
6 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 8
 				<language-scope id="org.eclipse.cdt.core.gcc"/>
9 9
 				<language-scope id="org.eclipse.cdt.core.g++"/>
10 10
 			</provider>
@@ -14,7 +14,7 @@
14 14
 		<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
15 15
 			<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
16 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 18
 				<language-scope id="org.eclipse.cdt.core.gcc"/>
19 19
 				<language-scope id="org.eclipse.cdt.core.g++"/>
20 20
 			</provider>

+ 2 - 1
Bluecell_Inc/PE43711.h

@@ -9,6 +9,7 @@
9 9
 #define PE43711_H_
10 10
 #include "main.h"
11 11
  void PE43711_PinInit(void);
12
+ uint8_t PE43711_DataToHexConvert(double val);
12 13
 
13 14
 
14 15
  typedef struct{
@@ -43,7 +44,7 @@
43 44
    PE43711_st ATT_UL4;
44 45
    uint8_t    data_UL4;
45 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 1
 #include <stdio.h>
2 2
 #include "main.h"
3 3
 #include "Bluecell_operate.h"
4
-
4
+#include "PE43711.h"
5 5
 extern volatile uint32_t LedTimerCnt;
6 6
 
7 7
 uint8_t Alarm_Status[MAX_ALARM_Len] = {0,};
@@ -59,11 +59,13 @@ BLUECELL_LENGTH,
59 59
 BLUECELL_CRCINDEX,
60 60
 BLUECELL_DATA,
61 61
 };
62
+
63
+extern ALL_PE43711_st ALL_ATT;
62 64
 bool Bluecell_Operate(uint8_t* data){
63 65
   uint8_t datatype = data[BLUECELL_TYPE];
64 66
   uint16_t tmp_h = 0,tmp_l = 0;
65 67
   double ret = 0 ,tmp = 0.1;
66
-
68
+  uint8_t val = 0;
67 69
   switch(datatype){
68 70
 	case ATTDL1 				 :
69 71
 		printf("Function : %s Line %d \r\n",__func__,__LINE__);
@@ -72,8 +74,10 @@ bool Bluecell_Operate(uint8_t* data){
72 74
 		ret += ((tmp_h << 8) & 0xFF00);
73 75
 		ret += (tmp_l & 0x00FF);
74 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 81
 		break;
78 82
 	case ATT_DL1_PATH_OFF 		 :
79 83
 		printf("Function : %s Line %d \r\n",__func__,__LINE__);
@@ -88,6 +92,8 @@ bool Bluecell_Operate(uint8_t* data){
88 92
 		ret += ((tmp_h << 8) & 0xFF00);
89 93
 		ret += (tmp_l & 0x00FF);
90 94
 		ret /= 100;
95
+        val = PE43711_DataToHexConvert(ret);
96
+        PE43711_atten_ctrl(ALL_ATT.ATT_UL1,val);
91 97
 
92 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 105
 		printf("Function : %s Line %d \r\n",__func__,__LINE__);
100 106
 		break;
101 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 110
 		printf("Function : %s Line %d \r\n",__func__,__LINE__);
103 111
 		break;
104 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 115
 		printf("Function : %s Line %d \r\n",__func__,__LINE__);
106 116
 		break;
107 117
 	case ATTDL2  				 :
@@ -111,6 +121,8 @@ bool Bluecell_Operate(uint8_t* data){
111 121
 		ret += ((tmp_h << 8) & 0xFF00);
112 122
 		ret += (tmp_l & 0x00FF);
113 123
 		ret /= 100;
124
+        val = PE43711_DataToHexConvert(ret);
125
+        PE43711_atten_ctrl(ALL_ATT.ATT_DL2,val);
114 126
 
115 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 140
 		ret += ((tmp_h << 8) & 0xFF00);
129 141
 		ret += (tmp_l & 0x00FF);
130 142
 		ret /= 100;
143
+        val = PE43711_DataToHexConvert(ret);
144
+        PE43711_atten_ctrl(ALL_ATT.ATT_UL2,val);
131 145
 
132 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 153
 		printf("Function : %s Line %d \r\n",__func__,__LINE__);
140 154
 		break;
141 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 158
 		printf("Function : %s Line %d \r\n",__func__,__LINE__);
143 159
 		break;
144 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 164
 		printf("Function : %s Line %d \r\n",__func__,__LINE__);
146 165
 		break;
147 166
 	case ATTDL3  :
@@ -151,6 +170,8 @@ bool Bluecell_Operate(uint8_t* data){
151 170
 		ret += ((tmp_h << 8) & 0xFF00);
152 171
 		ret += (tmp_l & 0x00FF);
153 172
 		ret /= 100;
173
+        val = PE43711_DataToHexConvert(ret);
174
+        PE43711_atten_ctrl(ALL_ATT.ATT_DL3,val);
154 175
 
155 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 189
 		ret += ((tmp_h << 8) & 0xFF00);
169 190
 		ret += (tmp_l & 0x00FF);
170 191
 		ret /= 100;
192
+        val = PE43711_DataToHexConvert(ret);
193
+        PE43711_atten_ctrl(ALL_ATT.ATT_UL3,val);
171 194
 
172 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 202
 		printf("Function : %s Line %d \r\n",__func__,__LINE__);
180 203
 		break;
181 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 208
 		printf("Function : %s Line %d \r\n",__func__,__LINE__);
183 209
 		break;
184 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 214
 		printf("Function : %s Line %d \r\n",__func__,__LINE__);
186 215
 		break;
187 216
 	case ATTDL4  :
@@ -191,14 +220,21 @@ bool Bluecell_Operate(uint8_t* data){
191 220
 		ret += ((tmp_h << 8) & 0xFF00);
192 221
 		ret += (tmp_l & 0x00FF);
193 222
 		ret /= 100;
223
+        val = PE43711_DataToHexConvert(ret);
224
+        PE43711_atten_ctrl(ALL_ATT.ATT_DL4,val);
194 225
 
195 226
 		printf("tmp_h : %x tmp_l : %x , ret : %x ,%f ,tmp %f \r\n",tmp_h,tmp_l,ret,tmp );
196 227
 
197 228
 		break;
198 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 232
 		printf("Function : %s Line %d \r\n",__func__,__LINE__);
200 233
 		break;
201 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 238
 		printf("Function : %s Line %d \r\n",__func__,__LINE__);
203 239
 		break;
204 240
 	case ATTUL4  :
@@ -208,6 +244,8 @@ bool Bluecell_Operate(uint8_t* data){
208 244
 		ret += ((tmp_h << 8) & 0xFF00);
209 245
 		ret += (tmp_l & 0x00FF);
210 246
 		ret /= 100;
247
+        val = PE43711_DataToHexConvert(ret);
248
+        PE43711_atten_ctrl(ALL_ATT.ATT_UL4,val);
211 249
 
212 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 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 120
 	for(int i = 0; i < 8; i++){
119 121
 		if(val == 0)
120 122
 			break;
121 123
 
122 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 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 143
 #if 0 // PYJ.2020.04.17_BEGIN --