Example #1
0
        /// <summary>
        /// Renders the Device Configuration Register states given its content.
        /// </summary>
        /// <param name="dcr">The Device Configuration Register of interest.</param>
        /// <param name="value">The value assigned to this register.</param>
        /// <returns>
        /// A human-readable string describing the configuration bits/fuses.
        /// </returns>
        public string Render(PICDevConfigRegister dcr, uint value)
        {
            value &= (uint)dcr.Impl;
            var ilg = dcr.Illegals.FirstOrDefault(p => p.Match(value));

            if (ilg != null)
            {
                return($"** Fuse=0x{value:X}: {ilg.Descr}**");
            }
            var sems = dcr.Fields.Select(f => f.GetSemantic((uint)((value >> f.BitPos) & f.BitMask)));
            var flds = dcr.Fields.Zip(sems, (fl, se) => fl.Name + "=" + se.State);

            return(String.Join(", ", flds));
        }
Example #2
0
        private PICDeviceConfigDefs(IPICDescriptor thePIC)
        {
            dcregisters = new SortedList <Address, PICDevConfigRegister>();
            foreach (var fuse in thePIC.ConfigurationFuses)
            {
                var dcreg = new PICDevConfigRegister(fuse);

                foreach (var dcilg in fuse.IllegalSettings)
                {
                    dcreg.AddIllegal(new DevConfigIllegal(dcilg));
                }
                foreach (var dcfld in fuse.ConfigFields.Where(f => !(f.IsHidden || f.IsLangHidden)))
                {
                    var dcrfdef = new DevConfigField(dcfld, dcreg.Address);
                    foreach (var dcsem in dcfld.Semantics)
                    {
                        dcrfdef.AddSemantic(new DevConfigSemantic(dcsem));
                    }
                    dcreg.AddField(dcrfdef);
                }
                dcregisters.Add(dcreg.Address, dcreg);
            }
        }