瀏覽代碼

SX1276_LNA 추가
Uart DMA 추가
Lora Set 프로토콜 추가

june9152 6 年之前
父節點
當前提交
a396af3f3f

文件差異過大導致無法顯示
+ 180 - 180
.cproject


+ 1 - 1
.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="157605811251204298" 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="252364546433938101" 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>

二進制
Debug/STM32F103_RGB_Controller.bin


二進制
Debug/STM32F103_RGB_Controller.binary


二進制
Debug/STM32F103_RGB_Controller.elf


文件差異過大導致無法顯示
+ 1285 - 822
Debug/STM32F103_RGB_Controller.hex


文件差異過大導致無法顯示
+ 8025 - 7315
Debug/STM32F103_RGB_Controller.list


文件差異過大導致無法顯示
+ 707 - 690
Debug/STM32F103_RGB_Controller.map


二進制
Debug/Src/GPIO_SPI.o


二進制
Debug/Src/M24C32.o


二進制
Debug/Src/RGB_Controller.o


二進制
Debug/Src/RGB_Lora.o


二進制
Debug/Src/SX1276.o


+ 17 - 17
Debug/Src/SX1276.su

@@ -11,20 +11,20 @@ SX1276.c:83:9:SX1276_SPIRead	0	static
11
 SX1276.c:98:6:SX1276_SPIWrite	16	static
11
 SX1276.c:98:6:SX1276_SPIWrite	16	static
12
 SX1276.c:107:6:SX1276_SPIBurstRead	24	static
12
 SX1276.c:107:6:SX1276_SPIBurstRead	24	static
13
 SX1276.c:125:6:SX1276_SPIBurstWrite	0	static
13
 SX1276.c:125:6:SX1276_SPIBurstWrite	0	static
14
-SX1276.c:198:6:SX1276_standby	8	static
15
-SX1276.c:203:6:SX1276_sleep	8	static
16
-SX1276.c:208:6:SX1276_entryLoRa	0	static
17
-SX1276.c:147:6:SX1276_config	24	static
18
-SX1276.c:142:6:SX1276_defaultConfig	16	static
19
-SX1276.c:212:6:SX1276_clearLoRaIrq	0	static
20
-SX1276.c:216:5:SX1276_LoRaEntryRx	16	static
21
-SX1276.c:248:9:SX1276_LoRaRxPacket	16	static
22
-SX1276.c:271:5:SX1276_LoRaEntryTx	16	static
23
-SX1276.c:302:5:SX1276_LoRaTxPacket	16	static
24
-SX1276.c:323:6:SX1276_begin	32	static
25
-SX1276.c:334:5:SX1276_transmit	24	static
26
-SX1276.c:342:5:SX1276_receive	0	static
27
-SX1276.c:346:9:SX1276_available	0	static
28
-SX1276.c:350:9:SX1276_read	16	static
29
-SX1276.c:359:9:SX1276_RSSI_LoRa	8	static
30
-SX1276.c:366:9:SX1276_RSSI	8	static
14
+SX1276.c:200:6:SX1276_standby	8	static
15
+SX1276.c:205:6:SX1276_sleep	8	static
16
+SX1276.c:210:6:SX1276_entryLoRa	0	static
17
+SX1276.c:147:6:SX1276_config	32	static
18
+SX1276.c:142:6:SX1276_defaultConfig	24	static
19
+SX1276.c:214:6:SX1276_clearLoRaIrq	0	static
20
+SX1276.c:218:5:SX1276_LoRaEntryRx	16	static
21
+SX1276.c:250:9:SX1276_LoRaRxPacket	16	static
22
+SX1276.c:273:5:SX1276_LoRaEntryTx	16	static
23
+SX1276.c:304:5:SX1276_LoRaTxPacket	16	static
24
+SX1276.c:325:6:SX1276_begin	32	static
25
+SX1276.c:337:5:SX1276_transmit	24	static
26
+SX1276.c:345:5:SX1276_receive	0	static
27
+SX1276.c:349:9:SX1276_available	0	static
28
+SX1276.c:353:9:SX1276_read	16	static
29
+SX1276.c:362:9:SX1276_RSSI_LoRa	8	static
30
+SX1276.c:369:9:SX1276_RSSI	8	static

二進制
Debug/Src/main.o


+ 20 - 20
Debug/Src/main.su

@@ -1,20 +1,20 @@
1
-main.c:137:6:HAL_UART_RxCpltCallback	8	static
2
-main.c:182:6:HAL_TIM_PeriodElapsedCallback	0	static
3
-main.c:192:6:LoraDataSendSet	0	static
4
-main.c:195:9:LoraDataSendGet	0	static
5
-main.c:199:6:UartDataRecvSet	0	static
6
-main.c:202:9:UartDataRecvGet	0	static
7
-main.c:205:6:RGB_SensorIDAutoSet	0	static
8
-main.c:208:9:RGB_SensorIDAutoGet	0	static
9
-main.c:212:6:Uart2_Data_Send	0	static
10
-main.c:215:6:Uart1_Data_Send	0	static
11
-main.c:219:5:_write	8	static
12
-main.c:255:6:Uart_dataCheck	24	static
13
-main.c:287:6:RGB_Sensor_PowerOnOff	8	static
14
-main.c:441:6:test_read	24	static
15
-main.c:460:6:Flash_RGB_Data_Write	16	static
16
-main.c:473:6:Flash_write	24	static
17
-main.c:526:6:Flash_InitRead	12	static
18
-main.c:760:6:SystemClock_Config	72	static
19
-main.c:564:5:main	296	static
20
-main.c:1034:6:Error_Handler	0	static
1
+main.c:139:6:HAL_UART_RxCpltCallback	4	static
2
+main.c:184:6:HAL_TIM_PeriodElapsedCallback	0	static
3
+main.c:194:6:LoraDataSendSet	0	static
4
+main.c:197:9:LoraDataSendGet	0	static
5
+main.c:201:6:UartDataRecvSet	0	static
6
+main.c:204:9:UartDataRecvGet	0	static
7
+main.c:207:6:RGB_SensorIDAutoSet	0	static
8
+main.c:210:9:RGB_SensorIDAutoGet	0	static
9
+main.c:214:6:Uart2_Data_Send	0	static
10
+main.c:217:6:Uart1_Data_Send	0	static
11
+main.c:221:5:_write	8	static
12
+main.c:257:6:Uart_dataCheck	24	static
13
+main.c:289:6:RGB_Sensor_PowerOnOff	8	static
14
+main.c:443:6:test_read	24	static
15
+main.c:462:6:Flash_RGB_Data_Write	16	static
16
+main.c:475:6:Flash_write	24	static
17
+main.c:528:6:Flash_InitRead	12	static
18
+main.c:766:6:SystemClock_Config	72	static
19
+main.c:567:5:main	312	static
20
+main.c:1053:6:Error_Handler	0	static

二進制
Debug/Src/stm32f1xx_hal_msp.o


