示例#1
0
文件: Program.cs 项目: xllj/BSPTools
        private static IEnumerable <MCUDefinitionWithPredicate> ParsePeripheralRegisters(string dir, MCUFamilyBuilder fam)
        {
            var mainClassifier = fam.Definition.Subfamilies.First(f => f.IsPrimary);
            List <Task <MCUDefinitionWithPredicate> > tasks = new List <Task <MCUDefinitionWithPredicate> >();

            Console.Write("Parsing {0} registers in background threads", fam.Definition.Name);
            RegisterParserErrors errors = new RegisterParserErrors();

            foreach (var fn in Directory.GetFiles(dir, "*.h"))
            {
                string subfamily = Path.GetFileNameWithoutExtension(fn);
                if (subfamily.Length != 11 && subfamily.Length != 12)
                {
                    continue;
                }

                /*if (subfamily != "stm32f301x8")
                 * continue;*/

                Func <MCUDefinitionWithPredicate> func = () =>
                {
                    RegisterParserConfiguration cfg = XmlTools.LoadObject <RegisterParserConfiguration>(fam.BSP.Directories.RulesDir + @"\PeripheralRegisters.xml");
                    var r = new MCUDefinitionWithPredicate
                    {
                        MCUName        = subfamily,
                        RegisterSets   = PeripheralRegisterGenerator.GenerateFamilyPeripheralRegisters(fn, cfg, errors, fam.MCUs[0].Core),
                        MatchPredicate = m => StringComparer.InvariantCultureIgnoreCase.Compare(mainClassifier.TryMatchMCUName(m.Name), subfamily) == 0,
                    };
                    Console.Write(".");
                    return(r);
                };

                //  func();
                tasks.Add(Task.Run(func));
            }

            Task.WaitAll(tasks.ToArray());
            var errorCnt = errors.ErrorCount;

            if (errorCnt != 0)
            {
                // throw new Exception("Found " + errorCnt + " errors while parsing headers");

                for (int i = 0; i < errors.ErrorCount; i++)
                {
                    Console.WriteLine("\n er  " + i + "  -  " + errors.DetalErrors(i));
                }
            }

            Console.WriteLine("done");
            return(from r in tasks select r.Result);
        }
示例#2
0
        private static IEnumerable <MCUDefinitionWithPredicate> ParsePeripheralRegisters(string dir)
        {
            List <MCUDefinitionWithPredicate> RegistersPeriphs = new List <MCUDefinitionWithPredicate>();
            MCUDefinitionWithPredicate        mcu_def          = new MCUDefinitionWithPredicate
            {
                MCUName        = "RM57L843ZWT",
                RegisterSets   = null,
                MatchPredicate = null
            };

            RegistersPeriphs.Add(mcu_def);
            return(RegistersPeriphs);
        }
示例#3
0
        //---------------------------------
        private static IEnumerable <MCUDefinitionWithPredicate> ParsePeripheralRegisters(string dir)
        {
            List <MCUDefinitionWithPredicate> RegistersPeriphs = new List <MCUDefinitionWithPredicate>();
            MCUDefinitionWithPredicate        mcu_def          = new MCUDefinitionWithPredicate
            {
                MCUName        = "CC_3200",
                RegisterSets   = PeripheralRegisterGenerator.GeneratePeripheralRegisters(dir),
                MatchPredicate = null
            };

            RegistersPeriphs.Add(mcu_def);
            return(RegistersPeriphs);
        }
示例#4
0
        private static IEnumerable <MCUDefinitionWithPredicate> ParsePeripheralRegisters(string dir, MCUFamilyBuilder fam)
        {
            List <MCUDefinitionWithPredicate>          RegistersPeriphs = new List <MCUDefinitionWithPredicate>();
            Dictionary <string, HardwareRegisterSet[]> periphs          = PeripheralRegisterGenerator.GenerateFamilyPeripheralRegistersEFM32(dir + "\\Include", fam.Definition.FamilySubdirectory);

            foreach (var subfamily in periphs.Keys)
            {
                MCUDefinitionWithPredicate mcu_def = new MCUDefinitionWithPredicate {
                    MCUName = subfamily, RegisterSets = periphs[subfamily], MatchPredicate = m => (subfamily == m.Name),
                };
                RegistersPeriphs.Add(mcu_def);
            }
            return(RegistersPeriphs);
        }
