Compare commits
61 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 443f200ce4 | |||
| f47e701185 | |||
| 4f2a34530c | |||
| 75d92df998 | |||
| bc39829ad2 | |||
| a9fd1c79c8 | |||
| 551b412329 | |||
| 7d79d4e6df | |||
| 83e2a6537c | |||
| 509419610b | |||
| 4d5c4182fd | |||
| 91fadb0d97 | |||
| 0ff4833fb0 | |||
| 2f2967c09a | |||
| ba5b306fd5 | |||
| 2190115d6f | |||
| a7d083c6bc | |||
| 7f51e113d6 | |||
| 651e42d218 | |||
| 8bbd4dbb41 | |||
| a032346630 | |||
| 6b78e8ebbe | |||
| 824ec33776 | |||
| 969a726332 | |||
| 1215f8a30c | |||
| 89e7706ac2 | |||
| 352e6f5e3b | |||
| 87c82df18c | |||
| 8f4eb259cf | |||
| ad12b9e857 | |||
| 3c91123424 | |||
| 0c602842a3 | |||
| a36b9e3ec2 | |||
| c7a92aa317 | |||
| 9ea145192e | |||
| 82abbcc528 | |||
| b99b75a31d | |||
| f5fa44b95a | |||
| ff64788ba4 | |||
| 1c49b2e204 | |||
| 171e3b2df6 | |||
| 16636e1c1d | |||
| 817eb45cb8 | |||
| 2ea3c76a49 | |||
| 4fc2c9c348 | |||
| a321ea5f3e | |||
| 13ace26dd0 | |||
| ceb73191dc | |||
| d5b5ebdadb | |||
| 9ac63d8313 | |||
| 0966c99b20 | |||
| 6f51cc35e2 | |||
| e85974b12b | |||
| f342ff0763 | |||
| cbe9bd8211 | |||
| 0293647d0c | |||
| 87d187c3a5 | |||
| 09fbfd9dda | |||
| 74ca631309 | |||
| 03e86e175d | |||
| 1c54525256 |
BIN
Binary file not shown.
+1
-1
@@ -16,7 +16,7 @@ BIOS_INC = -I"C:/ti/tirtos_cc13xx_cc26xx_2_21_01_08/products/bios_6_46_01_38/pa
|
||||
|
||||
TARGET_INC = -I"C:/ti/tirtos_cc13xx_cc26xx_2_21_01_08/products/bios_6_46_01_38/packages/"
|
||||
|
||||
INCS = $(BIOS_INC) $(TARGET_INC) --include_path="C:/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.3.LTS/include" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/inc" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/icall/inc" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/profiles/roles/cc26xx" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/profiles/roles" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/profiles/dev_info" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/profiles/simple_profile/cc26xx" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/profiles/simple_profile" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/common/cc26xx" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/components/heapmgr" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/controller/cc26xx/inc" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/components/hal/src/target/_common" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/target" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/components/hal/src/target/_common/cc26xx" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/components/hal/src/inc" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/components/osal/src/inc" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/components/services/src/sdata" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/components/services/src/saddr" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/components/icall/src/inc" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/inc" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/rom" --include_path="C:/ti/tirtos_cc13xx_cc26xx_2_21_01_08/products/cc26xxware_2_24_03_17272" -IC:/ti/tirtos_cc13xx_cc26xx_2_21_01_08/products/bios_6_46_01_38/packages/
|
||||
INCS = $(BIOS_INC) $(TARGET_INC) --include_path="C:/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.3.LTS/include" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/inc" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/icall/inc" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/profiles/roles/cc26xx" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/profiles/roles" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/profiles/dev_info" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/profiles/simple_profile/cc26xx" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/profiles/simple_profile" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/common/cc26xx" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/components/heapmgr" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/controller/cc26xx/inc" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/components/hal/src/target/_common" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/target" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/components/hal/src/target/_common/cc26xx" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/components/hal/src/inc" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/components/osal/src/inc" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/components/services/src/sdata" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/components/services/src/saddr" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/components/icall/src/inc" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/inc" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/rom" --include_path="C:/ti/tirtos_cc13xx_cc26xx_2_21_01_08/products/cc26xxware_2_24_03_17272" -IC:/ti/tirtos_cc13xx_cc26xx_2_21_01_08/products/bios_6_46_01_38/packages/
|
||||
|
||||
CC = C:/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.3.LTS/bin/armcl -c $(CCOPTS) -I C:/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.3.LTS/include
|
||||
ASM = C:/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.3.LTS/bin/armcl -c $(CCOPTS) -I C:/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.3.LTS/include
|
||||
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
@@ -106,7 +106,7 @@ extern const PIN_Config BoardGpioInitTable[];
|
||||
#define Board_BP_Pin_J2_15 DIO8 /* MOSI */
|
||||
#define Board_BP_Pin_J2_14 DIO7 /* MISO */
|
||||
#define Board_BP_Pin_J2_13 DIO9 /* DAC_CS */
|
||||
#define Board_BP_Pin_J2_12 DIO12 /* ADC_CS */
|
||||
#define Board_BP_Pin_J2_12 DIO12 /* AD_CS */
|
||||
#define Board_BP_Pin_J2_11 IOID_UNUSED /* NC */
|
||||
|
||||
/* Mapping of BoosterPack Connector Pins to BoosterPack Standard Functions (reflecting the BoosterPack Standard)
|
||||
|
||||
-217
@@ -1,217 +0,0 @@
|
||||
|
||||
#ifndef Elite15_PIN
|
||||
#define Elite_15PIN
|
||||
|
||||
#include "Elite_PIN.h"
|
||||
|
||||
static void update_latch_status (uint32_t latch_num, uint32_t elite_pin, bool highlow) {
|
||||
switch (latch_num) {
|
||||
case LOAD0: {
|
||||
switch (elite_pin) {
|
||||
case D0: {
|
||||
LH.LATCH0[0] = highlow;
|
||||
break;
|
||||
}
|
||||
case D1: {
|
||||
LH.LATCH0[1] = highlow;
|
||||
break;
|
||||
}
|
||||
case D2: {
|
||||
LH.LATCH0[2] = highlow;
|
||||
break;
|
||||
}
|
||||
case D3: {
|
||||
LH.LATCH0[3] = highlow;
|
||||
break;
|
||||
}
|
||||
case D4: {
|
||||
LH.LATCH0[4] = highlow;
|
||||
break;
|
||||
}
|
||||
case D5: {
|
||||
LH.LATCH0[5] = highlow;
|
||||
break;
|
||||
}
|
||||
case D6: {
|
||||
LH.LATCH0[6] = highlow;
|
||||
break;
|
||||
}
|
||||
case D7: {
|
||||
LH.LATCH0[7] = highlow;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case LOAD1: {
|
||||
switch (elite_pin) {
|
||||
case D0: {
|
||||
LH.LATCH1[0] = highlow;
|
||||
break;
|
||||
}
|
||||
case D1: {
|
||||
LH.LATCH1[1] = highlow;
|
||||
break;
|
||||
}
|
||||
case D2: {
|
||||
LH.LATCH1[2] = highlow;
|
||||
break;
|
||||
}
|
||||
case D3: {
|
||||
LH.LATCH1[3] = highlow;
|
||||
break;
|
||||
}
|
||||
case D4: {
|
||||
LH.LATCH1[4] = highlow;
|
||||
break;
|
||||
}
|
||||
case D5: {
|
||||
LH.LATCH1[5] = highlow;
|
||||
break;
|
||||
}
|
||||
case D6: {
|
||||
LH.LATCH1[6] = highlow;
|
||||
break;
|
||||
}
|
||||
case D7: {
|
||||
LH.LATCH1[7] = highlow;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case LOAD2: {
|
||||
switch (elite_pin) {
|
||||
case D0: {
|
||||
LH.LATCH2[0] = highlow;
|
||||
break;
|
||||
}
|
||||
case D1: {
|
||||
LH.LATCH2[1] = highlow;
|
||||
break;
|
||||
}
|
||||
case D2: {
|
||||
LH.LATCH2[2] = highlow;
|
||||
break;
|
||||
}
|
||||
case D3: {
|
||||
LH.LATCH2[3] = highlow;
|
||||
break;
|
||||
}
|
||||
case D4: {
|
||||
LH.LATCH2[4] = highlow;
|
||||
break;
|
||||
}
|
||||
case D5: {
|
||||
LH.LATCH2[5] = highlow;
|
||||
break;
|
||||
}
|
||||
case D6: {
|
||||
LH.LATCH2[6] = highlow;
|
||||
break;
|
||||
}
|
||||
case D7: {
|
||||
LH.LATCH2[7] = highlow;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void PIN15_setOutputValue (uint32_t latch_num, uint32_t pin_num, bool highlow) {
|
||||
if(PeriodicEvent){
|
||||
ELITE15_SPI_CLOSE();
|
||||
}
|
||||
add_elite_pin();
|
||||
update_latch_status (latch_num, pin_num, highlow);
|
||||
PIN_setOutputValue(&ZM_rst, latch_num, 1); // Turn on latch
|
||||
CPUdelay(10);
|
||||
switch (latch_num) {
|
||||
case LOAD0: {
|
||||
// PIN_setOutputValue(&ZM_rst, D0, LH.LATCH0[0]);
|
||||
// PIN_setOutputValue(&ZM_rst, D1, LH.LATCH0[1]);
|
||||
// PIN_setOutputValue(&ZM_rst, D2, LH.LATCH0[2]);
|
||||
// PIN_setOutputValue(&ZM_rst, D3, LH.LATCH0[3]);
|
||||
PIN_setOutputValue(pin_handle, D4, LH.LATCH0[4]);
|
||||
PIN_setOutputValue(pin_handle, D5, LH.LATCH0[5]);
|
||||
PIN_setOutputValue(pin_handle, D6, LH.LATCH0[6]);
|
||||
PIN_setOutputValue(pin_handle, D7, LH.LATCH0[7]);
|
||||
break;
|
||||
}
|
||||
case LOAD1: {
|
||||
PIN_setOutputValue(pin_handle, D0, LH.LATCH1[0]);
|
||||
PIN_setOutputValue(pin_handle, D1, LH.LATCH1[1]);
|
||||
PIN_setOutputValue(pin_handle, D2, LH.LATCH1[2]);
|
||||
PIN_setOutputValue(pin_handle, D3, LH.LATCH1[3]);
|
||||
PIN_setOutputValue(pin_handle, D4, LH.LATCH1[4]);
|
||||
PIN_setOutputValue(pin_handle, D5, LH.LATCH1[5]);
|
||||
PIN_setOutputValue(pin_handle, D6, LH.LATCH1[6]);
|
||||
PIN_setOutputValue(pin_handle, D7, LH.LATCH1[7]);
|
||||
break;
|
||||
}
|
||||
case LOAD2: {
|
||||
PIN_setOutputValue(pin_handle, D0, LH.LATCH2[0]);
|
||||
PIN_setOutputValue(pin_handle, D1, LH.LATCH2[1]);
|
||||
PIN_setOutputValue(pin_handle, D2, LH.LATCH2[2]);
|
||||
PIN_setOutputValue(pin_handle, D3, LH.LATCH2[3]);
|
||||
PIN_setOutputValue(pin_handle, D4, LH.LATCH2[4]);
|
||||
PIN_setOutputValue(pin_handle, D5, LH.LATCH2[5]);
|
||||
PIN_setOutputValue(pin_handle, D6, LH.LATCH2[6]);
|
||||
PIN_setOutputValue(pin_handle, D7, LH.LATCH2[7]);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
CPUdelay(10);
|
||||
PIN_setOutputValue(&ZM_rst, latch_num, 0); // Turn off latch
|
||||
remove_elite_pin();
|
||||
|
||||
if(PeriodicEvent){
|
||||
ELITE15_SPI_HOLD();
|
||||
}
|
||||
}
|
||||
|
||||
static void Init_Elite15_PIN () {
|
||||
InitLH();
|
||||
add_elite_pin();
|
||||
|
||||
PIN_setOutputValue(pin_handle, LOAD0, 1);
|
||||
PIN_setOutputValue(pin_handle, LOAD1, 1);
|
||||
PIN_setOutputValue(pin_handle, LOAD2, 1);
|
||||
CPUdelay(10);
|
||||
PIN_setOutputValue(pin_handle, D0, 0);
|
||||
PIN_setOutputValue(pin_handle, D1, 0);
|
||||
PIN_setOutputValue(pin_handle, D2, 0);
|
||||
PIN_setOutputValue(pin_handle, D3, 0);
|
||||
PIN_setOutputValue(pin_handle, D4, 0);
|
||||
PIN_setOutputValue(pin_handle, D5, 0);
|
||||
PIN_setOutputValue(pin_handle, D6, 0);
|
||||
PIN_setOutputValue(pin_handle, D7, 0);
|
||||
CPUdelay(10);
|
||||
PIN_setOutputValue(pin_handle, LOAD0, 0);
|
||||
PIN_setOutputValue(pin_handle, LOAD1, 0);
|
||||
PIN_setOutputValue(pin_handle, LOAD2, 0);
|
||||
|
||||
remove_elite_pin();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
+327
-391
@@ -46,11 +46,7 @@ static void ADC_write(uint8_t ADCin) {
|
||||
spi_ADC_txbuf[0] = ADCin;
|
||||
spi_ADC_txbuf[1] = 0b11101011;
|
||||
|
||||
if(PeriodicEvent){
|
||||
ADC_SPI_TEST(2, spi_ADC_txbuf, spi_ADC_rxbuf);
|
||||
}else{
|
||||
ADC_SPI(2, spi_ADC_txbuf, spi_ADC_rxbuf);
|
||||
}
|
||||
ADC_SPI(2, spi_ADC_txbuf, spi_ADC_rxbuf);
|
||||
}
|
||||
|
||||
static void ADC_read(uint8_t *ADCdata){
|
||||
@@ -59,90 +55,29 @@ static void ADC_read(uint8_t *ADCdata){
|
||||
spi_ADC_rxbuf[i] = 0;
|
||||
}
|
||||
|
||||
if(PeriodicEvent){
|
||||
ADC_SPI_TEST(2, spi_ADC_txbuf, spi_ADC_rxbuf);
|
||||
}else{
|
||||
ADC_SPI(2, spi_ADC_txbuf, spi_ADC_rxbuf);
|
||||
}
|
||||
ADC_SPI(2, spi_ADC_txbuf, spi_ADC_rxbuf);
|
||||
}
|
||||
|
||||
static void IinADCGainControl(uint8_t IinADCLevel){
|
||||
if(IinADCLevel == 0){
|
||||
// ADC gain level = 0, using 3M resister
|
||||
PIN15_setOutputValue(Turnon_I_LARGE, 0);
|
||||
PIN15_setOutputValue(Turnon_I_MID, 0);
|
||||
PIN15_setOutputValue(Turnon_I_SMALL, 0);
|
||||
}
|
||||
else if(IinADCLevel == 1){
|
||||
// ADC gain level = 1, using 100K resister
|
||||
PIN15_setOutputValue(Turnon_I_LARGE, 0);
|
||||
PIN15_setOutputValue(Turnon_I_MID, 0);
|
||||
PIN15_setOutputValue(Turnon_I_SMALL, 1);
|
||||
}
|
||||
else if(IinADCLevel == 2){
|
||||
// ADC gain level = 2, using 3K resister
|
||||
PIN15_setOutputValue(Turnon_I_LARGE, 0);
|
||||
PIN15_setOutputValue(Turnon_I_MID, 1);
|
||||
PIN15_setOutputValue(Turnon_I_SMALL, 0);
|
||||
}
|
||||
else if(IinADCLevel == 3){
|
||||
// ADC gain level = 3, using 100R resistor
|
||||
PIN15_setOutputValue(Turnon_I_LARGE, 1);
|
||||
PIN15_setOutputValue(Turnon_I_MID, 0);
|
||||
PIN15_setOutputValue(Turnon_I_SMALL, 0);
|
||||
}
|
||||
else if(IinADCLevel == 4){
|
||||
// ADC gain level = 3, auto gain (using 100R resister)
|
||||
PIN15_setOutputValue(Turnon_I_LARGE, 1);
|
||||
PIN15_setOutputValue(Turnon_I_MID, 0);
|
||||
PIN15_setOutputValue(Turnon_I_SMALL, 0);
|
||||
}
|
||||
else{
|
||||
// default using 100R resister
|
||||
PIN15_setOutputValue(Turnon_I_LARGE, 1);
|
||||
PIN15_setOutputValue(Turnon_I_MID, 0);
|
||||
PIN15_setOutputValue(Turnon_I_SMALL, 0);
|
||||
/* Elite1.5 Calibration Usage */
|
||||
static void CAL_ADC_read(uint8_t *ADCdata){
|
||||
for(int i=0 ; i<SPI_ADC_SIZE ; i++){
|
||||
spi_ADC_txbuf[i] = 0;
|
||||
spi_ADC_rxbuf[i] = 0;
|
||||
}
|
||||
|
||||
CAL_ADC_SPI(SPI_ADC_SIZE, spi_ADC_txbuf, ADCdata);
|
||||
}
|
||||
|
||||
static void CAL_ADC_write(uint8_t ADCin) {
|
||||
for(int i=0 ; i<SPI_ADC_SIZE ; i++){
|
||||
spi_ADC_txbuf[i] = 0;
|
||||
spi_ADC_rxbuf[i] = 0;
|
||||
}
|
||||
|
||||
if(IinADCLevel == 0 || IinADCLevel == 1 || IinADCLevel == 2 || IinADCLevel == 3){
|
||||
lastIinADCGainLevel = IinADCLevel;
|
||||
}else{
|
||||
lastIinADCGainLevel = 3;
|
||||
}
|
||||
}
|
||||
spi_ADC_txbuf[0] = ADCin;
|
||||
spi_ADC_txbuf[1] = 0b11101011;
|
||||
|
||||
static void VinADCGainControl(uint8_t VinADCLevel){
|
||||
if(VinADCLevel == 0){
|
||||
// Vin ADC gain level = 0, using 1M resister
|
||||
PIN15_setOutputValue(Turnon_V_SMALL, 0);
|
||||
PIN15_setOutputValue(Turnon_V_MID, 0);
|
||||
}
|
||||
else if(VinADCLevel == 1){
|
||||
// Vin ADC gain level = 1, using 30K resister
|
||||
PIN15_setOutputValue(Turnon_V_SMALL, 0);
|
||||
PIN15_setOutputValue(Turnon_V_MID, 1);
|
||||
}
|
||||
else if(VinADCLevel == 2){
|
||||
// Vin ADC gain level = 2, using 1K resister
|
||||
PIN15_setOutputValue(Turnon_V_SMALL, 1);
|
||||
PIN15_setOutputValue(Turnon_V_MID, 0);
|
||||
}
|
||||
else if(VinADCLevel == 3){
|
||||
// Vin ADC gain level = 3, auto gain (using 1K resister)
|
||||
PIN15_setOutputValue(Turnon_V_SMALL, 1);
|
||||
PIN15_setOutputValue(Turnon_V_MID, 0);
|
||||
}
|
||||
else{
|
||||
// default using 1K resister
|
||||
PIN15_setOutputValue(Turnon_V_SMALL, 1);
|
||||
PIN15_setOutputValue(Turnon_V_MID, 0);
|
||||
}
|
||||
|
||||
if(VinADCLevel == 0 || VinADCLevel == 1 || VinADCLevel == 2){
|
||||
lastVinADCGainLevel = VinADCLevel;
|
||||
}else{
|
||||
lastVinADCGainLevel = 2;
|
||||
}
|
||||
CAL_ADC_SPI(2, spi_ADC_txbuf, spi_ADC_rxbuf);
|
||||
}
|
||||
|
||||
static void ADCChannelSelect(uint8_t ADCChannel){
|
||||
@@ -239,11 +174,6 @@ static void ReadADCBat(uint8_t *buf){
|
||||
static int32_t AutoGainReadIin(uint8_t *buf){
|
||||
int32_t RealCurrent = 0;
|
||||
|
||||
if(INSTRUCTION.ADCGainLevel == I_GAIN_AUTO){
|
||||
INSTRUCTION.ADCGainLevel = I_GAIN_100R;
|
||||
IinADCGainControl(INSTRUCTION.ADCGainLevel);
|
||||
}
|
||||
|
||||
ReadADCIin(spi_ADC_rxbuf);
|
||||
RealCurrent = DecodeADCValue(INSTRUCTION.ADCGainLevel, ADC_CH_CURRENT, spi_ADC_rxbuf);
|
||||
|
||||
@@ -253,329 +183,335 @@ static int32_t AutoGainReadIin(uint8_t *buf){
|
||||
static int32_t AutoGainReadVin(uint8_t *buf){
|
||||
int32_t RealVolt = 0;
|
||||
|
||||
if(INSTRUCTION.VinADCGainLevel == VIN_GAIN_AUTO){
|
||||
INSTRUCTION.VinADCGainLevel = VIN_GAIN_1K;
|
||||
VinADCGainControl(INSTRUCTION.VinADCGainLevel);
|
||||
record_flag = false;
|
||||
}
|
||||
|
||||
ReadADCVin(spi_ADC_rxbuf);
|
||||
RealVolt = DecodeADCValue(INSTRUCTION.VinADCGainLevel, ADC_CH_VOLT, spi_ADC_rxbuf);
|
||||
|
||||
return RealVolt;
|
||||
}
|
||||
|
||||
static void AutoGainChangeIin(int32_t RealCurrent){
|
||||
// switch to 1 level current(small) 3M
|
||||
// switch to 2 level current 100K
|
||||
// switch to 3 level current 3K
|
||||
// switch to 4 level current(large) 100R
|
||||
if(INSTRUCTION.ADCGainLevel == I_GAIN_100R){
|
||||
if(RealCurrent < I_GAIN_LARGE_BOUNDARY && RealCurrent > -1*I_GAIN_LARGE_BOUNDARY){
|
||||
// switch to 1 level current(small)
|
||||
if (RealCurrent < I_GAIN_MID1_BOUNDARY1 && RealCurrent > -1*I_GAIN_MID1_BOUNDARY1){
|
||||
I_GAIN_3M_counter++;
|
||||
if(I_GAIN_3M_counter > 2){
|
||||
INSTRUCTION.ADCGainLevel = I_GAIN_3M;
|
||||
IinADCGainControl(INSTRUCTION.ADCGainLevel);
|
||||
I_GAIN_3M_counter = 0;
|
||||
record_flag = false;
|
||||
}
|
||||
}
|
||||
// switch to 2 level current
|
||||
else if (RealCurrent < I_GAIN_MID2_BOUNDARY1 && RealCurrent > -1*I_GAIN_MID2_BOUNDARY1){
|
||||
I_GAIN_100K_counter++;
|
||||
if(I_GAIN_100K_counter > 2){
|
||||
INSTRUCTION.ADCGainLevel = I_GAIN_100K;
|
||||
IinADCGainControl(INSTRUCTION.ADCGainLevel);
|
||||
I_GAIN_100K_counter = 0;
|
||||
record_flag = false;
|
||||
}
|
||||
}
|
||||
// switch to 3 level current
|
||||
else{
|
||||
I_GAIN_3K_counter++;
|
||||
if(I_GAIN_3K_counter > 2){
|
||||
INSTRUCTION.ADCGainLevel = I_GAIN_3K;
|
||||
IinADCGainControl(INSTRUCTION.ADCGainLevel);
|
||||
I_GAIN_3K_counter = 0;
|
||||
record_flag = false;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
if(I_GAIN_3K_counter > 0){
|
||||
I_GAIN_3K_counter--;
|
||||
}
|
||||
if(I_GAIN_100K_counter > 0){
|
||||
I_GAIN_100K_counter--;
|
||||
}
|
||||
if(I_GAIN_3M_counter > 0){
|
||||
I_GAIN_3M_counter--;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(INSTRUCTION.ADCGainLevel == I_GAIN_3K){
|
||||
// switch to 4 level current(large)
|
||||
if(RealCurrent > I_GAIN_MID2_BOUNDARY2 || RealCurrent < -1*I_GAIN_MID2_BOUNDARY2){
|
||||
I_GAIN_100R_counter++;
|
||||
if(I_GAIN_100R_counter > 2){
|
||||
INSTRUCTION.ADCGainLevel = I_GAIN_100R;
|
||||
IinADCGainControl(INSTRUCTION.ADCGainLevel);
|
||||
I_GAIN_100R_counter = 0;
|
||||
record_flag = false;
|
||||
}
|
||||
}
|
||||
else if (RealCurrent < I_GAIN_MID2_BOUNDARY1 && RealCurrent > -1*I_GAIN_MID2_BOUNDARY1){
|
||||
// switch to 1 level current(small)
|
||||
if(RealCurrent < I_GAIN_MID1_BOUNDARY1 && RealCurrent > -1*I_GAIN_MID1_BOUNDARY1){
|
||||
I_GAIN_3M_counter++;
|
||||
if(I_GAIN_3M_counter > 2){
|
||||
INSTRUCTION.ADCGainLevel = I_GAIN_3M;
|
||||
IinADCGainControl(INSTRUCTION.ADCGainLevel);
|
||||
I_GAIN_3M_counter = 0;
|
||||
record_flag = false;
|
||||
}
|
||||
}
|
||||
// switch to 2 level current
|
||||
else{
|
||||
I_GAIN_100K_counter++;
|
||||
if(I_GAIN_100K_counter > 2){
|
||||
INSTRUCTION.ADCGainLevel = I_GAIN_100K;
|
||||
IinADCGainControl(INSTRUCTION.ADCGainLevel);
|
||||
I_GAIN_100K_counter = 0;
|
||||
record_flag = false;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
if(I_GAIN_100R_counter > 0){
|
||||
I_GAIN_100R_counter--;
|
||||
}
|
||||
if(I_GAIN_100K_counter > 0){
|
||||
I_GAIN_100K_counter--;
|
||||
}
|
||||
if(I_GAIN_3M_counter > 0){
|
||||
I_GAIN_3M_counter--;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(INSTRUCTION.ADCGainLevel == I_GAIN_100K){
|
||||
// switch to 1 level current(small)
|
||||
if(RealCurrent < I_GAIN_MID1_BOUNDARY1 && RealCurrent > -1*I_GAIN_MID1_BOUNDARY1){
|
||||
I_GAIN_3M_counter++;
|
||||
if(I_GAIN_3M_counter > 2){
|
||||
INSTRUCTION.ADCGainLevel = I_GAIN_3M;
|
||||
IinADCGainControl(INSTRUCTION.ADCGainLevel);
|
||||
I_GAIN_3M_counter = 0;
|
||||
record_flag = false;
|
||||
}
|
||||
}
|
||||
else if (RealCurrent > I_GAIN_MID1_BOUNDARY2 || RealCurrent < -1*I_GAIN_MID1_BOUNDARY2){
|
||||
// switch to 4 level current(large)
|
||||
if(RealCurrent > I_GAIN_MID2_BOUNDARY2 || RealCurrent < -1*I_GAIN_MID2_BOUNDARY2){
|
||||
I_GAIN_100R_counter++;
|
||||
if(I_GAIN_100R_counter > 2){
|
||||
INSTRUCTION.ADCGainLevel = I_GAIN_100R;
|
||||
IinADCGainControl(INSTRUCTION.ADCGainLevel);
|
||||
I_GAIN_100R_counter = 0;
|
||||
record_flag = false;
|
||||
}
|
||||
}
|
||||
// switch to 3 level current
|
||||
else{
|
||||
I_GAIN_3K_counter++;
|
||||
if(I_GAIN_3K_counter > 2){
|
||||
INSTRUCTION.ADCGainLevel = I_GAIN_3K;
|
||||
IinADCGainControl(INSTRUCTION.ADCGainLevel);
|
||||
I_GAIN_3K_counter = 0;
|
||||
record_flag = false;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
if(I_GAIN_100R_counter > 0){
|
||||
I_GAIN_100R_counter--;
|
||||
}
|
||||
if(I_GAIN_3K_counter > 0){
|
||||
I_GAIN_3K_counter--;
|
||||
}
|
||||
if(I_GAIN_3M_counter > 0){
|
||||
I_GAIN_3M_counter--;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(INSTRUCTION.ADCGainLevel == I_GAIN_3M){
|
||||
if(RealCurrent > I_GAIN_SMALL_BOUNDARY || RealCurrent < -1*I_GAIN_SMALL_BOUNDARY){
|
||||
// switch to 4 level current(large)
|
||||
if(RealCurrent > I_GAIN_MID2_BOUNDARY2 || RealCurrent < -1*I_GAIN_MID2_BOUNDARY2){
|
||||
I_GAIN_100R_counter++;
|
||||
if(I_GAIN_100R_counter > 2){
|
||||
INSTRUCTION.ADCGainLevel = I_GAIN_100R;
|
||||
IinADCGainControl(INSTRUCTION.ADCGainLevel);
|
||||
I_GAIN_100R_counter = 0;
|
||||
record_flag = false;
|
||||
}
|
||||
}
|
||||
// switch to 3 level current
|
||||
else if(RealCurrent > I_GAIN_MID1_BOUNDARY2 || RealCurrent < -1*I_GAIN_MID1_BOUNDARY2){
|
||||
I_GAIN_3K_counter++;
|
||||
if(I_GAIN_3K_counter > 2){
|
||||
INSTRUCTION.ADCGainLevel = I_GAIN_3K;
|
||||
IinADCGainControl(INSTRUCTION.ADCGainLevel);
|
||||
I_GAIN_3K_counter = 0;
|
||||
record_flag = false;
|
||||
}
|
||||
}
|
||||
// switch to 2 level current
|
||||
else{
|
||||
I_GAIN_100K_counter++;
|
||||
if(I_GAIN_100K_counter > 2){
|
||||
INSTRUCTION.ADCGainLevel = I_GAIN_100K;
|
||||
IinADCGainControl(INSTRUCTION.ADCGainLevel);
|
||||
I_GAIN_100K_counter = 0;
|
||||
record_flag = false;
|
||||
}
|
||||
//static void AutoGainChangeIin(int32_t RealCurrent){
|
||||
// // switch to 1 level current(small) 3M
|
||||
// // switch to 2 level current 100K
|
||||
// // switch to 3 level current 3K
|
||||
// // switch to 4 level current(large) 100R
|
||||
// if(INSTRUCTION.ADCGainLevel == I_GAIN_100R){
|
||||
// if(RealCurrent < I_GAIN_LARGE_BOUNDARY && RealCurrent > -1*I_GAIN_LARGE_BOUNDARY){
|
||||
// // switch to 1 level current(small)
|
||||
// if (RealCurrent < I_GAIN_MID1_BOUNDARY1 && RealCurrent > -1*I_GAIN_MID1_BOUNDARY1){
|
||||
// I_GAIN_3M_counter++;
|
||||
// if(I_GAIN_3M_counter > 2){
|
||||
// INSTRUCTION.ADCGainLevel = I_GAIN_3M;
|
||||
// IinADCGainControl(INSTRUCTION.ADCGainLevel);
|
||||
// I_GAIN_3M_counter = 0;
|
||||
// record_flag = false;
|
||||
// }
|
||||
// }
|
||||
// // switch to 2 level current
|
||||
// else if (RealCurrent < I_GAIN_MID2_BOUNDARY1 && RealCurrent > -1*I_GAIN_MID2_BOUNDARY1){
|
||||
// I_GAIN_100K_counter++;
|
||||
// if(I_GAIN_100K_counter > 2){
|
||||
// INSTRUCTION.ADCGainLevel = I_GAIN_100K;
|
||||
// IinADCGainControl(INSTRUCTION.ADCGainLevel);
|
||||
// I_GAIN_100K_counter = 0;
|
||||
// record_flag = false;
|
||||
// }
|
||||
// }
|
||||
// // switch to 3 level current
|
||||
// else{
|
||||
// I_GAIN_3K_counter++;
|
||||
// if(I_GAIN_3K_counter > 2){
|
||||
// INSTRUCTION.ADCGainLevel = I_GAIN_3K;
|
||||
// IinADCGainControl(INSTRUCTION.ADCGainLevel);
|
||||
// I_GAIN_3K_counter = 0;
|
||||
// record_flag = false;
|
||||
// }
|
||||
// }
|
||||
// }else{
|
||||
// if(I_GAIN_3K_counter > 0){
|
||||
// I_GAIN_3K_counter--;
|
||||
// }
|
||||
// if(I_GAIN_100K_counter > 0){
|
||||
// I_GAIN_100K_counter--;
|
||||
// }
|
||||
// if(I_GAIN_3M_counter > 0){
|
||||
// I_GAIN_3M_counter--;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// else if(INSTRUCTION.ADCGainLevel == I_GAIN_3K){
|
||||
// // switch to 4 level current(large)
|
||||
// if(RealCurrent > I_GAIN_MID2_BOUNDARY2 || RealCurrent < -1*I_GAIN_MID2_BOUNDARY2){
|
||||
// I_GAIN_100R_counter++;
|
||||
// if(I_GAIN_100R_counter > 2){
|
||||
// INSTRUCTION.ADCGainLevel = I_GAIN_100R;
|
||||
// IinADCGainControl(INSTRUCTION.ADCGainLevel);
|
||||
// I_GAIN_100R_counter = 0;
|
||||
// record_flag = false;
|
||||
// }
|
||||
// }
|
||||
// else if (RealCurrent < I_GAIN_MID2_BOUNDARY1 && RealCurrent > -1*I_GAIN_MID2_BOUNDARY1){
|
||||
// // switch to 1 level current(small)
|
||||
// if(RealCurrent < I_GAIN_MID1_BOUNDARY1 && RealCurrent > -1*I_GAIN_MID1_BOUNDARY1){
|
||||
// I_GAIN_3M_counter++;
|
||||
// if(I_GAIN_3M_counter > 2){
|
||||
// INSTRUCTION.ADCGainLevel = I_GAIN_3M;
|
||||
// IinADCGainControl(INSTRUCTION.ADCGainLevel);
|
||||
// I_GAIN_3M_counter = 0;
|
||||
// record_flag = false;
|
||||
// }
|
||||
// }
|
||||
// // switch to 2 level current
|
||||
// else{
|
||||
// I_GAIN_100K_counter++;
|
||||
// if(I_GAIN_100K_counter > 2){
|
||||
// INSTRUCTION.ADCGainLevel = I_GAIN_100K;
|
||||
// IinADCGainControl(INSTRUCTION.ADCGainLevel);
|
||||
// I_GAIN_100K_counter = 0;
|
||||
// record_flag = false;
|
||||
// }
|
||||
// }
|
||||
// }else{
|
||||
// if(I_GAIN_100R_counter > 0){
|
||||
// I_GAIN_100R_counter--;
|
||||
// }
|
||||
// if(I_GAIN_100K_counter > 0){
|
||||
// I_GAIN_100K_counter--;
|
||||
// }
|
||||
// if(I_GAIN_3M_counter > 0){
|
||||
// I_GAIN_3M_counter--;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// else if(INSTRUCTION.ADCGainLevel == I_GAIN_100K){
|
||||
// // switch to 1 level current(small)
|
||||
// if(RealCurrent < I_GAIN_MID1_BOUNDARY1 && RealCurrent > -1*I_GAIN_MID1_BOUNDARY1){
|
||||
// I_GAIN_3M_counter++;
|
||||
// if(I_GAIN_3M_counter > 2){
|
||||
// INSTRUCTION.ADCGainLevel = I_GAIN_3M;
|
||||
// IinADCGainControl(INSTRUCTION.ADCGainLevel);
|
||||
// I_GAIN_3M_counter = 0;
|
||||
// record_flag = false;
|
||||
// }
|
||||
// }
|
||||
// else if (RealCurrent > I_GAIN_MID1_BOUNDARY2 || RealCurrent < -1*I_GAIN_MID1_BOUNDARY2){
|
||||
// // switch to 4 level current(large)
|
||||
// if(RealCurrent > I_GAIN_MID2_BOUNDARY2 || RealCurrent < -1*I_GAIN_MID2_BOUNDARY2){
|
||||
// I_GAIN_100R_counter++;
|
||||
// if(I_GAIN_100R_counter > 2){
|
||||
// INSTRUCTION.ADCGainLevel = I_GAIN_100R;
|
||||
// IinADCGainControl(INSTRUCTION.ADCGainLevel);
|
||||
// I_GAIN_100R_counter = 0;
|
||||
// record_flag = false;
|
||||
// }
|
||||
// }
|
||||
// // switch to 3 level current
|
||||
// else{
|
||||
// I_GAIN_3K_counter++;
|
||||
// if(I_GAIN_3K_counter > 2){
|
||||
// INSTRUCTION.ADCGainLevel = I_GAIN_3K;
|
||||
// IinADCGainControl(INSTRUCTION.ADCGainLevel);
|
||||
// I_GAIN_3K_counter = 0;
|
||||
// record_flag = false;
|
||||
// }
|
||||
// }
|
||||
// }else{
|
||||
// if(I_GAIN_100R_counter > 0){
|
||||
// I_GAIN_100R_counter--;
|
||||
// }
|
||||
// if(I_GAIN_3K_counter > 0){
|
||||
// I_GAIN_3K_counter--;
|
||||
// }
|
||||
// if(I_GAIN_3M_counter > 0){
|
||||
// I_GAIN_3M_counter--;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// else if(INSTRUCTION.ADCGainLevel == I_GAIN_3M){
|
||||
// if(RealCurrent > I_GAIN_SMALL_BOUNDARY || RealCurrent < -1*I_GAIN_SMALL_BOUNDARY){
|
||||
// // switch to 4 level current(large)
|
||||
// if(RealCurrent > I_GAIN_MID2_BOUNDARY2 || RealCurrent < -1*I_GAIN_MID2_BOUNDARY2){
|
||||
// I_GAIN_100R_counter++;
|
||||
// if(I_GAIN_100R_counter > 2){
|
||||
// INSTRUCTION.ADCGainLevel = I_GAIN_100R;
|
||||
// IinADCGainControl(INSTRUCTION.ADCGainLevel);
|
||||
// I_GAIN_100R_counter = 0;
|
||||
// record_flag = false;
|
||||
// }
|
||||
// }
|
||||
// // switch to 3 level current
|
||||
// else if(RealCurrent > I_GAIN_MID1_BOUNDARY2 || RealCurrent < -1*I_GAIN_MID1_BOUNDARY2){
|
||||
// I_GAIN_3K_counter++;
|
||||
// if(I_GAIN_3K_counter > 2){
|
||||
// INSTRUCTION.ADCGainLevel = I_GAIN_3K;
|
||||
// IinADCGainControl(INSTRUCTION.ADCGainLevel);
|
||||
// I_GAIN_3K_counter = 0;
|
||||
// record_flag = false;
|
||||
// }
|
||||
// }
|
||||
// // switch to 2 level current
|
||||
// else{
|
||||
// I_GAIN_100K_counter++;
|
||||
// if(I_GAIN_100K_counter > 2){
|
||||
// INSTRUCTION.ADCGainLevel = I_GAIN_100K;
|
||||
// IinADCGainControl(INSTRUCTION.ADCGainLevel);
|
||||
// I_GAIN_100K_counter = 0;
|
||||
// record_flag = false;
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// }else{
|
||||
// if(I_GAIN_100R_counter > 0){
|
||||
// I_GAIN_100R_counter--;
|
||||
// }
|
||||
// if(I_GAIN_3K_counter > 0){
|
||||
// I_GAIN_3K_counter--;
|
||||
// }
|
||||
// if(I_GAIN_100K_counter > 0){
|
||||
// I_GAIN_100K_counter--;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
}
|
||||
}else{
|
||||
if(I_GAIN_100R_counter > 0){
|
||||
I_GAIN_100R_counter--;
|
||||
}
|
||||
if(I_GAIN_3K_counter > 0){
|
||||
I_GAIN_3K_counter--;
|
||||
}
|
||||
if(I_GAIN_100K_counter > 0){
|
||||
I_GAIN_100K_counter--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void AutoGainChangeVin(int32_t RealVin){
|
||||
// switch to 1 level volt(small) 1M
|
||||
// switch to 2 level volt 30K
|
||||
// switch to 3 level volt(large) 1K
|
||||
if(INSTRUCTION.VinADCGainLevel == VIN_GAIN_1M){
|
||||
if(RealVin > VIN_GAIN_SMALL_BOUNDARY || RealVin < -1*VIN_GAIN_SMALL_BOUNDARY){
|
||||
// switch to 3 level volt(large)
|
||||
if (RealVin > VIN_GAIN_MID1_BOUNDARY2 || RealVin < -1*VIN_GAIN_MID1_BOUNDARY2){
|
||||
VIN_GAIN_1K_counter++;
|
||||
if(VIN_GAIN_1K_counter > 2){
|
||||
INSTRUCTION.VinADCGainLevel = VIN_GAIN_1K;
|
||||
VinADCGainControl(INSTRUCTION.VinADCGainLevel);
|
||||
VIN_GAIN_1K_counter = 0;
|
||||
record_flag = false;
|
||||
}
|
||||
}
|
||||
// switch to 2 level volt
|
||||
else{
|
||||
VIN_GAIN_30K_counter++;
|
||||
if(VIN_GAIN_30K_counter > 2){
|
||||
INSTRUCTION.VinADCGainLevel = VIN_GAIN_30K;
|
||||
VinADCGainControl(INSTRUCTION.VinADCGainLevel);
|
||||
VIN_GAIN_30K_counter = 0;
|
||||
record_flag = false;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
if(VIN_GAIN_1K_counter > 0){
|
||||
VIN_GAIN_1K_counter--;
|
||||
}
|
||||
if(VIN_GAIN_30K_counter > 0){
|
||||
VIN_GAIN_30K_counter--;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(INSTRUCTION.VinADCGainLevel == VIN_GAIN_30K){
|
||||
// switch to 1 level volt(small)
|
||||
if(RealVin < VIN_GAIN_MID1_BOUNDARY1 && RealVin > -1*VIN_GAIN_MID1_BOUNDARY1){
|
||||
VIN_GAIN_1M_counter++;
|
||||
if(VIN_GAIN_1M_counter > 2){
|
||||
INSTRUCTION.VinADCGainLevel = VIN_GAIN_1M;
|
||||
VinADCGainControl(INSTRUCTION.VinADCGainLevel);
|
||||
VIN_GAIN_1M_counter = 0;
|
||||
record_flag = false;
|
||||
}
|
||||
}
|
||||
else if (RealVin > VIN_GAIN_MID1_BOUNDARY2 || RealVin < -1*VIN_GAIN_MID1_BOUNDARY2){
|
||||
// switch to 3 level volt
|
||||
VIN_GAIN_1K_counter++;
|
||||
if(VIN_GAIN_1K_counter > 2){
|
||||
INSTRUCTION.VinADCGainLevel = VIN_GAIN_1K;
|
||||
VinADCGainControl(INSTRUCTION.VinADCGainLevel);
|
||||
VIN_GAIN_1K_counter = 0;
|
||||
record_flag = false;
|
||||
}
|
||||
}else{
|
||||
if(VIN_GAIN_1K_counter > 0){
|
||||
VIN_GAIN_1K_counter--;
|
||||
}
|
||||
if(VIN_GAIN_1M_counter > 0){
|
||||
VIN_GAIN_1M_counter--;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(INSTRUCTION.VinADCGainLevel == VIN_GAIN_1K){
|
||||
if(RealVin < VIN_GAIN_LARGE_BOUNDARY && RealVin > -1*VIN_GAIN_LARGE_BOUNDARY){
|
||||
// switch to 1 level volt(small)
|
||||
if (RealVin < VIN_GAIN_MID1_BOUNDARY1 && RealVin > -1*VIN_GAIN_MID1_BOUNDARY1){
|
||||
VIN_GAIN_1M_counter++;
|
||||
if(VIN_GAIN_1M_counter > 2){
|
||||
INSTRUCTION.VinADCGainLevel = VIN_GAIN_1M;
|
||||
VinADCGainControl(INSTRUCTION.VinADCGainLevel);
|
||||
VIN_GAIN_1M_counter = 0;
|
||||
record_flag = false;
|
||||
}
|
||||
}
|
||||
// switch to 2 level volt
|
||||
else{
|
||||
VIN_GAIN_30K_counter++;
|
||||
if(VIN_GAIN_30K_counter > 2){
|
||||
INSTRUCTION.VinADCGainLevel = VIN_GAIN_30K;
|
||||
VinADCGainControl(INSTRUCTION.VinADCGainLevel);
|
||||
VIN_GAIN_30K_counter = 0;
|
||||
record_flag = false;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
if(VIN_GAIN_1M_counter > 0){
|
||||
VIN_GAIN_1M_counter--;
|
||||
}
|
||||
if(VIN_GAIN_30K_counter > 0){
|
||||
VIN_GAIN_30K_counter--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//static void AutoGainChangeVin(int32_t RealVin){
|
||||
// // switch to 1 level volt(small) 1M
|
||||
// // switch to 2 level volt 30K
|
||||
// // switch to 3 level volt(large) 1K
|
||||
// if(INSTRUCTION.VinADCGainLevel == VIN_GAIN_1M){
|
||||
// if(RealVin > VIN_GAIN_SMALL_BOUNDARY || RealVin < -1*VIN_GAIN_SMALL_BOUNDARY){
|
||||
// // switch to 3 level volt(large)
|
||||
// if (RealVin > VIN_GAIN_MID1_BOUNDARY2 || RealVin < -1*VIN_GAIN_MID1_BOUNDARY2){
|
||||
// VIN_GAIN_1K_counter++;
|
||||
// if(VIN_GAIN_1K_counter > 2){
|
||||
// INSTRUCTION.VinADCGainLevel = VIN_GAIN_1K;
|
||||
// VinADCGainControl(INSTRUCTION.VinADCGainLevel);
|
||||
// VIN_GAIN_1K_counter = 0;
|
||||
// record_flag = false;
|
||||
// }
|
||||
// }
|
||||
// // switch to 2 level volt
|
||||
// else{
|
||||
// VIN_GAIN_30K_counter++;
|
||||
// if(VIN_GAIN_30K_counter > 2){
|
||||
// INSTRUCTION.VinADCGainLevel = VIN_GAIN_30K;
|
||||
// VinADCGainControl(INSTRUCTION.VinADCGainLevel);
|
||||
// VIN_GAIN_30K_counter = 0;
|
||||
// record_flag = false;
|
||||
// }
|
||||
// }
|
||||
// }else{
|
||||
// if(VIN_GAIN_1K_counter > 0){
|
||||
// VIN_GAIN_1K_counter--;
|
||||
// }
|
||||
// if(VIN_GAIN_30K_counter > 0){
|
||||
// VIN_GAIN_30K_counter--;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// else if(INSTRUCTION.VinADCGainLevel == VIN_GAIN_30K){
|
||||
// // switch to 1 level volt(small)
|
||||
// if(RealVin < VIN_GAIN_MID1_BOUNDARY1 && RealVin > -1*VIN_GAIN_MID1_BOUNDARY1){
|
||||
// VIN_GAIN_1M_counter++;
|
||||
// if(VIN_GAIN_1M_counter > 2){
|
||||
// INSTRUCTION.VinADCGainLevel = VIN_GAIN_1M;
|
||||
// VinADCGainControl(INSTRUCTION.VinADCGainLevel);
|
||||
// VIN_GAIN_1M_counter = 0;
|
||||
// record_flag = false;
|
||||
// }
|
||||
// }
|
||||
// else if (RealVin > VIN_GAIN_MID1_BOUNDARY2 || RealVin < -1*VIN_GAIN_MID1_BOUNDARY2){
|
||||
// // switch to 3 level volt
|
||||
// VIN_GAIN_1K_counter++;
|
||||
// if(VIN_GAIN_1K_counter > 2){
|
||||
// INSTRUCTION.VinADCGainLevel = VIN_GAIN_1K;
|
||||
// VinADCGainControl(INSTRUCTION.VinADCGainLevel);
|
||||
// VIN_GAIN_1K_counter = 0;
|
||||
// record_flag = false;
|
||||
// }
|
||||
// }else{
|
||||
// if(VIN_GAIN_1K_counter > 0){
|
||||
// VIN_GAIN_1K_counter--;
|
||||
// }
|
||||
// if(VIN_GAIN_1M_counter > 0){
|
||||
// VIN_GAIN_1M_counter--;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// else if(INSTRUCTION.VinADCGainLevel == VIN_GAIN_1K){
|
||||
// if(RealVin < VIN_GAIN_LARGE_BOUNDARY && RealVin > -1*VIN_GAIN_LARGE_BOUNDARY){
|
||||
// // switch to 1 level volt(small)
|
||||
// if (RealVin < VIN_GAIN_MID1_BOUNDARY1 && RealVin > -1*VIN_GAIN_MID1_BOUNDARY1){
|
||||
// VIN_GAIN_1M_counter++;
|
||||
// if(VIN_GAIN_1M_counter > 2){
|
||||
// INSTRUCTION.VinADCGainLevel = VIN_GAIN_1M;
|
||||
// VinADCGainControl(INSTRUCTION.VinADCGainLevel);
|
||||
// VIN_GAIN_1M_counter = 0;
|
||||
// record_flag = false;
|
||||
// }
|
||||
// }
|
||||
// // switch to 2 level volt
|
||||
// else{
|
||||
// VIN_GAIN_30K_counter++;
|
||||
// if(VIN_GAIN_30K_counter > 2){
|
||||
// INSTRUCTION.VinADCGainLevel = VIN_GAIN_30K;
|
||||
// VinADCGainControl(INSTRUCTION.VinADCGainLevel);
|
||||
// VIN_GAIN_30K_counter = 0;
|
||||
// record_flag = false;
|
||||
// }
|
||||
// }
|
||||
// }else{
|
||||
// if(VIN_GAIN_1M_counter > 0){
|
||||
// VIN_GAIN_1M_counter--;
|
||||
// }
|
||||
// if(VIN_GAIN_30K_counter > 0){
|
||||
// VIN_GAIN_30K_counter--;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
static uint16_t ADC_CURRENT_AVG_calibration (uint8_t ADC_channel) {
|
||||
uint32_t ADCValueTemp = 0;
|
||||
uint32_t ADCValueSUM = 0;
|
||||
uint32_t ADCValueAVG = 0;
|
||||
uint16_t ADCValueAVG_RAW = 0;
|
||||
#define count 10000
|
||||
uint32_t ADCValueTemp = 0;
|
||||
uint32_t ADCValueSUM = 0;
|
||||
uint32_t ADCValueAVG = 0;
|
||||
uint16_t ADCValueAVG_RAW = 0;
|
||||
#define avgcount 10000
|
||||
|
||||
// Red light for start acquiring data
|
||||
Elite_led_color(COLOR_RED);
|
||||
// CPUdelay(10);
|
||||
for(int i=0; i<avgcount; i++){
|
||||
CAL_ADC_write(ADC_channel);
|
||||
CAL_ADC_read(spi_ADC_rxbuf);
|
||||
CPUdelay(10);
|
||||
CAL_ADC_write(ADC_channel);
|
||||
CAL_ADC_read(spi_ADC_rxbuf);
|
||||
CPUdelay(500);
|
||||
|
||||
for(int i=0; i<count; i++){
|
||||
ADCChannelSelect(ADC_channel);
|
||||
CPUdelay(10);
|
||||
ADC_read(spi_ADC_rxbuf);
|
||||
CPUdelay(10);
|
||||
ADCChannelSelect(ADC_channel);
|
||||
CPUdelay(10);
|
||||
ADC_read(spi_ADC_rxbuf);
|
||||
CPUdelay(10);
|
||||
|
||||
ADCValueTemp = 0x0000FFFF & ((uint32_t) (spi_ADC_rxbuf[0]) << 8 | (uint32_t) (spi_ADC_rxbuf[1]));
|
||||
ADCValueTemp = 0x0000FFFF & (((uint32_t) (spi_ADC_rxbuf[0]) << 8) | ((uint32_t) (spi_ADC_rxbuf[1])));
|
||||
ADCValueSUM = ADCValueSUM + ADCValueTemp;
|
||||
}
|
||||
|
||||
ADCValueAVG = ADCValueSUM / count;
|
||||
ADCValueAVG = ADCValueSUM / avgcount;
|
||||
ADCValueAVG_RAW = (uint16_t) (ADCValueAVG & 0x0000FFFF);
|
||||
|
||||
// Blue light for data acquire done
|
||||
Elite_led_color(COLOR_BLUE);
|
||||
|
||||
if (ADCValueAVG_RAW > 0x7FFF) {
|
||||
ADCValueAVG_RAW = 0x0000;
|
||||
}
|
||||
|
||||
// clean data
|
||||
ADCValueAVG = 0;
|
||||
ADCValueSUM = 0;
|
||||
ADCValueTemp = 0;
|
||||
|
||||
// // Blue light for data acquire done
|
||||
// Elite_led_color(COLOR_BLUE);
|
||||
|
||||
|
||||
|
||||
return ADCValueAVG_RAW;
|
||||
}
|
||||
|
||||
|
||||
+67
-42
@@ -72,57 +72,82 @@ static void CV3_Vscan(CV3Mode *CV3){
|
||||
}
|
||||
|
||||
if(!vscanReset){
|
||||
if (Vset >= CV3->_Vmax){
|
||||
VmaxCounter++;
|
||||
}else if (Vset <= CV3->_Vmin){
|
||||
VminCounter++;
|
||||
}
|
||||
if((INSTRUCTION.Vinit < INSTRUCTION.Ve1 && INSTRUCTION.Vinit < INSTRUCTION.Ve2) ||
|
||||
(INSTRUCTION.Vinit > INSTRUCTION.Ve1 && INSTRUCTION.Vinit > INSTRUCTION.Ve2)
|
||||
){
|
||||
if (CV3->_current_direction_up){
|
||||
Vset = Vset + CV3->_Vstep;
|
||||
}else{
|
||||
Vset = Vset - CV3->_Vstep;
|
||||
}
|
||||
|
||||
if (CV3->_current_direction_up){
|
||||
Vset = Vset + CV3->_Vstep * GPT.GptimerMultiple;
|
||||
if(INSTRUCTION.Vinit < INSTRUCTION.Ve1 && INSTRUCTION.Vinit < INSTRUCTION.Ve2){
|
||||
if(Vset == CV3->_Vmin){
|
||||
VminCounter = -1;
|
||||
INSTRUCTION.Vinit = INSTRUCTION.Vmin;
|
||||
CV3->_Vinit = CV3->_Vmin;
|
||||
}
|
||||
}else if(INSTRUCTION.Vinit > INSTRUCTION.Ve1 && INSTRUCTION.Vinit > INSTRUCTION.Ve2){
|
||||
if(Vset == CV3->_Vmax){
|
||||
VmaxCounter = -1;
|
||||
INSTRUCTION.Vinit = INSTRUCTION.Vmax;
|
||||
CV3->_Vinit = CV3->_Vmax;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
Vset = Vset - CV3->_Vstep * GPT.GptimerMultiple;
|
||||
}
|
||||
if (Vset >= CV3->_Vmax){
|
||||
VmaxCounter++;
|
||||
}else if (Vset <= CV3->_Vmin){
|
||||
VminCounter++;
|
||||
}
|
||||
|
||||
if(VmaxCounter != 0 && VminCounter != 0){
|
||||
if(VmaxCounter == VminCounter && CV3->_direction_up && CV3->_current_direction_up){
|
||||
if(CycleCounter != VmaxCounter){
|
||||
if(Vset >= CV3->_Vinit){
|
||||
CV3->_cycleNumber--;
|
||||
CycleCounter = VmaxCounter; //VmaxCounter = VminCounter = CycleCounter
|
||||
if (CV3->_current_direction_up){
|
||||
Vset = Vset + CV3->_Vstep * GPT.GptimerMultiple;
|
||||
}else{
|
||||
Vset = Vset - CV3->_Vstep * GPT.GptimerMultiple;
|
||||
}
|
||||
|
||||
if(VmaxCounter != 0 && VminCounter != 0){
|
||||
if(VmaxCounter == VminCounter && CV3->_direction_up && CV3->_current_direction_up){
|
||||
if(CycleCounter != VmaxCounter){
|
||||
if(Vset >= CV3->_Vinit){
|
||||
CV3->_cycleNumber--;
|
||||
CycleCounter = VmaxCounter; //VmaxCounter = VminCounter = CycleCounter
|
||||
}
|
||||
}
|
||||
}
|
||||
if(VmaxCounter == VminCounter && !CV3->_direction_up && !CV3->_current_direction_up){
|
||||
if(CycleCounter != VmaxCounter){
|
||||
if(Vset <= CV3->_Vinit){
|
||||
CV3->_cycleNumber--;
|
||||
CycleCounter = VmaxCounter; //VmaxCounter = VminCounter = CycleCounter
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(VmaxCounter == VminCounter && !CV3->_direction_up && !CV3->_current_direction_up){
|
||||
if(CycleCounter != VmaxCounter){
|
||||
if(Vset <= CV3->_Vinit){
|
||||
CV3->_cycleNumber--;
|
||||
CycleCounter = VmaxCounter; //VmaxCounter = VminCounter = CycleCounter
|
||||
}
|
||||
}
|
||||
|
||||
if (Vset >= CV3->_Vmax){
|
||||
CV3->_current_direction_up = false;
|
||||
}else if (Vset <= CV3->_Vmin){
|
||||
CV3->_current_direction_up = true;
|
||||
}
|
||||
|
||||
/*stop condition*/
|
||||
if(CV3->_cycleNumber == 0){
|
||||
// PeriodicEvent = false;
|
||||
ModeLED(POST_WORK);
|
||||
InitEliteFlag();
|
||||
INSTRUCTION.eliteFxn = CONSTANT_CURRENT;
|
||||
INSTRUCTION.sampleRate = 15;
|
||||
INSTRUCTION.charge = 0x01;
|
||||
INSTRUCTION.constantCurrent = 0x00;
|
||||
INSTRUCTION.Vmax = 0xC350;
|
||||
INSTRUCTION.Vmin = 0x0000;
|
||||
INSTRUCTION.notifyRate = 500;
|
||||
INSTRUCTION.VoViSwitch = 0x02;//read Vscan = Vout - Vin
|
||||
}
|
||||
}
|
||||
|
||||
if (Vset >= CV3->_Vmax){
|
||||
CV3->_current_direction_up = false;
|
||||
}else if (Vset <= CV3->_Vmin){
|
||||
CV3->_current_direction_up = true;
|
||||
}
|
||||
|
||||
/*stop condition*/
|
||||
if(CV3->_cycleNumber == 0){
|
||||
// PeriodicEvent = false;
|
||||
ModeLED(POST_WORK);
|
||||
InitEliteFlag();
|
||||
INSTRUCTION.eliteFxn = CONSTANT_CURRENT;
|
||||
INSTRUCTION.sampleRate = 15;
|
||||
INSTRUCTION.charge = 0x01;
|
||||
INSTRUCTION.constantCurrent = 0x00;
|
||||
INSTRUCTION.Vmax = 0xC350;
|
||||
INSTRUCTION.Vmin = 0x0000;
|
||||
INSTRUCTION.notifyRate = 500;
|
||||
INSTRUCTION.VoViSwitch = 0x02;//read Vscan = Vout - Vin
|
||||
}
|
||||
}
|
||||
// int32_t RealV;
|
||||
// RealV = (int32_t)(Vset / 500);//[1uV]
|
||||
|
||||
-1
@@ -210,7 +210,6 @@ static void CV_Vscan(CVMode *CV){
|
||||
/*stop condition*/
|
||||
if(CV->_cycleNumber == 0){
|
||||
PeriodicEvent = false;
|
||||
ELITE15_SPI_CLOSE();
|
||||
ModeLED(NO_EVENT);
|
||||
}
|
||||
}
|
||||
|
||||
+39
-50
@@ -5,34 +5,31 @@
|
||||
static bool DACReset;
|
||||
|
||||
|
||||
//#ifdef ELITE_VERSION_1_3
|
||||
//#define DACOUT 0x30
|
||||
//
|
||||
//static void DAC_outputV(uint16_t voltLV) {
|
||||
// // C = command, X = don't care, D = data
|
||||
// // CCCC XXXX = command
|
||||
// // DDDD DDDD = v1
|
||||
// // DDDD XXXX = v2
|
||||
//
|
||||
// uint8_t v1, v2 = 0;
|
||||
// v1 = (uint8_t) (voltLV >> 4) & 0xFF;
|
||||
// v2 = (uint8_t) ((voltLV & 0x000F) << 4) & 0xF0;
|
||||
//
|
||||
// spi_DACtxbuf[0] = command;
|
||||
// spi_DACtxbuf[1] = v1;
|
||||
// spi_DACtxbuf[2] = v2;
|
||||
// for (int i = 3; i < SPI_DAC_SIZE; i++) {
|
||||
// spi_DACtxbuf[i] = 0;
|
||||
// }
|
||||
//
|
||||
// DAC_SPI(SPI_DAC_SIZE, spi_DACtxbuf, spi_rxbuf);
|
||||
//}
|
||||
//#endif
|
||||
#ifdef ELITE_VERSION_1_3
|
||||
#define DACOUT 0x30
|
||||
static void DAC_outputV(uint16_t voltLV) {
|
||||
// C = command, X = don't care, D = data
|
||||
// CCCC XXXX = command
|
||||
// DDDD DDDD = v1
|
||||
// DDDD XXXX = v2
|
||||
|
||||
uint8_t v1, v2 = 0;
|
||||
v1 = (uint8_t) (voltLV >> 4) & 0xFF;
|
||||
v2 = (uint8_t) ((voltLV & 0x000F) << 4) & 0xF0;
|
||||
|
||||
spi_DACtxbuf[0] = command;
|
||||
spi_DACtxbuf[1] = v1;
|
||||
spi_DACtxbuf[2] = v2;
|
||||
for (int i = 3; i < SPI_DAC_SIZE; i++) {
|
||||
spi_DACtxbuf[i] = 0;
|
||||
}
|
||||
|
||||
DAC_SPI(SPI_DAC_SIZE, spi_DACtxbuf, spi_rxbuf);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef ELITE_VERSION_1_4
|
||||
#define DACCLS 0x02
|
||||
#define DACOUT 0x31
|
||||
|
||||
static uint16_t DAC_outputV(uint16_t voltLV) {
|
||||
// C = command, X = don't care, D = data
|
||||
// CCCC CCCC = command
|
||||
@@ -51,34 +48,23 @@ static uint16_t DAC_outputV(uint16_t voltLV) {
|
||||
spi_DACtxbuf[1] = v1;
|
||||
spi_DACtxbuf[2] = v2;
|
||||
|
||||
if(PeriodicEvent){
|
||||
DAC_SPI_TEST(SPI_DAC_SIZE, spi_DACtxbuf, spi_rxbuf);
|
||||
}else{
|
||||
DAC_SPI(SPI_DAC_SIZE, spi_DACtxbuf, spi_rxbuf);
|
||||
}
|
||||
DAC_SPI(SPI_DAC_SIZE, spi_DACtxbuf, spi_rxbuf);
|
||||
|
||||
return voltLV;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void VoutGainControl(uint8_t VOUTLevel){
|
||||
if(VOUTLevel == 0){
|
||||
// VOUT gain level = 0, using 240K resister
|
||||
PIN15_setOutputValue(Turon_VOUT_SMALL, 0);
|
||||
}
|
||||
else if(VOUTLevel == 1){
|
||||
// VOUT gain level = 1, using 15K resister
|
||||
PIN15_setOutputValue(Turon_VOUT_SMALL, 1);
|
||||
}
|
||||
else if(VOUTLevel == 2){
|
||||
// VOUT gain level = 2, using 15K resister
|
||||
PIN15_setOutputValue(Turon_VOUT_SMALL, 1);
|
||||
}
|
||||
else{
|
||||
// default using 15K resister
|
||||
PIN15_setOutputValue(Turon_VOUT_SMALL, 1);
|
||||
}
|
||||
#ifdef ELITE_VERSION_EIS
|
||||
static uint32_t DAC_outputV(uint32_t voltLV) {
|
||||
|
||||
// uint8_t v1, v2 = 0;
|
||||
// v1 = (uint8_t) ((voltLV & 0xFF00) >> 8);
|
||||
// v2 = (uint8_t) (voltLV & 0x00FF);
|
||||
|
||||
EIS_LPDAC_SPI(voltLV);
|
||||
|
||||
return voltLV;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static int32_t User2Real(uint16_t UserCode){
|
||||
@@ -95,11 +81,15 @@ static void AutoGainChangeVout(int32_t RealVolt){
|
||||
RealVolt = (RealVolt - 25000) * 200; // (RealVolt - 25000) / 5 * 1000
|
||||
// switch to 1 level volt(small) 15K
|
||||
// switch to 2 level volt(large) 240K
|
||||
|
||||
if(INSTRUCTION.VoutGainLevel == VOUT_GAIN_AUTO){
|
||||
INSTRUCTION.VoutGainLevel = VOUT_GAIN_15K;
|
||||
}
|
||||
|
||||
if(INSTRUCTION.VoutGainLevel == VOUT_GAIN_15K){
|
||||
if(RealVolt > DAC_VOUT_GAIN_LARGE_BOUNDARY || RealVolt < -1 * DAC_VOUT_GAIN_LARGE_BOUNDARY){
|
||||
// switch to 2 level volt(large)
|
||||
INSTRUCTION.VoutGainLevel = VOUT_GAIN_240K;
|
||||
VoutGainControl(INSTRUCTION.VoutGainLevel);
|
||||
record_flag = false;
|
||||
}
|
||||
}
|
||||
@@ -107,7 +97,6 @@ static void AutoGainChangeVout(int32_t RealVolt){
|
||||
if(RealVolt < DAC_VOUT_GAIN_SMALL_BOUNDARY && RealVolt > -1 * DAC_VOUT_GAIN_SMALL_BOUNDARY ){
|
||||
// switch to 1 level volt(small)
|
||||
INSTRUCTION.VoutGainLevel = VOUT_GAIN_15K;
|
||||
VoutGainControl(INSTRUCTION.VoutGainLevel);
|
||||
record_flag = false;
|
||||
}
|
||||
}
|
||||
|
||||
+29
-29
@@ -224,35 +224,35 @@ static int32_t DecodeADCValue(uint8_t ADCGain, uint8_t ADCChannel, uint8_t *ADC_
|
||||
// #0 board, (0x5f75 <= rawdata) && (rawdata <= 0x5fb2)
|
||||
// ((0x5f97 < rawdata) && (rawdata < 0x6589)) || ((0x5999 < rawdata) && (rawdata < 0x5f93))
|
||||
|
||||
static void ADC_overflow(uint8_t gain, uint8_t *rawdata){
|
||||
|
||||
// Gain boundary defines different ADC gain level working area
|
||||
// Gain0Boundary = {lowerbound, upperbound}, is the lower and upper bound of gain level 0 working area.
|
||||
|
||||
uint16_t U16Rawdata = 0;
|
||||
U16Rawdata = (((uint16_t) (rawdata[0]))<<8) | ((uint16_t) (rawdata[1]));
|
||||
|
||||
if(gain == I_GAIN_3M){
|
||||
if( U16Rawdata <= Correction.Gain0Boundary[0]){
|
||||
rawdata[0] = Correction.Gain0Boundary[0] >> 4;
|
||||
rawdata[1] = (uint8_t) (Correction.Gain0Boundary[0] & 0x00FF);
|
||||
}
|
||||
else if(U16Rawdata >= Correction.Gain0Boundary[1]){
|
||||
rawdata[0] = (uint8_t) (Correction.Gain0Boundary[1] >> 4);
|
||||
rawdata[1] = (uint8_t) (Correction.Gain0Boundary[1] & 0x00FF);
|
||||
}
|
||||
}
|
||||
else if(gain == I_GAIN_100K){
|
||||
if( U16Rawdata <= Correction.Gain1Boundary[0]){
|
||||
rawdata[0] = Correction.Gain1Boundary[0] >> 4;
|
||||
rawdata[1] = (uint8_t) (Correction.Gain1Boundary[0] & 0x00FF);
|
||||
}
|
||||
else if(U16Rawdata >= Correction.Gain1Boundary[1]){
|
||||
rawdata[0] = (uint8_t) (Correction.Gain1Boundary[1] >> 4);
|
||||
rawdata[1] = (uint8_t) (Correction.Gain1Boundary[1] & 0x00FF);
|
||||
}
|
||||
}
|
||||
}
|
||||
//static void ADC_overflow(uint8_t gain, uint8_t *rawdata){
|
||||
//
|
||||
// // Gain boundary defines different ADC gain level working area
|
||||
// // Gain0Boundary = {lowerbound, upperbound}, is the lower and upper bound of gain level 0 working area.
|
||||
//
|
||||
// uint16_t U16Rawdata = 0;
|
||||
// U16Rawdata = (((uint16_t) (rawdata[0]))<<8) | ((uint16_t) (rawdata[1]));
|
||||
//
|
||||
// if(gain == I_GAIN_3M){
|
||||
// if( U16Rawdata <= Correction.Gain0Boundary[0]){
|
||||
// rawdata[0] = Correction.Gain0Boundary[0] >> 4;
|
||||
// rawdata[1] = (uint8_t) (Correction.Gain0Boundary[0] & 0x00FF);
|
||||
// }
|
||||
// else if(U16Rawdata >= Correction.Gain0Boundary[1]){
|
||||
// rawdata[0] = (uint8_t) (Correction.Gain0Boundary[1] >> 4);
|
||||
// rawdata[1] = (uint8_t) (Correction.Gain0Boundary[1] & 0x00FF);
|
||||
// }
|
||||
// }
|
||||
// else if(gain == I_GAIN_100K){
|
||||
// if( U16Rawdata <= Correction.Gain1Boundary[0]){
|
||||
// rawdata[0] = Correction.Gain1Boundary[0] >> 4;
|
||||
// rawdata[1] = (uint8_t) (Correction.Gain1Boundary[0] & 0x00FF);
|
||||
// }
|
||||
// else if(U16Rawdata >= Correction.Gain1Boundary[1]){
|
||||
// rawdata[0] = (uint8_t) (Correction.Gain1Boundary[1] >> 4);
|
||||
// rawdata[1] = (uint8_t) (Correction.Gain1Boundary[1] & 0x00FF);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
// User will enter -5V~+5V in UI.
|
||||
// websever and controler use 0~50000 represent -5~+5V
|
||||
|
||||
+1
@@ -22,6 +22,7 @@ struct _GPT{
|
||||
uint32_t BatteryADCCounter;
|
||||
uint32_t BatteryCheckCounter;
|
||||
uint32_t GptimerMultiple;
|
||||
uint32_t TestCounter;
|
||||
}GPT = {0};
|
||||
|
||||
static void InitCT(){
|
||||
|
||||
-2
@@ -28,13 +28,11 @@ static void IV_Vscan(IVMode *IV){
|
||||
if(IV->_current_direction_up){
|
||||
if(Vset >= IV->_Vmax){
|
||||
PeriodicEvent = false;
|
||||
ELITE15_SPI_CLOSE();
|
||||
ModeLED(NO_EVENT);
|
||||
}
|
||||
}else{
|
||||
if(Vset <= IV->_Vmin){
|
||||
PeriodicEvent = false;
|
||||
ELITE15_SPI_CLOSE();
|
||||
ModeLED(NO_EVENT);
|
||||
}
|
||||
}
|
||||
|
||||
+3
@@ -78,6 +78,8 @@ struct HEADSTAGE_INSTRUCTION {
|
||||
|
||||
uint16_t StepTime;
|
||||
|
||||
uint8_t AdcChannel;
|
||||
|
||||
} INSTRUCTION = {0};
|
||||
|
||||
/*********************************************************************
|
||||
@@ -118,5 +120,6 @@ static void InitEliteInstruction(){
|
||||
INSTRUCTION.constantCurrent = 0;
|
||||
INSTRUCTION.Currentmax = 0;
|
||||
INSTRUCTION.StepTime = STEPTIME_ONE_SEC;
|
||||
INSTRUCTION.AdcChannel = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
+8
-20
@@ -8,25 +8,19 @@ static bool TurnOnElite(uint8_t key) {
|
||||
if (key == 0) {
|
||||
// press 1 sec, power on LED, read bat power
|
||||
if (TurnOnCounter >= CLOCK_ONE_SECOND) {
|
||||
headstage_battery_volt();
|
||||
uint16_t bat = ((uint16_t)(NotifyVoltBat[2]) << 8 & 0xFF00 ) |
|
||||
((uint16_t)(NotifyVoltBat[3]) & 0x00FF);
|
||||
if( bat < 768 && bat > 20){
|
||||
PIN15_setOutputValue(enable_5v, 0);
|
||||
return false;
|
||||
}else{
|
||||
PIN15_setOutputValue(enable_5v, 1); // enable 5V
|
||||
TurnOn10V();
|
||||
ModeLED(BT_WAIT);
|
||||
return true;
|
||||
}
|
||||
PIN_setOutputValue(pin_handle, enable_5v, 1);// enable 5V
|
||||
Elite_SPI_init();
|
||||
ModeLED(BT_WAIT);
|
||||
AD5940_init();
|
||||
// DAC_outputV(0x3FFFF);
|
||||
return true;
|
||||
} else {
|
||||
TurnOnCounter++;
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
TurnOnCounter = 0;
|
||||
PIN15_setOutputValue(enable_5v, 0); // disable 5V
|
||||
PIN_setOutputValue(pin_handle, enable_5v, 0); // disable 5V
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -46,7 +40,7 @@ static void EliteKeyPress(uint8_t key) {
|
||||
// press 3~4 sec, shutdown 2650
|
||||
else if (ShutDownCounter > (CLOCK_ONE_SECOND*3) ) {
|
||||
LED_color(DARKLED, 0xFF, 0xFF, 0x00);
|
||||
PIN15_setOutputValue(enable_5v, 0); // disable 5V
|
||||
PIN_setOutputValue(pin_handle, enable_5v, 0); // disable 5V
|
||||
}
|
||||
ShutDownCounter ++;
|
||||
} else {
|
||||
@@ -66,10 +60,4 @@ static void EliteKeyPress(uint8_t key) {
|
||||
}
|
||||
}
|
||||
|
||||
static void TurnOn10V() {
|
||||
If10Von = true;
|
||||
PIN15_setOutputValue(enable_10v, 1);
|
||||
CPUdelay(8000);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
+10
-5
@@ -18,11 +18,7 @@ static void LED_color(uint8_t bright, uint8_t red, uint8_t green, uint8_t blue)
|
||||
spi_LEDtxbuf[SPI_LED_SIZE - 2] = 0xffff;
|
||||
spi_LEDtxbuf[SPI_LED_SIZE - 1] = 0xffff;
|
||||
|
||||
if(PeriodicEvent){
|
||||
LED_SPI_TEST(SPI_LED_SIZE, spi_LEDtxbuf, spi_LEDrxbuf);
|
||||
}else{
|
||||
LED_SPI(SPI_LED_SIZE, spi_LEDtxbuf, spi_LEDrxbuf);
|
||||
}
|
||||
LED_SPI(SPI_LED_SIZE, spi_LEDtxbuf, spi_LEDrxbuf);
|
||||
|
||||
}
|
||||
|
||||
@@ -157,6 +153,15 @@ static void WorkModeLED() {
|
||||
WORKLED();
|
||||
break;
|
||||
}
|
||||
case CALI_ADC_MODE:{
|
||||
if(INSTRUCTION.AdcChannel == IIN_ADC){
|
||||
Elite_led_color(COLOR_RED);
|
||||
}else if(INSTRUCTION.AdcChannel == VIN_ADC){
|
||||
Elite_led_color(COLOR_ORANGE);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
// case VIS_RST: {
|
||||
// LEDPowerON();
|
||||
// break;
|
||||
|
||||
-62
@@ -1,62 +0,0 @@
|
||||
|
||||
#ifndef ELITE_MACRO_MODE
|
||||
#define ELITE_MACRO_MODE
|
||||
|
||||
static void define_mode_macro(){
|
||||
#ifndef CURRENT_MODE
|
||||
switch (INSTRUCTION.eliteFxn) {
|
||||
case IT_CURVE:{
|
||||
#define CURRENT_MODE WorkModeData->IT
|
||||
break;
|
||||
}
|
||||
case VT_CURVE:{
|
||||
#define CURRENT_MODE WorkModeData->VT
|
||||
break;
|
||||
}
|
||||
case ZT_CURVE:{
|
||||
#define CURRENT_MODE WorkModeData->RT
|
||||
break;
|
||||
}
|
||||
case IV_CURVE:{
|
||||
#define CURRENT_MODE WorkModeData->IV
|
||||
break;
|
||||
}
|
||||
case CV_CURVE:{
|
||||
#define CURRENT_MODE WorkModeData->CV
|
||||
break;
|
||||
}
|
||||
case CONSTANT_CURRENT:{
|
||||
#define CURRENT_MODE WorkModeData->CC
|
||||
break;
|
||||
}
|
||||
case CYCLIC_VOLTAMMETRY:{
|
||||
#define CURRENT_MODE WorkModeData->CV3
|
||||
break;
|
||||
}
|
||||
case LINEAR_SWEEP_VOLTAMMETRY:{
|
||||
#define CURRENT_MODE WorkModeData->LSV
|
||||
break;
|
||||
}
|
||||
case CONSTANT_VSCAN:{
|
||||
#define CURRENT_MODE WorkModeData->CVSCAN
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
#define CURRENT_MODE NULL
|
||||
break;
|
||||
}
|
||||
}
|
||||
#else
|
||||
#error "CURRENT_MODE has already been defined"
|
||||
#endif
|
||||
}
|
||||
|
||||
static void undefine_mode_macro(){
|
||||
#ifndef CURRENT_MODE
|
||||
#error "CURRENT_MODE has NOT been defined"
|
||||
#else
|
||||
#undef CURRENT_MODE
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
+7
-12
@@ -10,11 +10,9 @@ static void reset() {
|
||||
InitGPT();
|
||||
InitLH();
|
||||
|
||||
VinADCGainControl(VIN_GAIN_AUTO);
|
||||
IinADCGainControl(I_GAIN_AUTO);
|
||||
VoutGainControl(VOUT_GAIN_AUTO);
|
||||
// VinADCGainControl(VIN_GAIN_AUTO);
|
||||
// IinADCGainControl(I_GAIN_AUTO);
|
||||
DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoutGainLevel, INSTRUCTION.VoltConstant));
|
||||
PIN15_setOutputValue(HIGH_Z_MODE, 0); // 0 => open high_z mode
|
||||
initINSBuf();
|
||||
initDATBuf();
|
||||
|
||||
@@ -33,8 +31,8 @@ static void reset() {
|
||||
spi_ADC_rxbuf[i] = 0;
|
||||
}
|
||||
|
||||
PIN15_setOutputValue(ADC_CS, 1); // ADC_CS HIGH
|
||||
PIN15_setOutputValue(DAC_CS, 1); // DAC_CS HIGH
|
||||
PIN_setOutputValue(pin_handle, AD_CS, 1); // AD_CS HIGH
|
||||
// PIN15_setOutputValue(DAC_CS, 1); // DAC_CS HIGH
|
||||
CPUdelay(1600);
|
||||
}
|
||||
|
||||
@@ -47,11 +45,9 @@ static void Eliteinterrupt() {
|
||||
InitGPT();
|
||||
InitLH();
|
||||
|
||||
VinADCGainControl(VIN_GAIN_AUTO);
|
||||
IinADCGainControl(I_GAIN_AUTO);
|
||||
VoutGainControl(VOUT_GAIN_AUTO);
|
||||
// VinADCGainControl(VIN_GAIN_AUTO);
|
||||
// IinADCGainControl(I_GAIN_AUTO);
|
||||
DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoutGainLevel, INSTRUCTION.VoltConstant));
|
||||
PIN15_setOutputValue(HIGH_Z_MODE, 0); // 0 => open high_z mode
|
||||
initINSBuf();
|
||||
initDATBuf();
|
||||
|
||||
@@ -70,8 +66,7 @@ static void Eliteinterrupt() {
|
||||
spi_ADC_rxbuf[i] = 0;
|
||||
}
|
||||
|
||||
PIN15_setOutputValue(ADC_CS, 1); // ADC_CS HIGH
|
||||
PIN15_setOutputValue(DAC_CS, 1); // DAC_CS HIGH
|
||||
PIN_setOutputValue(pin_handle, AD_CS, 1); // AD_CS HIGH
|
||||
CPUdelay(8000);
|
||||
}
|
||||
#endif
|
||||
|
||||
+197
-49
@@ -16,7 +16,7 @@
|
||||
|
||||
/* application use SPI parameters and buffers */
|
||||
#define SPI_LED_SIZE 28
|
||||
#define SPI_DAC_SIZE 3
|
||||
#define SPI_DAC_SIZE 5
|
||||
#define SPI_ADC_SIZE 4
|
||||
|
||||
static uint16_t spi_LEDtxbuf[SPI_LED_SIZE] = {0};
|
||||
@@ -36,13 +36,10 @@ static SPI_Params spiParams1;
|
||||
static SPI_Transaction LED_transaction;
|
||||
static SPI_Transaction ADC_DAC_transaction;
|
||||
|
||||
static void ELITE15_SPI_HOLD();
|
||||
static void ELITE15_SPI_CLOSE();
|
||||
|
||||
static void Elite_SPI_init(){
|
||||
SPI_init();
|
||||
SPI_Params_init(&spiParams0);
|
||||
spiParams0.bitRate = 2000; // 12k
|
||||
spiParams0.bitRate = 2000; // 2k
|
||||
spiParams0.mode = SPI_MASTER;
|
||||
spiParams0.dataSize = 16;
|
||||
spiParams0.frameFormat = SPI_POL0_PHA1;
|
||||
@@ -52,25 +49,21 @@ static void Elite_SPI_init(){
|
||||
spiParams1.bitRate = 1000000; // 1M
|
||||
spiParams1.mode = SPI_MASTER;
|
||||
spiParams1.dataSize = 8;
|
||||
spiParams1.frameFormat = SPI_POL0_PHA1;
|
||||
spiParams1.frameFormat = SPI_POL0_PHA0;
|
||||
|
||||
spiHandle1 = SPI_open(Board_SPI1, &spiParams1); // ADC DAC SPI
|
||||
}
|
||||
|
||||
static void LED_SPI(uint8_t length, uint16_t *spi_txbuf, uint16_t *spi_rxbuf) {
|
||||
ELITE15_SPI_HOLD();
|
||||
|
||||
LED_transaction.count = length;
|
||||
LED_transaction.txBuf = spi_txbuf;
|
||||
LED_transaction.rxBuf = spi_rxbuf;
|
||||
|
||||
SPI_transfer(spiHandle0, &LED_transaction);
|
||||
|
||||
ELITE15_SPI_CLOSE();
|
||||
}
|
||||
|
||||
static void ADC_SPI(uint8_t length, uint8_t *spi_txbuf, uint8_t *spi_rxbuf) {
|
||||
ELITE15_SPI_HOLD();
|
||||
PIN_setOutputValue(pin_handle, D6, 0); // CS_ADC
|
||||
PIN_setOutputValue(pin_handle, AD_CS, 0); // CS_ADC
|
||||
|
||||
ADC_DAC_transaction.count = length;
|
||||
ADC_DAC_transaction.txBuf = spi_txbuf;
|
||||
@@ -78,25 +71,29 @@ static void ADC_SPI(uint8_t length, uint8_t *spi_txbuf, uint8_t *spi_rxbuf) {
|
||||
|
||||
SPI_transfer(spiHandle1, &ADC_DAC_transaction);
|
||||
|
||||
PIN_setOutputValue(pin_handle, D6, 1); // CS_ADC
|
||||
ELITE15_SPI_CLOSE();
|
||||
PIN_setOutputValue(pin_handle, AD_CS, 1); // CS_ADC
|
||||
}
|
||||
|
||||
static void DAC_SPI(uint8_t length, uint8_t *spi_txbuf, uint8_t *spi_rxbuf) {
|
||||
ELITE15_SPI_HOLD();
|
||||
PIN_setOutputValue(pin_handle, D7, 0); // CD_DAC
|
||||
ADC_DAC_transaction.count = length;
|
||||
ADC_DAC_transaction.txBuf = spi_txbuf;
|
||||
ADC_DAC_transaction.rxBuf = spi_rxbuf;
|
||||
|
||||
SPI_transfer(spiHandle1, &ADC_DAC_transaction);
|
||||
}
|
||||
|
||||
/* Elite1.5 Calibration SPI */
|
||||
static void CAL_ADC_SPI(uint8_t length, uint8_t *spi_txbuf, uint8_t *spi_rxbuf) {
|
||||
ADC_DAC_transaction.count = length;
|
||||
ADC_DAC_transaction.txBuf = spi_txbuf;
|
||||
ADC_DAC_transaction.rxBuf = spi_rxbuf;
|
||||
|
||||
SPI_transfer(spiHandle1, &ADC_DAC_transaction);
|
||||
|
||||
PIN_setOutputValue(pin_handle, D7, 1); // CD_DAC
|
||||
ELITE15_SPI_CLOSE();
|
||||
PIN_setOutputValue(pin_handle, AD_CS, 1); // CS_ADC
|
||||
}
|
||||
|
||||
static void LED_SPI_TEST(uint8_t length, uint16_t *spi_txbuf, uint16_t *spi_rxbuf) {
|
||||
static void CAL_LED_SPI(uint8_t length, uint16_t *spi_txbuf, uint16_t *spi_rxbuf) {
|
||||
LED_transaction.count = length;
|
||||
LED_transaction.txBuf = spi_txbuf;
|
||||
LED_transaction.rxBuf = spi_rxbuf;
|
||||
@@ -104,50 +101,201 @@ static void LED_SPI_TEST(uint8_t length, uint16_t *spi_txbuf, uint16_t *spi_rxbu
|
||||
SPI_transfer(spiHandle0, &LED_transaction);
|
||||
}
|
||||
|
||||
static void ADC_SPI_TEST(uint8_t length, uint8_t *spi_txbuf, uint8_t *spi_rxbuf) {
|
||||
PIN_setOutputValue(pin_handle, D6, 0); // CS_ADC
|
||||
|
||||
ADC_DAC_transaction.count = length;
|
||||
ADC_DAC_transaction.txBuf = spi_txbuf;
|
||||
|
||||
#ifdef ELITE_VERSION_EIS
|
||||
//define SPI command
|
||||
#define SPICMD_SETADDR 0x20
|
||||
#define SPICMD_WRITEREG 0x2D
|
||||
#define SPICMD_READREG 0x6D
|
||||
|
||||
//define REG
|
||||
#define LPDACCON0 0x2128
|
||||
#define LPDACSW0 0x2124
|
||||
#define LPDACDAT0 0x2120
|
||||
#define LPREFBUFCON 0x2050
|
||||
#define SWMUX 0x235C
|
||||
#define LPTIASW0 0x20E4
|
||||
#define SWCON 0x200C
|
||||
#define HSDACCON 0x2010
|
||||
#define HSDACDAT 0x2048
|
||||
#define LPTIACON0 0x20EC
|
||||
#define HSTIACON 0x20FC
|
||||
#define AFECON 0x2000
|
||||
#define DSWFULLCON 0x2150
|
||||
#define NSWFULLCON 0x2154
|
||||
#define PSWFULLCON 0x2158
|
||||
#define TSWFULLCON 0x215C
|
||||
#define WGFCW 0x2030
|
||||
#define WGPHASE 0x2034
|
||||
#define WGOFFSET 0x2038
|
||||
#define WGAMPLITUDE 0x203C
|
||||
#define WGCON 0x2014
|
||||
#define DE0RESCON 0x20F8
|
||||
#define ADCCON 0x21A8
|
||||
#define DFTCON 0x20D0
|
||||
#define ADCFILTERCON 0x2044
|
||||
|
||||
static void select_REG(uint16_t addr){
|
||||
PIN_setOutputValue(pin_handle, AD_CS, 0);
|
||||
// CPUdelay(16000);
|
||||
|
||||
spi_DACtxbuf[0] = SPICMD_SETADDR;
|
||||
spi_DACtxbuf[1] = (uint8_t)((addr & 0xFF00) >> 8);
|
||||
spi_DACtxbuf[2] = (uint8_t)(addr & 0x00FF);
|
||||
|
||||
ADC_DAC_transaction.count = 3;
|
||||
ADC_DAC_transaction.txBuf = spi_DACtxbuf;
|
||||
ADC_DAC_transaction.rxBuf = spi_rxbuf;
|
||||
SPI_transfer(spiHandle1, &ADC_DAC_transaction);
|
||||
// CPUdelay(16000);
|
||||
PIN_setOutputValue(pin_handle, AD_CS, 1);
|
||||
}
|
||||
|
||||
static void w16_REG(uint16_t data){
|
||||
PIN_setOutputValue(pin_handle, AD_CS, 0);
|
||||
spi_DACtxbuf[0] = SPICMD_WRITEREG;
|
||||
spi_DACtxbuf[1] = (uint8_t)((data & 0xFF00) >> 8);
|
||||
spi_DACtxbuf[2] = (uint8_t)(data & 0x00FF);
|
||||
|
||||
ADC_DAC_transaction.count = 3;
|
||||
ADC_DAC_transaction.txBuf = spi_DACtxbuf;
|
||||
ADC_DAC_transaction.rxBuf = spi_rxbuf;
|
||||
SPI_transfer(spiHandle1, &ADC_DAC_transaction);
|
||||
|
||||
PIN_setOutputValue(pin_handle, D6, 1); // CS_ADC
|
||||
PIN_setOutputValue(pin_handle, AD_CS, 1);
|
||||
}
|
||||
|
||||
static void DAC_SPI_TEST(uint8_t length, uint8_t *spi_txbuf, uint8_t *spi_rxbuf) {
|
||||
PIN_setOutputValue(pin_handle, D7, 0); // CD_DAC
|
||||
static void r16_REG(){
|
||||
PIN_setOutputValue(pin_handle, AD_CS, 0);
|
||||
spi_DACtxbuf[0] = SPICMD_READREG;
|
||||
spi_DACtxbuf[1] = 0x00;
|
||||
spi_DACtxbuf[2] = 0x00;
|
||||
spi_DACtxbuf[3] = 0x00;
|
||||
|
||||
ADC_DAC_transaction.count = length;
|
||||
ADC_DAC_transaction.txBuf = spi_txbuf;
|
||||
ADC_DAC_transaction.count = 4;
|
||||
ADC_DAC_transaction.txBuf = spi_DACtxbuf;
|
||||
ADC_DAC_transaction.rxBuf = spi_rxbuf;
|
||||
|
||||
SPI_transfer(spiHandle1, &ADC_DAC_transaction);
|
||||
|
||||
PIN_setOutputValue(pin_handle, D7, 1); // CD_DAC
|
||||
PIN_setOutputValue(pin_handle, AD_CS, 1);
|
||||
}
|
||||
|
||||
static void ELITE15_SPI_HOLD() {
|
||||
PIN_setOutputValue(pin_handle, LOAD0, 1);
|
||||
PIN_setOutputValue(pin_handle, LOAD1, 0);
|
||||
PIN_setOutputValue(pin_handle, LOAD2, 0);
|
||||
PIN_setOutputValue(pin_handle, D4, 1); // HOLD_MEM
|
||||
PIN_setOutputValue(pin_handle, D5, 1); // CS_MEM
|
||||
PIN_setOutputValue(pin_handle, D6, 1); // CS_ADC
|
||||
PIN_setOutputValue(pin_handle, D7, 1); // CD_DAC
|
||||
Elite_SPI_init();
|
||||
static void w32_REG(uint32_t data){
|
||||
PIN_setOutputValue(pin_handle, AD_CS, 0);
|
||||
spi_DACtxbuf[0] = SPICMD_WRITEREG;
|
||||
spi_DACtxbuf[1] = (uint8_t)((data & 0xFF000000) >> 24);
|
||||
spi_DACtxbuf[2] = (uint8_t)((data & 0x00FF0000) >> 16);
|
||||
spi_DACtxbuf[3] = (uint8_t)((data & 0x0000FF00) >> 8);
|
||||
spi_DACtxbuf[4] = (uint8_t)(data & 0x000000FF);
|
||||
|
||||
ADC_DAC_transaction.count = 5;
|
||||
ADC_DAC_transaction.txBuf = spi_DACtxbuf;
|
||||
ADC_DAC_transaction.rxBuf = spi_rxbuf;
|
||||
SPI_transfer(spiHandle1, &ADC_DAC_transaction);
|
||||
|
||||
PIN_setOutputValue(pin_handle, AD_CS, 1);
|
||||
}
|
||||
static void ELITE15_SPI_CLOSE() {
|
||||
PIN_setOutputValue(pin_handle, D4, 1); // HOLD_MEM
|
||||
PIN_setOutputValue(pin_handle, D5, 1); // CS_MEM
|
||||
PIN_setOutputValue(pin_handle, D6, 1); // CS_ADC
|
||||
PIN_setOutputValue(pin_handle, D7, 1); // CD_DAC
|
||||
PIN_setOutputValue(pin_handle, LOAD0, 0);
|
||||
PIN_setOutputValue(pin_handle, LOAD1, 0);
|
||||
PIN_setOutputValue(pin_handle, LOAD2, 0);
|
||||
SPI_close(spiHandle0);
|
||||
SPI_close(spiHandle1);
|
||||
|
||||
static void r32_REG(){
|
||||
PIN_setOutputValue(pin_handle, AD_CS, 0);
|
||||
spi_DACtxbuf[0] = SPICMD_READREG;
|
||||
spi_DACtxbuf[1] = 0x00;
|
||||
spi_DACtxbuf[2] = 0x00;
|
||||
spi_DACtxbuf[3] = 0x00;
|
||||
spi_DACtxbuf[4] = 0x00;
|
||||
spi_DACtxbuf[5] = 0x00;
|
||||
|
||||
ADC_DAC_transaction.count = 6;
|
||||
ADC_DAC_transaction.txBuf = spi_DACtxbuf;
|
||||
ADC_DAC_transaction.rxBuf = spi_rxbuf;
|
||||
SPI_transfer(spiHandle1, &ADC_DAC_transaction);
|
||||
|
||||
PIN_setOutputValue(pin_handle, AD_CS, 1);
|
||||
}
|
||||
|
||||
static void AD5940_init(){
|
||||
PIN_setOutputValue(pin_handle, AD_reset, 0);
|
||||
PIN_setOutputValue(pin_handle, AD_reset, 1);
|
||||
select_REG(0x0908);//initiation
|
||||
w16_REG(0x02C9);
|
||||
select_REG(0x0C08);
|
||||
w16_REG(0x206C);
|
||||
select_REG(0x21F0);
|
||||
w16_REG(0x0010);
|
||||
select_REG(0x0410);
|
||||
w16_REG(0x02C9);
|
||||
select_REG(0x0A28);
|
||||
w16_REG(0x0009);
|
||||
select_REG(0x238C);
|
||||
w16_REG(0x0104);
|
||||
select_REG(0x0A04);
|
||||
w16_REG(0x4859);
|
||||
select_REG(0x0A04);
|
||||
w16_REG(0xF27B);
|
||||
select_REG(0x0A00);
|
||||
w16_REG(0x8009);
|
||||
select_REG(0x0A04);
|
||||
w16_REG(0x4859);
|
||||
select_REG(0x22F0);
|
||||
w16_REG(0x0000);
|
||||
|
||||
select_REG(SWCON); //200C
|
||||
w32_REG(0x000402B5); //0b1000000001010110101
|
||||
|
||||
select_REG(HSDACCON); //2010 //ac gain
|
||||
w32_REG(0x0000001E);
|
||||
|
||||
select_REG(WGFCW); //2030
|
||||
w32_REG(0x00340000); //SINEFCW/2^30 * 32 MHz
|
||||
select_REG(WGCON); //2014
|
||||
w32_REG(0x00000004); //AC on/off; 0x0:DC 0x4:AC 0x5:trapezoid
|
||||
//0x0: 00000 DC
|
||||
//0x4: 00100 Sinusoid
|
||||
//0x6: 00110 Trapezoid ---Taylor
|
||||
|
||||
select_REG(LPDACCON0); //2128 //DC on
|
||||
w32_REG(0b00000001);
|
||||
select_REG(LPDACSW0); //2124 //operation
|
||||
w32_REG(0b00101011);
|
||||
select_REG(LPDACDAT0); //2120 //output Vout
|
||||
w32_REG(0x00000000);
|
||||
|
||||
// select_REG(HSTIACON); //20FC //SE0's gain
|
||||
// w32_REG(0x0);
|
||||
select_REG(DE0RESCON); //20F8 //DE0's gain
|
||||
w32_REG(0x00000068);
|
||||
|
||||
select_REG(ADCCON); //21A8
|
||||
w32_REG(0x00000101);
|
||||
select_REG(DFTCON); //20D0
|
||||
w32_REG(0x000000C1);
|
||||
select_REG(ADCFILTERCON); //2044
|
||||
w32_REG(0x000000D0);
|
||||
|
||||
select_REG(AFECON); //2000
|
||||
w32_REG(0x0030CFC0);
|
||||
// w32_REG(0b1100011100111111000000);
|
||||
}
|
||||
|
||||
static void EIS_LPDAC_SPI(){
|
||||
// uint32_t con = 0b00001;//12 bit DAC
|
||||
// uint32_t sw = 0b01010;//test mode
|
||||
// uint32_t volt = 0;//2.4v
|
||||
// uint32_t buf = 0;//LP reference
|
||||
// uint32_t cm = 0;//common mode disabled
|
||||
// select_REG(LPDACCON0);
|
||||
// w32_REG(con);
|
||||
// select_REG(LPDACSW0);
|
||||
// w32_REG(sw);
|
||||
// select_REG(LPDACDAT0);
|
||||
// w32_REG(volt);
|
||||
// select_REG(LPREFBUFCON);
|
||||
// w32_REG(buf);
|
||||
// select_REG(SWMUX);
|
||||
// w32_REG(cm);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif // ELITE_SPI
|
||||
|
||||
+3
-1
@@ -1,7 +1,7 @@
|
||||
#ifndef ELITE_WORK_DATA
|
||||
#define ELITE_WORK_DATA
|
||||
|
||||
#define CLOCK_ONE_SECOND 10000
|
||||
#define CLOCK_ONE_SECOND 00001
|
||||
|
||||
#include "EliteInstruction.h"
|
||||
|
||||
@@ -434,6 +434,7 @@ WorkMode *CreateWorkMode(){
|
||||
void InitWorkMode(WorkMode *WM){
|
||||
switch(INSTRUCTION.eliteFxn){
|
||||
case VOLT_OUTPUT:
|
||||
case CALI_DAC_MODE:
|
||||
WM->VO = InitVoltOutMode();
|
||||
break;
|
||||
case IT_CURVE:
|
||||
@@ -475,6 +476,7 @@ void InitWorkMode(WorkMode *WM){
|
||||
void FreeWorkMode(WorkMode *WM){
|
||||
switch(INSTRUCTION.eliteFxn){
|
||||
case VOLT_OUTPUT:
|
||||
case CALI_DAC_MODE:
|
||||
if(WM->VO != NULL){
|
||||
free(WM->VO);
|
||||
WM->VO = NULL;
|
||||
|
||||
+15
-77
@@ -8,97 +8,37 @@
|
||||
|
||||
/* SPI Board */
|
||||
#define Board_SPI0_MISO PIN_UNASSIGNED
|
||||
#define Board_SPI0_MOSI D1
|
||||
#define Board_SPI0_CLK D0
|
||||
#define Board_SPI0_MOSI IOID_4
|
||||
#define Board_SPI0_CLK IOID_3
|
||||
#define Board_SPI0_CS PIN_UNASSIGNED
|
||||
|
||||
#define Board_SPI1_MISO IOID_1
|
||||
#define Board_SPI1_MOSI D3
|
||||
#define Board_SPI1_CLK D2
|
||||
#define Board_SPI1_MOSI IOID_6
|
||||
#define Board_SPI1_CLK IOID_5
|
||||
#define Board_SPI1_CS PIN_UNASSIGNED
|
||||
|
||||
#define D0 IOID_3
|
||||
#define D1 IOID_4
|
||||
#define D2 IOID_5
|
||||
#define D3 IOID_6
|
||||
#define D4 IOID_7
|
||||
#define D5 IOID_8
|
||||
#define D6 IOID_9
|
||||
#define D7 IOID_10
|
||||
#define AD_CS IOID_10
|
||||
|
||||
#define LOAD0 IOID_13
|
||||
#define LOAD1 IOID_12
|
||||
#define LOAD2 IOID_11
|
||||
//#define SD_MISO IOID_11
|
||||
//#define SD_CS IOID_8
|
||||
//#define SD_CLK IOID_7
|
||||
//#define SD_MOSI IOID_13
|
||||
|
||||
#define ADC_CS LOAD0, D6
|
||||
#define DAC_CS LOAD0, D7
|
||||
#define ADC_DAC_SPI_MOSI LOAD0, D3
|
||||
#define ADC_DAC_SPI_CLK LOAD0, D2
|
||||
#define LED_MOSI LOAD0, D1
|
||||
#define LED_CLK LOAD0, D0
|
||||
#define MEM_HOLD LOAD0, D4
|
||||
#define MEM_CS LOAD0, D5
|
||||
|
||||
#define Turnon_I_MID LOAD2, D0
|
||||
#define Turnon_I_SMALL LOAD2, D4
|
||||
#define Turnon_I_LARGE LOAD2, D1
|
||||
#define Turnon_V_SMALL LOAD2, D2
|
||||
#define Turnon_V_MID LOAD2, D3
|
||||
#define Turon_VOUT_SMALL LOAD2, D7
|
||||
|
||||
//#define Turnon10K Turnon_I_MID
|
||||
//#define Turnon200R Turnon_I_LARGE
|
||||
|
||||
/* I2C */
|
||||
#ifdef ELITE_VERSION_1_4
|
||||
#define Board_I2C0_SCL0 PIN_UNASSIGNED
|
||||
#define Board_I2C0_SDA0 PIN_UNASSIGNED
|
||||
#endif
|
||||
|
||||
#define shutdown_6994 LOAD2, D6
|
||||
#define switch_on IOID_14
|
||||
#define HIGH_Z_MODE LOAD2, D5
|
||||
#define enable_10v LOAD1, D5
|
||||
#define enable_5v LOAD1, D6
|
||||
#define enable_5v IOID_9
|
||||
#define AD_reset IOID_13
|
||||
|
||||
PIN_Handle pin_handle;
|
||||
static PIN_State ZM_rst;
|
||||
|
||||
const PIN_Config BLE_IO[] = {
|
||||
// D0 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
// D1 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
// D2 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
// D3 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
D4 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
D5 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
D6 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
D7 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
|
||||
LOAD0 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
LOAD1 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
LOAD2 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
|
||||
switch_on | PIN_INPUT_EN | PIN_PULLDOWN, // to sense switch
|
||||
|
||||
enable_5v | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,// 5V_enable
|
||||
AD_reset | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MAX,
|
||||
switch_on | PIN_INPUT_EN | PIN_PULLDOWN,
|
||||
AD_CS | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MAX,
|
||||
PIN_TERMINATE
|
||||
};
|
||||
|
||||
static void add_elite_pin() {
|
||||
// PIN_Status elite15_status;
|
||||
PIN_add(pin_handle,
|
||||
D0 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL);
|
||||
PIN_add(pin_handle,
|
||||
D1 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL);
|
||||
PIN_add(pin_handle,
|
||||
D2 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL);
|
||||
PIN_add(pin_handle,
|
||||
D3 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL);
|
||||
|
||||
// if(elite15_status != PIN_SUCCESS) {
|
||||
// LED_color(DARKLED, 0x0F, 0x0F, 0x0F);
|
||||
// }
|
||||
}
|
||||
|
||||
static void remove_elite_pin() {
|
||||
PIN_close(pin_handle);
|
||||
pin_handle = PIN_open(&ZM_rst, BLE_IO);
|
||||
@@ -219,8 +159,6 @@ const I2CCC26XX_HWAttrsV1 i2cCC26xxHWAttrs[CC2650_MA_I2CCOUNT] = {
|
||||
.intNum = INT_I2C_IRQ,
|
||||
.intPriority = ~0,
|
||||
.swiPriority = 0,
|
||||
.sdaPin = Board_I2C0_SDA0,
|
||||
.sclPin = Board_I2C0_SCL0,
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
+1
-1
@@ -85,7 +85,7 @@ static void measureBat(){
|
||||
uint16_t bat = ((uint16_t)(NotifyVoltBat[2]) << 8 & 0xFF00 ) |
|
||||
((uint16_t)(NotifyVoltBat[3]) & 0x00FF);
|
||||
if( bat < 768 && bat > 20){
|
||||
PIN15_setOutputValue(enable_5v, 0);
|
||||
PIN_setOutputValue(pin_handle, enable_5v, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+9
-2
@@ -36,13 +36,20 @@
|
||||
#define HIGH_CYCLE_CYCLIC_VOLTAMMETRY 0x01
|
||||
#define LINEAR_SWEEP_VOLTAMMETRY 0x02
|
||||
#define CONSTANT_VSCAN 0x03
|
||||
#define ADC_TEST 0x90
|
||||
#define ADC_TEST 0x91
|
||||
#define CALI_DAC_MODE 0x93
|
||||
#define CALI_ADC_MODE 0x92
|
||||
#define DEV_MODE 0xFF
|
||||
|
||||
// CIS (control instruction)
|
||||
#define CIS_VERSION 0x40
|
||||
#define CIS_VOLT 0x10
|
||||
#define CIS_LED_TEST 0x70
|
||||
|
||||
#define CTL_WRT 0x20
|
||||
#define CTL_RD 0x21
|
||||
#define CTL_RD_DFTR 0x78
|
||||
#define CTL_RD_DFTI 0x7C
|
||||
#define CTL_WRT_WGAMPL 0x3C
|
||||
// mode parameter
|
||||
#define STEP_TO_VSETRATE(step) step2VsetRate(step)
|
||||
#define VMAX(v1,v2) ((v1 >= v2) ? v1 : v2)
|
||||
|
||||
-52
@@ -1,52 +0,0 @@
|
||||
|
||||
#ifndef ELITE_EVENT_H
|
||||
#define ELITE_EVENT_H
|
||||
|
||||
/** event */
|
||||
#define EVT_KEY_DETECT 0x0001
|
||||
#define EVT_LED_CHANGE 0x0002
|
||||
#define EVT_CREATE_MODE 0x0004
|
||||
#define EVT_FREE_MODE 0x0008
|
||||
#define EVT_MODE_ACTIVE 0x0010
|
||||
#define EVT_RESERVED0 0x0020
|
||||
#define EVT_RESERVED1 0x0040
|
||||
|
||||
static uint16_t elite_event = 0x0000;
|
||||
|
||||
/**
|
||||
* test event [flag] has been enabled.
|
||||
*/
|
||||
#define flag_mask(flag) ((elite_event & (flag)) != 0)
|
||||
|
||||
/**
|
||||
* enable event [flag].
|
||||
*/
|
||||
#define flag_enable(flag) \
|
||||
do { \
|
||||
uint8 __key = Hwi_disable(); \
|
||||
elite_event |= (uint16_t)(flag); \
|
||||
Hwi_restore(__key); \
|
||||
} while (0)
|
||||
|
||||
/**
|
||||
* disable event [flag].
|
||||
*/
|
||||
#define flag_disable(flag) \
|
||||
do { \
|
||||
uint8 __key = Hwi_disable(); \
|
||||
elite_event &= ~((uint16_t)(flag)); \
|
||||
Hwi_restore(__key); \
|
||||
} while (0)
|
||||
|
||||
/**
|
||||
* fire a event with [flag].
|
||||
*/
|
||||
#define flag_notify(flag) \
|
||||
do { \
|
||||
uint8 __key = Hwi_disable(); \
|
||||
elite_event |= (uint16_t)(flag); \
|
||||
Hwi_restore(__key); \
|
||||
Semaphore_post(semaphore); \
|
||||
} while (0)
|
||||
|
||||
#endif
|
||||
-44
@@ -1,44 +0,0 @@
|
||||
|
||||
#ifndef ELITE_EVENT_HANDLE_H
|
||||
#define ELITE_EVENT_HANDLE_H
|
||||
|
||||
#include "Elite_event.h"
|
||||
#include "EliteKeyDetect.h"
|
||||
|
||||
static void elite_event_handle(WorkMode *WorkModeData){
|
||||
if (flag_mask(EVT_KEY_DETECT)) {
|
||||
flag_disable(EVT_KEY_DETECT);
|
||||
uint8_t key = PIN_getInputValue(switch_on);
|
||||
// elite_key_handle(key);
|
||||
}
|
||||
|
||||
if (flag_mask(EVT_LED_CHANGE)) {
|
||||
flag_disable(EVT_LED_CHANGE);
|
||||
// elite_led_handle();
|
||||
}
|
||||
|
||||
if(flag_mask(EVT_CREATE_MODE)){
|
||||
flag_disable(EVT_CREATE_MODE);
|
||||
InitWorkMode(WorkModeData);
|
||||
}
|
||||
|
||||
if(flag_mask(EVT_FREE_MODE)){
|
||||
flag_disable(EVT_FREE_MODE);
|
||||
FreeWorkMode(WorkModeData);
|
||||
InitEliteInstruction();
|
||||
IinADCGainControl(INSTRUCTION.ADCGainLevel);
|
||||
DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoutGainLevel, INSTRUCTION.VoltConstant));
|
||||
}
|
||||
|
||||
if (flag_mask(EVT_MODE_ACTIVE)) {
|
||||
flag_disable(EVT_MODE_ACTIVE);
|
||||
SimpleBLEPeripheral_performPeriodicTask(WorkModeData);
|
||||
}
|
||||
|
||||
if (flag_mask(EVT_UPDATE_WORK_MODE)) {
|
||||
flag_disable(EVT_UPDATE_WORK_MODE);
|
||||
update_work_mode_handle(WorkModeData);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
+235
-18
@@ -105,52 +105,41 @@ static void DACenable(WorkMode *WorkModeData, int32_t VoltData ,uint8_t afterRea
|
||||
}
|
||||
|
||||
static void CC_Plot(WorkMode *WorkModeData){
|
||||
|
||||
void *active_mode;
|
||||
switch (INSTRUCTION.eliteFxn) {
|
||||
case IT_CURVE:{
|
||||
#define CURRENT_MODE WorkModeData->IT
|
||||
active_mode = WorkModeData->IT;
|
||||
break;
|
||||
}
|
||||
case VT_CURVE:{
|
||||
#define CURRENT_MODE WorkModeData->VT
|
||||
active_mode = WorkModeData->VT;
|
||||
break;
|
||||
}
|
||||
case ZT_CURVE:{
|
||||
#define CURRENT_MODE WorkModeData->RT
|
||||
active_mode = WorkModeData->RT;
|
||||
break;
|
||||
}
|
||||
case IV_CURVE:{
|
||||
#define CURRENT_MODE WorkModeData->IV
|
||||
active_mode = WorkModeData->IV;
|
||||
break;
|
||||
}
|
||||
case CV_CURVE:{
|
||||
#define CURRENT_MODE WorkModeData->CV
|
||||
active_mode = WorkModeData->CV;
|
||||
break;
|
||||
}
|
||||
case CONSTANT_CURRENT:{
|
||||
#define CURRENT_MODE WorkModeData->CC
|
||||
active_mode = WorkModeData->CC;
|
||||
break;
|
||||
}
|
||||
case CYCLIC_VOLTAMMETRY:{
|
||||
#define CURRENT_MODE WorkModeData->CV3
|
||||
active_mode = WorkModeData->CV3;
|
||||
break;
|
||||
}
|
||||
case LINEAR_SWEEP_VOLTAMMETRY:{
|
||||
#define CURRENT_MODE WorkModeData->LSV
|
||||
active_mode = WorkModeData->LSV;
|
||||
break;
|
||||
}
|
||||
case CONSTANT_VSCAN:{
|
||||
#define CURRENT_MODE WorkModeData->CVSCAN
|
||||
active_mode = NULL;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
@@ -158,8 +147,6 @@ static void CC_Plot(WorkMode *WorkModeData){
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static uint8_t ADCSwitch = 0;
|
||||
static uint8_t BatSwitch = 0;
|
||||
static int32_t VoltData = 0;
|
||||
@@ -176,7 +163,7 @@ static void CC_Plot(WorkMode *WorkModeData){
|
||||
recordCount = 0;
|
||||
}
|
||||
}else{
|
||||
InputNotify(NOTIFY_CURRENT, ()active_mode->_measureCurrent);
|
||||
InputNotify(NOTIFY_CURRENT, CURRENT_MODE->_measureCurrent);
|
||||
}
|
||||
DACenable(WorkModeData, VoltData, AFTER_READ_I);
|
||||
|
||||
@@ -460,12 +447,12 @@ static void readIin(WorkMode *WorkModeData){
|
||||
|
||||
if(INSTRUCTION.AutoGainEnable){
|
||||
TEMP_MODE->_measureCurrent = AutoGainReadIin(spi_ADC_rxbuf);
|
||||
AutoGainChangeIin(TEMP_MODE->_measureCurrent);
|
||||
// AutoGainChangeIin(TEMP_MODE->_measureCurrent);
|
||||
}else{
|
||||
ReadADCIin(spi_ADC_rxbuf);
|
||||
TEMP_MODE->_measureCurrent = DecodeADCValue(INSTRUCTION.ADCGainLevel, ADC_CH_CURRENT, spi_ADC_rxbuf);
|
||||
if(lastIinADCGainLevel != INSTRUCTION.ADCGainLevel){
|
||||
IinADCGainControl(INSTRUCTION.ADCGainLevel);
|
||||
// IinADCGainControl(INSTRUCTION.ADCGainLevel);
|
||||
record_flag = false;
|
||||
}
|
||||
}
|
||||
@@ -520,12 +507,12 @@ static int32_t readVinVout(WorkMode *WorkModeData){
|
||||
if(TEMP_MODE->_VoViSwitch == 0x01 || TEMP_MODE->_VoViSwitch == 0x02){
|
||||
if(INSTRUCTION.VinAutoGainEnable){
|
||||
TEMP_MODE->_measureVin = AutoGainReadVin(spi_ADC_rxbuf);
|
||||
AutoGainChangeVin(TEMP_MODE->_measureVin);
|
||||
// AutoGainChangeVin(TEMP_MODE->_measureVin);
|
||||
}else{
|
||||
ReadADCVolt(TEMP_MODE->_VoViSwitch);
|
||||
TEMP_MODE->_measureVin = DecodeADCValue(INSTRUCTION.VinADCGainLevel, ADC_CH_VOLT, spi_ADC_rxbuf);
|
||||
if(lastVinADCGainLevel != INSTRUCTION.VinADCGainLevel){
|
||||
VinADCGainControl(INSTRUCTION.VinADCGainLevel);
|
||||
// VinADCGainControl(INSTRUCTION.VinADCGainLevel);
|
||||
record_flag = false;
|
||||
}
|
||||
|
||||
@@ -540,4 +527,234 @@ static int32_t readVinVout(WorkMode *WorkModeData){
|
||||
return VoltData;
|
||||
}
|
||||
|
||||
static void cali_IT_plot(WorkMode *WorkModeData) {
|
||||
switch (INSTRUCTION.eliteFxn) {
|
||||
case IT_CURVE:{
|
||||
#define CURRENT_MODE WorkModeData->IT
|
||||
break;
|
||||
}
|
||||
case VT_CURVE:{
|
||||
#define CURRENT_MODE WorkModeData->VT
|
||||
break;
|
||||
}
|
||||
case ZT_CURVE:{
|
||||
#define CURRENT_MODE WorkModeData->RT
|
||||
break;
|
||||
}
|
||||
case IV_CURVE:{
|
||||
#define CURRENT_MODE WorkModeData->IV
|
||||
break;
|
||||
}
|
||||
case CV_CURVE:{
|
||||
#define CURRENT_MODE WorkModeData->CV
|
||||
break;
|
||||
}
|
||||
case CONSTANT_CURRENT:{
|
||||
#define CURRENT_MODE WorkModeData->CC
|
||||
break;
|
||||
}
|
||||
case CYCLIC_VOLTAMMETRY:{
|
||||
#define CURRENT_MODE WorkModeData->CV3
|
||||
break;
|
||||
}
|
||||
case LINEAR_SWEEP_VOLTAMMETRY:{
|
||||
#define CURRENT_MODE WorkModeData->LSV
|
||||
break;
|
||||
}
|
||||
case CONSTANT_VSCAN:{
|
||||
#define CURRENT_MODE WorkModeData->CVSCAN
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
#define CURRENT_MODE WorkModeData->VT
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static uint8_t ADCSwitch = 0;
|
||||
static int32_t ADCValueSUM = 0;
|
||||
int32_t ADCValueAVG = 0;
|
||||
|
||||
if(ADCSwitch == 0){ /**read Iin(buffer)**/
|
||||
if(INSTRUCTION.AutoGainEnable){
|
||||
CURRENT_MODE->_measureCurrent = 0xFFFF;
|
||||
}else{
|
||||
ReadADCIin(spi_ADC_rxbuf);
|
||||
CURRENT_MODE->_measureCurrent = (int32_t) (spi_ADC_rxbuf[0] << 8) | (int32_t) (spi_ADC_rxbuf[1]);
|
||||
if(lastIinADCGainLevel != INSTRUCTION.ADCGainLevel){
|
||||
// IinADCGainControl(INSTRUCTION.ADCGainLevel);
|
||||
record_flag = false;
|
||||
}
|
||||
}
|
||||
|
||||
if(record_flag == false){
|
||||
static int recordCount = 0;
|
||||
recordCount++;
|
||||
if(recordCount == 2){
|
||||
record_flag = true;
|
||||
recordCount = 0;
|
||||
}
|
||||
}else{
|
||||
static uint16_t cali_count = 0;
|
||||
if(cali_count >= 1000){
|
||||
ADCValueAVG = ADCValueSUM / cali_count;
|
||||
|
||||
InputNotify(NOTIFY_CURRENT, ADCValueAVG);
|
||||
SendNotify();
|
||||
|
||||
uint8_t CIS_buf[9] = {0};
|
||||
CIS_buf[0] = INSTRUCTION.chip_id;
|
||||
CIS_buf[1] = (uint8_t) ((ADCValueAVG & 0xFF00) >> 8);
|
||||
CIS_buf[2] = (uint8_t) (ADCValueAVG & 0x00FF);
|
||||
CIS_buf[3] = 0x00;
|
||||
CIS_buf[4] = INSTRUCTION.ADCGainLevel;
|
||||
SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, 9, CIS_buf);
|
||||
ADCValueSUM = 0;
|
||||
cali_count = 0;
|
||||
|
||||
PeriodicEvent = false;
|
||||
ModeLED(NO_EVENT);
|
||||
}else{
|
||||
cali_count++;
|
||||
ADCValueSUM = ADCValueSUM + CURRENT_MODE->_measureCurrent;
|
||||
InputNotify(NOTIFY_CURRENT, CURRENT_MODE->_measureCurrent);
|
||||
InputNotify(NOTIFY_VOLT, ADCValueSUM);
|
||||
InputNotify(NOTIFY_IMPEDANCE, (int32_t)cali_count);
|
||||
}
|
||||
|
||||
}
|
||||
ADCSwitch++;
|
||||
}
|
||||
else if(ADCSwitch == 1){ /**read Iin**/
|
||||
ReadADCIin(spi_ADC_rxbuf);
|
||||
ADCSwitch++;
|
||||
}
|
||||
else if(ADCSwitch == 2){ /**read Iin**/
|
||||
ReadADCIin(spi_ADC_rxbuf);
|
||||
ADCSwitch = 0;
|
||||
}
|
||||
|
||||
#undef CURRENT_MODE
|
||||
}
|
||||
|
||||
static void cali_VT_plot(WorkMode *WorkModeData) {
|
||||
switch (INSTRUCTION.eliteFxn) {
|
||||
case IT_CURVE:{
|
||||
#define CURRENT_MODE WorkModeData->IT
|
||||
break;
|
||||
}
|
||||
case VT_CURVE:{
|
||||
#define CURRENT_MODE WorkModeData->VT
|
||||
break;
|
||||
}
|
||||
case ZT_CURVE:{
|
||||
#define CURRENT_MODE WorkModeData->RT
|
||||
break;
|
||||
}
|
||||
case IV_CURVE:{
|
||||
#define CURRENT_MODE WorkModeData->IV
|
||||
break;
|
||||
}
|
||||
case CV_CURVE:{
|
||||
#define CURRENT_MODE WorkModeData->CV
|
||||
break;
|
||||
}
|
||||
case CONSTANT_CURRENT:{
|
||||
#define CURRENT_MODE WorkModeData->CC
|
||||
break;
|
||||
}
|
||||
case CYCLIC_VOLTAMMETRY:{
|
||||
#define CURRENT_MODE WorkModeData->CV3
|
||||
break;
|
||||
}
|
||||
case LINEAR_SWEEP_VOLTAMMETRY:{
|
||||
#define CURRENT_MODE WorkModeData->LSV
|
||||
break;
|
||||
}
|
||||
case CONSTANT_VSCAN:{
|
||||
#define CURRENT_MODE WorkModeData->CVSCAN
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
#define CURRENT_MODE WorkModeData->VT
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static uint8_t ADCSwitch = 0;
|
||||
static int32_t VoltData;
|
||||
static int32_t ADCValueSUM = 0;
|
||||
int32_t ADCValueAVG = 0;
|
||||
|
||||
if(ADCSwitch == 0){ /**read Iin(buffer)**/
|
||||
if(CURRENT_MODE->_VoViSwitch == 0x01 || CURRENT_MODE->_VoViSwitch == 0x02){
|
||||
if(INSTRUCTION.VinAutoGainEnable){
|
||||
CURRENT_MODE->_measureVin = 0xFFFF;
|
||||
}else{
|
||||
ReadADCVolt(CURRENT_MODE->_VoViSwitch);
|
||||
CURRENT_MODE->_measureVin = (int32_t) (spi_ADC_rxbuf[0] << 8) | (int32_t) (spi_ADC_rxbuf[1]);
|
||||
if(lastVinADCGainLevel != INSTRUCTION.VinADCGainLevel){
|
||||
// VinADCGainControl(INSTRUCTION.VinADCGainLevel);
|
||||
record_flag = false;
|
||||
}
|
||||
|
||||
}
|
||||
VoltData = CURRENT_MODE->_measureVin;
|
||||
}
|
||||
// else if(CURRENT_MODE->_VoViSwitch == 0x00){
|
||||
// ReadADCVolt(CURRENT_MODE->_VoViSwitch);
|
||||
// CURRENT_MODE->_measureVout = DecodeADCValue(INSTRUCTION.ADCGainLevel, ADC_CH_DAC, spi_ADC_rxbuf);
|
||||
// VoltData = CURRENT_MODE->_measureVout;
|
||||
// }
|
||||
|
||||
if(record_flag == false){
|
||||
static int recordCount = 0;
|
||||
recordCount++;
|
||||
if(recordCount == 2){
|
||||
record_flag = true;
|
||||
recordCount = 0;
|
||||
}
|
||||
}else{
|
||||
static uint16_t cali_count = 0;
|
||||
if(cali_count >= 1000){
|
||||
ADCValueAVG = ADCValueSUM / cali_count;
|
||||
|
||||
InputNotify(NOTIFY_VOLT, ADCValueAVG);
|
||||
SendNotify();
|
||||
|
||||
uint8_t CIS_buf[9] = {0};
|
||||
CIS_buf[0] = INSTRUCTION.chip_id;
|
||||
CIS_buf[1] = (uint8_t) ((ADCValueAVG & 0xFF00) >> 8);
|
||||
CIS_buf[2] = (uint8_t) (ADCValueAVG & 0x00FF);
|
||||
CIS_buf[3] = 0x00;
|
||||
CIS_buf[4] = INSTRUCTION.VinADCGainLevel;
|
||||
SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, 9, CIS_buf);
|
||||
ADCValueSUM = 0;
|
||||
cali_count = 0;
|
||||
|
||||
PeriodicEvent = false;
|
||||
ModeLED(NO_EVENT);
|
||||
}else{
|
||||
cali_count++;
|
||||
ADCValueSUM = ADCValueSUM + CURRENT_MODE->_measureVin;
|
||||
InputNotify(NOTIFY_VOLT, CURRENT_MODE->_measureVin);
|
||||
InputNotify(NOTIFY_CURRENT, ADCValueSUM);
|
||||
InputNotify(NOTIFY_IMPEDANCE, (int32_t)cali_count);
|
||||
}
|
||||
|
||||
}
|
||||
ADCSwitch++;
|
||||
}
|
||||
else if(ADCSwitch == 1){ /**read v**/
|
||||
ReadADCVolt(CURRENT_MODE->_VoViSwitch);
|
||||
ADCSwitch++;
|
||||
}
|
||||
else if(ADCSwitch == 2){ /**read v**/
|
||||
ReadADCVolt(CURRENT_MODE->_VoViSwitch);
|
||||
ADCSwitch = 0;
|
||||
}
|
||||
|
||||
#undef CURRENT_MODE
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
+5
-5
@@ -4,12 +4,12 @@
|
||||
|
||||
#define VERSION_DATE_YEAR 20
|
||||
#define VERSION_DATE_MONTH 9
|
||||
#define VERSION_DATE_DAY 1
|
||||
#define VERSION_DATE_HOUR 16
|
||||
#define VERSION_DATE_MINUTE 34
|
||||
#define VERSION_DATE_DAY 7
|
||||
#define VERSION_DATE_HOUR 17
|
||||
#define VERSION_DATE_MINUTE 58
|
||||
|
||||
// this is NOT the version hash !!
|
||||
// it's the last version hash
|
||||
#define VERSION_HASH 595396f7a92da182e8bcfd3ab0b59693f7590e04
|
||||
#define VERSION_GIT_BRANCH Elite1.5_developement_EventHandle
|
||||
#define VERSION_HASH 8808490caa465cc94d14896de28763a5e5c4672b
|
||||
#define VERSION_GIT_BRANCH Elite_OBJ_0.2mv
|
||||
#endif
|
||||
|
||||
+205
-86
@@ -436,7 +436,8 @@ characteristic change event
|
||||
#define MINOR_PRODUCT_NUMBER 2 //1:Elite_legacy(Ori_Neulive) 2:Elite_zm 3:Elite_bat
|
||||
#define MAJOR_VERSION_NUMBER 1
|
||||
#define MINOR_VERSION_NUMBER 6
|
||||
#define ELITE_VERSION_1_4
|
||||
#define ELITE_VERSION_EIS
|
||||
//#define ELITE_VERSION_1_4
|
||||
//#define ELITE_VERSION_1_3
|
||||
|
||||
// buffer size
|
||||
@@ -481,7 +482,6 @@ struct _LH{
|
||||
uint8_t LoadState;
|
||||
} LH= {0};
|
||||
static void InitLH();
|
||||
static void Init_Elite15_PIN();
|
||||
|
||||
|
||||
static Clock_Struct periodicClock;
|
||||
@@ -571,16 +571,13 @@ static bool postWorkLedFlag = 0;
|
||||
static int32_t DecodeADCValue(uint8_t ADCGain, uint8_t ADCChannel, uint8_t *ADC_raw);
|
||||
static void headstage_battery_volt();
|
||||
static void EliteADCBattery();
|
||||
static void VinADCGainControl(uint8_t VinADCLevel);
|
||||
static void VoutGainControl(uint8_t VOUTLevel);
|
||||
static void PIN15_setOutputValue (uint32_t latch_num, uint32_t pin_num, bool highlow);
|
||||
//static void VinADCGainControl(uint8_t VinADCLevel);
|
||||
|
||||
// Elite key detection & turn on/ shutdown function (peripheral hardware control)
|
||||
static void Elite_led_color(uint16_t color);
|
||||
static void ModeLED(uint16_t modeStatus);
|
||||
//static void LED_color(uint8_t bright, uint8_t red, uint8_t green, uint8_t blue);
|
||||
static bool If10Von = false;
|
||||
static void TurnOn10V();
|
||||
|
||||
// periodic event control
|
||||
static void EliteADCControl();
|
||||
@@ -614,7 +611,6 @@ static void InitEliteFlag();
|
||||
#include "EliteDAC.h"
|
||||
#include "EliteSPI.h"
|
||||
#include "Elite_PIN.h"
|
||||
#include "Elite15_PIN.h"
|
||||
|
||||
#ifdef ELITE_VERSION_1_4
|
||||
#include "EliteI2C.h"
|
||||
@@ -645,7 +641,7 @@ static void InitEliteFlag();
|
||||
static void update_ZM_instruction(uint8 *ins) {
|
||||
uint8_t ins_type = ins[0] & 0b11110000;
|
||||
uint8_t chip_ID = ins[0] & 0b00001111;
|
||||
uint8_t oper = ins[1] & 0xF0; // this is don't care in RIS
|
||||
uint8_t oper = ins[1] & 0xFF; // this is don't care in RIS
|
||||
INSTRUCTION.chip_id = chip_ID;
|
||||
|
||||
switch (ins_type) {
|
||||
@@ -654,7 +650,6 @@ static void update_ZM_instruction(uint8 *ins) {
|
||||
switch (ins[2]) {
|
||||
case IV_CURVE: {
|
||||
ModeLED(WORKING);
|
||||
PIN15_setOutputValue(HIGH_Z_MODE, 1); // 1 => close high_z mode
|
||||
INSTRUCTION.eliteFxn = IV_CURVE;
|
||||
INSTRUCTION.sampleRate = 15;
|
||||
INSTRUCTION.Ve1 = ((uint16_t)(ins[3]) << 8) | (uint16_t)(ins[4]);
|
||||
@@ -676,7 +671,6 @@ static void update_ZM_instruction(uint8 *ins) {
|
||||
|
||||
case CV_CURVE: {
|
||||
ModeLED(WORKING);
|
||||
PIN15_setOutputValue(HIGH_Z_MODE, 1); // 1 => close high_z mode
|
||||
INSTRUCTION.eliteFxn = CV_CURVE;
|
||||
INSTRUCTION.sampleRate = 15;
|
||||
INSTRUCTION.Ve1 = ((uint16_t)(ins[3]) << 8) | (uint16_t)(ins[4]);
|
||||
@@ -698,15 +692,14 @@ static void update_ZM_instruction(uint8 *ins) {
|
||||
|
||||
case VOLT_OUTPUT: {
|
||||
ModeLED(WORKING);
|
||||
PIN15_setOutputValue(HIGH_Z_MODE, 1); // 1 => close high_z mode
|
||||
INSTRUCTION.eliteFxn = VOLT_OUTPUT;
|
||||
INSTRUCTION.VoltConstant = ( ((uint16_t)(ins[3])) << 8) | (uint16_t)(ins[4]);
|
||||
AutoGainChangeVout((int32_t)INSTRUCTION.VoltConstant);
|
||||
break;
|
||||
}
|
||||
|
||||
case ZT_CURVE: {
|
||||
ModeLED(WORKING);
|
||||
PIN15_setOutputValue(HIGH_Z_MODE, 1); // 1 => close high_z mode
|
||||
INSTRUCTION.eliteFxn = ZT_CURVE;
|
||||
INSTRUCTION.notifyRate = (uint32_t)INSTRUCTION.sampleRate;
|
||||
INSTRUCTION.sampleRate = 15;
|
||||
@@ -736,7 +729,6 @@ static void update_ZM_instruction(uint8 *ins) {
|
||||
|
||||
case CONSTANT_CURRENT:{
|
||||
ModeLED(WORKING);
|
||||
PIN15_setOutputValue(HIGH_Z_MODE, 1); // 1 => close high_z mode
|
||||
INSTRUCTION.eliteFxn = CONSTANT_CURRENT;
|
||||
INSTRUCTION.sampleRate = 15;
|
||||
INSTRUCTION.charge = ins[3]; //0:discharge 1:charge
|
||||
@@ -754,7 +746,6 @@ static void update_ZM_instruction(uint8 *ins) {
|
||||
}
|
||||
|
||||
case CYCLIC_VOLTAMMETRY: {
|
||||
PIN15_setOutputValue(HIGH_Z_MODE, 1); // 1 => close high_z mode
|
||||
if(ins[3] == PARA_1){
|
||||
INSTRUCTION.sampleRate = 15;
|
||||
INSTRUCTION.Vinit = ((int32_t)(ins[4]) << 8) | (int32_t)(ins[5]);
|
||||
@@ -785,7 +776,6 @@ static void update_ZM_instruction(uint8 *ins) {
|
||||
|
||||
case HIGH_CYCLE_CYCLIC_VOLTAMMETRY: {
|
||||
ModeLED(WORKING);
|
||||
PIN15_setOutputValue(HIGH_Z_MODE, 1); // 1 => close high_z mode
|
||||
INSTRUCTION.eliteFxn = CYCLIC_VOLTAMMETRY;
|
||||
INSTRUCTION.sampleRate = 15;
|
||||
INSTRUCTION.Vinit = ((int32_t)(ins[3]) << 8) | (int32_t)(ins[4]);
|
||||
@@ -812,7 +802,6 @@ static void update_ZM_instruction(uint8 *ins) {
|
||||
|
||||
case LINEAR_SWEEP_VOLTAMMETRY:{
|
||||
ModeLED(WORKING);
|
||||
PIN15_setOutputValue(HIGH_Z_MODE, 1); // 1 => close high_z mode
|
||||
INSTRUCTION.eliteFxn = LINEAR_SWEEP_VOLTAMMETRY;
|
||||
INSTRUCTION.sampleRate = 15;
|
||||
INSTRUCTION.Ve1 = ((uint16_t)(ins[3]) << 8) | (uint16_t)(ins[4]);
|
||||
@@ -835,7 +824,6 @@ static void update_ZM_instruction(uint8 *ins) {
|
||||
|
||||
case CONSTANT_VSCAN:{
|
||||
ModeLED(WORKING);
|
||||
PIN15_setOutputValue(HIGH_Z_MODE, 1); // 1 => close high_z mode
|
||||
INSTRUCTION.eliteFxn = CONSTANT_VSCAN;
|
||||
INSTRUCTION.sampleRate = 15;
|
||||
INSTRUCTION.Vinit = ((int32_t)(ins[3]) << 8) | (int32_t)(ins[4]);
|
||||
@@ -936,6 +924,7 @@ static void update_ZM_instruction(uint8 *ins) {
|
||||
}
|
||||
else{
|
||||
INSTRUCTION.AutoGainEnable = 1;
|
||||
INSTRUCTION.ADCGainLevel = I_GAIN_100R;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -946,30 +935,20 @@ static void update_ZM_instruction(uint8 *ins) {
|
||||
}
|
||||
else{
|
||||
INSTRUCTION.VinAutoGainEnable = 1;
|
||||
INSTRUCTION.VinADCGainLevel = VIN_GAIN_1K;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case VOUT_DAC :{
|
||||
// INSTRUCTION.VoutGainLevel = ins[4];
|
||||
// if(INSTRUCTION.VoutGainLevel == VOUT_GAIN_AUTO){
|
||||
// INSTRUCTION.VoutGainLevel = VOUT_GAIN_15K;
|
||||
// }
|
||||
INSTRUCTION.VoutGainLevel = ins[4];
|
||||
if(INSTRUCTION.VoutGainLevel != VOUT_GAIN_AUTO){
|
||||
INSTRUCTION.VoutAutoGainEnable = 0;
|
||||
}
|
||||
else{
|
||||
INSTRUCTION.VoutAutoGainEnable = 1;
|
||||
INSTRUCTION.VoutGainLevel = VOUT_GAIN_15K;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case HIGH_Z :{
|
||||
switch(ins[4]) {
|
||||
case 0x00 :{
|
||||
PIN15_setOutputValue(HIGH_Z_MODE, 0); // 0 => open high_z mode
|
||||
break;
|
||||
}
|
||||
case 0x01 :{
|
||||
PIN15_setOutputValue(HIGH_Z_MODE, 1); // 1 => close high_z mode
|
||||
break;
|
||||
}
|
||||
default :{
|
||||
break;
|
||||
}
|
||||
@@ -984,39 +963,32 @@ static void update_ZM_instruction(uint8 *ins) {
|
||||
}
|
||||
|
||||
case ADC_TEST: {
|
||||
ModeLED(WORKING);
|
||||
INSTRUCTION.eliteFxn = ADC_TEST;
|
||||
int32_t ADCRealValue = 0;
|
||||
// int32_t ADCRealValue = 0;
|
||||
uint8_t CIS_buf[9] = {0};
|
||||
uint16_t ADCValueAVG_RAW = 0;
|
||||
uint8_t ADC_input = 0;
|
||||
bool AVG_done = 0;
|
||||
|
||||
switch(ins[3]) {
|
||||
case IIN_ADC :{ // 0x00
|
||||
IinADCGainControl(ins[4]);
|
||||
// IinADCGainControl(ins[4]);
|
||||
AVG_done = 1;
|
||||
ADC_input = CMD_CURRENT_MEASURE;
|
||||
break;
|
||||
}
|
||||
case VIN_ADC :{ // 0x01
|
||||
VinADCGainControl(ins[4]);
|
||||
// VinADCGainControl(ins[4]);
|
||||
AVG_done = 1;
|
||||
ADC_input = CMD_VOLT_MEASURE;
|
||||
break;
|
||||
}
|
||||
case VOUT_DAC :{ // 0x02
|
||||
VoutGainControl(ins[4]);
|
||||
AVG_done = 0;
|
||||
break;
|
||||
}
|
||||
case HIGH_Z :{ // 0x03
|
||||
switch(ins[4]) {
|
||||
case 0x00 :{
|
||||
PIN15_setOutputValue(HIGH_Z_MODE, 0); // 0 => open high_z mode
|
||||
break;
|
||||
}
|
||||
case 0x01 :{
|
||||
PIN15_setOutputValue(HIGH_Z_MODE, 1); // 1 => close high_z mode
|
||||
break;
|
||||
}
|
||||
default :{
|
||||
break;
|
||||
}
|
||||
@@ -1031,51 +1003,204 @@ static void update_ZM_instruction(uint8 *ins) {
|
||||
}
|
||||
|
||||
if (AVG_done) {
|
||||
ADCValueAVG_RAW = ADC_CURRENT_AVG_calibration(ins[3]);
|
||||
CPUdelay(100);
|
||||
ADCValueAVG_RAW = ADC_CURRENT_AVG_calibration(ADC_input);
|
||||
} else {
|
||||
AVG_done = 0;
|
||||
}
|
||||
// ADCChannelSelect(ins[3]);
|
||||
// CPUdelay(10);
|
||||
// ADC_read(spi_ADC_rxbuf);
|
||||
|
||||
CIS_buf[0] = chip_ID;
|
||||
CIS_buf[1] = (uint8_t) ((ADCValueAVG_RAW & 0xFF00) >> 8);
|
||||
CIS_buf[2] = (uint8_t) (ADCValueAVG_RAW & 0x00FF);
|
||||
CIS_buf[3] = spi_ADC_rxbuf[2];
|
||||
CIS_buf[4] = spi_ADC_rxbuf[3];
|
||||
// for(int i=0; i<4 ; i++){
|
||||
// CIS_buf[i+1] = spi_ADC_rxbuf[i];
|
||||
// }
|
||||
|
||||
// decode ADC measure value
|
||||
ADCRealValue = DecodeADCValue(ins[4], ins[3], spi_ADC_rxbuf);
|
||||
|
||||
// test ADC output through CIS
|
||||
if (ins[3] == ADC_CH_VOLT) {
|
||||
// return ADC volt measure
|
||||
CIS_buf[5] = (uint8_t)(ADCRealValue >> 24);
|
||||
CIS_buf[6] = (uint8_t)((ADCRealValue & 0x00FF0000) >> 16);
|
||||
CIS_buf[7] = (uint8_t)((ADCRealValue & 0x0000FF00) >> 8);
|
||||
CIS_buf[8] = (uint8_t)(ADCRealValue & 0x000000FF);
|
||||
} else if (ins[3] == ADC_CH_CURRENT) {
|
||||
// return ADC current measure
|
||||
CIS_buf[5] = (uint8_t)(ADCRealValue >> 24);
|
||||
CIS_buf[6] = (uint8_t)((ADCRealValue & 0x00FF0000) >> 16);
|
||||
CIS_buf[7] = (uint8_t)((ADCRealValue & 0x0000FF00) >> 8);
|
||||
CIS_buf[8] = (uint8_t)(ADCRealValue & 0x000000FF);
|
||||
} else {
|
||||
// CIS = 0xFF...FF using as an error report
|
||||
for (int i = 1; i < 9; i++) {
|
||||
CIS_buf[i + 1] = 0xFF;
|
||||
CIS_buf[i + 1] = 0x00;
|
||||
}
|
||||
}
|
||||
|
||||
CIS_buf[0] = chip_ID;
|
||||
CIS_buf[1] = (uint8_t) ((ADCValueAVG_RAW & 0xFF00) >> 8);
|
||||
CIS_buf[2] = (uint8_t) (ADCValueAVG_RAW & 0x00FF);
|
||||
CIS_buf[3] = spi_ADC_rxbuf[2];
|
||||
CIS_buf[4] = spi_ADC_rxbuf[3];
|
||||
|
||||
// decode ADC measure value
|
||||
// ADCRealValue = DecodeADCValue(ins[4], ins[3], spi_ADC_rxbuf);
|
||||
|
||||
// test ADC output through CIS
|
||||
// if (ins[3] == ADC_CH_VOLT) {
|
||||
// // return ADC volt measure
|
||||
// CIS_buf[5] = (uint8_t)(ADCRealValue >> 24);
|
||||
// CIS_buf[6] = (uint8_t)((ADCRealValue & 0x00FF0000) >> 16);
|
||||
// CIS_buf[7] = (uint8_t)((ADCRealValue & 0x0000FF00) >> 8);
|
||||
// CIS_buf[8] = (uint8_t)(ADCRealValue & 0x000000FF);
|
||||
// } else if (ins[3] == ADC_CH_CURRENT) {
|
||||
// // return ADC current measure
|
||||
// CIS_buf[5] = (uint8_t)(ADCRealValue >> 24);
|
||||
// CIS_buf[6] = (uint8_t)((ADCRealValue & 0x00FF0000) >> 16);
|
||||
// CIS_buf[7] = (uint8_t)((ADCRealValue & 0x0000FF00) >> 8);
|
||||
// CIS_buf[8] = (uint8_t)(ADCRealValue & 0x000000FF);
|
||||
// } else {
|
||||
// // CIS = 0xFF...FF using as an error report
|
||||
// for (int i = 1; i < 9; i++) {
|
||||
// CIS_buf[i + 1] = 0xFF;
|
||||
// }
|
||||
// }
|
||||
|
||||
SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, 9, CIS_buf);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case CALI_DAC_MODE: {
|
||||
ModeLED(WORKING);
|
||||
INSTRUCTION.eliteFxn = CALI_DAC_MODE;
|
||||
INSTRUCTION.VoltConstant = ( ((uint16_t)(ins[3])) << 8) | (uint16_t)(ins[4]);
|
||||
break;
|
||||
}
|
||||
|
||||
case CALI_ADC_MODE: {
|
||||
switch(ins[3]) {
|
||||
case IIN_ADC :{ // 0x00
|
||||
INSTRUCTION.eliteFxn = CALI_ADC_MODE;
|
||||
INSTRUCTION.AdcChannel = IIN_ADC;
|
||||
INSTRUCTION.notifyRate = 1000;
|
||||
INSTRUCTION.sampleRate = 15;
|
||||
INSTRUCTION.VoViSwitch = 0x01;
|
||||
ModeLED(WORKING);
|
||||
break;
|
||||
}
|
||||
case VIN_ADC :{ // 0x01
|
||||
INSTRUCTION.eliteFxn = CALI_ADC_MODE;
|
||||
INSTRUCTION.AdcChannel = VIN_ADC;
|
||||
INSTRUCTION.notifyRate = 1000;
|
||||
INSTRUCTION.sampleRate = 15;
|
||||
INSTRUCTION.VoViSwitch = 0x01;
|
||||
ModeLED(WORKING);
|
||||
break;
|
||||
}
|
||||
default :{
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case DEV_MODE: { // INS_TYPE_RIS:0x30, DEV_MODE:0xFFF
|
||||
switch (ins[3]) {
|
||||
case CTL_WRT: { // ble write: 0x3000FF 20FFFFFFFFFFFF
|
||||
uint32_t address = ((uint16_t)(ins[4]) << 8) | (uint16_t)(ins[5]);
|
||||
uint32_t data = ((uint16_t)(ins[6]) << 24) | (uint16_t)(ins[7]) << 16 |
|
||||
(uint16_t)(ins[8]) << 8 | (uint16_t)(ins[9]);
|
||||
|
||||
select_REG(address);
|
||||
w32_REG(data);
|
||||
|
||||
initCISBuf();
|
||||
cis_buf[0] = (uint8_t)((address & 0x0000FF00) >> 8);
|
||||
cis_buf[1] = (uint8_t)(address & 0x000000FF);
|
||||
cis_buf[2] = (uint8_t)((data & 0xFF000000) >> 24);
|
||||
cis_buf[3] = (uint8_t)((data & 0x00FF0000) >> 16);
|
||||
cis_buf[4] = (uint8_t)((data & 0x0000FF00) >> 8);
|
||||
cis_buf[5] = (uint8_t)(data & 0x000000FF);
|
||||
SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, BLE_CIS_BUFF_SIZE, cis_buf);
|
||||
break;
|
||||
}
|
||||
|
||||
case CTL_RD: { // ble write: 0x3000FF 21FFFF
|
||||
|
||||
uint32_t address = ((uint16_t)(ins[4]) << 8) | (uint16_t)(ins[5]);
|
||||
select_REG(address);
|
||||
r32_REG();
|
||||
|
||||
initCISBuf();
|
||||
cis_buf[0] = (uint8_t)((address & 0x0000FF00) >> 8);
|
||||
cis_buf[1] = (uint8_t)(address & 0x000000FF);
|
||||
cis_buf[2] = spi_rxbuf[2];
|
||||
cis_buf[3] = spi_rxbuf[3];
|
||||
cis_buf[4] = spi_rxbuf[4];
|
||||
cis_buf[5] = spi_rxbuf[5];
|
||||
SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, BLE_CIS_BUFF_SIZE, cis_buf);
|
||||
break;
|
||||
}
|
||||
|
||||
case CTL_RD_DFTR: { // ble write: 0x3000FF 78FFFFFFFF
|
||||
select_REG(0x2078);
|
||||
r32_REG();
|
||||
|
||||
initCISBuf();
|
||||
cis_buf[0] = (uint8_t)(0x20);
|
||||
cis_buf[1] = (uint8_t)(0x78);
|
||||
cis_buf[2] = spi_rxbuf[2];
|
||||
cis_buf[3] = spi_rxbuf[3];
|
||||
cis_buf[4] = spi_rxbuf[4];
|
||||
cis_buf[5] = spi_rxbuf[5];
|
||||
SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, BLE_CIS_BUFF_SIZE, cis_buf);
|
||||
break;
|
||||
}
|
||||
|
||||
case CTL_RD_DFTI: { // ble write: 0x3000FF 7CFFFFFFFF
|
||||
select_REG(0x207C);
|
||||
r32_REG();
|
||||
|
||||
initCISBuf();
|
||||
cis_buf[0] = (uint8_t)(0x20);
|
||||
cis_buf[1] = (uint8_t)(0x7C);
|
||||
cis_buf[2] = spi_rxbuf[2];
|
||||
cis_buf[3] = spi_rxbuf[3];
|
||||
cis_buf[4] = spi_rxbuf[4];
|
||||
cis_buf[5] = spi_rxbuf[5];
|
||||
SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, BLE_CIS_BUFF_SIZE, cis_buf);
|
||||
break;
|
||||
}
|
||||
|
||||
case CTL_WRT_WGAMPL: { // ble write: 0x3000FF 3CFFFFFFFF | write waveform generator amplitude
|
||||
uint32_t data = ((uint16_t)(ins[4]) << 24) | (uint16_t)(ins[5]) << 16 | (uint16_t)(ins[6]) << 8 | (uint16_t)(ins[7]);
|
||||
|
||||
select_REG(0x2014);
|
||||
w32_REG(0x0); // 0x0: DC disable ac first
|
||||
|
||||
select_REG(0x203C);
|
||||
w32_REG(data);
|
||||
|
||||
initCISBuf();
|
||||
cis_buf[0] = (uint8_t)(0x20);
|
||||
cis_buf[1] = (uint8_t)(0x3C);
|
||||
cis_buf[2] = (uint8_t)((data & 0xFF000000) >> 24);
|
||||
cis_buf[3] = (uint8_t)((data & 0x00FF0000) >> 16);
|
||||
cis_buf[4] = (uint8_t)((data & 0x0000FF00) >> 8);
|
||||
cis_buf[5] = (uint8_t)(data & 0x000000FF);
|
||||
SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, BLE_CIS_BUFF_SIZE, cis_buf);
|
||||
|
||||
select_REG(0x2014);
|
||||
w32_REG(0x4); //0x4: Sinusoid
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x01: { // ble write: 0x3000FF 01
|
||||
if (ins[4] == 1) {
|
||||
Elite_led_color(COLOR_RED); //0101
|
||||
} else if (ins[4] == 2){
|
||||
Elite_led_color(COLOR_ORANGE); //0102
|
||||
} else if (ins[4] == 3){
|
||||
Elite_led_color(COLOR_YELLOW);
|
||||
} else if (ins[4] == 4){
|
||||
Elite_led_color(COLOR_GREEN);
|
||||
} else if (ins[4] == 5){
|
||||
Elite_led_color(COLOR_BLUE);
|
||||
} else if (ins[4] == 6){
|
||||
Elite_led_color(COLOR_MAGENTA);
|
||||
} else if (ins[4] == 7){
|
||||
Elite_led_color(COLOR_PURPLE);
|
||||
}
|
||||
|
||||
initCISBuf();
|
||||
cis_buf[0] = (uint8_t)(0x11);
|
||||
cis_buf[1] = (uint8_t)(0xFF);
|
||||
cis_buf[2] = ins[4];
|
||||
SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, BLE_CIS_BUFF_SIZE, cis_buf);
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default: {
|
||||
/** **/
|
||||
break;
|
||||
@@ -1107,7 +1232,6 @@ static void update_ZM_instruction(uint8 *ins) {
|
||||
}
|
||||
PeriodicEvent = true;
|
||||
InitEliteFlag();
|
||||
ELITE15_SPI_HOLD();
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1117,10 +1241,6 @@ static void update_ZM_instruction(uint8 *ins) {
|
||||
}
|
||||
|
||||
case VIS_INT: {
|
||||
if(PeriodicEvent){
|
||||
ELITE15_SPI_CLOSE();
|
||||
}
|
||||
|
||||
Eliteinterrupt();
|
||||
for(int i=0 ; i<12 ; i++){
|
||||
FlushNotify();
|
||||
@@ -1154,7 +1274,6 @@ static void update_ZM_instruction(uint8 *ins) {
|
||||
|
||||
case VIS_CC_ZERO:{
|
||||
ModeLED(PRE_WORK);
|
||||
PIN15_setOutputValue(HIGH_Z_MODE, 1); // 1 => close high_z mode
|
||||
INSTRUCTION.eliteFxn = CONSTANT_CURRENT;
|
||||
INSTRUCTION.sampleRate = 15;
|
||||
INSTRUCTION.charge = 0x01;
|
||||
@@ -1176,7 +1295,7 @@ static void update_ZM_instruction(uint8 *ins) {
|
||||
case INS_TYPE_CIS: {
|
||||
switch (oper) {
|
||||
case 0x00: {
|
||||
I2CWrite(0x01, 0xAB);
|
||||
// I2CWrite(0x01, 0xAB);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
+23
-24
@@ -33,8 +33,7 @@ static void SimpleBLEPeripheral_clockHandler(UArg arg) {
|
||||
|
||||
}
|
||||
static void elite_gptimer_callback(GPTimerCC26XX_Handle handle, GPTimerCC26XX_IntMask interruptMask) {
|
||||
// events |= SBP_PERIODIC_EVT;
|
||||
// events |= EVT_KEY_DETECT;
|
||||
events |= SBP_PERIODIC_EVT;
|
||||
Semaphore_post(semaphore);
|
||||
GPT.GptimerCounter++;
|
||||
}
|
||||
@@ -47,24 +46,12 @@ static void ZM_init() {
|
||||
|
||||
// initialize
|
||||
pin_handle = PIN_open(&ZM_rst, BLE_IO);
|
||||
Init_Elite15_PIN();
|
||||
|
||||
PIN15_setOutputValue(shutdown_6994, 1); // OFF = 1 => turn off 6994
|
||||
PIN15_setOutputValue(enable_10v, 0); // enable 10V
|
||||
|
||||
PIN15_setOutputValue(ADC_CS, 1); // ADC_CS HIGH
|
||||
PIN15_setOutputValue(DAC_CS, 1); // DAC_CS HIGH
|
||||
PIN15_setOutputValue(MEM_CS, 1); // MEM_CS HIGH
|
||||
PIN15_setOutputValue(HIGH_Z_MODE, 0); // HIGH Z MODE
|
||||
PIN_setOutputValue(pin_handle, AD_CS, 1); // AD_CS HIGH
|
||||
|
||||
InitEliteInstruction();
|
||||
IinADCGainControl(INSTRUCTION.ADCGainLevel);
|
||||
VinADCGainControl(INSTRUCTION.VinADCGainLevel);
|
||||
VoutGainControl(INSTRUCTION.VoutGainLevel);
|
||||
elite_gptimer_open();
|
||||
|
||||
// PIN_registerIntCb(pin_handle, switch_on_callback);
|
||||
// PIN_setInterrupt(pin_handle, switch_on | PIN_IRQ_POSEDGE);
|
||||
elite_gptimer_open();
|
||||
}
|
||||
|
||||
static void ZM_update_instruction_callback(uint8_t ins_type, uint8_t chip_ID, uint8_t *ins) {}
|
||||
@@ -89,7 +76,8 @@ static void DACCode2Real2Notify(uint16_t DACcode) {
|
||||
(INSTRUCTION.eliteFxn == CONSTANT_CURRENT) || \
|
||||
(INSTRUCTION.eliteFxn == CYCLIC_VOLTAMMETRY) || \
|
||||
(INSTRUCTION.eliteFxn == LINEAR_SWEEP_VOLTAMMETRY) || \
|
||||
(INSTRUCTION.eliteFxn == CONSTANT_VSCAN) \
|
||||
(INSTRUCTION.eliteFxn == CONSTANT_VSCAN) || \
|
||||
(INSTRUCTION.eliteFxn == CALI_ADC_MODE) \
|
||||
)
|
||||
|
||||
#define Ve1MatchVe2Mode() ( \
|
||||
@@ -122,14 +110,12 @@ static void SimpleBLEPeripheral_performPeriodicTask(WorkMode *WorkModeData) {
|
||||
EliteWorkReset = false;
|
||||
batteryADC_flag = false;
|
||||
record_flag = true;
|
||||
VinADCGainControl(INSTRUCTION.VinADCGainLevel);
|
||||
IinADCGainControl(INSTRUCTION.ADCGainLevel);
|
||||
VoutGainControl(INSTRUCTION.VoutGainLevel);
|
||||
// VinADCGainControl(INSTRUCTION.VinADCGainLevel);
|
||||
// IinADCGainControl(INSTRUCTION.ADCGainLevel);
|
||||
if( Ve1MatchVe2Mode() ){
|
||||
if (INSTRUCTION.Ve1 == INSTRUCTION.Ve2) {
|
||||
DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoutGainLevel, INSTRUCTION.Ve1));
|
||||
PeriodicEvent = false;
|
||||
ELITE15_SPI_CLOSE();
|
||||
ModeLED(NO_EVENT);
|
||||
}
|
||||
}
|
||||
@@ -174,7 +160,7 @@ static void SimpleBLEPeripheral_performPeriodicTask(WorkMode *WorkModeData) {
|
||||
|
||||
uint16_t bat = ((uint16_t)(NotifyVoltBat[2]) << 8 & 0xFF00 ) | ((uint16_t)(NotifyVoltBat[3]) & 0x00FF);
|
||||
if( bat < 768 && bat > 20){
|
||||
PIN15_setOutputValue(enable_5v, 0);
|
||||
PIN_setOutputValue(pin_handle, enable_5v, 0);
|
||||
}
|
||||
|
||||
//ADC counter
|
||||
@@ -209,8 +195,12 @@ static void SimpleBLEPeripheral_performPeriodicTask(WorkMode *WorkModeData) {
|
||||
DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoutGainLevel, WorkModeData->VO->_Vset)); //UserCode -> DAC code -> DAC out
|
||||
FreeWorkMode(WorkModeData);
|
||||
PeriodicEvent = false;
|
||||
ELITE15_SPI_CLOSE();
|
||||
}else{
|
||||
}else if(INSTRUCTION.eliteFxn == CALI_DAC_MODE){
|
||||
DAC_outputV(INSTRUCTION.VoltConstant); //UserCode -> DAC code -> DAC out
|
||||
FreeWorkMode(WorkModeData);
|
||||
PeriodicEvent = false;
|
||||
}
|
||||
else{
|
||||
InitFlag();
|
||||
}
|
||||
}
|
||||
@@ -253,6 +243,15 @@ static void EliteADCControl(WorkMode *WorkModeData) {
|
||||
CC_Plot(WorkModeData);
|
||||
break;
|
||||
}
|
||||
case CALI_ADC_MODE:{
|
||||
if(INSTRUCTION.AdcChannel == IIN_ADC){
|
||||
cali_IT_plot(WorkModeData);
|
||||
}else if(INSTRUCTION.AdcChannel == VIN_ADC){
|
||||
cali_VT_plot(WorkModeData);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
default:{
|
||||
break;
|
||||
}
|
||||
|
||||
+27
-32
@@ -174,10 +174,10 @@
|
||||
#ifndef RTOSPARA
|
||||
#define RTOSPARA
|
||||
#define SBP_STATE_CHANGE_EVT 0x0001
|
||||
#define SBP_CHAR_CHANGE_EVT 0x0002
|
||||
#define SBP_PERIODIC_EVT 0x0004
|
||||
#define SBP_CHAR_CHANGE_EVT 0x0002
|
||||
#define SBP_PERIODIC_EVT 0x0004
|
||||
#define SBP_CONN_EVT_END_EVT 0x0008
|
||||
#define SBP_KEY_CHANGE_EVT 0x0010
|
||||
#define SBP_KEY_CHANGE_EVT 0x0010
|
||||
#endif
|
||||
|
||||
// data length extension parameter
|
||||
@@ -548,7 +548,6 @@ static void SimpleBLEPeripheral_taskFxn(UArg a0, UArg a1) {
|
||||
SimpleBLEPeripheral_init();
|
||||
|
||||
ZM_init();
|
||||
// Elite_SPI_init();
|
||||
WorkMode *WorkModeData = CreateWorkMode();
|
||||
|
||||
uint8_t key = 0;
|
||||
@@ -556,13 +555,13 @@ static void SimpleBLEPeripheral_taskFxn(UArg a0, UArg a1) {
|
||||
bool EliteOn = 0;
|
||||
|
||||
// init DAC, set output ~= 0 V
|
||||
DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoutGainLevel, 25000));
|
||||
// DAC_outputV(25000);
|
||||
elite_gptimer_start();
|
||||
|
||||
// Application main loops
|
||||
GPT.GptimerCounter0 = GPT.GptimerCounter;
|
||||
batteryADC_flag = false;
|
||||
headstage_battery_volt();
|
||||
// headstage_battery_volt();
|
||||
headstage_init_device_info();
|
||||
|
||||
for (;;) {
|
||||
@@ -620,42 +619,38 @@ static void SimpleBLEPeripheral_taskFxn(UArg a0, UArg a1) {
|
||||
if (counter6994 < CLOCK_ONE_SECOND/2) { // counter6994 enable a IC after 35 counts
|
||||
counter6994++;
|
||||
} else if (counter6994 == CLOCK_ONE_SECOND/2) {
|
||||
PIN15_setOutputValue(shutdown_6994, 1); // OFF = 1 => turn off 6994
|
||||
counter6994++;
|
||||
}
|
||||
EliteKeyPress(key);
|
||||
if(key != 0){ //detect Elite battery power when no periodic event
|
||||
measureBat();
|
||||
}
|
||||
if(Free_Work_Mode){
|
||||
FreeWorkMode(WorkModeData);
|
||||
InitEliteInstruction();
|
||||
IinADCGainControl(INSTRUCTION.ADCGainLevel);
|
||||
DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoutGainLevel, INSTRUCTION.VoltConstant));
|
||||
|
||||
Free_Work_Mode = false;
|
||||
}
|
||||
// if(key != 0){ //detect Elite battery power when no periodic event
|
||||
// measureBat();
|
||||
// }
|
||||
// if(Free_Work_Mode){
|
||||
// FreeWorkMode(WorkModeData);
|
||||
// InitEliteInstruction();
|
||||
//// IinADCGainControl(INSTRUCTION.ADCGainLevel);
|
||||
// DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoutGainLevel, INSTRUCTION.VoltConstant));
|
||||
//
|
||||
// Free_Work_Mode = false;
|
||||
// }
|
||||
} else {
|
||||
EliteOn = TurnOnElite(key);
|
||||
}
|
||||
}
|
||||
else { // if there is periodic event
|
||||
if(InitPeriodicEvent){
|
||||
InitWorkMode(WorkModeData);
|
||||
InitPeriodicEvent = false;
|
||||
}
|
||||
|
||||
// Perform periodic application task
|
||||
SimpleBLEPeripheral_performPeriodicTask(WorkModeData);
|
||||
key = PIN_getInputValue(switch_on);
|
||||
EliteKeyPress(key); // onPress=> key = 0; 1.lighten LED 2.long press shut down 2650
|
||||
}
|
||||
// else { // if there is periodic event
|
||||
// if(InitPeriodicEvent){
|
||||
// InitWorkMode(WorkModeData);
|
||||
// InitPeriodicEvent = false;
|
||||
// }
|
||||
//
|
||||
// // Perform periodic application task
|
||||
// SimpleBLEPeripheral_performPeriodicTask(WorkModeData);
|
||||
// key = PIN_getInputValue(switch_on);
|
||||
// EliteKeyPress(key); // onPress=> key = 0; 1.lighten LED 2.long press shut down 2650
|
||||
// }
|
||||
}
|
||||
|
||||
// if(elite_event > 0){
|
||||
// elite_event_handle(WorkModeData);
|
||||
// }
|
||||
|
||||
#ifdef FEATURE_OAD
|
||||
while (!Queue_empty(hOadQ)) {
|
||||
oadTargetWrite_t *oadWriteEvt = Queue_get(hOadQ);
|
||||
|
||||
Reference in New Issue
Block a user