   }
 
   Twiddler twiddler_;
-  int current_state_;
+  uint8_t current_state_;
   uint8_t sdrsize_bits_;
   uint8_t sdrsize_bytes_;
   uint8_t repeat_;
-  uint8_t runtest_;
+  uint32_t runtest_;
   bool reached_xcomplete_;
 
   enum {

  bool handle_XSDR() {
    get_next_bytes(tdi_, sdrsize_bytes_);
    DEBUG_BYTES("... sending ", tdi_, sdrsize_bytes_);
    return sdr(true, false);
  }

  bool handle_XRUNTEST() {

// Knows how to set MCU-specific pins in a JTAG-relevant way.
class Twiddler {
 public:
 Twiddler() : portb_(0) {
    DDRB = TMS | TDI | TCK;
  }

  inline void pulse_clock() {
    clr_port(TCK);
    delayMicroseconds(1);
    set_port(TCK);
  }

  bool pulse_clock_and_read_tdo() {
    clr_port(TCK);
    delayMicroseconds(1);
    uint8_t pinb = PINB;
    set_port(TCK);
    return pinb & TDO;
  }

  void wait_time(unsigned long microsec) {
