Neil's profileMindRoadPhotosBlogListsMore ![]() | Help |
MindRoad大海扬帆看日出日落 碧空展翅笑云卷云飞 |
||||||||||||||||||||||||||||||||||||||||
|
6/23/2009 SD卡的读写和加解密一、概述 SD卡全称为 Secrue Digital Memory Card,具有轻巧、可加密、传输速度高、适用于手持设备使用等优点。 二、总线接口 SD需要高速读写,同时也要使手持等嵌入式设备能方便使用,特设有两个访问接口中:SD模式接口和SPI接口。SD卡在上电初期,卡主控通过检测引脚1(DAT3)来决定使用SD模式还是SPI模式。当此脚接50KOhm上拉电阻时,卡进入SD模式;当此脚为低电平,卡则工作于SPI模式。 1、SPI接口 SPI接口是为嵌入式和手持设备准备的,只使用普通的三线制SPI总线,即可对卡进行一般的慢速的读写等操作。 <!--[if !vml]-->图略<!--[endif]--> 图一:SPI总线 如上图,由读卡器到卡的数据,在每个时种的上升沿把DO的数据锁存到卡主控,而卡的数据则在每个CLK的上升沿把DI的数据读入读卡器。 2、SD接口 SD接口是为高速专有设备而设计,使设备能对卡进行高速可靠的传输而设计,因SD模式在每个命令及数据转输时,都必须具有正确的CRC校验。因此,此模式下主机一般需要专门设计的硬件模块以产生CRC校验。 在此模式下,SD卡具有四根数据线,且时种速度最大可达50MHz,所以此模式下数据传输速率比SPI模式快得多。 三、总线协议 SD卡命令共分为12类,分别为class0到class11,不同的卡主控根据其功能,支持不同的命令集。主要如下: class0:卡的识别、初始化命令集。 class2:读卡命令集 class4:写卡命令集 class7:卡的锁定,解锁功能命令集 SD卡只有唯一的主机,所有命令是由主机发出。总线上可传输三种类型数据,分别是命令帧、响应、数据。 命令帧:由总线上唯一的主机发出,由设备响应并执行。 响应:指设备响应主机的命令。 数据:指由主机传给设备,或由设备传给主机的数据实体。 <!--[if !vml]-->图略<!--[endif]--> 如上图,命令帧一共由48bit组成,其中起始位固定为0,结束位固定为1。每个命令最后1字节包含7bit的CRC校验,第一字节为的另外7bit为命令码,中间的32bit为命令参数。 一个完整的命令由命令帧和响应,或命令帧、响应和数据组合而成。 <!--[if !vml]-->图略<!--[endif]--> 图二:Mult Block Read 如上图,主机发出command请求,然后卡返回该命令的respond,如果respond响应为正确,则Host通过读取cmd线状态,等待卡准备好数据;如果cmd为低电平,表示卡busy,busy结束后卡会把cmd线拉高,并且发出start token,随即进入数据传输阶段;数据传输结束后,主机发送结束命令停止命令,传输结束。 五、加密 SD卡具有安全加密功能,内置128bit加密位,在加密状态下,用户需提供密码才可以访问卡内的数据。 在卡上电时,若卡包含密码,卡自动进入锁定状态,读写命令均返回错误,以保护卡内容不被读出及修改。 密码设置功能由CMD42实现,其数据包中包括该命令中所有的信息。 擦除:此位置1时,卡的密码和内容会被强制擦除,在遗忘密码时可使用此功能。 锁定/解锁:此位置1时,表示命令结束后状态为锁定,为0,表示卡解锁。 清除密码:此位置1,表示清除卡的旧密码,此时数据中必须包含旧密码的正确内容。 加密:此位置1,表示设置卡的新密码,数据中必须包含新密码内容;更改密码时,新密码紧跟随旧密码内容。 注:在CMD42命令之前,首先要使卡工作在传输状态,在SD模式下可使用CMD7进行状态转换,在SPI模式下,可使用初始化序列进行状态切换。 在任意刻,主机可以通过CMD13命令读取卡的内部状态,判断其锁定状态。定义如下: <!--[if !vml]-->图略<!--[endif]--> bit0置1表示卡处于锁定状态。 1、设置密码 使用CMD16设置Block长度为密码长度为PWD_LEN+2; 发送CMD42命令:0x6A,0x00,0x00,0x00,0x00,0x95; 发送命令数据:0x01,LEN,CMD_DATA0,CMD_DATA1……,0xFF,0xFF; 使用CMD16恢复原Block长度。 2、清除密码 使用CMD16设置Block长度为PWD_LEN+2; 发送CMD42命令:0x6A,0x00,0x00,0x00,0x00,0x95; 发送命令数据:0x02,LEN,CMD_DATA0,CMD_DATA1……,0xFF,0xFF; 使用CMD16恢复原Block长度。 3、卡的锁定、解锁 使用CMD16设置Block长度为PWD_LEN+2; 发送CMD42命令:0x6A,0x00,0x00,0x00,0x00,0x95; 发送命令数据:0x04,LEN,密码[LEN]……,0xFF,0xFF; 使用CMD16恢复原Block长度。 4、修改密码 使用CMD16设置Block长度为OLD_PWD_LEN+NEW_PWD_LEN+2; 发送CMD42命令:0x6A,0x00,0x00,0x00,0x00,0x95; 发送命令数据:0x05,LEN,旧密码[n],新密码[m]……,0xFF,0xFF; 使用CMD16恢复原Block长度。 5、卡擦除 使用CMD16设置Block长度为1; 发送CMD42命令:0x6A,0x00,0x00,0x00,0x00,0x95; 发送命令数据:0x08,0xFF,0xFF; 使用CMD16恢复原Block长度。 6/19/2009 LCD调试的几个心得从网上收集的,收藏一下! LCD调试中的常见问题以及注意事项 功能:Init、SleepIn、SleepOut、DisplayOn、DisplayOff 网上资料: 2,LCD driver 电源管理: (1)3级chargepump之间确保有足够的时间延迟,不同的系统这个要调整; (2)chargepump的输出端要加足够大的滤波电容,具体选择看波形 3,修改driver ,主要是有关显示周期方面方面的寄存器设置 肯定是背光电源module的问题,估计你采用的是PWM方式控制屏的亮度! 这种纹波产生的原因是LCD的刷屏频率与白光灯的频率频差小于20Hz造成的,就像在日光灯下看高速旋转的电风扇叶子的影响一样!好解决,要软件调一调PWM的频率,运气好就可以解决问题,如果LCD的刷频不是很稳定,就不能100%解决问题了 1、条纹的宽度,较宽的条纹一般跟背光有较大的关系 4手机 LCD&Camera ESD 问题 6/2/2009 So this is tech (1): Freescale, Qualcomm mint smartbooks at ComputexFreescale, Qualcomm mint smartbooks at Computex Rick Merritt SAN JOSE, Calif. — What's bigger than a smart phone, smaller than a notebook and different than a netbook? That's the description of a smartbook, a term Freescale and Qualcomm are minting at Computex for the ARM- and Linux-based portables their customers are designing. Intel popularized the term netbooks to refer to ultra small laptops, generally using its Atom processor and some version of Microsoft Windows. Compared to netbooks, smartbooks will be smaller, cheaper, and have longer battery life and instant-on capabilities, backers say. "We are re-labeling this category smartbooks," said Glen Burchers, a consumer marketing director for Freescale. Whatever you call them, mobile devices will be all the rage at Computex in Taipei where about 80 percent of the world's notebook computers are made. Chip makers including Broadcom, Nvidia and Sandisk are expected to make announcements at Computex about their activities around netbooks. Several of Taiwan's contract design and manufacturing companies will show smartbooks at Computex based on Freescale's iMX51 processor, Burchers said. Branded OEM product launches are not expected until the fall. Some of the new systems will use a notebook-like clamshell form factor but be about 20mm thick compared to 30mm for some Windows/x86 netbooks, Burchers said. In addition, the smartbooks will run an entire day on a single battery, thanks to the power-pinching ARM processors, he added. Some of the ARM-based systems will sell for as little as $199. Atom-based notebooks typically sell for $399 to $599. Taiwan's Pegatron and Wistron will both show clamshell smartbooks at Computex. Burchers said he believes the companies have deals to sell the designs to OEMs. More than a dozen companies plan to be shipping smartbooks by this fall using chips from Freescale, Texas Instruments and Qualcomm, according to Will Strauss, principal of market watcher Forward Concepts (Tempe, Ariz.). "We believe that smartbooks could be a 40-million unit annual market by 2013," Strauss wrote in a newsletter released Sunday (May 31). To drive the new concept forward, Freescale hired industrial designers from the Savannah College of Art and Design. They have researched the requirements of target users and developed concept physical and user interface designs to display at Computex. Pictures of two of the new concept designs to be shown at Computex are displayed below. The Freescale work mirrors efforts years ago by Intel to stage a fashion show to get PC makers to design more stylish desktop computers. "Taiwan doesn't have a lot of focus on industrial design," said Burchers. He acknowledged two concerns for smartbooks are the lack of native support for Adobe Flash on ARM and the fragmentation of Linux application environments. However, he said solutions to both issues are in the works. Some OEMs will use Adobe Flash Lite 3.1 in devices shipping this fall. The software is roughly equivalent to Adobe Flash 9 for desktop PCs and can handle video from the vast majority of popular Web sites, he said. A version of Flash 10 for ARM could be available by the end of the year, he added, though Adobe said the code may not be widely available until early 2010. On the application front, Freescale is showing customers a prototype app store for Linux that aggregates as many as 6,000 Linux applications and tools. The company expects OEMs will develop their own online app stories for smartbooks just as Apple has done for the iPhone. "One of the downsides of Linux is the fragmented nature of it," he said. "That's why so many designers are excited about Google's Android, because it's managed by a single entity," he added. Android supports 320x480 pixel displays now and will support 800x480 in its next version called Donut. But work is going on to bring to Android support for 1280x1024 pixel resolutions as well as external USB peripherals, he added. 5/28/2009 C++ Primer, Fourth Edition -- AbstractBy Stanley B. Lippman , Josée Lajoie , Barbara E. Moo 1-100 2.3.5. Declarations and Definitions A definition of a variable allocates storage for the variable and may also specify an initial value for the variable. A declaration makes known the type and name of the variable to the program. extern int i; // declares but does not define i extern double pi = 3.1416; // definition 2.4. const Qualifier const Objects Are Local to a File By Default // file_1.cc Unlike other variables, unless otherwise specified, const variables declared at global scope are local to the file in which the object is defined. The variable exists in that file only and cannot be accessed by other files. // uses bufSize defined in file_1 2.5. References A reference must be initialized using an object of the same type as the reference: Because a reference is just another name for the object to which it is bound, all operations on a reference are actually operations on the underlying object to which the reference is bound:
const References A const reference can be initialized to an object of a different type or to an rvalue (Section 2.3.1 , p. 45 ), such as a literal constant:
The same initializations are not legal for nonconst references. Rather, they result in compile-time errors. The reason is subtle and warrants an explanation. 2.8. Class Types Using the structKeyword
Addison Wesley - c++ faqs (2nd Version) FAQ 2.04 What are the basics of default parameters?C++ allows functions to have default parameters. This is useful when a parameter should have a specified value when the caller does not supply a value. For example, suppose that the value 42 should be passed to the function f() when the caller does not supply a value. In that case, it would make the calling code somewhat simpler if this parameter value were supplied as a default value: void f(int x=42); <-- 1 void f(int x) <-- 2 { //... } int main() { f(29); <-- 3 f(); <-- 4 }
FAQ 2.24 What are the basics of inheritance and dynamic binding?
Inheritance is a powerful tool that enables extensibility. It allows the software to capture the is-a or kind-of relationship (although as will be shown in FAQ 7.01, the phrase, "is substitutable for," more accurately captures the true meaning of inheritance). In the following example, class Vehicle is defined with = 0; after the declaration of the startEngine() member function. This syntax means that the startEngine() member function is pure virtual and the Vehicle class is an abstract base class, or ABC. In practice, this means that Vehicle is an important class from which other classes inherit, and those other derived classes are, in general, required to provide a startEngine() member function. class Vehicle {
public:
virtual void startEngine() = 0;
virtual ~Vehicle(); <-- 1
};
Vehicle::~Vehicle()
{
// Intentionally left blank
}
The idea with ABCs is to build the bulk of the application so that it knows about the ABCs but not the derived classes. For example, the following function is aware of the ABC Vehicle but is not aware of any of the derived classes. void f(Vehicle& v)
{
// ...
v.startEngine();
// ...
}
If the ABCs are designed properly, a large percentage of the application will be written at that level. Then new derived classes can be added without impacting the bulk of the application. In other words, the goal is to minimize the ripple effect when adding new derived classes. For example, the following derived classes can be added without disturbing function f(). #include <iostream>
using namespace std;
class Car : public Vehicle {
public:
virtual void startEngine();
};
void Car::startEngine()
{
cout << "Starting a Car's engine\n";
}
class NuclearSubmarine: public Vehicle {
public:
virtual void startEngine();
};
void NuclearSubmarine::startEngine()
{
cout << "Starting a NuclearSubmarine's engine\n";
}
The reason these won't disturb the code in function f() (and recall, function f() represents the bulk of the application) is because of two features of C++: the is-a conversion and dynamic binding. The is-a conversion says that an object of a derived class, such as an object of class Car, can be passed as a base reference. For example, the following objects c and s can be passed to function f(). Thus the compiler allows a conversion from a derived class (e.g., a Car object) to a base class (e.g., a Vehicle reference). int main()
{
Car c;
NuclearSubmarine s;
f(c);
f(s);
}
The is-a conversion is always safe because inheritance means "is substitutable for." That is, a Car is substitutable for a Vehicle, so it won't surprise function f() if v is in fact referring to a Car. Dynamic binding is the flip side of the same coin. Whereas the is-a conversion safely converts from derived class to base class, dynamic binding safely converts from base class back to derived class. For example, the line v.startEngine() in function f() actually calls the appropriate startEngine() member function associated with the object. That is, when main() passes a NuclearSubmarine into f() (line f(s) in main()), v.startEngine() calls the startEngine() member function associated with class NuclearSubmarine. This is extremely powerful, since class NuclearSubmarine might have been written long after function f() was written and compiled and put into a library. In other words, dynamic binding allows old code (f()) to call new code (NuclearSubmarine::startEngine()) without the old code needing to be modified or even recompiled. This is the essence of extensibility: the ability to add new features to an application without significant impact to existing code. It is doable with C++, but only when the design considerations are carefully thought through ahead of time; it does not come free.
3/9/2009 Windows Embedded开发资源介绍现在Windows Embedded的开发资源很多,但是对于初次进入这个领域的开发者来说,如何开始则成为一个很大的问题。下面,我们就来试着为Windows Embedded的开发资源进行一个整合。 Windows Embedded是什么Windows Embedded是微软针对嵌入式领域推出的操作系统,目前主要包括三大产品:Windows Embedded CE、XP Embedded和.NET Micro Framework。 其中Windows Embedded CE可以适应多种CPU,比如ARM、MIPS、SH4和x86等,主要应用于手持设备、机顶盒、GPS和PMP等嵌入式设备中。基于Windows Embedded CE开发的Windows Mobile智能手机操作系统是专门针对智能手机的操作系统平台。 XP Embedded是基于XP Professional的组件化操作系统,以适应嵌入式设备对不同功能及存储空间的要求。XP Embedded只能运行在x86的CPU平台上,能够和Windows应用程序做到完全兼容。主要用于ATM、POS、电子信息亭等设备。 Windows Embedded for Point of Service是在XP Embedded的基础上开发的专门针对POS系统的操作系统,无需复杂的定制就可以直接应用于POS系统中。 除了以上的产品外,微软产品中还有两项技术与嵌入式产品相关: l .NET Micro Framework 应用于便携式的个人数字化产品中的.NET平台,允许.NET托管代码运行在ARM等嵌入式平台上。最早来源于SmartWatch计划,早期名为SPOT(Smart Personal Object Tech)。 l Microsoft Robotics Studio 微软针对机器人领域开发的控制系统和开发工具, 可以使用可视化编程语言(VPL)或者.NET托管语言来编写机器人的控制指令。可以支持多种不同的机器人硬件平台。 获取开发工具微软为开发者提供了免费的试用版软件,在产品开发的初始阶段,可以用试用版软件来验证,Windows Embedded产品是否适合自己的产品。 首先访问Windows Embedded的产品页面: http://www.microsoft.com/windows/embedded/ 点击左侧列表中的“Try Windows Embedded”。也可以直接访问下面的页面: http://www.microsoft.com/windows/embedded/eval/trial.mspx 然后再Download the trial version中选择要下载的产品: l Windows Embedded CE l Windows XP Embeddeds 下载需要提供一个Live ID进行那个注册。 在下载完成后,点击页面上的“please register your evaluation version here”链接,进行注册获取Product Key,系统会将这个Product Key发送到你注册的邮箱中。在安装过程中,需要使用Product Key进行安装。 .NET Micro Framework的开发需要Visual Studio 2005的支持,除了Visual Studio 2005外,还需要安装.NET MF的SDK,我们可以在下面的链接中下载: Microsoft Robotics Studio的开发工具是免费获取的,我们可以从下面的链接中下载: http://msdn2.microsoft.com/en-us/robotics/aa731520.aspx 购买Windows Embedded在中国大陆地区,如果需要购买Windows Embedded开发工具和Runtime的License可以联系三家Windows Embedded的分销商: l 研华科技 l 联强国际 l Avnet 在Windows Embedded的中文主页中,可以找到更详细的分销商联系方式: http://www.microsoft.com/china/windows/embedded/distrib.mspx 网络资源l MSDN产品中心: Windows Embedded http://msdn2.microsoft.com/en-us/embedded/default.aspx Windows Embedded CE http://msdn2.microsoft.com/en-us/embedded/aa731407.aspx Windows XP Embedded http://msdn2.microsoft.com/en-us/embedded/aa731409.aspx Windows Embedded for Point of Service http://msdn2.microsoft.com/en-us/embedded/aa714298.aspx .NET Micro Framework http://msdn2.microsoft.com/en-us/embedded/bb267253.aspx Microsoft Robotics Studio http://msdn2.microsoft.com/en-us/robotics/default.aspx l 英文开发网站: WE-DIG WindowsForDevices http://www.windowsfordevices.com/ l 第三方开发网站: 博客园Windows Embedded频道 嵌入式研究网 嵌入开发网 Windows Mobile门户网站 电子产品世界 开发社区中文的开发论坛: l 微软嵌入式开发者论坛 微软的官方开发者论坛,目前的版主是微软的嵌入式专家和微软最有价值专家(MVP)。 http://forums.microsoft.com/china/default.aspx?ForumGroupID=493&SiteID=15 l CSDN嵌入式开发论坛 最大的开发者社区,硬件/嵌入式开发板块中包括“嵌入开发(WinCE)”板块 l 嵌入式研究网论坛 偏重于Windows Embedded相关技术的讨论,也包括Windows Mobile应用程序开发。 l 嵌入式开发网技术论坛 偏重于硬件开发方面的讨论,不仅限于Windows Embedded的讨论 http://www.embed.com.cn/bbs/index.asp l Windows Mobile开发者社区 CSIP创建的开发者讨论社区 l 电子产品世界论坛 http://forum.eepw.com.cn/forum/main 有一些问题还是需要去英文论坛问的: l Smart Device Development http://forums.microsoft.com/MSDN/default.aspx?ForumGroupID=11&SiteID=1 l Microsoft Robotics Studio http://forums.microsoft.com/MSDN/default.aspx?ForumGroupID=383&SiteID=1 WebcastWindows Embedded从入门到精通课程: XP Embedded开发初体验 Windows CE下的开发概述 Windows CE 内存泄漏的检测和防止 http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032361286&Culture=zh-CN Windows CE 5.0/Windows Mobile调试与性能优化 http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032361320&Culture=zh-CN 本系列的新课程,请关注: http://www.microsoft.com/china/msdn/events/webcasts/shared/Webcast/MSDNWebCast.aspx Windows嵌入式开发系列课程 http://www.microsoft.com/china/msdn/events/webcasts/shared/webcast/Series/WindowsCE.aspx 英文的Windows Embedded Webcast可以在下面的链接中找到: http://msdn2.microsoft.com/en-us/embedded/aa731227.aspx BLOGl 英文产品组BLOG: Mike Hall’s Blog http://blogs.msdn.com/mikehall/ Windows CE Base Team Blog http://blogs.msdn.com/ce_base/ XP Embedded Team Blog http://blogs.msdn.com/embedded/ .NET Micro Framework Team Blog http://www.dotnetmicroframework.com/ Microsoft Robotics Studio Blog http://blogs.msdn.com/MSRoboticsStudio/ l 中文BLOG方面: 微软中国嵌入式开发者博客 凌宁的博客 http://blogs.msdn.com/ningling/ 开发图书Programming Windows® Embedded CE 6.0 Developer Reference 作者:Douglas Boling 出版社: Microsoft Press; 4 edition (October 10, 2007) 语言: English ISBN-10: 0735624178 Windows CE实用开发技术 作 者:张冬泉 谭南林 王雪梅 焦风川 出 版 社: 电子工业出版社 书 号: 7121024527 出版日期: 2006 年4月 Windows CE嵌入式系统 作 者:何宗键 出 版 社: 北京航空航天大学出版社 书 号: 7810777939 出版日期: 2006 年9月
Embedded Programming with the Microsoft .NET Micro Framework 作者:Donald Thompson , Rob S. Miles 出版社: Microsoft Press (June 20, 2007) 语言: English ISBN-10: 0735623651 Windows XP Embedded Advanced 作者:Sean D. Liming 出版社: Annabooks/Rtc Books; Pap/Cdr edition (October 1, 2003) 语言: English ISBN-10: 0929392779 Professional Microsoft Robotics Studio(预订中) 作者:Martin R. Calsyn 出版社: Wrox (June 3, 2008) 语言: English ISBN-10: 0470141077 Programming Microsoft® Robotics Studio (PRO-Developer)(预订中) 作者:Sara Morgan 出版社: Microsoft Press (March 5, 2008) 语言: English ISBN-10: 0735624321 |
感谢访问!
冰苓崛烬wrote:
你好!
我叫戴冰清,现在在德国慕尼黑读大学(本科),毕业后想去新加坡实习半年左右,主要想请教一下在那里的消费水平,不知那里普通学生的生活水平一个月大约要多少生活费(包括吃住)?比较在意房租啦,我在国外房子是不是很难找啊?我的邮箱是bingqingdai@googlemail.com,希望能抽空指点一下,谢谢啦!
Mar. 21
丹波wrote:
您好,我是浙江大学本科大三软件工程专业的学生。现在我们学院有去NTU的交流项目。我想申请去NTU交流。在看NTU的实验室项目介绍时发现对 T-engine方面的东西比较感兴趣。在google搜索就搜到了您的博客。
我想请教您一些关于NTU的老师,研究课题还有在NTU的生活等等情况。您能否帮助我?可以的话加我的MSN好吗?MSN:bobounha1987@hotmail.com
Apr. 8
莎丽 罗wrote:
即将成为常客~哈哈!
Nov. 28
|
|||||||||||||||||||||||||||||||||||||||
|
|