Quellcode durchsuchen

Uart 추가 / adc 추가 /crc 추가 /neslab operate 추가

PYJ vor 4 Jahren
Ursprung
Commit
3af55a338f
100 geänderte Dateien mit 15798 neuen und 9846 gelöschten Zeilen
  1. 3 0
      .cproject
  2. 36 11
      Bluecell_Inc/NessLab.h
  3. 2 2
      Bluecell_Inc/adc.h
  4. 6 1
      Bluecell_Inc/crc.h
  5. 59 11
      Bluecell_Src/NessLab.c
  6. 62 11
      Bluecell_Src/adc.c
  7. 27 1
      Bluecell_Src/crc.c
  8. 13 7
      Bluecell_Src/uart.c
  9. 7 1
      Debug/Bluecell_Src/NessLab.d
  10. BIN
      Debug/Bluecell_Src/NessLab.o
  11. 5 1
      Debug/Bluecell_Src/NessLab.su
  12. 4 1
      Debug/Bluecell_Src/adc.d
  13. BIN
      Debug/Bluecell_Src/adc.o
  14. 4 3
      Debug/Bluecell_Src/adc.su
  15. BIN
      Debug/Bluecell_Src/crc.o
  16. 11 9
      Debug/Bluecell_Src/crc.su
  17. BIN
      Debug/Bluecell_Src/led.o
  18. 5 2
      Debug/Bluecell_Src/uart.d
  19. BIN
      Debug/Bluecell_Src/uart.o
  20. 6 6
      Debug/Bluecell_Src/uart.su
  21. BIN
      Debug/Nesslab_200M_System.bin
  22. BIN
      Debug/Nesslab_200M_System.elf
  23. 12663 8791
      Debug/Nesslab_200M_System.list
  24. 1218 906
      Debug/Nesslab_200M_System.map
  25. BIN
      Debug/Src/main.o
  26. 7 7
      Debug/Src/main.su
  27. BIN
      Debug/Src/stm32f1xx_hal_msp.o
  28. 5 5
      Debug/Src/stm32f1xx_hal_msp.su
  29. BIN
      Debug/Src/stm32f1xx_it.o
  30. 1 1
      Debug/makefile
  31. 17 7
      Inc/main.h
  32. 51 30
      Nesslab_200M_System.ioc
  33. 22 27
      Src/main.c
  34. 2 4
      Src/stm32f1xx_hal_msp.c
  35. 76 0
      insight/Nesslab_200M_System.si4project/Backup/NessLab(1113).h
  36. 55 0
      insight/Nesslab_200M_System.si4project/Backup/NessLab(1970).c
  37. 55 0
      insight/Nesslab_200M_System.si4project/Backup/NessLab(2530).c
  38. 68 0
      insight/Nesslab_200M_System.si4project/Backup/NessLab(4175).c
  39. 60 0
      insight/Nesslab_200M_System.si4project/Backup/NessLab(5969).c
  40. 57 0
      insight/Nesslab_200M_System.si4project/Backup/NessLab(6033).c
  41. 75 0
      insight/Nesslab_200M_System.si4project/Backup/NessLab(6167).c
  42. 75 0
      insight/Nesslab_200M_System.si4project/Backup/NessLab(6997).c
  43. 41 0
      insight/Nesslab_200M_System.si4project/Backup/NessLab(7138).c
  44. 80 0
      insight/Nesslab_200M_System.si4project/Backup/NessLab(7731).h
  45. 76 0
      insight/Nesslab_200M_System.si4project/Backup/NessLab(985).h
  46. 59 0
      insight/Nesslab_200M_System.si4project/Backup/adc(3877).c
  47. 19 0
      insight/Nesslab_200M_System.si4project/Backup/adc(3912).h
  48. 87 0
      insight/Nesslab_200M_System.si4project/Backup/adc(700).c
  49. 27 0
      insight/Nesslab_200M_System.si4project/Backup/crc(1936).h
  50. 25 0
      insight/Nesslab_200M_System.si4project/Backup/crc(518).h
  51. 25 0
      insight/Nesslab_200M_System.si4project/Backup/crc(5317).h
  52. 287 0
      insight/Nesslab_200M_System.si4project/Backup/crc(7234).c
  53. 106 0
      insight/Nesslab_200M_System.si4project/Backup/main(6098).h
  54. 43 0
      insight/Nesslab_200M_System.si4project/Backup/uart(6859).h
  55. 149 0
      insight/Nesslab_200M_System.si4project/Backup/uart(7653).c
  56. 2 0
      insight/Nesslab_200M_System.si4project/Nesslab_200M_System.SearchResults
  57. 7 0
      insight/Nesslab_200M_System.si4project/Nesslab_200M_System.bookmarks.xml
  58. BIN
      insight/Nesslab_200M_System.si4project/Nesslab_200M_System.sip_sym
  59. BIN
      insight/Nesslab_200M_System.si4project/Nesslab_200M_System.sip_xab
  60. BIN
      insight/Nesslab_200M_System.si4project/Nesslab_200M_System.sip_xad
  61. BIN
      insight/Nesslab_200M_System.si4project/Nesslab_200M_System.sip_xc
  62. BIN
      insight/Nesslab_200M_System.si4project/Nesslab_200M_System.sip_xf
  63. BIN
      insight/Nesslab_200M_System.si4project/Nesslab_200M_System.sip_xm
  64. BIN
      insight/Nesslab_200M_System.si4project/Nesslab_200M_System.sip_xr
  65. BIN
      insight/Nesslab_200M_System.si4project/Nesslab_200M_System.sip_xsb
  66. BIN
      insight/Nesslab_200M_System.si4project/Nesslab_200M_System.sip_xsd
  67. BIN
      insight/Nesslab_200M_System.si4project/Nesslab_200M_System.siproj
  68. 1 1
      insight/Nesslab_200M_System.si4project/Nesslab_200M_System.siproj_settings.xml
  69. BIN
      insight/Nesslab_200M_System.si4project/Nesslab_200M_System.siwork
  70. 7 0
      insight/Nesslab_200M_System.si4project/Nesslab_200M_System.snippets.xml
  71. BIN
      insight/Nesslab_200M_System.si4project/cache/parse/.._Bluecell_Inc_NessLab.h.sisc
  72. BIN
      insight/Nesslab_200M_System.si4project/cache/parse/.._Bluecell_Inc_adc.h.sisc
  73. BIN
      insight/Nesslab_200M_System.si4project/cache/parse/.._Bluecell_Inc_crc.h.sisc
  74. BIN
      insight/Nesslab_200M_System.si4project/cache/parse/.._Bluecell_Inc_led.h.sisc
  75. BIN
      insight/Nesslab_200M_System.si4project/cache/parse/.._Bluecell_Inc_uart.h.sisc
  76. BIN
      insight/Nesslab_200M_System.si4project/cache/parse/.._Bluecell_Src_NessLab.c.sisc
  77. BIN
      insight/Nesslab_200M_System.si4project/cache/parse/.._Bluecell_Src_adc.c.sisc
  78. BIN
      insight/Nesslab_200M_System.si4project/cache/parse/.._Bluecell_Src_crc.c.sisc
  79. BIN
      insight/Nesslab_200M_System.si4project/cache/parse/.._Bluecell_Src_led.c.sisc
  80. BIN
      insight/Nesslab_200M_System.si4project/cache/parse/.._Bluecell_Src_uart.c.sisc
  81. BIN
      insight/Nesslab_200M_System.si4project/cache/parse/.._Drivers_CMSIS_Device_ST_STM32F1xx_Include_stm32f100xb.h.sisc
  82. BIN
      insight/Nesslab_200M_System.si4project/cache/parse/.._Drivers_CMSIS_Device_ST_STM32F1xx_Include_stm32f1xx.h.sisc
  83. BIN
      insight/Nesslab_200M_System.si4project/cache/parse/.._Drivers_CMSIS_Device_ST_STM32F1xx_Include_system_stm32f1xx.h.sisc
  84. BIN
      insight/Nesslab_200M_System.si4project/cache/parse/.._Drivers_CMSIS_Include_cmsis_armcc.h.sisc
  85. BIN
      insight/Nesslab_200M_System.si4project/cache/parse/.._Drivers_CMSIS_Include_cmsis_armclang.h.sisc
  86. BIN
      insight/Nesslab_200M_System.si4project/cache/parse/.._Drivers_CMSIS_Include_cmsis_compiler.h.sisc
  87. BIN
      insight/Nesslab_200M_System.si4project/cache/parse/.._Drivers_CMSIS_Include_cmsis_gcc.h.sisc
  88. BIN
      insight/Nesslab_200M_System.si4project/cache/parse/.._Drivers_CMSIS_Include_cmsis_iccarm.h.sisc
  89. BIN
      insight/Nesslab_200M_System.si4project/cache/parse/.._Drivers_CMSIS_Include_cmsis_version.h.sisc
  90. BIN
      insight/Nesslab_200M_System.si4project/cache/parse/.._Drivers_CMSIS_Include_core_armv8mbl.h.sisc
  91. BIN
      insight/Nesslab_200M_System.si4project/cache/parse/.._Drivers_CMSIS_Include_core_armv8mml.h.sisc
  92. BIN
      insight/Nesslab_200M_System.si4project/cache/parse/.._Drivers_CMSIS_Include_core_cm0.h.sisc
  93. BIN
      insight/Nesslab_200M_System.si4project/cache/parse/.._Drivers_CMSIS_Include_core_cm0plus.h.sisc
  94. BIN
      insight/Nesslab_200M_System.si4project/cache/parse/.._Drivers_CMSIS_Include_core_cm1.h.sisc
  95. BIN
      insight/Nesslab_200M_System.si4project/cache/parse/.._Drivers_CMSIS_Include_core_cm23.h.sisc
  96. BIN
      insight/Nesslab_200M_System.si4project/cache/parse/.._Drivers_CMSIS_Include_core_cm3.h.sisc
  97. BIN
      insight/Nesslab_200M_System.si4project/cache/parse/.._Drivers_CMSIS_Include_core_cm33.h.sisc
  98. BIN
      insight/Nesslab_200M_System.si4project/cache/parse/.._Drivers_CMSIS_Include_core_cm4.h.sisc
  99. BIN
      insight/Nesslab_200M_System.si4project/cache/parse/.._Drivers_CMSIS_Include_core_cm7.h.sisc
  100. 0 0
      insight/Nesslab_200M_System.si4project/cache/parse/.._Drivers_CMSIS_Include_core_sc000.h.sisc

+ 3 - 0
.cproject

@@ -53,6 +53,9 @@
53 53
 							</tool>
54 54
 							<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.34253181" name="MCU GCC Linker" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker">
55 55
 								<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.option.script.1886648493" name="Linker Script (-T)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.option.script" useByScannerDiscovery="false" value="${workspace_loc:/${ProjName}/STM32F100C8TX_FLASH.ld}" valueType="string"/>
56
+								<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.option.otherflags.1315147050" name="Other flags" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.option.otherflags" useByScannerDiscovery="false" valueType="stringList">
57
+									<listOptionValue builtIn="false" value="-u_printf_float"/>
58
+								</option>
56 59
 								<inputType id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.input.711468543" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.input">
57 60
 									<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
58 61
 									<additionalInput kind="additionalinput" paths="$(LIBS)"/>

+ 36 - 11
Bluecell_Inc/NessLab.h

@@ -11,12 +11,17 @@
11 11
 #include "main.h"
12 12
 