+ 7 - 7
Debug/Src/stm32f1xx_hal_msp.su

@@ -1,7 +1,7 @@
1
-stm32f1xx_hal_msp.c:84:6:HAL_MspInit	8	static
2
-stm32f1xx_hal_msp.c:110:6:HAL_I2C_MspInit	32	static
3
-stm32f1xx_hal_msp.c:146:6:HAL_I2C_MspDeInit	0	static
4
-stm32f1xx_hal_msp.c:176:6:HAL_TIM_Base_MspInit	8	static
5
-stm32f1xx_hal_msp.c:200:6:HAL_TIM_Base_MspDeInit	0	static
6
-stm32f1xx_hal_msp.c:226:6:HAL_UART_MspInit	40	static
7
-stm32f1xx_hal_msp.c:294:6:HAL_UART_MspDeInit	8	static
1
+stm32f1xx_hal_msp.c:85:6:HAL_MspInit	8	static
2
+stm32f1xx_hal_msp.c:111:6:HAL_I2C_MspInit	32	static
3
+stm32f1xx_hal_msp.c:147:6:HAL_I2C_MspDeInit	0	static
4
+stm32f1xx_hal_msp.c:177:6:HAL_TIM_Base_MspInit	8	static
5
+stm32f1xx_hal_msp.c:201:6:HAL_TIM_Base_MspDeInit	0	static
6
+stm32f1xx_hal_msp.c:227:6:HAL_UART_MspInit	48	static
7
+stm32f1xx_hal_msp.c:312:6:HAL_UART_MspDeInit	8	static

二進制
Debug/Src/stm32f1xx_it.o


+ 13 - 12
Debug/Src/stm32f1xx_it.su

@@ -1,12 +1,13 @@
1
-stm32f1xx_it.c:87:6:NMI_Handler	0	static
2
-stm32f1xx_it.c:100:6:HardFault_Handler	0	static
3
-stm32f1xx_it.c:115:6:MemManage_Handler	0	static
4
-stm32f1xx_it.c:130:6:BusFault_Handler	0	static
5
-stm32f1xx_it.c:145:6:UsageFault_Handler	0	static
6
-stm32f1xx_it.c:160:6:SVC_Handler	0	static
7
-stm32f1xx_it.c:173:6:DebugMon_Handler	0	static
8
-stm32f1xx_it.c:186:6:PendSV_Handler	0	static
9
-stm32f1xx_it.c:199:6:SysTick_Handler	0	static
10
-stm32f1xx_it.c:220:6:USART1_IRQHandler	0	static
11
-stm32f1xx_it.c:234:6:USART2_IRQHandler	0	static
12
-stm32f1xx_it.c:248:6:TIM6_IRQHandler	0	static
1
+stm32f1xx_it.c:88:6:NMI_Handler	0	static
2
+stm32f1xx_it.c:101:6:HardFault_Handler	0	static
3
+stm32f1xx_it.c:116:6:MemManage_Handler	0	static
4
+stm32f1xx_it.c:131:6:BusFault_Handler	0	static
5
+stm32f1xx_it.c:146:6:UsageFault_Handler	0	static
6
+stm32f1xx_it.c:161:6:SVC_Handler	0	static
7
+stm32f1xx_it.c:174:6:DebugMon_Handler	0	static
8
+stm32f1xx_it.c:187:6:PendSV_Handler	0	static
9
+stm32f1xx_it.c:200:6:SysTick_Handler	0	static
10
+stm32f1xx_it.c:221:6:DMA1_Channel5_IRQHandler	0	static
11
+stm32f1xx_it.c:235:6:USART1_IRQHandler	0	static
12
+stm32f1xx_it.c:249:6:USART2_IRQHandler	0	static
13
+stm32f1xx_it.c:263:6:TIM6_IRQHandler	0	static

+ 22 - 4
Inc/SX1276.h

@@ -243,7 +243,15 @@ typedef enum{
243
  SX1276_LORA_SF_10		=4,
243
  SX1276_LORA_SF_10		=4,
244
  SX1276_LORA_SF_11		=5,
244
  SX1276_LORA_SF_11		=5,
245
  SX1276_LORA_SF_12		=6,
245
  SX1276_LORA_SF_12		=6,
246
-};
246
+}SX1276_Sf_t;
247
+ typedef enum{
248
+     SX1276_LORA_G1	= 1 ,
249
+     SX1276_LORA_G2	    ,
250
+     SX1276_LORA_G3     ,
251
+     SX1276_LORA_G4     ,
252
+     SX1276_LORA_G5     ,
253
+     SX1276_LORA_G6     ,
254
+}SX1276_Lna_t;
247
 static const uint8_t SX1276_SpreadFactor[7] = { 6, 7, 8, 9, 10, 11, 12 };
255
 static const uint8_t SX1276_SpreadFactor[7] = { 6, 7, 8, 9, 10, 11, 12 };
248
 
256
 
249
 
257
 
