From b11b36a943d6d8013dddfb77945c67317169a4b6 Mon Sep 17 00:00:00 2001
From: Heltec-Aaron-Lee <support@heltec.cn>
Date: Thu, 21 May 2020 15:31:59 +0800
Subject: [PATCH] update boards' name

---
 boards.txt                                    | 88 +++++++++++++++++--
 cores/asr650x/board/src/asr_board.c           |  3 +-
 .../examples/ADC_battery/ADC_battery.ino      | 13 +--
 libraries/LoRa/src/LoRaWan_APP.cpp            |  4 +
 libraries/LoRa/src/LoRaWan_APP.h              |  2 +-
 variants/CubeCell-HalfAA/pins_arduino.h       | 54 ++++++++++++
 variants/CubeCell-Module/pins_arduino.h       |  3 -
 variants/CubeCell-ModulePlus/pins_arduino.h   |  5 +-
 8 files changed, 146 insertions(+), 26 deletions(-)
 create mode 100644 variants/CubeCell-HalfAA/pins_arduino.h

diff --git a/boards.txt b/boards.txt
index 966e8031..b249e434 100644
--- a/boards.txt
+++ b/boards.txt
@@ -9,7 +9,7 @@ menu.LORAWAN_RGB=LORAWAN_RGB
 menu.LORAWAN_DebugLevel=LoRaWan Debug Level
 ##############################################################
 
-CubeCell-Board.name=CubeCell-Board
+CubeCell-Board.name=CubeCell-Board(HTCC-AB01)
 
 CubeCell-Board.upload.tool=CubeCellflash
 CubeCell-Board.upload.maximum_size=131072
@@ -86,7 +86,7 @@ CubeCell-Board.menu.LORAWAN_DebugLevel.2=Freq && DIO
 CubeCell-Board.menu.LORAWAN_DebugLevel.2.build.LORAWAN_DebugLevel=2
 ##############################################################
 
-CubeCell-Capsule.name=CubeCell-Capsule
+CubeCell-Capsule.name=CubeCell-Capsule(HTCC-AC0X)
 
 CubeCell-Capsule.upload.tool=CubeCellflash
 CubeCell-Capsule.upload.maximum_size=131072
@@ -164,7 +164,7 @@ CubeCell-Capsule.menu.LORAWAN_DebugLevel.2=Freq && DIO
 CubeCell-Capsule.menu.LORAWAN_DebugLevel.2.build.LORAWAN_DebugLevel=2
 ##############################################################
 
-CubeCell-Module.name=CubeCell-Module
+CubeCell-Module.name=CubeCell-Module(HTCC-AM01)
 
 CubeCell-Module.upload.tool=CubeCellflash
 CubeCell-Module.upload.maximum_size=131072
@@ -240,7 +240,7 @@ CubeCell-Module.menu.LORAWAN_DebugLevel.2.build.LORAWAN_DebugLevel=2
 
 ###############################
 
-CubeCell-BoardPlus.name=CubeCell-BoardPlus
+CubeCell-BoardPlus.name=CubeCell-Board Plus(HTCC-AB02)
 
 CubeCell-BoardPlus.upload.tool=CubeCellflash
 CubeCell-BoardPlus.upload.maximum_size=131072
@@ -317,7 +317,7 @@ CubeCell-BoardPlus.menu.LORAWAN_DebugLevel.2=Freq && DIO
 CubeCell-BoardPlus.menu.LORAWAN_DebugLevel.2.build.LORAWAN_DebugLevel=2
 ##############################################################
 
-CubeCell-GPS.name=CubeCell-GPS
+CubeCell-GPS.name=CubeCell-GPS(HTCC-AB02S)
 
 CubeCell-GPS.upload.tool=CubeCellflash
 CubeCell-GPS.upload.maximum_size=131072
@@ -395,7 +395,7 @@ CubeCell-GPS.menu.LORAWAN_DebugLevel.2=Freq && DIO
 CubeCell-GPS.menu.LORAWAN_DebugLevel.2.build.LORAWAN_DebugLevel=2
 ##############################################################
 
