Logo Search packages:      
Sourcecode: odyssey version File versions

void Pic18Device::program ( DataBuffer buf  )  [virtual]

Program the contents of the DataBuffer to the device. This performs no erasure or blank check.

Parameters:
buf The DataBuffer containing the data to program.
Precondition:
set_iodevice() must have been called with a valid IO object.
Exceptions:
runtime_error Contains a textual description of the error.

Implements Device.

Definition at line 84 of file Pic18Device.cxx.

References PicDevice::codesize, PicDevice::eesize, PicDevice::flags, PicDevice::memtype, PIC_FEATURE_EEPROM, PicDevice::pic_off(), Device::progress_count, Device::progress_total, PicDevice::set_program_mode(), write_config_memory(), write_data_memory(), write_id_memory(), and write_program_memory().

                                         {
      switch(this->memtype) {
      case MEMTYPE_EPROM:
      case MEMTYPE_FLASH:
            break;
      default:
            throw runtime_error("Unsupported memory type in device");
      }

      /* Progress_total is x2 because we write and verify every location */
      this->progress_total = 2 * (this->codesize + 4 + 7 + this->eesize) - 1;
      this->progress_count = 0;

      try {
            set_program_mode();

            write_program_memory(buf, true);
            write_id_memory(buf, 0x200000, true);
            if(flags & PIC_FEATURE_EEPROM)
                  write_data_memory(buf, 0xf00000, true);
            write_config_memory(buf, 0x300000, true);

            pic_off();
      } catch(std::exception& e) {
            pic_off();
            throw;
      }
}


Generated by  Doxygen 1.6.0   Back to index