Beispiel #1
0
        public static DeviceBits Parse(XElement xBits)
        {
            var res = new DeviceBits();

            var xPage     = xBits.Attribute("page");
            var xLocation = xBits.Attribute("location");

            res.PageSize = xPage != null?int.Parse(xPage.Value) : 1;

            res.Location = xLocation != null ? new AvrMemoryType?((AvrMemoryType)Enum.Parse(typeof(AvrMemoryType), xLocation.Value, true)) : null;
            foreach (var xBit in xBits.Elements())
            {
                res.Groups.Add(DeviceBitsGroup.From(xBit));
            }
            return(res);
        }
Beispiel #2
0
        public static DeviceInfo From(XElement node)
        {
            var xName = node.Attribute("name");

            var xFlash     = node.Element("flash");
            var xEeprom    = node.Element("eeprom");
            var xRam       = node.Attribute("ram");
            var xSignature = node.Attribute("signature");
            var xLockBits  = node.Element("lockBits");
            var xFuseBits  = node.Element("fuseBits");
            var xStkCode   = node.Attribute("stkCode");
            var res        = new DeviceInfo {
                Name   = xName != null ? xName.Value : "unknown",
                _flash = xFlash != null?DeviceFlashParameters.From(xFlash) : new DeviceFlashParameters(),
                             _eeprom = xEeprom != null?DeviceEepromParameters.From(xEeprom) : new DeviceEepromParameters(),
                                           RamSize = xRam != null?int.Parse(xRam.Value) : 0,
                                                         Signature = xSignature != null?AvrSignature.Parse(xSignature.Value) : new AvrSignature(),
                                                                         _lockBits = xLockBits != null?DeviceBits.Parse(xLockBits) : new DeviceBits(),
                                                                                         _fuseBits = xFuseBits != null?DeviceBits.Parse(xFuseBits) : new DeviceBits(),
                                                                                                         StkCode = xStkCode != null?ParseStkCode(xStkCode.Value) : StkDeviceCode.None,
            };

            var xMasks = node.Element("masks");

            if (xMasks != null)
            {
                foreach (var xMask in xMasks.Elements())
                {
                    var mask = MemoryMask.From(xMask);
                    res.Masks.Add(mask);
                }
            }
            return(res);
        }