-CubeCell-ModulePlus.name=CubeCell-ModulePlus
+CubeCell-ModulePlus.name=CubeCell-Module Plus(HTCC-AM02)
 
 CubeCell-ModulePlus.upload.tool=CubeCellflash
 CubeCell-ModulePlus.upload.maximum_size=131072
@@ -467,4 +467,78 @@ CubeCell-ModulePlus.menu.LORAWAN_DebugLevel.0.build.LORAWAN_DebugLevel=0
 CubeCell-ModulePlus.menu.LORAWAN_DebugLevel.1=Freq
 CubeCell-ModulePlus.menu.LORAWAN_DebugLevel.1.build.LORAWAN_DebugLevel=1
 CubeCell-ModulePlus.menu.LORAWAN_DebugLevel.2=Freq && DIO
-CubeCell-ModulePlus.menu.LORAWAN_DebugLevel.2.build.LORAWAN_DebugLevel=2
\ No newline at end of file
+CubeCell-ModulePlus.menu.LORAWAN_DebugLevel.2.build.LORAWAN_DebugLevel=2
+###############################
+CubeCell-1/2AA.name=CubeCell-1/2AA Node(HTCC-AB02A)
+
+CubeCell-1/2AA.upload.tool=CubeCellflash
+CubeCell-1/2AA.upload.maximum_size=131072
+CubeCell-1/2AA.upload.maximum_data_size=131072
+CubeCell-1/2AA.upload.wait_for_upload_port=true
+
+CubeCell-1/2AA.build.board=CubeCell_HalfAA
+CubeCell-1/2AA.build.core=asr650x
+CubeCell-1/2AA.build.variant=CubeCell-HalfAA
+
+CubeCell-1/2AA.menu.LORAWAN_REGION.923AS=REGION_AS923
+CubeCell-1/2AA.menu.LORAWAN_REGION.923AS.build.band=REGION_AS923
+CubeCell-1/2AA.menu.LORAWAN_REGION.915AU=REGION_AU915
+CubeCell-1/2AA.menu.LORAWAN_REGION.915AU.build.band=REGION_AU915
+CubeCell-1/2AA.menu.LORAWAN_REGION.470CN=REGION_CN470
+CubeCell-1/2AA.menu.LORAWAN_REGION.470CN.build.band=REGION_CN470
+CubeCell-1/2AA.menu.LORAWAN_REGION.779CN=REGION_CN779
+CubeCell-1/2AA.menu.LORAWAN_REGION.779CN.build.band=REGION_CN779
+CubeCell-1/2AA.menu.LORAWAN_REGION.433EU=REGION_EU433
+CubeCell-1/2AA.menu.LORAWAN_REGION.433EU.build.band=REGION_EU433
+CubeCell-1/2AA.menu.LORAWAN_REGION.868EU=REGION_EU868
+CubeCell-1/2AA.menu.LORAWAN_REGION.868EU.build.band=REGION_EU868
+CubeCell-1/2AA.menu.LORAWAN_REGION.920KR=REGION_KR920
+CubeCell-1/2AA.menu.LORAWAN_REGION.920KR.build.band=REGION_KR920
+CubeCell-1/2AA.menu.LORAWAN_REGION.865IN=REGION_IN865
+CubeCell-1/2AA.menu.LORAWAN_REGION.865IN.build.band=REGION_IN865
+CubeCell-1/2AA.menu.LORAWAN_REGION.915US=REGION_US915
+CubeCell-1/2AA.menu.LORAWAN_REGION.915US.build.band=REGION_US915
+CubeCell-1/2AA.menu.LORAWAN_REGION.915_HYBRID=REGION_US915_HYBRID
+CubeCell-1/2AA.menu.LORAWAN_REGION.915_HYBRID.build.band=REGION_US915_HYBRID
+
+CubeCell-1/2AA.menu.LORAWAN_CLASS.0=CLASS_A
+CubeCell-1/2AA.menu.LORAWAN_CLASS.0.build.LORAWAN_CLASS=CLASS_A
+##CubeCell-GPS.menu.LORAWAN_CLASS.1=CLASS_B
+##CubeCell-GPS.menu.LORAWAN_CLASS.1.build.LORAWAN_CLASS=CLASS_B
+CubeCell-1/2AA.menu.LORAWAN_CLASS.2=CLASS_C
+CubeCell-1/2AA.menu.LORAWAN_CLASS.2.build.LORAWAN_CLASS=CLASS_C
+
+CubeCell-1/2AA.menu.LORAWAN_NETMODE.0=OTAA
+CubeCell-1/2AA.menu.LORAWAN_NETMODE.0.build.LORAWAN_NETMODE=true
+CubeCell-1/2AA.menu.LORAWAN_NETMODE.1=ABP
+CubeCell-1/2AA.menu.LORAWAN_NETMODE.1.build.LORAWAN_NETMODE=false
+
+CubeCell-1/2AA.menu.LORAWAN_ADR.0=ON
+CubeCell-1/2AA.menu.LORAWAN_ADR.0.build.LORAWAN_ADR=true
+CubeCell-1/2AA.menu.LORAWAN_ADR.1=OFF
+CubeCell-1/2AA.menu.LORAWAN_ADR.1.build.LORAWAN_ADR=false
+
+CubeCell-1/2AA.menu.LORAWAN_UPLINKMODE.0=CONFIRMED
+CubeCell-1/2AA.menu.LORAWAN_UPLINKMODE.0.build.LORAWAN_UPLINKMODE=true
+CubeCell-1/2AA.menu.LORAWAN_UPLINKMODE.1=UNCONFIRMED
+CubeCell-1/2AA.menu.LORAWAN_UPLINKMODE.1.build.LORAWAN_UPLINKMODE=false
+
+CubeCell-1/2AA.menu.LORAWAN_Net_Reserve.0=OFF
+CubeCell-1/2AA.menu.LORAWAN_Net_Reserve.0.build.LORAWAN_Net_Reserve=false
+CubeCell-1/2AA.menu.LORAWAN_Net_Reserve.1=ON
+CubeCell-1/2AA.menu.LORAWAN_Net_Reserve.1.build.LORAWAN_Net_Reserve=true
+
+CubeCell-1/2AA.menu.LORAWAN_AT_SUPPORT.0=ON
+CubeCell-1/2AA.menu.LORAWAN_AT_SUPPORT.0.build.LORAWAN_AT_SUPPORT=1
+CubeCell-1/2AA.menu.LORAWAN_AT_SUPPORT.1=OFF
+CubeCell-1/2AA.menu.LORAWAN_AT_SUPPORT.1.build.LORAWAN_AT_SUPPORT=0
+
+CubeCell-1/2AA.menu.LORAWAN_RGB.0=DEACTIVE
+CubeCell-1/2AA.menu.LORAWAN_RGB.0.build.RGB=0
+
+CubeCell-1/2AA.menu.LORAWAN_DebugLevel.0=None
+CubeCell-1/2AA.menu.LORAWAN_DebugLevel.0.build.LORAWAN_DebugLevel=0
+CubeCell-1/2AA.menu.LORAWAN_DebugLevel.1=Freq
+CubeCell-1/2AA.menu.LORAWAN_DebugLevel.1.build.LORAWAN_DebugLevel=1
+CubeCell-1/2AA.menu.LORAWAN_DebugLevel.2=Freq && DIO
+CubeCell-1/2AA.menu.LORAWAN_DebugLevel.2.build.LORAWAN_DebugLevel=2
\ No newline at end of file
diff --git a/cores/asr650x/board/src/asr_board.c b/cores/asr650x/board/src/asr_board.c
index ea302f66..87134e45 100644
--- a/cores/asr650x/board/src/asr_board.c
+++ b/cores/asr650x/board/src/asr_board.c
@@ -463,11 +463,12 @@ void boardInitMcu( void )
     SpiInit();
     Asr_Timer_Init();
     RtcInit();