13 13
 typedef struct{
14
+	uint8_t Header0;
15
+	uint8_t Header1;
16
+	uint8_t MsgId;
17
+	uint8_t MsgSn0;
18
+	uint8_t MsgSn1;
19
+	uint8_t MsgReserve0;
20
+	uint8_t MsgDataLength;
14 21
 	uint8_t DownLink_Forward_Det_H;
15 22
 	uint8_t DownLink_Forward_Det_L;
16 23
 	uint8_t DownLink_Reverse_Det_H;
17 24
 	uint8_t DownLink_Reverse_Det_L;
18
-	uint8_t Gate_Enable;
19
-	uint8_t Reset;
20 25
 	uint8_t DC_Fail_Alarm;
21 26
 	uint8_t Downlink_Status;
22 27
 	uint8_t Over_Power_Alarm;
@@ -25,20 +30,22 @@ typedef struct{
25 30
 	uint8_t Over_Temp_Alarm;
26 31
 	uint8_t Temp_Monitor;
27 32
 	uint8_t ALC_Alarm;
28
-	uint8_t Reserve0;
29
-	uint8_t Reserve1;
33
+	uint8_t Checksum;
34
+	uint8_t Tail0;
35
+	uint8_t Tail1;
30 36
 }Nesslab_Prot;
31 37
 
32 38
 
33 39
 typedef enum{
34
-	NessLab_GATE_ENABLE_SET_REQ,
35
-	NessLab_GATE_ENABLE_SET_RES,
36
-	NessLab_RESET_SET_REQ,
37
-	NessLab_RESET_SET_RES,
38
-	NessLab_DOWNLINK_SET_REQ,
39
-	NessLab_DOWNLINK_SET_RES,
40
+	NessLab_STATUS_REQ = 101,
41
+	NessLab_STATUS_RES,
40 42
 }NessLabDataType_t;
41 43
 
44
+typedef enum{
45
+	NessLab_DownLink_Tx,
46
+	NessLab_DownLink_Rx,
47
+	NessLab_Temperature,
48
+}Adc_Index_t;
42 49
 typedef enum{
43 50
 	NessLab_Header0,
44 51
 	NessLab_Header1,
@@ -47,7 +54,25 @@ typedef enum{
47 54
 	NessLab_MsgSN1,
48 55
 	NessLab_Reserve0,
49 56
 	NessLab_DataLength,
50
-	NessLab_Data,
57
+	NessLab_Data_ADC0_H,
58
+	NessLab_Data_ADC0_L,
59
+	NessLab_Data_ADC1_H,
60
+	NessLab_Data_ADC1_L,
61
+	DC_FAIL_ALARM,
62
+	NessLab_DownLink_Status,
63
+	NessLab_Over_Power_Alarm,
64
+	NessLab_VSWR_ALARM,
65
+	NessLab_Over_Input_Alarm,
66
+	NessLab_Over_Temp_Alarm,
67
+	NessLab_Temp_Monitor,
68
+	NessLab_ALC_ALARM,
69
+	NessLab_ChecksumVal,
70
+	NessLab_Tail0,
71
+	NessLab_Tail1,	
72
+
51 73
 }NessLabProtIndex_t;
74
+
75
+
76
+extern void NessLab_Operate(uint8_t* data);
52 77
 #endif /* NESSLAB_H_ */
53 78
 

+ 2 - 2
Bluecell_Inc/adc.h

@@ -14,6 +14,6 @@ void ADC_Initialize();
14 14
 void ADC_Check();
15 15
 
16 16
 
17
-#define ADC1_CNT 4
18
-#define ADC_AVERAGECNT 100
17
+#define ADC1_CNT 3
18
+//#define ADC_AVERAGECNT 100
19 19
 #endif /* ADC_H_ */

+ 6 - 1
Bluecell_Inc/crc.h

@@ -8,8 +8,8 @@
8 8
 #ifndef CRC_H_
9 9
 #define CRC_H_
10 10
 
11
+#include <stdbool.h>
11 12
 #include "main.h"
12
-
13 13
 typedef enum{
14 14
     CHECKSUM_ERROR = 0,
15 15
     NO_ERROR
@@ -19,5 +19,10 @@ uint16_t CRC16_Generate(uint8_t* buf_ptr, int len);
19 19
 etError CRC16_Check(uint8_t* buf_ptr, int len,uint16_t checksum);
20 20
 uint8_t STH30_CreateCrc(uint8_t *data, uint8_t nbrOfBytes);
21 21
 etError STH30_CheckCrc(uint8_t *data, uint8_t nbrOfBytes, uint8_t checksum);
22
+uint8_t NessLab_Checksum(uint8_t *data,uint8_t size);
23
+bool NessLab_CheckSum_Check(uint8_t* data,uint8_t size,uint8_t checksum);
24
+
25
+
26
+
22 27
 #define POLYNOMIAL 0x131 // P(x) = x^8 + x^5 + x^4 + 1 = 100110001
23 28
 #endif /* CRC_H_ */

+ 59 - 11
Bluecell_Src/NessLab.c

@@ -8,22 +8,70 @@
8 8
 
9 9
 #include "main.h"
10 10
 #include "NessLab.h"
11
-
11
+#include "adc.h"
12
+#include "crc.h"
13
+//extern uint8_t NessLab_Checksum(uint8_t* data,uint8_t size);
12 14
 Nesslab_Prot Currstatus;
15
+uint8_t data_Tx[50] = {0,};
16
+extern volatile uint16_t ADC1value[ADC1_CNT];
13 17
 
14
-void NessLab(uint8_t* data){
15
-	NessLabDataType_t datatype = data[NessLab_MsgID0];
18
+void NessLab_Operate(uint8_t* data){
19
+	uint8_t datatype = data[NessLab_MsgID0];
16 20
 
17 21
 	switch(datatype){
18
-		case NessLab_GATE_ENABLE_SET_REQ:
19
-			HAL_GPIO_WritePin(GATE_TDD_OUTPUT_GPIO_Port, GATE_TDD_OUTPUT_Pin, data[NessLab_Data]);
20
-			break;
21
-		case NessLab_RESET_SET_REQ:
22
-			HAL_GPIO_WritePinP(PAU_RESET_GPIO_Port, PAU_RESET_Pin, data[NessLab_Data]);
23
-			break;
24
-		case NessLab_DOWNLINK_SET_REQ:
25
-			HAL_GPIO_WritePin(AMP_EN_GPIO_Port, AMP_EN_Pin, data[NessLab_Data]);
22
+		case NessLab_STATUS_REQ:
23
+			ADC_Check();
26 24
 			break;
25
+
26
+
27 27
 	}
28
+    NessLab_Frame_Set(data,12);
29
+    Uart1_Data_Send(&data, 30);
30
+
31
+
32
+}
33
+
28 34
 
35
+
36
+void NessLab_Frame_Set(uint8_t* data,uint8_t size){
37
+    data[NessLab_Header0] = 0x7E;
38
+    data[NessLab_Header1] = 0x7E;
39
+
40
+    data[NessLab_MsgID0] = NessLab_STATUS_RES;// ID
41
+    data[NessLab_MsgSN0] = 0; // SEQ NUMBER
42
+    data[NessLab_MsgSN1] = 0; // SEQ NUMBER   
43
+    data[NessLab_Reserve0] = 0; // NessLab_Reserve0
44
+    data[NessLab_DataLength] = size; // Nesslab Size
45
+//    data[NessLab_Data_ADC0_H] = 12; // (uint8_t)((ADC1value & 0xFF00) >> 8);
46
+//    data[NessLab_Data_ADC0_L] = 34; // (uint8_t)(ADC1value & 0x00FF);
47
+    data[NessLab_Data_ADC0_H] = (uint8_t)((ADC1value & 0xFF00) >> 8);
48
+    data[NessLab_Data_ADC0_L] = (uint8_t)(ADC1value & 0x00FF);
49
+
50
+    data[NessLab_Data_ADC1_H] = 00;
51
+    data[NessLab_Data_ADC1_L] = 00;
52
+    data[DC_FAIL_ALARM] = 11;
53
+    data[NessLab_DownLink_Status] = 22;
54
+    data[NessLab_Over_Power_Alarm] = 33;
55
+    data[NessLab_VSWR_ALARM] = 44;
56
+    data[NessLab_Over_Input_Alarm] = 55;
57
+    data[NessLab_Over_Temp_Alarm] = 66;
58
+    data[NessLab_Temp_Monitor] = 77;
59
+    data[NessLab_ALC_ALARM] = 88;
60
+    data[NessLab_ChecksumVal] = NessLab_Checksum(0, 17);
61
+    /* Exception Header Tail Checksum */
62
+    data[NessLab_Tail0] = 0x7E;
63
+    data[NessLab_Tail0] = 0x7E; 
29 64
 }
65
+
66
+
67
+void NessLab_Status_Check(){
68
+	//HAL_GPIO_ReadPin(, GPIO_Pin)
69
+}
70
+void NessLab_PAU_Enable(){
71
+	HAL_GPIO_WritePin(AMP_EN_GPIO_Port,AMP_EN_Pin, HAL_GPIO_ReadPin(PAU_EN_GPIO_Port, PAU_EN_Pin));
72
+	//HAL_GPIO_WritePin(AMP_EN_GPIO_Port,AMP_EN_Pin, HAL_GPIO_ReadPin(PAU_RESET_GPIO_Port, PAU_RESET_Pin));
73
+}
74
+void NessLab_GPIO_Operate(){
75
+	NessLab_PAU_Enable();
76
+}
77
+

+ 62 - 11
Bluecell_Src/adc.c

@@ -1,4 +1,4 @@
1
-/*
1
+ /*
2 2
  * adc.c
3 3
  *
4 4
  *  Created on: 2020. 8. 3.
@@ -6,31 +6,82 @@
6 6
  */
7 7
 #include "main.h"
8 8
 #include "adc.h"
9
+#include "NessLab.h"
10
+
11
+
9 12
 extern ADC_HandleTypeDef hadc1;
10 13
 extern DMA_HandleTypeDef hdma_adc1;
14
+extern Nesslab_Prot Currstatus;
11 15
 
12 16
 
13
-volatile uint16_t ADC1valuearray[ADC1_CNT][ADC_AVERAGECNT];
17
+//volatile uint16_t ADC1valuearray[ADC1_CNT][ADC_AVERAGECNT];
14 18
 volatile uint16_t ADC1value[ADC1_CNT];
15 19
 uint16_t adc1cnt = 0 ;
16 20
 
21
+/*
22
+ *
23
+ * ADC 0 :DL TX
24
+ * ADC 1 :DL RX
25
+ * ADC 2 :TEMP
26
+ * */
27
+
28
+void ADC_Value_Get(){
29
+	uint16_t CalcRet = 0 ;
30
+
31
+	/*DL TX Calc*/
32
+	Currstatus.DownLink_Forward_Det_H = ((ADC1value[0] & 0xFF00) >> 8);
33
+	Currstatus.DownLink_Forward_Det_L = (ADC1value[0] & 0x00FF);
34
+
35
+	/*DL RX Calc*/
36
+	Currstatus.DownLink_Reverse_Det_H = ((ADC1value[1] & 0xFF00) >> 8);
37
+	Currstatus.DownLink_Reverse_Det_L = (ADC1value[1] & 0x00FF);
38
+
39
+	/*Temp Calc*/
40
+	Currstatus.Temp_Monitor = ((ADC1value[1] & 0xFF00) >> 8);
41
+
42
+
43
+}
17 44
 void ADC_Initialize(){
18 45
 	while(!(HAL_ADCEx_Calibration_Start(&hadc1)==HAL_OK));
19
-	HAL_ADC_Start_DMA(&hadc1, (uint16_t*)ADC1value,(uint32_t) 4);
46
+	HAL_ADC_Start_DMA(&hadc1, (uint16_t*)ADC1value,(uint32_t) 3);
20 47
 }
21
-void ADC_Check(){
22
-
23 48
 
49
+void ADC_Check(){
50
+    double tempval = 0;
51
+    for(int i = 0 ; i < ADC1_CNT; i++){
52
+        tempval = (ADC1value[i] * (3.3 / 4095)) * 100;
53
+        printf("ADC1value[%d] : %f \r\n",i,tempval);
54
+    }
55
+//    Currstatus.DownLink_Forward_Det_H
56
+//        = ((ADC1value[0] & 0xFF00) >> 8);
57
+//    Currstatus.DownLink_Forward_Det_L
58
+//        = ((ADC1value[0] & 0x00FF) );
59
+//
60
+//    Currstatus.DownLink_Reverse_Det_H
61
+//        = ((ADC1value[0] & 0xFF00) >> 8);
62
+//    Currstatus.DownLink_Reverse_Det_L
63
+//        = ((ADC1value[0] & 0x00FF) );
64
+//
65
+//    Currstatus.DC_Level_Det_H
66
+//        = ((ADC1value[0] & 0xFF00) >> 8);
67
+//    Currstatus.DC_Level_Det_L
68
+//        = ((ADC1value[0] & 0x00FF) );
69
+//
70
+//    Currstatus.Temp_Monitor
71
+//        = ((ADC1value[0] & 0xFF00) >> 8);
72
+//    Currstatus.Temp_Monitor
73
+//        = ((ADC1value[0] & 0x00FF) );  
74
+    adc1cnt = 0;
24 75
 }
25 76
 void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc)
26 77
 {
27 78
     if(hadc->Instance == hadc1.Instance)
28 79
     {
29
-        if(adc1cnt < ADC_AVERAGECNT){
30
-            for(int i = 0; i < 4; i++){
31
-                ADC1valuearray[i][adc1cnt] = ADC1value[i];
32
-            }
33
-            adc1cnt++;
34
-        }
80
+//        if(adc1cnt < ADC_AVERAGECNT){
81
+//            for(int i = 0; i < ADC1_CNT; i++){
82
+//                ADC1valuearray[i][adc1cnt] = ADC1value[i];
83
+//            }
84
+//            adc1cnt++;
85
+//        }
35 86
     }
36 87
 }

+ 27 - 1
Bluecell_Src/crc.c

@@ -10,6 +10,7 @@
10 10
 /*---------------------------------------------------------------------------------------*/
11 11
 #include <stdio.h>						
12 12
 #include <stdint.h>	
13
+#include <stdbool.h>
13 14
 #include "crc.h"
14 15
 #include "uart.h"
15 16
 const uint16_t crc16_tab[256] = {				
@@ -257,5 +258,30 @@ etError crc32Check(uint32_t checksum,uint32_t crc, const void *buf, size_t size)
257 258
     crcret ^ ~0U;		
258 259
 
259 260
     return (crcret == checksum ? CHECKSUM_ERROR : NO_ERROR);
260
-}							
261
+}
262
+uint8_t NessLab_Checksum(uint8_t *data,uint8_t size){
263
+	uint8_t ret = 0;
264
+	for(int i = 0; i < size; i++){
265
+		ret += data[i];
266
+	}
267
+
268
+	ret = (~ret) + 1;
269
+	return ret;
270
+}
271
+bool NessLab_CheckSum_Check(uint8_t* data,uint8_t size,uint8_t checksum){
272
+	uint8_t dataret = 0;
273
+	bool ret = false;
274
+
275
+	for(int i = 0; i < size; i++){
276
+		dataret += data[i];
277
+	}
278
+
279
+	dataret = (~dataret) + 1;
280
+	if(dataret != checksum){
281
+		ret = false;
282
+	}else{
283
+		ret = true;
284
+	}
285
+	return ret;
286
+}
261 287
 

+ 13 - 7
Bluecell_Src/uart.c

@@ -10,17 +10,21 @@
10 10
 #include "string.h"
11 11
 
12 12
 
13
-#include "uart.h"
14 13
 #include "crc.h"
14
+#include "uart.h"
15
+#include "NessLab.h"
15 16
 
17
+extern void NessLab_Operate(uint8_t* data);
16 18
 
17 19
 UARTQUEUE TerminalQueue;
18 20
 UARTQUEUE WifiQueue;
19 21
 uart_hal_tx_type uart_hal_tx;
20 22
 extern volatile uint32_t UartRxTimerCnt;
23
+uint8_t uart_buf[QUEUE_BUFFER_LENGTH];
21 24
 
22 25
 extern bool Bluecell_Operate(uint8_t* data);
23 26
 extern void MBIC_Operate(uint8_t * data);
27
+extern bool NessLab_CheckSum_Check(uint8_t* data,uint8_t size,uint8_t checksum);
24 28
 
25 29
 void InitUartQueue(pUARTQUEUE pQueue)
26 30
 {
@@ -62,7 +66,6 @@ void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
62 66
 }
63 67
 
64 68
 
65
-
66 69
 void PutDataToUartQueue(UART_HandleTypeDef *huart, uint8_t data)
67 70
 {
68 71
     pUARTQUEUE pQueue = &TerminalQueue;
@@ -74,14 +77,15 @@ void PutDataToUartQueue(UART_HandleTypeDef *huart, uint8_t data)
74 77
    // HAL_UART_Receive_DMA(&hTerminal,  pQueue->Buffer + pQueue->head, 10);
75 78
 }
76 79
 
77
-volatile uint8_t uart_buf[QUEUE_BUFFER_LENGTH];
80
+
78 81
 void GetDataFromUartQueue(UART_HandleTypeDef *huart)
79 82
 {
80 83
     volatile static int cnt;
81
-    bool chksumret = 0;
84
+    bool ret = 0;
85
+ /*   bool chksumret = 0;
82 86
     uint16_t Length = 0;
83 87
     uint16_t CrcChk = 0;
84
-    UART_HandleTypeDef *dst = (huart->Instance == USART2 ? &hTest:&hTerminal);
88
+    UART_HandleTypeDef *dst = (huart->Instance == USART2 ? &hTest:&hTerminal);*/
85 89
 //    UART_HandleTypeDef *dst = &hTerminal;
86 90
     pUARTQUEUE pQueue = &TerminalQueue;
87 91
 //    if (HAL_UART_Transmit(dst, pQueue->Buffer + pQueue->tail, 1, 3000) != HAL_OK)
@@ -109,10 +113,12 @@ void GetDataFromUartQueue(UART_HandleTypeDef *huart)
109 113
             }
110 114
             printf(ANSI_COLOR_GREEN"\r\n CNT : %d \r\n"ANSI_COLOR_RESET,cnt);
111 115
 #endif // PYJ.2019.07.15_END --
116
+        ret = NessLab_CheckSum_Check(&uart_buf[NessLab_MsgID0],uart_buf[NessLab_DataLength],uart_buf[NessLab_ChecksumVal]);
117
+        if(ret == true){
118
+			NessLab_Operate(&uart_buf[0]);
119
+        }
112 120
 		cnt = 0;
113
-//        HAL_Delay(1);
114 121
     }
115
-
116 122
 }
117 123
 void Uart_Check(void){
118 124
   while (TerminalQueue.data > 0 && UartRxTimerCnt > 50) GetDataFromUartQueue(&hTerminal);

+ 7 - 1
Debug/Bluecell_Src/NessLab.d

@@ -25,7 +25,9 @@ Bluecell_Src/NessLab.o: ../Bluecell_Src/NessLab.c ../Inc/main.h \
25 25
  ../Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_tim.h \
26 26
  ../Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_tim_ex.h \
27 27
  ../Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_uart.h \
28
- D:/CubeIDE_Workspace/Nesslab_200M_System/Bluecell_Inc/NessLab.h
28
+ D:/CubeIDE_Workspace/Nesslab_200M_System/Bluecell_Inc/NessLab.h \
29
+ D:/CubeIDE_Workspace/Nesslab_200M_System/Bluecell_Inc/adc.h \
30
+ D:/CubeIDE_Workspace/Nesslab_200M_System/Bluecell_Inc/crc.h
29 31
 
30 32
 ../Inc/main.h:
31 33
 
@@ -82,3 +84,7 @@ Bluecell_Src/NessLab.o: ../Bluecell_Src/NessLab.c ../Inc/main.h \
82 84
 ../Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_uart.h:
83 85
 
84 86
 D:/CubeIDE_Workspace/Nesslab_200M_System/Bluecell_Inc/NessLab.h:
87
+
88
+D:/CubeIDE_Workspace/Nesslab_200M_System/Bluecell_Inc/adc.h:
89
+
90
+D:/CubeIDE_Workspace/Nesslab_200M_System/Bluecell_Inc/crc.h:

BIN
Debug/Bluecell_Src/NessLab.o


+ 5 - 1
Debug/Bluecell_Src/NessLab.su

@@ -1 +1,5 @@
1
-NessLab.c:14:6:NessLab	24	static
1
+NessLab.c:19:6:NessLab_Operate	24	static
2
+NessLab.c:37:6:NessLab_Frame_Set	24	static
3
+NessLab.c:65:6:NessLab_Status_Check	4	static
4
+NessLab.c:68:6:NessLab_PAU_Enable	8	static
5
+NessLab.c:72:6:NessLab_GPIO_Operate	8	static

+ 4 - 1
Debug/Bluecell_Src/adc.d

@@ -25,7 +25,8 @@ Bluecell_Src/adc.o: ../Bluecell_Src/adc.c ../Inc/main.h \
25 25
  ../Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_tim.h \
26 26
  ../Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_tim_ex.h \
27 27
  ../Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_uart.h \
28
- D:/CubeIDE_Workspace/Nesslab_200M_System/Bluecell_Inc/adc.h
28
+ D:/CubeIDE_Workspace/Nesslab_200M_System/Bluecell_Inc/adc.h \
29
+ D:/CubeIDE_Workspace/Nesslab_200M_System/Bluecell_Inc/NessLab.h
29 30
 
30 31
 ../Inc/main.h:
31 32
 
@@ -82,3 +83,5 @@ Bluecell_Src/adc.o: ../Bluecell_Src/adc.c ../Inc/main.h \
82 83
 ../Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_uart.h:
83 84
 
84 85
 D:/CubeIDE_Workspace/Nesslab_200M_System/Bluecell_Inc/adc.h:
86
+
87
+D:/CubeIDE_Workspace/Nesslab_200M_System/Bluecell_Inc/NessLab.h:

BIN
Debug/Bluecell_Src/adc.o


+ 4 - 3
Debug/Bluecell_Src/adc.su

@@ -1,3 +1,4 @@
1
-adc.c:17:6:ADC_Initialize	8	static
2
-adc.c:21:6:ADC_Check	4	static
3
-adc.c:25:6:HAL_ADC_ConvCpltCallback	24	static
1
+adc.c:28:6:ADC_Value_Get	16	static
2
+adc.c:44:6:ADC_Initialize	8	static
3
+adc.c:49:6:ADC_Check	32	static
4
+adc.c:76:6:HAL_ADC_ConvCpltCallback	16	static

BIN
Debug/Bluecell_Src/crc.o


+ 11 - 9
Debug/Bluecell_Src/crc.su

@@ -1,9 +1,11 @@
1
-crc.c:100:16:genCRC16	24	static
2
-crc.c:134:9:STH30_CreateCrc	24	static
3
-crc.c:152:9:STH30_CheckCrc	24	static
4
-crc.c:176:6:Chksum_Check	32	static
5
-crc.c:189:9:Chksum_Create	24	static
6
-crc.c:203:9:CRC16_Check	32	static
7
-crc.c:217:10:CRC16_Generate	32	static
8
-crc.c:231:10:crc32	24	static
9
-crc.c:245:9:crc32Check	32	static
1
+crc.c:101:16:genCRC16	24	static
2
+crc.c:135:9:STH30_CreateCrc	24	static
3
+crc.c:153:9:STH30_CheckCrc	24	static
4
+crc.c:177:6:Chksum_Check	32	static
5
+crc.c:190:9:Chksum_Create	24	static
6
+crc.c:204:9:CRC16_Check	32	static
7
+crc.c:218:10:CRC16_Generate	32	static
8
+crc.c:232:10:crc32	24	static
9
+crc.c:246:9:crc32Check	32	static
10
+crc.c:262:9:NessLab_Checksum	24	static
11
+crc.c:271:6:NessLab_CheckSum_Check	24	static

BIN
Debug/Bluecell_Src/led.o


+ 5 - 2
Debug/Bluecell_Src/uart.d

@@ -25,8 +25,9 @@ Bluecell_Src/uart.o: ../Bluecell_Src/uart.c ../Inc/main.h \
25 25
  ../Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_tim.h \
26 26
  ../Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_tim_ex.h \
27 27
  ../Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_uart.h \
28
+ D:/CubeIDE_Workspace/Nesslab_200M_System/Bluecell_Inc/crc.h \
28 29
  D:/CubeIDE_Workspace/Nesslab_200M_System/Bluecell_Inc/uart.h \
29
- D:/CubeIDE_Workspace/Nesslab_200M_System/Bluecell_Inc/crc.h
30
+ D:/CubeIDE_Workspace/Nesslab_200M_System/Bluecell_Inc/NessLab.h
30 31
 
31 32
 ../Inc/main.h:
32 33
 
@@ -82,6 +83,8 @@ Bluecell_Src/uart.o: ../Bluecell_Src/uart.c ../Inc/main.h \
82 83
 
83 84
 ../Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_uart.h:
84 85
 
86
+D:/CubeIDE_Workspace/Nesslab_200M_System/Bluecell_Inc/crc.h:
87
+
85 88
 D:/CubeIDE_Workspace/Nesslab_200M_System/Bluecell_Inc/uart.h:
86 89
 
87
-D:/CubeIDE_Workspace/Nesslab_200M_System/Bluecell_Inc/crc.h:
90
+D:/CubeIDE_Workspace/Nesslab_200M_System/Bluecell_Inc/NessLab.h:

BIN
Debug/Bluecell_Src/uart.o


+ 6 - 6
Debug/Bluecell_Src/uart.su

@@ -1,6 +1,6 @@
1
-uart.c:25:6:InitUartQueue	16	static
2
-uart.c:46:6:HAL_UART_RxCpltCallback	24	static
3
-uart.c:66:6:PutDataToUartQueue	24	static
4
-uart.c:78:6:GetDataFromUartQueue	32	static
5
-uart.c:117:6:Uart_Check	8	static
6
-uart.c:122:6:Uart1_Data_Send	16	static
1
+uart.c:29:6:InitUartQueue	16	static
2
+uart.c:50:6:HAL_UART_RxCpltCallback	24	static
3
+uart.c:69:6:PutDataToUartQueue	24	static
4
+uart.c:81:6:GetDataFromUartQueue	24	static
5
+uart.c:123:6:Uart_Check	8	static
6
+uart.c:128:6:Uart1_Data_Send	16	static

BIN
Debug/Nesslab_200M_System.bin


BIN
Debug/Nesslab_200M_System.elf


Datei-Diff unterdrückt, da er zu groß ist
+ 12663 - 8791
Debug/Nesslab_200M_System.list


Datei-Diff unterdrückt, da er zu groß ist
+ 1218 - 906
Debug/Nesslab_200M_System.map


BIN
Debug/Src/main.o


+ 7 - 7
Debug/Src/main.su

@@ -2,10 +2,10 @@ main.c:87:5:main	8	static
2 2
 main.c:153:6:SystemClock_Config	80	static
3 3
 main.c:196:13:MX_NVIC_Init	8	static
4 4
 main.c:223:13:MX_ADC1_Init	24	static
5
-main.c:292:13:MX_TIM6_Init	16	static
6
-main.c:330:13:MX_USART1_UART_Init	8	static
7
-main.c:363:13:MX_USART3_UART_Init	8	static
8
-main.c:394:13:MX_DMA_Init	16	static
9
-main.c:412:13:MX_GPIO_Init	40	static
10
-main.c:474:6:HAL_TIM_PeriodElapsedCallback	16	static
11
-main.c:494:6:Error_Handler	4	static
5
+main.c:284:13:MX_TIM6_Init	16	static
6
+main.c:322:13:MX_USART1_UART_Init	8	static
7
+main.c:355:13:MX_USART3_UART_Init	8	static
8
+main.c:386:13:MX_DMA_Init	16	static
9
+main.c:404:13:MX_GPIO_Init	40	static
10
+main.c:469:6:HAL_TIM_PeriodElapsedCallback	16	static
11
+main.c:489:6:Error_Handler	4	static

BIN
Debug/Src/stm32f1xx_hal_msp.o


+ 5 - 5
Debug/Src/stm32f1xx_hal_msp.su

@@ -1,7 +1,7 @@
1 1
 stm32f1xx_hal_msp.c:69:6:HAL_MspInit	24	static
2 2
 stm32f1xx_hal_msp.c:95:6:HAL_ADC_MspInit	40	static
3
-stm32f1xx_hal_msp.c:147:6:HAL_ADC_MspDeInit	16	static
4
-stm32f1xx_hal_msp.c:183:6:HAL_TIM_Base_MspInit	24	static
5
-stm32f1xx_hal_msp.c:205:6:HAL_TIM_Base_MspDeInit	16	static
6
-stm32f1xx_hal_msp.c:230:6:HAL_UART_MspInit	48	static
7
-stm32f1xx_hal_msp.c:330:6:HAL_UART_MspDeInit	16	static
3
+stm32f1xx_hal_msp.c:146:6:HAL_ADC_MspDeInit	16	static
4
+stm32f1xx_hal_msp.c:181:6:HAL_TIM_Base_MspInit	24	static
5
+stm32f1xx_hal_msp.c:203:6:HAL_TIM_Base_MspDeInit	16	static
6
+stm32f1xx_hal_msp.c:228:6:HAL_UART_MspInit	48	static
7
+stm32f1xx_hal_msp.c:328:6:HAL_UART_MspDeInit	16	static

BIN
Debug/Src/stm32f1xx_it.o


+ 1 - 1
Debug/makefile

@@ -42,7 +42,7 @@ all: Nesslab_200M_System.elf secondary-outputs
42 42
 
43 43
 # Tool invocations
44 44
 Nesslab_200M_System.elf: $(OBJS) $(USER_OBJS) D:\CubeIDE_Workspace\Nesslab_200M_System\STM32F100C8TX_FLASH.ld
45
-	arm-none-eabi-gcc -o "Nesslab_200M_System.elf" @"objects.list" $(USER_OBJS) $(LIBS) -mcpu=cortex-m3 -T"D:\CubeIDE_Workspace\Nesslab_200M_System\STM32F100C8TX_FLASH.ld" --specs=nosys.specs -Wl,-Map="Nesslab_200M_System.map" -Wl,--gc-sections -static --specs=nano.specs -mfloat-abi=soft -mthumb -Wl,--start-group -lc -lm -Wl,--end-group
45
+	arm-none-eabi-gcc -o "Nesslab_200M_System.elf" @"objects.list" $(USER_OBJS) $(LIBS) -mcpu=cortex-m3 -T"D:\CubeIDE_Workspace\Nesslab_200M_System\STM32F100C8TX_FLASH.ld" --specs=nosys.specs -Wl,-Map="Nesslab_200M_System.map" -Wl,--gc-sections -static -u_printf_float --specs=nano.specs -mfloat-abi=soft -mthumb -Wl,--start-group -lc -lm -Wl,--end-group
46 46
 	@echo 'Finished building target: $@'
47 47
 	@echo ' '
48 48
 

+ 17 - 7
Inc/main.h

@@ -32,7 +32,7 @@ extern "C" {
32 32
 
33 33
 /* Private includes ----------------------------------------------------------*/
34 34
 /* USER CODE BEGIN Includes */
35
-
35
+#include <stdint.h>
36 36
 /* USER CODE END Includes */
37 37
 
38 38
 /* Exported types ------------------------------------------------------------*/
@@ -65,24 +65,34 @@ void Error_Handler(void);
65 65
 #define DL_TX_DET_GPIO_Port GPIOA
66 66
 #define DL_RX_DET_Pin GPIO_PIN_1
67 67
 #define DL_RX_DET_GPIO_Port GPIOA
68
-#define DC_LEVEL_DET_Pin GPIO_PIN_2
69
-#define DC_LEVEL_DET_GPIO_Port GPIOA
68
+#define DC_FAIL_ALARM_Pin GPIO_PIN_2
69
+#define DC_FAIL_ALARM_GPIO_Port GPIOA
70 70
 #define PAU_TEMP_Pin GPIO_PIN_3
71 71
 #define PAU_TEMP_GPIO_Port GPIOA
72
+#define PAU_RESERVED0_Pin GPIO_PIN_6
73
+#define PAU_RESERVED0_GPIO_Port GPIOA
74
+#define PAU_RESERVED1_Pin GPIO_PIN_7
75
+#define PAU_RESERVED1_GPIO_Port GPIOA
72 76
 #define PAU_RESERVED3_Pin GPIO_PIN_0
73 77
 #define PAU_RESERVED3_GPIO_Port GPIOB
74 78
 #define PAU_RESERVED2_Pin GPIO_PIN_1
75 79
 #define PAU_RESERVED2_GPIO_Port GPIOB
76
-#define GATE_TDD_INPUT_Pin GPIO_PIN_12
77
-#define GATE_TDD_INPUT_GPIO_Port GPIOB
78
-#define GATE_TDD_OUTPUT_Pin GPIO_PIN_13
79
-#define GATE_TDD_OUTPUT_GPIO_Port GPIOB
80
+#define OVER_POWER_ALARM_Pin GPIO_PIN_12
81
+#define OVER_POWER_ALARM_GPIO_Port GPIOB
82
+#define VSWR_ALARM_Pin GPIO_PIN_13
83
+#define VSWR_ALARM_GPIO_Port GPIOB
80 84
 #define PAU_RESET_Pin GPIO_PIN_14
81 85
 #define PAU_RESET_GPIO_Port GPIOB
82 86
 #define PAU_EN_Pin GPIO_PIN_15
83 87
 #define PAU_EN_GPIO_Port GPIOB
84 88
 #define AMP_EN_Pin GPIO_PIN_8
85 89
 #define AMP_EN_GPIO_Port GPIOA
90
+#define OVER_INPUT_ALARM_Pin GPIO_PIN_11
91
+#define OVER_INPUT_ALARM_GPIO_Port GPIOA
92
+#define OVER_TEMP_ALARM_Pin GPIO_PIN_12
93
+#define OVER_TEMP_ALARM_GPIO_Port GPIOA
94
+#define ALC_ALARM_Pin GPIO_PIN_3
95
+#define ALC_ALARM_GPIO_Port GPIOB
86 96
 /* USER CODE BEGIN Private defines */
87 97
 
88 98
 /* USER CODE END Private defines */

Datei-Diff unterdrückt, da er zu groß ist
+ 51 - 30
Nesslab_200M_System.ioc


+ 22 - 27
Src/main.c

@@ -240,7 +240,7 @@ static void MX_ADC1_Init(void)
240 240
   hadc1.Init.DiscontinuousConvMode = DISABLE;
241 241
   hadc1.Init.ExternalTrigConv = ADC_SOFTWARE_START;
242 242
   hadc1.Init.DataAlign = ADC_DATAALIGN_RIGHT;
243
-  hadc1.Init.NbrOfConversion = 4;
243
+  hadc1.Init.NbrOfConversion = 3;
244 244
   if (HAL_ADC_Init(&hadc1) != HAL_OK)
245 245
   {
246 246
     Error_Handler();
@@ -264,16 +264,8 @@ static void MX_ADC1_Init(void)
264 264
   }
265 265
   /** Configure Regular Channel 
266 266
   */
267
-  sConfig.Channel = ADC_CHANNEL_2;
268
-  sConfig.Rank = ADC_REGULAR_RANK_3;
269
-  if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
270
-  {
271
-    Error_Handler();
272
-  }
273
-  /** Configure Regular Channel 
274
-  */
275 267
   sConfig.Channel = ADC_CHANNEL_3;
276
-  sConfig.Rank = ADC_REGULAR_RANK_4;
268
+  sConfig.Rank = ADC_REGULAR_RANK_3;
277 269
   if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
278 270
   {
279 271
     Error_Handler();
@@ -422,11 +414,10 @@ static void MX_GPIO_Init(void)
422 414
   HAL_GPIO_WritePin(BOOT_LED_GPIO_Port, BOOT_LED_Pin, GPIO_PIN_RESET);
423 415
 
424 416
   /*Configure GPIO pin Output Level */
425
-  HAL_GPIO_WritePin(GPIOB, PAU_RESERVED3_Pin|PAU_RESERVED2_Pin|GATE_TDD_OUTPUT_Pin|PAU_RESET_Pin 
426
-                          |PAU_EN_Pin, GPIO_PIN_RESET);
417
+  HAL_GPIO_WritePin(GPIOA, PAU_RESERVED0_Pin|PAU_RESERVED1_Pin|AMP_EN_Pin, GPIO_PIN_RESET);
427 418
 
428 419
   /*Configure GPIO pin Output Level */
429
-  HAL_GPIO_WritePin(AMP_EN_GPIO_Port, AMP_EN_Pin, GPIO_PIN_RESET);
420
+  HAL_GPIO_WritePin(GPIOB, PAU_RESERVED3_Pin|PAU_RESERVED2_Pin|PAU_RESET_Pin, GPIO_PIN_RESET);
430 421
 
431 422
   /*Configure GPIO pin : BOOT_LED_Pin */
432 423
   GPIO_InitStruct.Pin = BOOT_LED_Pin;
@@ -435,27 +426,31 @@ static void MX_GPIO_Init(void)
435 426
   GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
436 427
   HAL_GPIO_Init(BOOT_LED_GPIO_Port, &GPIO_InitStruct);
437 428
 
438
-  /*Configure GPIO pins : PAU_RESERVED3_Pin PAU_RESERVED2_Pin GATE_TDD_OUTPUT_Pin PAU_RESET_Pin 
439
-                           PAU_EN_Pin */
440
-  GPIO_InitStruct.Pin = PAU_RESERVED3_Pin|PAU_RESERVED2_Pin|GATE_TDD_OUTPUT_Pin|PAU_RESET_Pin 
441
-                          |PAU_EN_Pin;
442
-  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
429
+  /*Configure GPIO pins : DC_FAIL_ALARM_Pin OVER_INPUT_ALARM_Pin OVER_TEMP_ALARM_Pin */
430
+  GPIO_InitStruct.Pin = DC_FAIL_ALARM_Pin|OVER_INPUT_ALARM_Pin|OVER_TEMP_ALARM_Pin;
431
+  GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
443 432
   GPIO_InitStruct.Pull = GPIO_NOPULL;
444
-  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
445
-  HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
433
+  HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
446 434
 
447
-  /*Configure GPIO pin : GATE_TDD_INPUT_Pin */
448
-  GPIO_InitStruct.Pin = GATE_TDD_INPUT_Pin;
449
-  GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
435
+  /*Configure GPIO pins : PAU_RESERVED0_Pin PAU_RESERVED1_Pin AMP_EN_Pin */
436
+  GPIO_InitStruct.Pin = PAU_RESERVED0_Pin|PAU_RESERVED1_Pin|AMP_EN_Pin;
437
+  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
450 438
   GPIO_InitStruct.Pull = GPIO_NOPULL;
451
-  HAL_GPIO_Init(GATE_TDD_INPUT_GPIO_Port, &GPIO_InitStruct);
439
+  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
440
+  HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
452 441
 
453
-  /*Configure GPIO pin : AMP_EN_Pin */
454
-  GPIO_InitStruct.Pin = AMP_EN_Pin;
442
+  /*Configure GPIO pins : PAU_RESERVED3_Pin PAU_RESERVED2_Pin PAU_RESET_Pin */
443
+  GPIO_InitStruct.Pin = PAU_RESERVED3_Pin|PAU_RESERVED2_Pin|PAU_RESET_Pin;
455 444
   GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
456 445
   GPIO_InitStruct.Pull = GPIO_NOPULL;
457 446
   GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
458
-  HAL_GPIO_Init(AMP_EN_GPIO_Port, &GPIO_InitStruct);
447
+  HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
448
+
449
+  /*Configure GPIO pins : OVER_POWER_ALARM_Pin VSWR_ALARM_Pin PAU_EN_Pin ALC_ALARM_Pin */
450
+  GPIO_InitStruct.Pin = OVER_POWER_ALARM_Pin|VSWR_ALARM_Pin|PAU_EN_Pin|ALC_ALARM_Pin;
451
+  GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
452
+  GPIO_InitStruct.Pull = GPIO_NOPULL;
453
+  HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
459 454
 
460 455
 }
461 456
 

+ 2 - 4
Src/stm32f1xx_hal_msp.c

@@ -107,10 +107,9 @@ void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc)
107 107
     /**ADC1 GPIO Configuration    
108 108
     PA0-WKUP     ------> ADC1_IN0
109 109
     PA1     ------> ADC1_IN1
110
-    PA2     ------> ADC1_IN2
111 110
     PA3     ------> ADC1_IN3 
112 111
     */
113
-    GPIO_InitStruct.Pin = DL_TX_DET_Pin|DL_RX_DET_Pin|DC_LEVEL_DET_Pin|PAU_TEMP_Pin;
112
+    GPIO_InitStruct.Pin = DL_TX_DET_Pin|DL_RX_DET_Pin|PAU_TEMP_Pin;
114 113
     GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
115 114
     HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
116 115
 
@@ -157,10 +156,9 @@ void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc)
157 156
     /**ADC1 GPIO Configuration    
158 157
     PA0-WKUP     ------> ADC1_IN0
159 158
     PA1     ------> ADC1_IN1
160
-    PA2     ------> ADC1_IN2
161 159
     PA3     ------> ADC1_IN3 
162 160
     */
163
-    HAL_GPIO_DeInit(GPIOA, DL_TX_DET_Pin|DL_RX_DET_Pin|DC_LEVEL_DET_Pin|PAU_TEMP_Pin);
161
+    HAL_GPIO_DeInit(GPIOA, DL_TX_DET_Pin|DL_RX_DET_Pin|PAU_TEMP_Pin);
164 162
 
165 163
     /* ADC1 DMA DeInit */
166 164
     HAL_DMA_DeInit(hadc->DMA_Handle);

+ 76 - 0
insight/Nesslab_200M_System.si4project/Backup/NessLab(1113).h

@@ -0,0 +1,76 @@
1
+/*
2
+ * NessLab.h
3
+ *
4
+ *  Created on: Aug 3, 2020
5
+ *      Author: parkyj
6
+ */
7
+
8
+#ifndef NESSLAB_H_
9
+#define NESSLAB_H_
10
+
11
+#include "main.h"
12
+
13
+typedef struct{
14
+	uint8_t Header0;
15
+	uint8_t Header1;
16
+	uint8_t MsgId;
17
+	uint8_t MsgSn0;
18
+	uint8_t MsgSn1;
19
+	uint8_t MsgReserve0;
20
+	uint8_t MsgDataLength;
21
+	uint8_t DownLink_Forward_Det_H;
22
+	uint8_t DownLink_Forward_Det_L;
23
+	uint8_t DownLink_Reverse_Det_H;
24
+	uint8_t DownLink_Reverse_Det_L;
25
+	uint8_t DC_Fail_Alarm;
26
+	uint8_t Downlink_Status;
27
+	uint8_t Over_Power_Alarm;
28
+	uint8_t VSWR_Alarm;
29
+	uint8_t Over_Input_Alarm;
30
+	uint8_t Over_Temp_Alarm;
31
+	uint8_t Temp_Monitor;
32
+	uint8_t ALC_Alarm;
33
+	uint8_t Checksum;
34
+	uint8_t Tail0;
35
+	uint8_t Tail1;
36
+}Nesslab_Prot;
37
+
38
+
39
+typedef enum{
40
+	NessLab_STATUS_REQ = 101,
41
+	NessLab_STATUS_RES,
42
+}NessLabDataType_t;
43
+
44
+typedef enum{
45
+	NessLab_DownLink_Tx,
46
+	NessLab_DownLink_Rx,
47
+	NessLab_Temperature,
48
+}Adc_Index_t;
49
+typedef enum{
50
+	NessLab_Header0,
51
+	NessLab_Header1,
52
+	NessLab_MsgID0,
53
+	NessLab_MsgSN0,
54
+	NessLab_MsgSN1,
55
+	NessLab_Reserve0,
56
+	NessLab_DataLength,
57
+	NessLab_Data_ADC0_H,
58
+	NessLab_Data_ADC0_L,
59
+	NessLab_Data_ADC1_H,
60
+	NessLab_Data_ADC1_L,
61
+	DC_FAIL_ALARM,
62
+	NessLab_DownLink_Status,
63
+	NessLab_Over_Power_Alarm,
64
+	NessLab_VSWR_ALARM,
65
+	NessLab_Over_Input_Alarm,
66
+	NessLab_Over_Temp_Alarm,
67
+	NessLab_Temp_Monitor,
68
+	NessLab_ALC_ALARM,
69
+	NessLab_ChecksumVal,
70
+
71
+}NessLabProtIndex_t;
72
+
73
+
74
+extern void NessLab_Operate(uint8_t* data);
75
+#endif /* NESSLAB_H_ */
76
+

+ 55 - 0
insight/Nesslab_200M_System.si4project/Backup/NessLab(1970).c

@@ -0,0 +1,55 @@
1
+/*
2
+ * NessLab.c
3
+ *
4
+ *  Created on: Aug 3, 2020
5
+ *      Author: parkyj
6
+ */
7
+
8
+
9
+#include "main.h"
10
+#include "NessLab.h"
11
+#include "adc.h"
12
+#include "crc.h"
13
+//extern uint8_t NessLab_Checksum(uint8_t* data,uint8_t size);
14
+
15
+Nesslab_Prot Currstatus;
16
+uint8_t data_Tx[50] = {0,};
17
+
18
+void NessLab_Operate(uint8_t* data){
19
+	uint8_t datatype = data[NessLab_MsgID0];
20
+
21
+	switch(datatype){
22
+		case NessLab_STATUS_REQ:
23
+			ADC_Check();
24
+			break;
25
+
26
+
27
+	}
28
+    Uart1_Data_Send(&Currstatus, 30);
29
+
30
+
31
+}
32
+void NessLab_Frame_Set(){
33
+    Currstatus.Header0 = 0x7E;
34
+    Currstatus.Header1 = 0x7E;
35
+
36
+    /* Exception Header Tail Checksum */
37
+    Currstatus.Checksum = NessLab_Checksum(&Currstatus.MsgId, 17);
38
+    
39
+    Currstatus.Tail0 = 0x7E;
40
+    Currstatus.Tail1 = 0x7E;
41
+
42
+}
43
+
44
+
45
+void NessLab_Status_Check(){
46
+	//HAL_GPIO_ReadPin(, GPIO_Pin)
47
+}
48
+void NessLab_PAU_Enable(){
49
+	HAL_GPIO_WritePin(AMP_EN_GPIO_Port,AMP_EN_Pin, HAL_GPIO_ReadPin(PAU_EN_GPIO_Port, PAU_EN_Pin));
50
+	//HAL_GPIO_WritePin(AMP_EN_GPIO_Port,AMP_EN_Pin, HAL_GPIO_ReadPin(PAU_RESET_GPIO_Port, PAU_RESET_Pin));
51
+}
52
+void NessLab_GPIO_Operate(){
53
+	NessLab_PAU_Enable();
54
+}
55
+

+ 55 - 0
insight/Nesslab_200M_System.si4project/Backup/NessLab(2530).c

@@ -0,0 +1,55 @@
1
+/*
2
+ * NessLab.c
3
+ *
4
+ *  Created on: Aug 3, 2020
5
+ *      Author: parkyj
6
+ */
7
+
8
+
9
+#include "main.h"
10
+#include "NessLab.h"
11
+#include "adc.h"
12
+#include "crc.h"
13
+//extern uint8_t NessLab_Checksum(uint8_t* data,uint8_t size);
14
+
15
+Nesslab_Prot Currstatus;
16
+uint8_t data_Tx[50] = {0,};
17
+
18
+void NessLab_Operate(uint8_t* data){
19
+	uint8_t datatype = data[NessLab_MsgID0];
20
+
21
+	switch(datatype){
22
+		case NessLab_STATUS_REQ:
23
+			ADC_Check();
24
+			break;
25
+
26
+
27
+	}
28
+    Uart1_Data_Send(&Currstatus, 30);
29
+
30
+
31
+}
32
+void NessLab_Frame_Set(){
33
+    Currstatus.Header0 = 0x7E;
34
+    Currstatus.Header1 = 0x7E;
35
+
36
+    /* Exception Header Tail Checksum */
37
+    Currstatus.Checksum = NessLab_Checksum(&Currstatus.MsgId, 17);
38
+    
39
+    Currstatus.Tail0 = 0x7E;
40
+    Currstatus.Tail1 = 0x7E;
41
+
42
+}
43
+
44
+
45
+void NessLab_Status_Check(){
46
+	//HAL_GPIO_ReadPin(, GPIO_Pin)
47
+}
48
+void NessLab_PAU_Enable(){
49
+	HAL_GPIO_WritePin(AMP_EN_GPIO_Port,AMP_EN_Pin, HAL_GPIO_ReadPin(PAU_EN_GPIO_Port, PAU_EN_Pin));
50
+	//HAL_GPIO_WritePin(AMP_EN_GPIO_Port,AMP_EN_Pin, HAL_GPIO_ReadPin(PAU_RESET_GPIO_Port, PAU_RESET_Pin));
51
+}
52
+void NessLab_GPIO_Operate(){
53
+	NessLab_PAU_Enable();
54
+}
55
+

+ 68 - 0
insight/Nesslab_200M_System.si4project/Backup/NessLab(4175).c

@@ -0,0 +1,68 @@
1
+/*
2
+ * NessLab.c
3
+ *
4
+ *  Created on: Aug 3, 2020
5
+ *      Author: parkyj
6
+ */
7
+
8
+
9
+#include "main.h"
10
+#include "NessLab.h"
11
+#include "adc.h"
12
+#include "crc.h"
13
+//extern uint8_t NessLab_Checksum(uint8_t* data,uint8_t size);
14
+
15
+Nesslab_Prot Currstatus;
16
+uint8_t data_Tx[50] = {0,};
17
+
18
+
19
+void NessLab_Operate(uint8_t* data){
20
+	uint8_t datatype = data[NessLab_MsgID0];
21
+
22
+	switch(datatype){
23
+		case NessLab_STATUS_REQ:
24
+			ADC_Check();
25
+			break;
26
+
27
+
28
+	}
29
+    
30
+    Uart1_Data_Send(&Currstatus, 30);
31
+
32
+
33
+}
34
+
35
+
36
+
37
+void NessLab_Frame_Set(uint8_t* data,uint8_t size){
38
+    data[NessLab_Header0] = 0x7E;
39
+    data[NessLab_Header1] = 0x7E;
40
+
41
+    data[NessLab_MsgID0] = NessLab_STATUS_RES;// ID
42
+    data[NessLab_MsgSN0] = 0; // SEQ NUMBER
43
+    data[NessLab_MsgSN1] = 0; // SEQ NUMBER   
44
+    data[NessLab_Reserve0] = 0; // NessLab_Reserve0
45
+    data[NessLab_Reserve0] = size; // Nesslab Size
46
+    
47
+    
48
+    
49
+    /* Exception Header Tail Checksum */
50
+    Currstatus.Checksum = NessLab_Checksum(0, 17);
51
+    
52
+    Currstatus.Tail0 = 0x7E;
53
+    Currstatus.Tail1 = 0x7E;
54
+
55
+}
56
+
57
+
58
+void NessLab_Status_Check(){
59
+	//HAL_GPIO_ReadPin(, GPIO_Pin)
60
+}
61
+void NessLab_PAU_Enable(){
62
+	HAL_GPIO_WritePin(AMP_EN_GPIO_Port,AMP_EN_Pin, HAL_GPIO_ReadPin(PAU_EN_GPIO_Port, PAU_EN_Pin));
63
+	//HAL_GPIO_WritePin(AMP_EN_GPIO_Port,AMP_EN_Pin, HAL_GPIO_ReadPin(PAU_RESET_GPIO_Port, PAU_RESET_Pin));
64
+}
65
+void NessLab_GPIO_Operate(){
66
+	NessLab_PAU_Enable();
67
+}
68
+

+ 60 - 0
insight/Nesslab_200M_System.si4project/Backup/NessLab(5969).c

@@ -0,0 +1,60 @@
1
+/*
2
+ * NessLab.c
3
+ *
4
+ *  Created on: Aug 3, 2020
5
+ *      Author: parkyj
6
+ */
7
+
8
+
9
+#include "main.h"
10
+#include "NessLab.h"
11
+#include "adc.h"
12
+#include "crc.h"
13
+//extern uint8_t NessLab_Checksum(uint8_t* data,uint8_t size);
14
+
15
+Nesslab_Prot Currstatus;
16
+uint8_t data_Tx[50] = {0,};
17
+
18
+
19
+
20
+void NessLab_Operate(uint8_t* data){
21
+	uint8_t datatype = data[NessLab_MsgID0];
22
+
23
+	switch(datatype){
24
+		case NessLab_STATUS_REQ:
25
+			ADC_Check();
26
+			break;
27
+
28
+
29
+	}
30
+    Uart1_Data_Send(&Currstatus, 30);
31
+
32
+
33
+}
34
+
35
+
36
+
37
+void NessLab_Frame_Set(){
38
+    Currstatus.Header0 = 0x7E;
39
+    Currstatus.Header1 = 0x7E;
40
+
41
+    /* Exception Header Tail Checksum */
42
+    Currstatus.Checksum = NessLab_Checksum(0, 17);
43
+    
44
+    Currstatus.Tail0 = 0x7E;
45
+    Currstatus.Tail1 = 0x7E;
46
+
47
+}
48
+
49
+
50
+void NessLab_Status_Check(){
51
+	//HAL_GPIO_ReadPin(, GPIO_Pin)
52
+}
53
+void NessLab_PAU_Enable(){
54
+	HAL_GPIO_WritePin(AMP_EN_GPIO_Port,AMP_EN_Pin, HAL_GPIO_ReadPin(PAU_EN_GPIO_Port, PAU_EN_Pin));
55
+	//HAL_GPIO_WritePin(AMP_EN_GPIO_Port,AMP_EN_Pin, HAL_GPIO_ReadPin(PAU_RESET_GPIO_Port, PAU_RESET_Pin));
56
+}
57
+void NessLab_GPIO_Operate(){
58
+	NessLab_PAU_Enable();
59
+}
60
+

+ 57 - 0
insight/Nesslab_200M_System.si4project/Backup/NessLab(6033).c

@@ -0,0 +1,57 @@
1
+/*
2
+ * NessLab.c
3
+ *
4
+ *  Created on: Aug 3, 2020
5
+ *      Author: parkyj
6
+ */
7
+
8
+
9
+#include "main.h"
10
+#include "NessLab.h"
11
+#include "adc.h"
12
+#include "crc.h"
13
+//extern uint8_t NessLab_Checksum(uint8_t* data,uint8_t size);
14
+
15
+Nesslab_Prot Currstatus;
16
+uint8_t data_Tx[50] = {0,};
17
+
18
+
19
+
20
+void NessLab_Operate(uint8_t* data){
21
+	uint8_t datatype = data[NessLab_MsgID0];
22
+
23
+	switch(datatype){
24
+		case NessLab_STATUS_REQ:
25
+			ADC_Check();
26
+			break;
27
+
28
+
29
+	}
30
+    Uart1_Data_Send(&Currstatus, 30);
31
+
32
+
33
+}
34
+void NessLab_Frame_Set(){
35
+    Currstatus.Header0 = 0x7E;
36
+    Currstatus.Header1 = 0x7E;
37
+
38
+    /* Exception Header Tail Checksum */
39
+    Currstatus.Checksum = NessLab_Checksum(&Currstatus.MsgId, 17);
40
+    
41
+    Currstatus.Tail0 = 0x7E;
42
+    Currstatus.Tail1 = 0x7E;
43
+
44
+}
45
+
46
+
47
+void NessLab_Status_Check(){
48
+	//HAL_GPIO_ReadPin(, GPIO_Pin)
49
+}
50
+void NessLab_PAU_Enable(){
51
+	HAL_GPIO_WritePin(AMP_EN_GPIO_Port,AMP_EN_Pin, HAL_GPIO_ReadPin(PAU_EN_GPIO_Port, PAU_EN_Pin));
52
+	//HAL_GPIO_WritePin(AMP_EN_GPIO_Port,AMP_EN_Pin, HAL_GPIO_ReadPin(PAU_RESET_GPIO_Port, PAU_RESET_Pin));
53
+}
54
+void NessLab_GPIO_Operate(){
55
+	NessLab_PAU_Enable();
56
+}
57
+

+ 75 - 0
insight/Nesslab_200M_System.si4project/Backup/NessLab(6167).c

@@ -0,0 +1,75 @@
1
+/*
2
+ * NessLab.c
3
+ *
4
+ *  Created on: Aug 3, 2020
5
+ *      Author: parkyj
6
+ */
7
+
8
+
9
+#include "main.h"
10
+#include "NessLab.h"
11
+#include "adc.h"
12
+#include "crc.h"
13
+//extern uint8_t NessLab_Checksum(uint8_t* data,uint8_t size);
14
+
15
+Nesslab_Prot Currstatus;
16
+uint8_t data_Tx[50] = {0,};
17
+extern volatile uint16_t ADC1value[ADC1_CNT];
18
+
19
+void NessLab_Operate(uint8_t* data){
20
+	uint8_t datatype = data[NessLab_MsgID0];
21
+
22
+	switch(datatype){
23
+		case NessLab_STATUS_REQ:
24
+			ADC_Check();
25
+			break;
26
+
27
+
28
+	}
29
+    NessLab_Frame_Set(data,12);
30
+    Uart1_Data_Send(&data, 30);
31
+
32
+
33
+}
34
+
35
+
36
+
37
+void NessLab_Frame_Set(uint8_t* data,uint8_t size){
38
+    data[NessLab_Header0] = 0x7E;
39
+    data[NessLab_Header1] = 0x7E;
40
+
41
+    data[NessLab_MsgID0] = NessLab_STATUS_RES;// ID
42
+    data[NessLab_MsgSN0] = 0; // SEQ NUMBER
43
+    data[NessLab_MsgSN1] = 0; // SEQ NUMBER   
44
+    data[NessLab_Reserve0] = 0; // NessLab_Reserve0
45
+    data[NessLab_DataLength] = size; // Nesslab Size
46
+    data[NessLab_Data_ADC0_H] = 12; // (uint8_t)((ADC1value & 0xFF00) >> 8);
47
+    data[NessLab_Data_ADC0_L] = 34; // (uint8_t)(ADC1value & 0x00FF);
48
+    data[NessLab_Data_ADC1_H] = 00;
49
+    data[NessLab_Data_ADC1_L] = 00;
50
+    data[DC_FAIL_ALARM] = 11;
51
+    data[NessLab_DownLink_Status] = 22;
52
+    data[NessLab_Over_Power_Alarm] = 33;
53
+    data[NessLab_VSWR_ALARM] = 44;
54
+    data[NessLab_Over_Input_Alarm] = 55;
55
+    data[NessLab_Over_Temp_Alarm] = 66;
56
+    data[NessLab_Temp_Monitor] = 77;
57
+    data[NessLab_ALC_ALARM] = 88;
58
+    data[NessLab_ChecksumVal] = NessLab_Checksum(0, 17);
59
+    /* Exception Header Tail Checksum */
60
+    data[NessLab_Tail0] = 0x7E;
61
+    data[NessLab_Tail0] = 0x7E; 
62
+}
63
+
64
+
65
+void NessLab_Status_Check(){
66
+	//HAL_GPIO_ReadPin(, GPIO_Pin)
67
+}
68
+void NessLab_PAU_Enable(){
69
+	HAL_GPIO_WritePin(AMP_EN_GPIO_Port,AMP_EN_Pin, HAL_GPIO_ReadPin(PAU_EN_GPIO_Port, PAU_EN_Pin));
70
+	//HAL_GPIO_WritePin(AMP_EN_GPIO_Port,AMP_EN_Pin, HAL_GPIO_ReadPin(PAU_RESET_GPIO_Port, PAU_RESET_Pin));
71
+}
72
+void NessLab_GPIO_Operate(){
73
+	NessLab_PAU_Enable();
74
+}
75
+

+ 75 - 0
insight/Nesslab_200M_System.si4project/Backup/NessLab(6997).c

@@ -0,0 +1,75 @@
1
+/*
2
+ * NessLab.c
3
+ *
4
+ *  Created on: Aug 3, 2020
5
+ *      Author: parkyj
6
+ */
7
+
8
+
9
+#include "main.h"
10
+#include "NessLab.h"
11
+#include "adc.h"
12
+#include "crc.h"
13
+//extern uint8_t NessLab_Checksum(uint8_t* data,uint8_t size);
14
+
15
+Nesslab_Prot Currstatus;
16
+uint8_t data_Tx[50] = {0,};
17
+
18
+
19
+void NessLab_Operate(uint8_t* data){
20
+	uint8_t datatype = data[NessLab_MsgID0];
21
+
22
+	switch(datatype){
23
+		case NessLab_STATUS_REQ:
24
+			ADC_Check();
25
+			break;
26
+
27
+
28
+	}
29
+    NessLab_Frame_Set(data,12);
30
+    Uart1_Data_Send(&data, 30);
31
+
32
+
33
+}
34
+
35
+
36
+
37
+void NessLab_Frame_Set(uint8_t* data,uint8_t size){
38
+    data[NessLab_Header0] = 0x7E;
39
+    data[NessLab_Header1] = 0x7E;
40
+
41
+    data[NessLab_MsgID0] = NessLab_STATUS_RES;// ID
42
+    data[NessLab_MsgSN0] = 0; // SEQ NUMBER
43
+    data[NessLab_MsgSN1] = 0; // SEQ NUMBER   
44
+    data[NessLab_Reserve0] = 0; // NessLab_Reserve0
45
+    data[NessLab_DataLength] = size; // Nesslab Size
46
+    data[NessLab_Data_ADC0_H] = 12;
47
+    data[NessLab_Data_ADC0_L] = 34;
48
+    data[NessLab_Data_ADC1_H] = 00;
49
+    data[NessLab_Data_ADC1_L] = 00;
50
+    data[DC_FAIL_ALARM] = 11;
51
+    data[NessLab_DownLink_Status] = 22;
52
+    data[NessLab_Over_Power_Alarm] = 33;
53
+    data[NessLab_VSWR_ALARM] = 44;
54
+    data[NessLab_Over_Input_Alarm] = 55;
55
+    data[NessLab_Over_Temp_Alarm] = 66;
56
+    data[NessLab_Temp_Monitor] = 77;
57
+    data[NessLab_ALC_ALARM] = 88;
58
+    data[NessLab_ChecksumVal] = NessLab_Checksum(0, 17);
59
+    /* Exception Header Tail Checksum */
60
+    data[NessLab_Tail0] = 0x7E;
61
+    data[NessLab_Tail0] = 0x7E; 
62
+}
63
+
64
+
65
+void NessLab_Status_Check(){
66
+	//HAL_GPIO_ReadPin(, GPIO_Pin)
67
+}
68
+void NessLab_PAU_Enable(){
69
+	HAL_GPIO_WritePin(AMP_EN_GPIO_Port,AMP_EN_Pin, HAL_GPIO_ReadPin(PAU_EN_GPIO_Port, PAU_EN_Pin));
70
+	//HAL_GPIO_WritePin(AMP_EN_GPIO_Port,AMP_EN_Pin, HAL_GPIO_ReadPin(PAU_RESET_GPIO_Port, PAU_RESET_Pin));
71
+}
72
+void NessLab_GPIO_Operate(){
73
+	NessLab_PAU_Enable();
74
+}
75
+

+ 41 - 0
insight/Nesslab_200M_System.si4project/Backup/NessLab(7138).c

@@ -0,0 +1,41 @@
1
+/*
2
+ * NessLab.c
3
+ *
4
+ *  Created on: Aug 3, 2020
5
+ *      Author: parkyj
6
+ */
7
+
8
+
9
+#include "main.h"
10
+#include "NessLab.h"
11
+#include "adc.h"
12
+Nesslab_Prot Currstatus;
13
+uint8_t data_Tx[50] = {0,};
14
+
15
+void NessLab_Operate(uint8_t* data){
16
+	uint8_t datatype = data[NessLab_MsgID0];
17
+
18
+	switch(datatype){
19
+		case NessLab_STATUS_REQ:
20
+		case NessLab_STATUS_RES:
21
+			ADC_Check();
22
+			Uart1_Data_Send(&Currstatus, 30);
23
+			break;
24
+
25
+
26
+	}
27
+
28
+
29
+}
30
+
31
+void NessLab_Status_Check(){
32
+	//HAL_GPIO_ReadPin(, GPIO_Pin)
33
+}
34
+void NessLab_PAU_Enable(){
35
+	HAL_GPIO_WritePin(AMP_EN_GPIO_Port,AMP_EN_Pin, HAL_GPIO_ReadPin(PAU_EN_GPIO_Port, PAU_EN_Pin));
36
+	//HAL_GPIO_WritePin(AMP_EN_GPIO_Port,AMP_EN_Pin, HAL_GPIO_ReadPin(PAU_RESET_GPIO_Port, PAU_RESET_Pin));
37
+}
38
+void NessLab_GPIO_Operate(){
39
+	NessLab_PAU_Enable();
40
+}
41
+

+ 80 - 0
insight/Nesslab_200M_System.si4project/Backup/NessLab(7731).h

@@ -0,0 +1,80 @@
1
+/*
2
+ * NessLab.h
3
+ *
4
+ *  Created on: Aug 3, 2020
5
+ *      Author: parkyj
6
+ */
7
+
8
+#ifndef NESSLAB_H_
9
+#define NESSLAB_H_
10
+
11
+#include "main.h"
12
+
13
+typedef struct{
14
+	uint8_t Header0;
15
+	uint8_t Header1;
16
+	uint8_t MsgId;
17
+	uint8_t MsgSn0;
18
+	uint8_t MsgSn1;
19
+	uint8_t MsgReserve0;
20
+	uint8_t MsgDataLength;
21
+	uint8_t DownLink_Forward_Det_H;
22
+	uint8_t DownLink_Forward_Det_L;
23
+	uint8_t DownLink_Reverse_Det_H;
24
+	uint8_t DownLink_Reverse_Det_L;
25
+	uint8_t DC_Level_Det_H;
26
+	uint8_t DC_Level_Det_L;    
27
+	uint8_t Gate_Enable;
28
+	uint8_t Reset;
29
+	uint8_t DC_Fail_Alarm;
30
+	uint8_t Downlink_Status;
31
+	uint8_t Over_Power_Alarm;
32
+	uint8_t VSWR_Alarm;
33
+	uint8_t Over_Input_Alarm;
34
+	uint8_t Over_Temp_Alarm;
35
+	uint8_t Temp_Monitor;
36
+	uint8_t ALC_Alarm;
37
+	uint8_t Checksum;
38
+	uint8_t Tail0;
39
+	uint8_t Tail1;
40
+}Nesslab_Prot;
41
+
42
+
43
+typedef enum{
44
+	NessLab_STATUS_REQ,
45
+	NessLab_STATUS_RES,
46
+}NessLabDataType_t;
47
+
48
+typedef enum{
49
+	NessLab_DownLink_Tx,
50
+	NessLab_DownLink_Rx,
51
+	NessLab_Temperature,
52
+}Adc_Index_t;
53
+typedef enum{
54
+	NessLab_Header0,
55
+	NessLab_Header1,
56
+	NessLab_MsgID0,
57
+	NessLab_MsgSN0,
58
+	NessLab_MsgSN1,
59
+	NessLab_Reserve0,
60
+	NessLab_DataLength,
61
+	NessLab_Data_ADC0_H,
62
+	NessLab_Data_ADC0_L,
63
+	NessLab_Data_ADC1_H,
64
+	NessLab_Data_ADC1_L,
65
+	DC_FAIL_ALARM,
66
+	NessLab_DownLink_Status,
67
+	NessLab_Over_Power_Alarm,
68
+	NessLab_VSWR_ALARM,
69
+	NessLab_Over_Input_Alarm,
70
+	NessLab_Over_Temp_Alarm,
71
+	NessLab_Temp_Monitor,
72
+	NessLab_ALC_ALARM,
73
+	NessLab_Checksum,
74
+
75
+}NessLabProtIndex_t;
76
+
77
+
78
+extern void NessLab_Operate(uint8_t* data);
79
+#endif /* NESSLAB_H_ */
80
+

+ 76 - 0
insight/Nesslab_200M_System.si4project/Backup/NessLab(985).h

@@ -0,0 +1,76 @@
1
+/*
2
+ * NessLab.h
3
+ *
4
+ *  Created on: Aug 3, 2020
5
+ *      Author: parkyj
6
+ */
7
+
8
+#ifndef NESSLAB_H_
9
+#define NESSLAB_H_
10
+
11
+#include "main.h"
12
+
13
+typedef struct{
14
+	uint8_t Header0;
15
+	uint8_t Header1;
16
+	uint8_t MsgId;
17
+	uint8_t MsgSn0;
18
+	uint8_t MsgSn1;
19
+	uint8_t MsgReserve0;
20
+	uint8_t MsgDataLength;
21
+	uint8_t DownLink_Forward_Det_H;
22
+	uint8_t DownLink_Forward_Det_L;
23
+	uint8_t DownLink_Reverse_Det_H;
24
+	uint8_t DownLink_Reverse_Det_L;
25
+	uint8_t DC_Fail_Alarm;
26
+	uint8_t Downlink_Status;
27
+	uint8_t Over_Power_Alarm;
28
+	uint8_t VSWR_Alarm;
29
+	uint8_t Over_Input_Alarm;
30
+	uint8_t Over_Temp_Alarm;
31
+	uint8_t Temp_Monitor;
32
+	uint8_t ALC_Alarm;
33
+	uint8_t Checksum;
34
+	uint8_t Tail0;
35
+	uint8_t Tail1;
36
+}Nesslab_Prot;
37
+
38
+
39
+typedef enum{
40
+	NessLab_STATUS_REQ,
41
+	NessLab_STATUS_RES,
42
+}NessLabDataType_t;
43
+
44
+typedef enum{
45
+	NessLab_DownLink_Tx,
46
+	NessLab_DownLink_Rx,
47
+	NessLab_Temperature,
48
+}Adc_Index_t;
49
+typedef enum{
50
+	NessLab_Header0,
51
+	NessLab_Header1,
52
+	NessLab_MsgID0,
53
+	NessLab_MsgSN0,
54
+	NessLab_MsgSN1,
55
+	NessLab_Reserve0,
56
+	NessLab_DataLength,
57
+	NessLab_Data_ADC0_H,
58
+	NessLab_Data_ADC0_L,
59
+	NessLab_Data_ADC1_H,
60
+	NessLab_Data_ADC1_L,
61
+	DC_FAIL_ALARM,
62
+	NessLab_DownLink_Status,
63
+	NessLab_Over_Power_Alarm,
64
+	NessLab_VSWR_ALARM,
65
+	NessLab_Over_Input_Alarm,
66
+	NessLab_Over_Temp_Alarm,
67
+	NessLab_Temp_Monitor,
68
+	NessLab_ALC_ALARM,
69
+	NessLab_ChecksumVal,
70
+
71
+}NessLabProtIndex_t;
72
+
73
+
74
+extern void NessLab_Operate(uint8_t* data);
75
+#endif /* NESSLAB_H_ */
76
+

+ 59 - 0
insight/Nesslab_200M_System.si4project/Backup/adc(3877).c

@@ -0,0 +1,59 @@
1
+/*
2
+ * adc.c
3
+ *
4
+ *  Created on: 2020. 8. 3.
5
+ *      Author: parkyj
6
+ */
7
+#include "main.h"
8
+#include "adc.h"
9
+#include "NessLab.h"
10
+
11
+
12
+extern ADC_HandleTypeDef hadc1;
13
+extern DMA_HandleTypeDef hdma_adc1;
14
+extern Nesslab_Prot Currstatus;
15
+
16
+
17
+volatile uint16_t ADC1valuearray[ADC1_CNT][ADC_AVERAGECNT];
18
+volatile uint16_t ADC1value[ADC1_CNT];
19
+uint16_t adc1cnt = 0 ;
20
+
21
+void ADC_Initialize(){
22
+	while(!(HAL_ADCEx_Calibration_Start(&hadc1)==HAL_OK));
23
+	HAL_ADC_Start_DMA(&hadc1, (uint16_t*)ADC1value,(uint32_t) 4);
24
+}
25
+void ADC_Check(){
26
+    Currstatus.DownLink_Forward_Det_H
27
+        = ((ADC1value[0] & 0xFF00) >> 8);
28
+    Currstatus.DownLink_Forward_Det_L
29
+        = ((ADC1value[0] & 0x00FF) );
30
+
31
+    Currstatus.DownLink_Reverse_Det_H
32
+        = ((ADC1value[0] & 0xFF00) >> 8);
33
+    Currstatus.DownLink_Reverse_Det_L
34
+        = ((ADC1value[0] & 0x00FF) );
35
+
36
+    Currstatus.DC_Level_Det_H
37
+        = ((ADC1value[0] & 0xFF00) >> 8);
38
+    Currstatus.DC_Level_Det_L
39
+        = ((ADC1value[0] & 0x00FF) );
40
+
41
+    Currstatus.Temp_Monitor
42
+        = ((ADC1value[0] & 0xFF00) >> 8);
43
+    Currstatus.Temp_Monitor
44
+        = ((ADC1value[0] & 0x00FF) );        
45
+
46
+
47
+}
48
+void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc)
49
+{
50
+    if(hadc->Instance == hadc1.Instance)
51
+    {
52
+        if(adc1cnt < ADC_AVERAGECNT){
53
+            for(int i = 0; i < 4; i++){
54
+                ADC1valuearray[i][adc1cnt] = ADC1value[i];
55
+            }
56
+            adc1cnt++;
57
+        }
58
+    }
59
+}

