Logo Search packages:      
Sourcecode: odyssey version File versions

uint32_t IO::shift_bits_in ( int  numbits,
int  tdly = 0 
) [virtual, inherited]

Reads a stream of up to 32 bits from the data signal, clocked by us controlling the clock signal. The bits are received LSB first and are read tdly microseconds after the rising edge of the clock.

Parameters:
numbits The number of bits to read in and return.
tdly The delay time (microseconds) from the clock's rising edge to data valid (from the device).
Returns:
The bits which were read.

Definition at line 123 of file IO.cxx.

References IO::read_data(), IO::set_clk(), IO::set_data(), IO::tdly_stretch, and IO::usleep().

Referenced by Pic16Device::read_ee_data(), PicDevice::read_prog_data(), and Pic18Device::write_command_read_data().

                                                {
      uint32_t data, mask;

      data = 0;
      mask = 0x00000001;
      this->set_data(true);
      while(numbits > 0) {
            this->set_clk(true);
            this->usleep(tdly + this->tdly_stretch);
            if(this->read_data())
                  data |= mask;
            this->set_clk(false);
            this->usleep(tdly + this->tdly_stretch);
            mask <<= 1;
            numbits--;
      }
      this->set_data(false);
      return data;
}


Generated by  Doxygen 1.6.0   Back to index