spi hold when run mode
This commit is contained in:
+7
@@ -133,6 +133,9 @@ static void update_latch_status (uint32_t latch_num, uint32_t elite_pin, bool hi
|
||||
}
|
||||
|
||||
static void PIN15_setOutputValue (uint32_t latch_num, uint32_t pin_num, bool highlow) {
|
||||
if(PeriodicEvent){
|
||||
ELITE15_SPI_CLOSE();
|
||||
}
|
||||
add_elite_pin();
|
||||
update_latch_status (latch_num, pin_num, highlow);
|
||||
PIN_setOutputValue(&ZM_rst, latch_num, 1); // Turn on latch
|
||||
@@ -178,6 +181,10 @@ static void PIN15_setOutputValue (uint32_t latch_num, uint32_t pin_num, bool hig
|
||||
CPUdelay(10);
|
||||
PIN_setOutputValue(&ZM_rst, latch_num, 0); // Turn off latch
|
||||
remove_elite_pin();
|
||||
|
||||
if(PeriodicEvent){
|
||||
ELITE15_SPI_HOLD();
|
||||
}
|
||||
}
|
||||
|
||||
static void Init_Elite15_PIN () {
|
||||
|
||||
+15
-6
@@ -46,7 +46,11 @@ static void ADC_write(uint8_t ADCin) {
|
||||
spi_ADC_txbuf[0] = ADCin;
|
||||
spi_ADC_txbuf[1] = 0b11101011;
|
||||
|
||||
ADC_SPI(2, spi_ADC_txbuf, spi_ADC_rxbuf);
|
||||
if(PeriodicEvent){
|
||||
ADC_SPI_TEST(2, spi_ADC_txbuf, spi_ADC_rxbuf);
|
||||
}else{
|
||||
ADC_SPI(2, spi_ADC_txbuf, spi_ADC_rxbuf);
|
||||
}
|
||||
}
|
||||
|
||||
static void ADC_read(uint8_t *ADCdata){
|
||||
@@ -55,7 +59,11 @@ static void ADC_read(uint8_t *ADCdata){
|
||||
spi_ADC_rxbuf[i] = 0;
|
||||
}
|
||||
|
||||
ADC_SPI(SPI_ADC_SIZE, spi_ADC_txbuf, ADCdata);
|
||||
if(PeriodicEvent){
|
||||
ADC_SPI_TEST(2, spi_ADC_txbuf, spi_ADC_rxbuf);
|
||||
}else{
|
||||
ADC_SPI(2, spi_ADC_txbuf, spi_ADC_rxbuf);
|
||||
}
|
||||
}
|
||||
|
||||
static void IinADCGainControl(uint8_t IinADCLevel){
|
||||
@@ -164,7 +172,7 @@ static void ADCChannelSelect(uint8_t ADCChannel){
|
||||
|
||||
static void ReadADCIin(uint8_t *buf){
|
||||
// Read data twice since the first data we get is previous data
|
||||
IinADCGainControl(INSTRUCTION.ADCGainLevel);
|
||||
// IinADCGainControl(INSTRUCTION.ADCGainLevel);
|
||||
ADCChannelSelect(ADC_CH_CURRENT);
|
||||
ADC_read(buf);
|
||||
|
||||
@@ -174,7 +182,8 @@ static void ReadADCIin(uint8_t *buf){
|
||||
|
||||
static void ReadADCVin(uint8_t *buf){
|
||||
// Read data twice since the first data we get is previous data
|
||||
VinADCGainControl(INSTRUCTION.VinADCGainLevel);
|
||||
|
||||
// VinADCGainControl(INSTRUCTION.VinADCGainLevel);
|
||||
ADCChannelSelect(ADC_CH_VOLT);
|
||||
ADC_read(buf);
|
||||
|
||||
@@ -447,7 +456,7 @@ static void AutoGainChangeVin(int32_t RealVin){
|
||||
else{
|
||||
VIN_GAIN_30K_counter++;
|
||||
if(VIN_GAIN_30K_counter > 2){
|
||||
INSTRUCTION.VinADCGainLevel = VIN_GAIN_30K_counter;
|
||||
INSTRUCTION.VinADCGainLevel = VIN_GAIN_30K;
|
||||
VinADCGainControl(INSTRUCTION.VinADCGainLevel);
|
||||
VIN_GAIN_30K_counter = 0;
|
||||
record_flag = false;
|
||||
@@ -507,7 +516,7 @@ static void AutoGainChangeVin(int32_t RealVin){
|
||||
else{
|
||||
VIN_GAIN_30K_counter++;
|
||||
if(VIN_GAIN_30K_counter > 2){
|
||||
INSTRUCTION.VinADCGainLevel = VIN_GAIN_30K_counter;
|
||||
INSTRUCTION.VinADCGainLevel = VIN_GAIN_30K;
|
||||
VinADCGainControl(INSTRUCTION.VinADCGainLevel);
|
||||
VIN_GAIN_30K_counter = 0;
|
||||
record_flag = false;
|
||||
|
||||
+1
@@ -210,6 +210,7 @@ static void CV_Vscan(CVMode *CV){
|
||||
/*stop condition*/
|
||||
if(CV->_cycleNumber == 0){
|
||||
PeriodicEvent = false;
|
||||
ELITE15_SPI_CLOSE();
|
||||
ModeLED(NO_EVENT);
|
||||
}
|
||||
}
|
||||
|
||||
+6
-1
@@ -51,7 +51,12 @@ static uint16_t DAC_outputV(uint16_t voltLV) {
|
||||
spi_DACtxbuf[1] = v1;
|
||||
spi_DACtxbuf[2] = v2;
|
||||
|
||||
DAC_SPI(SPI_DAC_SIZE, spi_DACtxbuf, spi_rxbuf);
|
||||
if(PeriodicEvent){
|
||||
DAC_SPI_TEST(SPI_DAC_SIZE, spi_DACtxbuf, spi_rxbuf);
|
||||
}else{
|
||||
DAC_SPI(SPI_DAC_SIZE, spi_DACtxbuf, spi_rxbuf);
|
||||
}
|
||||
|
||||
return voltLV;
|
||||
}
|
||||
|
||||
|
||||
+2
@@ -28,11 +28,13 @@ static void IV_Vscan(IVMode *IV){
|
||||
if(IV->_current_direction_up){
|
||||
if(Vset >= IV->_Vmax){
|
||||
PeriodicEvent = false;
|
||||
ELITE15_SPI_CLOSE();
|
||||
ModeLED(NO_EVENT);
|
||||
}
|
||||
}else{
|
||||
if(Vset <= IV->_Vmin){
|
||||
PeriodicEvent = false;
|
||||
ELITE15_SPI_CLOSE();
|
||||
ModeLED(NO_EVENT);
|
||||
}
|
||||
}
|
||||
|
||||
+11
-6
@@ -18,7 +18,12 @@ static void LED_color(uint8_t bright, uint8_t red, uint8_t green, uint8_t blue)
|
||||
spi_LEDtxbuf[SPI_LED_SIZE - 2] = 0xffff;
|
||||
spi_LEDtxbuf[SPI_LED_SIZE - 1] = 0xffff;
|
||||
|
||||
LED_SPI(SPI_LED_SIZE, spi_LEDtxbuf, spi_LEDrxbuf);
|
||||
if(PeriodicEvent){
|
||||
LED_SPI_TEST(SPI_LED_SIZE, spi_LEDtxbuf, spi_LEDrxbuf);
|
||||
}else{
|
||||
LED_SPI(SPI_LED_SIZE, spi_LEDtxbuf, spi_LEDrxbuf);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void Elite_led_color(uint16_t color){
|
||||
@@ -82,28 +87,28 @@ static void ModeLED(uint16_t modeStatus) {
|
||||
|
||||
switch (modeStatus) {
|
||||
case BT_WAIT: {
|
||||
BT_WAIT_LED();
|
||||
btWaitLedFlag = 1;
|
||||
BT_WAIT_LED();
|
||||
break;
|
||||
}
|
||||
case NO_EVENT: {
|
||||
LEDPowerON();
|
||||
noEventLedFlag = 1;
|
||||
LEDPowerON();
|
||||
break;
|
||||
}
|
||||
case PRE_WORK: {
|
||||
Elite_led_color(COLOR_BLUE);
|
||||
preWorkLedFlag = 1;
|
||||
Elite_led_color(COLOR_BLUE);
|
||||
break;
|
||||
}
|
||||
case WORKING: {
|
||||
WorkModeLED();
|
||||
workingLedFlag = 1;
|
||||
WorkModeLED();
|
||||
break;
|
||||
}
|
||||
case POST_WORK: {
|
||||
Elite_led_color(COLOR_BLUE);
|
||||
postWorkLedFlag = 1;
|
||||
Elite_led_color(COLOR_BLUE);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
|
||||
+1
-1
@@ -39,10 +39,10 @@ static void reset() {
|
||||
}
|
||||
|
||||
static void Eliteinterrupt() {
|
||||
InitFlag();
|
||||
ModeLED(NO_EVENT);
|
||||
|
||||
InitEliteFlag();
|
||||
InitFlag();
|
||||
InitCT();
|
||||
InitGPT();
|
||||
InitLH();
|
||||
|
||||
+32
@@ -96,6 +96,38 @@ static void DAC_SPI(uint8_t length, uint8_t *spi_txbuf, uint8_t *spi_rxbuf) {
|
||||
ELITE15_SPI_CLOSE();
|
||||
}
|
||||
|
||||
static void LED_SPI_TEST(uint8_t length, uint16_t *spi_txbuf, uint16_t *spi_rxbuf) {
|
||||
LED_transaction.count = length;
|
||||
LED_transaction.txBuf = spi_txbuf;
|
||||
LED_transaction.rxBuf = spi_rxbuf;
|
||||
|
||||
SPI_transfer(spiHandle0, &LED_transaction);
|
||||
}
|
||||
|
||||
static void ADC_SPI_TEST(uint8_t length, uint8_t *spi_txbuf, uint8_t *spi_rxbuf) {
|
||||
PIN_setOutputValue(pin_handle, D6, 0); // CS_ADC
|
||||
|
||||
ADC_DAC_transaction.count = length;
|
||||
ADC_DAC_transaction.txBuf = spi_txbuf;
|
||||
ADC_DAC_transaction.rxBuf = spi_rxbuf;
|
||||
|
||||
SPI_transfer(spiHandle1, &ADC_DAC_transaction);
|
||||
|
||||
PIN_setOutputValue(pin_handle, D6, 1); // CS_ADC
|
||||
}
|
||||
|
||||
static void DAC_SPI_TEST(uint8_t length, uint8_t *spi_txbuf, uint8_t *spi_rxbuf) {
|
||||
PIN_setOutputValue(pin_handle, D7, 0); // CD_DAC
|
||||
|
||||
ADC_DAC_transaction.count = length;
|
||||
ADC_DAC_transaction.txBuf = spi_txbuf;
|
||||
ADC_DAC_transaction.rxBuf = spi_rxbuf;
|
||||
|
||||
SPI_transfer(spiHandle1, &ADC_DAC_transaction);
|
||||
|
||||
PIN_setOutputValue(pin_handle, D7, 1); // CD_DAC
|
||||
}
|
||||
|
||||
static void ELITE15_SPI_HOLD() {
|
||||
PIN_setOutputValue(pin_handle, LOAD0, 1);
|
||||
PIN_setOutputValue(pin_handle, LOAD1, 0);
|
||||
|
||||
+2
-2
@@ -363,8 +363,8 @@ static void VT_Plot(WorkMode *WorkModeData) {
|
||||
}
|
||||
|
||||
// ADC gain is don't care when measuring voltage
|
||||
INSTRUCTION.ADCGainLevel = I_GAIN_100R;
|
||||
IinADCGainControl(INSTRUCTION.ADCGainLevel);
|
||||
// INSTRUCTION.ADCGainLevel = I_GAIN_100R;
|
||||
// IinADCGainControl(INSTRUCTION.ADCGainLevel);
|
||||
|
||||
static uint8_t ADCSwitch = 0;
|
||||
static int32_t VoltData;
|
||||
|
||||
+3
-3
@@ -4,9 +4,9 @@
|
||||
|
||||
#define VERSION_DATE_YEAR 20
|
||||
#define VERSION_DATE_MONTH 8
|
||||
#define VERSION_DATE_DAY 20
|
||||
#define VERSION_DATE_HOUR 11
|
||||
#define VERSION_DATE_MINUTE 50
|
||||
#define VERSION_DATE_DAY 24
|
||||
#define VERSION_DATE_HOUR 15
|
||||
#define VERSION_DATE_MINUTE 59
|
||||
|
||||
// this is NOT the version hash !!
|
||||
// it's the last version hash
|
||||
|
||||
+5
@@ -1111,6 +1111,7 @@ static void update_ZM_instruction(uint8 *ins) {
|
||||
}
|
||||
PeriodicEvent = true;
|
||||
InitEliteFlag();
|
||||
ELITE15_SPI_HOLD();
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1120,6 +1121,10 @@ static void update_ZM_instruction(uint8 *ins) {
|
||||
}
|
||||
|
||||
case VIS_INT: {
|
||||
if(PeriodicEvent){
|
||||
ELITE15_SPI_CLOSE();
|
||||
}
|
||||
|
||||
Eliteinterrupt();
|
||||
for(int i=0 ; i<12 ; i++){
|
||||
FlushNotify();
|
||||
|
||||
+2
@@ -125,6 +125,7 @@ static void SimpleBLEPeripheral_performPeriodicTask(WorkMode *WorkModeData) {
|
||||
if (INSTRUCTION.Ve1 == INSTRUCTION.Ve2) {
|
||||
DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.Ve1));
|
||||
PeriodicEvent = false;
|
||||
ELITE15_SPI_CLOSE();
|
||||
ModeLED(NO_EVENT);
|
||||
}
|
||||
}
|
||||
@@ -207,6 +208,7 @@ static void SimpleBLEPeripheral_performPeriodicTask(WorkMode *WorkModeData) {
|
||||
DAC_outputV(Usercode_Correction_to_DAC(WorkModeData->VO->_Vset)); //UserCode -> DAC code -> DAC out
|
||||
FreeWorkMode(WorkModeData);
|
||||
PeriodicEvent = false;
|
||||
ELITE15_SPI_CLOSE();
|
||||
}else{
|
||||
InitFlag();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user