-
+#if defined(CubeCell_Board)||defined(CubeCell_Capsule)||defined(CubeCell_BoardPlus)||defined(CubeCell_GPS)||defined(CubeCell_HalfAA)
     pinMode(Vext,OUTPUT);
     digitalWrite(Vext,HIGH);
     pinMode(VBAT_ADC_CTL,OUTPUT);
     digitalWrite(VBAT_ADC_CTL,HIGH);
+#endif
     SX126xIoInit();
     delay(10);
     SX126xReset();
diff --git a/libraries/Basics/examples/ADC_battery/ADC_battery.ino b/libraries/Basics/examples/ADC_battery/ADC_battery.ino
index 1858042e..79f99d0d 100644
--- a/libraries/Basics/examples/ADC_battery/ADC_battery.ino
+++ b/libraries/Basics/examples/ADC_battery/ADC_battery.ino
@@ -1,21 +1,14 @@
 #include "Arduino.h"
-
+#include "LoRaWan_APP.h"
 
 void setup() {
   // put your setup code here, to run once:
   Serial.begin(115200);
 }
 
-uint16_t voltage;
-
 void loop() {
   // put your main code here, to run repeatedly:
-  pinMode(VBAT_ADC_CTL,OUTPUT);
-  digitalWrite(VBAT_ADC_CTL,LOW);
-  uint16_t voltage=analogRead(ADC)*2;
-  digitalWrite(VBAT_ADC_CTL,HIGH);
-  Serial.print(millis());
-  Serial.print("  ");
+  uint16_t voltage = getBatteryVoltage();
   Serial.println(voltage);
   delay(1000);
-}
+}
\ No newline at end of file
diff --git a/libraries/LoRa/src/LoRaWan_APP.cpp b/libraries/LoRa/src/LoRaWan_APP.cpp
index cccc0186..b148de31 100644
--- a/libraries/LoRa/src/LoRaWan_APP.cpp
+++ b/libraries/LoRa/src/LoRaWan_APP.cpp
@@ -244,10 +244,14 @@ void turnOffRGB(void)
 /*  get the BatteryVoltage in mV. */
 uint16_t getBatteryVoltage(void)
 {
+#if defined(CubeCell_Board)||defined(CubeCell_Capsule)||defined(CubeCell_BoardPlus)||defined(CubeCell_GPS)||defined(CubeCell_HalfAA)
 	pinMode(VBAT_ADC_CTL,OUTPUT);
 	digitalWrite(VBAT_ADC_CTL,LOW);
 	uint16_t volt=analogRead(ADC)*2;
 	digitalWrite(VBAT_ADC_CTL,HIGH);
+#else
+	uint16_t volt=analogRead(ADC)*2;
+#endif
 	return volt;
 }
 
