adjust more READ again...
This commit is contained in:
+1
@@ -22,6 +22,7 @@ struct _GPT{
|
||||
uint32_t BatteryADCCounter;
|
||||
uint32_t BatteryCheckCounter;
|
||||
uint32_t GptimerMultiple;
|
||||
uint32_t TestCounter;
|
||||
}GPT = {0};
|
||||
|
||||
static void InitCT(){
|
||||
|
||||
+4
-4
@@ -8,12 +8,12 @@ static bool TurnOnElite(uint8_t key) {
|
||||
if (key == 0) {
|
||||
// press 1 sec, power on LED, read bat power
|
||||
if (TurnOnCounter >= CLOCK_ONE_SECOND) {
|
||||
PIN_setOutputValue(pin_handle, AD_reset, 0);
|
||||
CPUdelay(100);
|
||||
// PIN_setOutputValue(pin_handle, AD_reset, 0);
|
||||
// CPUdelay(100);
|
||||
// PIN_setOutputValue(pin_handle, AD_reset, 1);
|
||||
PIN_setOutputValue(pin_handle, enable_5v, 1); // enable 5V
|
||||
PIN_setOutputValue(pin_handle, AD_reset, 1);
|
||||
Elite_SPI_init();
|
||||
AD5940_init();
|
||||
// AD5940_init();
|
||||
ModeLED(BT_WAIT);
|
||||
// DAC_outputV(0x3FFFF);
|
||||
return true;
|
||||
|
||||
+118
-28
@@ -117,14 +117,18 @@ static void CAL_LED_SPI(uint8_t length, uint16_t *spi_txbuf, uint16_t *spi_rxbuf
|
||||
|
||||
static void select_REG(uint16_t addr){
|
||||
PIN_setOutputValue(pin_handle, Board_SPI1_CS, 0);
|
||||
CPUdelay(100);
|
||||
spi_DACtxbuf[0] = SPICMD_SETADDR;
|
||||
CPUdelay(100);
|
||||
spi_DACtxbuf[1] = (uint8_t)((addr & 0xFF00) >> 8);
|
||||
CPUdelay(100);
|
||||
spi_DACtxbuf[2] = (uint8_t)(addr & 0x00FF);
|
||||
|
||||
ADC_DAC_transaction.count = 3;
|
||||
ADC_DAC_transaction.txBuf = spi_DACtxbuf;
|
||||
ADC_DAC_transaction.rxBuf = spi_rxbuf;
|
||||
SPI_transfer(spiHandle1, &ADC_DAC_transaction);
|
||||
CPUdelay(100);
|
||||
PIN_setOutputValue(pin_handle, Board_SPI1_CS, 1);
|
||||
}
|
||||
|
||||
@@ -191,38 +195,124 @@ static void r32_REG(){
|
||||
}
|
||||
|
||||
static void AD5940_init(){
|
||||
select_REG(0x0908);//initiation
|
||||
w16_REG(0x02C9);
|
||||
select_REG(0x0C08);
|
||||
w16_REG(0x206C);
|
||||
select_REG(0x21F0);
|
||||
w16_REG(0x0010);
|
||||
select_REG(0x0410);
|
||||
w16_REG(0x02C9);
|
||||
select_REG(0x0A28);
|
||||
w16_REG(0x0009);
|
||||
select_REG(0x238C);
|
||||
w16_REG(0x0104);
|
||||
select_REG(0x0A04);
|
||||
w16_REG(0x4859);
|
||||
select_REG(0x0A04);
|
||||
w16_REG(0xF27B);
|
||||
select_REG(0x0A00);
|
||||
w16_REG(0x8009);
|
||||
select_REG(0x22F0);
|
||||
w16_REG(0x0000);
|
||||
static uint16_t writeWhere = 0;
|
||||
if(writeWhere == 0){
|
||||
PIN_setOutputValue(pin_handle, AD_reset, 0);
|
||||
writeWhere = 1;
|
||||
}
|
||||
else if(writeWhere == 1){
|
||||
PIN_setOutputValue(pin_handle, AD_reset, 1);
|
||||
writeWhere = 2;
|
||||
}
|
||||
else if(writeWhere == 2){
|
||||
select_REG(0x0908);//initiation
|
||||
w16_REG(0x02C9);
|
||||
writeWhere = 3;
|
||||
}
|
||||
else if(writeWhere == 3){
|
||||
select_REG(0x0C08);
|
||||
w16_REG(0x206C);
|
||||
writeWhere = 4;
|
||||
}
|
||||
else if(writeWhere == 4){
|
||||
select_REG(0x21F0);
|
||||
w16_REG(0x0010);
|
||||
writeWhere = 5;
|
||||
}
|
||||
else if(writeWhere == 5){
|
||||
select_REG(0x0410);
|
||||
w16_REG(0x02C9);
|
||||
writeWhere = 6;
|
||||
}
|
||||
else if(writeWhere == 6){
|
||||
select_REG(0x0A28);
|
||||
w16_REG(0x0009);
|
||||
writeWhere = 7;
|
||||
}
|
||||
else if(writeWhere == 7){
|
||||
select_REG(0x238C);
|
||||
w16_REG(0x0104);
|
||||
writeWhere = 8;
|
||||
}
|
||||
else if(writeWhere == 8){
|
||||
select_REG(0x0A04);
|
||||
w16_REG(0x4859);
|
||||
writeWhere = 9;
|
||||
}
|
||||
else if(writeWhere == 9){
|
||||
select_REG(0x0A04);
|
||||
w16_REG(0xF27B);
|
||||
writeWhere = 10;
|
||||
}
|
||||
else if(writeWhere == 10){
|
||||
select_REG(0x0A00);
|
||||
w16_REG(0x8009);
|
||||
writeWhere = 11;
|
||||
}
|
||||
else if(writeWhere == 11){
|
||||
select_REG(0x0A04);
|
||||
w16_REG(0x4859);
|
||||
writeWhere = 12;
|
||||
}
|
||||
else if(writeWhere == 12){
|
||||
select_REG(0x22F0);
|
||||
w16_REG(0x0000);
|
||||
writeWhere = 13;
|
||||
}
|
||||
else if(writeWhere == 13){
|
||||
select_REG(0x22F0);
|
||||
r16_REG();
|
||||
writeWhere = 20;
|
||||
}
|
||||
|
||||
select_REG(0x2000);//configuration register
|
||||
w32_REG(0x80000);
|
||||
select_REG(0x22F0);//Power modes configuration register
|
||||
w32_REG(0x88800);
|
||||
r32_REG();
|
||||
}
|
||||
|
||||
static void EIS_LPDAC_SPI(uint32_t volt){
|
||||
// select_REG(0x0908);//initiation
|
||||
// w16_REG(0x02C9);
|
||||
// select_REG(0x0C08);
|
||||
// w16_REG(0x206C);
|
||||
// select_REG(0x21F0);
|
||||
// w16_REG(0x0010);
|
||||
// select_REG(0x0410);
|
||||
// w16_REG(0x02C9);
|
||||
// select_REG(0x0A28);
|
||||
// w16_REG(0x0009);
|
||||
// select_REG(0x238C);
|
||||
// w16_REG(0x0104);
|
||||
// select_REG(0x0A04);
|
||||
// w16_REG(0x4859);
|
||||
// select_REG(0x0A04);
|
||||
// w16_REG(0xF27B);
|
||||
// select_REG(0x0A00);
|
||||
// w16_REG(0x8009);
|
||||
// select_REG(0x22F0);
|
||||
// w16_REG(0x0000);
|
||||
//
|
||||
// select_REG(0x2000);//configuration register
|
||||
// w32_REG(0x80000);
|
||||
// select_REG(0x22F0);//Power modes configuration register
|
||||
// w32_REG(0x88800);
|
||||
// r32_REG();
|
||||
uint32_t con = 0b00001;//12 bit DAC
|
||||
uint32_t sw = 0b01010;//test mode
|
||||
volt = 0x3FFFF;//2.4v
|
||||
uint32_t volt = 0x3FFFF;//2.4v
|
||||
uint32_t buf = 0;//LP reference
|
||||
uint32_t cm = 0;//common mode disabled
|
||||
select_REG(LPDACCON0);
|
||||
w32_REG(con);
|
||||
select_REG(LPDACSW0);
|
||||
w32_REG(sw);
|
||||
select_REG(LPDACDAT0);
|
||||
w32_REG(volt);
|
||||
select_REG(LPREFBUFCON);
|
||||
w32_REG(buf);
|
||||
select_REG(SWMUX);
|
||||
w32_REG(cm);
|
||||
}
|
||||
|
||||
static void EIS_LPDAC_SPI(){
|
||||
uint32_t con = 0b00001;//12 bit DAC
|
||||
uint32_t sw = 0b01010;//test mode
|
||||
uint32_t volt = 0x3FFFF;//2.4v
|
||||
uint32_t buf = 0;//LP reference
|
||||
uint32_t cm = 0;//common mode disabled
|
||||
select_REG(LPDACCON0);
|
||||
|
||||
+12
@@ -560,6 +560,7 @@ static void SimpleBLEPeripheral_taskFxn(UArg a0, UArg a1) {
|
||||
|
||||
// Application main loops
|
||||
GPT.GptimerCounter0 = GPT.GptimerCounter;
|
||||
GPT.TestCounter = 0;
|
||||
batteryADC_flag = false;
|
||||
// headstage_battery_volt();
|
||||
headstage_init_device_info();
|
||||
@@ -622,6 +623,17 @@ static void SimpleBLEPeripheral_taskFxn(UArg a0, UArg a1) {
|
||||
counter6994++;
|
||||
}
|
||||
EliteKeyPress(key);
|
||||
|
||||
|
||||
GPT.DeltaGptimerCounter = GPT.GptimerCounter - GPT.GptimerCounter0;
|
||||
GPT.GptimerCounter0 = GPT.GptimerCounter;
|
||||
|
||||
GPT.TestCounter = GPT.TestCounter + GPT.DeltaGptimerCounter;
|
||||
if(GPT.TestCounter >= 100){
|
||||
GPT.TestCounter = 0; //To get right data, ADC must be delay 1.5ms
|
||||
AD5940_init();
|
||||
}
|
||||
|
||||
// if(key != 0){ //detect Elite battery power when no periodic event
|
||||
// measureBat();
|
||||
// }
|
||||
|
||||
Reference in New Issue
Block a user