﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-Good Good code,Day Day up-文章分类-DSP</title><link>http://www.cppblog.com/dawnbreak/category/21077.html</link><description>PearLi's Blog</description><language>zh-cn</language><lastBuildDate>Tue, 07 Apr 2015 22:07:46 GMT</lastBuildDate><pubDate>Tue, 07 Apr 2015 22:07:46 GMT</pubDate><ttl>60</ttl><item><title>TI XDC介绍</title><link>http://www.cppblog.com/dawnbreak/articles/210271.html</link><dc:creator>pear_li</dc:creator><author>pear_li</author><pubDate>Tue, 07 Apr 2015 12:55:00 GMT</pubDate><guid>http://www.cppblog.com/dawnbreak/articles/210271.html</guid><wfw:comment>http://www.cppblog.com/dawnbreak/comments/210271.html</wfw:comment><comments>http://www.cppblog.com/dawnbreak/articles/210271.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/dawnbreak/comments/commentRss/210271.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/dawnbreak/services/trackbacks/210271.html</trackback:ping><description><![CDATA[<span style="color: #362e2b; font-family: Arial; line-height: 26px;">XDC是TI公司为嵌入式实时系统可重用软件组件（在XDC里被成为packages，以下成为包）制定的一套标准。它包括一些有用的工具，标准的API函数，静态配置文件和打包（packaging）操作。XDC最主要的亮点在于它标准化了传递过程，并简化了在应用程序中引用目标平台下其他包的过程。</span>
<p style="color: #362e2b; font-family: Arial; line-height: 26px; background-color: #ffffff;">&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr><span>&nbsp;本文从一个简单的&#8220;Hello，World&#8220;入手，引领大家进入XDC开发世界。</span></p>
<p style="color: #362e2b; font-family: Arial; line-height: 26px; background-color: #ffffff;">&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr><span>&nbsp;在XDC开发世界中，首先需要明确两个概念，package和repository。</span></p>
<p style="color: #362e2b; font-family: Arial; line-height: 26px; background-color: #ffffff;">&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr><span>&nbsp;所谓package，类似与java里的jar文件或.net世界里的assembly，是开发者将源代码编译打包后交付给使用者使用的一组集合。和java里的package类似，XDC的Package也是按照一定层次的文件夹组织形式来存放的（这点和.net不同，.net仅仅是编译成一个dll），该目录的名字就是包的名字。</span></p>
<p style="color: #362e2b; font-family: Arial; line-height: 26px; background-color: #ffffff;">&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr><span>&nbsp;所谓repository，实际上是一个包含多个package的文件夹，例如在XDC里，我们使用packages来作为一个repository，该文件夹下包含很多ti.xdc.*的包。在XDC开发中，有一个很重要的变量XDCPATH，在XDCPATH中制定的路径就是repository。这有点类似于C++的包含文件目录。</span></p>
<p style="color: #362e2b; font-family: Arial; line-height: 26px; background-color: #ffffff;">&nbsp;<wbr></p>
<p style="color: #362e2b; font-family: Arial; line-height: 26px; background-color: #ffffff;"><span>安装和卸载XDC</span></p>
<p style="color: #362e2b; font-family: Arial; line-height: 26px; background-color: #ffffff;"><span>你可以从TI的网站上下载，安装过程很简单，如果在Windows平台下，直接双击安装文件安装到特定目录就可以了，如果是在Linux平台，可能需要修改文件的属性将文件设置成可执行，然后双击安装。</span></p>
<p style="color: #362e2b; font-family: Arial; line-height: 26px; background-color: #ffffff;"><span>至于卸载，找到uninstall文件，双击即可。</span></p>
<p style="color: #362e2b; font-family: Arial; line-height: 26px; background-color: #ffffff;"><span>将XDC添加到你的环境变量</span></p>
<p style="color: #362e2b; font-family: Arial; line-height: 26px; background-color: #ffffff;"><span>为了更方便地使用XDC（实际上就是不要在xs前加上一长串路径），需要将XDC添加到环境变量里。</span></p>
<p style="color: #362e2b; font-family: Arial; line-height: 26px; background-color: #ffffff;"><span>如果开发平台为Windows，在安装完XDC后，需要环境变量的PATH中添加XDC安装目录（和JAVA一样），此外，顺便新建一个XDCPATH的环境变量，该变量用来制定repository的位置。</span></p>
<p style="color: #362e2b; font-family: Arial; line-height: 26px; background-color: #ffffff;"><span>如果你用的是Linux，自己查文档吧：-）</span></p>
<p style="color: #362e2b; font-family: Arial; line-height: 26px; background-color: #ffffff;"><span>测试</span></p>
<p style="color: #362e2b; font-family: Arial; line-height: 26px; background-color: #ffffff;"><span>当你完成以上步骤后，恭喜你，你现在可以开始XDC编程之旅了，试试在命令行下键入：</span></p>
<p style="color: #362e2b; font-family: Arial; line-height: 26px; background-color: #ffffff;"><span>xs &#8211;version</span></p>
<p style="color: #362e2b; font-family: Arial; line-height: 26px; background-color: #ffffff;"><span>和</span></p>
<p style="color: #362e2b; font-family: Arial; line-height: 26px; background-color: #ffffff;"><span>xs xdc.tools.echo hello world</span></p>
<p style="color: #362e2b; font-family: Arial; line-height: 26px; background-color: #ffffff;"><span>很简单吧？广告之后我们开始编写第一个基于XDC的应用程序，下一节更精彩，不要走开哦。</span></p>
<p style="color: #362e2b; font-family: Arial; line-height: 26px; background-color: #ffffff;">&nbsp;<wbr></p>
<p style="color: #362e2b; font-family: Arial; line-height: 26px; background-color: #ffffff;"><span>下面介绍如何创建一个基于XDC的应用程序。</span></p>
<p style="color: #362e2b; font-family: Arial; line-height: 26px; background-color: #ffffff;"><span>一般的我们使用传统的C语言进行XDC开发，在配置上还需要使用Javascript。不过总体来说，开发XDC还是很容易的，只需要遵循以下几个步骤：</span></p>
<p style="color: #362e2b; font-family: Arial; line-height: 26px; background-color: #ffffff;"><span>配置应用程序（也就是写配置文件了啊）</span></p>
<p style="color: #362e2b; font-family: Arial; line-height: 26px; background-color: #ffffff;"><span>写C语言</span></p>
<p style="color: #362e2b; font-family: Arial; line-height: 26px; background-color: #ffffff;"><span>编译、链接</span></p>
<p style="color: #362e2b; font-family: Arial; line-height: 26px; background-color: #ffffff;"><span>根据TI标准开发流程，XDC开发主要关注点还是编写C语言代码，至于其他的（主要是指1、3）很简单（文档上说的，我不觉得~~~），TI提供了一些工具。</span></p>
<p style="color: #362e2b; font-family: Arial; line-height: 26px; background-color: #ffffff;"><span>废话少说，开始我们的&#8220;Hello，World&#8221;之旅吧！</span></p>
<p style="color: #362e2b; font-family: Arial; line-height: 26px; background-color: #ffffff;"><span>配置应用程序</span></p>
<p style="color: #362e2b; font-family: Arial; line-height: 26px; background-color: #ffffff;"><span>和Java、C不同，开发XDC应用程序需要使用javascript语法写一个配置文件，进行一些预先的配置工作以供应用程序使用（例如使用什么模块啊，设置一些常量啊）。当然，第二步也就是写C语言也可以进行一些动态的设置。</span></p>
<p style="color: #362e2b; font-family: Arial; line-height: 26px; background-color: #ffffff;"><span>至于为什么写配置文件，TI给出的答案是：</span></p>
<p style="color: #362e2b; font-family: Arial; line-height: 26px; background-color: #ffffff;"><span>在编译时就制定需要使用到哪些模块，以及生成哪些静态对象。</span></p>
<p style="color: #362e2b; font-family: Arial; line-height: 26px; background-color: #ffffff;"><span>检查制定包和继承包</span></p>
<p style="color: #362e2b; font-family: Arial; line-height: 26px; background-color: #ffffff;"><span>设置指定模块或对象的属性</span></p>
<p style="color: #362e2b; font-family: Arial; line-height: 26px; background-color: #ffffff;"><span>下图展示了XDC编译的全过程：</span></p>
<p style="color: #362e2b; font-family: Arial; line-height: 26px; background-color: #ffffff;"><a href="http://newinfo.sysu.edu.cn/Snowwaft/wp-content/uploads/2008/10/xdcbuild.jpg" style="color: #6a3906; text-decoration: none;">&nbsp;<wbr></a><a href="http://photo.blog.sina.com.cn/showpic.html#blogid=693301190100sitz&amp;url=http://s5.sinaimg.cn/orignal/693301194a62e295732b4" target="_blank" style="color: #6a3906; text-decoration: none;"></a><img alt="" src="http://img.my.csdn.net/uploads/201303/07/1362586417_2798.jpg" style="border: none; max-width: 100%;" /><br />
<br />
<a href="http://photo.blog.sina.com.cn/showpic.html#blogid=693301190100sitz&amp;url=http://s14.sinaimg.cn/orignal/69330119077049dc6f3dd" target="_blank" style="color: #6a3906; text-decoration: none;"></a><br />
<br />
</p>
<p style="color: #362e2b; font-family: Arial; line-height: 26px; background-color: #ffffff;"><a href="http://newinfo.sysu.edu.cn/Snowwaft/wp-content/uploads/2008/10/xdcbuild.jpg" style="color: #6a3906; text-decoration: none;"></a></p>
<p style="color: #362e2b; font-family: Arial; line-height: 26px; background-color: #ffffff;"><span>XDC的配置文件是以cfg结尾的，在Codec Engine开发过程中，我们主要是Application端和server端使用XDC来编译。</span></p>
<p style="color: #362e2b; font-family: Arial; line-height: 26px; background-color: #ffffff;"><span>如上图所示，CONFIG OUTPUT中为XDC编译器根据配置文件生成的一些中间文件（例如C代码、.cmd文件），这些文件不需要自己动手编写，甚至不需要知道他们是干什么的。</span></p>
<p style="color: #362e2b; font-family: Arial; line-height: 26px; background-color: #ffffff;"><span>现在回到&#8220;Hello，World&#8221;开发，我们先在开发目录下建立一个名为hello的文件夹，然后在该文件夹中建立一个名为hello.cfg的文件：</span></p>
<p style="color: #362e2b; font-family: Arial; line-height: 26px; background-color: #ffffff;"><span>接下来，在该文件中输入以下javascript表达式，声明一个xdc.runtime.System对象：</span></p>
<p style="color: #362e2b; font-family: Arial; line-height: 26px; background-color: #ffffff;"><span>var System = xdc.useModule(&#8220;xdc.runtime.System&#8221;);</span></p>
<p style="color: #362e2b; font-family: Arial; line-height: 26px; background-color: #ffffff;"><span>写C语言</span></p>
<p style="color: #362e2b; font-family: Arial; line-height: 26px; background-color: #ffffff;"><span>创建一个名为hello.c的文件，在里面添加以下代码：</span></p>
<p style="color: #362e2b; font-family: Arial; line-height: 26px; background-color: #ffffff;"><span>#include &lt;xdc/std.h&gt;</span><br /><span>
#include &lt;xdc/runtime/System.h&gt;</span></p>
<p style="color: #362e2b; font-family: Arial; line-height: 26px; background-color: #ffffff;"><span>int main()</span><br /><span>
{</span><br />
&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr><span>&nbsp;System_printf(&#8220;Hello World!\n&#8221;);</span><br />
&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr><span>&nbsp;return (0);</span><br /><span>
}</span></p>
<p style="color: #362e2b; font-family: Arial; line-height: 26px; background-color: #ffffff;"><span>编译</span></p>
<p style="color: #362e2b; font-family: Arial; line-height: 26px; background-color: #ffffff;"><span>确定目标和平台</span></p>
<p style="color: #362e2b; font-family: Arial; line-height: 26px; background-color: #ffffff;"><span>在编译前，我们首先需要明确我们的程序是运行在什么平台上的，以及使用什么编译起来进行编译。在TI的文档中，用目标（Target）和平台（Platform）、编译器来定义这些属性：</span></p>
<p style="color: #362e2b; font-family: Arial; line-height: 26px; background-color: #ffffff;"><span>目标（-t）：制定的编译器，例如TI &#8216;C6000&nbsp;</span><wbr><span>编译器。</span></p>
<p style="color: #362e2b; font-family: Arial; line-height: 26px; background-color: #ffffff;"><span>平台（-p）：运行的环境，例如DM6446 EVM。</span></p>
<p style="color: #362e2b; font-family: Arial; line-height: 26px; background-color: #ffffff;"><span>编译器（-c）：编译XDC的编译器，例如TI 公司提供的Code Gen Tools或者Visual Studio 2008。</span></p>
<p style="color: #362e2b; font-family: Arial; line-height: 26px; background-color: #ffffff;"><span>在本例中，目标为ti.targets.C64P，平台定位ti.platforms.evmDM6446。</span></p>
<p style="color: #362e2b; font-family: Arial; line-height: 26px; background-color: #ffffff;"><span>运行Configuro</span></p>
<p style="color: #362e2b; font-family: Arial; line-height: 26px; background-color: #ffffff;"><span>XDC提供了一个叫做&#8220;Configuro&#8221;的工具来处理配置文件，我们可以在命令行中输入以下命令：</span></p>
<p style="color: #362e2b; font-family: Arial; line-height: 26px; background-color: #ffffff;"><span>xs xdc.tools.configuro -t ti.targets.C64P -p ti.platforms.evmDM6446 -c d:/opt/</span><a href="http://newinfo.sysu.edu.cn/Snowwaft/wp-content/uploads/2008/10/result.jpg" style="color: #6a3906; text-decoration: none;"></a><span>cgtools&nbsp;</span><wbr><span>hello.cfg</span></p>
<p style="color: #362e2b; font-family: Arial; line-height: 26px; background-color: #ffffff;"><span>注：你需要在</span><a href="https://www-a.ti.com/downloads/sds_support/CodeGenerationTools.htm" style="color: #6a3906; text-decoration: none;"><span>https://www-a.ti.com/downloads/sds_support/CodeGenerationTools.htm</span></a><span>下载Code Gen Tools。</span></p>
<p style="color: #362e2b; font-family: Arial; line-height: 26px; background-color: #ffffff;"><span>编译后将生成一个名为hello的文件夹：</span></p>
<p style="color: #362e2b; font-family: Arial; line-height: 26px; background-color: #ffffff;">&nbsp;</p>
<p style="color: #362e2b; font-family: Arial; line-height: 26px; background-color: #ffffff;">&nbsp;</p>
<p style="color: #362e2b; font-family: Arial; line-height: 26px; background-color: #ffffff;">&nbsp;</p>
<p style="color: #362e2b; font-family: Arial; line-height: 26px; background-color: #ffffff;"><span style="font-family: 黑体; font-size: 24px;">关于XDC工具的文章</span>&nbsp;&nbsp;</p>
<p style="color: #362e2b; font-family: Arial; line-height: 26px; background-color: #ffffff;"><span>1.TI XDC工具入门简介</span><br /><span>
http://www.usr.cc/thread-52028-1-3.html</span><br /><span>
2.XDC工具使用示例</span><br /><span>
http://www.usr.cc/thread-52037-1-2.html</span><br /><span>
3.codec engine代码阅读四---CE_DIR/examples/ti/sdo/ce/examles/codecs/videnc_copy</span><br /><span>
http://alphamailpost.blog.163.com/blog/static/20111808120127219241667/</span><br /><span>
4.XDC工具手册(在xdc安装目录下的docs文件夹里也有,这个是在线网页)</span><br /><span>
http://rtsc.eclipse.org/docs-tip/XDCtools_User%27s_Guide</span><br />
<br /><span>
5.rtsc</span></p>
<p style="color: #362e2b; font-family: Arial; line-height: 26px; background-color: #ffffff;"><a href="http://rtsc.eclipse.org/docs-tip/Main_Page" style="color: #6a3906; text-decoration: none;"><span>http://rtsc.eclipse.org/docs-tip/Main_Page</span></a></p><img src ="http://www.cppblog.com/dawnbreak/aggbug/210271.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/dawnbreak/" target="_blank">pear_li</a> 2015-04-07 20:55 <a href="http://www.cppblog.com/dawnbreak/articles/210271.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>