示例#5
0
        private static IEnumerable <MCUDefinitionWithPredicate> ParsePeripheralRegisters(string dir, MCUFamilyBuilder fam, string specificDevice, ParseReportWriter writer)
        {
            List <MCUDefinitionWithPredicate> result = new List <MCUDefinitionWithPredicate>();
            string subfamilySuffix = "";

            if (fam.Definition.Name.EndsWith("_M4"))
            {
                subfamilySuffix += "_m4";
            }

            Console.Write("Parsing {0} registers using the new parsing logic...", fam.Definition.Name);
            foreach (var fn in Directory.GetFiles(dir, "*.h"))
            {
                string subfamily            = Path.GetFileNameWithoutExtension(fn);
                string subfamilyForMatching = subfamily;
                if (subfamily.Length != 11 && subfamily.Length != 12)
                {
                    if (subfamily.EndsWith("_cm4", StringComparison.InvariantCultureIgnoreCase))
                    {
                        //This is a header file for the Cortex-M4 core of an STM32MP1 device
                        subfamilyForMatching = subfamily.Substring(0, subfamily.Length - 4);
                    }
                    else
                    {
                        continue;
                    }
                }

                if (specificDevice != null && subfamily != specificDevice)
                {
                    continue;
                }

                var r = new MCUDefinitionWithPredicate
                {
                    MCUName        = subfamily + subfamilySuffix,
                    RegisterSets   = PeripheralRegisterGenerator2.GeneratePeripheralRegisterDefinitionsFromHeaderFile(fn, fam.MCUs[0].Core, writer),
                    MatchPredicate = m => StringComparer.InvariantCultureIgnoreCase.Compare(GetSubfamilyDefine(m), subfamilyForMatching) == 0,
                };

                result.Add(r);
            }

            Console.WriteLine("done");
            return(result);
        }
示例#6
0
        private static IEnumerable <MCUDefinitionWithPredicate> ParsePeripheralRegisters(string dir, MCUFamilyBuilder fam)
        {
            List <MCUDefinitionWithPredicate>          RegistersPeriphs = new List <MCUDefinitionWithPredicate>();
            Dictionary <string, HardwareRegisterSet[]> periphs          = PeripheralRegisterGenerator.GenerateFamilyPeripheralRegistersAtmel(dir + "\\" + fam.Definition.FamilySubdirectory + "\\Utils\\Include", fam.FamilyFilePrefix);

            //      Dictionary<string, HardwareRegisterSet[]> periphs;
            if (fam.FamilyFilePrefix.Contains("SAMl21"))
            {
                periphs = periphs.Concat(PeripheralRegisterGenerator.GenerateFamilyPeripheralRegistersAtmel(dir + "\\" + fam.Definition.FamilySubdirectory + "\\Utils\\Include_b", fam.FamilyFilePrefix)).ToDictionary(v => v.Key, v => v.Value);
            }
            foreach (var subfamily in periphs.Keys)
            {
                MCUDefinitionWithPredicate mcu_def = new MCUDefinitionWithPredicate {
                    MCUName = subfamily, RegisterSets = periphs[subfamily], MatchPredicate = m => (subfamily == m.Name.Substring(2)),
                };
                RegistersPeriphs.Add(mcu_def);
            }
            return(RegistersPeriphs);
        }
示例#7
0
        private static IEnumerable<MCUDefinitionWithPredicate> ParsePeripheralRegisters(string dir, MCUFamilyBuilder fam)
        {
            List<MCUDefinitionWithPredicate> RegistersPeriphs = new List<MCUDefinitionWithPredicate>();

            Dictionary<string, HardwareRegisterSet[]> periphs = PeripheralRegisterGenerator.GenerateFamilyPeripheralRegisters(dir);

            foreach (var subfamily in periphs.Keys)
            {
                MCUDefinitionWithPredicate mcu_def = new MCUDefinitionWithPredicate { MCUName = subfamily, RegisterSets = periphs[subfamily], MatchPredicate = m => GytTypMcuFile(subfamily,m.Name), };
                RegistersPeriphs.Add(mcu_def);
            }
                return RegistersPeriphs;
        }
