Beispiel #1
0
        static void Main(string[] args)
        {
            XmlConfigurator.Configure();
            ModelContainer mc = CreateAndCheckModelContainer();

            if (mc == null)
            {
                Console.WriteLine("See errors and then press any key to exit");
                Console.ReadKey();
                return;
            }
            SourceCodeGenerator.GenerateAppIds_h(mc);
            SourceCodeGenerator.GenerateModel_cpp(mc);
            SourceCodeGenerator.GenerateCommandAndEventTypes_h(mc);
            SourceCodeGenerator.GenerateApplication_H_and_CPP(mc);
            SourceCodeGenerator.GenerateHeaderIncludesForApplications(mc);

            if (Properties.Settings.Default.DoNotCompile)
            {
                return;
            }
            foreach (Node n in mc.Model.Nodes)
            {
                SensactFileCollector p  = new SensactFileCollector();
                CompileOptions       o  = p.BuildCompileOptions(n);
                CompilerController   cc = new CompilerController(o);
                string firmwareBinPath  = Path.Combine(Properties.Settings.Default.SensactDirectory, "firmwareBin", n.Id + ".hex");
                cc.Compile(firmwareBinPath);
            }



            return;
        }
Beispiel #2
0
        public CompileOptions BuildCompileOptions(Node node)
        {
            O = new CompileOptions()
            {
                BoardId  = node.BoardType.ToUpper(),
                RevMajor = node.VersionMajor,
                RevMinor = node.VersionMinor,
                NodeId   = node.Id,
                Chip     = node.Chip,
                Defines  =
                {
                    CompilerController.HSEValue(node.HSEValue)
                },
                CubeMXModulesToInclude = node.CubeMXModules,
                IncDirectories         = new List <string>()
            };
            string firmwaredir = Path.Combine(Properties.Settings.Default.SensactDirectory, "firmware");
            string moddir      = Path.Combine(firmwaredir, "modules");
            string bspDir      = Path.Combine(moddir, "bsp", node.BoardType);

            O.IncDirectories.Add(bspDir);
            foreach (string file in Directory.EnumerateFiles(bspDir))
            {
                AddFile(file);
            }


            string genDir = Path.Combine(moddir, "generated");

            O.IncDirectories.Add(genDir);
            //check if there are hw specific files for each file in the bsp directory
            foreach (string file in Directory.EnumerateFiles(genDir, "*.cpp", SearchOption.TopDirectoryOnly))
            {
                AddFile(file);
            }
            string driversDir = Path.Combine(moddir, "drivers");

            O.IncDirectories.Add(driversDir);
            foreach (Driver driver in  node.Drivers)
            {
                string file = Path.Combine(driversDir, Convert.ToString(driver) + ".cpp");
                if (File.Exists(file))
                {
                    AddFile(file);
                }
                else
                {
                    throw new Exception("HAL file " + file + " does not exist");
                }
            }
            string coreDir = Path.Combine(moddir, "core");

            O.IncDirectories.Add(coreDir);
            foreach (string file in Directory.EnumerateFiles(coreDir, "*.cpp", SearchOption.TopDirectoryOnly))
            {
                AddFile(file);
            }

            return(O);
        }
Beispiel #3
0
 public CompilerController(CompileOptions opts)
 {
     compilerExecutables = new string[]
     {
         Path.Combine(toolchainBinDir, TARGET_TRIPLET + "-gcc" + EXECUTABLE_FILE_SUFFIX),
         Path.Combine(toolchainBinDir, TARGET_TRIPLET + "-g++" + EXECUTABLE_FILE_SUFFIX),
         Path.Combine(toolchainBinDir, TARGET_TRIPLET + "-gcc" + EXECUTABLE_FILE_SUFFIX)
     };
     this.objCopyExe = Path.Combine(toolchainBinDir, TARGET_TRIPLET + "-objcopy" + EXECUTABLE_FILE_SUFFIX);
     this.sizeExe    = Path.Combine(toolchainBinDir, TARGET_TRIPLET + "-size" + EXECUTABLE_FILE_SUFFIX);
     this.o          = opts;
 }