+ 19 - 0
insight/Nesslab_200M_System.si4project/Backup/adc(3912).h

@@ -0,0 +1,19 @@
1
+/*
2
+ * adc.h
3
+ *
4
+ *  Created on: 2020. 8. 3.
5
+ *      Author: parkyj
6
+ */
7
+
8
+#ifndef ADC_H_
9
+#define ADC_H_
10
+
11
+#include "main.h"
12
+
13
+void ADC_Initialize();
14
+void ADC_Check();
15
+
16
+
17
+#define ADC1_CNT 3
18
+#define ADC_AVERAGECNT 100
19
+#endif /* ADC_H_ */

+ 87 - 0
insight/Nesslab_200M_System.si4project/Backup/adc(700).c

@@ -0,0 +1,87 @@
1
+ /*
2
+ * adc.c
3
+ *
4
+ *  Created on: 2020. 8. 3.
5
+ *      Author: parkyj
6
+ */
7
+#include "main.h"
8
+#include "adc.h"
9
+#include "NessLab.h"
10
+
11
+
12
+extern ADC_HandleTypeDef hadc1;
13
+extern DMA_HandleTypeDef hdma_adc1;
14
+extern Nesslab_Prot Currstatus;
15
+
16
+
17
+volatile uint16_t ADC1valuearray[ADC1_CNT][ADC_AVERAGECNT];
18
+volatile uint16_t ADC1value[ADC1_CNT];
19
+uint16_t adc1cnt = 0 ;
20
+
21
+/*
22
+ *
23
+ * ADC 0 :DL TX
24
+ * ADC 1 :DL RX
25
+ * ADC 2 :TEMP
26
+ * */
27
+
28
+void ADC_Value_Get(){
29
+	uint16_t CalcRet = 0 ;
30
+
31
+	/*DL TX Calc*/
32
+	Currstatus.DownLink_Forward_Det_H = ((ADC1value[0] & 0xFF00) >> 8);
33
+	Currstatus.DownLink_Forward_Det_L = (ADC1value[0] & 0x00FF);
34
+
35
+	/*DL RX Calc*/
36
+	Currstatus.DownLink_Reverse_Det_H = ((ADC1value[1] & 0xFF00) >> 8);
37
+	Currstatus.DownLink_Reverse_Det_L = (ADC1value[1] & 0x00FF);
38
+
39
+	/*Temp Calc*/
40
+	Currstatus.Temp_Monitor = ((ADC1value[1] & 0xFF00) >> 8);
41
+
42
+
43
+}
44
+void ADC_Initialize(){
45
+	while(!(HAL_ADCEx_Calibration_Start(&hadc1)==HAL_OK));
46
+	HAL_ADC_Start_DMA(&hadc1, (uint16_t*)ADC1value,(uint32_t) 3);
47
+}
48
+
49
+void ADC_Check(){
50
+    double tempval = 0;
51
+    for(int i = 0 ; i < 3; i++){
52
+        tempval = (ADC1value[i] * (3.3 / 4095)) * 100;
53
+        printf("ADC1value[%d] : %f \r\n",i,tempval);
54
+    }
55
+//    Currstatus.DownLink_Forward_Det_H
56
+//        = ((ADC1value[0] & 0xFF00) >> 8);
57
+//    Currstatus.DownLink_Forward_Det_L
58
+//        = ((ADC1value[0] & 0x00FF) );
59
+//
60
+//    Currstatus.DownLink_Reverse_Det_H
61
+//        = ((ADC1value[0] & 0xFF00) >> 8);
62
+//    Currstatus.DownLink_Reverse_Det_L
63
+//        = ((ADC1value[0] & 0x00FF) );
64
+//
65
+//    Currstatus.DC_Level_Det_H
66
+//        = ((ADC1value[0] & 0xFF00) >> 8);
67
+//    Currstatus.DC_Level_Det_L
68
+//        = ((ADC1value[0] & 0x00FF) );
69
+//
70
+//    Currstatus.Temp_Monitor
71
+//        = ((ADC1value[0] & 0xFF00) >> 8);
72
+//    Currstatus.Temp_Monitor
73
+//        = ((ADC1value[0] & 0x00FF) );  
74
+    adc1cnt = 0;
75
+}
76
+void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc)
77
+{
78
+    if(hadc->Instance == hadc1.Instance)
79
+    {
80
+        if(adc1cnt < ADC_AVERAGECNT){
81
+            for(int i = 0; i < 4; i++){
82
+                ADC1valuearray[i][adc1cnt] = ADC1value[i];
83
+            }
84
+            adc1cnt++;
85
+        }
86
+    }
87
+}

