Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 87bb2580da | |||
| 15dfb53b60 | |||
| a967255ffb | |||
| a26cdf2a73 | |||
| 380c5b7553 | |||
| bf0fec66bf | |||
| f628c4f438 | |||
| 22a475c8a0 | |||
| 80191f7cad | |||
| be415717b3 | |||
| 26cc4a3a0f | |||
| e9f863894f |
+22
-6
@@ -43,6 +43,7 @@ struct _correction{
|
||||
Formula ADC_volt[3];
|
||||
Formula ADC_current[4];
|
||||
Formula Usercode2DAC[2];
|
||||
Formula ADC_Vout_volt[1];
|
||||
uint16_t Gain0Boundary[2];
|
||||
uint16_t Gain1Boundary[4];
|
||||
uint16_t Gain2Boundary[2];
|
||||
@@ -77,6 +78,9 @@ struct _correction{
|
||||
|
||||
.Usercode2DAC[1].coeff = (-10511469),
|
||||
.Usercode2DAC[1].offset = 563770560100,
|
||||
|
||||
.ADC_Vout_volt[0].coeff = (-6251051),
|
||||
.ADC_Vout_volt[0].offset = 102081366120,
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -108,6 +112,9 @@ struct _correction{
|
||||
|
||||
.Usercode2DAC[1].coeff = (-178077711),
|
||||
.Usercode2DAC[1].offset = 4777894559527,
|
||||
|
||||
.ADC_Vout_volt[0].coeff = (-6245014),
|
||||
.ADC_Vout_volt[0].offset = 101751226981,
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -139,6 +146,9 @@ struct _correction{
|
||||
|
||||
.Usercode2DAC[1].coeff = (-178746005),
|
||||
.Usercode2DAC[1].offset = 4789272862069,
|
||||
|
||||
.ADC_Vout_volt[0].coeff = (-6223818),
|
||||
.ADC_Vout_volt[0].offset = 100571214617,
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -165,11 +175,14 @@ struct _correction{
|
||||
.ADC_current[3].coeff = 30518004246,
|
||||
.ADC_current[3].offset = (-495456618814855),
|
||||
|
||||
.Usercode2DAC[0].coeff = (-10568719),
|
||||
.Usercode2DAC[0].offset = 585036272447,
|
||||
.Usercode2DAC[0].coeff = (-10563123),
|
||||
.Usercode2DAC[0].offset = 584273387784,
|
||||
|
||||
.Usercode2DAC[1].coeff = (-179441058),
|
||||
.Usercode2DAC[1].offset = 4807380622351,
|
||||
.Usercode2DAC[1].coeff = (-178953278),
|
||||
.Usercode2DAC[1].offset = 4795625159379,
|
||||
|
||||
.ADC_Vout_volt[0].coeff = (-6254234),
|
||||
.ADC_Vout_volt[0].offset = 101718986999,
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -201,6 +214,9 @@ struct _correction{
|
||||
|
||||
.Usercode2DAC[1].coeff = (-178479878),
|
||||
.Usercode2DAC[1].offset = 4782895510276,
|
||||
|
||||
.ADC_Vout_volt[0].coeff = (6194),
|
||||
.ADC_Vout_volt[0].offset = -100974071,
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -219,8 +235,8 @@ static int32_t DecodeADCVolt(uint8_t ADCGain, uint16_t ADC_measure){
|
||||
static int32_t DecodeADCVoutVolt(uint16_t ADC_measure){
|
||||
long long ADCVoutVolt = 0;
|
||||
|
||||
ADCVoutVolt = ((-62658782380) * ADC_measure + 1020118014900000);
|
||||
ADCVoutVolt = ADCVoutVolt / 1e11;
|
||||
ADCVoutVolt = (Correction.ADC_Vout_volt[0].coeff * ADC_measure + Correction.ADC_Vout_volt[0].offset);
|
||||
ADCVoutVolt = ADCVoutVolt / 1e4;
|
||||
return (int32_t) (ADCVoutVolt);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ static void elite_gptimer_callback(GPTimerCC26XX_Handle handle, GPTimerCC26XX_In
|
||||
#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 4800 // clock freq = 0.1 ms
|
||||
#define CLOCK_FREQ 4800 // clock freq = 0.1 ms CLK frequency 4769
|
||||
|
||||
#define elite_gptimer_open() \
|
||||
do { \
|
||||
|
||||
+2
-1
@@ -163,8 +163,9 @@ static void WorkModeLED() {
|
||||
Elite_led_color(COLOR_RED);
|
||||
}else if(INSTRUCTION.AdcChannel == VIN_ADC){
|
||||
Elite_led_color(COLOR_ORANGE);
|
||||
}else if(INSTRUCTION.AdcChannel == VOUT_DAC){
|
||||
Elite_led_color(COLOR_BLUE);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
// case VIS_RST: {
|
||||
|
||||
+3
-3
@@ -50,9 +50,9 @@ static void Eliteinterrupt() {
|
||||
|
||||
PIN15_setOutputValue(HIGH_Z_MODE, 1); // 0 => open high_z mode
|
||||
|
||||
INSTRUCTION.VoutGainLevel = VOUT_GAIN_15K;
|
||||
VoutGainControl(INSTRUCTION.VoutGainLevel);
|
||||
DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoutGainLevel, 25000));
|
||||
// INSTRUCTION.VoutGainLevel = VOUT_GAIN_15K;
|
||||
// VoutGainControl(INSTRUCTION.VoutGainLevel);
|
||||
// DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoutGainLevel, 25000));
|
||||
|
||||
initINSBuf();
|
||||
initDATBuf();
|
||||
|
||||
+6
-2
@@ -75,7 +75,7 @@ static void ADC_SPI(uint8_t length, uint8_t *spi_txbuf, uint8_t *spi_rxbuf) {
|
||||
|
||||
SPI_transfer(spiHandle1, &ADC_DAC_transaction);
|
||||
|
||||
PIN_setOutputValue(pin_handle, D6, 1); // ADC_CS HOGH
|
||||
PIN_setOutputValue(pin_handle, D6, 1); // ADC_CS HIGH
|
||||
update_latch_status (ADC_CS, 1);
|
||||
// PIN15_setOutputValue(ADC_CS, 1); // ADC_CS HIGH
|
||||
}
|
||||
@@ -91,7 +91,7 @@ static void DAC_SPI(uint8_t length, uint8_t *spi_txbuf, uint8_t *spi_rxbuf) {
|
||||
|
||||
SPI_transfer(spiHandle1, &ADC_DAC_transaction);
|
||||
|
||||
PIN_setOutputValue(pin_handle, D7, 1); // DAC_CS HOGH
|
||||
PIN_setOutputValue(pin_handle, D7, 1); // DAC_CS HIGH
|
||||
update_latch_status (DAC_CS, 1);
|
||||
// PIN15_setOutputValue(DAC_CS, 1); // DAC_CS HIGH
|
||||
}
|
||||
@@ -99,6 +99,10 @@ static void DAC_SPI(uint8_t length, uint8_t *spi_txbuf, uint8_t *spi_rxbuf) {
|
||||
static void ELITE15_SPI_HOLD() {
|
||||
Elite_SPI_init();
|
||||
|
||||
PIN_setOutputValue(pin_handle, D6, LH.LATCH0[6]); // ADC_CS
|
||||
PIN_setOutputValue(pin_handle, D7, LH.LATCH0[7]); // DAC_CS
|
||||
PIN_setOutputValue(pin_handle, D4, LH.LATCH0[4]); // update HIGH_Z_MODE
|
||||
|
||||
PIN_setOutputValue(pin_handle, LOAD0, 1);
|
||||
PIN_setOutputValue(pin_handle, LOAD1, 0);
|
||||
PIN_setOutputValue(pin_handle, LOAD2, 0);
|
||||
|
||||
+6
-2
@@ -17,6 +17,7 @@
|
||||
#define Board_SPI1_CLK D2
|
||||
#define Board_SPI1_CS PIN_UNASSIGNED
|
||||
|
||||
//#define clk_test_pin IOID_0
|
||||
#define D0 IOID_3
|
||||
#define D1 IOID_4
|
||||
#define D2 IOID_5
|
||||
@@ -36,7 +37,7 @@
|
||||
#define ADC_DAC_SPI_CLK LOAD0, D2
|
||||
#define LED_MOSI LOAD0, D1
|
||||
#define LED_CLK LOAD0, D0
|
||||
#define MEM_HOLD LOAD0, D4
|
||||
#define HIGH_Z_MODE LOAD0, D4
|
||||
#define MEM_CS LOAD0, D5
|
||||
|
||||
#define Turnon_I_MID LOAD2, D0
|
||||
@@ -57,9 +58,10 @@
|
||||
|
||||
#define shutdown_6994 LOAD2, D6
|
||||
#define switch_on IOID_14
|
||||
#define HIGH_Z_MODE LOAD2, D5
|
||||
//#define HIGH_Z_MODE LOAD2, D5
|
||||
#define enable_10v LOAD1, D5
|
||||
#define enable_5v LOAD1, D6
|
||||
#define MEM_HOLD LOAD1, D0
|
||||
|
||||
PIN_Handle pin_handle;
|
||||
static PIN_State ZM_rst;
|
||||
@@ -74,6 +76,8 @@ const PIN_Config BLE_IO[] = {
|
||||
D6 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
D7 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
|
||||
// clk_test_pin | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
|
||||
LOAD0 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
LOAD1 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
LOAD2 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
|
||||
|
||||
+8
-11
@@ -549,7 +549,8 @@ static int32_t readVinVout(WorkMode *WorkModeData){
|
||||
return VoltData;
|
||||
}
|
||||
|
||||
static void cali_IT_plot(WorkMode *WorkModeData) {
|
||||
static void cali_IT_plot(WorkMode *WorkModeData)
|
||||
{
|
||||
switch (INSTRUCTION.eliteFxn) {
|
||||
case IT_CURVE:{
|
||||
#define CURRENT_MODE WorkModeData->IT
|
||||
@@ -598,10 +599,8 @@ static void cali_IT_plot(WorkMode *WorkModeData) {
|
||||
}
|
||||
|
||||
static uint8_t ADCSwitch = 0;
|
||||
int32_t ADCValueTemp = 0;
|
||||
static int32_t ADCValueSUM = 0;
|
||||
int32_t ADCValueAVG = 0;
|
||||
int16_t ADCValueAVG_RAW = 0;
|
||||
static uint16_t cali_count_max = 1000;
|
||||
|
||||
if(ADCSwitch == 0){ /**read Iin(buffer)**/
|
||||
@@ -721,10 +720,8 @@ static void cali_VT_plot(WorkMode *WorkModeData) {
|
||||
|
||||
static uint8_t ADCSwitch = 0;
|
||||
static int32_t VoltData;
|
||||
int32_t ADCValueTemp = 0;
|
||||
static int32_t ADCValueSUM = 0;
|
||||
int32_t ADCValueAVG = 0;
|
||||
int16_t ADCValueAVG_RAW = 0;
|
||||
static uint16_t cali_count_max = 1000;
|
||||
|
||||
if(ADCSwitch == 0){ /**read Iin(buffer)**/
|
||||
@@ -741,18 +738,18 @@ static void cali_VT_plot(WorkMode *WorkModeData) {
|
||||
|
||||
}
|
||||
VoltData = CURRENT_MODE->_measureVin;
|
||||
} else if(CURRENT_MODE->_VoViSwitch == 0x00) {
|
||||
ReadADCVolt(CURRENT_MODE->_VoViSwitch);
|
||||
// CURRENT_MODE->_measureVout = DecodeADCValue(INSTRUCTION.ADCGainLevel, ADC_CH_DAC, spi_ADC_rxbuf);
|
||||
CURRENT_MODE->_measureVin = (int32_t) (spi_ADC_rxbuf[0] << 8) | (int32_t) (spi_ADC_rxbuf[1]);
|
||||
VoltData = CURRENT_MODE->_measureVout;
|
||||
}
|
||||
|
||||
if(INSTRUCTION.VinADCGainLevel == 0) {
|
||||
if((INSTRUCTION.VinADCGainLevel == 0) && !(CURRENT_MODE->_VoViSwitch == 0x00)) {
|
||||
cali_count_max = 5000;
|
||||
} else {
|
||||
cali_count_max = 1000;
|
||||
}
|
||||
// else if(CURRENT_MODE->_VoViSwitch == 0x00){
|
||||
// ReadADCVolt(CURRENT_MODE->_VoViSwitch);
|
||||
// CURRENT_MODE->_measureVout = DecodeADCValue(INSTRUCTION.ADCGainLevel, ADC_CH_DAC, spi_ADC_rxbuf);
|
||||
// VoltData = CURRENT_MODE->_measureVout;
|
||||
// }
|
||||
|
||||
if(record_flag == false){
|
||||
static int recordCount = 0;
|
||||
|
||||
+18
-3
@@ -497,6 +497,9 @@ static bool megaStiEnable = false;
|
||||
static ICall_Semaphore semaphore;
|
||||
static uint16_t events;
|
||||
|
||||
/* clock stability test 0326 */
|
||||
static bool clk_onoff = 0;
|
||||
|
||||
/*=====================================
|
||||
==== headstage function prototype ====
|
||||
====================================*/
|
||||
@@ -683,7 +686,7 @@ static void update_ZM_instruction(uint8 *ins) {
|
||||
INSTRUCTION.step = INSTRUCTION.step * 100000 / INSTRUCTION.notifyRate;
|
||||
STEP_TO_VSETRATE(INSTRUCTION.step);
|
||||
INSTRUCTION.VsetRate = VsetRateTable[INSTRUCTION.VsetRateIndex];//N
|
||||
INSTRUCTION.VoViSwitch = 0x01;
|
||||
INSTRUCTION.VoViSwitch = 0x00;
|
||||
INSTRUCTION.cycleNumber = 1;
|
||||
|
||||
if((INSTRUCTION.Ve1 < DAC_VOUT_GAIN_LARGE_BOUNDARY_USERCODE && INSTRUCTION.Ve1 > DAC_VOUT_GAIN_LARGE_BOUNDARY1_USERCODE)
|
||||
@@ -1126,7 +1129,7 @@ static void update_ZM_instruction(uint8 *ins) {
|
||||
break;
|
||||
}
|
||||
|
||||
case CALI_DAC_MODE: {
|
||||
case CALI_DAC_MODE: { // 0x93
|
||||
ModeLED(WORKING);
|
||||
INSTRUCTION.eliteFxn = CALI_DAC_MODE;
|
||||
PIN15_setOutputValue(HIGH_Z_MODE, 1); // 1 => close high_z mode
|
||||
@@ -1134,7 +1137,7 @@ static void update_ZM_instruction(uint8 *ins) {
|
||||
break;
|
||||
}
|
||||
|
||||
case CALI_ADC_MODE: {
|
||||
case CALI_ADC_MODE: { // 0x92
|
||||
switch(ins[3]) {
|
||||
case IIN_ADC : { // 0x00
|
||||
INSTRUCTION.eliteFxn = CALI_ADC_MODE;
|
||||
@@ -1154,6 +1157,18 @@ static void update_ZM_instruction(uint8 *ins) {
|
||||
ModeLED(WORKING);
|
||||
break;
|
||||
}
|
||||
case VOUT_DAC : { // 0x02
|
||||
INSTRUCTION.eliteFxn = CALI_ADC_MODE;
|
||||
INSTRUCTION.AdcChannel = VOUT_DAC;
|
||||
INSTRUCTION.notifyRate = 1000;
|
||||
INSTRUCTION.sampleRate = 15;
|
||||
INSTRUCTION.VoViSwitch = 0x00; // 0: read Vout voltage
|
||||
// PIN15_setOutputValue(HIGH_Z_MODE, 1); // 1 => close high_z mode
|
||||
INSTRUCTION.VoltConstant = ( ((uint16_t)(ins[4])) << 8) | (uint16_t)(ins[5]); // output voltage
|
||||
DAC_outputV(INSTRUCTION.VoltConstant); //UserCode -> DAC code -> DAC out
|
||||
ModeLED(WORKING);
|
||||
break;
|
||||
}
|
||||
default : {
|
||||
break;
|
||||
}
|
||||
|
||||
+7
-1
@@ -36,6 +36,7 @@ static void elite_gptimer_callback(GPTimerCC26XX_Handle handle, GPTimerCC26XX_In
|
||||
events |= SBP_PERIODIC_EVT;
|
||||
Semaphore_post(semaphore);
|
||||
GPT.GptimerCounter++;
|
||||
// clk_onoff = !clk_onoff;
|
||||
}
|
||||
|
||||
|
||||
@@ -51,6 +52,7 @@ static void ZM_init() {
|
||||
|
||||
PIN15_setOutputValue(shutdown_6994, 1); // OFF = 1 => turn off 6994
|
||||
PIN15_setOutputValue(enable_10v, 0); // enable 10V
|
||||
// PIN15_setOutputValue(enable_5v, 1); // enable 10V
|
||||
PIN15_setOutputValue(HIGH_Z_MODE, 1); // HIGH Z MODE // 1 => close high_z mode
|
||||
|
||||
InitEliteInstruction();
|
||||
@@ -166,7 +168,8 @@ static void SimpleBLEPeripheral_performPeriodicTask(WorkMode *WorkModeData) {
|
||||
GPT.BatteryCheckCounter = GPT.BatteryCheckCounter + GPT.DeltaGptimerCounter;
|
||||
if(GPT.BatteryCheckCounter >= 50000){
|
||||
GPT.BatteryCheckCounter -= 50000; //To get right time
|
||||
batteryCheck_flag = true;
|
||||
// batteryCheck_flag = true;
|
||||
batteryCheck_flag = false; // set flag "false" for calibration mode
|
||||
}
|
||||
|
||||
uint16_t bat = ((uint16_t)(NotifyVoltBat[2]) << 8 & 0xFF00 ) | ((uint16_t)(NotifyVoltBat[3]) & 0x00FF);
|
||||
@@ -377,6 +380,9 @@ static void EliteADCControl(WorkMode *WorkModeData) {
|
||||
cali_IT_plot(WorkModeData);
|
||||
}else if(INSTRUCTION.AdcChannel == VIN_ADC){
|
||||
cali_VT_plot(WorkModeData);
|
||||
}else if(INSTRUCTION.AdcChannel == VOUT_DAC){
|
||||
// DAC_outputV(INSTRUCTION.VoltConstant); //UserCode -> DAC code -> DAC out
|
||||
cali_VT_plot(WorkModeData);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
+1
@@ -567,6 +567,7 @@ static void SimpleBLEPeripheral_taskFxn(UArg a0, UArg a1) {
|
||||
headstage_init_device_info();
|
||||
|
||||
for (;;) {
|
||||
// PIN_setOutputValue(pin_handle, clk_test_pin, clk_onoff); // test system clock frequency
|
||||
// Waits for a signal to the semaphore associated with the calling thread.
|
||||
// Note that the semaphore associated with a thread is signaled when a
|
||||
// message is queued to the message receive queue of the thread or when
|
||||
|
||||
Reference in New Issue
Block a user