Logo Search packages:      
Sourcecode: odyssey version File versions

PicDevice::PicDevice ( char *  name  ) 

Constructor

Definition at line 77 of file PicDevice.cxx.

References codesize, eesize, erase_time, flags, ConfigFile::get_integer(), ConfigFile::get_string(), memtype, PIC_FEATURE_EEPROM, PIC_REQUIRE_EPROG, program_count, program_multiplier, program_time, READ_PIC_CONFIG_ENTRY_DEFAULT, wordmask, and Device::wordsize.

                               : Device(name) {
      char memtypebuf[10];
      long value;

      this->flags = 0;
      /* Fill in this PIC's common attributes */
      if(! pic_config->get_string(name, "memtype", memtypebuf, sizeof(memtypebuf)))
            throw runtime_error("PIC device is missing memtype configuration parameter");
      if(strcmp(memtypebuf, "eprom") == 0) {
            this->memtype = MEMTYPE_EPROM;
            this->flags |= PIC_REQUIRE_EPROG;
      } else if(strcmp(memtypebuf, "flash") == 0) {
            this->memtype = MEMTYPE_FLASH;
      } else if(strcmp(memtypebuf, "flashe") == 0) {
            this->memtype = MEMTYPE_FLASH;
            this->flags |= PIC_REQUIRE_EPROG;
      } else {
            throw runtime_error("PIC device has an unknown memory type");
      }

      if(! pic_config->get_integer(name, "wordsize", &value))
            throw runtime_error("PIC device has incomplete configuration entry");
      this->wordsize = value;

      if(! pic_config->get_integer(name, "codesize", &value))
            throw runtime_error("PIC device has incomplete configuration entry");
      this->codesize = value;

      if(pic_config->get_integer(name, "eesize", &value) && (value > 0)) {
            this->flags |= PIC_FEATURE_EEPROM;
            this->eesize = value;
      } else {
            this->eesize = 0;
      }

      /* Calculate the word mask */
      this->wordmask = 0;
      for(int i=0; i<this->wordsize; i++) {
            this->wordmask <<= 1;
            this->wordmask |= 0x0001;
      }

      /* Read programming parameters with defaults for an EPROM device */
      READ_PIC_CONFIG_ENTRY_DEFAULT("progcount", program_count, 25);
      READ_PIC_CONFIG_ENTRY_DEFAULT("progmult", program_multiplier, 3);
      READ_PIC_CONFIG_ENTRY_DEFAULT("progtime", program_time, 100);
      READ_PIC_CONFIG_ENTRY_DEFAULT("erasetime", erase_time, 0);
}


Generated by  Doxygen 1.6.0   Back to index