+ 27 - 0
insight/Nesslab_200M_System.si4project/Backup/crc(1936).h

@@ -0,0 +1,27 @@
1
+/*
2
+ * crc.h
3
+ *
4
+ *  Created on: 2020. 8. 3.
5
+ *      Author: parkyj
6
+ */
7
+
8
+#ifndef CRC_H_
9
+#define CRC_H_
10
+
11
+#include <stdbool.h>
12
+#include "main.h"
13
+typedef enum{
14
+    CHECKSUM_ERROR = 0,
15
+    NO_ERROR
16
+}etError;
17
+
18
+uint16_t CRC16_Generate(uint8_t* buf_ptr, int len);
19
+etError CRC16_Check(uint8_t* buf_ptr, int len,uint16_t checksum);
20
+uint8_t STH30_CreateCrc(uint8_t *data, uint8_t nbrOfBytes);
21
+etError STH30_CheckCrc(uint8_t *data, uint8_t nbrOfBytes, uint8_t checksum);
22
+uint8_t NessLab_Checksum(uint8_t *data,uint8_t size);
23
+bool NessLab_CheckSum_Check(uint8_t* data,uint8_t size,uint8_t checksum);
24
+
25
+
26
+#define POLYNOMIAL 0x131 // P(x) = x^8 + x^5 + x^4 + 1 = 100110001
27
+#endif /* CRC_H_ */

