Browse Source

EEPROM 라이브러리 추가
Warning 수정
Controller ID Set 함수 추가
Controller ID Get 함수 추가
EEPROM에서 Data 가져오는 Initialize 함수 추가 Main 문에도 추가하였음

june9152 6 years ago
parent
commit
3899642255

BIN
Debug/STM32F103_RGB_Controller.bin


BIN
Debug/STM32F103_RGB_Controller.binary


BIN
Debug/STM32F103_RGB_Controller.elf


File diff suppressed because it is too large
+ 7685 - 6602
Debug/STM32F103_RGB_Controller.list


File diff suppressed because it is too large
+ 809 - 779
Debug/STM32F103_RGB_Controller.map


BIN
Debug/STM32F103_RGB_Gateway.bin - 바로 가기.lnk


BIN
Debug/Src/GPIO_SPI.o


BIN
Debug/Src/M24C32.o


+ 3 - 0
Debug/Src/M24C32.su

@@ -0,0 +1,3 @@
1
+M24C32.c:12:6:I2c_Status_Check	0	static
2
+M24C32.c:27:6:M24C32_Data_Write	64	static
3
+M24C32.c:37:9:M24C32_Data_Read	32	static

BIN
Debug/Src/RGB_Controller.o


+ 12 - 9
Debug/Src/RGB_Controller.su

@@ -1,9 +1,12 @@
1
-RGB_Controller.c:10:6:RGB_Response_Func	8	static
2
-RGB_Controller.c:61:6:RGB_Sensor_LED_Alarm_ON	8	static
3
-RGB_Controller.c:99:6:RGB_Sensor_LED_Alarm_OFF	8	static
4
-RGB_Controller.c:138:6:RGB_Alarm_Operate	32	static
5
-RGB_Controller.c:171:9:RGB_DeviceStatusCheck	12	static
6
-RGB_Controller.c:245:9:RGB_BufCal	0	static
7
-RGB_Controller.c:218:6:RGB_Data_Stack	24	static
8
-RGB_Controller.c:154:6:RGB_Alarm_Check	48	static
9
-RGB_Controller.c:262:6:RGB_Controller_Func	120	static
1
+RGB_Controller.c:43:10:RGB_Limit_Address_Check	0	static
2
+RGB_Controller.c:57:10:RGB_Location_Address_Check	0	static
3
+RGB_Controller.c:17:6:RGB_Data_Init	48	static
4
+RGB_Controller.c:72:6:RGB_Response_Func	8	static
5
+RGB_Controller.c:125:6:RGB_Sensor_LED_Alarm_ON	8	static
6
+RGB_Controller.c:163:6:RGB_Sensor_LED_Alarm_OFF	8	static
7
+RGB_Controller.c:202:6:RGB_Alarm_Operate	32	static
8
+RGB_Controller.c:239:9:RGB_DeviceStatusCheck	12	static
9
+RGB_Controller.c:313:9:RGB_BufCal	0	static
10
+RGB_Controller.c:286:6:RGB_Data_Stack	24	static
11
+RGB_Controller.c:218:6:RGB_Alarm_Check	96	static
12
+RGB_Controller.c:330:6:RGB_Controller_Func	120	static

BIN
Debug/Src/RGB_Lora.o


BIN
Debug/Src/SX1276.o


BIN
Debug/Src/main.o


+ 2 - 2
Debug/Src/main.su

@@ -15,6 +15,6 @@ main.c:383:6:test_read	24	static
15 15
 main.c:402:6:Flash_RGB_Data_Write	16	static
16 16
 main.c:415:6:Flash_write	24	static
17 17
 main.c:468:6:Flash_InitRead	12	static
18
-main.c:721:6:SystemClock_Config	72	static
18
+main.c:729:6:SystemClock_Config	72	static
19 19
 main.c:506:5:main	112	static
20
-main.c:995:6:Error_Handler	0	static
20
+main.c:1003:6:Error_Handler	0	static

BIN
Debug/Src/stm32f1xx_hal_msp.o


BIN
Debug/Src/stm32f1xx_it.o


+ 7 - 0
Inc/M24C32.h

