[译]PIC C代码向导
By robot-v1.0
本文链接 https://www.kyfws.com/applications/a-pic-c-code-wizard-zh/
版权声明 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
- 8 分钟阅读 - 3669 个词 阅读量 0[译]PIC C代码向导
原文地址:https://www.codeproject.com/Articles/4081/A-PIC-C-Code-Wizard
原文作者:Carlos Buelna
译文由本站 robot-v1.0 翻译
前言
Creates C code templates for PIC microcontrollers. The default templates are for use with the Hi-Tech (tm) PICC compiler.
为PIC微控制器创建C代码模板.默认模板与高科技(tm)PICC编译器一起使用.
介绍(Introduction)
我为工作中的PIC单片机做了一些C编程.前一段时间,我开发了一个" PIC" C AppWizard(在MS-Visual Studio v6下)来创建C PIC应用程序.现在,我决定使其成为Win32"常规"可执行文件,因此该向导不依赖于Visual Studio IDE.(I do some C programming for PIC microcontrollers at work. Some time ago, I developed a “PIC” C AppWizard (under MS-Visual Studio v6) to create C PIC applications. Now I’ve decided to make it a Win32 “regular” executable so the wizard does not depend on Visual Studio IDE.)
该PIC-C向导使用高科技的PICC编译器(tm)创建用于某些Microchip(tm)PIC单片机的C代码模板.我知道这两个问题限制了该工具的可用性,因此我希望有人觉得它有用.(This PIC-C Wizard creates C code templates to be used for certain Microchip (tm) PIC microcontrollers using the Hi-Tech’s PICC compiler (tm). I know these two issues limit the usability of the tool, so I hope someone finds it useful.)
提供的演示文件是使用此向导创建的演示PIC C项目的一部分.(The demo files provided are part of a demo PIC C project created using this wizard.)
特征(Features)
- GUI界面可帮助用户设置PIC的硬件和软件.(GUI interface to assist the user setup PIC’s hardware and software.)
- 创建C代码模板,对于嵌入式版本,可以使用PICC(tm)编译器进行编译;对于PIC应用程序的PC版本,可以使用Visual C/C ++进行编译.(Creates C code templates that can be compiled with PICC (tm) compiler for the embedded version and Visual C/C++ for the PC version of the PIC’s application.)
- 处理不同的用户.(Handles different users.)
- 创建用于PICC编译的基本make批处理文件和项目文件((Creates a basic make batch file for PICC compilation and a project file ().dsp(.dsp))适用于MS Visual C/C ++ v6.0.() for MS Visual C/C++ v6.0.)
- 用户可以通过编辑文本信息文件来添加或删除PIC micros((User can add or remove PIC micros by editing a text information file ()图片文件(PIC.INF)).().)
- 用户可以修改,添加和/或删除默认的C模板,因此该向导将使用用户的编程样式生成C代码.(Users can modify, add and/or remove the default C templates, so the wizard generates C code with the user’s programming style.)
- 它包括基本的源代码注释,可使用以下内容创建文档(It includes basic source code comments to create documentation using) 氧(doxygen) .(.) 老实说,所有这些功能尚未100%实现,向导可能仍然"笨拙".我将继续进行频繁的更新,因为我仍在进行更新.(To be honest, all these features are not yet implemented 100% and the wizard may still be “buggy”. I’ll be posting frequent updates as I’m still working on it.)
安装(Install)
我尚未为此工具创建安装程序.因此,现在,只需下载它并将其放在您选择的文件夹下即可.我已经在Windows XP,2K和NT SP6下对其进行了测试.(I have not yet created an installer for this tool. So for now, simply download it and place it under a folder of your choice. I have tested it under Windows XP, 2K and NT SP6.)
该向导的工作方式(How This Wizard Works)
用户的文件夹和默认的C模板文件(User’s folder and default C template files)
向导将在向导的根文件夹下创建一个文件夹.该文件夹将被命名为:(The wizard will create a folder under the wizard’s root folder. This folder will be named:) Templates_<username>
.例如,如果实际登录的用户是trinity,则创建的文件夹将是:(. For instance, if the actual logged on user is trinity, the folder created will be:) Templates_trinity
.该向导将在此处放置用于为不同用户创建PIC应用程序的默认C模板和配置文件.如果由于某种原因删除了用户的文件夹,向导将使用默认模板再次创建它.(. This is where the wizard will put the default C templates and configuration files used to create PIC applications for different users. If a user’s folder has been removed for some reason, the wizard will create it again with default templates.)
用户可以修改这些C模板,向导将只替换其中包含的宏.(The user can modify these C templates and the wizard will just replace the macros contained in them.)
这是向导生成的文件的列表:(This is a list of the files generated by the wizard:)
PIC和PC共有:(Common to both PIC and PC:)
-
图片(pic.h):此文件将包含在源文件中,并将加载PICC的文件(: this file will be included in the sources and it’ll load the PICC’s)**图片(pic.h)**要么(or)picpc.h(picpc.h)(对于Win32).((for Win32).)
-
主文件(main.h):此文件将重命名为应用程序的名称.用户可以在此文件中添加特定于应用程序的各种定义.(: this file will be renamed to the application’s name. The user can add all sorts of definitions in this file that are specific to the application.)
-
main.c(main.c):此文件也将被重命名.它将包含C(: this file will also be renamed. It’ll contain the C)
main()
入口点和中断向量,以及基于简单任务调度程序的默认程序结构.用户可以向该文件添加特定于应用程序的代码.(entry point and the interrupt vector, as well as a default program structure based on a simple tasks scheduler. The user can add code to this file that is specific to the application.) -
typedefs.h(typedefs.h):此文件将包含应用程序的嵌入式和Win32版本的通用定义.(:this file will contain common definitions to both the embedded and Win32 versions of the application.)
-
picpcproj.inf(picpcproj.inf):此文件包含哪些模板文件将成为应用程序项目的一部分.它包含有关关键字的简要说明,以指示向导如何创建项目文件.(: this file contains what template files will be part of the application’s project. It contains a brief explanation on the keywords to indicate to the wizard, how to create the project files.)
-
确认(confirm.inf):它包含将在创建项目文件之前显示的文本信息.(: it contains the text information to be displayed just before the creation of the project files.)
-
图片文件(pic.inf):它包含将列出供选择的PIC微控制器的列表.可以修改此文件以添加或删除micros.可以从以下地址获得添加新微控制器所需的信息:(: it contains the list of PIC microcontrollers that are going to be listed for selection. This file can be modified to add or remove micros. The information required to add a new microcontroller can be obtained from a) Microchip的产品线卡(Microchip’s Product Line Card) .(.) 对于PIC编译:(For PIC compilation:)
-
picc.h(picc.h):它将包含更特定于PIC而不是应用程序的定义.(: it will contain definitions more specific to the PIC rather than the application.)
-
picc.c(picc.c):它将包含针对PIC编程的不同支持功能的代码实现,具体取决于用户选择创建应用程序的选项.(: it will contain code implementation of different support functions for PIC programming, depending on which options the user selected to create the application.) 对于PC编译:(For PC compilation:)
-
picpc.h(picpc.h):它将包含更特定于Win32编程的定义.(: it will contain definitions more specific to Win32 programming.)
-
picpc.c(picpc.c):它将包含各种支持功能的代码实现,以尝试模拟PIC的一些外围设备.嗯,没有太多的收获.(: it will contain code implementation of different support functions trying to simulate some of the PIC ’s peripherals. Mmmh, didn’t get much with this.) 您可能想知道,为什么应该将Win32版本的应用程序放入8位微型计算机中?因为这个想法是要在一定程度上调试应用程序,然后才将零和一实际下载到微控制器中.这个想法以前对我来说很有意义,因为在VC下调试起来更容易.但是很快,我得知我缺乏时间和知识来模拟PIC的外围设备.(You may be wondering, why is there a Win32 version of an application that is supposed to go into an 8-bit micro? Because the idea was to debug the application, to some extent, before actually downloading the zeros and ones into the micro. The idea made some sense to me before, as it’s easier to debug under VC. But quickly I learned that I lack the time and knowledge to simulate the PIC’s peripherals.)
好吧,至少它可以帮助我使用基于浮点算法的调试某些应用程序.(Well, at least it helps me to debug certain applications using floating-point based algorithms.)
该向导如何创建PIC应用程序?(How does the wizard create a PIC application?)
由于我已经多次使用Visual C/C ++ AppWizard,因此我的大脑无法想到另一种实现方法,而是模仿了MS-VC的实现方法.当然,与真正的实现相比,我的实现还不够,但是我认为它可以完成工作.因此,该向导基本上会在所有模板文件中查找称为宏的特殊词,并将其替换为用户通过GUI界面提供的值.(Since I’ve used the Visual C/C++ AppWizard several times, my brain could not think of another good way to implement one, but to imitate the way MS-VC does it. Of course my implementation falls short compared to the real one but I think it does the job. So this wizard basically looks for special words, called macros, in all the template files and replace them with values provided by the user through the GUI interface.)
此向导的一个明显优点是,C模板已打开,供用户修改.我的意思是说,我提供了这些C默认模板,这仅反映了我在C编程方面的有限经验.对于初学者来说足够好了.但是对于专家mmh,让我们最好再看看该代码.(One clear advantage of this wizard is that the C templates are open for the user to modify. It makes sense, I mean, I provided these C default templates, which only reflects my limited experience in C programming; good enough for the novice user though. But for the expert, mmh, let’s better have another look at that code.)
现在,对于要开始修改默认模板的人来说,有必要知道所有可用的宏,并且我将在不久的将来将它们包括在本文中.(Now, for someone to start modifying the default templates, it’s necessary to know all the available macros and I’ll include them in this article in the very near future.)
可以将源代码修改为具有另一个向导吗?(Can the source code be modified to have another wizard?)
简短的回答是.很快,我将提供有关如何以及如何修改提供的源代码以具有另一个向导的更多信息.(Short answer is yes. Soon I’ll provide more information on what and how to modify the source code provided to have another wizard.)
如何使用(How To Use)
教程即将推出…(A tutorial will be coming soon…)
修订记录(Revision History)
-
2003年6月6日:(06/MAY/2003:)
- 初始修订.(Initial revision.)
致谢(Acknowledgments)
什么?您真的认为关于向导的唯一很棒的东西是我编写的吗?当然不是,我真的必须感谢这些家伙的出色代码:(What? You really think that the only cool things about the wizard were programmed by me? Of course not, I really must thank these guys for their great code:)
- 克里斯`桑德(Chris Maunder)(Chris Maunder for) CGridCtrl(CGridCtrl)
- Sven Wiegand为(Sven Wiegand for) CTreePropSheet(CTreePropSheet)
许可
本文以及所有相关的源代码和文件均已获得The Code Project Open License (CPOL)的许可。
C++ VC6 WinXP Windows Win2K MFC Visual-Studio Dev 新闻 翻译