+ 25 - 0
insight/Nesslab_200M_System.si4project/Backup/crc(518).h

@@ -0,0 +1,25 @@
1
+/*
2
+ * crc.h
3
+ *
4
+ *  Created on: 2020. 8. 3.
5
+ *      Author: parkyj
6
+ */
7
+
8
+#ifndef CRC_H_
9
+#define CRC_H_
10
+
11
+#include "main.h"
12
+
13
+typedef enum{
14
+    CHECKSUM_ERROR = 0,
15
+    NO_ERROR
16
+}etError;
17
+
18
+uint16_t CRC16_Generate(uint8_t* buf_ptr, int len);
19
+etError CRC16_Check(uint8_t* buf_ptr, int len,uint16_t checksum);
20
+uint8_t STH30_CreateCrc(uint8_t *data, uint8_t nbrOfBytes);
21
+etError STH30_CheckCrc(uint8_t *data, uint8_t nbrOfBytes, uint8_t checksum);
22
+
23
+
24
+#define POLYNOMIAL 0x131 // P(x) = x^8 + x^5 + x^4 + 1 = 100110001
25
+#endif /* CRC_H_ */

+ 25 - 0
insight/Nesslab_200M_System.si4project/Backup/crc(5317).h

@@ -0,0 +1,25 @@
1
+/*
2
+ * crc.h
3
+ *
4
+ *  Created on: 2020. 8. 3.
5
+ *      Author: parkyj
6
+ */
7
+
8
+#ifndef CRC_H_
9
+#define CRC_H_
10
+
11
+#include "main.h"
12
+
13
+typedef enum{
14
+    CHECKSUM_ERROR = 0,
15
+    NO_ERROR
16
+}etError;
17
+
18
+uint16_t CRC16_Generate(uint8_t* buf_ptr, int len);
19
+etError CRC16_Check(uint8_t* buf_ptr, int len,uint16_t checksum);
20
+uint8_t STH30_CreateCrc(uint8_t *data, uint8_t nbrOfBytes);
21
+etError STH30_CheckCrc(uint8_t *data, uint8_t nbrOfBytes, uint8_t checksum);
22
+bool NessLab_CheckSum_Check(uint8_t* data,uint8_t size,uint8_t checksum);
23
+
24
+#define POLYNOMIAL 0x131 // P(x) = x^8 + x^5 + x^4 + 1 = 100110001
25
+#endif /* CRC_H_ */