@@ -0,0 +1,7 @@
1
+#include "main.h"
2
+
3
+extern void I2c_Status_Check(I2C_HandleTypeDef* hi2cx,HAL_StatusTypeDef status);
4
+extern void M24C32_Data_Write(I2C_HandleTypeDef* hi2cx,uint8_t* data,uint16_t address,uint8_t size);
5
+extern uint8_t M24C32_Data_Read(I2C_HandleTypeDef* hi2cx,uint16_t address);
6
+
7
+

+ 3 - 0
Inc/RGB_Controller.h

@@ -4,6 +4,9 @@
4 4
 extern void RGB_Controller_Func(uint8_t* data);
5 5
 extern void RGB_Alarm_Operate(void);
6 6
 extern void RGB_Sensor_LED_Alarm_OFF(uint8_t id );
7
+extern void RGB_Data_Init(void);
8
+extern uint8_t M24C32_Data_Read(I2C_HandleTypeDef* hi2cx,uint16_t address);
9
+extern void M24C32_Data_Write(I2C_HandleTypeDef* hi2cx,uint8_t* data,uint16_t address,uint8_t size);
7 10
 
8 11
 extern uint8_t SensorID_buf[8];
9 12
 extern uint8_t SensorID_Cnt;

+ 106 - 2
Inc/main.h

@@ -78,6 +78,12 @@ typedef enum{ //LIMIT SET enum
78 78
     bluecell_crc,
79 79
     bluecell_etx,
80 80
 }RGB_Protocol_t;    
81
+typedef enum{ //LIMIT SET enum
82
+    Location_stx = 0,
83
+    Location_type,
84
+    Location_length,
85
+    Location_Data,
86
+}RGB_Location_Protocol_t;    
81 87
 /* USER CODE END ET */
82 88
 
83 89
 /* Exported constants --------------------------------------------------------*/
@@ -106,6 +112,7 @@ void Error_Handler(void);
106 112
 extern uint8_t MyControllerID;
107 113
 extern uint8_t  SensorID;
108 114
 extern uint8_t Lora_Buf[100];
115
+extern I2C_HandleTypeDef hi2c2;
109 116
 