diff --git a/libraries/LoRa/src/LoRaWan_APP.h b/libraries/LoRa/src/LoRaWan_APP.h
index 494aa5d1..edac6d0c 100644
--- a/libraries/LoRa/src/LoRaWan_APP.h
+++ b/libraries/LoRa/src/LoRaWan_APP.h
@@ -70,7 +70,7 @@ class LoRaWanClass{
 #endif
 };
 
-
+extern "C" uint16_t getBatteryVoltage(void);
 extern "C" bool SendFrame( void );
 extern "C" void turnOnRGB(uint32_t color,uint32_t time);
 extern "C" void turnOffRGB(void);
diff --git a/variants/CubeCell-HalfAA/pins_arduino.h b/variants/CubeCell-HalfAA/pins_arduino.h
new file mode 100644
index 00000000..e8b96dcc
--- /dev/null
+++ b/variants/CubeCell-HalfAA/pins_arduino.h
@@ -0,0 +1,54 @@
+#ifndef Pins_Arduino_h
+#define Pins_Arduino_h
+
+#include <stdint.h>
+
+#define MCU_PINS \
+    P0_0 = 0, P0_1, P0_2, P0_3, P0_4, P0_5, P0_6, P0_7,  \
+    P1_0 , P1_1, P1_2, P1_3, P1_4, P1_5, P1_6, P1_7,  \
+    P2_0 , P2_1, P2_2, P2_3, P2_4, P2_5, P2_6, P2_7,  \
+    P3_0 , P3_1, P3_2, P3_3, P3_4, P3_5, P3_6, P3_7,  \
+    P4_0 , P4_1, P4_2, P4_3, P4_4, P4_5, P4_6, P4_7,  \
+    P5_0 , P5_1, P5_2, P5_3, P5_4, P5_5, P5_6, P5_7,  \
+    P6_0 , P6_1, P6_2, P6_3, P6_4, P6_5, P6_6, P6_7,  \
+    P7_0 , P7_1, P7_2, P7_3, P7_4, P7_5, P7_6, P7_7  
+    
+typedef enum
+{
+    MCU_PINS,
+    NC = (int)0xFFFFFFFF    
+}PinNames;    
+
+#define UART_RX P3_0
+#define UART_TX P3_1
+#define UART_RX1 UART_RX
+#define UART_TX1 UART_TX
+#define UART_RX2 P4_4
+#define UART_TX2 P4_5
+#define Vext P3_2 
+#define VBAT_ADC_CTL P3_3 
+#define USER_KEY P3_3
+#define SDA P0_1
+#define SCL P0_0
+#define PWM1 P6_2 
+#define PWM2 P6_4
+#define ADC1 P2_0
+#define ADC ADC1
+#define ADC2 P2_1
+#define ADC3 P2_2
+#define GPIO1 P6_1
+#define GPIO2 P6_2
+#define GPIO3 P6_3
+#define GPIO4 P6_4
+#define GPIO5 P3_4
+#define GPIO6 P3_6
+#define GPIO7 P3_7
+#define GPIO8 P7_0
+#define GPIO9 P7_1
+#define GPIO10 P7_2
+#define GPIO11 P0_2
+#define GPIO12 P0_3
+#define GPIO13 P0_6 
+#define GPIO14 P0_7
+
+#endif /* Pins_Arduino_h */
diff --git a/variants/CubeCell-Module/pins_arduino.h b/variants/CubeCell-Module/pins_arduino.h
index ddcf83c7..5ba23372 100644
--- a/variants/CubeCell-Module/pins_arduino.h
+++ b/variants/CubeCell-Module/pins_arduino.h
@@ -21,8 +21,6 @@ typedef enum
 
 #define UART_RX P3_0
 #define UART_TX P3_1