+ 287 - 0
insight/Nesslab_200M_System.si4project/Backup/crc(7234).c

@@ -0,0 +1,287 @@
1
+/*
2
+ * crc.c
3
+ *
4
+ *  Created on: 2020. 8. 3.
5
+ *      Author: parkyj
6
+ */
7
+
8
+/*---------------------------------------------------------------------------------------*/
9
+/*									CRC16	TABLE						    			 */
10
+/*---------------------------------------------------------------------------------------*/
11
+#include <stdio.h>						
12
+#include <stdint.h>	
13
+#include <stdbool.h>
14
+#include "crc.h"
15
+#include "uart.h"
16
+const uint16_t crc16_tab[256] = {				
17
+    0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7,				
18
+    0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef,				
19
+    0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6,				
20
+    0x9339, 0x8318, 0xb37b, 0xa35a, 0xd3bd, 0xc39c, 0xf3ff, 0xe3de,				
21
+    0x2462, 0x3443, 0x0420, 0x1401, 0x64e6, 0x74c7, 0x44a4, 0x5485,				
22
+    0xa56a, 0xb54b, 0x8528, 0x9509, 0xe5ee, 0xf5cf, 0xc5ac, 0xd58d,				
23
+    0x3653, 0x2672, 0x1611, 0x0630, 0x76d7, 0x66f6, 0x5695, 0x46b4,				
24
+    0xb75b, 0xa77a, 0x9719, 0x8738, 0xf7df, 0xe7fe, 0xd79d, 0xc7bc,				
25
+    0x48c4, 0x58e5, 0x6886, 0x78a7, 0x0840, 0x1861, 0x2802, 0x3823,				
26
+    0xc9cc, 0xd9ed, 0xe98e, 0xf9af, 0x8948, 0x9969, 0xa90a, 0xb92b,				
27
+    0x5af5, 0x4ad4, 0x7ab7, 0x6a96, 0x1a71, 0x0a50, 0x3a33, 0x2a12,				
28
+    0xdbfd, 0xcbdc, 0xfbbf, 0xeb9e, 0x9b79, 0x8b58, 0xbb3b, 0xab1a,				
29
+    0x6ca6, 0x7c87, 0x4ce4, 0x5cc5, 0x2c22, 0x3c03, 0x0c60, 0x1c41,				
30
+    0xedae, 0xfd8f, 0xcdec, 0xddcd, 0xad2a, 0xbd0b, 0x8d68, 0x9d49,				
31
+    0x7e97, 0x6eb6, 0x5ed5, 0x4ef4, 0x3e13, 0x2e32, 0x1e51, 0x0e70,				
32
+    0xff9f, 0xefbe, 0xdfdd, 0xcffc, 0xbf1b, 0xaf3a, 0x9f59, 0x8f78,				
33
+    0x9188, 0x81a9, 0xb1ca, 0xa1eb, 0xd10c, 0xc12d, 0xf14e, 0xe16f,				
34
+    0x1080, 0x00a1, 0x30c2, 0x20e3, 0x5004, 0x4025, 0x7046, 0x6067,				
35
+    0x83b9, 0x9398, 0xa3fb, 0xb3da, 0xc33d, 0xd31c, 0xe37f, 0xf35e,				
36
+    0x02b1, 0x1290, 0x22f3, 0x32d2, 0x4235, 0x5214, 0x6277, 0x7256,				
37
+    0xb5ea, 0xa5cb, 0x95a8, 0x8589, 0xf56e, 0xe54f, 0xd52c, 0xc50d,				
38
+    0x34e2, 0x24c3, 0x14a0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405,				
39
+    0xa7db, 0xb7fa, 0x8799, 0x97b8, 0xe75f, 0xf77e, 0xc71d, 0xd73c,				
40
+    0x26d3, 0x36f2, 0x0691, 0x16b0, 0x6657, 0x7676, 0x4615, 0x5634,				
41
+    0xd94c, 0xc96d, 0xf90e, 0xe92f, 0x99c8, 0x89e9, 0xb98a, 0xa9ab,				
42
+    0x5844, 0x4865, 0x7806, 0x6827, 0x18c0, 0x08e1, 0x3882, 0x28a3,				
43
+    0xcb7d, 0xdb5c, 0xeb3f, 0xfb1e, 0x8bf9, 0x9bd8, 0xabbb, 0xbb9a,				
44
+    0x4a75, 0x5a54, 0x6a37, 0x7a16, 0x0af1, 0x1ad0, 0x2ab3, 0x3a92,				
45
+    0xfd2e, 0xed0f, 0xdd6c, 0xcd4d, 0xbdaa, 0xad8b, 0x9de8, 0x8dc9,				
46
+    0x7c26, 0x6c07, 0x5c64, 0x4c45, 0x3ca2, 0x2c83, 0x1ce0, 0x0cc1,				
47
+    0xef1f, 0xff3e, 0xcf5d, 0xdf7c, 0xaf9b, 0xbfba, 0x8fd9, 0x9ff8,				
48
+    0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0				
49
+};			
50
+static uint32_t crc32_tab[] = {						
51
+    0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f,						
52
+    0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,						
53
+    0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2,						
54
+    0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,						
55
+    0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9,						
56
+    0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172,						
57
+    0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c,						
58
+    0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,						
59
+    0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423,						
60
+    0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,						
61
+    0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106,						
62
+    0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,						
63
+    0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d,						
64
+    0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e,						
65
+    0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950,						
66
+    0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,						
67
+    0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7,						
68
+    0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0,						
69
+    0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa,						
70
+    0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,						
71
+    0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81,						
72
+    0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a,						
73
+    0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84,						
74
+    0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,						
75
+    0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb,						
76
+    0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc,						
77
+    0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e,						
78
+    0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,						
79
+    0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55,						
80
+    0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,						
81
+    0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28,						
82
+    0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,						
83
+    0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f,						
84
+    0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38,						
85
+    0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242,						
86
+    0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,						
87
+    0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69,						
88
+    0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2,						
89
+    0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc,						
90
+    0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,						
91
+    0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693,						
92
+    0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94,						
93
+    0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d						
94
+};						
95
+				
96
+
97
+
98
+//-----------------------------------------------
99
+//UART CRC üũ �Լ�
100
+//-----------------------------------------------
101
+unsigned short genCRC16(char *buf_ptr, int len)
102
+{
103
+	unsigned char dt = 0U;
104
+	unsigned short crc16 = 0U;
105
+
106
+	len *= 8;
107
+	for(crc16 = (unsigned short)0x0000; len >= 8; len -= 8, buf_ptr++)
108
+	{
109
+		crc16 = (unsigned short)(crc16_tab[(crc16>>8) ^ (unsigned short)(*buf_ptr)] ^ (crc16<<8));
110
+	}
111
+
112
+	if(len != 0)
113
+	{
114
+		dt = (unsigned char)(*buf_ptr << 8);
115
+
116
+		while(len != 0)
117
+		{
118
+			len--;
119
+
120
+			if(((crc16^dt) & ((unsigned short)1 << 15)) != 0)
121
+			{
122
+				crc16 =  (unsigned short)(crc16 << 1);
123
+				crc16 = (unsigned short)(crc16 ^ 0x1021);
124
+			}
125
+			else
126
+			{
127
+				crc16 =  (unsigned short)(crc16 << 1);
128
+			}
129
+			dt = (unsigned char)(dt << 1);
130
+		}
131
+	}
132
+	return(crc16);
133
+}
134
+
135
+uint8_t STH30_CreateCrc(uint8_t *data, uint8_t nbrOfBytes)
136
+{
137
+  uint8_t bit;        // bit mask
138
+  uint8_t crc = 0xFF; // calculated checksum
139
+  uint8_t byteCtr;    // byte counter
140
+
141
+  // calculates 8-Bit checksum with given polynomial
142
+  for(byteCtr = 0; byteCtr < nbrOfBytes; byteCtr++)
143
+  {
144
+    crc ^= (data[byteCtr]);
145
+    for(bit = 8; bit > 0; --bit)
146
+    {
147
+      if(crc & 0x80) crc = (crc << 1) ^ POLYNOMIAL;
148
+      else           crc = (crc << 1);
149
+    }
150
+  }
151
+  return crc;
152
+}
153
+etError STH30_CheckCrc(uint8_t *data, uint8_t nbrOfBytes, uint8_t checksum)
154
+{
155
+  uint8_t bit;        // bit mask
156
+  uint8_t crc = 0xFF; // calculated checksum
157
+  uint8_t byteCtr;    // byte counter
158
+
159
+  // calculates 8-Bit checksum with given polynomial
160
+  for(byteCtr = 0; byteCtr < nbrOfBytes; byteCtr++)
161
+  {
162
+    crc ^= (data[byteCtr]);
163
+    for(bit = 8; bit > 0; --bit)
164
+    {
165
+      if(crc & 0x80) crc = (crc << 1) ^ POLYNOMIAL;
166
+      else           crc = (crc << 1);
167
+    }
168
+  }
169
+  if(crc != checksum) return CHECKSUM_ERROR;
170
+  else                return NO_ERROR;
171
+}
172
+
173
+
174
+
175
+
176
+
177
+bool Chksum_Check(uint8_t *data, uint32_t len,uint8_t chkdata)
178
+{
179
+   uint8_t dataret = 0;
180
+   bool ret = false;
181
+   for(int i = 0; i < len; i++){
182
+        dataret += data[i];
183
+   }
184
+   if(dataret == chkdata){
185
+        ret = true;
186
+   }
187
+//    printf("dataret : %x   chkdata : %x \r\n",dataret,chkdata);
188
+    return ret;
189
+}
190
+uint8_t Chksum_Create(uint8_t *data,uint32_t len)
191
+{
192
+   uint8_t dataret = 0;
193
+
194
+   for(int i = 0; i < len; i++){
195
+        dataret += data[i];
196
+//        printf("dataret : %x data[%d] : %x \r\n",dataret,i,data[i]);
197
+   }
198
+//    printf("dataret : %x \r\n",dataret);
199
+    return dataret;
200
+}
201
+
202
+
203
+
204
+etError CRC16_Check(uint8_t* buf_ptr, int len,uint16_t checksum)
205
+{
206
+    uint16_t crc = 0;
207
+    etError ret = CHECKSUM_ERROR;
208
+    for (uint32_t counter = 0; counter < len; counter++)
209
+        crc = (uint16_t)((crc << 8) ^ crc16_tab[(uint32_t)(((crc >> 8) ^ buf_ptr[counter]) & 0x00FF)]);
210
+//    printf("REAL CRC %x / IN CRC : %x \r\n",crc,checksum);
211
+    if(crc == checksum)
212
+        ret = NO_ERROR;
213
+        
214
+    return ret;
215
+}
216
+
217
+
218
+uint16_t CRC16_Generate(uint8_t* buf_ptr, int len)
219
+{
220
+  int a = 0;
221
+    uint16_t crc = 0;
222
+    for (uint32_t counter = 0; counter < len; counter++){
223
+        crc = (uint16_t)((crc << 8) ^ crc16_tab[(uint32_t)(((crc >> 8) ^ buf_ptr[counter]) & 0x00FF)]);
224
+//      printf("%d CRC : %x  buf_ptr : %x Counter %d\r\n",a,crc,buf_ptr[counter],counter);
225
+      a++;
226
+    }
227
+//    printf("len : %d \r\n",len);
228
+    return crc;
229
+}   
230
+
231
+		
232
+uint32_t crc32(const void *buf, size_t size)						
233
+{						
234
+    const uint8_t *p;						
235
+    uint32_t crcret = 0;
236
+						
237
+    p = buf;						
238
+    crcret = crcret ^ ~0U;						
239
+						
240
+    while (size--) {						
241
+        crcret = crc32_tab[(crcret ^ *p++) & 0xFF] ^ (crcret >> 8);						
242
+    }						
243
+						
244
+    return crcret ^ ~0U;						
245
+}						
246
+etError crc32Check(uint32_t checksum,uint32_t crc, const void *buf, size_t size)						
247
+{						
248
+    const uint8_t *p;						
249
+    uint32_t crcret = 0;
250
+						
251
+    p = buf;						
252
+    crcret = crcret ^ ~0U;						
253
+						
254
+    while (size--) {						
255
+        crcret = crc32_tab[(crcret ^ *p++) & 0xFF] ^ (crcret >> 8);						
256
+    }						
257
+						
258
+    crcret ^ ~0U;		
259
+
260
+    return (crcret == checksum ? CHECKSUM_ERROR : NO_ERROR);
261
+}
262
+uint8_t NessLab_Checksum(uint8_t* data,uint8_t size){
263
+	uint8_t ret = 0;
264
+	for(int i = 0; i < size; i++){
265
+		ret += data[i];
266
+	}
267
+
268
+	ret = (~ret) + 1;
269
+	return ret;
270
+}
271
+bool NessLab_CheckSum_Check(uint8_t* data,uint8_t size,uint8_t checksum){
272
+	uint8_t dataret = 0;
273
+	bool ret = false;
274
+
275
+	for(int i = 0; i < size; i++){
276
+		dataret += data[i];
277
+	}
278
+
279
+	dataret = (~dataret) + 1;
280
+	if(dataret != checksum){
281
+		ret = false;
282
+	}else{
283
+		ret = true;
284
+	}
285
+	return ret;
286
+}
287
+