110 117
 typedef enum{
111 118
     RGB_Status_Data_Request = 0x01,
@@ -118,8 +125,12 @@ typedef enum{
118 125
     RGB_Sensor_Check ,              //8
119 126
     RGB_Sensor_Ack,                 //9
120 127
     RGB_Reset,                      //10
121
-    RGB_ID_Allocate_Request,        //11
122
-    RGB_Lora_Data_Report,           //12
128
+    RGB_BootStart,                  //11
129
+    RGB_ID_Allocate_Request,        //12
130
+    RGB_Lora_Data_Report,           //13
131
+    RGB_Location_Report,           //14
132
+    RGB_Location_Response,           //15
133
+    RGB_ControllerID_GET,           //16
123 134
 }RGB_CMD_T;
124 135
 #define     RGB_ControllerID_SET_Length         10 
125 136
 #define     RGB_SensorID_SET_Length             10 
@@ -132,6 +143,99 @@ typedef enum{
132 143
 #define     RGB_SensorDataResponseData_Length   RGB_SensorDataResponse_Length - 3
133 144
 #define     Lora_Max_Amount                     5
134 145
 #define     LORA_MAX_DATA_CNT                   Lora_Max_Amount + 3
146
+
147
+/*ID 정보  */
148
+
149
+#define MY_ID_ADDRESS               0x0000
150
+
151
+/*색깔 제한 정보 */
152
+/*SENSOR 1  ADDRESS*/
153
+#define RGB1_LIMIT_RED_H_ADDRESS     0x0001
154
+#define RGB1_LIMIT_RED_L_ADDRESS     0x0002
155
+#define RGB1_LIMIT_GREEN_H_ADDRESS   0x0003
156
+#define RGB1_LIMIT_GREEN_L_ADDRESS   0x0004
157
+#define RGB1_LIMIT_BLUE_H_ADDRESS    0x0005
158
+#define RGB1_LIMIT_BLUE_L_ADDRESS    0x0006
159
+/*SENSOR 2  ADDRESS*/
160
+#define RGB2_LIMIT_RED_H_ADDRESS     0x0007
161
+#define RGB2_LIMIT_RED_L_ADDRESS     0x0008
162
+#define RGB2_LIMIT_GREEN_H_ADDRESS   0x0009
163
+#define RGB2_LIMIT_GREEN_L_ADDRESS   0x000A
164
+#define RGB2_LIMIT_BLUE_H_ADDRESS    0x000B
165
+#define RGB2_LIMIT_BLUE_L_ADDRESS    0x000C
166
+/*SENSOR 3  ADDRESS*/
167
+#define RGB3_LIMIT_RED_H_ADDRESS     0x000D
168
+#define RGB3_LIMIT_RED_L_ADDRESS     0x000E
169
+#define RGB3_LIMIT_GREEN_H_ADDRESS   0x000F
170
+#define RGB3_LIMIT_GREEN_L_ADDRESS   0x0010
171
+#define RGB3_LIMIT_BLUE_H_ADDRESS    0x0011
172
+#define RGB3_LIMIT_BLUE_L_ADDRESS    0x0012
173
+/*SENSOR 4  ADDRESS*/
174
+#define RGB4_LIMIT_RED_H_ADDRESS     0x0013
175
+#define RGB4_LIMIT_RED_L_ADDRESS     0x0014
176
+#define RGB4_LIMIT_GREEN_H_ADDRESS   0x0015
177
+#define RGB4_LIMIT_GREEN_L_ADDRESS   0x0016
178
+#define RGB4_LIMIT_BLUE_H_ADDRESS    0x0017
179
+#define RGB4_LIMIT_BLUE_L_ADDRESS    0x0018
180
+/*SENSOR 5  ADDRESS*/
181
+#define RGB5_LIMIT_RED_H_ADDRESS     0x0019
182
+#define RGB5_LIMIT_RED_L_ADDRESS     0x001A
183
+#define RGB5_LIMIT_GREEN_H_ADDRESS   0x001B
184
+#define RGB5_LIMIT_GREEN_L_ADDRESS   0x001C
185
+#define RGB5_LIMIT_BLUE_H_ADDRESS    0x001D
186
+#define RGB5_LIMIT_BLUE_L_ADDRESS    0x001E
187
+/*SENSOR 6  ADDRESS*/
188
+#define RGB6_LIMIT_RED_H_ADDRESS     0x001F
189
+#define RGB6_LIMIT_RED_L_ADDRESS     0x0020
190
+#define RGB6_LIMIT_GREEN_H_ADDRESS   0x0021
191
+#define RGB6_LIMIT_GREEN_L_ADDRESS   0x0022
192
+#define RGB6_LIMIT_BLUE_H_ADDRESS    0x0023
193
+#define RGB6_LIMIT_BLUE_L_ADDRESS    0x0024
194
+/*SENSOR 7  ADDRESS*/
195
+#define RGB7_LIMIT_RED_H_ADDRESS     0x0025
196
+#define RGB7_LIMIT_RED_L_ADDRESS     0x0036
197
+#define RGB7_LIMIT_GREEN_H_ADDRESS   0x0027
198
+#define RGB7_LIMIT_GREEN_L_ADDRESS   0x0028
199
+#define RGB7_LIMIT_BLUE_H_ADDRESS    0x0029
200
+#define RGB7_LIMIT_BLUE_L_ADDRESS    0x002A
201
+/*SENSOR 8  ADDRESS*/
202
+#define RGB8_LIMIT_RED_H_ADDRESS     0x002B
203
+#define RGB8_LIMIT_RED_L_ADDRESS     0x002C
204
+#define RGB8_LIMIT_GREEN_H_ADDRESS   0x002D
205
+#define RGB8_LIMIT_GREEN_L_ADDRESS   0x002E
206
+#define RGB8_LIMIT_BLUE_H_ADDRESS    0x002F
207
+#define RGB8_LIMIT_BLUE_L_ADDRESS    0x0031
208
+/*위치 정보 */
209
+#define RGB1_LOCATION_ADDRESS        0x0032
210
+#define RGB2_LOCATION_ADDRESS        RGB1_LOCATION_ADDRESS + 50
211
+#define RGB3_LOCATION_ADDRESS        RGB2_LOCATION_ADDRESS + 50
212
+#define RGB4_LOCATION_ADDRESS        RGB3_LOCATION_ADDRESS + 50
213
+#define RGB5_LOCATION_ADDRESS        RGB4_LOCATION_ADDRESS + 50
214
+#define RGB6_LOCATION_ADDRESS        RGB5_LOCATION_ADDRESS + 50
215
+#define RGB7_LOCATION_ADDRESS        RGB6_LOCATION_ADDRESS + 50
216
+#define RGB8_LOCATION_ADDRESS        RGB7_LOCATION_ADDRESS + 50
217
+/*reserved*/
218
+#define RESERVED_ADDRESS             RGB8_LOCATION_ADDRESS + 50
219
+
220
+
221
+
222
+
223
+
224
+
225
+
226
+
227
+
228
+
229
+
230
+
231
+
232
+
233
+
234
+
235
+
236
+
237
+
238
+
135 239
 
136 240
 /* USER CODE END EFP */
137 241
 

+ 46 - 0
Src/M24C32.c

@@ -0,0 +1,46 @@
1
+#include "M24C32.h"
2
+
3
+
4
+uint8_t writedata[1] = {0xAA};
5
+uint8_t Readdata[1] = {0,};  
6
+
7
+
8
+
9
+
10
+
11
+
12
+void I2c_Status_Check(I2C_HandleTypeDef* hi2cx,HAL_StatusTypeDef status){
13
+    if(HAL_OK == status){
14
+        printf("HAL_OK\n");
15
+    }
16
+    else if(HAL_ERROR == status){
17
+        printf("HAL_ERROR\n");
18
+    }else if(HAL_BUSY == status){
19
+        printf("HAL_ERROR\n");
20
+    }else if(HAL_TIMEOUT == status){
21
+        printf("HAL_ERROR\n");
22
+    }  
23
+}
24
+
25
+
26
+
27
+void M24C32_Data_Write(I2C_HandleTypeDef* hi2cx,uint8_t* data,uint16_t address,uint8_t size){
28
+    HAL_StatusTypeDef status = HAL_ERROR;
29
+    for(uint8_t i = 0; i < size; i++){
30
+        status = HAL_I2C_Mem_Write(hi2cx,0xA0,address + i, I2C_MEMADD_SIZE_16BIT, &data[i],1, 2000);
31
+        HAL_Delay(5);
32
+        if(status > HAL_OK)
33
+            printf("EEPROM SAVE ERROR!!! \n");
34
+    }
35
+   // I2c_Status_Check(status);
36
+}
37
+uint8_t M24C32_Data_Read(I2C_HandleTypeDef* hi2cx,uint16_t address){
38
+    uint8_t data[1] = {0};
39
+    HAL_StatusTypeDef status = HAL_ERROR;
40
+    status = HAL_I2C_Mem_Read(hi2cx,0xA1, address,I2C_MEMADD_SIZE_16BIT, &data[0],1, 2000);
41
+  //  I2c_Status_Check(status);
42
+//    printf("Readdata[0] : %02x\n",data);
43
+    return data[0];
44
+}
45
+
46
+

+ 94 - 15
Src/RGB_Controller.c

@@ -4,8 +4,70 @@ void RGB_Response_Func(uint8_t* data);
4 4
 uint8_t RGB_BufCal(uint8_t srcid);
5 5
 void RGB_Alarm_Operate(void);
6 6
 void RGB_Data_Stack(uint8_t* rgb_buf);
7
+uint16_t RGB_Location_Address_Check(uint8_t id);
7 8
 
9
+uint8_t SensorID_Cnt = 0;
10
+uint8_t SensorID_buf[8] = {0,};
11
+uint16_t RGB_SensorRedLimit_Buf[9]={0,};
12
+uint16_t RGB_SensorGreenLimit_Buf[9]={0,};
13
+uint16_t RGB_SensorBlueLimit_Buf[9]={0,};
14
+uint8_t LED_Alarm[9] = {0,};
15
+uint8_t RGB_Location_Buf[9][50] = {0};
8 16
 
17
+void RGB_Data_Init(void){
18
+    MyControllerID = M24C32_Data_Read(&hi2c2,MY_ID_ADDRESS);
19
+  
20
+    for(uint8_t i = 0; i < 8; i++){
21
+        RGB_SensorRedLimit_Buf[i + 1] = (M24C32_Data_Read(&hi2c2,RGB1_LIMIT_RED_H_ADDRESS + (6 * i)) << 8);
22
+        RGB_SensorRedLimit_Buf[i + 1] |= M24C32_Data_Read(&hi2c2,RGB1_LIMIT_RED_L_ADDRESS + (6 * i));
23
+    }
24
+    for(uint8_t i = 0; i < 8; i++){
25
+        RGB_SensorGreenLimit_Buf[i + 1] = (M24C32_Data_Read(&hi2c2,RGB1_LIMIT_GREEN_H_ADDRESS + (6 * i)) << 8);
26
+        RGB_SensorGreenLimit_Buf[i + 1] |= M24C32_Data_Read(&hi2c2,RGB1_LIMIT_GREEN_L_ADDRESS + (6 * i));
27
+    }
28
+    for(uint8_t i = 0; i < 8; i++){
29
+        RGB_SensorBlueLimit_Buf[i + 1] = (M24C32_Data_Read(&hi2c2,RGB1_LIMIT_BLUE_H_ADDRESS + (6 * i)) << 8);
30
+        RGB_SensorBlueLimit_Buf[i + 1] |= M24C32_Data_Read(&hi2c2,RGB1_LIMIT_BLUE_L_ADDRESS + (6 * i));
31
+    }
32
+    for(uint8_t i = 0; i < 8; i++){
33
+        for(uint8_t aa= 0; aa < 50; aa++)
34
+            RGB_Location_Buf[i + 1][aa] = M24C32_Data_Read(&hi2c2,RGB_Location_Address_Check(i + 1) + aa);
35
+    }
36
+    printf("MY id is %d \n",MyControllerID);
37
+    for(uint8_t i = 1; i <= 8; i++){
38
+        printf("RGB_SensorRedLimit_Buf[%d]    :  %04x\n",i,RGB_SensorRedLimit_Buf[i]);
39
+        printf("RGB_SensorGreenLimit_Buf[%d]  :  %04x\n",i,RGB_SensorGreenLimit_Buf[i]);
40
+        printf("RGB_SensorBlueLimit_Buf[%d]   :  %04x\n",i,RGB_SensorBlueLimit_Buf[i]);    
41
+    }
42
+}
43
+uint16_t RGB_Limit_Address_Check(uint8_t id){
44
+    uint16_t ret = 0;
45
+    switch(id){
46
+        case 1: ret = RGB1_LIMIT_RED_H_ADDRESS;break;
47
+        case 2: ret = RGB2_LIMIT_RED_H_ADDRESS;break;
48
+        case 3: ret = RGB3_LIMIT_RED_H_ADDRESS;break;
49
+        case 4: ret = RGB4_LIMIT_RED_H_ADDRESS;break;
50
+        case 5: ret = RGB5_LIMIT_RED_H_ADDRESS;break;
51
+        case 6: ret = RGB6_LIMIT_RED_H_ADDRESS;break;
52
+        case 7: ret = RGB7_LIMIT_RED_H_ADDRESS;break;
53
+        case 8: ret = RGB8_LIMIT_RED_H_ADDRESS;break;        
54
+    }
55
+    return ret;
56
+}
57
+uint16_t RGB_Location_Address_Check(uint8_t id){
58
+    uint16_t ret = 0;
59
+    switch(id){
60
+        case 1: ret = RGB1_LOCATION_ADDRESS;break;
61
+        case 2: ret = RGB2_LOCATION_ADDRESS;break;
62
+        case 3: ret = RGB3_LOCATION_ADDRESS;break;
63
+        case 4: ret = RGB4_LOCATION_ADDRESS;break;
64
+        case 5: ret = RGB5_LOCATION_ADDRESS;break;
65
+        case 6: ret = RGB6_LOCATION_ADDRESS;break;
66
+        case 7: ret = RGB7_LOCATION_ADDRESS;break;
67
+        case 8: ret = RGB8_LOCATION_ADDRESS;break;        
68
+    }
69
+    return ret;
70
+}
9 71
 
10 72
 void RGB_Response_Func(uint8_t* data){

11 73
 	RGB_CMD_T type = data[bluecell_type];
@@ -20,6 +82,7 @@ for(uint8_t i = 0; i < 10; i++){
20 82
             break;
21 83
         case RGB_ControllerID_SET: 
22 84
             Uart1_Data_Send(data,RGB_ControllerID_SET_Length);
85
+            M24C32_Data_Write(&hi2c2,&MyControllerID,MY_ID_ADDRESS,1); // EEPROM Controller ID Save 
23 86
             break;
24 87
         case RGB_SensorID_SET:  
25 88
             Uart2_Data_Send(data,RGB_SensorIDAutoSetRequest_Length);
@@ -29,7 +92,7 @@ for(uint8_t i = 0; i < 10; i++){
29 92
             break;
30 93
         case RGB_ControllerLimitSet:
31 94
             Uart1_Data_Send(data,data[bluecell_length] + 3);
32
-            Flash_write(&data[0]);
95
+            M24C32_Data_Write(&hi2c2,&data[bluecell_red_H],RGB_Limit_Address_Check(data[bluecell_dstid]),6); // EEPROM Controller ID Save 
33 96
             break;
34 97
         case RGB_Sensor_Start:    
35 98
         case RGB_Sensor_Check:
@@ -40,23 +103,24 @@ for(uint8_t i = 0; i < 10; i++){
40 103
             break;
41 104
         case RGB_Reset:
42 105
         case RGB_SensorID_SET_Success:
106
+        case RGB_ID_Allocate_Request:
107
+            case RGB_Lora_Data_Report:
108
+            break;
109
+        case RGB_Location_Report:
110
+        case RGB_Location_Response:
111
+            M24C32_Data_Write(&hi2c2,&data[Location_Data],RGB_Location_Address_Check(data[bluecell_dstid]),data[bluecell_length] - 2); // EEPROM Controller ID Save 
43 112
             break;
44
-             
113
+         case RGB_ControllerID_GET:
114
+             Uart1_Data_Send(data,data[bluecell_length] + 3);
115
+             break;
45 116
     }
46 117
 
47 118
 }
48
-uint8_t SensorID_Cnt = 0;
49
-uint8_t SensorID_buf[8] = {0,};
50
-uint16_t RGB_SensorRedLimit_Buf[9]={0,};
51
-uint16_t RGB_SensorGreenLimit_Buf[9]={0,};
52
-uint16_t RGB_SensorBlueLimit_Buf[9]={0,};
53 119
 
54 120
 
55
-uint16_t Sensor_red[9] = {0,};
56
-uint16_t Sensor_green[9] = {0,};
57
-uint16_t Sensor_blue[9] = {0,};    
58 121
 
59
-uint8_t LED_Alarm[9] = {0,};
122
+
123
+
60 124
 void RGB_Sensor_LED_Alarm_ON(uint8_t id ){
61 125
     switch(id){
62 126
         case 0:// 모든 LED의 전원을 ON
@@ -151,6 +215,10 @@ void RGB_Alarm_Operate(void){
151 215
     }
152 216
 }
153 217
 void RGB_Alarm_Check(uint8_t* data){
218
+    uint16_t Sensor_red[9] = {0,};
219
+    uint16_t Sensor_green[9] = {0,};
220
+    uint16_t Sensor_blue[9] = {0,};    
221
+
154 222
     Sensor_red[data[bluecell_srcid]] = ((data[bluecell_red_H + 2] << 8)| data[bluecell_red_L + 2]);
155 223
     Sensor_green[data[bluecell_srcid]] = ((data[bluecell_green_H + 2] << 8)| data[bluecell_green_L + 2]);
156 224
     Sensor_blue[data[bluecell_srcid]] = ((data[bluecell_blue_H + 2] << 8)| data[bluecell_blue_L + 2]);  
@@ -274,13 +342,13 @@ void RGB_Controller_Func(uint8_t* data){
274 342
             break;
275 343
         case RGB_ControllerID_SET:        
276 344
             memcpy(&Result_buf[bluecell_stx],&data[bluecell_stx],data[bluecell_length] + 3);
277
-            Result_buf[7] = data[bluecell_srcid]; // �긽��諛⑹쓽 SRC ID�뒗 �굹�쓽 DST ID�씠�떎.
278
-            MyControllerID = Result_buf[7] = data[7];//�긽��諛⑹쓽 DST ID �뒗 �굹�쓽 ID �씠�떎.
345
+            MyControllerID = data[bluecell_srcid]; // �긽��諛⑹쓽 SRC ID�뒗 �굹�쓽 DST ID�씠�떎.
346
+            
279 347
             break;
280 348
         case RGB_SensorID_SET:        
281 349
             RGB_SensorIDAutoSet(1);
282 350
             memcpy(&Result_buf[bluecell_stx],&data[bluecell_stx],data[bluecell_length] + 3);
283
-            Result_buf[5]   = STH30_CreateCrc(&Result_buf[bluecell_type],Result_buf[bluecell_length]);
351
+            Result_buf[5]  = STH30_CreateCrc(&Result_buf[bluecell_type],Result_buf[bluecell_length]);
284 352
             break;
285 353
         case RGB_SensorID_SET_Success:
286 354
             SensorID_Cnt++;
@@ -306,7 +374,18 @@ void RGB_Controller_Func(uint8_t* data){
306 374
             NVIC_SystemReset();
307 375
             break;
308 376
         case RGB_ID_Allocate_Request:
309
-            
377
+            break;
378
+        case RGB_Location_Report:
379
+            break;
380
+        case RGB_Location_Response:
381
+            break;
382
+        case RGB_ControllerID_GET:
383
+            Result_buf[bluecell_stx]         = 0xbe;
384
+            Result_buf[bluecell_type]        = RGB_ControllerID_GET;
385
+            Result_buf[bluecell_length]      = 3;
386
+            Result_buf[bluecell_srcid]       = MyControllerID;      
387
+            Result_buf[bluecell_srcid + 1]   = STH30_CreateCrc(&Result_buf[bluecell_type],Result_buf[bluecell_length]);
388
+            Result_buf[bluecell_srcid + 2]   = 0xeb;
310 389
             break;
311 390
         default:
312 391
         break;

+ 1 - 1
Src/SX1276.c

@@ -59,7 +59,7 @@ __weak uint8_t SX1276_hw_SPIReadByte(SX1276_hw_t * hw) {
59 59
 }
60 60
 #endif // PYJ.2019.04.01_END -- 
61 61
 uint8_t SX1276_hw_SPIReadByte(SX1276_hw_t * hw) {
62
-	uint8_t txByte = 0x00;
62
+	//uint8_t txByte = 0x00;
63 63
 	uint8_t rxByte = 0x00;
64 64
 
65 65
 	SX1276_hw_SetNSS(hw, 0);

+ 11 - 3
Src/main.c

@@ -551,6 +551,7 @@ int main(void)
551 551
 #endif // PYJ.2019.03.04_END -- 
552 552
   RGB_SensorIDAutoSet(1);
553 553
   Flash_InitRead();
554
+  RGB_Data_Init();
554 555
   /* USER CODE END 2 */
555 556
 
556 557
   /* Infinite loop */
@@ -562,11 +563,8 @@ int main(void)
562 563
    SX1276_hw.nss.pin = GPIO_PIN_15;
563 564
    SX1276_hw.reset.port = SX1276_RESET_GPIO_Port;
564 565
    SX1276_hw.reset.pin = SX1276_RESET_Pin;
565
-  
566 566
   // SX1276_hw.spi = &hspi3;
567
-   
568 567
    SX1276.hw = &SX1276_hw;
569
-
570 568
    printf("Configuring LoRa module\r\n");
571 569
    SX1276_begin(&SX1276, SX1276_917MHZ, SX1276_POWER_17DBM, SX1276_LORA_SF_8,
572 570
            SX1276_LORA_BW_20_8KHZ, 10);
@@ -577,7 +575,17 @@ int main(void)
577 575
    } else {
578 576
        ret = SX1276_LoRaEntryRx(&SX1276, LORA_MAX_DATA_CNT, 2000);
579 577
    }
578
+#if 0 // PYJ.2019.04.16_BEGIN -- 
579
+   for(uint8_t i = 0; i < 100; i++){
580
+    Test_data[i] = i;
581
+    M24C32_Data_Write(&hi2c2,&Test_data[i],(uint16_t)i,1);
582
+   }
580 583
    
584
+   for(uint8_t i = 0; i < 100; i++){
585
+    printf("%d \n",M24C32_Data_Read(&hi2c2,(uint16_t)i));
586
+   }
587
+#endif // PYJ.2019.04.16_END -- 
588
+     
581 589
 
582 590
   while (1)
583 591
   {