摘要: #define SVC_0 0#define SVC_1 1#define SVC_2 2void SVC_Handler( void ){ asm("TST LR, #4"); asm("ITE EQ"); asm("MRSEQ R0, MSP"); asm("MRSNE R0, PSP"); asm("B SVC_Handler_main");}void Dummy0_Handler( unsigned int * svc_args ){ svc_args[6] += 4; // skip 阅读全文
posted @ 2013-05-01 01:00 IAmAProgrammer 阅读(1217) 评论(0) 推荐(0) 编辑
摘要: http://www.coactionos.com/embedded-design/133-effective-use-of-arm-cortex-m3-svcall.htmlThe ARM Cortex-M3 service call (SVCall) can be a tricky feature to integrate in to your system software. It is useful for two things:Allowing a piece of code to execute without interruptionJumping to privileged m 阅读全文
posted @ 2013-04-30 23:05 IAmAProgrammer 阅读(6034) 评论(0) 推荐(0) 编辑
摘要: unit uMultiInputBox;interfaceuses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Controls, Vcl.Forms, Vcl.StdCtrls;type TFieldType = ( ftNumber, ftHexNumber, ftFloatNumber, ftText ); TInputRec = record Prompt : string; MaxLength : integer; FieldTy... 阅读全文
posted @ 2013-04-30 22:16 IAmAProgrammer 阅读(1070) 评论(0) 推荐(0) 编辑
摘要: http://blog.frankvh.com/2011/12/07/cortex-m3-m4-hard-fault-handler/If you’re seeing a Hard Fault exception on your Cortex M3 or Cortex M4 processor, t... 阅读全文
posted @ 2013-04-30 21:57 IAmAProgrammer 阅读(1392) 评论(0) 推荐(0) 编辑
摘要: This is the difference between a "procedure" and a "procedure of object"TheOnClickis defined as aTNotifyEvent:type TNotifyEvent = procedure(Sender: TObject) of object;You cannot assign a procedure to theOnClickas it is the wrong type. It needs to be a procedure of object.You can 阅读全文
posted @ 2013-04-30 13:21 IAmAProgrammer 阅读(2518) 评论(0) 推荐(0) 编辑
摘要: procedure MoveMemory(Destination: Pointer; Source: Pointer; Length: NativeUInt);begin Move(Source^, Destination^, Length);end;procedure CopyMemory(Destination: Pointer; Source: Pointer; Length: NativeUInt);begin Move(Source^, Destination^, Length);end;procedure FillMemory(Destination: Pointer; Len.. 阅读全文
posted @ 2013-04-30 11:01 IAmAProgrammer 阅读(480) 评论(0) 推荐(0) 编辑
摘要: 指针 : 指针是一个特殊的变量, 它里面存储的数值被解释成为内存里的一个地址.(1) 指针对应着一个数据在内存中的地址, 得到了指针就可以自由地修改该数据. (2) 一个指针变量仅仅是存储一个内存的地址, 为指针所指向的内容分配空间是程序员要干的工作. (3) 如果一个指针没有指向任何数据, 它的值是nil, 它就被称为是零( nil )指针或空(null) 指针. (4) 要访问一个指针所指向的内容, 在指针变量名字的后面跟上^运算符. 这种方法称为对指针取内容. (5) 指针的指针就是用来存放指针所在的内存地址的. 要搞清一个指针, 需要了解以下内容:(1) 指针的类型. (2) 指针所. 阅读全文
posted @ 2013-04-30 10:48 IAmAProgrammer 阅读(1687) 评论(0) 推荐(0) 编辑
摘要: fmOpenRead = $0000; fmOpenWrite = $0001; fmOpenReadWrite = $0002; fmExclusive = $0004; // when used with FileCreate, atomically creates the file only if it doesn't exist, fails otherwise fmShareCompat = $0000 platform; // DOS compatibility mode is not portable fmShareExclu... 阅读全文
posted @ 2013-04-30 08:36 IAmAProgrammer 阅读(499) 评论(0) 推荐(0) 编辑
摘要: Hex formatsIntel=====Hexadecimal values are always in uppercase. Each line is a record.The sum of all the bytes in each record should be 00 (modulo 256).Record types:00: data records01: end-of-file record02: extended address recordData record----------- :0D011C0000000000C3E0FF0000000000C30F: 0D 0... 阅读全文
posted @ 2013-04-29 03:08 IAmAProgrammer 阅读(2337) 评论(0) 推荐(0) 编辑
摘要: var fullFileName : string;begin // Set up a full file name with drive and path fullFileName := 'C:\Program Files\Borland\Delphi7\Projects\Unit1.dcu'; // Show the component parts of this full name ShowMessage('Drive = '+ExtractFileDrive (fullFileName)); ShowMessage('Dir = '+Ex 阅读全文
posted @ 2013-04-29 00:37 IAmAProgrammer 阅读(910) 评论(0) 推荐(0) 编辑
摘要: QuickSort AlgorithOne of the common problems in programming is to sort anarray of valuesin some order (ascending or descending).While there are many "standard" sorting algorithms, QuickSort is one of the fastest.Quicksort sorts by employing adivide and conquer strategyto divide a list into 阅读全文
posted @ 2013-04-28 23:21 IAmAProgrammer 阅读(1433) 评论(0) 推荐(0) 编辑
摘要: 1 RowOut: pByteArray; 2 RowIn : array[0..2400] of pByteArray; 3 4 RowOut := pByteArray(Bitmap0.Scanline[y]); 5 6 RowIn[xout] := pByteArray(Imagebits.Picture.Bitmap.Scanline[wout-1-xout]); 7 8 9 if RowIn[x*8+bitx][y div 8] and pu2[y mod 8] <> 0 then 10 11 if RowIn[x*8+bitx]^[y div 8] an... 阅读全文
posted @ 2013-04-28 18:38 IAmAProgrammer 阅读(390) 评论(0) 推荐(0) 编辑
摘要: /*The CRC calculation unit mainly consists of a single 32-bit data register, which:is used as an input register to enter new data in the CRC calculator(when writing into the register) holds the result of the previous CRC calculation(when reading the register)Each write operation into the data regist 阅读全文
posted @ 2013-04-28 18:36 IAmAProgrammer 阅读(5011) 评论(0) 推荐(0) 编辑
摘要: unit USBDeviceNotify;//USB Device arrival or removeinterfaceuses Windows, Messages, SysUtils, Classes, Forms;type PDevBroadcastHdr = ^DEV_BROADCAST_HDR; DEV_BROADCAST_HDR = packed record dbch_size: DWORD; dbch_devicetype: DWORD; dbch_reserved: DWORD; end; PDevBroadcastDev... 阅读全文
posted @ 2013-04-28 18:34 IAmAProgrammer 阅读(927) 评论(0) 推荐(0) 编辑
摘要: #ifndef _W25Q_H_#define _W25Q_H_/*The W25Q16BV array is organized into 8,192 programmable pages of 256-bytes each.Up to 256 bytes can be programmed at a time.Pages can be erased in groups of 16 (sector erase),groups of 128 (32KB block erase),groups of 256 (64KB block erase) orthe entire chip (chip e 阅读全文
posted @ 2013-04-28 18:32 IAmAProgrammer 阅读(3284) 评论(0) 推荐(0) 编辑
摘要: /* Define to prevent recursive inclusion -------------------------------------*/#ifndef __AT24_H#define __AT24_H#include <string.h>#include "hw_twi.h"#include "hw_def.h"/*AT24C02, 2K Bits SERIAL EEPROM:Internally organized with 32 pages of 8 bytes each,the 2K Bits requires 阅读全文
posted @ 2013-04-28 18:29 IAmAProgrammer 阅读(1635) 评论(0) 推荐(0) 编辑
摘要: move to www.csdn.net 阅读全文
posted @ 2013-04-28 17:47 IAmAProgrammer 阅读(161) 评论(0) 推荐(0) 编辑
摘要: http://marc.durdin.net/2011/10/comparing-tstringstream-vs-tstringlist.htmlThere are two methods widely used in Delphi code for reading and writing strings to/from streams with Delphi,that initially seem pretty similar in their behaviour. These areTStrings.SaveToStreamandTStringStream.SaveToStream (o 阅读全文
posted @ 2013-04-28 13:37 IAmAProgrammer 阅读(785) 评论(0) 推荐(0) 编辑
摘要: http://delphi.wikia.com/wiki/CompilerVersion_ConstantThe CompilerVersion constant identifies the internal version number of the Delphi compiler.It is defined in the System unit and may be referenced either in code just as any other constant:if CompilerVersion = 20 then sCompilerName := 'Delphi 2 阅读全文
posted @ 2013-04-27 21:30 IAmAProgrammer 阅读(488) 评论(0) 推荐(0) 编辑
摘要: B<cond>.<qualifier><lable>--Branch causes a branch to a target addressif ConditionPassed(cond) then{ EncodingSpecificOperations(PC, lable);BranchWritePC(PC + imm32);}//All versions of the Thumb instruction setT1 : B<cond> <lable> : not allowed in IT blockT2 : B<cond& 阅读全文
posted @ 2013-04-26 10:50 IAmAProgrammer 阅读(802) 评论(0) 推荐(0) 编辑
摘要: #ifndef __BUFFER_H__#define __BUFFER_H__#include /* * http://en.wikipedia.org/wiki/Circular_buffer : Mirroring * * The capacity of circle buffer must ... 阅读全文
posted @ 2013-04-25 13:58 IAmAProgrammer 阅读(871) 评论(0) 推荐(1) 编辑
摘要: #ifndef __LIST_H__#define __LIST_H__#include <stdint.h>#define LIST_ITEM_VAR() LIST_ITEM_T item#define LIST_ITEM_PTR(x) LIST_ITEM_T * x#define LIST_ITEM_PAIR(x, y) LIST_ITEM_T * x, * y//#define list_entry(pItem, T) ( (T *)(pItem) )#define LIST_ITEM_U8_PTR( p... 阅读全文
posted @ 2013-04-24 22:37 IAmAProgrammer 阅读(343) 评论(0) 推荐(0) 编辑
摘要: 参见USB枚举过程USB枚举过程图示http://blogs.msdn.com/b/usbcoreblog/archive/2010/09/11/9915562.aspxDevice enumeration for a USB port begins when the hub indicate a ... 阅读全文
posted @ 2013-04-23 11:14 IAmAProgrammer 阅读(1679) 评论(0) 推荐(0) 编辑
摘要: ClassUsageDescriptionExamples00hDeviceUnspecifiedclass 0(Device class is unspecified. Interface descriptors are used for determining the required drivers.)01hInterfaceAudioSpeaker,microphone,sound card02hBothCommunications and CDC ControlEthernet adapter,modem,serial port adapter03hInterfaceHuman In 阅读全文
posted @ 2013-04-23 00:42 IAmAProgrammer 阅读(639) 评论(0) 推荐(0) 编辑
摘要: /* * File: alloc.c * Purpose: generic malloc() and free() engine * * Notes: 99% of this code stolen/borrowed from the K&R C * examples. * */#include "common.h"#include "stdlib.h"#pragma section = "HEAP"/*************************************************************** 阅读全文
posted @ 2013-04-22 23:20 IAmAProgrammer 阅读(346) 评论(0) 推荐(0) 编辑
摘要: /* * File: printk.c * Purpose: The standard C library routine printf(), but without * all the baggage. */#include <stdarg.h>/********************************************************************/typedef struct{ int dest; void (*func)( char ); char * loc;} PRINTK_INFO;int pr... 阅读全文
posted @ 2013-04-22 23:14 IAmAProgrammer 阅读(579) 评论(0) 推荐(0) 编辑
摘要: /* * File: queue.h * Purpose: Implement a first in, first out linked list * * Notes: */#ifndef _QUEUE_H_#define _QUEUE_H_/********************************************************************//* * Individual queue node */typedef struct NODE{ struct NODE *next;} QNODE;/* * Queue Struture - linke... 阅读全文
posted @ 2013-04-22 23:04 IAmAProgrammer 阅读(312) 评论(0) 推荐(0) 编辑
摘要: 简单讲,OHCI,UHCI都是USB1.1的接口标准,而EHCI是对应USB2.0接口标准,最新的XHCI是USB3.0的接口标准。1.OHCI(Open Host Controller Interface)是支持USB1.1标准,但不只是针对USB,还支持其他的一些接口,比如它还支持Apple的火线(Firewire,IEEE 1394)接口。与UHCI相比,OHCI的硬件复杂,硬件做的事情更多,所以实现对应的驱动的任务就相对简单。主要用于非X86的USB,如扩展卡,嵌入式开发板的USB主控。2.UHCI(Universal Host Controller Interface), 是Inte 阅读全文
posted @ 2013-04-21 12:46 IAmAProgrammer 阅读(760) 评论(0) 推荐(0) 编辑
摘要: USB Composite Class DevicesA USB Composite Device is any device which does more than one jobfor example a combined keyboard and mouse.A USB Composite device is the one with multiple interfaces controlled independently of each other. When using such device multiple functions are combined into a singl 阅读全文
posted @ 2013-04-19 15:41 IAmAProgrammer 阅读(2435) 评论(0) 推荐(0) 编辑
摘要: http://www.cppblog.com/Lee7/archive/2008/01/07/40650.htmlOverlapped I/O简述:Overlapped I/O也称Asynchronous I/O,异步I/O模型。异步I/O和同步I/O不同,同步I/O时,程序被挂起,一直到I/O处理完,程序才能获得控制。异步I/O,调用一个函数告诉 OS,进行I/O操作,不等I/O结束就立即返回,继续程序执行,操作系统完成I/O之后,通知消息给你。Overlapped I/O只是一种模型,它可以由内核对象(hand),事件内核对象(hEvent), 异步过程调用(apcs) 和完成端口(I/O 阅读全文
posted @ 2013-04-19 15:21 IAmAProgrammer 阅读(827) 评论(0) 推荐(0) 编辑
摘要: 应用程序和驱动程序的通信过程是:应用程序使用CreateFile函数打开设备,然后用DeviceIoControl与驱动程序进行通信,包括读和写两种操作。还可以用ReadFile读数据用WriteFile写数据。操作完毕时用CloseHandle关闭设备。我们比较常用的就是用DeviceIoControl对设备进行读写操作。CreateFile这是一个多功能的函数,可打开或创建以下对象,并返回可访问的句柄:控制台,通信资源,目录(只读打开),磁盘驱动器,文件,邮槽,管道。HANDLE WINAPI CreateFile( _In_ LPCTSTR lpFileName, _In_ ... 阅读全文
posted @ 2013-04-19 13:53 IAmAProgrammer 阅读(4249) 评论(0) 推荐(1) 编辑
摘要: Standard DescriptorsADevice Descriptordescribes general information about a USB device. It includes information that applies globally to the device and all of the device's configurations. A USB device has only one device descriptor.TheConfiguration Descriptorgives information about a specific de 阅读全文
posted @ 2013-04-19 10:09 IAmAProgrammer 阅读(2038) 评论(0) 推荐(0) 编辑
摘要: 选择 USB 设备的驱动程序模型https://github.com/libusbx/libusbx/wiki/Windows-BackendWinUSBdoes not supportWindows 2003 ( 32bit/64bit )WinUSBdoes not supportWindows XP 64 bit ( not officially support on 64bit Windows XP)WinUSBcannot be used to send an actual reset command to an USB device. This is a limitation of 阅读全文
posted @ 2013-04-17 21:53 IAmAProgrammer 阅读(33727) 评论(0) 推荐(1) 编辑
摘要: 在计算机还没有出现之前,有一种叫做电传打字机(Teletype Model 33)的玩意,每秒钟可以打10个字符。但是它有一个问题,就是打完一行换行的时候,要用去0.2秒,正好可以打两个字符。要是在这0.2秒里面,又有新的字符传过来,那么这个字符将丢失。于是,研制人员想了个办法解决这个问题,就是在每行后面加两个表示结束的字符。一个叫做“回车”,告诉打字机把打印头定位在左边界;另一个叫做“换行”,告诉打字机把纸向下移一行。这就是“换行”和“回车”的来历,从它们的英语名字上也可以看出一二。Unix系统里,每行结尾只有“<换行>”,即“\n”;Windows系统里面,每行结尾是“< 阅读全文
posted @ 2013-04-16 05:25 IAmAProgrammer 阅读(830) 评论(0) 推荐(0) 编辑
摘要: C99中新增加了restrict修饰的指针:由restrict修饰的指针是最初唯一对指针所指向的对象进行存取的方法,仅当第二个指针基于第一个时,才能对对象进行存取。对对象的存取都限定于基于由restrict修饰的指针表达式中。由restrict修饰的指针主要用于函数形参,或指向由malloc()分配的内存空间。restrict数据类型不改变程序的语义。编译器能通过作出restrict修饰的指针是存取对象的唯一方法的假设,更好地优化某些类型的例程。restrict是c99标准引入的,它只可以用于限定和约束指针,并表明指针是访问一个数据对象的唯一且初始的方式.即它告诉编译器,所有修改该指针所指向内 阅读全文
posted @ 2013-04-15 23:59 IAmAProgrammer 阅读(1150) 评论(0) 推荐(0) 编辑
摘要: %% 打印一个百分号%a 浮点数、十六进制数字和p-记数法(C99)%A 浮点数、十六进制数字和p-记法(C99)%c 一个字符 %d 有符号十进制整数 %i 有符号十进制数(与%d相同)%e 浮点数、e-记数法%E 浮点数、E-记数法%f 浮点数、十进制记数法 %g 根据数值不同自动选择%f或%e.%G 根据数值不同自动选择%f或%e.%p 指针 %s 字符串%u 无符号十进制整数%o 无符号八进制整数%x 使用十六进制数字0..f的无符号十六进制整数 %X 使用十六进... 阅读全文
posted @ 2013-04-15 22:51 IAmAProgrammer 阅读(318) 评论(0) 推荐(0) 编辑
摘要: http://stackoverflow.com/questions/14926294/formatted-print-to-circular-bufferI'm writing embedded code for STM32F3 mc (STM32F3-Discovery). I need to output some data to UART and I'm using DMA for this as this allows me to concentrate on sensors reading and data processing rather than on wai 阅读全文
posted @ 2013-04-15 21:19 IAmAProgrammer 阅读(373) 评论(0) 推荐(0) 编辑
摘要: PostThreadMessage将一个消息放入(寄送)到指定线程的消息队列里,不等待线程处理消息就返回。既可以发送消息给工作线程,也可以发送给UI线程。其原型如下:BOOL PostThreadMessage( DWORD idThread, UINT Msg, WPARAM wParam, LPARAM lParam);idThread:其消息将被寄送的线程的线程标识符。如果线程没有消息队列,此函数将失败。当线程第一次调用一个Win 32 USER或GDI函数时,系统创建线程的消息队列。要得到更多的信息,参见备注。Msg:指定将被寄送的消息的类型。... 阅读全文
posted @ 2013-04-14 20:51 IAmAProgrammer 阅读(2969) 评论(0) 推荐(0) 编辑
摘要: #ifndef __RING_BUFFER_H__#define __RING_BUFFER_H__//------------------------------------------------------------------------------// External functions//------------------------------------------------------------------------------void BSP_Lock( void );void BSP_Unlock( void );typedef struct{... 阅读全文
posted @ 2013-04-14 07:01 IAmAProgrammer 阅读(514) 评论(0) 推荐(0) 编辑
摘要: #ifndef __CIRCLE_BUFFER_H__#define __CIRCLE_BUFFER_H__/* * http://en.wikipedia.org/wiki/Circular_buffer : Mirroring * * The capacity of circle buffer must be a power of two ! * * The source and sink of data can implement independent policies for dealing * with a full buffer and overrun while adherin 阅读全文
posted @ 2013-04-14 07:00 IAmAProgrammer 阅读(573) 评论(0) 推荐(0) 编辑