@@ -258,7 +266,7 @@ typedef enum{
258
 	SX1276_LORA_BW_125KHZ		,
266
 	SX1276_LORA_BW_125KHZ		,
259
 	SX1276_LORA_BW_250KHZ		,
267
 	SX1276_LORA_BW_250KHZ		,
260
 	SX1276_LORA_BW_500KHZ		,
268
 	SX1276_LORA_BW_500KHZ		,
261
-};
269
+}SX1276_Bw_t;
262
 static const uint8_t SX1276_LoRaBandwidth[10] = { 0, //   7.8KHz,
270
 static const uint8_t SX1276_LoRaBandwidth[10] = { 0, //   7.8KHz,
263
 		1, //  10.4KHz,
271
 		1, //  10.4KHz,
264
 		2, //  15.6KHz,
272
 		2, //  15.6KHz,
@@ -294,6 +302,7 @@ typedef struct {
294
 	uint8_t power;
302
 	uint8_t power;
295
 	uint8_t LoRa_Rate;
303
 	uint8_t LoRa_Rate;
296
 	uint8_t LoRa_BW;
304
 	uint8_t LoRa_BW;
305
+	uint8_t LoRa_Lna;    
297
 	uint8_t packetLength;
306
 	uint8_t packetLength;
298
 
307
 
299
 	SX1276_Status_t status;
308
 	SX1276_Status_t status;
@@ -301,6 +310,15 @@ typedef struct {
301
 	uint8_t rxBuffer[SX1276_MAX_PACKET];
310
 	uint8_t rxBuffer[SX1276_MAX_PACKET];
302
 	uint8_t readBytes;
311
 	uint8_t readBytes;
303
 } SX1276_t;
312
 } SX1276_t;
313
+typedef struct {
314
+	uint8_t frequency;
315
+	uint8_t power;
316
+	uint8_t LoRa_Rate;
317
+	uint8_t LoRa_BW;
318
+	uint8_t LoRa_Lna;    
319
+	uint8_t packetLength;
320
+} Default_SX1276_t;
321
+
304
 
322
 
305
 //hardware
323
 //hardware
306
 __weak void SX1276_hw_init(SX1276_hw_t * hw);
324
 __weak void SX1276_hw_init(SX1276_hw_t * hw);
@@ -322,7 +340,7 @@ void SX1276_SPIBurstWrite(SX1276_t * module, uint8_t addr, uint8_t *txBuf,
322
 void SX1276_DIO0_InterruptHandler(SX1276_t * module);
340
 void SX1276_DIO0_InterruptHandler(SX1276_t * module);
323
 
341
 
324
 void SX1276_config(SX1276_t * module, uint8_t frequency, uint8_t power,
342
 void SX1276_config(SX1276_t * module, uint8_t frequency, uint8_t power,
325
-		uint8_t LoRa_Rate, uint8_t LoRa_BW);
343
+		uint8_t LoRa_Rate, uint8_t LoRa_BW,uint8_t LoRa_Lna);
326
 void SX1276_defaultConfig(SX1276_t * module);
344
 void SX1276_defaultConfig(SX1276_t * module);
327
 
345
 
328
 void SX1276_entryLoRa(SX1276_t * module);
346
 void SX1276_entryLoRa(SX1276_t * module);
@@ -337,7 +355,7 @@ int SX1276_LoRaTxPacket(SX1276_t * module, uint8_t *txBuf, uint8_t length,
337
 		uint32_t timeout);
355
 		uint32_t timeout);
338
 
356
 
339
 void SX1276_begin(SX1276_t * module, uint8_t frequency, uint8_t power,
357
 void SX1276_begin(SX1276_t * module, uint8_t frequency, uint8_t power,
340
-		uint8_t LoRa_Rate, uint8_t LoRa_BW, uint8_t packetLength);
358
+		uint8_t LoRa_Rate, uint8_t LoRa_BW, uint8_t packetLength,uint8_t LoRa_Lna);
341
 
359
 
342
 int SX1276_transmit(SX1276_t * module, uint8_t *txBuf, uint8_t length,
360
 int SX1276_transmit(SX1276_t * module, uint8_t *txBuf, uint8_t length,
343
 		uint32_t timeout);
361
 		uint32_t timeout);

+ 5 - 3
Inc/main.h

@@ -114,6 +114,7 @@ extern uint8_t MyControllerID;
114
 extern uint8_t  SensorID;
114
 extern uint8_t  SensorID;
115
 extern uint8_t Lora_Buf[100];
115
 extern uint8_t Lora_Buf[100];
116
 extern I2C_HandleTypeDef hi2c2;
116
 extern I2C_HandleTypeDef hi2c2;
117
+extern Default_SX1276_t Default_SX1276;
117
 
118
 
118
 typedef enum{
119
 typedef enum{
119
     RGB_Status_Data_Request = 0x01,
120
     RGB_Status_Data_Request = 0x01,
@@ -139,6 +140,7 @@ typedef enum{
139
     RGB_Lora_DataRequest,           //21
140
     RGB_Lora_DataRequest,           //21
140
     RGB_Lora_DataResponse,          //22
141
     RGB_Lora_DataResponse,          //22
141
     RGB_Lora_ConfigSet,             //23
142
     RGB_Lora_ConfigSet,             //23
143
+    RGB_Lora_ConfigGet,             //24    
142
 }RGB_CMD_T;
144
 }RGB_CMD_T;
143
 typedef struct{
145
 typedef struct{
144
     uint8_t Request_stx;
146
     uint8_t Request_stx;
@@ -158,11 +160,11 @@ typedef struct{
158
 #define     Lora_Max_Amount                     5
160
 #define     Lora_Max_Amount                     5
159
 #define     LORA_MAX_DATA_CNT                   Lora_Max_Amount + 3
161
 #define     LORA_MAX_DATA_CNT                   Lora_Max_Amount + 3
160
 
162
 
161
-/*ID ì •ë³´  */
163
+/*ID ? •ë³?  */
162
 
164
 
163
 #define MY_ID_ADDRESS               0x0000
165
 #define MY_ID_ADDRESS               0x0000
164
 
166
 
165
-/*색깔 제한 정보 */
167
+/*?ƒ‰ê¹? ? œ?•œ ? •ë³? */
166
 /*SENSOR 1  ADDRESS*/
168
 /*SENSOR 1  ADDRESS*/
167
 #define RGB1_LIMIT_RED_H_ADDRESS     0x0001
169
 #define RGB1_LIMIT_RED_H_ADDRESS     0x0001
168
 #define RGB1_LIMIT_RED_L_ADDRESS     0x0002
170
 #define RGB1_LIMIT_RED_L_ADDRESS     0x0002
@@ -219,7 +221,7 @@ typedef struct{
219
 #define RGB8_LIMIT_GREEN_L_ADDRESS   0x002E
221
 #define RGB8_LIMIT_GREEN_L_ADDRESS   0x002E
220
 #define RGB8_LIMIT_BLUE_H_ADDRESS    0x002F
222
 #define RGB8_LIMIT_BLUE_H_ADDRESS    0x002F
221
 #define RGB8_LIMIT_BLUE_L_ADDRESS    0x0031
223
 #define RGB8_LIMIT_BLUE_L_ADDRESS    0x0031
222
-/*위치 정보 */
224
+/*?œ„ì¹? ? •ë³? */
223
 #define RGB1_LOCATION_ADDRESS        0x0032
225
 #define RGB1_LOCATION_ADDRESS        0x0032
224
 #define RGB2_LOCATION_ADDRESS        RGB1_LOCATION_ADDRESS + 50
226
 #define RGB2_LOCATION_ADDRESS        RGB1_LOCATION_ADDRESS + 50
225
 #define RGB3_LOCATION_ADDRESS        RGB2_LOCATION_ADDRESS + 50
227
 #define RGB3_LOCATION_ADDRESS        RGB2_LOCATION_ADDRESS + 50

+ 1 - 1
Inc/stm32f1xx_hal_conf.h

@@ -56,7 +56,7 @@
56
 /*#define HAL_CORTEX_MODULE_ENABLED   */
56
 /*#define HAL_CORTEX_MODULE_ENABLED   */
57
 /*#define HAL_CRC_MODULE_ENABLED   */
57
 /*#define HAL_CRC_MODULE_ENABLED   */
58
 /*#define HAL_DAC_MODULE_ENABLED   */
58
 /*#define HAL_DAC_MODULE_ENABLED   */
59
-/*#define HAL_DMA_MODULE_ENABLED   */
59
+#define HAL_DMA_MODULE_ENABLED
60
 /*#define HAL_ETH_MODULE_ENABLED   */
60
 /*#define HAL_ETH_MODULE_ENABLED   */
61
 /*#define HAL_FLASH_MODULE_ENABLED   */
61
 /*#define HAL_FLASH_MODULE_ENABLED   */
62
 #define HAL_GPIO_MODULE_ENABLED
62
 #define HAL_GPIO_MODULE_ENABLED

+ 1 - 0
Inc/stm32f1xx_it.h

@@ -71,6 +71,7 @@ void SVC_Handler(void);
71
 void DebugMon_Handler(void);
71
 void DebugMon_Handler(void);
72
 void PendSV_Handler(void);
72
 void PendSV_Handler(void);
73
 void SysTick_Handler(void);
73
 void SysTick_Handler(void);
74
+void DMA1_Channel5_IRQHandler(void);
74
 void USART1_IRQHandler(void);
75
 void USART1_IRQHandler(void);
75
 void USART2_IRQHandler(void);
76
 void USART2_IRQHandler(void);
76
 void TIM6_IRQHandler(void);
77
 void TIM6_IRQHandler(void);

+ 24 - 11
STM32F103_RGBController.ioc

@@ -1,15 +1,27 @@
1
 #MicroXplorer Configuration settings - do not modify
1
 #MicroXplorer Configuration settings - do not modify
2
+Dma.Request0=USART1_RX
3
+Dma.RequestsNb=1
4
+Dma.USART1_RX.0.Direction=DMA_PERIPH_TO_MEMORY
5
+Dma.USART1_RX.0.Instance=DMA1_Channel5
6
+Dma.USART1_RX.0.MemDataAlignment=DMA_MDATAALIGN_BYTE
7
+Dma.USART1_RX.0.MemInc=DMA_MINC_ENABLE
8
+Dma.USART1_RX.0.Mode=DMA_CIRCULAR
9
+Dma.USART1_RX.0.PeriphDataAlignment=DMA_PDATAALIGN_BYTE
10
+Dma.USART1_RX.0.PeriphInc=DMA_PINC_DISABLE
11
+Dma.USART1_RX.0.Priority=DMA_PRIORITY_LOW
12
+Dma.USART1_RX.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority
2
 File.Version=6
13
 File.Version=6
3
 KeepUserPlacement=false
14
 KeepUserPlacement=false
4
 Mcu.Family=STM32F1
15
 Mcu.Family=STM32F1
5
-Mcu.IP0=I2C2
6
-Mcu.IP1=NVIC
7
-Mcu.IP2=RCC
8
-Mcu.IP3=SYS
9
-Mcu.IP4=TIM6
10
-Mcu.IP5=USART1
11
-Mcu.IP6=USART2
12
-Mcu.IPNb=7
16
+Mcu.IP0=DMA
17
+Mcu.IP1=I2C2
18
+Mcu.IP2=NVIC
19
+Mcu.IP3=RCC
20
+Mcu.IP4=SYS
21
+Mcu.IP5=TIM6
22
+Mcu.IP6=USART1
23
+Mcu.IP7=USART2
24
+Mcu.IPNb=8
13
 Mcu.Name=STM32F103R(C-D-E)Tx
25
 Mcu.Name=STM32F103R(C-D-E)Tx
14
 Mcu.Package=LQFP64
26
 Mcu.Package=LQFP64
15
 Mcu.Pin0=PC15-OSC32_OUT
27
 Mcu.Pin0=PC15-OSC32_OUT
@@ -61,6 +73,7 @@ Mcu.UserName=STM32F103RCTx
61
 MxCube.Version=5.0.1
73
 MxCube.Version=5.0.1
62
 MxDb.Version=DB.5.0.1
74
 MxDb.Version=DB.5.0.1
63
 NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false
75
 NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false
76
+NVIC.DMA1_Channel5_IRQn=true\:0\:0\:false\:true\:true\:1\:false
64
 NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false
77
 NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false
65
 NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false
78
 NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false
66
 NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:false
79
 NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:false
@@ -69,9 +82,9 @@ NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:true\:false
69
 NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4
82
 NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4
70
 NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false
83
 NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false
71
 NVIC.SysTick_IRQn=true\:0\:0\:false\:false\:true\:false
84
 NVIC.SysTick_IRQn=true\:0\:0\:false\:false\:true\:false
72
-NVIC.TIM6_IRQn=true\:0\:0\:false\:true\:true\:3\:true
85
+NVIC.TIM6_IRQn=true\:0\:0\:false\:true\:true\:4\:true
73
 NVIC.USART1_IRQn=true\:0\:0\:false\:true\:true\:2\:true
86
 NVIC.USART1_IRQn=true\:0\:0\:false\:true\:true\:2\:true
74
-NVIC.USART2_IRQn=true\:0\:0\:false\:true\:true\:1\:true
87
+NVIC.USART2_IRQn=true\:0\:0\:false\:true\:true\:3\:true
75
 NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false
88
 NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false
76
 PA10.Mode=Asynchronous
89
 PA10.Mode=Asynchronous
77
 PA10.Signal=USART1_RX
90
 PA10.Signal=USART1_RX
@@ -245,7 +258,7 @@ ProjectManager.StackSize=0x400
245
 ProjectManager.TargetToolchain=TrueSTUDIO
258
 ProjectManager.TargetToolchain=TrueSTUDIO
246
 ProjectManager.ToolChainLocation=
259
 ProjectManager.ToolChainLocation=
247
 ProjectManager.UnderRoot=true
260
 ProjectManager.UnderRoot=true
248
-ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-SystemClock_Config-RCC-false-HAL-false,3-MX_TIM6_Init-TIM6-false-HAL-true,4-MX_USART1_UART_Init-USART1-false-HAL-true,5-MX_USART2_UART_Init-USART2-false-HAL-true,6-MX_I2C2_Init-I2C2-false-HAL-true
261
+ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-MX_DMA_Init-DMA-false-HAL-true,3-SystemClock_Config-RCC-false-HAL-false,4-MX_TIM6_Init-TIM6-false-HAL-true,5-MX_USART1_UART_Init-USART1-false-HAL-true,6-MX_USART2_UART_Init-USART2-false-HAL-true,7-MX_I2C2_Init-I2C2-false-HAL-true
249
 RCC.ADCFreqValue=8000000
262
 RCC.ADCFreqValue=8000000
250
 RCC.AHBFreq_Value=16000000
263
 RCC.AHBFreq_Value=16000000
251
 RCC.APB1CLKDivider=RCC_HCLK_DIV2
264
 RCC.APB1CLKDivider=RCC_HCLK_DIV2

+ 17 - 0
Src/RGB_Controller.c

@@ -39,6 +39,11 @@ void RGB_Data_Init(void){
39
         printf("RGB_SensorGreenLimit_Buf[%d]  :  %04x\n",i,RGB_SensorGreenLimit_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]);    
40
         printf("RGB_SensorBlueLimit_Buf[%d]   :  %04x\n",i,RGB_SensorBlueLimit_Buf[i]);    
41
     }
41
     }
42
+        Default_SX1276.frequency = 
43
+    Default_SX1276.power     = 
44
+    Default_SX1276.LoRa_Rate = 
45
+    Default_SX1276.LoRa_BW   = 
46
+    Default_SX1276.LoRa_Lna  = 
42
 
47
 
43
 }
48
 }
44
 uint16_t RGB_Limit_Address_Check(uint8_t id){
49
 uint16_t RGB_Limit_Address_Check(uint8_t id){
@@ -135,6 +140,12 @@ for(uint8_t i = 0; i < 10; i++){
135
              else
140
              else
136
                  return;
141
                  return;
137
              break;
142
              break;
143
+        case RGB_Lora_ConfigSet:
144
+            M24C32_Data_Write(&hi2c2,&data[bluecell_srcid],RGB_LORA_FREQ_ADDRESS,data[bluecell_length] - 2); // EEPROM Controller ID Save 
145
+            break;
146
+        case RGB_Lora_ConfigGet:
147
+
148
+            break;             
138
          default:break;
149
          default:break;
139
     }
150
     }
140
 }
151
 }
@@ -442,6 +453,12 @@ void RGB_Controller_Func(uint8_t* data){
442
         case RGB_Lora_DataRequest:
453
         case RGB_Lora_DataRequest:
443
             memcpy(&Result_buf[bluecell_stx],&data[bluecell_stx],data[bluecell_length] + 3);
454
             memcpy(&Result_buf[bluecell_stx],&data[bluecell_stx],data[bluecell_length] + 3);
444
             Result_buf[bluecell_type] = RGB_Lora_DataResponse;
455
             Result_buf[bluecell_type] = RGB_Lora_DataResponse;
456
+            break;
457
+        case RGB_Lora_ConfigSet:
458
+            memcpy(&Result_buf[bluecell_stx],&data[bluecell_stx],data[bluecell_length] + 3);
459
+            break;
460
+        case RGB_Lora_ConfigGet:
461
+
445
             break;
462
             break;
446
         default:
463
         default:
447
             break;
464
             break;

+ 12 - 9
Src/SX1276.c

@@ -141,11 +141,11 @@ void SX1276_SPIBurstWrite(SX1276_t * module, uint8_t addr, uint8_t* txBuf,
141
 }
141
 }
142
 void SX1276_defaultConfig(SX1276_t * module) {
142
 void SX1276_defaultConfig(SX1276_t * module) {
143
 	SX1276_config(module, module->frequency, module->power, module->LoRa_Rate,
143
 	SX1276_config(module, module->frequency, module->power, module->LoRa_Rate,
144
-			module->LoRa_BW);
144
+			module->LoRa_BW,module->LoRa_Lna);
145
 }
145
 }
146
 
146
 
147
 void SX1276_config(SX1276_t * module, uint8_t frequency, uint8_t power,
147
 void SX1276_config(SX1276_t * module, uint8_t frequency, uint8_t power,
148
-		uint8_t LoRa_Rate, uint8_t LoRa_BW) {
148
+		uint8_t LoRa_Rate, uint8_t LoRa_BW,uint8_t LoRa_Lna) {
149
 	SX1276_sleep(module); //Change modem mode Must in Sleep mode
149
 	SX1276_sleep(module); //Change modem mode Must in Sleep mode
150
 	SX1276_hw_DelayMs(15);
150
 	SX1276_hw_DelayMs(15);
151
 
151
 
@@ -159,7 +159,9 @@ void SX1276_config(SX1276_t * module, uint8_t frequency, uint8_t power,
159
 	SX1276_SPIWrite(module, LR_RegPaConfig, SX1276_Power[power]); //Setting output power parameter
159
 	SX1276_SPIWrite(module, LR_RegPaConfig, SX1276_Power[power]); //Setting output power parameter
160
 
160
 
161
 	SX1276_SPIWrite(module, LR_RegOcp, 0x0B);			//RegOcp,Close Ocp
161
 	SX1276_SPIWrite(module, LR_RegOcp, 0x0B);			//RegOcp,Close Ocp
162
-	SX1276_SPIWrite(module, LR_RegLna, 0x23);		//RegLNA,High & LNA Enable
162
+//	SX1276_SPIWrite(module, LR_RegLna, 0x20);		//RegLNA,High & LNA Enable
163
+    SX1276_SPIWrite(module, LR_RegLna, LoRa_Lna);       //RegLNA,High & LNA Enable
164
+
163
 	if (SX1276_SpreadFactor[LoRa_Rate] == 6) {	//SFactor=6
165
 	if (SX1276_SpreadFactor[LoRa_Rate] == 6) {	//SFactor=6
164
 		uint8_t tmp;
166
 		uint8_t tmp;
165
 		SX1276_SPIWrite(module,
167
 		SX1276_SPIWrite(module,
@@ -321,13 +323,14 @@ int SX1276_LoRaTxPacket(SX1276_t * module, uint8_t* txBuffer, uint8_t length,
321
 }
323
 }
322
 
324
 
323
 void SX1276_begin(SX1276_t * module, uint8_t frequency, uint8_t power,
325
 void SX1276_begin(SX1276_t * module, uint8_t frequency, uint8_t power,
324
-		uint8_t LoRa_Rate, uint8_t LoRa_BW, uint8_t packetLength) {
326
+		uint8_t LoRa_Rate, uint8_t LoRa_BW, uint8_t packetLength,uint8_t LoRa_Lna) {
325
 	SX1276_hw_init(module->hw);
327
 	SX1276_hw_init(module->hw);
326
-	module->frequency = frequency;
327
-	module->power = power;
328
-	module->LoRa_Rate = LoRa_Rate;
329
-	module->LoRa_BW = LoRa_BW;
330
-	module->packetLength = packetLength;
328
+	module->frequency       = frequency;
329
+	module->power           = power;
330
+	module->LoRa_Rate       = LoRa_Rate;
331
+	module->LoRa_BW         = LoRa_BW;
332
+	module->packetLength    = packetLength;
333
+    module->LoRa_Lna        = LoRa_Lna;
331
 	SX1276_defaultConfig(module);
334
 	SX1276_defaultConfig(module);
332
 }
335
 }
333
 
336
 

+ 60 - 26
Src/main.c

@@ -68,10 +68,11 @@ TIM_HandleTypeDef htim6;
68
 
68
 
69
 UART_HandleTypeDef huart1;
69
 UART_HandleTypeDef huart1;
70
 UART_HandleTypeDef huart2;
70
 UART_HandleTypeDef huart2;
71
+DMA_HandleTypeDef hdma_usart1_rx;
71
 
72
 
72
 /* USER CODE BEGIN PV */
73
 /* USER CODE BEGIN PV */
73
-uint8_t rx1_data[1];
74
-uint8_t rx2_data[1];
74
+uint8_t rx1_data[buf_size];
75
+uint8_t rx2_data[buf_size];
75
 
76
 
76
 
77
 
77
 uint8_t ring_buf[buf_size];
78
 uint8_t ring_buf[buf_size];
@@ -110,6 +111,7 @@ typedef enum{
110
 /* Private function prototypes -----------------------------------------------*/
111
 /* Private function prototypes -----------------------------------------------*/
111
 void SystemClock_Config(void);
112
 void SystemClock_Config(void);
112
 static void MX_GPIO_Init(void);
113
 static void MX_GPIO_Init(void);
114
+static void MX_DMA_Init(void);
113
 static void MX_TIM6_Init(void);
115
 static void MX_TIM6_Init(void);
114
 static void MX_USART1_UART_Init(void);
116
 static void MX_USART1_UART_Init(void);
115
 static void MX_USART2_UART_Init(void);
117
 static void MX_USART2_UART_Init(void);
@@ -149,9 +151,9 @@ void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
149
                 count_in1 = 0;
151
                 count_in1 = 0;
150
         }
152
         }
151
 #endif // PYJ.2019.04.19_END -- 
153
 #endif // PYJ.2019.04.19_END -- 
152
-        HAL_UART_Receive_IT(&huart1,&rx1_data[0],1);
154
+//        HAL_UART_Receive_IT(&huart1,&rx1_data[0],1);
153
     }
155
     }
154
-    if(huart->Instance == USART2) // Lora?? ?†µ?‹ ?•˜?Š� ?�¬?Џ
156
+    if(huart->Instance == USART2) // Lora?? ?? Â???¹Â???¢Ë??Å ?? ?Â�¬?Џ
155
     {
157
     {
156
         buf2[count_in2] = rx2_data[0];//(uint8_t)USART2->DR;
158
         buf2[count_in2] = rx2_data[0];//(uint8_t)USART2->DR;
157
         if(++count_in2>=buf_size){ count_in2 = 0; }
159
         if(++count_in2>=buf_size){ count_in2 = 0; }
@@ -168,7 +170,7 @@ void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
168
         HAL_UART_Receive_IT(&huart2,&rx2_data[0],1);
170
         HAL_UART_Receive_IT(&huart2,&rx2_data[0],1);
169
     }
171
     }
170
 #if 0 // PYJ.2019.04.13_BEGIN -- 
172
 #if 0 // PYJ.2019.04.13_BEGIN -- 
171
-    if(huart->Instance == USART3) //GUI ?? ?†µ?‹ ?•˜?Š� Port
173
+    if(huart->Instance == USART3) //GUI ?? ?? Â???¹Â???¢Ë??Å ?? Port
172
     {
174
     {
173
         buf[count_in3] = rx3_data[0];//(uint8_t)USART2->DR;
175
         buf[count_in3] = rx3_data[0];//(uint8_t)USART2->DR;
174
         if(buf[count_in3++] == 0xEB)UartDataRecvSet(3);
176
         if(buf[count_in3++] == 0xEB)UartDataRecvSet(3);
@@ -402,10 +404,10 @@ void RGB_Sensor_PowerOnOff(uint8_t id){
402
 #define END_ADDR    FLASH_USER + 262144 // 256K
404
 #define END_ADDR    FLASH_USER + 262144 // 256K
403
 //----------------------------------------------------
405
 //----------------------------------------------------
404
 #if 0 // PYJ.2019.03.20_BEGIN -- 
406
 #if 0 // PYJ.2019.03.20_BEGIN -- 
405
-void test_write() // 쓰기함수
407
+void test_write() // ?“°ê¸°í•¨?ˆ˜
406
 {
408
 {
407
 
409
 
408
-    __HAL_RCC_TIM7_CLK_DISABLE(); // 매�타�머를 정지합니다
410
+    __HAL_RCC_TIM7_CLK_DISABLE(); // 매ì�¸???�´ë¨¸ë?? ? •ì§??•©?‹ˆ?‹¤
409
     uint32_t  Address = 0;
411
     uint32_t  Address = 0;
410
     Address = StartAddr;
412
     Address = StartAddr;
411
 //    printf("================First============ \r\n");
413
 //    printf("================First============ \r\n");
@@ -416,10 +418,10 @@ void test_write() // 쓰기함수
416
 //        Address += 4;
418
 //        Address += 4;
417
 //    }  
419
 //    }  
418
 
420
 
419
-//    HAL_FLASH_Unlock(); // lock 풀기
421
+//    HAL_FLASH_Unlock(); // lock ??�
420
 //    HAL_FLASH_Program(FLASH_TYPEPROGRAM_WORD, START_ADDR, (uint32_t)0x12345678); //test
422
 //    HAL_FLASH_Program(FLASH_TYPEPROGRAM_WORD, START_ADDR, (uint32_t)0x12345678); //test
421
-//    HAL_FLASH_Lock(); // lock 잠그기
422
-//    __HAL_RCC_TIM7_CLK_ENABLE(); // 매�타�머를 재시작합니다
423
+//    HAL_FLASH_Lock(); // lock ?ž ê·¸ê¸°
424
+//    __HAL_RCC_TIM7_CLK_ENABLE(); // 매ì�¸???�´ë¨¸ë?? ?ž¬?‹œ?ž‘?•©?‹ˆ?‹¤
423
     Address = StartAddr;
425
     Address = StartAddr;
424
     printf("================Second============ \r\n");
426
     printf("================Second============ \r\n");
425
 
427
 
@@ -438,7 +440,7 @@ void test_write() // 쓰기함수
438
 
440
 
439
 
441
 
440
 #if 1 // PYJ.2019.03.20_BEGIN -- 
442
 #if 1 // PYJ.2019.03.20_BEGIN -- 
441
-void test_read(void) // 쓰기함수
443
+void test_read(void) // ?“°ê¸°í•¨?ˆ˜
442
 {
444
 {
443
     uint32_t Address = 0x08000000;
445
     uint32_t Address = 0x08000000;
444
     uint8_t aa = 0;
446
     uint8_t aa = 0;
@@ -470,7 +472,7 @@ void Flash_RGB_Data_Write(uint32_t Addr,uint8_t* data){
470
     HAL_FLASH_Program(FLASH_TYPEPROGRAM_HALFWORD,Addr + 4 ,   (uint16_t)temp_Blue);
472
     HAL_FLASH_Program(FLASH_TYPEPROGRAM_HALFWORD,Addr + 4 ,   (uint16_t)temp_Blue);
471
 
473
 
472
 }
474
 }
473
-void Flash_write(uint8_t* data) // 쓰기함수
475
+void Flash_write(uint8_t* data) // ?“°ê¸°í•¨?ˆ˜
474
 {
476
 {
475
    
477
    
476
     /*Variable used for Erase procedure*/
478
     /*Variable used for Erase procedure*/
@@ -483,8 +485,8 @@ void Flash_write(uint8_t* data) // 쓰기함수
483
 //    EraseInitStruct.NbPages     = (FLASH_USER_END_ADDR - FLASH_USER_START_ADDR) / FLASH_PAGE_SIZE;
485
 //    EraseInitStruct.NbPages     = (FLASH_USER_END_ADDR - FLASH_USER_START_ADDR) / FLASH_PAGE_SIZE;
484
      Address = START_ADDR;
486
      Address = START_ADDR;
485
 
487
 
486
-    __HAL_RCC_TIM7_CLK_DISABLE(); // 매�타�머를 정지합니다
487
-    HAL_FLASH_Unlock(); // lock 풀기
488
+    __HAL_RCC_TIM7_CLK_DISABLE(); // 매ì�¸???�´ë¨¸ë?? ? •ì§??•©?‹ˆ?‹¤
489
+    HAL_FLASH_Unlock(); // lock ??�
488
 //    if (HAL_FLASHEx_Erase(&EraseInitStruct, &PAGEError) != HAL_OK){
490
 //    if (HAL_FLASHEx_Erase(&EraseInitStruct, &PAGEError) != HAL_OK){
489
 //        printf("Erase Failed \r\n");
491
 //        printf("Erase Failed \r\n");
490
 //    }else{
492
 //    }else{
@@ -519,11 +521,11 @@ void Flash_write(uint8_t* data) // 쓰기함수
519
 
521
 
520
     }
522
     }
521
     Flash_RGB_Data_Write(Address,&data[bluecell_stx]);
523
     Flash_RGB_Data_Write(Address,&data[bluecell_stx]);
522
-    HAL_FLASH_Lock(); // lock 잠그기
523
-    __HAL_RCC_TIM7_CLK_ENABLE(); // 매�타�머를 재시작합니다
524
+    HAL_FLASH_Lock(); // lock ?ž ê·¸ê¸°
525
+    __HAL_RCC_TIM7_CLK_ENABLE(); // 매ì�¸???�´ë¨¸ë?? ?ž¬?‹œ?ž‘?•©?‹ˆ?‹¤
524
 
526
 
525
 }
527
 }
526
-void Flash_InitRead(void) // 쓰기함수
528
+void Flash_InitRead(void) // ?“°ê¸°í•¨?ˆ˜
527
 {
529
 {
528
     uint32_t  Address = 0;
530
     uint32_t  Address = 0;
529
     Address = StartAddr;
531
     Address = StartAddr;
@@ -546,6 +548,16 @@ void Flash_InitRead(void) // 쓰기함수
546
 
548
 
547
 SX1276_hw_t SX1276_hw;
549
 SX1276_hw_t SX1276_hw;
548
 SX1276_t SX1276;
550
 SX1276_t SX1276;
551
+Default_SX1276_t Default_SX1276 = 
552
+{
553
+    SX1276_917MHZ,
554
+    SX1276_POWER_17DBM,
555
+    SX1276_LORA_SF_8,
556
+    SX1276_LORA_BW_20_8KHZ,
557
+    10,
558
+    SX1276_LORA_G1,
559
+};
560
+
549
 
561
 
550
 int master;
562
 int master;
551
 int ret;
563
 int ret;
@@ -555,6 +567,12 @@ char buffer[100];
555
 int message_length;
567
 int message_length;
556
 int message;
568
 int message;
557
 
569
 
570
+
571
+
572
+
573
+
574
+
575
+
558
 /* USER CODE END 0 */
576
 /* USER CODE END 0 */
559
 
577
 
560
 /**
578
 /**
@@ -588,6 +606,7 @@ int main(void)
588
 
606
 
589
   /* Initialize all configured peripherals */
607
   /* Initialize all configured peripherals */
590
   MX_GPIO_Init();
608
   MX_GPIO_Init();
609
+  MX_DMA_Init();
591
   MX_TIM6_Init();
610
   MX_TIM6_Init();
592
   MX_USART1_UART_Init();
611
   MX_USART1_UART_Init();
593
   MX_USART2_UART_Init();
612
   MX_USART2_UART_Init();
@@ -597,9 +616,9 @@ int main(void)
597
   MX_NVIC_Init();
616
   MX_NVIC_Init();
598
   /* USER CODE BEGIN 2 */
617
   /* USER CODE BEGIN 2 */
599
   HAL_TIM_Base_Start_IT(&htim6);
618
   HAL_TIM_Base_Start_IT(&htim6);
600
-  HAL_UART_Receive_IT(&huart1, &rx1_data[0],1);
619
+  HAL_UART_Receive_DMA(&huart1, rx1_data, 1);
601
   HAL_UART_Receive_IT(&huart2, &rx2_data[0],1);
620
   HAL_UART_Receive_IT(&huart2, &rx2_data[0],1);
602
-  setbuf(stdout, NULL); // \n � �� 떄만 
621
+  setbuf(stdout, NULL); // \n ?�„ ? �?�„ ?–„ë§? 
603
 #if 1 // PYJ.2019.03.04_BEGIN -- 
622
 #if 1 // PYJ.2019.03.04_BEGIN -- 
604
       printf("****************************************\r\n");
623
       printf("****************************************\r\n");
605
       printf("RGB Project\r\n");
624
       printf("RGB Project\r\n");
@@ -623,9 +642,12 @@ int main(void)
623
    SX1276_hw.reset.pin = SX1276_RESET_Pin;
642
    SX1276_hw.reset.pin = SX1276_RESET_Pin;
624
   // SX1276_hw.spi = &hspi3;
643
   // SX1276_hw.spi = &hspi3;
625
    SX1276.hw = &SX1276_hw;
644
    SX1276.hw = &SX1276_hw;
645
+
646
+
647
+    
626
    printf("Configuring LoRa module\r\n");
648
    printf("Configuring LoRa module\r\n");
627
-   SX1276_begin(&SX1276, SX1276_917MHZ, SX1276_POWER_17DBM, SX1276_LORA_SF_8,
628
-           SX1276_LORA_BW_20_8KHZ, 10);
649
+   SX1276_begin(&SX1276, Default_SX1276.frequency, Default_SX1276.power, Default_SX1276.LoRa_Rate,
650
+           Default_SX1276.LoRa_BW, 10,Default_SX1276.LoRa_Lna);
629
    printf("Done configuring LoRaModule\r\n");
651
    printf("Done configuring LoRaModule\r\n");
630
    master = 0;
652
    master = 0;
631
    if (master == 1) {
653
    if (master == 1) {
@@ -730,9 +752,8 @@ int main(void)
730
                     SensorID = 0;
752
                     SensorID = 0;
731
                 }else{
753
                 }else{
732
                     RGB_Sensor_PowerOnOff(IDAutoSetRequest_data[4]);
754
                     RGB_Sensor_PowerOnOff(IDAutoSetRequest_data[4]);
733
-                    HAL_Delay(450);
755
+                    HAL_Delay(75);
734
                     RGB_Controller_Func(&IDAutoSetRequest_data[bluecell_stx]);
756
                     RGB_Controller_Func(&IDAutoSetRequest_data[bluecell_stx]);
735
-                    HAL_Delay(450);
736
                 }
757
                 }
737
             }
758
             }
738
             else{
759
             else{
@@ -796,12 +817,15 @@ void SystemClock_Config(void)
796
   */
817
   */
797
 static void MX_NVIC_Init(void)
818
 static void MX_NVIC_Init(void)
798
 {
819
 {
799
-  /* USART2_IRQn interrupt configuration */
800
-  HAL_NVIC_SetPriority(USART2_IRQn, 0, 0);
801
-  HAL_NVIC_EnableIRQ(USART2_IRQn);
820
+  /* DMA1_Channel5_IRQn interrupt configuration */
821
+  HAL_NVIC_SetPriority(DMA1_Channel5_IRQn, 0, 0);
822
+  HAL_NVIC_EnableIRQ(DMA1_Channel5_IRQn);
802
   /* USART1_IRQn interrupt configuration */
823
   /* USART1_IRQn interrupt configuration */
803
   HAL_NVIC_SetPriority(USART1_IRQn, 0, 0);
824
   HAL_NVIC_SetPriority(USART1_IRQn, 0, 0);
804
   HAL_NVIC_EnableIRQ(USART1_IRQn);
825
   HAL_NVIC_EnableIRQ(USART1_IRQn);
826
+  /* USART2_IRQn interrupt configuration */
827
+  HAL_NVIC_SetPriority(USART2_IRQn, 0, 0);
828
+  HAL_NVIC_EnableIRQ(USART2_IRQn);
805
   /* TIM6_IRQn interrupt configuration */
829
   /* TIM6_IRQn interrupt configuration */
806
   HAL_NVIC_SetPriority(TIM6_IRQn, 0, 0);
830
   HAL_NVIC_SetPriority(TIM6_IRQn, 0, 0);
807
   HAL_NVIC_EnableIRQ(TIM6_IRQn);
831
   HAL_NVIC_EnableIRQ(TIM6_IRQn);
@@ -945,6 +969,16 @@ static void MX_USART2_UART_Init(void)
945
 
969
 
946
 }
970
 }
947
 
971
 
972
+/** 
973
+  * Enable DMA controller clock
974
+  */
975
+static void MX_DMA_Init(void) 
976
+{
977
+  /* DMA controller clock enable */
978
+  __HAL_RCC_DMA1_CLK_ENABLE();
979
+
980
+}
981
+
948
 /**
982
 /**
949
   * @brief GPIO Initialization Function
983
   * @brief GPIO Initialization Function
950
   * @param None
984
   * @param None

+ 21 - 0
Src/stm32f1xx_hal_msp.c

@@ -44,6 +44,7 @@
44
 /* USER CODE BEGIN Includes */
44
 /* USER CODE BEGIN Includes */
45
 
45
 
46
 /* USER CODE END Includes */
46
 /* USER CODE END Includes */
47
+extern DMA_HandleTypeDef hdma_usart1_rx;
47
 
48
 
48
 /* Private typedef -----------------------------------------------------------*/
49
 /* Private typedef -----------------------------------------------------------*/
49
 /* USER CODE BEGIN TD */
50
 /* USER CODE BEGIN TD */
@@ -250,6 +251,23 @@ void HAL_UART_MspInit(UART_HandleTypeDef* huart)
250
     GPIO_InitStruct.Pull = GPIO_NOPULL;
251
     GPIO_InitStruct.Pull = GPIO_NOPULL;
251
     HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
252
     HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
252
 
253
 
254
+    /* USART1 DMA Init */
255
+    /* USART1_RX Init */
256
+    hdma_usart1_rx.Instance = DMA1_Channel5;
257
+    hdma_usart1_rx.Init.Direction = DMA_PERIPH_TO_MEMORY;
258
+    hdma_usart1_rx.Init.PeriphInc = DMA_PINC_DISABLE;
259
+    hdma_usart1_rx.Init.MemInc = DMA_MINC_ENABLE;
260
+    hdma_usart1_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
261
+    hdma_usart1_rx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
262
+    hdma_usart1_rx.Init.Mode = DMA_CIRCULAR;
263
+    hdma_usart1_rx.Init.Priority = DMA_PRIORITY_LOW;
264
+    if (HAL_DMA_Init(&hdma_usart1_rx) != HAL_OK)
265
+    {
266
+      Error_Handler();
267
+    }
268
+
269
+    __HAL_LINKDMA(huart,hdmarx,hdma_usart1_rx);
270
+
253
   /* USER CODE BEGIN USART1_MspInit 1 */
271
   /* USER CODE BEGIN USART1_MspInit 1 */
254
 
272
 
255
   /* USER CODE END USART1_MspInit 1 */
273
   /* USER CODE END USART1_MspInit 1 */
@@ -308,6 +326,9 @@ void HAL_UART_MspDeInit(UART_HandleTypeDef* huart)
308
     */
326
     */
309
     HAL_GPIO_DeInit(GPIOA, GPIO_PIN_9|GPIO_PIN_10);
327
     HAL_GPIO_DeInit(GPIOA, GPIO_PIN_9|GPIO_PIN_10);
310
 
328
 
329
+    /* USART1 DMA DeInit */
330
+    HAL_DMA_DeInit(huart->hdmarx);
331
+
311
     /* USART1 interrupt DeInit */
332
     /* USART1 interrupt DeInit */
312
     HAL_NVIC_DisableIRQ(USART1_IRQn);
333
     HAL_NVIC_DisableIRQ(USART1_IRQn);
313
   /* USER CODE BEGIN USART1_MspDeInit 1 */
334
   /* USER CODE BEGIN USART1_MspDeInit 1 */

+ 15 - 0
Src/stm32f1xx_it.c

@@ -72,6 +72,7 @@
72
 
72
 
73
 /* External variables --------------------------------------------------------*/
73
 /* External variables --------------------------------------------------------*/
74
 extern TIM_HandleTypeDef htim6;
74
 extern TIM_HandleTypeDef htim6;
75
+extern DMA_HandleTypeDef hdma_usart1_rx;
75
 extern UART_HandleTypeDef huart1;
76
 extern UART_HandleTypeDef huart1;
76
 extern UART_HandleTypeDef huart2;
77
 extern UART_HandleTypeDef huart2;
77
 /* USER CODE BEGIN EV */
78
 /* USER CODE BEGIN EV */
@@ -214,6 +215,20 @@ void SysTick_Handler(void)
214
 /* please refer to the startup file (startup_stm32f1xx.s).                    */
215
 /* please refer to the startup file (startup_stm32f1xx.s).                    */
215
 /******************************************************************************/
216
 /******************************************************************************/
216
 
217
 
218
+/**
219
+  * @brief This function handles DMA1 channel5 global interrupt.
220
+  */
221
+void DMA1_Channel5_IRQHandler(void)
222
+{
223
+  /* USER CODE BEGIN DMA1_Channel5_IRQn 0 */
224
+
225
+  /* USER CODE END DMA1_Channel5_IRQn 0 */
226
+  HAL_DMA_IRQHandler(&hdma_usart1_rx);
227
+  /* USER CODE BEGIN DMA1_Channel5_IRQn 1 */
228
+
229
+  /* USER CODE END DMA1_Channel5_IRQn 1 */
230
+}
231
+
217
 /**
232
 /**
218
   * @brief This function handles USART1 global interrupt.
233
   * @brief This function handles USART1 global interrupt.
219
   */
234
   */