// deactivate the given channel...note: stops data colleciton to issue its commands // N is the channel number: 1-8 // void ADS1299::deactivateChannel(int N) { byte reg, config; //check the inputs if ((N < 1) || (N > 8)) return; //proceed...first, disable any data collection SDATAC(); delay(1); // exit Read Data Continuous mode to communicate with ADS //shut down the channel N = constrain(N-1,0,7); //subtracts 1 so that we're counting from 0, not 1 reg = CH1SET+(byte)N; // select the current channel config = RREG(reg); delay(1); // get the current channel settings bitSet(config,7); // set bit7 to shut down channel if (use_N_inputs) bitClear(config,3); // clear bit3 to disclude from SRB2 if used WREG(reg,config); delay(1); // write the new value to disable the channel //remove the channel from the bias generation... reg = BIAS_SENSP; // set up to disconnect the P inputs from Bias generation config = RREG(reg); delay(1); //get the current bias settings bitClear(config,N); //clear this channel's bit to remove from bias generation WREG(reg,config); delay(1); //send the modified byte back to the ADS reg = BIAS_SENSN; // set up to disconnect the N inputs from Bias generation config = RREG(reg); delay(1); //get the current bias settings bitClear(config,N); //clear this channel's bit to remove from bias generation WREG(reg,config); delay(1); //send the modified byte back to the ADS };
//Configure the test signals that can be inernally generated by the ADS1299 void ADS1299::configureInternalTestSignal(byte amplitudeCode, byte freqCode) { if (amplitudeCode == ADSTESTSIG_NOCHANGE) amplitudeCode = (RREG(CONFIG2) & (0b00000100)); if (freqCode == ADSTESTSIG_NOCHANGE) freqCode = (RREG(CONFIG2) & (0b00000011)); freqCode &= 0b00000011; //only the last two bits are used amplitudeCode &= 0b00000100; //only this bit is used byte message = 0b11010000 | freqCode | amplitudeCode; //compose the code WREG(CONFIG2,message); delay(1); }
// USE THIS METHOD IF YOU WANT TO CONTROL THE SIGNAL INCLUSION IN SRB AND BIAS GENERATION void ADS1299::activateChannel(int N,byte gainCode,byte inputCode,boolean useInBias) { byte reg, config; //check the inputs if ((N < 1) || (N > 8)) return; //proceed...first, disable any data collection SDATAC(); delay(1); // exit Read Data Continuous mode to communicate with ADS //active the channel using the given gain. Set MUX for normal operation //see ADS1299 datasheet, PDF p44 N = constrain(N-1,0,7); //shift down by one config = 0b00000000; //left-most zero (bit 7) is to activate the channel gainCode = gainCode & 0b01110000; //bitwise AND to get just the bits we want and set the rest to zero config = config | gainCode; //bitwise OR to set just the gain bits high or low and leave the rest inputCode = inputCode & 0b00000111; //bitwise AND to get just the bits we want and set the rest to zero config = config | inputCode; //bitwise OR to set just the gain bits high or low and leave the rest if ((use_SRB2[N]) && useInBias)config |= 0b00001000; //set the SRB2 flag if you plan to use it WREG(CH1SET+(byte)N,config); delay(1); //add this channel to the bias generation //see ADS1299 datasheet, PDF p44 if(useInBias){ reg = BIAS_SENSP; // set up to connect the P inputs for bias generation config = RREG(reg); //get the current bias settings bitSet(config,N); //set this channel's bit to add it to the bias generation WREG(reg,config); delay(1); //send the modified byte back to the ADS reg = BIAS_SENSN; // set up to connect the N input for bias generation config = RREG(reg); //get the current bias settings bitSet(config,N); //set this channel's bit to add it to the bias generation WREG(reg,config); delay(1); //send the modified byte back to the ADS } // // Now, these actions are necessary whenever there is at least one active channel // // though they don't strictly need to be done EVERY time we activate a channel. // // just once after the reset. //activate SRB1 as the Negative input for all channels, if needed // setSRB1(use_SRB1()); setSRB1(false); //Finalize the bias setup...activate buffer and use internal reference for center of bias creation, datasheet PDF p42 WREG(CONFIG3,0b11101100); delay(1); // THIS COULD MOVE TO THE INITIALIZATION };
// Register Read/Write Commands byte ADS1299::getDeviceID() { // simple hello world com check byte data = RREG(0x00); if(verbosity){ // verbosity otuput Serial.print("Device ID "); printHex(data); Serial.println(); } return data; }
static void _stp_print_regs(struct pt_regs * regs) { _stp_printf("RIP: %016lx\nRSP: %016lx\n", RREG(ip, regs), RREG(sp, regs)); _stp_printf("RAX: %016lx RBX: %016lx RCX: %016lx\n", RREG(ax, regs), RREG(bx, regs), RREG(cx, regs)); _stp_printf("RDX: %016lx RSI: %016lx RDI: %016lx\n", RREG(dx, regs), RREG(si, regs), RREG(di, regs)); _stp_printf("RBP: %016lx R08: %016lx R09: %016lx\n", RREG(bp, regs), regs->r8, regs->r9); _stp_printf("R10: %016lx R11: %016lx R12: %016lx\n", regs->r10, regs->r11, regs->r12); _stp_printf("R13: %016lx R14: %016lx R15: %016lx\n", regs->r13, regs->r14, regs->r15); }