From 80929a01a8a0e6eed1dd4f5c15bfa57ee45c729d Mon Sep 17 00:00:00 2001 From: ROY Date: Wed, 28 Sep 2022 14:52:24 +0800 Subject: [PATCH] [update] update cali value --- .../cc26xx/app/headstage/EliteADC.h | 10 -- .../cc26xx/app/headstage/Elite_version.h | 6 +- .../cc26xx/app/headstage/eis_cali_cis.h | 138 ++++++++++++++++++ .../cc26xx/app/headstage/headstage.h | 43 +++++- 4 files changed, 181 insertions(+), 16 deletions(-) diff --git a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteADC.h b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteADC.h index e59af33..2de2147 100644 --- a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteADC.h +++ b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteADC.h @@ -273,16 +273,6 @@ static uint32_t ReadSINC2() { return AD5940_SPIReadReg(0x2080); } -static uint32_t ReadFreq() { - static uint64_t freqDAC; - static uint32_t ret; - // select_REG_RRR(WGFCW); - freqDAC = AD5940_SPIReadReg(WGFCW); - ret = User2Freq(freqDAC); //freeDAC * 16M / 2^30 - - return ret; //this gives the freq in mHz -} - /* for Elite1.5-re */ // Iin theoretical boundary <2.67, 1.89~80, 63~2600, >1900 (uA) #define I_GAIN_SMALL_BOUNDARY 4000 // 4 uA = 4,000,000 pA diff --git a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/Elite_version.h b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/Elite_version.h index faedac3..3f5ef6f 100644 --- a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/Elite_version.h +++ b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/Elite_version.h @@ -4,9 +4,9 @@ #define VERSION_DATE_YEAR 22 #define VERSION_DATE_MONTH 9 -#define VERSION_DATE_DAY 19 -#define VERSION_DATE_HOUR 17 -#define VERSION_DATE_MINUTE 16 +#define VERSION_DATE_DAY 28 +#define VERSION_DATE_HOUR 14 +#define VERSION_DATE_MINUTE 52 // this is NOT the version hash !! // it's the last version hash diff --git a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/eis_cali_cis.h b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/eis_cali_cis.h index ef7310a..a24eec8 100644 --- a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/eis_cali_cis.h +++ b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/eis_cali_cis.h @@ -188,3 +188,141 @@ static void SendCaliValue6(void) { SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, index, cali_buf); } + +static void SendCaliValue7(void) { + uint8_t cali_buf[BLE_CIS_BUFF_SIZE]; + + uint8_t filter_number1 = 2, index = 2; + + cali_buf[1] = instru.chip_id; + + for (int i = 0; i < filter_number1 ; i++) { + cali_buf[index++] = (uint8_t) (CaliTable.Ft[i][1].Phase_coeff >> 24)& 0xFF; + cali_buf[index++] = (uint8_t) (CaliTable.Ft[i][1].Phase_coeff >> 16) & 0xFF; + cali_buf[index++] = (uint8_t) (CaliTable.Ft[i][1].Phase_coeff >> 8)& 0xFF; + cali_buf[index++] = (uint8_t) CaliTable.Ft[i][1].Phase_coeff & 0xFF; + cali_buf[index++] = (uint8_t) (CaliTable.Ft[i][1].Phase_offset >> 24)& 0xFF; + cali_buf[index++] = (uint8_t) (CaliTable.Ft[i][1].Phase_offset >> 16) & 0xFF; + cali_buf[index++] = (uint8_t) (CaliTable.Ft[i][1].Phase_offset >> 8) & 0xFF; + cali_buf[index++] = (uint8_t) CaliTable.Ft[i][1].Phase_offset & 0xFF; + } + + cali_buf[0] = index - 1; + + SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, 20, cali_buf); +} + +static void SendCaliValue8(void) { + uint8_t cali_buf[BLE_CIS_BUFF_SIZE]; + + uint8_t filter_number1 = 2, filter_number2 = 4, index = 2; + + cali_buf[1] = instru.chip_id; + + for (int i = filter_number1; i < filter_number2 ; i++) { + cali_buf[index++] = (uint8_t) (CaliTable.Ft[i][1].Phase_coeff >> 24)& 0xFF; + cali_buf[index++] = (uint8_t) (CaliTable.Ft[i][1].Phase_coeff >> 16) & 0xFF; + cali_buf[index++] = (uint8_t) (CaliTable.Ft[i][1].Phase_coeff >> 8)& 0xFF; + cali_buf[index++] = (uint8_t) CaliTable.Ft[i][1].Phase_coeff & 0xFF; + cali_buf[index++] = (uint8_t) (CaliTable.Ft[i][1].Phase_offset >> 24)& 0xFF; + cali_buf[index++] = (uint8_t) (CaliTable.Ft[i][1].Phase_offset >> 16) & 0xFF; + cali_buf[index++] = (uint8_t) (CaliTable.Ft[i][1].Phase_offset >> 8) & 0xFF; + cali_buf[index++] = (uint8_t) CaliTable.Ft[i][1].Phase_offset & 0xFF; + } + + cali_buf[0] = index - 1; + + SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, index, cali_buf); +} + +static void SendCaliValue9(void) { + uint8_t cali_buf[BLE_CIS_BUFF_SIZE]; + + uint8_t filter_number1 = 2, index = 2; + + cali_buf[1] = instru.chip_id; + + for (int i = 0; i < filter_number1 ; i++) { + cali_buf[index++] = (uint8_t) (CaliTable.Ft[i][2].Phase_coeff >> 24)& 0xFF; + cali_buf[index++] = (uint8_t) (CaliTable.Ft[i][2].Phase_coeff >> 16) & 0xFF; + cali_buf[index++] = (uint8_t) (CaliTable.Ft[i][2].Phase_coeff >> 8)& 0xFF; + cali_buf[index++] = (uint8_t) CaliTable.Ft[i][2].Phase_coeff & 0xFF; + cali_buf[index++] = (uint8_t) (CaliTable.Ft[i][2].Phase_offset >> 24)& 0xFF; + cali_buf[index++] = (uint8_t) (CaliTable.Ft[i][2].Phase_offset >> 16) & 0xFF; + cali_buf[index++] = (uint8_t) (CaliTable.Ft[i][2].Phase_offset >> 8) & 0xFF; + cali_buf[index++] = (uint8_t) CaliTable.Ft[i][2].Phase_offset & 0xFF; + } + + cali_buf[0] = index - 1; + + SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, 20, cali_buf); +} + +static void SendCaliValue10(void) { + uint8_t cali_buf[BLE_CIS_BUFF_SIZE]; + + uint8_t filter_number1 = 2, filter_number2 = 4, index = 2; + + cali_buf[1] = instru.chip_id; + + for (int i = filter_number1; i < filter_number2 ; i++) { + cali_buf[index++] = (uint8_t) (CaliTable.Ft[i][2].Phase_coeff >> 24)& 0xFF; + cali_buf[index++] = (uint8_t) (CaliTable.Ft[i][2].Phase_coeff >> 16) & 0xFF; + cali_buf[index++] = (uint8_t) (CaliTable.Ft[i][2].Phase_coeff >> 8)& 0xFF; + cali_buf[index++] = (uint8_t) CaliTable.Ft[i][2].Phase_coeff & 0xFF; + cali_buf[index++] = (uint8_t) (CaliTable.Ft[i][2].Phase_offset >> 24)& 0xFF; + cali_buf[index++] = (uint8_t) (CaliTable.Ft[i][2].Phase_offset >> 16) & 0xFF; + cali_buf[index++] = (uint8_t) (CaliTable.Ft[i][2].Phase_offset >> 8) & 0xFF; + cali_buf[index++] = (uint8_t) CaliTable.Ft[i][2].Phase_offset & 0xFF; + } + + cali_buf[0] = index - 1; + + SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, index, cali_buf); +} + +static void SendCaliValue11(void) { + uint8_t cali_buf[BLE_CIS_BUFF_SIZE]; + + uint8_t filter_number1 = 2, index = 2; + + cali_buf[1] = instru.chip_id; + + for (int i = 0; i < filter_number1 ; i++) { + cali_buf[index++] = (uint8_t) (CaliTable.Ft[i][3].Phase_coeff >> 24)& 0xFF; + cali_buf[index++] = (uint8_t) (CaliTable.Ft[i][3].Phase_coeff >> 16) & 0xFF; + cali_buf[index++] = (uint8_t) (CaliTable.Ft[i][3].Phase_coeff >> 8)& 0xFF; + cali_buf[index++] = (uint8_t) CaliTable.Ft[i][3].Phase_coeff & 0xFF; + cali_buf[index++] = (uint8_t) (CaliTable.Ft[i][3].Phase_offset >> 24)& 0xFF; + cali_buf[index++] = (uint8_t) (CaliTable.Ft[i][3].Phase_offset >> 16) & 0xFF; + cali_buf[index++] = (uint8_t) (CaliTable.Ft[i][3].Phase_offset >> 8) & 0xFF; + cali_buf[index++] = (uint8_t) CaliTable.Ft[i][3].Phase_offset & 0xFF; + } + + cali_buf[0] = index - 1; + + SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, 20, cali_buf); +} + +static void SendCaliValue12(void) { + uint8_t cali_buf[BLE_CIS_BUFF_SIZE]; + + uint8_t filter_number1 = 2, filter_number2 = 4, index = 2; + + cali_buf[1] = instru.chip_id; + + for (int i = filter_number1; i < filter_number2 ; i++) { + cali_buf[index++] = (uint8_t) (CaliTable.Ft[i][3].Phase_coeff >> 24)& 0xFF; + cali_buf[index++] = (uint8_t) (CaliTable.Ft[i][3].Phase_coeff >> 16) & 0xFF; + cali_buf[index++] = (uint8_t) (CaliTable.Ft[i][3].Phase_coeff >> 8)& 0xFF; + cali_buf[index++] = (uint8_t) CaliTable.Ft[i][3].Phase_coeff & 0xFF; + cali_buf[index++] = (uint8_t) (CaliTable.Ft[i][3].Phase_offset >> 24)& 0xFF; + cali_buf[index++] = (uint8_t) (CaliTable.Ft[i][3].Phase_offset >> 16) & 0xFF; + cali_buf[index++] = (uint8_t) (CaliTable.Ft[i][3].Phase_offset >> 8) & 0xFF; + cali_buf[index++] = (uint8_t) CaliTable.Ft[i][3].Phase_offset & 0xFF; + } + + cali_buf[0] = index - 1; + + SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, index, cali_buf); +} \ No newline at end of file diff --git a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/headstage.h b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/headstage.h index 1196689..23eeee4 100644 --- a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/headstage.h +++ b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/headstage.h @@ -304,6 +304,22 @@ static void update_ZM_instruction(uint8 *ins) { case 0xFF: { // 0x3000FF DEV_MODE switch (ins[3]) { + // case 0x13: { //HIGH_Z + // SetEISHIGHZ(ins[4]); //0:open highz, CE0 no output + // break; + // } + + // case 0x14: { + // instru.Vinit = ((int32_t)(ins[4]) << 8) | (int32_t)(ins[5]); //37500 + // setEIS_CV(); + // SetEISHIGHZ(0); //0:open highz, CE0 no output + // led_color_set(LED_NB_MAX, LED_BR_LV1, LED_CLR_BLUE); + // break; + // } + // case 0x15: { + // AD5940_SPIWriteReg(ADCCON, 0x00010221); //PGA = 1.5 | LPTIA- | LPTIA_OUT + // break; + // } case 0x01: { // headstage_battery_volt(); @@ -406,6 +422,7 @@ static void update_ZM_instruction(uint8 *ins) { case CTL_RESET: { //UI write: 11 AD5940_HWReset(); AD5940_Initialize(); + led_color_set(LED_NB_MAX, LED_BR_LV1, LED_CLR_GREEN); break; } @@ -499,9 +516,17 @@ static void update_ZM_instruction(uint8 *ins) { instru.dcbias = (uint16_t)(ins[4]) << 8 | (uint16_t)(ins[5]); instru.acamp = (uint16_t)(ins[6]) << 8 | (uint16_t)(ins[7]); instru.fset = (uint32_t)(ins[8]) << 24 | (uint32_t)(ins[9]) << 16 | (uint32_t)(ins[10]) << 8 | (uint32_t)(ins[11]); - setEIS_EIS(); - freq_out(); - led_color_set(LED_NB_MAX, LED_BR_LV1, LED_CLR_PURPLE); + + uint8_t use_cali = ins[12]; + if (use_cali == 0) { + setEIS_EIS_cali(); + DAC_outputF(instru.fset); + led_color_set(LED_NB_MAX, LED_BR_LV1, LED_CLR_PURPLE); + } else { + setEIS_EIS(); + DAC_outputF(instru.fset); + led_color_set(LED_NB_MAX, LED_BR_LV1, LED_CLR_BLUE); + } break; } } @@ -614,6 +639,18 @@ static void update_ZM_instruction(uint8 *ins) { SendCaliValue5(); } else if (ins[2] == 6) { SendCaliValue6(); + } else if (ins[2] == 7) { + SendCaliValue7(); + } else if (ins[2] == 8) { + SendCaliValue8(); + } else if (ins[2] == 9) { + SendCaliValue9(); + } else if (ins[2] == 10) { + SendCaliValue10(); + } else if (ins[2] == 11) { + SendCaliValue11(); + } else if (ins[2] == 12) { + SendCaliValue12(); } break; }