Beispiel #4
0
        public void AddCMSIS(CompileOptions o)
        {
            string DriverPath = Path.Combine(basePath, "Drivers", "CMSIS");

            o.IncDirectories.Add(Path.Combine(DriverPath, "Include"));
            o.IncDirectories.Add(Path.Combine(DriverPath, "Device", "ST", "STM32F1xx", "Include"));
            string srcPath = Path.Combine(DriverPath, "Device", "ST", "STM32F1xx", "Source", "Templates");

            o.SourceFiles.Add(new SourceFile(Path.Combine(srcPath, "system_stm32f1xx.c"), Language.C));
            string startupFilename = string.Format(STARTUP_FILE_PATTERN, (int)o.Chip.Type, o.Chip.Flash.ToString()[1]);

            o.SourceFiles.Add(new SourceFile(Path.Combine(srcPath, "gcc", startupFilename), Language.C));
        }
Beispiel #5
0
        public void AddHal(CompileOptions o)
        {
            string DriverPath = Path.Combine(basePath, "Drivers", "STM32F1xx_HAL_Driver");

            o.IncDirectories.Add(Path.Combine(DriverPath, "inc"));
            string path = Path.Combine(DriverPath, "src", string.Format(HAL_BASE_FILE_PATTERN, (int)STM32_FAMILY.F1));

            o.SourceFiles.Add(new SourceFile(path, Language.C));
            foreach (CubeMXModule mod in o.CubeMXModulesToInclude)
            {
                path = Path.Combine(DriverPath, "src", string.Format(HAL_FILE_PATTERN, (int)STM32_FAMILY.F1, mod));
                o.SourceFiles.Add(new SourceFile(path, Language.C));
            }
        }
Beispiel #6
0
        public override void UpdateOptions(CompileOptions o)
        {
            o.Defines.Add(new Tuple <string, string>("STM32F4", null));
            o.Defines.Add(new Tuple <string, string>("STM32F40" + (int)o.Chip.Type + "xx", null));

            string CmsisPath = Path.Combine(basePath, "Drivers", "CMSIS");

            o.IncDirectories.Add(Path.Combine(CmsisPath, "Include"));
            o.IncDirectories.Add(Path.Combine(CmsisPath, "Device", "ST", "STM32F4xx", "Include"));
            string srcPath = Path.Combine(CmsisPath, "Device", "ST", "STM32F4xx", "Source", "Templates");

            o.SourceFiles.Add(new SourceFile(Path.Combine(srcPath, "system_stm32f4xx.c"), Language.C));
            string startupFilename = string.Format(STARTUP_FILE_PATTERN, (int)o.Chip.Type, o.Chip.Package.ToString().ToLower(), o.Chip.Flash.ToString().ToLower()[1]);
            string startupFilePath = Path.Combine(srcPath, "gcc", startupFilename);

            if (!File.Exists(startupFilePath))
            {
                startupFilename = string.Format(STARTUP_FILE_PATTERN, (int)o.Chip.Type, "x", o.Chip.Flash.ToString().ToLower()[1]);
                startupFilePath = Path.Combine(srcPath, "gcc", startupFilename);
                if (!File.Exists(startupFilePath))
                {
                    startupFilename = string.Format(STARTUP_FILE_PATTERN, (int)o.Chip.Type, o.Chip.Package.ToString().ToLower(), "x");
                    startupFilePath = Path.Combine(srcPath, "gcc", startupFilename);
                    if (!File.Exists(startupFilePath))
                    {
                        startupFilename = string.Format(STARTUP_FILE_PATTERN, (int)o.Chip.Type, "x", "x");
                        startupFilePath = Path.Combine(srcPath, "gcc", startupFilename);
                    }
                }
            }
            o.SourceFiles.Add(new SourceFile(startupFilePath, Language.C));

            string HalPath = Path.Combine(basePath, "Drivers", "STM32F4xx_HAL_Driver");

            o.IncDirectories.Add(Path.Combine(HalPath, "Inc"));
            string path = Path.Combine(HalPath, "Src", HAL_BASE_FILE);

            o.SourceFiles.Add(new SourceFile(path, Language.C));
            foreach (CubeMXModule mod in o.CubeMXModulesToInclude)
            {
                path = Path.Combine(HalPath, "src", string.Format(HAL_FILE_PATTERN, mod));
                o.SourceFiles.Add(new SourceFile(path, Language.C));
            }
        }
Beispiel #7
0
 public abstract void UpdateOptions(CompileOptions o);
Beispiel #8
0
 public override void UpdateOptions(CompileOptions o)
 {
     AddDefines(o);
     AddCMSIS(o);
     AddHal(o);
 }
Beispiel #9
0
 public void AddDefines(CompileOptions o)
 {
     o.Defines.Add(new Tuple <string, string>("STM32F1", null));
     o.Defines.Add(new Tuple <string, string>("STM32F10" + (int)o.Chip.Type + "x" + o.Chip.Flash.ToString()[1], null));
 }