<commit_before>
byte moduloReplacement;
 
/******* SETUP *********/
 
void setup()
{
  // Defining PB1 and PB2 as outputs by setting PORTB1 and PORTB2
  // Setting DDB1 and DDB2
  DDRB |= bit (DDB1) | bit (DDB2);

  //Set D pins to input
  DDRD = 0x00;

  Serial.begin(230400);
  //Serial.println("Starting...");
  
  setupClockSignals();
  enableInterrupts();
} 

void setupClockSignals() {
    // stop timer 1
  TCCR1A = 0;
  TCCR1B = 0;

  TCCR1A = bit (COM1B0) | bit (COM1B1)  // Set OC1B on Compare Match, clear
           // OC1B at BOTTOM (inverting mode)
           | bit (COM1A1)                 // Clear OC1A on Compare Match, set
           // OC1A at BOTTOM (non-inverting mode)
           | bit (WGM11) | bit (WGM13);                 // Fast PWM, top at ICR1
  TCCR1B = bit (WGM12)  | bit (WGM13)   //       ditto
           | bit (CS11);                  // Start timer, prescaler of 8

  // Initialize OCR1A = 300 (pulse_width = 150us), OCR1B, and ICR1
  ICR1 = 15;
  OCR1B = 7;
  OCR1A = 7;
//   ICR1 = 45;
//  OCR1B = 22;
//  OCR1A = 22;
}

void enableInterrupts(){
    // enable timer compare interrupt
  TIMSK1 |= (1 << OCIE1A);
  sei();
}

/******** Interrupt Callback and helpers ********/

ISR(TIMER1_COMPA_vect) {
  static byte currentByte = 0x00; 
  byte pinVal = PIND >> 7;
  boolean byteReady = collectBit(pinVal, &currentByte);
 
//  PORTD = 0b00000100;
//  delayMicroseconds(1);
//  PORTD = 0b00000000;
 
  if (byteReady){
    Serial.write(currentByte);
    currentByte = 0;
  }
}

//@return true if byte is full/complete
boolean collectBit(byte inputBit, byte *currentByte){
  static int bitCounter = 0;
  *currentByte |= inputBit << bitCounter;
  //modulo is very slow, so we do a bitwise operation. Equivelant to % 8
   bitCounter = (++bitCounter) & 0b00000111; 
  
  if (bitCounter == 0) {
    return true;
  }
  return false;
}

void loop()
{
}<commit_msg>Update no conditioning code to read from both even and odd pins<commit_after>
byte moduloReplacement;
 
/******* SETUP *********/
 
void setup()
{
  // Defining PB1 and PB2 as outputs by setting PORTB1 and PORTB2
  // Setting DDB1 and DDB2
  DDRB |= bit (DDB1) | bit (DDB2);

  //Set D pins to input
  DDRD = 0x00;

  Serial.begin(2000000);
  //Serial.println("Starting...");
  
  setupClockSignals();
  enableInterrupts();
} 

void setupClockSignals() {
    // stop timer 1
  TCCR1A = 0;
  TCCR1B = 0;

  TCCR1A = bit (COM1B0) | bit (COM1B1)  // Set OC1B on Compare Match, clear
           // OC1B at BOTTOM (inverting mode)
           | bit (COM1A1)                 // Clear OC1A on Compare Match, set
           // OC1A at BOTTOM (non-inverting mode)
           | bit (WGM11) | bit (WGM13);                 // Fast PWM, top at ICR1
  TCCR1B = bit (WGM12)  | bit (WGM13)   //       ditto
           | bit (CS11);                  // Start timer, prescaler of 8

  // Initialize OCR1A = 300 (pulse_width = 150us), OCR1B, and ICR1
  ICR1 = 15;
  OCR1B = 7;
  OCR1A = 7;

//   ICR1 = 45;
//  OCR1B = 22;
//  OCR1A = 22;
}

void enableInterrupts(){
    // enable timer compare interrupt
  TIMSK1 |= (1 << OCIE1A);
  sei();
}

/******** Interrupt Callback and helpers ********/

ISR(TIMER1_COMPA_vect) {
  static byte currentByte = 0x00; 
  byte pinVals = (PIND >> 6) & 0b00000011;
  boolean byteReady = collectBits(pinVals, &currentByte);
 
//  PORTD = 0b00000100;
//  delayMicroseconds(1);
//  PORTD = 0b00000000;
 
  if (byteReady){
    Serial.write(currentByte);
    currentByte = 0;
  }
}

//@return true if byte is full/complete
boolean collectBits(byte inputBits, byte *currentByte){
  static int bitCounter = 0;
  *currentByte |= inputBits << bitCounter;
  bitCounter += 2;

  //modulo is very slow, so we do a bitwise operation. Equivelant to % 8
  bitCounter = bitCounter & 0b00000111; 
  
  if (bitCounter == 0) {
    return true;
  }
  return false;
}

void loop()
{
}
{'fraction_non_alphanumeric': 0.13657527159855148, 'fraction_numerical': 0.06026901189860321, 'mean_word_length': 2.416077738515901, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3016236', 'n_tokens_mistral': 1618, 'n_tokens_neox': 1416, 'n_words': 408}