+ 106 - 0
insight/Nesslab_200M_System.si4project/Backup/main(6098).h

@@ -0,0 +1,106 @@
1
+/* USER CODE BEGIN Header */
2
+/**
3
+  ******************************************************************************
4
+  * @file           : main.h
5
+  * @brief          : Header for main.c file.
6
+  *                   This file contains the common defines of the application.
7
+  ******************************************************************************
8
+  * @attention
9
+  *
10
+  * <h2><center>&copy; Copyright (c) 2020 STMicroelectronics.
11
+  * All rights reserved.</center></h2>
12
+  *
13
+  * This software component is licensed by ST under Ultimate Liberty license
14
+  * SLA0044, the "License"; You may not use this file except in compliance with
15
+  * the License. You may obtain a copy of the License at:
16
+  *                             www.st.com/SLA0044
17
+  *
18
+  ******************************************************************************
19
+  */
20
+/* USER CODE END Header */
21
+
22
+/* Define to prevent recursive inclusion -------------------------------------*/
23
+#ifndef __MAIN_H
24
+#define __MAIN_H
25
+
26
+#ifdef __cplusplus
27
+extern "C" {
28
+#endif
29
+
30
+/* Includes ------------------------------------------------------------------*/
31
+#include "stm32f1xx_hal.h"
32
+
33
+/* Private includes ----------------------------------------------------------*/
34
+/* USER CODE BEGIN Includes */
35
+
36
+/* USER CODE END Includes */
37
+
38
+/* Exported types ------------------------------------------------------------*/
39
+/* USER CODE BEGIN ET */
40
+
41
+/* USER CODE END ET */
42
+
43
+/* Exported constants --------------------------------------------------------*/
44
+/* USER CODE BEGIN EC */
45
+
46
+/* USER CODE END EC */
47
+
48
+/* Exported macro ------------------------------------------------------------*/
49
+/* USER CODE BEGIN EM */
50
+extern ADC_HandleTypeDef hadc1;
51
+extern DMA_HandleTypeDef hdma_adc1;
52
+/* USER CODE END EM */
53
+
54
+/* Exported functions prototypes ---------------------------------------------*/
55
+void Error_Handler(void);
56
+
57
+/* USER CODE BEGIN EFP */
58
+
59
+/* USER CODE END EFP */
60
+
61
+/* Private defines -----------------------------------------------------------*/
62
+#define BOOT_LED_Pin GPIO_PIN_15
63
+#define BOOT_LED_GPIO_Port GPIOC
64
+#define DL_TX_DET_Pin GPIO_PIN_0
65
+#define DL_TX_DET_GPIO_Port GPIOA
66
+#define DL_RX_DET_Pin GPIO_PIN_1
67
+#define DL_RX_DET_GPIO_Port GPIOA
68
+#define DC_FAIL_ALARM_Pin GPIO_PIN_2
69
+#define DC_FAIL_ALARM_GPIO_Port GPIOA
70
+#define PAU_TEMP_Pin GPIO_PIN_3
71
+#define PAU_TEMP_GPIO_Port GPIOA
72
+#define PAU_RESERVED0_Pin GPIO_PIN_6
73
+#define PAU_RESERVED0_GPIO_Port GPIOA
74
+#define PAU_RESERVED1_Pin GPIO_PIN_7
75
+#define PAU_RESERVED1_GPIO_Port GPIOA
76
+#define PAU_RESERVED3_Pin GPIO_PIN_0
77
+#define PAU_RESERVED3_GPIO_Port GPIOB
78
+#define PAU_RESERVED2_Pin GPIO_PIN_1
79
+#define PAU_RESERVED2_GPIO_Port GPIOB
80
+#define OVER_POWER_ALARM_Pin GPIO_PIN_12
81
+#define OVER_POWER_ALARM_GPIO_Port GPIOB
82
+#define VSWR_ALARM_Pin GPIO_PIN_13
83
+#define VSWR_ALARM_GPIO_Port GPIOB
84
+#define PAU_RESET_Pin GPIO_PIN_14
85
+#define PAU_RESET_GPIO_Port GPIOB
86
+#define PAU_EN_Pin GPIO_PIN_15
87
+#define PAU_EN_GPIO_Port GPIOB
88
+#define AMP_EN_Pin GPIO_PIN_8
89
+#define AMP_EN_GPIO_Port GPIOA
90
+#define OVER_INPUT_ALARM_Pin GPIO_PIN_11
91
+#define OVER_INPUT_ALARM_GPIO_Port GPIOA
92
+#define OVER_TEMP_ALARM_Pin GPIO_PIN_12
93
+#define OVER_TEMP_ALARM_GPIO_Port GPIOA
94
+#define ALC_ALARM_Pin GPIO_PIN_3
95
+#define ALC_ALARM_GPIO_Port GPIOB
96
+/* USER CODE BEGIN Private defines */
97
+
98
+/* USER CODE END Private defines */
99
+
100
+#ifdef __cplusplus
101
+}
102
+#endif
103
+
104
+#endif /* __MAIN_H */
105
+
106
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