示例#8
0
        //---------------------------------
        private static IEnumerable<MCUDefinitionWithPredicate> ParsePeripheralRegisters(string dir)
        {
            List<MCUDefinitionWithPredicate> RegistersPeriphs = new List<MCUDefinitionWithPredicate>();
            MCUDefinitionWithPredicate mcu_def = new MCUDefinitionWithPredicate
            {
                MCUName = "CC_3200",
                RegisterSets = PeripheralRegisterGenerator.GeneratePeripheralRegisters(dir),
                MatchPredicate = null
            };

            RegistersPeriphs.Add(mcu_def);
            return RegistersPeriphs;
        }
示例#9
0
 private static IEnumerable<MCUDefinitionWithPredicate> ParsePeripheralRegisters(string dir, MCUFamilyBuilder fam)
 {
     List<MCUDefinitionWithPredicate> RegistersPeriphs = new List<MCUDefinitionWithPredicate>();
     Dictionary<string, HardwareRegisterSet[]> periphs = PeripheralRegisterGenerator.GenerateFamilyPeripheralRegistersAtmel(dir +"\\"+ fam.Definition.FamilySubdirectory+ "\\Utils\\Include",fam.FamilyFilePrefix);
       //      Dictionary<string, HardwareRegisterSet[]> periphs;
         if (fam.FamilyFilePrefix.Contains("SAMl21"))
          periphs = periphs.Concat(PeripheralRegisterGenerator.GenerateFamilyPeripheralRegistersAtmel(dir + "\\" + fam.Definition.FamilySubdirectory + "\\Utils\\Include_b", fam.FamilyFilePrefix)).ToDictionary(v => v.Key, v => v.Value);
     foreach (var subfamily in periphs.Keys)
     {
         MCUDefinitionWithPredicate mcu_def = new MCUDefinitionWithPredicate { MCUName = subfamily, RegisterSets = periphs[subfamily], MatchPredicate = m => ( subfamily == m.Name.Substring(2)), };
         RegistersPeriphs.Add(mcu_def);
     }
     return RegistersPeriphs;
 }
示例#10
0
        private static IEnumerable<MCUDefinitionWithPredicate> ParsePeripheralRegisters(string dir, MCUFamilyBuilder fam)
        {
            var mainClassifier = fam.Definition.Subfamilies.First(f => f.IsPrimary);
            List<Task<MCUDefinitionWithPredicate>> tasks = new List<Task<MCUDefinitionWithPredicate>>();
            Console.Write("Parsing {0} registers in background threads", fam.Definition.Name);
            RegisterParserErrors errors = new RegisterParserErrors();

            foreach (var fn in Directory.GetFiles(dir, "*.h"))
            {
                string subfamily = Path.GetFileNameWithoutExtension(fn);
                if (subfamily.Length != 11 && subfamily.Length != 12)
                    continue;

                /*if (subfamily != "stm32f301x8")
                 continue;*/

                Func<MCUDefinitionWithPredicate> func = () =>
                    {
                        RegisterParserConfiguration cfg = XmlTools.LoadObject<RegisterParserConfiguration>(fam.BSP.Directories.RulesDir + @"\PeripheralRegisters.xml");
                        var r = new MCUDefinitionWithPredicate
                            {
                                MCUName = subfamily,
                                RegisterSets = PeripheralRegisterGenerator.GenerateFamilyPeripheralRegisters(fn, cfg, errors,fam.MCUs[0].Core),
                                MatchPredicate = m => StringComparer.InvariantCultureIgnoreCase.Compare(mainClassifier.TryMatchMCUName(m.Name), subfamily) == 0,
                            };
                        Console.Write(".");
                        return r;
                    };

            //  func();
              tasks.Add(Task.Run(func));
            }

               Task.WaitAll(tasks.ToArray());
            var errorCnt = errors.ErrorCount;
            if (errorCnt != 0)
            {
                throw new Exception("Found " + errorCnt + " errors while parsing headers");

                //   for (int i = 0; i < errors.ErrorCount;i++)
                //     Console.WriteLine("\n er  " + i + "  -  " + errors.DetalErrors(i));

            }

            Console.WriteLine("done");
            return from r in tasks select r.Result;
        }