-#define Vext P3_2 //gpio6
-#define VBAT_ADC_CTL P3_3 //gpio7
 #define USER_KEY P3_3
 #define GPIO0 P0_2
 #define GPIO1 P6_1
@@ -37,6 +35,5 @@ typedef enum
 #define ADC P2_3
 #define PWM1 P6_2 //gpio2
 #define PWM2 P6_4 //gpio3
-#define RGB P0_7 //gpio4
 
 #endif /* Pins_Arduino_h */
diff --git a/variants/CubeCell-ModulePlus/pins_arduino.h b/variants/CubeCell-ModulePlus/pins_arduino.h
index 3d123220..e463e82a 100644
--- a/variants/CubeCell-ModulePlus/pins_arduino.h
+++ b/variants/CubeCell-ModulePlus/pins_arduino.h
@@ -25,12 +25,9 @@ typedef enum
 #define UART_TX1 UART_TX
 #define UART_RX2 P4_4
 #define UART_TX2 P4_5
-#define Vext P3_2 
-#define VBAT_ADC_CTL P3_3 
 #define USER_KEY P3_3
 #define SDA P0_1
 #define SCL P0_0
-#define RGB P0_6  //GPIO13
 #define PWM1 P6_2 
 #define PWM2 P6_4
 #define ADC1 P2_0
@@ -49,7 +46,7 @@ typedef enum
 #define GPIO10 P7_2
 #define GPIO11 P0_2
 #define GPIO12 P0_3
-#define GPIO13 P0_6 //RGB
+#define GPIO13 P0_6
 #define GPIO14 P0_7
 
 #endif /* Pins_Arduino_h */