+ 43 - 0
insight/Nesslab_200M_System.si4project/Backup/uart(6859).h

@@ -0,0 +1,43 @@
1
+/*
2
+ * uart.h
3
+ *
4
+ *  Created on: 2020. 8. 3.
5
+ *      Author: parkyj
6
+ */
7
+
8
+#ifndef UART_H_
9
+#define UART_H_
10
+
11
+#include <stdbool.h>
12
+#include "main.h"
13
+#define hTerminal    huart1
14
+#define hTest    huart3
15
+
16
+
17
+#define QUEUE_BUFFER_LENGTH 128
18
+
19
+typedef struct
20
+{
21
+    int head, tail, data;
22
+    uint8_t Buffer[QUEUE_BUFFER_LENGTH];
23
+}UARTQUEUE, *pUARTQUEUE;
24
+typedef struct  {
25
+   uint8_t buffer[QUEUE_BUFFER_LENGTH];
26
+   volatile uint16_t input_p;
27
+   volatile uint16_t output_p;
28
+} uart_hal_tx_type;
29
+
30
+extern UART_HandleTypeDef huart1;
31
+extern UART_HandleTypeDef huart3;
32
+
33
+
34
+extern UARTQUEUE TerminalQueue;
35
+void PutDataToUartQueue(UART_HandleTypeDef *huart, uint8_t data);
36
+void InitUartQueue(pUARTQUEUE pQueue);
37
+void GetDataFromUartQueue(UART_HandleTypeDef *huart);
38
+bool Get_UartRcv(void);
39
+void Set_UartRcv(bool);
40
+void Uart1_Data_Send(uint8_t* data,uint16_t size);
41
+void Uart_Check(void);
42
+
43
+#endif /* UART_H_ */

+ 149 - 0
insight/Nesslab_200M_System.si4project/Backup/uart(7653).c

@@ -0,0 +1,149 @@
1
+/*
2
+ * uart.c
3
+ *
4
+ *  Created on: 2020. 8. 3.
5
+ *      Author: parkyj
6
+ */
7
+#include <stdio.h>
8
+#include <stdint.h>
9
+#include "main.h"
10
+#include "string.h"
11
+
12
+
13
+#include "uart.h"
14
+#include "crc.h"
15
+#include "NessLab.h"
16
+
17
+extern void NessLab_Operate(uint8_t* data);
18
+
19
+UARTQUEUE TerminalQueue;
20
+UARTQUEUE WifiQueue;
21
+uart_hal_tx_type uart_hal_tx;
22
+extern volatile uint32_t UartRxTimerCnt;
23
+
24
+extern bool Bluecell_Operate(uint8_t* data);
25
+extern void MBIC_Operate(uint8_t * data);
26
+
27
+void InitUartQueue(pUARTQUEUE pQueue)
28
+{
29
+  pQueue->data = pQueue->head = pQueue->tail = 0;
30
+  uart_hal_tx.output_p = uart_hal_tx.input_p = 0;
31
+//  HAL_UART_Receive_IT(&huart2,rxBuf,5);
32
+
33
+
34
+
35
+  if (HAL_UART_Receive_DMA(&hTerminal, TerminalQueue.Buffer, 1) != HAL_OK)
36
+  //if (HAL_UART_Receive_IT(&hTerminal, TerminalQueue.Buffer, 1) != HAL_OK)
37
+  {
38
+//    _Error_Handler(__FILE__, __LINE__);
39
+  }  
40
+//  if (HAL_UART_Receive_DMA(&hTest, TerminalQueue.Buffer, 1) != HAL_OK)
41
+//  {
42
+////    _Error_Handler(__FILE__, __LINE__);
43
+//  }
44
+  //HAL_UART_Receive_DMA(&hTerminal,  TerminalQueue.Buffer, 1);
45
+  //HAL_UART_Receive_IT(hTerminal, pQueue->Buffer + pQueue->head, 1);
46
+}
47
+
48
+void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
49
+{
50
+//    UART_HandleTypeDef *dst = (huart->Instance == USART2 ? &hTest:&hTerminal);
51
+    pUARTQUEUE pQueue;
52
+   // printf("Function : %s : \r\n",__func__);
53
+    //printf("%02x ",uart_buf[i]);
54
+    UartRxTimerCnt = 0;
55
+    pQueue = &TerminalQueue;
56
+    pQueue->head++;
57
+    if (pQueue->head >= QUEUE_BUFFER_LENGTH) pQueue->head = 0;
58
+    pQueue->data++;
59
+    if (pQueue->data >= QUEUE_BUFFER_LENGTH)
60
+        GetDataFromUartQueue(huart);
61
+    HAL_UART_Receive_IT(&hTerminal, pQueue->Buffer + pQueue->head, 1);
62
+//    HAL_UART_Receive_DMA(&hTest, pQueue->Buffer + pQueue->head, 1);
63
+   // Set_UartRcv(true);
64
+}
65
+
66
+
67
+
68
+void PutDataToUartQueue(UART_HandleTypeDef *huart, uint8_t data)
69
+{
70
+    pUARTQUEUE pQueue = &TerminalQueue;
71
+    if (pQueue->data >= QUEUE_BUFFER_LENGTH)
72
+        GetDataFromUartQueue(huart);
73
+    pQueue->Buffer[pQueue->head++] = data;
74
+    if (pQueue->head == QUEUE_BUFFER_LENGTH) pQueue->head = 0;
75
+    pQueue->data++;
76
+   // HAL_UART_Receive_DMA(&hTerminal,  pQueue->Buffer + pQueue->head, 10);
77
+}
78
+
79
+uint8_t uart_buf[QUEUE_BUFFER_LENGTH];
80
+void GetDataFromUartQueue(UART_HandleTypeDef *huart)
81
+{
82
+    volatile static int cnt;
83
+ /*   bool chksumret = 0;
84
+    uint16_t Length = 0;
85
+    uint16_t CrcChk = 0;
86
+    UART_HandleTypeDef *dst = (huart->Instance == USART2 ? &hTest:&hTerminal);*/
87
+//    UART_HandleTypeDef *dst = &hTerminal;
88
+    pUARTQUEUE pQueue = &TerminalQueue;
89
+//    if (HAL_UART_Transmit(dst, pQueue->Buffer + pQueue->tail, 1, 3000) != HAL_OK)
90
+//    {
91
+//       _Error_Handler(__FILE__, __LINE__);
92
+//    }
93
+    uart_buf[cnt++] = *(pQueue->Buffer + pQueue->tail); 
94
+//#ifdef DEBUG_PRINT
95
+//    printf("%02x ",*(pQueue->Buffer + pQueue->tail)) ;
96
+//#endif /* DEBUG_PRINT */
97
+
98
+    pQueue->tail++;
99
+    if (pQueue->tail >= QUEUE_BUFFER_LENGTH) pQueue->tail = 0;
100
+    pQueue->data--;
101
+    
102
+    if(pQueue->data == 0){
103
+
104
+//        printf("data cnt zero !!!  \r\n");
105
+        //RF_Ctrl_Main(&uart_buf[Header]);
106
+//        HAL_UART_Transmit(dst, &temp_buf[BLUECELL_HEADER00], 11, 3000);
107
+#if 0// PYJ.2019.07.15_BEGIN --
108
+            printf("\r\n[RX]");
109
+            for(int i = 0; i < cnt; i++){
110
+                printf("%02x ",uart_buf[i]);
111
+            }
112
+            printf(ANSI_COLOR_GREEN"\r\n CNT : %d \r\n"ANSI_COLOR_RESET,cnt);
113
+#endif // PYJ.2019.07.15_END --
114
+        if(NessLab_CheckSum_Check(&uart_buf[NessLab_MsgID0],uart_buf[NessLab_DataLength],uart_buf[NessLab_Checksum]) == true){
115
+			NessLab_Operate(&uart_buf[0]);
116
+        }
117
+		cnt = 0;
118
+
119
+    }
120
+
121
+}
122
+void Uart_Check(void){
123
+  while (TerminalQueue.data > 0 && UartRxTimerCnt > 50) GetDataFromUartQueue(&hTerminal);
124
+}
125
+
126
+
127
+void Uart1_Data_Send(uint8_t* data,uint16_t size){
128
+
129
+      HAL_UART_Transmit_DMA(&hTerminal, &data[0],size);
130
+  //HAL_UART_Transmit_IT(&hTerminal, &data[0],size);
131
+//    printf("data[278] : %x \r\n",data[278]);
132
+////    HAL_Delay(1);   
133
+#if 0 // PYJ.2020.07.19_BEGIN -- 
134
+    printf("\r\n [TX] : ");
135
+    for(int i = 0; i< size; i++)
136
+        printf("%02x ",data[i]);
137
+//    printf("};\r\n\tCOUNT : %d \r\n",size);
138
+    printf("\r\n");
139
+#endif // PYJ.2020.07.19_END -- 
140
+//    printf("\r\n [TX] : {");
141
+//    for(int i = 0; i< size; i++){
142
+//        printf(",%02x ",data[i]);
143
+//        data[i] = 0;
144
+//    }
145
+//    printf("};\r\n\tCOUNT : %d \r\n",size);
146
+//    printf("\r\n");
147
+    
148
+}
149
+

+ 2 - 0
insight/Nesslab_200M_System.si4project/Nesslab_200M_System.SearchResults

@@ -0,0 +1,2 @@
1
+---- Nesslab_Prot Matches (1 in 1 files) ----
2
+adc.c (D:\CubeIDE_Workspace\Nesslab_200M_System\Bluecell_Src) line 14 : extern Nesslab_Prot Currstatus;

+ 7 - 0
insight/Nesslab_200M_System.si4project/Nesslab_200M_System.bookmarks.xml

@@ -0,0 +1,7 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<SourceInsightBookmarks
3
+	AppVer="4.00.0116"
4
+	AppVerMinReader="4.00.0009"
5
+	>
6
+	<Bookmarks/>
7
+</SourceInsightBookmarks>

BIN
insight/Nesslab_200M_System.si4project/Nesslab_200M_System.sip_sym


BIN
insight/Nesslab_200M_System.si4project/Nesslab_200M_System.sip_xab


BIN
insight/Nesslab_200M_System.si4project/Nesslab_200M_System.sip_xad


BIN
insight/Nesslab_200M_System.si4project/Nesslab_200M_System.sip_xc


BIN
insight/Nesslab_200M_System.si4project/Nesslab_200M_System.sip_xf


BIN
insight/Nesslab_200M_System.si4project/Nesslab_200M_System.sip_xm


BIN
insight/Nesslab_200M_System.si4project/Nesslab_200M_System.sip_xr


BIN
insight/Nesslab_200M_System.si4project/Nesslab_200M_System.sip_xsb


BIN
insight/Nesslab_200M_System.si4project/Nesslab_200M_System.sip_xsd


BIN
insight/Nesslab_200M_System.si4project/Nesslab_200M_System.siproj


+ 1 - 1
insight/Nesslab_200M_System.si4project/Nesslab_200M_System.siproj_settings.xml

@@ -1,6 +1,6 @@
1 1
 <?xml version="1.0" encoding="utf-8"?>
2 2
 <ProjectSettings
3
-	AppVer="4.00.0098"
3
+	AppVer="4.00.0116"
4 4
 	AppVerMinReader="4.00.0034"
5 5
 	GlobalConfiguration="1"
6 6
 	GlobalWorkspace="0"

BIN
insight/Nesslab_200M_System.si4project/Nesslab_200M_System.siwork


+ 7 - 0
insight/Nesslab_200M_System.si4project/Nesslab_200M_System.snippets.xml

@@ -0,0 +1,7 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<SourceInsightCodeSnippets
3
+	AppVer="4.00.0116"
4
+	AppVerMinReader="4.00.0019"
5
+	>
6
+	<SnippetList/>
7
+</SourceInsightCodeSnippets>

BIN
insight/Nesslab_200M_System.si4project/cache/parse/.._Bluecell_Inc_NessLab.h.sisc


BIN
insight/Nesslab_200M_System.si4project/cache/parse/.._Bluecell_Inc_adc.h.sisc


BIN
insight/Nesslab_200M_System.si4project/cache/parse/.._Bluecell_Inc_crc.h.sisc


BIN
insight/Nesslab_200M_System.si4project/cache/parse/.._Bluecell_Inc_led.h.sisc


BIN
insight/Nesslab_200M_System.si4project/cache/parse/.._Bluecell_Inc_uart.h.sisc


BIN
insight/Nesslab_200M_System.si4project/cache/parse/.._Bluecell_Src_NessLab.c.sisc


BIN
insight/Nesslab_200M_System.si4project/cache/parse/.._Bluecell_Src_adc.c.sisc


BIN
insight/Nesslab_200M_System.si4project/cache/parse/.._Bluecell_Src_crc.c.sisc


BIN
insight/Nesslab_200M_System.si4project/cache/parse/.._Bluecell_Src_led.c.sisc


BIN
insight/Nesslab_200M_System.si4project/cache/parse/.._Bluecell_Src_uart.c.sisc


BIN
insight/Nesslab_200M_System.si4project/cache/parse/.._Drivers_CMSIS_Device_ST_STM32F1xx_Include_stm32f100xb.h.sisc


BIN
insight/Nesslab_200M_System.si4project/cache/parse/.._Drivers_CMSIS_Device_ST_STM32F1xx_Include_stm32f1xx.h.sisc


BIN
insight/Nesslab_200M_System.si4project/cache/parse/.._Drivers_CMSIS_Device_ST_STM32F1xx_Include_system_stm32f1xx.h.sisc


BIN
insight/Nesslab_200M_System.si4project/cache/parse/.._Drivers_CMSIS_Include_cmsis_armcc.h.sisc


BIN
insight/Nesslab_200M_System.si4project/cache/parse/.._Drivers_CMSIS_Include_cmsis_armclang.h.sisc


BIN
insight/Nesslab_200M_System.si4project/cache/parse/.._Drivers_CMSIS_Include_cmsis_compiler.h.sisc


BIN
insight/Nesslab_200M_System.si4project/cache/parse/.._Drivers_CMSIS_Include_cmsis_gcc.h.sisc


BIN
insight/Nesslab_200M_System.si4project/cache/parse/.._Drivers_CMSIS_Include_cmsis_iccarm.h.sisc


BIN
insight/Nesslab_200M_System.si4project/cache/parse/.._Drivers_CMSIS_Include_cmsis_version.h.sisc


BIN
insight/Nesslab_200M_System.si4project/cache/parse/.._Drivers_CMSIS_Include_core_armv8mbl.h.sisc


BIN
insight/Nesslab_200M_System.si4project/cache/parse/.._Drivers_CMSIS_Include_core_armv8mml.h.sisc


BIN
insight/Nesslab_200M_System.si4project/cache/parse/.._Drivers_CMSIS_Include_core_cm0.h.sisc


BIN
insight/Nesslab_200M_System.si4project/cache/parse/.._Drivers_CMSIS_Include_core_cm0plus.h.sisc


BIN
insight/Nesslab_200M_System.si4project/cache/parse/.._Drivers_CMSIS_Include_core_cm1.h.sisc


BIN
insight/Nesslab_200M_System.si4project/cache/parse/.._Drivers_CMSIS_Include_core_cm23.h.sisc


BIN
insight/Nesslab_200M_System.si4project/cache/parse/.._Drivers_CMSIS_Include_core_cm3.h.sisc


BIN
insight/Nesslab_200M_System.si4project/cache/parse/.._Drivers_CMSIS_Include_core_cm33.h.sisc


BIN
insight/Nesslab_200M_System.si4project/cache/parse/.._Drivers_CMSIS_Include_core_cm4.h.sisc


BIN
insight/Nesslab_200M_System.si4project/cache/parse/.._Drivers_CMSIS_Include_core_cm7.h.sisc


+ 0 - 0
insight/Nesslab_200M_System.si4project/cache/parse/.._Drivers_CMSIS_Include_core_sc000.h.sisc


Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden.