Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9e2c1373f1 | |||
| ab5926a933 | |||
| ba29ac9418 | |||
| 6754c4b9e8 |
@@ -60,7 +60,6 @@ extern "C" {
|
||||
#define Board_initGPIO()
|
||||
#define Board_initPWM() PWM_init()
|
||||
#define Board_initSPI() SPI_init()
|
||||
#define Board_initI2C() I2C_init()
|
||||
#define Board_initUART() UART_init()
|
||||
#define Board_initWatchdog() Watchdog_init()
|
||||
#define GPIO_toggle(n)
|
||||
|
||||
+29
-103
@@ -6,29 +6,19 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
*
|
||||
* product number: MAJOR_PRODUCT_NUMBER, MINOR_PRODUCT_NUMBER, MAJOR_VERSION_NUMBER, MINOR_VERSION_NUMBER
|
||||
* MAJOR_PRODUCT_NUMBER -> 0:Elite, 1:other serial
|
||||
* Elite:
|
||||
* MINOR_PRODUCT_NUMBER -> 1:legacy, 2:EDC, 3:BAT, 4:EIS, 5:TRIG, 6:MEGAFLY
|
||||
*
|
||||
* +------------------------+----------------------+-------------------------+----------------+----------------------+----------------------+----------+
|
||||
* | model name | hw upper board | hw lower board | product number | device name | data server lib name | UI |
|
||||
* +------------------------+----------------------+-------------------------+----------------+----------------------+----------------------+----------+
|
||||
* | DEF_ELITE_EDC_1_4 | Elite1.4-re Jun.2019 | Elite1.4-re Jun. 2019 | 0, 2, 1, 5 | "Elite-EDC" | Elite_EDC_1.4 | null |
|
||||
* | DEF_ELITE_EDC_1_5 | Elite1.5 Dec. 2019 | Elite1.5 Dec. 2019 | 0, 2, 1, 6 | "Elite-EDC" | Elite_EDC_1.5 | EliteEDC |
|
||||
* | DEF_ELITE_EDC_1_5_RE | Elite1.5 Dec. 2019 | Elite1.5-re Jan. 2021 | 0, 2, 1, 7 | "Elite-EDC" | Elite_EDC_1.5re | EliteEDC |
|
||||
* | DEF_ELITE_EDC_1_5_R2 | Elite1.5 Dec. 2019 | Elite1.5-r2 May. 2022 | 0, 2, 1, 8 | "Elite-EDC" | Elite_EDC_1.5r2 | EliteEDC |
|
||||
* | DEF_ELITE_BAT_1_0 | Elite2.0 Feb. 2022 | 0, 3, 1, 0 | "Elite-BAT" | Elite_BAT_1.0 | EliteEDC |
|
||||
* | DEF_ELITE_EIS_1_0 | Elite1.5 Dec. 2019 | Elite EIS1.0 Aug. 2020 | 0, 4, 1, 0 | "Elite-EIS" | Elite_EIS_1.0 | EliteEIS |
|
||||
* | DEF_ELITE_EIS_1_1 | Elite1.5 Dec. 2019 | Elite EIS1.1 Feb. 2022 | 0, 4, 1, 1 | "Elite-EIS" | Elite_EIS_1.1 | EliteEIS |
|
||||
* | DEF_ELITE_EIS_MINI_1_0 | EIS MINI May. 2022 | 0, 4, 1, 2 | "Elite-EIS-MINI" | Elite_EIS_MINI_1.0 | EliteEIS |
|
||||
* | DEF_ELITE_TRIG_0_1 | Elite TRIG01 Jan. 2021 | 0, 5, 1, 0 | "Elite-TRIG" | Elite_TRIG_0.1 | null |
|
||||
* | DEF_ELITE_MEGAFLY_0_1 | Elite1.5 Dec. 2019 | Elite Megafly Sep. 2020 | 0, 6, 1, 0 | "Elite-MEGAFLY" | Elite_MEGAFLY_0.1 | null |
|
||||
* +------------------------+----------------------+-------------------------+----------------+----------------------+----------------------+----------+
|
||||
* ps.
|
||||
* model name is FW engineer defined
|
||||
* device name is used for controller
|
||||
* +---------------+----------------------+-------------------------+
|
||||
* | model name | upper board | lower board |
|
||||
* +---------------+----------------------+-------------------------+
|
||||
* | EDC1.4 | Elite1.4-re Jun.2019 | Elite1.4-re Jun. 2019 |<- DEF_ELITE_EDC_1_4
|
||||
* | EDC1.5 | Elite1.5 Dec. 2019 | Elite1.5 Dec. 2019 |<- DEF_ELITE_EDC_1_5
|
||||
* | EDC1.5re | Elite1.5 Dec. 2019 | Elite1.5-re Jan. 2021 |<- DEF_ELITE_EDC_1_5_RE
|
||||
* | EDC1.5r2 | Elite1.5 Dec. 2019 | Elite1.5 - r2 May. 2022 |<- DEF_ELITE_EDC_1_5_R2
|
||||
* | EIS1.0 | Elite1.5 Dec. 2019 | Elite EIS 1.0 Aug. 2020 |<- DEF_ELITE_EIS_1_0
|
||||
* | EIS1.1 | Elite1.5 Dec. 2019 | Elite EIS 1.1 Feb. 2022 |<- DEF_ELITE_EIS_1_1
|
||||
* | BAT1.0 | Elite2.0 Feb. 2022 |<- DEF_ELITE_BAT_1_0
|
||||
* | MEGAFLY0.1 | ? | ? |<- DEF_ELITE_MEGAFLY_0_1
|
||||
* | TRIG0.1 | Elite TRIG01 Jan. 2021 |<- DEF_ELITE_TRIG_0_1
|
||||
* +---------------+----------------------+-------------------------+
|
||||
*/
|
||||
|
||||
|
||||
@@ -36,13 +26,13 @@ extern "C" {
|
||||
#define DEF_ELITE_EDC_1_5 1
|
||||
#define DEF_ELITE_EDC_1_5_RE 2
|
||||
#define DEF_ELITE_EDC_1_5_R2 3
|
||||
#define DEF_ELITE_BAT_1_0 4
|
||||
#define DEF_ELITE_EIS_1_0 5
|
||||
#define DEF_ELITE_EIS_1_1 6
|
||||
#define DEF_ELITE_EIS_MINI_1_0 7
|
||||
#define DEF_ELITE_EIS_1_0 4
|
||||
#define DEF_ELITE_EIS_1_1 5
|
||||
#define DEF_ELITE_BAT_1_0 6
|
||||
#define DEF_ELITE_MEGAFLY_0_1 7
|
||||
#define DEF_ELITE_TRIG_0_1 8
|
||||
#define DEF_ELITE_MEGAFLY_0_1 9
|
||||
#define DEF_ELITE_MAX 10
|
||||
#define DEF_ELITE_MAX 9
|
||||
|
||||
|
||||
#define DEF_ELITE_MODEL DEF_ELITE_EDC_1_5_RE
|
||||
#ifndef DEF_ELITE_MODEL
|
||||
@@ -50,89 +40,25 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
#if (DEF_ELITE_MODEL == DEF_ELITE_EDC_1_4)
|
||||
#error "code no support" // need fix
|
||||
#error "code no support" // need fix
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EDC_1_5)
|
||||
#error "code no support" // need fix
|
||||
#error "code no support" // need fix
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EDC_1_5_RE)
|
||||
#include "boards_config/pin_def_edc15re.h"
|
||||
#include "boards_config/pin_def_edc15re.h"
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EDC_1_5_R2)
|
||||
#error "code no support" // need fix
|
||||
#error "code no support" // need fix
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EIS_1_0)
|
||||
#error "code no support" // need fix
|
||||
#error "code no support" // need fix
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EIS_1_1)
|
||||
#include "boards_config/pin_def_eis11.h"
|
||||
#include "boards_config/pin_def_eis11.h"
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_BAT_1_0)
|
||||
#error "code no support" // need fix
|
||||
#error "code no support" // need fix
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_MEGAFLY_0_1)
|
||||
#error "code no support" // need fix
|
||||
#error "code no support" // need fix
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_TRIG_0_1)
|
||||
#error "code no support" // need fix
|
||||
#error "code no support" // need fix
|
||||
#else
|
||||
#error "no this model"
|
||||
#endif
|
||||
|
||||
|
||||
// model information
|
||||
#if (DEF_ELITE_MODEL == DEF_ELITE_EDC_1_4)
|
||||
#define DEVICE_NAME "Elite-EDC"
|
||||
#define MAJOR_PRODUCT_NUMBER 0
|
||||
#define MINOR_PRODUCT_NUMBER 2
|
||||
#define MAJOR_VERSION_NUMBER 1
|
||||
#define MINOR_VERSION_NUMBER 5
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EDC_1_5)
|
||||
#define DEVICE_NAME "Elite-EDC"
|
||||
#define MAJOR_PRODUCT_NUMBER 0
|
||||
#define MINOR_PRODUCT_NUMBER 2
|
||||
#define MAJOR_VERSION_NUMBER 1
|
||||
#define MINOR_VERSION_NUMBER 6
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EDC_1_5_RE)
|
||||
#define DEVICE_NAME "Elite-EDC"
|
||||
#define MAJOR_PRODUCT_NUMBER 0
|
||||
#define MINOR_PRODUCT_NUMBER 2
|
||||
#define MAJOR_VERSION_NUMBER 1
|
||||
#define MINOR_VERSION_NUMBER 7
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EDC_1_5_R2)
|
||||
#define DEVICE_NAME "Elite-EDC"
|
||||
#define MAJOR_PRODUCT_NUMBER 0
|
||||
#define MINOR_PRODUCT_NUMBER 2
|
||||
#define MAJOR_VERSION_NUMBER 1
|
||||
#define MINOR_VERSION_NUMBER 8
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_BAT_1_0)
|
||||
#define DEVICE_NAME "Elite-BAT"
|
||||
#define MAJOR_PRODUCT_NUMBER 0
|
||||
#define MINOR_PRODUCT_NUMBER 3
|
||||
#define MAJOR_VERSION_NUMBER 1
|
||||
#define MINOR_VERSION_NUMBER 0
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EIS_1_0)
|
||||
#define DEVICE_NAME "Elite-EIS"
|
||||
#define MAJOR_PRODUCT_NUMBER 0
|
||||
#define MINOR_PRODUCT_NUMBER 4
|
||||
#define MAJOR_VERSION_NUMBER 1
|
||||
#define MINOR_VERSION_NUMBER 0
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EIS_1_1)
|
||||
#define DEVICE_NAME "Elite-EIS"
|
||||
#define MAJOR_PRODUCT_NUMBER 0
|
||||
#define MINOR_PRODUCT_NUMBER 4
|
||||
#define MAJOR_VERSION_NUMBER 1
|
||||
#define MINOR_VERSION_NUMBER 1
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EIS_MINI_1_0)
|
||||
#define DEVICE_NAME "Elite-EIS"
|
||||
#define MAJOR_PRODUCT_NUMBER 0
|
||||
#define MINOR_PRODUCT_NUMBER 4
|
||||
#define MAJOR_VERSION_NUMBER 1
|
||||
#define MINOR_VERSION_NUMBER 2
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_TRIG_0_1)
|
||||
#define DEVICE_NAME "Elite-TRIG"
|
||||
#define MAJOR_PRODUCT_NUMBER 0
|
||||
#define MINOR_PRODUCT_NUMBER 5
|
||||
#define MAJOR_VERSION_NUMBER 1
|
||||
#define MINOR_VERSION_NUMBER 0
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_MEGAFLY_0_1)
|
||||
#define DEVICE_NAME "Elite-MEGAFLY"
|
||||
#define MAJOR_PRODUCT_NUMBER 0
|
||||
#define MINOR_PRODUCT_NUMBER 6
|
||||
#define MAJOR_VERSION_NUMBER 1
|
||||
#define MINOR_VERSION_NUMBER 0
|
||||
#error "no this model"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
+5
@@ -5,8 +5,13 @@
|
||||
#include "driver/timers.h"
|
||||
#include "simple_peripheral.h"
|
||||
|
||||
#define EVT_PERIODIC_GPTIMER EVT_PERIODIC_0
|
||||
|
||||
static GPTimerCC26XX_Handle gptimer_handle; // was defined static
|
||||
|
||||
//#define elite_gptimer_start() GPTimerCC26XX_start(gptimer_handle)
|
||||
// #define elite_gptimer_stop() GPTimerCC26XX_stop(gptimer_handle)
|
||||
// #define elite_gptimer_close() GPTimerCC26XX_close(gptimer_handle)
|
||||
#define CLOCK_FREQ 4769 // clock freq = 0.1 ms(4800), Measured(4769)
|
||||
|
||||
static void elite_gptimer_callback(GPTimerCC26XX_Handle handle, GPTimerCC26XX_IntMask interruptMask) {
|
||||
|
||||
+2
@@ -44,6 +44,8 @@ extern "C" {
|
||||
#define E_LATCH_OFF LOAD2, D6
|
||||
#define E_LATCH_VOUT_SMALL_ON LOAD2, D7
|
||||
|
||||
#define HIGH_Z_OPEN() latch_single_ctrl(E_LATCH_HIGH_Z, 0);
|
||||
#define HIGH_Z_CLOSE() latch_single_ctrl(E_LATCH_HIGH_Z, 1);
|
||||
uint8_t update_latch_stat(uint8_t latch, uint8_t dio, uint8_t value);
|
||||
uint8_t latch_single_ctrl(uint8_t latch, uint8_t dio, uint8_t value);
|
||||
uint8_t latch_multi_ctrl(void);
|
||||
|
||||
+1
-1
@@ -9,8 +9,8 @@ extern "C" {
|
||||
|
||||
#define ADC_CH_CURR AIN0_GND
|
||||
#define ADC_CH_VIN AIN1_GND
|
||||
#define ADC_CH_VOUT AIN2_GND
|
||||
#define ADC_CH_BAT AIN3_GND
|
||||
#define ADC_CH_VOUT AIN2_GND
|
||||
|
||||
#define MEASURE_CURRENT() read_adc_data(ADC_CH_CURR, FSR3)
|
||||
#define MEASURE_VOLT() read_adc_data(ADC_CH_VIN, FSR3)
|
||||
|
||||
+9
@@ -4,12 +4,15 @@
|
||||
#define LED_SERIES_D_START 0x00000000
|
||||
#define LED_SERIES_D_END 0xFFFFFFFF
|
||||
|
||||
|
||||
// struct of led_series_data defined
|
||||
struct led_series_data_t {
|
||||
uint32_t f_start;
|
||||
struct led_frame_t f_led[LED_TANDEM_N];
|
||||
uint32_t f_end;
|
||||
};
|
||||
|
||||
|
||||
static struct led_series_data_t led_series_data_g = {0};
|
||||
|
||||
const struct led_color_t led_color_list_g[LED_CLR_MAX] = {
|
||||
@@ -28,6 +31,8 @@ const struct led_color_t led_color_list_g[LED_CLR_MAX] = {
|
||||
{0x78, 0xC8, 0x50}, // LED_CLR_EMERALD
|
||||
};
|
||||
|
||||
|
||||
/*led_single_set*/
|
||||
static int __led_single_set(struct led_series_data_t *led_s_d, struct led_frame_t *led_f, enum led_series_nb_e led_nb)
|
||||
{
|
||||
struct led_series_data_t *sd = led_s_d;
|
||||
@@ -39,6 +44,8 @@ static int __led_single_set(struct led_series_data_t *led_s_d, struct led_frame_
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*led _multiple_set*/
|
||||
static int __led_multiple_set(struct led_series_data_t *led_s_d, struct led_frame_t *led_f)
|
||||
{
|
||||
struct led_series_data_t *sd = led_s_d;
|
||||
@@ -55,6 +62,8 @@ static int __led_multiple_set(struct led_series_data_t *led_s_d, struct led_fram
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*led_complete*/
|
||||
static int __led_complete(struct led_series_data_t *led_s_d)
|
||||
{
|
||||
struct led_series_data_t *sd = led_s_d;
|
||||
|
||||
+179
@@ -0,0 +1,179 @@
|
||||
{
|
||||
"name": "Elite-ZM",
|
||||
"version": "1.2.30",
|
||||
"match_rule": {
|
||||
"local_name_pattern": "Elite-ZM.+",
|
||||
"major_product_number": 0,
|
||||
"minor_product_number": 2,
|
||||
"major_version_number": 1,
|
||||
"minor_version_number": 2
|
||||
},
|
||||
"constant": {
|
||||
"ADC_CHANNEL_NUMBER": [
|
||||
12,
|
||||
13,
|
||||
14,
|
||||
15
|
||||
],
|
||||
"VOLT_MAX": 4095
|
||||
},
|
||||
"parameters": {
|
||||
"CHANNEL": {
|
||||
"description": "record channels",
|
||||
"record_meta": true,
|
||||
"domain": "property",
|
||||
"value": [
|
||||
0,
|
||||
1,
|
||||
2
|
||||
]
|
||||
},
|
||||
"SAMPLE_RATE": {
|
||||
"description": "data sampling rate",
|
||||
"record_meta": true,
|
||||
"domain": "constant",
|
||||
"value": 1
|
||||
},
|
||||
"AMP_GAIN": {
|
||||
"description": "amp gain",
|
||||
"record_meta": true,
|
||||
"domain": "constant",
|
||||
"value": 1
|
||||
},
|
||||
"MODE": {
|
||||
"description": "working mode",
|
||||
"value": [
|
||||
"I-V Curve",
|
||||
"Cyclic Voltammetry",
|
||||
"Function Generator",
|
||||
"Z-T Curve",
|
||||
"V-T Curve",
|
||||
"I-T Curve",
|
||||
"ADC test"
|
||||
]
|
||||
},
|
||||
"VOLT_ORIGIN": {
|
||||
"description": "Origin Voltage of Scan",
|
||||
"domain": [
|
||||
"VOLT_MAX"
|
||||
]
|
||||
},
|
||||
"VOLT_FINAL": {
|
||||
"description": "The last Voltage of Scan",
|
||||
"domain": [
|
||||
"VOLT_MAX"
|
||||
],
|
||||
"value": "1365 * VALUE"
|
||||
},
|
||||
"VOLT_STEP": {
|
||||
"description": "Voltage Step",
|
||||
"domain": [
|
||||
5
|
||||
]
|
||||
},
|
||||
"STEP_TIME": {
|
||||
"description": "How much time between two step",
|
||||
"domain": [
|
||||
4
|
||||
]
|
||||
},
|
||||
"DAC_VOLT": {
|
||||
"description": "DAC output Voltage",
|
||||
"domain": [
|
||||
"VOLT_MAX"
|
||||
]
|
||||
},
|
||||
"ADC_CHANNEL": {
|
||||
"description": "read ADC data",
|
||||
"value": [
|
||||
"ANA0",
|
||||
"ANA1",
|
||||
"ANA2",
|
||||
"ANA3"
|
||||
]
|
||||
}
|
||||
},
|
||||
"instruction": {
|
||||
"start": [
|
||||
{
|
||||
"expression": "MODE",
|
||||
"when": {
|
||||
"0": "curve_iv",
|
||||
"1": "curve_cv",
|
||||
"2": "func_gen",
|
||||
"6": "adc_test"
|
||||
}
|
||||
}
|
||||
],
|
||||
"data_format": [
|
||||
"_data_format('TDC4VAF2')"
|
||||
],
|
||||
"curve_iv": [
|
||||
"data_format",
|
||||
"_notify(True)",
|
||||
"curve_iv0",
|
||||
"_sync(True)",
|
||||
"VIS_STI"
|
||||
],
|
||||
"curve_iv0": {
|
||||
"type": "RIS",
|
||||
"parameter": {
|
||||
"va": "(VOLT_ORIGIN + 1) * 0x0010",
|
||||
"vb": "(VOLT_FINAL + 1) * 0x0010",
|
||||
"dv": "VOLT_STEP * 0x40",
|
||||
"dt": "STEP_TIME * 0x12"
|
||||
},
|
||||
"data": [
|
||||
"1X10;2B>va;2B>vb;B>dv;B>dt"
|
||||
]
|
||||
},
|
||||
"curve_cv": [
|
||||
"data_format",
|
||||
"_notify(True)",
|
||||
"curve_cv0",
|
||||
"_sync(True)",
|
||||
"VIS_STI"
|
||||
],
|
||||
"curve_cv0": {
|
||||
"type": "RIS",
|
||||
"parameter": {
|
||||
"va": "(VOLT_ORIGIN + 1) * 0x0010",
|
||||
"vb": "(VOLT_FINAL + 1) * 0x0010",
|
||||
"dv": "VOLT_STEP * 0x40",
|
||||
"dt": "STEP_TIME * 0x12"
|
||||
},
|
||||
"data": [
|
||||
"1X20;2B>va;2B>vb;B>dv;B>dt"
|
||||
]
|
||||
},
|
||||
"func_gen": [
|
||||
"data_format",
|
||||
"func_gen0",
|
||||
"VIS_STI"
|
||||
],
|
||||
"func_gen0": {
|
||||
"type": "RIS",
|
||||
"parameter": {
|
||||
"v": "(DAC_VOLT + 1) * 0x0010"
|
||||
},
|
||||
"data": [
|
||||
"X30;X30;2B>v"
|
||||
]
|
||||
},
|
||||
"adc_test": [
|
||||
"data_format",
|
||||
"_notify(True)",
|
||||
"adc_test0",
|
||||
"_sync(True)",
|
||||
"VIS_STI"
|
||||
],
|
||||
"adc_test0": {
|
||||
"type": "RIS",
|
||||
"data": [
|
||||
"X90;B>ADC_CHANNEL"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+162
-107
@@ -16,7 +16,7 @@
|
||||
// Vin theoretical boundary <7, 5~200, >100 (mV)
|
||||
#define VIN_GAIN_SMALL_BOUNDARY 7000 // 7 mV = 7,000,000 nV
|
||||
#define VIN_GAIN_MID1_BOUNDARY1 5000 // 5 mV = 5,000,000 nV
|
||||
#define VIN_GAIN_MID1_BOUNDARY2 290000 // 290 mV = 290,000,000 nV
|
||||
#define VIN_GAIN_MID1_BOUNDARY2 300000 // 300 mV = 300,000,000 nV
|
||||
#define VIN_GAIN_LARGE_BOUNDARY 250000 // 250 mV = 250,000,000 nV
|
||||
|
||||
/*
|
||||
@@ -41,168 +41,182 @@ void AutoGainChangeVin(int32_t RealVin);
|
||||
= EliteADC.c =
|
||||
=============================================================================*/
|
||||
|
||||
static void __switch_lv0(uint8_t gain0_en, uint16_t plot, uint16_t *no_rec_cnt)
|
||||
|
||||
|
||||
static void __reset_i_gain_cnt(int16_t *I_100R_cnt, int16_t *I_3K_cnt, int16_t *I_100K_cnt, int16_t *I_3M_cnt)
|
||||
{
|
||||
static int16_t gain_cnt = 0;
|
||||
*I_3M_cnt = 0;
|
||||
*I_100K_cnt = 0;
|
||||
*I_3K_cnt = 0;
|
||||
*I_100R_cnt = 0;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void __switch_lv0(uint8_t gain0_en, uint16_t plot, int16_t *I_GAIN_3M_counter, uint16_t *no_rec_cnt)
|
||||
{
|
||||
int16_t *gain_cnt = I_GAIN_3M_counter;
|
||||
uint16_t *no_rec = no_rec_cnt;
|
||||
uint8_t gain_en = gain0_en;
|
||||
uint16_t pt = plot;
|
||||
|
||||
if (gain_en == 0)
|
||||
return;
|
||||
if (gain_en) {
|
||||
*gain_cnt += 1;
|
||||
|
||||
gain_cnt++;
|
||||
if (*gain_cnt > 2) {
|
||||
instru.IinADCGainLv = I_GAIN_3M;
|
||||
IinADCGainCtrl(instru.IinADCGainLv);
|
||||
*gain_cnt = 0;
|
||||
|
||||
if (gain_cnt > 2) {
|
||||
instru.IinADCGainLv = I_GAIN_3M;
|
||||
IinADCGainCtrl(instru.IinADCGainLv);
|
||||
gain_cnt = 0;
|
||||
if (pt == IIN_VIN_VOUT_PLOT) {
|
||||
*no_rec = CNT_H2L_IIN_VIN_VOUT_PLOT;
|
||||
|
||||
if (pt == IIN_VIN_VOUT_PLOT)
|
||||
*no_rec = CNT_H2L_IIN_VIN_VOUT_PLOT;
|
||||
} else if (pt == IIN_VIN_PLOT) {
|
||||
*no_rec = CNT_H2L_IIN_VIN_PLOT;
|
||||
|
||||
else if (pt == IIN_VIN_PLOT)
|
||||
*no_rec = CNT_H2L_IIN_VIN_PLOT;
|
||||
} else if (pt == IT_PLOT) {
|
||||
*no_rec = CNT_H2L_IT_PLOT;
|
||||
|
||||
else if (pt == IT_PLOT)
|
||||
*no_rec = CNT_H2L_IT_PLOT;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void __switch_lv3(uint8_t gain3_en, uint16_t plot, uint16_t *no_rec_cnt)
|
||||
static void __switch_lv3(uint8_t gain3_en, uint16_t plot, int16_t *I_GAIN_100R_counter, uint16_t *no_rec_cnt)
|
||||
{
|
||||
static int16_t gain_cnt = 0;
|
||||
int16_t *gain_cnt = I_GAIN_100R_counter;
|
||||
uint16_t *no_rec = no_rec_cnt;
|
||||
uint8_t gain_en = gain3_en;
|
||||
|
||||
if (gain_en == 0)
|
||||
return;
|
||||
if (gain_en) {
|
||||
*gain_cnt += 1;
|
||||
|
||||
gain_cnt++;
|
||||
if (gain_cnt > 2) {
|
||||
instru.IinADCGainLv = I_GAIN_100R;
|
||||
IinADCGainCtrl(instru.IinADCGainLv);
|
||||
gain_cnt = 0;
|
||||
*no_rec = 0;
|
||||
if (*gain_cnt > 2) {
|
||||
instru.IinADCGainLv = I_GAIN_100R;
|
||||
IinADCGainCtrl(instru.IinADCGainLv);
|
||||
*gain_cnt = 0;
|
||||
*no_rec = 0;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void __large_switch_lv1(uint8_t gain1_en, uint16_t plot, uint16_t *no_rec_cnt)
|
||||
static void __large_switch_lv1(uint8_t gain1_en, uint16_t plot, int16_t *I_GAIN_100K_counter, uint16_t *no_rec_cnt)
|
||||
{
|
||||
static int16_t gain_cnt = 0;
|
||||
int16_t *gain_cnt = I_GAIN_100K_counter;
|
||||
uint16_t *no_rec = no_rec_cnt;
|
||||
uint8_t gain_en = gain1_en;
|
||||
uint16_t pt = plot;
|
||||
|
||||
if (gain_en == 0)
|
||||
return;
|
||||
if (gain_en) {
|
||||
*gain_cnt += 1;
|
||||
|
||||
gain_cnt++;
|
||||
if (*gain_cnt > 2) {
|
||||
instru.IinADCGainLv = I_GAIN_100K;
|
||||
IinADCGainCtrl(instru.IinADCGainLv);
|
||||
*gain_cnt = 0;
|
||||
*no_rec = 0;
|
||||
|
||||
if (gain_cnt > 2) {
|
||||
instru.IinADCGainLv = I_GAIN_100K;
|
||||
IinADCGainCtrl(instru.IinADCGainLv);
|
||||
gain_cnt = 0;
|
||||
*no_rec = 0;
|
||||
if (pt == IIN_VIN_VOUT_PLOT) {
|
||||
*no_rec = CNT_H2L_IIN_VIN_VOUT_PLOT;
|
||||
|
||||
if (pt == IIN_VIN_VOUT_PLOT)
|
||||
*no_rec = CNT_H2L_IIN_VIN_VOUT_PLOT;
|
||||
} else if (pt == IIN_VIN_PLOT) {
|
||||
*no_rec = CNT_H2L_IIN_VIN_PLOT;
|
||||
|
||||
else if (pt == IIN_VIN_PLOT)
|
||||
*no_rec = CNT_H2L_IIN_VIN_PLOT;
|
||||
} else if (pt == IT_PLOT) {
|
||||
*no_rec = CNT_H2L_IT_PLOT;
|
||||
|
||||
else if (pt == IT_PLOT)
|
||||
*no_rec = CNT_H2L_IT_PLOT;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void __small_switch_lv1(uint8_t gain1_en, uint16_t plot, uint16_t *no_rec_cnt)
|
||||
static void __small_switch_lv1(uint8_t gain1_en, uint16_t plot, int16_t *I_GAIN_100K_counter, uint16_t *no_rec_cnt)
|
||||
{
|
||||
static int16_t gain_cnt = 0;
|
||||
int16_t *gain_cnt = I_GAIN_100K_counter;
|
||||
uint16_t *no_rec = no_rec_cnt;
|
||||
uint8_t gain_en = gain1_en;
|
||||
uint16_t pt = plot;
|
||||
|
||||
if (gain_en == 0)
|
||||
return;
|
||||
if (gain_en) {
|
||||
*gain_cnt += 1;
|
||||
|
||||
gain_cnt++;
|
||||
if (*gain_cnt > 2) {
|
||||
instru.IinADCGainLv = I_GAIN_100K;
|
||||
IinADCGainCtrl(instru.IinADCGainLv);
|
||||
*gain_cnt = 0;
|
||||
|
||||
if (gain_cnt > 2) {
|
||||
instru.IinADCGainLv = I_GAIN_100K;
|
||||
IinADCGainCtrl(instru.IinADCGainLv);
|
||||
gain_cnt = 0;
|
||||
if (pt == IIN_VIN_VOUT_PLOT) {
|
||||
*no_rec = CNT_L2H_IIN_VIN_VOUT_PLOT;
|
||||
|
||||
if (pt == IIN_VIN_VOUT_PLOT)
|
||||
*no_rec = CNT_L2H_IIN_VIN_VOUT_PLOT;
|
||||
} else if (pt == IIN_VIN_PLOT) {
|
||||
*no_rec = CNT_L2H_IIN_VIN_PLOT;
|
||||
|
||||
else if (pt == IIN_VIN_PLOT)
|
||||
*no_rec = CNT_L2H_IIN_VIN_PLOT;
|
||||
|
||||
else if (pt == IT_PLOT)
|
||||
*no_rec = CNT_L2H_IT_PLOT;
|
||||
} else if (pt == IT_PLOT) {
|
||||
*no_rec = CNT_L2H_IT_PLOT;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void __large_switch_lv2(uint8_t gain2_en, uint16_t plot, uint16_t *no_rec_cnt)
|
||||
static void __large_switch_lv2(uint8_t gain2_en, uint16_t plot, int16_t *I_GAIN_3K_counter, uint16_t *no_rec_cnt)
|
||||
{
|
||||
static int16_t gain_cnt = 0;
|
||||
int16_t *gain_cnt = I_GAIN_3K_counter;
|
||||
uint16_t *no_rec = no_rec_cnt;
|
||||
uint8_t gain_en = gain2_en;
|
||||
uint16_t pt = plot;
|
||||
|
||||
if (gain_en == 0)
|
||||
return;
|
||||
if (gain_en) {
|
||||
*gain_cnt += 1;
|
||||
|
||||
gain_cnt++;
|
||||
if (*gain_cnt > 2) {
|
||||
instru.IinADCGainLv = I_GAIN_3K;
|
||||
IinADCGainCtrl(instru.IinADCGainLv);
|
||||
*gain_cnt = 0;
|
||||
*no_rec = 0;
|
||||
|
||||
if (gain_cnt > 2) {
|
||||
instru.IinADCGainLv = I_GAIN_3K;
|
||||
IinADCGainCtrl(instru.IinADCGainLv);
|
||||
gain_cnt = 0;
|
||||
*no_rec = 0;
|
||||
if (pt == IIN_VIN_VOUT_PLOT) {
|
||||
*no_rec = CNT_H2L_IIN_VIN_VOUT_PLOT;
|
||||
|
||||
if (pt == IIN_VIN_VOUT_PLOT)
|
||||
*no_rec = CNT_H2L_IIN_VIN_VOUT_PLOT;
|
||||
} else if (pt == IIN_VIN_PLOT) {
|
||||
*no_rec = CNT_H2L_IIN_VIN_PLOT;
|
||||
|
||||
else if (pt == IIN_VIN_PLOT)
|
||||
*no_rec = CNT_H2L_IIN_VIN_PLOT;
|
||||
|
||||
else if (pt == IT_PLOT)
|
||||
*no_rec = CNT_H2L_IT_PLOT;
|
||||
} else if (pt == IT_PLOT) {
|
||||
*no_rec = CNT_H2L_IT_PLOT;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void __small_switch_lv2(uint8_t gain2_en, uint16_t plot, uint16_t *no_rec_cnt)
|
||||
static void __small_switch_lv2(uint8_t gain2_en, uint16_t plot, int16_t *I_GAIN_3K_counter, uint16_t *no_rec_cnt)
|
||||
{
|
||||
static int16_t gain_cnt = 0;
|
||||
int16_t *gain_cnt = I_GAIN_3K_counter;
|
||||
uint16_t *no_rec = no_rec_cnt;
|
||||
uint8_t gain_en = gain2_en;
|
||||
|
||||
if (gain_en == 0)
|
||||
return;
|
||||
if (gain_en) {
|
||||
*gain_cnt += 1;
|
||||
|
||||
gain_cnt++;
|
||||
if (*gain_cnt > 2) {
|
||||
instru.IinADCGainLv = I_GAIN_3K;
|
||||
IinADCGainCtrl(instru.IinADCGainLv);
|
||||
*gain_cnt = 0;
|
||||
*no_rec = 0;
|
||||
|
||||
if (gain_cnt > 2) {
|
||||
instru.IinADCGainLv = I_GAIN_3K;
|
||||
IinADCGainCtrl(instru.IinADCGainLv);
|
||||
gain_cnt = 0;
|
||||
*no_rec = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
@@ -210,8 +224,7 @@ static void __small_switch_lv2(uint8_t gain2_en, uint16_t plot, uint16_t *no_rec
|
||||
|
||||
void IinADCGainCtrl(uint8_t IinADCLevel)
|
||||
{
|
||||
if (IinADCLevel>= 4)
|
||||
return;
|
||||
|
||||
/* hardware need open before close, so don't change position*/
|
||||
if (IinADCLevel == 0) {
|
||||
// ADC gain level = 0, using 2M resister
|
||||
@@ -241,23 +254,35 @@ void IinADCGainCtrl(uint8_t IinADCLevel)
|
||||
update_latch_stat(E_LATCH_I_SMALL_ON, 0);
|
||||
latch_multi_ctrl();
|
||||
|
||||
} else if (IinADCLevel == 4) {
|
||||
// ADC gain level = 3, auto gain (using 200R resister)
|
||||
update_latch_stat(E_LATCH_I_LARGE_ON, 1); /* need open first */
|
||||
update_latch_stat(E_LATCH_I_MID_ON, 0);
|
||||
update_latch_stat(E_LATCH_I_SMALL_ON, 0);
|
||||
latch_multi_ctrl();
|
||||
|
||||
} else {
|
||||
// default using 100R resister
|
||||
update_latch_stat(E_LATCH_I_LARGE_ON, 1); /* need open first */
|
||||
update_latch_stat(E_LATCH_I_MID_ON, 0);
|
||||
update_latch_stat(E_LATCH_I_SMALL_ON, 0);
|
||||
latch_multi_ctrl();
|
||||
|
||||
}
|
||||
|
||||
if (IinADCLevel == 0 || IinADCLevel == 1 || IinADCLevel == 2 || IinADCLevel == 3) {
|
||||
lastIinADCGainLevel = IinADCLevel;
|
||||
|
||||
} else {
|
||||
lastIinADCGainLevel = 3;
|
||||
|
||||
}
|
||||
|
||||
curr_rec_en = false;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void VinADCGainCtrl(uint8_t VinADCLevel)
|
||||
{
|
||||
if (VinADCLevel >= 3)
|
||||
return;
|
||||
|
||||
{
|
||||
/* hardware need open before close, so don't change position*/
|
||||
if (VinADCLevel == 0) {
|
||||
// Vin ADC gain level = 0, using 1M resister
|
||||
@@ -277,14 +302,27 @@ void VinADCGainCtrl(uint8_t VinADCLevel)
|
||||
update_latch_stat(E_LATCH_V_MID_ON, 0);
|
||||
latch_multi_ctrl();
|
||||
|
||||
} else if (VinADCLevel == 3) {
|
||||
// Vin ADC gain level = 3, auto gain (using 1K resister)
|
||||
update_latch_stat(E_LATCH_V_SMALL_ON, 1); /* need open first */
|
||||
update_latch_stat(E_LATCH_V_MID_ON, 0);
|
||||
latch_multi_ctrl();
|
||||
|
||||
} else {
|
||||
// default using 1K resister
|
||||
update_latch_stat(E_LATCH_V_SMALL_ON, 1); /* need open first */
|
||||
update_latch_stat(E_LATCH_V_MID_ON, 0);
|
||||
latch_multi_ctrl();
|
||||
|
||||
}
|
||||
|
||||
if (VinADCLevel == 0 || VinADCLevel == 1 || VinADCLevel == 2) {
|
||||
lastVinADCGainLv = VinADCLevel;
|
||||
} else {
|
||||
lastVinADCGainLv = 2;
|
||||
}
|
||||
|
||||
volt_rec_en = false;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -303,6 +341,11 @@ void AutoGainChangeIin(int32_t RealCurrent, uint16_t plot_type, uint16_t *no_rec
|
||||
uint16_t plot = plot_type;
|
||||
uint16_t *skip_time = no_rec_time;
|
||||
|
||||
static int16_t I_100R_cnt = 0;
|
||||
static int16_t I_3K_cnt = 0;
|
||||
static int16_t I_100K_cnt = 0;
|
||||
static int16_t I_3M_cnt = 0;
|
||||
|
||||
int64_t small_gain = I_GAIN_SMALL_BOUNDARY;
|
||||
int64_t mid1_gain1 = I_GAIN_MID1_BOUNDARY1;
|
||||
int64_t mid1_gain2 = I_GAIN_MID1_BOUNDARY2;
|
||||
@@ -318,15 +361,18 @@ void AutoGainChangeIin(int32_t RealCurrent, uint16_t plot_type, uint16_t *no_rec
|
||||
if (instru.IinADCGainLv == I_GAIN_100R) {
|
||||
if (curr < large_gain && curr > -1 * large_gain) {
|
||||
if (curr < mid1_gain1 && curr > -1 * mid1_gain1) {
|
||||
__switch_lv0(gain0_en, plot, skip_time);
|
||||
__switch_lv0(gain0_en, plot, &I_3M_cnt, skip_time);
|
||||
|
||||
} else if (curr < mid2_gain1 && curr > -1 * mid2_gain1) {
|
||||
__large_switch_lv1(gain1_en, plot, skip_time);
|
||||
__large_switch_lv1(gain1_en, plot, &I_100K_cnt, skip_time);
|
||||
|
||||
} else {
|
||||
__large_switch_lv2(gain2_en, plot, skip_time);
|
||||
__large_switch_lv2(gain2_en, plot, &I_3K_cnt, skip_time);
|
||||
|
||||
}
|
||||
} else {
|
||||
__reset_i_gain_cnt(&I_100R_cnt, &I_3K_cnt, &I_100K_cnt, &I_3M_cnt);
|
||||
|
||||
}
|
||||
|
||||
return;
|
||||
@@ -334,16 +380,19 @@ void AutoGainChangeIin(int32_t RealCurrent, uint16_t plot_type, uint16_t *no_rec
|
||||
|
||||
if (instru.IinADCGainLv == I_GAIN_3K) {
|
||||
if (curr > mid2_gain2 || curr < -1 * mid2_gain2) {
|
||||
__switch_lv3(gain3_en, plot, skip_time);
|
||||
__switch_lv3(gain3_en, plot, &I_100R_cnt, skip_time);
|
||||
|
||||
} else if (curr < mid2_gain1 && curr > -1 * mid2_gain1) {
|
||||
if (curr < mid1_gain1 && curr > -1 * mid1_gain1) {
|
||||
__switch_lv0(gain0_en, plot, skip_time);
|
||||
__switch_lv0(gain0_en, plot, &I_3M_cnt, skip_time);
|
||||
|
||||
} else {
|
||||
__large_switch_lv1(gain1_en, plot, skip_time);
|
||||
__large_switch_lv1(gain1_en, plot, &I_100K_cnt, skip_time);
|
||||
|
||||
}
|
||||
} else {
|
||||
__reset_i_gain_cnt(&I_100R_cnt, &I_3K_cnt, &I_100K_cnt, &I_3M_cnt);
|
||||
|
||||
}
|
||||
|
||||
return;
|
||||
@@ -351,16 +400,19 @@ void AutoGainChangeIin(int32_t RealCurrent, uint16_t plot_type, uint16_t *no_rec
|
||||
|
||||
if (instru.IinADCGainLv == I_GAIN_100K) {
|
||||
if (curr < mid1_gain1 && curr > -1 * mid1_gain1) {
|
||||
__switch_lv0(gain0_en, plot, skip_time);
|
||||
__switch_lv0(gain0_en, plot, &I_3M_cnt, skip_time);
|
||||
|
||||
} else if (curr > mid1_gain2 || curr < -1 * mid1_gain2) {
|
||||
if (curr > mid2_gain2 || curr < -1 * mid2_gain2) {
|
||||
__switch_lv3(gain3_en, plot, skip_time);
|
||||
__switch_lv3(gain3_en, plot, &I_100R_cnt, skip_time);
|
||||
|
||||
} else {
|
||||
__small_switch_lv2(gain2_en, plot, skip_time);
|
||||
__small_switch_lv2(gain2_en, plot, &I_3K_cnt, skip_time);
|
||||
|
||||
}
|
||||
} else {
|
||||
__reset_i_gain_cnt(&I_100R_cnt, &I_3K_cnt, &I_100K_cnt, &I_3M_cnt);
|
||||
|
||||
}
|
||||
|
||||
return;
|
||||
@@ -369,15 +421,18 @@ void AutoGainChangeIin(int32_t RealCurrent, uint16_t plot_type, uint16_t *no_rec
|
||||
if (instru.IinADCGainLv == I_GAIN_3M) {
|
||||
if (curr > small_gain || curr < -1 * small_gain) {
|
||||
if (curr > mid2_gain2 || curr < -1 * mid2_gain2) {
|
||||
__switch_lv3(gain3_en, plot, skip_time);
|
||||
__switch_lv3(gain3_en, plot, &I_100R_cnt, skip_time);
|
||||
|
||||
} else if (curr > mid1_gain2 || curr < -1 * mid1_gain2) {
|
||||
__small_switch_lv2(gain2_en, plot, skip_time);
|
||||
__small_switch_lv2(gain2_en, plot, &I_3K_cnt, skip_time);
|
||||
|
||||
} else {
|
||||
__small_switch_lv1(gain1_en, plot, skip_time);
|
||||
__small_switch_lv1(gain1_en, plot, &I_100K_cnt, skip_time);
|
||||
|
||||
}
|
||||
} else {
|
||||
__reset_i_gain_cnt(&I_100R_cnt, &I_3K_cnt, &I_100K_cnt, &I_3M_cnt);
|
||||
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
+9
@@ -4,9 +4,11 @@
|
||||
|
||||
static bool DACReset;
|
||||
|
||||
#ifdef ELITE_VERSION_1_4
|
||||
#define DACCLS 0x02
|
||||
#define DACOUT 0x31
|
||||
|
||||
|
||||
static void VoutGainControl(uint8_t VOUTLevel){
|
||||
if(VOUTLevel == 0){
|
||||
// VOUT gain level = 0, using 240K resister
|
||||
@@ -27,6 +29,8 @@ static void VoutGainControl(uint8_t VOUTLevel){
|
||||
volt_rec_en = false;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static int32_t User2Real(uint16_t UserCode){
|
||||
/* transfer usercode to real voltage value (mV) */
|
||||
return (int32_t)((UserCode - 25000) / 5);
|
||||
@@ -44,6 +48,11 @@ static void AutoGainChangeVout(int32_t userCode){
|
||||
// switch to 1 level volt(small) 15K
|
||||
// switch to 2 level volt(large) 240K
|
||||
|
||||
if(instru.VoutGainLv == VOUT_GAIN_AUTO){
|
||||
instru.VoutGainLv = VOUT_GAIN_15K;
|
||||
VoutGainControl(instru.VoutGainLv);
|
||||
}
|
||||
|
||||
if(instru.VoutGainLv == VOUT_GAIN_15K){
|
||||
if(RealVolt > DAC_VOUT_GAIN_LARGE_BOUNDARY || RealVolt < -1 * DAC_VOUT_GAIN_LARGE_BOUNDARY){
|
||||
// switch to 2 level volt(large)
|
||||
|
||||
-170
@@ -2145,176 +2145,6 @@ struct correction_ctx_t Correction = {
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef BOARD_17 // R2
|
||||
struct correction_ctx_t Correction = {
|
||||
.ADC_volt[0].coeff = 6281,
|
||||
.ADC_volt[0].offset = (-102091135),
|
||||
|
||||
.ADC_volt[1].coeff = 215489,
|
||||
.ADC_volt[1].offset = (-3502773449),
|
||||
|
||||
.ADC_volt[2].coeff = 6284799,
|
||||
.ADC_volt[2].offset = (-102137567699),
|
||||
|
||||
.ADC_current[0].coeff = 3127489,
|
||||
.ADC_current[0].offset = (-50929238025),
|
||||
|
||||
.ADC_current[1].coeff = 72028152,
|
||||
.ADC_current[1].offset = (-1173190386421),
|
||||
|
||||
.ADC_current[2].coeff = 1462120904,
|
||||
.ADC_current[2].offset = (-23813658336317),
|
||||
|
||||
.ADC_current[3].coeff = 30772133023,
|
||||
.ADC_current[3].offset = (-501193399098681),
|
||||
|
||||
.Usercode2DAC[0].coeff = (-10525509),
|
||||
.Usercode2DAC[0].offset = 583168750255,
|
||||
|
||||
.Usercode2DAC[1].coeff = (-178502405),
|
||||
.Usercode2DAC[1].offset = 4783222906500,
|
||||
|
||||
.ADC_Vout_volt[0].coeff = (-6246238),
|
||||
.ADC_Vout_volt[0].offset = 101174300735,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef BOARD_18 // R2
|
||||
struct correction_ctx_t Correction = {
|
||||
.ADC_volt[0].coeff = 6307,
|
||||
.ADC_volt[0].offset = (-102227194),
|
||||
|
||||
.ADC_volt[1].coeff = 216350,
|
||||
.ADC_volt[1].offset = (-3510441794),
|
||||
|
||||
.ADC_volt[2].coeff = 6321158,
|
||||
.ADC_volt[2].offset = (-102545234591),
|
||||
|
||||
.ADC_current[0].coeff = 3127182,
|
||||
.ADC_current[0].offset = (-50985551728),
|
||||
|
||||
.ADC_current[1].coeff = 71761497,
|
||||
.ADC_current[1].offset = (-1170210907687),
|
||||
|
||||
.ADC_current[2].coeff = 1457926498,
|
||||
.ADC_current[2].offset = (-23773550048662),
|
||||
|
||||
.ADC_current[3].coeff = 30730387774,
|
||||
.ADC_current[3].offset = (-501134113778611),
|
||||
|
||||
.Usercode2DAC[0].coeff = (-10542537),
|
||||
.Usercode2DAC[0].offset = 582354584774,
|
||||
|
||||
.Usercode2DAC[1].coeff = (-178433148),
|
||||
.Usercode2DAC[1].offset = 4780251590552,
|
||||
|
||||
.ADC_Vout_volt[0].coeff = (-6245655),
|
||||
.ADC_Vout_volt[0].offset = 101405660400,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef BOARD_19 //R2
|
||||
struct correction_ctx_t Correction = {
|
||||
.ADC_volt[0].coeff = 6248,
|
||||
.ADC_volt[0].offset = (-101988256),
|
||||
|
||||
.ADC_volt[1].coeff = 215428,
|
||||
.ADC_volt[1].offset = (-3518184654),
|
||||
|
||||
.ADC_volt[2].coeff = 6267624,
|
||||
.ADC_volt[2].offset = (-102333798553),
|
||||
|
||||
.ADC_current[0].coeff = 3132332,
|
||||
.ADC_current[0].offset = (-50985538056),
|
||||
|
||||
.ADC_current[1].coeff = 71555053,
|
||||
.ADC_current[1].offset = (-1165030559094),
|
||||
|
||||
.ADC_current[2].coeff = 1464565286,
|
||||
.ADC_current[2].offset = (-23841501204443),
|
||||
|
||||
.ADC_current[3].coeff = 30827554942,
|
||||
.ADC_current[3].offset = (-501862954230438),
|
||||
|
||||
.Usercode2DAC[0].coeff = (-10508759),
|
||||
.Usercode2DAC[0].offset = 581937735033,
|
||||
|
||||
.Usercode2DAC[1].coeff = (-178323180),
|
||||
.Usercode2DAC[1].offset = 4777879424722,
|
||||
|
||||
.ADC_Vout_volt[0].coeff = (-6212067),
|
||||
.ADC_Vout_volt[0].offset = 101533593863,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef BOARD_20 //R2
|
||||
struct correction_ctx_t Correction = {
|
||||
.ADC_volt[0].coeff = 6223,
|
||||
.ADC_volt[0].offset = (-100772846),
|
||||
|
||||
.ADC_volt[1].coeff = 214243,
|
||||
.ADC_volt[1].offset = (-3474181335),
|
||||
|
||||
.ADC_volt[2].coeff = 6249611,
|
||||
.ADC_volt[2].offset = (-101316282249),
|
||||
|
||||
.ADC_current[0].coeff = 3120936,
|
||||
.ADC_current[0].offset = (-50668228961),
|
||||
|
||||
.ADC_current[1].coeff = 71902191,
|
||||
.ADC_current[1].offset = (-1167587543417),
|
||||
|
||||
.ADC_current[2].coeff = 1457439423,
|
||||
.ADC_current[2].offset = (-23664301410063),
|
||||
|
||||
.ADC_current[3].coeff = 30697477675,
|
||||
.ADC_current[3].offset = (-498485527107672),
|
||||
|
||||
.Usercode2DAC[0].coeff = (-10506483),
|
||||
.Usercode2DAC[0].offset = 579666250198,
|
||||
|
||||
.Usercode2DAC[1].coeff = (-178136809),
|
||||
.Usercode2DAC[1].offset = 4771066521917,
|
||||
|
||||
.ADC_Vout_volt[0].coeff = (-6279145),
|
||||
.ADC_Vout_volt[0].offset = 101443137473,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef BOARD_21
|
||||
struct correction_ctx_t Correction = {
|
||||
.ADC_volt[0].coeff = 6297,
|
||||
.ADC_volt[0].offset = (-102239918),
|
||||
|
||||
.ADC_volt[1].coeff = 215976,
|
||||
.ADC_volt[1].offset = (-3511853183),
|
||||
|
||||
.ADC_volt[2].coeff = 6301113,
|
||||
.ADC_volt[2].offset = (-102433011284),
|
||||
|
||||
.ADC_current[0].coeff = 3142822,
|
||||
.ADC_current[0].offset = (-51073945597),
|
||||
|
||||
.ADC_current[1].coeff = 71828674,
|
||||
.ADC_current[1].offset = (-1167357180875),
|
||||
|
||||
.ADC_current[2].coeff = 1464305335,
|
||||
.ADC_current[2].offset = (-23796552730288),
|
||||
|
||||
.ADC_current[3].coeff = 30691748879,
|
||||
.ADC_current[3].offset = (-498801800724347),
|
||||
|
||||
.Usercode2DAC[0].coeff = (-10538563),
|
||||
.Usercode2DAC[0].offset = 583007751105,
|
||||
|
||||
.Usercode2DAC[1].coeff = (-178520622),
|
||||
.Usercode2DAC[1].offset = 4783591915817,
|
||||
|
||||
.ADC_Vout_volt[0].coeff = (-6245655),
|
||||
.ADC_Vout_volt[0].offset = 101405660400,
|
||||
};
|
||||
#endif
|
||||
|
||||
int32_t DecodeADCValue(uint8_t adc_gain, uint8_t adc_channel, uint16_t adc_rxbuf);
|
||||
uint16_t Usercode_Correction_to_DAC(uint8_t dac_gain, uint16_t usercode);
|
||||
|
||||
|
||||
+3
-3
@@ -141,9 +141,9 @@ static void InitEliteInstruction(void)
|
||||
instru.IinADCAutoGainEn = 1;
|
||||
instru.VinADCAutoGainEn = 1;
|
||||
instru.VoutAutoGainEn = 1;
|
||||
instru.IinADCGainLv = I_GAIN_100R;
|
||||
instru.VinADCGainLv = VIN_GAIN_1K;
|
||||
instru.VoutGainLv = VOUT_GAIN_15K;
|
||||
instru.IinADCGainLv = I_GAIN_AUTO;
|
||||
instru.VinADCGainLv = VIN_GAIN_AUTO;
|
||||
instru.VoutGainLv = VOUT_GAIN_AUTO;
|
||||
instru.gain_switch_on = 0b11110000; // cur auto gain switch, |lv0|lv1|lv2|lv3|none|none|none|none|
|
||||
instru.AdcChannel = 0; // RIS_ADC_IIN: 0x00, RIS_ADC_VIN: 0x01, RIS_DAC_VOUT: 0x02, RIS_HIGH_Z: 0x03
|
||||
instru.hign_z_en = 0;
|
||||
|
||||
+42
-33
@@ -2,6 +2,9 @@
|
||||
#ifndef ELITELED
|
||||
#define ELITELED
|
||||
|
||||
#define DARKLED 0xE1
|
||||
#define LIGHTLED 0xE8
|
||||
|
||||
static bool btWaitLedFlag = 0;
|
||||
static bool noEventLedFlag = 0;
|
||||
static bool preWorkLedFlag = 0;
|
||||
@@ -18,47 +21,53 @@ static void ModeLED(uint16_t modeStatus) {
|
||||
postWorkLedFlag = 0;
|
||||
|
||||
switch (modeStatus) {
|
||||
case BT_WAIT:
|
||||
btWaitLedFlag = 1;
|
||||
led_color_set(LED_NB_MAX, LED_BR_LV1, LED_CLR_YELLOWGREEN);
|
||||
break;
|
||||
|
||||
case NO_EVENT:
|
||||
noEventLedFlag = 1;
|
||||
led_color_set(LED_NB_MAX, LED_BR_LV1, LED_CLR_GREEN);
|
||||
break;
|
||||
|
||||
case PRE_WORK:
|
||||
preWorkLedFlag = 1;
|
||||
led_color_set(LED_NB_MAX, LED_BR_LV1, LED_CLR_BLUE);
|
||||
break;
|
||||
|
||||
case WORKING:
|
||||
workingLedFlag = 1;
|
||||
WorkModeLED();
|
||||
break;
|
||||
|
||||
case POST_WORK:
|
||||
postWorkLedFlag = 1;
|
||||
led_color_set(LED_NB_MAX, LED_BR_LV1, LED_CLR_GREEN);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
case BT_WAIT: {
|
||||
btWaitLedFlag = 1;
|
||||
led_color_set(LED_NB_MAX, LED_BR_LV1, LED_CLR_YELLOWGREEN);
|
||||
break;
|
||||
}
|
||||
case NO_EVENT: {
|
||||
noEventLedFlag = 1;
|
||||
led_color_set(LED_NB_MAX, LED_BR_LV1, LED_CLR_GREEN);
|
||||
break;
|
||||
}
|
||||
case PRE_WORK: {
|
||||
preWorkLedFlag = 1;
|
||||
led_color_set(LED_NB_MAX, LED_BR_LV1, LED_CLR_BLUE);
|
||||
break;
|
||||
}
|
||||
case WORKING: {
|
||||
workingLedFlag = 1;
|
||||
WorkModeLED();
|
||||
break;
|
||||
}
|
||||
case POST_WORK: {
|
||||
postWorkLedFlag = 1;
|
||||
led_color_set(LED_NB_MAX, LED_BR_LV1, LED_CLR_GREEN);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
led_color_set(LED_NB_MAX, LED_BR_LV1, LED_CLR_GREEN);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void checkFlafLED()
|
||||
{
|
||||
if(btWaitLedFlag == 1) {
|
||||
if(btWaitLedFlag == 1){
|
||||
ModeLED(BT_WAIT);
|
||||
} else if(noEventLedFlag == 1) {
|
||||
}
|
||||
else if(noEventLedFlag == 1){
|
||||
ModeLED(NO_EVENT);
|
||||
} else if(preWorkLedFlag == 1) {
|
||||
}
|
||||
else if(preWorkLedFlag == 1){
|
||||
ModeLED(PRE_WORK);
|
||||
} else if(workingLedFlag == 1) {
|
||||
}
|
||||
else if(workingLedFlag == 1){
|
||||
ModeLED(WORKING);
|
||||
} else if(postWorkLedFlag == 1) {
|
||||
}
|
||||
else if(postWorkLedFlag == 1){
|
||||
ModeLED(POST_WORK);
|
||||
}
|
||||
}
|
||||
@@ -85,7 +94,7 @@ static void WorkModeLED()
|
||||
led_color_set(LED_NB_MAX, LED_BR_LV1, LED_CLR_CYAN);
|
||||
break;
|
||||
|
||||
case CURVE_CALI_ADC:
|
||||
case CURVE_CALI:
|
||||
if (instru.AdcChannel == RIS_ADC_IIN) {
|
||||
led_color_set(LED_NB_MAX, LED_BR_LV1, LED_CLR_RED);
|
||||
} else if (instru.AdcChannel == RIS_ADC_VIN) {
|
||||
|
||||
+2
-4
@@ -12,10 +12,8 @@ static void reset() {
|
||||
|
||||
latch_single_ctrl(E_LATCH_HIGH_Z, 0); // HIGH Z MODE // 1: close; 0: open;
|
||||
|
||||
instru.VinADCGainLv = VIN_GAIN_1K;
|
||||
VinADCGainCtrl(instru.VinADCGainLv);
|
||||
instru.IinADCGainLv = I_GAIN_100R;
|
||||
IinADCGainCtrl(instru.IinADCGainLv);
|
||||
VinADCGainCtrl(VIN_GAIN_AUTO);
|
||||
IinADCGainCtrl(I_GAIN_AUTO);
|
||||
|
||||
instru.VoutGainLv = VOUT_GAIN_15K;
|
||||
VoutGainControl(instru.VoutGainLv);
|
||||
|
||||
+33
-1
@@ -205,6 +205,12 @@ struct wm_ocp_ctx_t {
|
||||
struct wm_meas_t measure;
|
||||
};
|
||||
|
||||
struct wm_adc_cali_ctx_t {
|
||||
|
||||
struct wm_meas_t measure;
|
||||
};
|
||||
|
||||
|
||||
int wm_init(void);
|
||||
int wm_deinit(void);
|
||||
void *wm_get(void);
|
||||
@@ -698,6 +704,29 @@ static int __ocp_create(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int __adc_cali_create()
|
||||
{
|
||||
struct wm_meas_t *m;
|
||||
struct wm_adc_cali_ctx_t *p;
|
||||
void **wm = &workMode_p;
|
||||
|
||||
p = malloc(sizeof(struct wm_adc_cali_ctx_t));
|
||||
if (!p) return -1;
|
||||
|
||||
m = (struct wm_meas_t *)p;
|
||||
m->_measureCurrent = 0;
|
||||
m->_measureVin = 0;
|
||||
m->_measureVout = 0;
|
||||
m->_measureBat = 0;
|
||||
m->_VoViSwitch = instru.VoViSwitch;
|
||||
|
||||
*wm = p;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int wm_init(void)
|
||||
{
|
||||
int mode = instru.eliteFxn;
|
||||
@@ -762,7 +791,10 @@ int wm_init(void)
|
||||
case CURVE_DPV_ADVANCE_SMPRATE:
|
||||
if (__dpv_advance_create()) return -2;
|
||||
break;
|
||||
|
||||
case CURVE_CALI:
|
||||
if (__adc_cali_create()) return -2;
|
||||
break;
|
||||
|
||||
default:
|
||||
// printf("DO NOT support!!");
|
||||
return -3;
|
||||
|
||||
+17
-16
@@ -17,36 +17,37 @@
|
||||
#define VIS_SHIFT_200R 0x80
|
||||
#define VIS_DEVICE_SHINY 0x10
|
||||
#define VIS_SHINY_DIS 0x20
|
||||
#define VIS_CC_ZERO 0x40
|
||||
|
||||
// RIS (real instruction)
|
||||
enum all_mode_e {
|
||||
CURVE_IV = 0x01, // I-V Curve
|
||||
CURVE_IV_CY = 0x02, // Cycle I-V
|
||||
CURVE_VO = 0x03, // Function Generator
|
||||
CURVE_RT = 0x04, // R-T Graph
|
||||
CURVE_VT = 0x05, // V-T Graph
|
||||
CURVE_IT = 0x06, // I-T Graph
|
||||
CURVE_CC = 0x07, // Constant Current (CC)
|
||||
CURVE_OCP = 0x08, // Open Circuit Potential (OCP)
|
||||
CURVE_CV = 0x09, // Cyclic Voltammetry (CV)
|
||||
CURVE_LSV = 0x0A, // Linear Sweep Voltammetry (LSV)
|
||||
CURVE_CA = 0x0B, // Chronoamperometric Graph (CA)
|
||||
CURVE_UNI_PULSE = 0x0D, // Pulse Sensing (universal pulse)
|
||||
CURVE_DPV = 0x0E, // Differential Pulse Voltammetry (DPV)
|
||||
CURVE_IV = 0x01,
|
||||
CURVE_IV_CY = 0x02,
|
||||
CURVE_VO = 0x03,
|
||||
CURVE_RT = 0x04,
|
||||
CURVE_VT = 0x05,
|
||||
CURVE_IT = 0x06,
|
||||
CURVE_CC = 0x07,
|
||||
CURVE_OCP = 0x08,
|
||||
CURVE_CV = 0x09,
|
||||
CURVE_LSV = 0x0A,
|
||||
CURVE_CA = 0x0B,
|
||||
CURVE_UNI_PULSE = 0x0D,
|
||||
CURVE_DPV = 0x0E,
|
||||
CURVE_DPV_SMPRATE = 0x0F,
|
||||
CURVE_DPV_ADVANCE = 0x10,
|
||||
CURVE_DPV_ADVANCE_SMPRATE = 0x11,
|
||||
|
||||
CURVE_CALI_ADC = 0xF1, // Cali ADC - test
|
||||
CURVE_CALI = 0xF1, // 0xF1
|
||||
|
||||
|
||||
SET_SAMPLE_RATE = 0xE0,
|
||||
SET_ADC_DAC_GAIN = 0xE1,
|
||||
SET_ADC_DAC_GAIN = 0xE1, //0xE1
|
||||
SET_PARA = 0xE2
|
||||
};
|
||||
|
||||
enum set_para_e {
|
||||
DAC_VOLT = 0x01,
|
||||
DAC_VOLT = 0x01,
|
||||
};
|
||||
|
||||
enum dev_para_e {
|
||||
|
||||
+19
-13
@@ -711,13 +711,15 @@ static void cali_IT_plot(void) {
|
||||
} else {
|
||||
cali_count++;
|
||||
ADCValueSUM = ADCValueSUM + MEAS_CURR(wm);
|
||||
InputNotify(NOTIFY_CURRENT, MEAS_CURR(wm));
|
||||
InputNotify(NOTIFY_VOLT, ADCValueSUM);
|
||||
ADCValueAVG = ADCValueSUM / cali_count;
|
||||
InputNotify(NOTIFY_CURRENT, ADCValueAVG);
|
||||
InputNotify(NOTIFY_VOLT, MEAS_CURR(wm));
|
||||
InputNotify(NOTIFY_IMPEDANCE, (int32_t)cali_count);
|
||||
}
|
||||
}
|
||||
|
||||
if (rec_cnt == 2) {
|
||||
volt_rec_en = true;
|
||||
curr_rec_en = true;
|
||||
rec_cnt = 0;
|
||||
}
|
||||
@@ -792,19 +794,21 @@ static void cali_VT_plot(void) {
|
||||
|
||||
PeriodicEvent = false;
|
||||
ADCValueSUM = 0;
|
||||
cali_count = 0;
|
||||
cali_count = 0;
|
||||
ModeLED(NO_EVENT);
|
||||
} else {
|
||||
cali_count++;
|
||||
ADCValueSUM = ADCValueSUM + MEAS_VIN(wm);
|
||||
ADCValueAVG = ADCValueSUM / cali_count;
|
||||
InputNotify(NOTIFY_VOLT, MEAS_VIN(wm));
|
||||
InputNotify(NOTIFY_CURRENT, ADCValueSUM);
|
||||
InputNotify(NOTIFY_CURRENT, ADCValueAVG);
|
||||
InputNotify(NOTIFY_IMPEDANCE, (int32_t)cali_count);
|
||||
}
|
||||
}
|
||||
|
||||
if (rec_cnt == 2) {
|
||||
volt_rec_en = true;
|
||||
curr_rec_en = true;
|
||||
rec_cnt = 0;
|
||||
}
|
||||
ADC_cnt++;
|
||||
@@ -828,20 +832,20 @@ static void cali_VT_plot(void) {
|
||||
|
||||
return;
|
||||
}
|
||||
static void cali_Vout_plot(void) {
|
||||
static void cali_Vout_plot() {
|
||||
void *wm = wm_get();
|
||||
|
||||
static int32_t ADCValueSUM = 0;
|
||||
static uint16_t cali_count = 0;
|
||||
static uint8_t ADC_cnt = 0;
|
||||
static uint8_t rec_cnt = 0;
|
||||
uint16_t cali_count_max = 1000;
|
||||
uint16_t cali_count_max = 2000;
|
||||
int32_t ADCValueAVG = 0;
|
||||
|
||||
/* ADC_cnt: 0 - read Vin and do NOT buffer the Vin after changing gain twice
|
||||
* 1 - read Vin and increase ADC_cnt
|
||||
* 2 - read Vin and reset ADC_cnt
|
||||
*/
|
||||
if(vscanReset)
|
||||
return;
|
||||
if (ADC_cnt == 0) {
|
||||
|
||||
ADC_rxbuf = MEASURE_DAC();
|
||||
@@ -853,9 +857,9 @@ static void cali_Vout_plot(void) {
|
||||
if (cali_count >= cali_count_max) {
|
||||
ADCValueAVG = ADCValueSUM / cali_count;
|
||||
|
||||
InputNotify(NOTIFY_VOLT, ADCValueAVG);
|
||||
InputNotify(NOTIFY_VOLT, ADCValueAVG);
|
||||
SendNotify();
|
||||
|
||||
|
||||
uint8_t CIS_buf[9] = {0};
|
||||
CIS_buf[0] = 5; //data len
|
||||
CIS_buf[1] = instru.chip_id;
|
||||
@@ -864,7 +868,7 @@ static void cali_Vout_plot(void) {
|
||||
CIS_buf[4] = 0x00;
|
||||
CIS_buf[5] = instru.VinADCGainLv;
|
||||
SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, 9, CIS_buf);
|
||||
|
||||
//HIGH_Z_OPEN();
|
||||
PeriodicEvent = false;
|
||||
ADCValueSUM = 0;
|
||||
cali_count = 0;
|
||||
@@ -872,14 +876,16 @@ static void cali_Vout_plot(void) {
|
||||
} else {
|
||||
cali_count++;
|
||||
ADCValueSUM = ADCValueSUM + MEAS_VOUT(wm);
|
||||
ADCValueAVG = ADCValueSUM / cali_count;
|
||||
InputNotify(NOTIFY_VOLT, MEAS_VOUT(wm));
|
||||
InputNotify(NOTIFY_CURRENT, ADCValueSUM);
|
||||
InputNotify(NOTIFY_IMPEDANCE, (int32_t)cali_count);
|
||||
InputNotify(NOTIFY_CURRENT, ADCValueAVG);
|
||||
InputNotify(NOTIFY_IMPEDANCE, (int32_t)cali_count);
|
||||
}
|
||||
}
|
||||
|
||||
if (rec_cnt == 2) {
|
||||
volt_rec_en = true;
|
||||
curr_rec_en = true;
|
||||
rec_cnt = 0;
|
||||
}
|
||||
ADC_cnt++;
|
||||
|
||||
+3
-3
@@ -4,9 +4,9 @@
|
||||
|
||||
#define VERSION_DATE_YEAR 22
|
||||
#define VERSION_DATE_MONTH 8
|
||||
#define VERSION_DATE_DAY 2
|
||||
#define VERSION_DATE_HOUR 11
|
||||
#define VERSION_DATE_MINUTE 33
|
||||
#define VERSION_DATE_DAY 15
|
||||
#define VERSION_DATE_HOUR 18
|
||||
#define VERSION_DATE_MINUTE 30
|
||||
|
||||
// this is NOT the version hash !!
|
||||
// it's the last version hash
|
||||
|
||||
+217
-130
@@ -420,7 +420,38 @@ characteristic change event
|
||||
/*===================================
|
||||
==== headstage general variable ====
|
||||
==================================*/
|
||||
// Internal Events for RTOS application
|
||||
#ifndef RTOSPARA
|
||||
#define RTOSPARA
|
||||
#define SBP_STATE_CHANGE_EVT 0x0001
|
||||
#define SBP_CHAR_CHANGE_EVT 0x0002
|
||||
#define SBP_PERIODIC_EVT 0x0004
|
||||
#define SBP_CONN_EVT_END_EVT 0x0008
|
||||
#define SBP_KEY_CHANGE_EVT 0x0010
|
||||
#endif
|
||||
|
||||
/**************************
|
||||
controller version
|
||||
EliteZM02 0,2,1,5
|
||||
EliteZM15 0,2,1,6
|
||||
EliteZM_pulsefly 0,2,1,7
|
||||
**************************/
|
||||
// product information
|
||||
#define DEVICE_NAME "Elite-EDC"
|
||||
#define MAJOR_PRODUCT_NUMBER 0 // 0:Elite, 1:Neulive
|
||||
#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
|
||||
|
||||
// buffer size
|
||||
#define BLE_CIS_BUFF_CHAR SIMPLEPROFILE_CHAR2
|
||||
#define BLE_INS_BUFF_CHAR SIMPLEPROFILE_CHAR3
|
||||
#define BLE_DAT_BUFF_CHAR SIMPLEPROFILE_CHAR4
|
||||
#define BLE_CIS_BUFF_SIZE SIMPLEPROFILE_CHAR2_LEN
|
||||
#define BLE_INS_BUFF_SIZE SIMPLEPROFILE_CHAR3_LEN
|
||||
#define BLE_DAT_BUFF_SIZE SIMPLEPROFILE_CHAR4_LEN
|
||||
|
||||
enum send_ins_para_order_e {
|
||||
PARA_1 = 0x01,
|
||||
@@ -456,9 +487,12 @@ static uint8_t ins_buf[BLE_INS_BUFF_SIZE] = {0};
|
||||
static uint8_t not_buf[BLE_DAT_BUFF_SIZE] = {0};
|
||||
static uint8_t cis_buf[BLE_CIS_BUFF_SIZE] = {0};
|
||||
|
||||
static Clock_Struct periodicClock;
|
||||
static bool PeriodicEvent = false;
|
||||
static bool InitPeriodicEvent = true;
|
||||
static bool megaStiEnable = false;
|
||||
static ICall_Semaphore semaphore;
|
||||
static uint16_t events;
|
||||
|
||||
/*=====================================
|
||||
==== headstage function prototype ====
|
||||
@@ -466,7 +500,7 @@ static bool megaStiEnable = false;
|
||||
/**
|
||||
* ZM function
|
||||
*/
|
||||
static void device_init(void);
|
||||
static void ZM_init();
|
||||
|
||||
/**
|
||||
* update the instruction buffer major content.
|
||||
@@ -553,11 +587,12 @@ static void pulse_vscan(void);
|
||||
|
||||
//mode (notify)
|
||||
static void initDATBuf();
|
||||
#include "EliteNotify.h"
|
||||
|
||||
#include "EliteADC.h"
|
||||
#include "EliteInstruction.h"
|
||||
#include "EliteDAC.h"
|
||||
#include "EliteDeviceCorrection.h"
|
||||
#include "EliteNotify.h"
|
||||
#include "EliteReset.h"
|
||||
#include "EliteLED.h"
|
||||
#include "Elite_mode_ADC_DAC.h"
|
||||
@@ -585,7 +620,8 @@ static void update_ZM_instruction(uint8 *ins) {
|
||||
instru.Vmax = (int32_t)VMAX(instru.Ve1,instru.Ve2);
|
||||
instru.Vmin = (int32_t)VMIN(instru.Ve1,instru.Ve2);
|
||||
instru.directionInit = VDIRECTION(instru.Ve1,instru.Ve2);
|
||||
instru.steptime = get_step_time(ins[9]); //5000;10000;20000;
|
||||
instru.steptime = (uint32_t)(ins[9]);
|
||||
instru.steptime = OldStep2NewStepTime(instru.steptime); //5000;10000;20000;
|
||||
instru.step = ((uint32_t)(ins[7]) << 8) | (uint32_t)(ins[8]);//1~1000 = 0.1mv ~ 100mv
|
||||
instru.step = instru.step * 100000 / instru.steptime;
|
||||
STEP_TO_VSETRATE(instru.step);
|
||||
@@ -615,7 +651,8 @@ static void update_ZM_instruction(uint8 *ins) {
|
||||
instru.Vmax = (int32_t)VMAX(instru.Ve1,instru.Ve2);
|
||||
instru.Vmin = (int32_t)VMIN(instru.Ve1,instru.Ve2);
|
||||
instru.directionInit = VDIRECTION(instru.Ve1,instru.Ve2);
|
||||
instru.steptime = get_step_time(ins[9]); //5000;10000;20000;
|
||||
instru.steptime = (uint32_t)(ins[9]);
|
||||
instru.steptime = OldStep2NewStepTime(instru.steptime); //5000;10000;20000;
|
||||
instru.step = ((uint32_t)(ins[7]) << 8) | (uint32_t)(ins[8]);//1~1000 = 0.1mv ~ 100mv
|
||||
instru.step = instru.step * 100000 / instru.steptime;
|
||||
STEP_TO_VSETRATE(instru.step);
|
||||
@@ -833,10 +870,11 @@ static void update_ZM_instruction(uint8 *ins) {
|
||||
instru.IinADCGainLv = ins[4];
|
||||
if (instru.IinADCGainLv != I_GAIN_AUTO) {
|
||||
instru.IinADCAutoGainEn = 0;
|
||||
//IinADCGainCtrl(instru.IinADCGainLv);
|
||||
} else {
|
||||
instru.IinADCAutoGainEn = 1;
|
||||
instru.IinADCGainLv = I_GAIN_100R;
|
||||
IinADCGainCtrl(instru.IinADCGainLv);
|
||||
//IinADCGainCtrl(instru.IinADCGainLv);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -847,27 +885,29 @@ static void update_ZM_instruction(uint8 *ins) {
|
||||
} else {
|
||||
instru.VinADCAutoGainEn = 1;
|
||||
instru.VinADCGainLv = VIN_GAIN_1K;
|
||||
VinADCGainCtrl(instru.VinADCGainLv);
|
||||
//VinADCGainCtrl(instru.VinADCGainLv);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case RIS_DAC_VOUT : {
|
||||
instru.VoutGainLv = ins[4];
|
||||
VoutGainControl(instru.VoutGainLv);
|
||||
//VoutGainControl(instru.VoutGainLv);
|
||||
break;
|
||||
}
|
||||
case RIS_HIGH_Z : {
|
||||
switch(ins[4]) {
|
||||
case 0x00 : {
|
||||
if (PeriodicEvent) {
|
||||
latch_single_ctrl(E_LATCH_HIGH_Z, 0); // 0 => open high_z mode
|
||||
//latch_single_ctrl(E_LATCH_HIGH_Z, 0); // 0 => open high_z mode
|
||||
HIGH_Z_OPEN();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 0x01 : {
|
||||
if (PeriodicEvent) {
|
||||
latch_single_ctrl(E_LATCH_HIGH_Z, 1); // 1 => close high_z mode
|
||||
//latch_single_ctrl(E_LATCH_HIGH_Z, 1); // 1 => close high_z mode
|
||||
HIGH_Z_CLOSE();
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -884,28 +924,47 @@ static void update_ZM_instruction(uint8 *ins) {
|
||||
break;
|
||||
}
|
||||
|
||||
case CURVE_CALI_ADC: {
|
||||
switch(ins[3]) {
|
||||
case CURVE_CALI: {
|
||||
switch(ins[3]) {
|
||||
case RIS_ADC_IIN : { // 0x00
|
||||
instru.eliteFxn = CURVE_CALI_ADC;
|
||||
instru.eliteFxn = CURVE_CALI;
|
||||
instru.AdcChannel = RIS_ADC_IIN;
|
||||
instru.notifyRate = 1000;
|
||||
ModeLED(WORKING);
|
||||
break;
|
||||
}
|
||||
case RIS_ADC_VIN : { // 0x01
|
||||
instru.eliteFxn = CURVE_CALI_ADC;
|
||||
instru.eliteFxn = CURVE_CALI;
|
||||
instru.AdcChannel = RIS_ADC_VIN;
|
||||
instru.notifyRate = 1000;
|
||||
ModeLED(WORKING);
|
||||
break;
|
||||
}
|
||||
case RIS_DAC_VOUT : { // 0x02
|
||||
instru.eliteFxn = CURVE_CALI_ADC;
|
||||
instru.eliteFxn = CURVE_CALI;
|
||||
instru.AdcChannel = RIS_DAC_VOUT;
|
||||
instru.notifyRate = 1000;
|
||||
instru.VoltConstant = ( ((uint16_t)(ins[4])) << 8) | (uint16_t)(ins[5]); // output voltage
|
||||
DAC0_W_T(instru.VoltConstant);
|
||||
instru.hign_z_en = 1;
|
||||
|
||||
switch(ins[4]) {
|
||||
case 0x00: {
|
||||
instru.VoltConstant = 0x2710;
|
||||
break;
|
||||
}
|
||||
case 0x01: {
|
||||
instru.VoltConstant = 0x61A8;
|
||||
break;
|
||||
}
|
||||
case 0x02: {
|
||||
instru.VoltConstant = 0xC350;
|
||||
break;
|
||||
}
|
||||
case 0x03: {
|
||||
instru.VoltConstant = 0xEA60;
|
||||
break;
|
||||
}
|
||||
}
|
||||
DAC0_W_T(instru.VoltConstant);
|
||||
ModeLED(WORKING);
|
||||
break;
|
||||
}
|
||||
@@ -1249,7 +1308,8 @@ static void update_ZM_instruction(uint8 *ins) {
|
||||
switch (ins[3]){
|
||||
case DAC_VOLT:
|
||||
value = (ins[4] << 8) | ins[5]; // usercode
|
||||
|
||||
|
||||
|
||||
if(value < DAC_VOUT_GAIN_LARGE_BOUNDARY_USERCODE && value > DAC_VOUT_GAIN_LARGE_BOUNDARY1_USERCODE){
|
||||
instru.VoutGainLv = VOUT_GAIN_15K;
|
||||
} else {
|
||||
@@ -1320,59 +1380,38 @@ static void update_ZM_instruction(uint8 *ins) {
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x50: {
|
||||
initCISBuf();
|
||||
case 0x90 : {
|
||||
|
||||
led_rainbow(LED_BR_LV8);
|
||||
VoutGainControl(0x00);
|
||||
|
||||
cis_buf[0] = 2;
|
||||
cis_buf[1] = (uint8_t) ADC_rxbuf >> 8;
|
||||
cis_buf[2] = (uint8_t) ADC_rxbuf;
|
||||
SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, BLE_CIS_BUFF_SIZE, cis_buf);
|
||||
|
||||
HIGH_Z_CLOSE();
|
||||
|
||||
|
||||
|
||||
uint16_t volts = ( ((uint16_t)(ins[4])) << 8) | (uint16_t)(ins[5]);
|
||||
dac_write_through_mode(0x01, 0x01, volts);
|
||||
|
||||
//CPUdelay(32000000);
|
||||
led_color_set(LED_NB_MAX, LED_BR_LV1, LED_CLR_BLUE);
|
||||
CPUdelay(32000000);
|
||||
ADC_rxbuf = MEASURE_DAC();
|
||||
CPUdelay(32000000);
|
||||
ADC_rxbuf = MEASURE_DAC();
|
||||
led_rainbow(LED_BR_LV1);
|
||||
uint8_t CIS_buf[9] = {0};
|
||||
CIS_buf[0] = 5; //data len
|
||||
CIS_buf[1] = instru.chip_id;
|
||||
CIS_buf[2] = (uint8_t) ((ADC_rxbuf & 0xFF00) >> 8);
|
||||
CIS_buf[3] = (uint8_t) (ADC_rxbuf & 0x00FF);
|
||||
CIS_buf[4] = 0x00;
|
||||
CIS_buf[5] = instru.VinADCGainLv;
|
||||
SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, 9, CIS_buf);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
case 0x51: {
|
||||
initCISBuf();
|
||||
cis_buf[0] = 2;
|
||||
cis_buf[1] = (uint8_t) ADC_rxbuf >> 8;
|
||||
cis_buf[2] = (uint8_t) ADC_rxbuf;
|
||||
SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, BLE_CIS_BUFF_SIZE, cis_buf);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
case 0x61: {
|
||||
dac_ldac_mode(ins[4], ins[5]);
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x62: {
|
||||
dac_clear_mode();
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x63: {
|
||||
dac_power_control_mode(ins[4], ins[5], ins[6]);
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x64: {
|
||||
dac_linearity_mode(ins[4]);
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x65: {
|
||||
uint16_t volts = (uint16_t)ins[6] << 8 | ins[7];
|
||||
dac_write_mode(ins[4], ins[5], volts);
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x66: {
|
||||
uint16_t volts = (uint16_t)ins[6] << 8 | ins[7];
|
||||
DAC0_W_T(volts);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1441,6 +1480,23 @@ static void update_ZM_instruction(uint8 *ins) {
|
||||
break;
|
||||
}
|
||||
|
||||
case VIS_CC_ZERO: {
|
||||
instru.eliteFxn = CURVE_OCP;
|
||||
instru.notifyRate = 500;
|
||||
|
||||
if (instru.notifyRate > 1000) {
|
||||
// slow notify rate, < 10sps, auto gain changer only use ADC gain level = 1.2.3.4
|
||||
instru.gain_switch_on = 0b11110000;
|
||||
|
||||
} else {
|
||||
// fast notify rate, >= 10sps, auto gain changer only use ADC gain level = 1.2.3
|
||||
instru.gain_switch_on = 0b01110000;
|
||||
}
|
||||
|
||||
ModeLED(PRE_WORK);
|
||||
break;
|
||||
}
|
||||
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
@@ -1513,85 +1569,116 @@ static void ZM_instruction_update_handle(uint8_t characteristic) {
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef DEVICE_NAME
|
||||
#error "DEVICE_NAME not defined"
|
||||
#endif
|
||||
|
||||
#ifndef MAJOR_PRODUCT_NUMBER
|
||||
#error "MAJOR_PRODUCT_NUMBER not defined"
|
||||
#endif
|
||||
|
||||
#ifndef MINOR_PRODUCT_NUMBER
|
||||
#error "MINOR_PRODUCT_NUMBER not defined"
|
||||
#endif
|
||||
|
||||
#ifndef MAJOR_VERSION_NUMBER
|
||||
#error "MAJOR_VERSION_NUMBER not defined"
|
||||
#endif
|
||||
|
||||
#ifndef MINOR_VERSION_NUMBER
|
||||
#error "MINOR_VERSION_NUMBER not defined"
|
||||
#endif
|
||||
|
||||
#include "devinfoservice.h"
|
||||
#include "gapgattserver.h"
|
||||
#include "gattservapp.h"
|
||||
|
||||
struct date_t {
|
||||
uint8_t year;
|
||||
uint8_t month;
|
||||
uint8_t day;
|
||||
};
|
||||
static void headstage_init_device_info() {
|
||||
char * date = __DATE__;
|
||||
uint8_t year = 10 * (date[9] - '0') + (date[10] - '0');
|
||||
uint8_t month = 0;
|
||||
|
||||
struct device_info_t {
|
||||
struct date_t date;
|
||||
};
|
||||
|
||||
struct device_info_t device_info;
|
||||
|
||||
void get_date(struct date_t *date)
|
||||
{
|
||||
const char *months[12] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
||||
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
|
||||
struct date_t *d = date;
|
||||
char year_s[5] = {0};
|
||||
char month_s[4] = {0};
|
||||
char day_s[3] = {0};
|
||||
int i;
|
||||
char date_now[] = __DATE__;
|
||||
|
||||
memcpy(year_s, date_now + 9, 2);
|
||||
memcpy(month_s, date_now, 3);
|
||||
memcpy(day_s, date_now + 4, 2);
|
||||
|
||||
d->year = atoi(year_s);
|
||||
d->day = atoi(day_s);
|
||||
for (i=0; i<12; i++) {
|
||||
if (!strcmp(month_s, months[i])) {
|
||||
d->month = i + 1;
|
||||
break;
|
||||
switch (date[0]) {
|
||||
case 'J':
|
||||
// Jan, January
|
||||
// Jun, June
|
||||
// Jul, July
|
||||
if (date[1] == 'a') {
|
||||
month = 1;
|
||||
} else if (date[2] == 'n') {
|
||||
month = 6;
|
||||
} else {
|
||||
month = 7;
|
||||
}
|
||||
break;
|
||||
case 'F':
|
||||
// Feb, February
|
||||
month = 2;
|
||||
break;
|
||||
case 'M':
|
||||
// Mar, March
|
||||
// May, May
|
||||
if (date[2] == 'r') {
|
||||
month = 3;
|
||||
} else {
|
||||
month = 5;
|
||||
}
|
||||
break;
|
||||
case 'A':
|
||||
// Apr, April
|
||||
// Ang, August
|
||||
if (date[1] == 'p') {
|
||||
month = 4;
|
||||
} else {
|
||||
month = 8;
|
||||
}
|
||||
break;
|
||||
case 'S':
|
||||
// Sep, September
|
||||
month = 9;
|
||||
break;
|
||||
case 'O':
|
||||
// Oct, October
|
||||
month = 10;
|
||||
break;
|
||||
case 'N':
|
||||
// Nov, November
|
||||
month = 11;
|
||||
break;
|
||||
case 'D':
|
||||
// Dec, December
|
||||
month = 12;
|
||||
break;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void headstage_init_device_info() {
|
||||
uint8_t scan_rsp_data[64] = {9};
|
||||
uint8_t *p = scan_rsp_data;
|
||||
struct device_info_t *dev = &device_info;
|
||||
int i;
|
||||
|
||||
get_date(&device_info.date);
|
||||
|
||||
*p++ = sizeof(DEVICE_NAME); // 10
|
||||
*p++ = GAP_ADTYPE_LOCAL_NAME_COMPLETE; // 09
|
||||
for (i=0; i<sizeof(DEVICE_NAME)-1; i++) {
|
||||
uint8_t scanRspData[64];
|
||||
uint8_t *p = scanRspData;
|
||||
*p++ = sizeof(DEVICE_NAME);
|
||||
*p++ = GAP_ADTYPE_LOCAL_NAME_COMPLETE;
|
||||
for (unsigned int i = 0; i < sizeof(DEVICE_NAME) - 1; i++) {
|
||||
*p++ = DEVICE_NAME[i];
|
||||
} // 69 108 105 116 101 45 69 73 83
|
||||
*p++ = 16; // 16
|
||||
*p++ = GAP_ADTYPE_MANUFACTURER_SPECIFIC; // 255
|
||||
*p++ = 'B'; // 66
|
||||
*p++ = 'P'; // 80
|
||||
*p++ = 'H'; // 72
|
||||
*p++ = 'S'; // 83
|
||||
*p++ = MAJOR_PRODUCT_NUMBER; // 0
|
||||
*p++ = MINOR_PRODUCT_NUMBER; // 4
|
||||
*p++ = MAJOR_VERSION_NUMBER; // 1
|
||||
*p++ = MINOR_VERSION_NUMBER; // 0
|
||||
*p++ = dev->date.year; // 22
|
||||
*p++ = dev->date.month; // 07
|
||||
*p++ = 'B'; // 66
|
||||
*p++ = 'A'; // 65
|
||||
*p++ = 'T'; // 84
|
||||
*p++ = (uint8_t)(NotifyVoltBat); // 44
|
||||
*p++ = (uint8_t)(NotifyVoltBat >> 8); // 33
|
||||
}
|
||||
*p++ = 16;
|
||||
*p++ = GAP_ADTYPE_MANUFACTURER_SPECIFIC;
|
||||
*p++ = 'B';
|
||||
*p++ = 'P';
|
||||
*p++ = 'H';
|
||||
*p++ = 'S';
|
||||
*p++ = MAJOR_PRODUCT_NUMBER;
|
||||
*p++ = MINOR_PRODUCT_NUMBER;
|
||||
*p++ = MAJOR_VERSION_NUMBER;
|
||||
*p++ = MINOR_VERSION_NUMBER;
|
||||
*p++ = year;
|
||||
*p++ = month;
|
||||
*p++ = 'B';
|
||||
*p++ = 'A';
|
||||
*p++ = 'T';
|
||||
*p++ = (uint8_t)(NotifyVoltBat);
|
||||
*p++ = (uint8_t)(NotifyVoltBat >> 8);
|
||||
|
||||
GGS_SetParameter(GGS_DEVICE_NAME_ATT, sizeof(DEVICE_NAME), DEVICE_NAME);
|
||||
|
||||
GAPRole_SetParameter(GAPROLE_SCAN_RSP_DATA, p - scan_rsp_data, scan_rsp_data);
|
||||
GAPRole_SetParameter(GAPROLE_SCAN_RSP_DATA, p - scanRspData, scanRspData);
|
||||
}
|
||||
|
||||
#endif // HEADSTAGE_H
|
||||
|
||||
+311
@@ -0,0 +1,311 @@
|
||||
|
||||
#ifndef HEADSTAGE_H
|
||||
#error "headstage.h not include"
|
||||
#endif
|
||||
|
||||
#ifdef HEADSTAGE_H_H
|
||||
#error "headstage_*.h has be included"
|
||||
#endif
|
||||
|
||||
#ifndef HEADSTAGE_TNI_H
|
||||
#define HEADSTAGE_H_H
|
||||
#define HEADSTAGE_TNI_H
|
||||
|
||||
// product information
|
||||
#define DEVICE_NAME "Elite-v0.1"
|
||||
#define MAJOR_PRODUCT_NUMBER 0
|
||||
#define MINOR_PRODUCT_NUMBER 1
|
||||
#define MAJOR_VERSION_NUMBER 0
|
||||
#define MINOR_VERSION_NUMBER 1
|
||||
|
||||
// header
|
||||
#include <ti/drivers/PIN.h>
|
||||
#include "board.h"
|
||||
|
||||
/*============
|
||||
==== SPI ====
|
||||
===========*/
|
||||
|
||||
/* application use SPI parameters and buffers */
|
||||
|
||||
#define SPI_BUFFER_SIZE 16
|
||||
|
||||
/**
|
||||
* the pointer to point which channel is used currently.
|
||||
* -1 for not beginning.
|
||||
*/
|
||||
static int8 channel_pointer = -1;
|
||||
|
||||
static uint8_t spi_txbuf[SPI_BUFFER_SIZE] = {0};
|
||||
static uint8_t spi_rxbuf[SPI_BUFFER_SIZE] = {0};
|
||||
|
||||
/*=============================
|
||||
==== headstage variable ====
|
||||
============================*/
|
||||
|
||||
PIN_Handle pin_handle;
|
||||
static PIN_State DBS_rst;
|
||||
|
||||
// DBS reset pin
|
||||
|
||||
const PIN_Config BLE_IO[] = {
|
||||
//
|
||||
IOID_9 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
IOID_2 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
IOID_3 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
IOID_13 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
PIN_TERMINATE //
|
||||
};
|
||||
|
||||
/**
|
||||
* ADC clock switch signal.
|
||||
*/
|
||||
static bool adc_clock_signal = FALSE;
|
||||
|
||||
/*=======================================
|
||||
==== headstage function declaration ====
|
||||
======================================*/
|
||||
|
||||
static void headstage_tni_update_instruction_callback(uint8_t ins_type, uint8_t ins_op, uint8_t ins_len, uint8_t *ins);
|
||||
|
||||
/*=============================
|
||||
==== ramp data generating ====
|
||||
============================*/
|
||||
|
||||
static uint16_t ramp_data_counter = 0;
|
||||
|
||||
static void create_ramp(uint8_t *buff) {
|
||||
buff[0] = 0b10110000 | (0b00001111 & (uint8_t)(ramp_data_counter >> 6));
|
||||
buff[1] = (uint8_t)(ramp_data_counter << 2);
|
||||
ramp_data_counter += 1;
|
||||
}
|
||||
|
||||
/*=======================================
|
||||
==== headstage function implemented ====
|
||||
======================================*/
|
||||
|
||||
/**
|
||||
* change channel value to little endian
|
||||
*/
|
||||
static uint8 encode_channel(uint8 channel) {
|
||||
return 0x0F & (((channel & 0b1000) >> 3) | //
|
||||
((channel & 0b0100) >> 1) | //
|
||||
((channel & 0b0010) << 1) | //
|
||||
((channel & 0b0001) << 3));
|
||||
}
|
||||
|
||||
static void headstage_init() {
|
||||
set_update_instruction_callback(headstage_tni_update_instruction_callback);
|
||||
|
||||
// initialize the DBS reset pin
|
||||
pin_handle = PIN_open(&DBS_rst, BLE_IO);
|
||||
PIN_setOutputValue(pin_handle, IOID_9, 1);
|
||||
PIN_setOutputValue(pin_handle, IOID_2, 0);
|
||||
PIN_setOutputValue(pin_handle, IOID_3, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* change the recording clock bit in the instruction buffer.
|
||||
*/
|
||||
static void update_ins_rec_clock(uint8_t *buf, bool adc_clock_signal) {
|
||||
buf[3] = (buf[3] & 0b11110000) | ((adc_clock_signal) ? 0b1000 : 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* change the recording channel bit in the instruction buffer.
|
||||
*/
|
||||
static void update_ins_rec_channel(uint8_t *buf, uint8 channel) {
|
||||
buf[1] = (buf[1] & 0b00001111) | (encode_channel(channel) << 4);
|
||||
}
|
||||
|
||||
/**
|
||||
* change the stimulation enable bit in the instruction buffer.
|
||||
*/
|
||||
static void update_ins_sti_enable(uint8_t *buf, bool enable) {
|
||||
buf[1] = (buf[1] & 0b11111101) | ((enable) ? 0b10 : 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* change the stimulating channel bit in the instruction buffer.
|
||||
*/
|
||||
static void update_ins_sti_channel(uint8_t *buf, uint8 sti_chp, uint8 sti_chn) {
|
||||
buf[2] = (buf[2] & 0b11110000) | encode_channel(sti_chp);
|
||||
buf[3] = (buf[3] & 0b00001111) | (encode_channel(sti_chn) << 4);
|
||||
}
|
||||
|
||||
static void update_ins_buffer() {
|
||||
uint8 header = 0b10100000;
|
||||
uint8 amp_gain = (instru.amp_gain & 0b11) << 3;
|
||||
uint8 amp_lbf = instru.amp_low_band_freq & 0b111;
|
||||
uint8 channel = 0; // should be call update_ins_channel to modify this value
|
||||
uint8 chopper = (instru.chopper) ? 0b00001000 : 0;
|
||||
uint8 fast_settle = (instru.fast_settle) ? 0b00000100 : 0;
|
||||
uint8 sti_enable = (instru.work_mode != STI_MODE_DISABLE) ? 0b00000010 : 0;
|
||||
uint8 sti_volt_l = (instru.sti_volt & 0b11111) >> 4;
|
||||
uint8 sti_volt_h = (instru.sti_volt & 0b01111) << 4;
|
||||
uint8 sti_chp = instru.sti_channel_pmos & 0b1111;
|
||||
uint8 sti_chn = (instru.sti_channel_nmos & 0b1111) << 4;
|
||||
uint8 clk_signal = 0; // should be call update_ins_clock to modify this value
|
||||
|
||||
spi_txbuf[0] = header | amp_gain | amp_lbf;
|
||||
spi_txbuf[1] = channel | chopper | fast_settle | sti_enable | sti_volt_l;
|
||||
spi_txbuf[2] = sti_volt_h | sti_chp;
|
||||
spi_txbuf[3] = sti_chn | clk_signal;
|
||||
}
|
||||
|
||||
static bool update_ins_rec_buffer() {
|
||||
adc_clock_signal = (adc_clock_signal) ? FALSE : TRUE; // switch adc_clock
|
||||
update_ins_rec_clock(spi_txbuf, adc_clock_signal);
|
||||
|
||||
if (adc_clock_signal) {
|
||||
// change to next channel
|
||||
|
||||
if (next_active_channel()) {
|
||||
update_ins_rec_channel(spi_txbuf, channel_pointer);
|
||||
} else {
|
||||
// no channel active
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the instruction content for SPI buffer, which is depended on the
|
||||
* work_mode. Expend the remind instruction according to the base instruction
|
||||
* which allocated at the beginning 4 bytes of the SPI buffer.
|
||||
*
|
||||
* ========= ===========
|
||||
* work_mode ins pattern
|
||||
* ========= ===========
|
||||
* POS, NEG 4 F D 0
|
||||
* P2N, N2P 4 4' F D
|
||||
* AWF not impl
|
||||
* ========= ===========
|
||||
*
|
||||
* pattern *4*
|
||||
* stimulation instruction.
|
||||
*
|
||||
* pattern *F*
|
||||
* set pmos channel to 0xF, release the remain voltage in the capacitance.
|
||||
*
|
||||
* pattern *D*
|
||||
* disable stimulation
|
||||
*
|
||||
* pattern *0*
|
||||
* nop.
|
||||
*
|
||||
* @param: buf: pointer of the SPI buffer.
|
||||
*/
|
||||
static void update_ins_sti_buffer() {
|
||||
switch (instru.work_mode) {
|
||||
case STI_MODE_POS:
|
||||
case STI_MODE_NEG:
|
||||
// copy [4:7]
|
||||
spi_txbuf[4] = spi_txbuf[0];
|
||||
spi_txbuf[5] = spi_txbuf[1];
|
||||
spi_txbuf[6] = spi_txbuf[2];
|
||||
spi_txbuf[7] = spi_txbuf[3];
|
||||
// copy [8:B]
|
||||
spi_txbuf[8] = spi_txbuf[0];
|
||||
spi_txbuf[9] = spi_txbuf[1];
|
||||
spi_txbuf[10] = spi_txbuf[2];
|
||||
spi_txbuf[11] = spi_txbuf[3];
|
||||
// reset [C:F]
|
||||
spi_txbuf[12] = 0;
|
||||
spi_txbuf[13] = 0;
|
||||
spi_txbuf[14] = 0;
|
||||
spi_txbuf[15] = 0;
|
||||
// change content
|
||||
update_ins_sti_enable(spi_txbuf, TRUE);
|
||||
// ins buf [4:7]
|
||||
update_ins_sti_enable(spi_txbuf + 4, TRUE);
|
||||
update_ins_sti_channel(spi_txbuf + 4, 0xF, instru.sti_channel_pmos);
|
||||
// ins buf [8:B]
|
||||
update_ins_sti_enable(spi_txbuf + 8, FALSE);
|
||||
break;
|
||||
case STI_MODE_P2N:
|
||||
case STI_MODE_N2P:
|
||||
// copy [4:7]
|
||||
spi_txbuf[4] = spi_txbuf[0];
|
||||
spi_txbuf[5] = spi_txbuf[1];
|
||||
spi_txbuf[6] = spi_txbuf[2];
|
||||
spi_txbuf[7] = spi_txbuf[3];
|
||||
// copy [8:B]
|
||||
spi_txbuf[8] = spi_txbuf[0];
|
||||
spi_txbuf[9] = spi_txbuf[1];
|
||||
spi_txbuf[10] = spi_txbuf[2];
|
||||
spi_txbuf[11] = spi_txbuf[3];
|
||||
// copy [C:F]
|
||||
spi_txbuf[12] = spi_txbuf[0];
|
||||
spi_txbuf[13] = spi_txbuf[1];
|
||||
spi_txbuf[14] = spi_txbuf[2];
|
||||
spi_txbuf[15] = spi_txbuf[3];
|
||||
// change content
|
||||
update_ins_sti_enable(spi_txbuf + 0, TRUE);
|
||||
update_ins_sti_channel(spi_txbuf + 0, instru.sti_channel_pmos, instru.sti_channel_nmos);
|
||||
// ins buf [4:7]
|
||||
update_ins_sti_enable(spi_txbuf + 4, TRUE);
|
||||
update_ins_sti_channel(spi_txbuf + 4, instru.sti_channel_nmos, instru.sti_channel_pmos);
|
||||
// ins buf [8:B]
|
||||
update_ins_sti_enable(spi_txbuf + 8, TRUE);
|
||||
update_ins_sti_channel(spi_txbuf + 8, 0xF, instru.sti_channel_nmos);
|
||||
// ins buf [C:F]
|
||||
update_ins_sti_enable(spi_txbuf + 12, FALSE);
|
||||
break;
|
||||
case STI_MODE_AWF:
|
||||
// XXX define the voltage change
|
||||
break;
|
||||
default:
|
||||
// do nothing
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void headstage_tni_update_instruction_callback(uint8_t ins_type, uint8_t ins_op, uint8_t ins_len, uint8_t *ins) {
|
||||
switch (ins_type) {
|
||||
case INS_TYPE_VIS: {
|
||||
// reset
|
||||
case VIS_RST:
|
||||
// reset. reset all variable
|
||||
adc_clock_signal = FALSE;
|
||||
memset(spi_txbuf, 0, SPI_BUFFER_SIZE);
|
||||
break;
|
||||
|
||||
// interrupt
|
||||
case VIS_INT:
|
||||
// stop. reset channel table
|
||||
ramp_data_counter = 0;
|
||||
memset(spi_txbuf, 0, SPI_BUFFER_SIZE);
|
||||
break;
|
||||
}
|
||||
case INS_TYPE_RIS:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static uint8_t *spi_transact_rec_instruction() {
|
||||
if (IS_REC_MODE(instru.work_mode)) {
|
||||
PIN_setOutputValue(pin_handle, IOID_13, 1); // DBS_P2S turn on
|
||||
headstage_spi_transaction(SPI_BUFFER_SIZE, spi_txbuf, spi_rxbuf);
|
||||
PIN_setOutputValue(pin_handle, IOID_13, 0); // DBS_P2S turn off
|
||||
|
||||
} else if (IS_ARM_MODE(instru.work_mode) && !adc_clock_signal) {
|
||||
create_ramp(spi_rxbuf);
|
||||
}
|
||||
|
||||
if (adc_clock_signal) {
|
||||
return NULL;
|
||||
} else {
|
||||
return spi_rxbuf;
|
||||
}
|
||||
}
|
||||
|
||||
static uint8_t *spi_transact_sti_instruction() {
|
||||
headstage_spi_transaction(16, spi_txbuf, NULL);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif
|
||||
+80
-21
@@ -17,33 +17,63 @@
|
||||
#define IMPEDANCE_METER_H_
|
||||
|
||||
// header
|
||||
#include <ti/drivers/PIN.h>
|
||||
#include "board.h"
|
||||
#include "EliteWorkData.h"
|
||||
#include <driverlib/aon_batmon.h>
|
||||
|
||||
static void SimpleBLEPeripheral_performPeriodicTask(void);
|
||||
|
||||
static void SimpleBLEPeripheral_clockHandler(UArg arg) {
|
||||
// Store the event.
|
||||
// events |= SBP_PERIODIC_EVT;
|
||||
|
||||
// Wake up the application.
|
||||
// Semaphore_post(semaphore); // send samaphore to jump out of infinite waiting(simple_peripheral.c line570)
|
||||
|
||||
}
|
||||
// static void elite_gptimer_callback(GPTimerCC26XX_Handle handle, GPTimerCC26XX_IntMask interruptMask) {
|
||||
// events |= SBP_PERIODIC_EVT;
|
||||
// Semaphore_post(semaphore);
|
||||
// GPT.cnt_gpt++;
|
||||
// }
|
||||
|
||||
|
||||
static void device_init(void)
|
||||
{
|
||||
// static void ZM_update_instruction_callback(uint8_t ins_type, uint8_t chip_ID, uint8_t *ins);
|
||||
|
||||
static void ZM_init() {
|
||||
// set_update_instruction_callback(ZM_update_instruction_callback);
|
||||
|
||||
// initialize
|
||||
gpio_create();
|
||||
InitEliteInstruction();
|
||||
|
||||
update_latch_stat(E_LATCH_CS_MEM, 1);
|
||||
update_latch_stat(E_LATCH_CS_ADC, 1);
|
||||
update_latch_stat(E_LATCH_CS_DAC, 1);
|
||||
update_latch_stat(E_LATCH_OFF, 1); // E_LATCH_OFF = 1 => turn off 6994
|
||||
update_latch_stat(E_LATCH_OFF, 1); // OFF = 1 => turn off 6994
|
||||
latch_multi_ctrl();
|
||||
|
||||
/* when elite open, must change vin level,
|
||||
measure battery value will be right */
|
||||
IinADCGainCtrl(instru.IinADCGainLv);
|
||||
VinADCGainCtrl(instru.VinADCGainLv);
|
||||
InitEliteInstruction();
|
||||
|
||||
// init DAC, set output ~= 0 V
|
||||
instru.VoutGainLv = VOUT_GAIN_15K;
|
||||
VoutGainControl(instru.VoutGainLv);
|
||||
DAC0_W_T(Usercode_Correction_to_DAC(instru.VoutGainLv, 25000));
|
||||
|
||||
|
||||
/* when elite open, must change vin level,
|
||||
measure battery value will be right */
|
||||
VinADCGainCtrl(VIN_GAIN_AUTO);
|
||||
|
||||
elite_gptimer_open();
|
||||
InitGPT();
|
||||
|
||||
return;
|
||||
//elite_gptimer_start();
|
||||
|
||||
// PIN_registerIntCb(pin_handle, switch_on_callback);
|
||||
// PIN_setInterrupt(pin_handle, E_PIN_SHUT_DOWN | PIN_IRQ_POSEDGE);
|
||||
}
|
||||
|
||||
// static void ZM_update_instruction_callback(uint8_t ins_type, uint8_t chip_ID, uint8_t *ins) {}
|
||||
|
||||
#define IsPeriodicMode() ( \
|
||||
(instru.eliteFxn == CURVE_IV) || \
|
||||
(instru.eliteFxn == CURVE_IV_CY) || \
|
||||
@@ -56,7 +86,7 @@ static void device_init(void)
|
||||
(instru.eliteFxn == CURVE_CA) || \
|
||||
(instru.eliteFxn == CURVE_VO) || \
|
||||
(instru.eliteFxn == CURVE_OCP) || \
|
||||
(instru.eliteFxn == CURVE_CALI_ADC) \
|
||||
(instru.eliteFxn == CURVE_CALI) \
|
||||
)
|
||||
|
||||
#define Ve1MatchVe2Mode() ( \
|
||||
@@ -75,9 +105,15 @@ static void peri_mode(void)
|
||||
vscanReset = true;
|
||||
if (first_highz_flag && GPT.cnt_lead_time >= 1000) {
|
||||
if (instru.eliteFxn == CURVE_OCP) {
|
||||
latch_single_ctrl(E_LATCH_HIGH_Z, instru.hign_z_en); // HIGH Z MODE // 1: close; 0: open;
|
||||
HIGH_Z_OPEN(); // HIGH Z MODE // 1: close; 0: open;
|
||||
} else {
|
||||
latch_single_ctrl(E_LATCH_HIGH_Z, instru.hign_z_en); // HIGH Z MODE // 1: close; 0: open;
|
||||
//latch_single_ctrl(E_LATCH_HIGH_Z, instru.hign_z_en); // HIGH Z MODE // 1: close; 0: open;
|
||||
if(instru.hign_z_en == 1) {
|
||||
HIGH_Z_CLOSE();
|
||||
}
|
||||
else{
|
||||
HIGH_Z_OPEN();
|
||||
}
|
||||
}
|
||||
first_highz_flag = false;
|
||||
}
|
||||
@@ -121,7 +157,7 @@ static void peri_mode(void)
|
||||
(instru.eliteFxn == CURVE_DPV_SMPRATE) ||
|
||||
(instru.eliteFxn == CURVE_DPV_ADVANCE) ||
|
||||
(instru.eliteFxn == CURVE_DPV_ADVANCE_SMPRATE) ||
|
||||
(instru.eliteFxn == CURVE_CALI_ADC)) {
|
||||
(instru.eliteFxn == CURVE_CALI)) {
|
||||
batteryCheck_flag = false;
|
||||
tempCheck_flag = false;
|
||||
|
||||
@@ -225,7 +261,7 @@ static void uni_pulse_mode(void)
|
||||
(instru.eliteFxn == CURVE_DPV_SMPRATE) ||
|
||||
(instru.eliteFxn == CURVE_DPV_ADVANCE) ||
|
||||
(instru.eliteFxn == CURVE_DPV_ADVANCE_SMPRATE) ||
|
||||
(instru.eliteFxn == CURVE_CALI_ADC)) {
|
||||
(instru.eliteFxn == CURVE_CALI)) {
|
||||
batteryCheck_flag = false;
|
||||
tempCheck_flag = false;
|
||||
|
||||
@@ -284,6 +320,8 @@ static void uni_pulse_mode(void)
|
||||
|
||||
static void mode_init_set(void)
|
||||
{
|
||||
|
||||
|
||||
batteryADC_flag = false;
|
||||
volt_rec_en = true;
|
||||
curr_rec_en = true;
|
||||
@@ -308,10 +346,22 @@ static void mode_init_set(void)
|
||||
instru.gain_switch_on = 0b01110000;
|
||||
}
|
||||
|
||||
if (instru.IinADCGainLv == I_GAIN_AUTO) {
|
||||
instru.IinADCGainLv = I_GAIN_100R;
|
||||
}
|
||||
|
||||
if (instru.VinADCAutoGainEn == VIN_GAIN_AUTO) {
|
||||
instru.VinADCGainLv = VIN_GAIN_1K;
|
||||
}
|
||||
|
||||
VinADCGainCtrl(instru.VinADCGainLv);
|
||||
IinADCGainCtrl(instru.IinADCGainLv);
|
||||
VoutGainControl(instru.VoutGainLv);
|
||||
|
||||
// if(instru.eliteFxn == CURVE_CALI) {
|
||||
// volt_rec_en = true;
|
||||
// curr_rec_en = true;
|
||||
// }
|
||||
if (Ve1MatchVe2Mode()) {
|
||||
if (instru.Ve1 == instru.Ve2) {
|
||||
DAC0_W_T(Usercode_Correction_to_DAC(instru.VoutGainLv, 25000));
|
||||
@@ -333,7 +383,7 @@ static void mode_init_set(void)
|
||||
*
|
||||
* @return None.
|
||||
*/
|
||||
static void elite_task(void)
|
||||
static void SimpleBLEPeripheral_performPeriodicTask(void)
|
||||
{
|
||||
// GPT_timerIncrement();
|
||||
|
||||
@@ -516,13 +566,16 @@ static void EliteADCControl(uint32_t time)
|
||||
}
|
||||
break;
|
||||
|
||||
case CURVE_CALI_ADC:
|
||||
case CURVE_CALI:
|
||||
if (instru.AdcChannel == RIS_ADC_IIN) {
|
||||
cali_IT_plot();
|
||||
|
||||
} else if (instru.AdcChannel == RIS_ADC_VIN) {
|
||||
cali_VT_plot();
|
||||
|
||||
} else if (instru.AdcChannel == RIS_DAC_VOUT) {
|
||||
cali_Vout_plot();
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -574,9 +627,13 @@ static void mode_done(void)
|
||||
(instru.eliteFxn == CURVE_DPV) ||
|
||||
(instru.eliteFxn == CURVE_DPV_SMPRATE) ||
|
||||
(instru.eliteFxn == CURVE_DPV_ADVANCE) ||
|
||||
(instru.eliteFxn == CURVE_DPV_ADVANCE_SMPRATE)) {
|
||||
(instru.eliteFxn == CURVE_DPV_ADVANCE_SMPRATE) ||
|
||||
(instru.eliteFxn == CURVE_CALI))
|
||||
{
|
||||
if (!PeriodicEvent) {
|
||||
finishMode = true;
|
||||
|
||||
// if(!(instru.eliteFxn == CURVE_CALI))
|
||||
SendNotify();
|
||||
Eliteinterrupt();
|
||||
}
|
||||
@@ -641,9 +698,11 @@ static void vscan_ctrl(uint32_t time)
|
||||
}
|
||||
}
|
||||
|
||||
static uint32_t get_step_time(uint8_t StepTime){
|
||||
static uint32_t OldStep2NewStepTime(uint32_t StepTime){
|
||||
uint8_t StepTimeLevel = 0;
|
||||
StepTimeLevel = StepTime / 0x12;
|
||||
|
||||
switch (StepTime) {
|
||||
switch (StepTimeLevel) {
|
||||
case 0: { //0.5 sec
|
||||
return STEPTIME_HALF_SEC;
|
||||
}
|
||||
|
||||
+4
-11
@@ -178,7 +178,7 @@ static void vo_vscan(void)
|
||||
return;
|
||||
}
|
||||
|
||||
#define DELTAVOLTMAX 20000000 //2000000 = 10mV //10000000 = 50mV //20000000 = 100mV
|
||||
#define DELTAVOLTMAX 2000000 //2000000 = 10mV
|
||||
#define RESISTANCE_100R 1 // 100V/1A = 1[5nV]/50[pA]
|
||||
|
||||
static void cc_vscan(void)
|
||||
@@ -229,7 +229,7 @@ static void cc_vscan(void)
|
||||
Iin = m->_measureCurrent * 20; //[50pA] nA => 50pA
|
||||
deltaI = Iin - i_set;
|
||||
|
||||
if (deltaI > 400000 || deltaI < -400000) { //20uA
|
||||
if (deltaI > 2000000 || deltaI < -2000000) { //100uA
|
||||
if (instru.cc_cp_speed == 0) { // 0:low 1:normal 2:high
|
||||
cc_cp_speed = 100;
|
||||
} else if (instru.cc_cp_speed == 1) {
|
||||
@@ -237,18 +237,11 @@ static void cc_vscan(void)
|
||||
} else {
|
||||
cc_cp_speed = 1;
|
||||
}
|
||||
divisionRate = cc_cp_speed;
|
||||
} else {
|
||||
if (instru.cc_cp_speed == 0) { // 0:low 1:normal 2:high
|
||||
cc_cp_speed = 100;
|
||||
} else if (instru.cc_cp_speed == 1) {
|
||||
cc_cp_speed = 20;
|
||||
} else {
|
||||
cc_cp_speed = 20;
|
||||
}
|
||||
divisionRate = 20;
|
||||
}
|
||||
|
||||
divisionRate = cc_cp_speed;
|
||||
|
||||
deltaV = -1 * (deltaI / divisionRate); //-5 * deltaI / 5000 //pV=> 5nV
|
||||
|
||||
if (deltaV > DELTAVOLTMAX) { //2000000 = 10mV
|
||||
|
||||
@@ -50,9 +50,13 @@
|
||||
|
||||
#include <xdc/runtime/Error.h>
|
||||
|
||||
|
||||
#include <ti/drivers/Power.h>
|
||||
#include <ti/drivers/power/PowerCC26XX.h>
|
||||
#include <ti/sysbios/BIOS.h>
|
||||
#include <ti/drivers/SPI.h>
|
||||
#include <ti/drivers/spi/SPICC26XXDMA.h>
|
||||
#include <ti/drivers/dma/UDMACC26XX.h>
|
||||
|
||||
#include "icall.h"
|
||||
#include "hal_assert.h"
|
||||
@@ -132,7 +136,7 @@ PIN_Handle radCtrlHandle;
|
||||
|
||||
extern void AssertHandler(uint8 assertCause, uint8 assertSubcause);
|
||||
|
||||
// extern Display_Handle dispHandle;
|
||||
//extern Display_Handle dispHandle;
|
||||
|
||||
/*******************************************************************************
|
||||
* @fn Main
|
||||
@@ -247,49 +251,48 @@ int main()
|
||||
*/
|
||||
void AssertHandler(uint8 assertCause, uint8 assertSubcause)
|
||||
{
|
||||
/*
|
||||
// Open the display if the app has not already done so
|
||||
if ( !dispHandle )
|
||||
{
|
||||
dispHandle = Display_open(Display_Type_LCD, NULL);
|
||||
}
|
||||
// if ( !dispHandle )
|
||||
// {
|
||||
// dispHandle = Display_open(Display_Type_LCD, NULL);
|
||||
// }
|
||||
|
||||
Display_print0(dispHandle, 0, 0, ">>>STACK ASSERT");
|
||||
|
||||
// Display_print0(dispHandle, 0, 0, ">>>STACK ASSERT");
|
||||
|
||||
// check the assert cause
|
||||
switch (assertCause)
|
||||
{
|
||||
case HAL_ASSERT_CAUSE_OUT_OF_MEMORY:
|
||||
Display_print0(dispHandle, 0, 0, "***ERROR***");
|
||||
Display_print0(dispHandle, 2, 0, ">> OUT OF MEMORY!");
|
||||
break;
|
||||
|
||||
case HAL_ASSERT_CAUSE_INTERNAL_ERROR:
|
||||
// check the subcause
|
||||
if (assertSubcause == HAL_ASSERT_SUBCAUSE_FW_INERNAL_ERROR)
|
||||
{
|
||||
Display_print0(dispHandle, 0, 0, "***ERROR***");
|
||||
Display_print0(dispHandle, 2, 0, ">> INTERNAL FW ERROR!");
|
||||
}
|
||||
else
|
||||
{
|
||||
Display_print0(dispHandle, 0, 0, "***ERROR***");
|
||||
Display_print0(dispHandle, 2, 0, ">> INTERNAL ERROR!");
|
||||
}
|
||||
break;
|
||||
|
||||
case HAL_ASSERT_CAUSE_ICALL_ABORT:
|
||||
Display_print0(dispHandle, 0, 0, "***ERROR***");
|
||||
Display_print0(dispHandle, 2, 0, ">> ICALL ABORT!");
|
||||
HAL_ASSERT_SPINLOCK;
|
||||
break;
|
||||
|
||||
default:
|
||||
Display_print0(dispHandle, 0, 0, "***ERROR***");
|
||||
Display_print0(dispHandle, 2, 0, ">> DEFAULT SPINLOCK!");
|
||||
HAL_ASSERT_SPINLOCK;
|
||||
}
|
||||
*/
|
||||
// switch (assertCause)
|
||||
// {
|
||||
// case HAL_ASSERT_CAUSE_OUT_OF_MEMORY:
|
||||
// Display_print0(dispHandle, 0, 0, "***ERROR***");
|
||||
// Display_print0(dispHandle, 2, 0, ">> OUT OF MEMORY!");
|
||||
// break;
|
||||
//
|
||||
// case HAL_ASSERT_CAUSE_INTERNAL_ERROR:
|
||||
// // check the subcause
|
||||
// if (assertSubcause == HAL_ASSERT_SUBCAUSE_FW_INERNAL_ERROR)
|
||||
// {
|
||||
// Display_print0(dispHandle, 0, 0, "***ERROR***");
|
||||
// Display_print0(dispHandle, 2, 0, ">> INTERNAL FW ERROR!");
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Display_print0(dispHandle, 0, 0, "***ERROR***");
|
||||
// Display_print0(dispHandle, 2, 0, ">> INTERNAL ERROR!");
|
||||
// }
|
||||
// break;
|
||||
//
|
||||
// case HAL_ASSERT_CAUSE_ICALL_ABORT:
|
||||
// Display_print0(dispHandle, 0, 0, "***ERROR***");
|
||||
// Display_print0(dispHandle, 2, 0, ">> ICALL ABORT!");
|
||||
// HAL_ASSERT_SPINLOCK;
|
||||
// break;
|
||||
//
|
||||
// default:
|
||||
// Display_print0(dispHandle, 0, 0, "***ERROR***");
|
||||
// Display_print0(dispHandle, 2, 0, ">> DEFAULT SPINLOCK!");
|
||||
// HAL_ASSERT_SPINLOCK;
|
||||
// }
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
+538
-713
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user