Friday, November 9, 2007

Flash

Flash儲存媒體包括幾種模式,一是SSD/DOC/CF/DOM,二是EFD(Embedded Flash Drive)像是mDOC、OneNAND、SanDisk的iNAND、Samsung的MoviNAND、Toshiba的GBNAND;三是MCP(Multi-Chip Package),包括EFD、SDR/DDR和NAND Flash,手機使用廣;四是Flash記憶體,也包括pure Flash,像iPhone把8G的NAND Flash直接銲在裡面。
from Embedded World report


快閃記憶體(Flash Memory),是非揮發性記憶體的一種,不需電力來維持數據的儲存。又可分為NOR Flash以及NAND Flash兩種,前者用於儲存程式碼,後者用於儲存數據資料。快閃記憶體用一個浮動閘(Floating Gate)電晶體來儲存數據,利用每個電晶體所能儲存的資料數量來區分,可以將NAND Flash區分為兩類:單級儲存(Sigle Level Cell,SLC)和多級儲存(Multi Level Cell,MLC)。單級儲存具有速度快,耗電量低的優點,但是多級儲存的成本比較低。

M-System DOC
DOC H3 provides:
  • Flash disk for both code and data storage
  • Code and data storage protection
  • 1Gb (128MB) – 16Gb (2GB) data storage capacity, with device cascading options for up to 32Gb (4GB).
  • Enhanced Programmable Boot Block (32KB) enabling eXecute In Place (XIP) functionality using 16-bit access.

Thursday, October 11, 2007

Mapping physical to virtual address

PVOID MmMapIoSpace(
   IN PHYSICAL_ADDRESS PhysicalAddress,
   IN ULONG NumberOfBytes,
   IN MEMORY_CACHING_TYPE CacheType
);

//----example:
PHYSICAL_ADDRESS RegPA;
ULONG uBase;

RegPA.QuadPart = 0xA0000000;
uBase = (ULONG)MmMapIoSpace(RegPA, 4, 0);

//----

//Header: CEDDK.h
//Link Library: CEDDK.lib

出現link error的話,把ceddk.lib的path加到
Project -> Settings -> Link的object/library modules應該就可以過了


from WinCE driver and BSP Develop blog
驅動開發過程中可能遇到以下幾種與內在訪問相關的情況:

1.CPU訪問設備寄存器:
在ARM中可以直接將設備的寄存器映射到ARM的存儲空間中,我們需要使用幾個函數將硬體寄存器位址映射到系統空間:
如果已知硬體的虛擬位址,可以使用VirtualAlloc,VirtualCopy,
如果已知硬體的物理位址,需要使用MmMapIoSpace映射.

2.CPU與DMA或其他硬體交換資料。
DMA需要使用物理位址,因為DMA訪問記憶體時不會向CPU一樣先經過MMU,所以它使用物理位址。如果硬體需要與CPU交互資料,比如CPU需要將圖像畫到LCD控制器使用的記憶體中,LCD才會將其顯示出來。我們在設置硬體硬體時需要將CPU使用的虛擬位址轉換成物理位址,再告訴硬體物理位址。通常有以下幾種辦法:

1. 為該硬體保留一塊記憶體空間。一般用於記憶體使用量比較大的,且位址不再改變的設備,例如LCD控制器。
記錄下該塊記憶體的物理位址給硬體使用,計算出該塊記憶體的虛擬位址位址給CPU使用。

2. 當驅動需要訪問硬體時才將虛擬位址轉換成物理位址,一般用在記憶體空間經常變化的場合。例如塊設備的驅動,檔系統或者其他上層程式讀寫資料時並不會保證每次使用同一段位址。這種情況下,可以使用LockPages函數將虛擬位址轉換成物理位址。

3. 分配一塊物理位址,這可以用在記憶體位址不需要變化,且用量不大的情況,這時可以用AllocPhysMem分配一塊位址,同時得到物理位址與虛擬位址。

Wednesday, October 3, 2007

CString

總算找到一篇比較完整的介紹文
有關CString轉換
int to string
string to int(signed, unsigned) 等等...
CString Management from Code Project
翻譯篇


Generic Text Mapping的觀念
字集設定 ANSI / UNICODE (窄字元 / 寬字元 / neutral)

Monday, October 1, 2007

專案管理技巧 WBS

Work Breakdown Structure (工作分解結構)

WBS使用階層樹狀結構(Hierarchical Tree Structure)與100%原則(100% Rule)來定義與組織專案範圍(Project Scope)。一個優良的專案WBS技巧,是針對產出(Outcomes)所進行的拆解,而非工作項目(Actions)拆解。



腳踏車WBS展開圖 Source: Wikipedia

from MECE原則與專案管理技巧
add.. 專案管理與專案生命週期
MECE

Thursday, September 6, 2007

什麼是專案管理

專案管理是為了達成專案目標的協調工作。專案小組的負責人是專案經理,負責執行這項工作及其最終的結果。專案經理憑藉知識、技能、工具及方法來:

  • 確立專案的目標、需求及限制。
  • 協調各專案關係人 (包括小組成員、資源經理、資深管理階層、客戶及贊助商) 的不同需要和期望。
  • 根據確立的專案目標來規劃、執行及控制專案的任務、階段及交付項目。
  • 當專案完成時關閉專案,並且記錄當中所累積的知識。

專案經理也負責平衡和整合互相競爭的需求,以利成功地執行整體專案,如下:

  • 專案範圍 確立專案要完成的特定工作。

  • 專案時間 設定專案的完成日期,以及階段、里程碑及交付項目的中期期限。

  • 專案成本 計算及追蹤專案成本和預算。

  • 專案人力資源 任用完成專案任務所需的小組成員。

  • 專案採購 取得完成專案任務所需的材料和設備資源。

  • 專案溝通 向小組成員和其他關係人傳達工作分派、更新、報表及其他資訊。

  • 專案品質 確立專案目標可接受的品質層級。

  • 專案風險 分析潛在的專案風險和回應計畫。


瞭解專案管理基本概念
平衡 範圍、時間及金錢 通常是專案經理的最大責任。
如果您增加範圍,三角關係中的時間或金錢兩邊也會增加。如果您需要縮減時間 (即提前專案完成日期),則可能需要減少範圍,或藉由增加成本來增加資源。

step by step - Microsoft Project 2003 : 建立project計劃

Wednesday, September 5, 2007

Bluetooth stack

"Bluetooth Stack" means the driver and applications used to control Bluetooth devices.
這樣是不是表示不同廠商的藍芽堆疊架構不盡相同?
Windows CE 5.0的bluetooth stack architecture



OBEX <- GEOP <-- FTP(File Transfer Profile) , OPP(Object Push Profile)
Com Port Emulation : 支援LAP(LAN Access Profile)DUN(Dial-Up Networking Profile)
RFCOMM <- SPP <-- HFP(Hands
-Free Profile), HSP(HeadSet Profile)
HID(Human Interface Device Profile)
PAN(Personal Area Networking Profile)
WinCE只支援這8個上層應用的profiles


MSDN BT Profile
MSDN BT Stack
認識藍芽堆疊 : 藍芽技術

Tuesday, September 4, 2007

blogger tips : blockquote and more

分享一些部落格的小技巧
美化blockquote跟程式碼區段

-----需要更改template-----
到customize template-> edit html
搜尋skin
]]></b:skin>
把以下程式碼貼在以上之前


blockquote {
color:#333333;
background-color: #FFEBCD;
padding: .5em 1em;
border: 2px #D2B48C dashed;
}


顏色選擇看~

code部份則是拿別人的圖來用的 連結隨時會不見
原著: Ben's 部落不及格
code {
display:block;
font:normal normal 100% 'Lucida Grande',儷黑 Pro,Verdana,Arial,Sans-serif;
font-size:10px;
color:#666666;
overflow:hidden;
background:#e3f5d2 url(http://benjamin31.googlepages.com/code_bg.gif) no-repeat left top;
padding:30px 20px 10px;
margin:0 4px;
max-height:none;
max-width:370px;
border-bottom:1px solid #eaeaea;
}

因為圖檔大小是固定的
所以用max-width控制background color


-----不需要更改到template-----
將po過的文字用畫線的方式顯示是要被刪除的 像這樣
直接在寫文章的時候加入語法
<span style="text-decoration: line-through;"> deleted text part </span>

語法記不起來怎麼辦?
到customize settings -> formatting的最下方 post templates把語法加進去之後按儲存
這樣每次在Edit Html po文時就會顯示了

然後是空格 不管在寫文章時打出多少空格
貼出來之後總是會被吃掉
一個方法是寫代碼
空格在html code代碼是 &#12288;
所以想要美美的排版可以多用 但真的不方便 orz
like this

int main()
{
 printf("Test");
}

專案管理術語

使用Microsoft Project促進專案發展

  • 比較基準 任務的重要專案資訊快照,例如開始日期、完成日期、工期及成本。使用比較基準資訊,您便可以和任務實際進度做對照。
  • 日期限制 與特定任務關聯的特定日期。例如,日期限制會指定任務必須在特定日期前完成,或不在某個特定日期之前開始。
  • 交付項目 必須產生的實質結果或項目,以標示專案或專案階段的完成。通常,交付項目必須獲得專案贊助商或客戶的核准。
  • 相依性 某個任務對另一個任務的依賴。當某個任務必須在關聯的任務開始或完成時才能開始或完成,任務就是彼此相依 (或相關)。又稱為任務連結或任務關係。
  • 甘特圖 專案的圖形表示。甘特圖的左邊是一個表格,當中列出任務名稱和其他任務相關資訊。甘特圖右邊則是橫條圖和時間表,其中每個橫條分別代表任務、開始和完成日期,以及任務工期。此外也會顯示其他任務的連結。
  • 里程碑 專案中有意義的事件,通常是完成了主要交付項目或階段。里程碑是專案任務清單的一部分。
  • 網狀圖 專案的圖形表示,以節點表示任務,並以連結線顯示任務關係。有時又稱為 PERT (計劃評估及審核技術) 圖。
  • 階段 一組任務,代表專案生命週期中的主要階段。階段的結果通常是主要交付項目。
  • 範圍 專案中必須完成的特定工作,以交付產品或服務。
  • 關係人 可由專案結果獲得既定利益,並且可以影響專案結果的個人或組織。關係人包括專案經理、專案小組成員、贊助組織及客戶。

Monday, August 27, 2007

Catering to convenience

The origins of 7-Eleven

figures : 數量

venture : 帶有投機性質的 公司/企業; venture capitalist : 風險投資家

dock : 零售店
常會看到的其他名詞 - ipod dock = ipod的基座; OS Dock = mac桌面上的程式icon
others - 被告席, 船塢, 飛機棚, 月臺。想像任何東西的基座都可以叫dock..

steady stream : 川流不息 ; never-ending

Friday, August 24, 2007

How to deal with a falling population

The Economist : How to deal with a falling population
Jul 26th 2007

Malthusian catastrophe : a return to subsistence-level conditions as a result of agricultural (or, in later formulations, economic) production being eventually outstripped by growth in population

net primary production : Primary production is the production of organic compounds from atmospheric or aquatic carbon dioxide, principally through the process of photosynthesis, with chemosynthesis being much less important. All life on earth is directly or indirectly reliant on primary production. The organisms responsible for primary production are known as primary producers or autotrophs, and form the base of the food chain.
Net primary production is the rate at which new biomass accrues in an ecosystem. Some net primary production will go towards growth and reproduction of primary producers, while some will be consumed by herbivores.

parental leave : 育嬰假

Tuesday, August 21, 2007

The mythical man-month

ch2

好菜都得多花些時間準備,為了能讓您享受到更美味、更可口的佳餚,請您務必耐心稍待。

——紐奧良,ANTOINE餐廳的點菜單



軟體專案進行不順利的原因或許很多,但絕大部分都是肇因於缺乏良好的時程規劃所致:
  1. 我們目前的時程預估技術還非常不成熟,糟的是,這些不成熟的技術背後都反映出一個假設,亦即,一切都會進行得很順利,但這實在是大錯特錯。
  2. 我們的預估技術誤把工作量和專案進度混為一談,這又隱含了另一個假設,以為人力和工時可以互換。
  3. 由於我們對自己所做的預估都無法篤定,所以專案經理通常缺乏Antoine餐廳廚師那種委婉的堅持。
  4. 時程進行缺乏監控,並把其他工程領域上被證明可行或慣用的技術套在軟體工程上進行改革。
  5. 當發現時程延誤的時候,自然而然的(也很典型的)反應就是增加人手,但這簡直就是火上加油,只會把情況弄得更糟。
過於樂觀 :
第一個錯誤假設就是一切都會進行得很順利,亦即,每項工作都將只會耗費掉它「理應」耗費的時間。

就單獨一件工作而言,如果假設一切都將順利進行,其結果會對時程造成何種影響就要看運氣。從機率分佈的角度來看,「完全不延期」也是有一定的機會,所以, 或許它真的能如計畫所預期地進行,但是,如果面對的是大型軟體開發專案,包含的是一大群工作,而且彼此環環相扣,那麼,一切都將進行得很順利的機率將是微 乎其微。

人月的迷思 :
第二個錯誤的想法,是來自於預估和排定時程所使用的人月,這正是一般用來衡量工作量的單位。成本確實會隨著人力與工時的乘積而變, 但工作的進度可不是如此,所以用人月來衡量工作規模的大小是危險的,也是一個容易遭到誤解的迷思,使用人月的前題必須是在人力和工時可以互換 的情況之下。

只有當工作可被切分,而且投入工作的人彼此不用溝通,人力和工時的互換才算成立,像割小麥或採收棉花就是這樣,但這對程式設計來說卻完全不適用。

當一份工作因具有連續性的限制而不可切分時,就算投入再多的人力,也不會對時程有所影響,生小孩就是需要九個月,你叫多少個媽一起生都一樣,軟體工程就是像這樣的工作,因為它必須除錯,而除錯就具有連續性的本質。

系統測試 :
在時程中,組件除錯(component debugging)和系統測試(system test)是受連續性限制影響最徹底的部分,甚至,需要耗費的時間是基於所遭遇到的錯誤數目以及錯誤的棘手程度,理論上,這個數目應該是零,但因為樂觀, 使我們預期的錯誤數目往往會比真正遭遇到的少,因此測試總是大大地延誤時程。

我要特別指出,沒有分配足夠的時間給系統測試,就會釀成大災難,這是因為等到交貨在即,發現時間不夠用的時候,時間卻已經快用光了,而在這之前,都沒有人會意識到時程有什麼不對勁,結果,在噩耗、落後竟然都沒有任何預警的情況下,把你的顧客和老闆嚇一大跳。

要有勇氣堅持自己的預估 :
請注意,程式設計師的遭遇跟廚師一樣,顧客的催促也許會左右工作的預定完成時間,但對工作的實際完成時間不會有什麼影響。一客煎蛋卷,答應兩分鐘做 好,而且看起來應該可以順利上桌,但是如果到了兩分鐘還沒有做好,那麼這位顧客只有兩種選擇──繼續等,或者吃生的。你的軟體顧客也是只有這兩種選擇。   

當然廚師還有另外一種選擇,他可以把火加大,那煎蛋卷就完蛋了──有一半燒焦,另一半還是生的。   

我不認為軟體 專案經理在先天上就缺乏廚師的勇氣與堅持,或是在這點上比其他工程領域的管理者還差,但是在軟體界,以錯誤的時程去配合顧客期望的日期,這是比其他工程領 域還普遍的現象。對於缺乏數據、僅憑很少的資料、主要靠著專案經理的直覺所預估出來的時程,很難提出一個強而有力、能夠自圓其說,並足以擔保一切風險的辯 解。

明顯地,這必須從兩方面來解決。我們先要蒐集並告知大家有關生產力的資料、錯誤發生率的資料、預估時程的法則等等,唯有藉著分享這些資料,整個軟體界才能夠獲利。

另一方面,在為預估方法找到一個更為堅實的基礎之前,專案經理個人必須挺起胸膛,勇敢為自己的估計堅持立場,保證就算是他的直覺再不濟,也比用願望來做預估要好。   

雖然不夠嚴謹,看來也異於常理,我們還是在此提出Brooks定律:在一個時程已經落後的軟體專案中增加人手,只會讓它更加落後。(Adding manpower to a late software project makes it later.)   

這 定律破除了人月神話。軟體專案會耗費多少時間是看它有多少連續性的限制,該投入多少人力是看它可以切分成多少獨立的子工作,根據這兩點,我們就可以推論出 用人較少、耗時較多的時程(唯一的風險就是軟體落伍的問題),然而,你是無法得到一個用人較多、耗時較少而又行得通的時程。軟體專案進行不順利的原因或許 很多,但絕大部分都是缺乏良好的時程規劃所致。

博客來 人月神話 : 軟體專案管理之道

Friday, August 17, 2007

RF and Baseband of BT

RF(無線電):

  • 採用2.4GHz的ISM公用頻段 - 頻段從2400MHz 到 2483,5MHz,劃分為79個頻道,每個頻道1MHz (f=2402+k MHz, k=0,…,78)
  • 採用跳頻式展頻技術(Frequency Hopping Spread spectrum)- 每秒跳動1600次(在正常操作的情況下)1Mhz的頻道間距
  • 採用GFSK(Gaussian Frequency Shift Key)調變 - 數位FM模式,容許的峰值頻率偏差為175kHz
  • 最低功率的傳輸距離為10公尺,加大功率最多可達100公尺
Baseband(基頻):
  • BT device address: 每個bt device有一個48 bits的IEEE MAC, it's like an unique id of the device. MAC分成 -- Lower address(24 bits), Upper address(8 bits) and Non-significant address(16 bits)


  • BT clock: Every Bluetooth device shall have a native clock that shall be derived from a free running system clock. The clock determines critical periods and triggers the events in the device. Four periods are important in the Bluetooth system: 312.5 μs, 625 μs, 1.25 ms, and 1.28 s.
  • Piconet and Scatternet: a) single-slave piconet, b) multi-slave piconet and c) scatternet (master is also slave, many piconets form a scatternet)

  • 封包結構: access code, header, payload (this is the standard basic rate packet format)
  • Logical transport:
    • Synchronous Connection-Oriented (SCO) logical transport
    • Extended Synchronous Connection-Oriented (eSCO) logical transport
    • Asynchronous Connection-Oriented (ACL) logical transport
    • Active Slave Broadcast (ASB) logical transport
    • Parked Slave Broadcast (PSB) logical transport
SCO : Circuit-switched - 較適合語音(Voice)服務的傳輸方式,它有點像是在溝通的兩方之間設立一條專 用道路,這條專用道路在通話過程中不會有別人來Share。
ACL : Packet-switched - 大家共享一條高速公路,人少的時候,你可以開快一 點。塞車的時候,就會慢一點,通常較適合資料(Data)的傳輸。

Thursday, August 16, 2007

Bluetooth

Mapping between Bluetooth, OSI model and IEEE802 standards




Bluetooth Core System Architecture (the four lowest layer)



C-plane :

  • device control services that modify the behavior and modes of a Bluetooth device,
  • transport control services that create, modify and release traffic bearers (channels and links)
U-plane :
  • data services that are used to submit data for transmission over traffic bearers

Bluetooth controller operates the lowest three layers (Radio, Baseband and Link Manager layers) and the L2CAP layer is contained with the rest of the Bluetooth application in a host system.
The standard interface is called the Host to Controller Interface (HCI) and its service access points are represented by the ellipses on the upper edge of the Bluetooth controller subsystem.

Channel manager : responsible for creating, managing and destroying L2CAP channels for the transport of service protocols and application data streams.

L2CAP resource manager : responsible for managing the ordering of submission of PDU fragments to the baseband and some relative scheduling between channels to ensure that L2CAP channels with QoS commitments are not denied access to the physical channel due to Bluetooth controller resource exhaustion.

Device manager : responsible for all operation of the Bluetooth system that is not directly related to data transport, such as inquiring for the presence of other nearby Bluetooth devices, connecting to other Bluetooth devices, or making the local Bluetooth device discoverable or connectible by other devices.

Link manager : responsible for the creation, modification and release of logical links.

Baseband resource manager : responsible for all access to the radio medium. It has two main functions. At its heart is a scheduler that grants time on the physical channels to all of the entities that have negotiated an access contract. The other main function is to negotiate access contracts with these entities. An access contract is effectively a commitment to deliver a certain
QoS that is required in order to provide a user application with an expected performance.

Link controller : responsible for the encoding and decoding of Bluetooth packets from the data payload and parameters related to the physical channel, logical transport and logical link.

RF : responsible for transmitting and receiving packets of information on the physical channel.

Wednesday, August 1, 2007

在CE下自動開啟目錄

沒想到msdn library有CreateDirectory, RemoveDirectory
但就是沒有OpenDirectory
還好達哥之前有寫過
不然這個方法我大概要找很久吧 orz

void OpenFolder()
{
HWND hwnd;
SHELLEXECUTEINFO si;

memset (&si, 0, sizeof (si));
si.cbSize = sizeof (si);
si.fMask = 0;
si.hwnd = hwnd;
si.lpFile = TEXT ("\\My Flash Disk\\PEtestfolder"); //要開啟的資料夾
si.lpVerb = TEXT ("explore"); //特定參數

ShellExecuteEx (&si);
}

lpVerb
Long pointer to a string specifying the name of a verb. The verb specifies an action for the application to perform. The set of available verbs depends on the particular file or folder. It includes the commands listed in the context menu and the registry. The following table shows verbs that are usually valid.
Value Description
Edit The function opens an editor.
Find The function initiates a search starting from the specified directory.
Open The function opens the file specified by the lpFile parameter. The file can be an executable file or a document file. It can also be a folder. This is the default verb if no verb is specified.
Print The function prints the document file specified by lpFile.

其他的verbs要參考registry的HKEY_CLASSES_ROOT\object_name\Shell\verb

不懂的是explore這個參數是哪來的,如果設Open會不會有一樣的結果?
試了之後發現
也是可以的!

Friday, July 20, 2007

Loading Stream driver from ap

如果不想要系統啟動時由DeviceManager自動載入我們寫的driver,而是經由上層ap呼叫去load的話,則在platform.reg有一個地方要改 : 就是把[HKEY_LOCAL_MACHINE\Drivers\BuiltIn\Cin]的BuiltIn拿掉,系統就不會自動載入了,路徑可自定,不要在BuiltIn底下即可。
e.g. [HKEY_LOCAL_MACHINE\Drivers\Cin]


//cintest.cpp - demo ap to load driver
//---------------------------------------------------------------------------------
HANDLE hDevice; //handle to initialize the driver
HANDLE hSerial; //handle to open the driver, used by write, read, seek and ioctrl

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) {
DWORD cBytes_out, cBytes_in;

char cBuffer_out[] = "\f\n Hello WORLD! \n\r";
TCHAR cBuffer_in[80];

printf("\n CinTest Demo driver \n");

//使用ActivateDeviceEx時,lpszDevKey 路徑不用加上 HKEY_LOCAL_MACHINE,加的話driver叫不起來
hDevice = ActivateDeviceEx(L"Drivers\\Cin", NULL, 0, 0);
if (hDevice == INVALID_HANDLE_VALUE) { printf("file init errors \n", "%X", hDevice); return 0; }

hSerial = CreateFile(_T("CIN1:"), GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);

if (hSerial == INVALID_HANDLE_VALUE) { printf("file open errors \n", "%X", hSerial); Sleep(4000); return 0; }

if (!WriteFile(hSerial, cBuffer_out, strlen(cBuffer_out), &cBytes_out, NULL))
{ printf("file write errors\n"); Sleep(4000); return 0; }
cBuffer_in[0] = 0;


if (ReadFile(hSerial, cBuffer_in, 1, &cBytes_in, NULL))
{
if (!WriteFile(hSerial, cBuffer_in, cBytes_in, &cBytes_out, NULL))
{ printf("\rfile write errors\n"); Sleep(4000); return 0; }
}

CloseHandle(hSerial);
DeactivateDevice(hDevice);
return 0;
}

Result :

Tuesday, July 17, 2007

Using Macros and Environment Variables

The Build utility uses numerous environment variables and macros:

  • Environment variables are set by the SetEnv.bat batch file when you open a Windows Driver Kit (WDK) build environment window.
  • Macros are specified in the sources files. These files must exist in each source code subdirectory.
The distinction between environment variables and macros is weak, because some environment variables can be referenced or changed within "sources" files, and some macros can be defined as environment variables in the build environment window. However, it is recommended that you not attempt to interchange environment variables and build macros in this manner.

Build Utility MacrosSources File 兩個分類下都有macro的list,不同的是Build Utility Macros分類下除了macro之外也可以用來做環境變數的設定

Build Utility Macros


Sources File

以下是一些巨集的介紹,完整的list要連到MSDN去參考

DEFFILE :
This macro definition specifies the name for the module-definition file (.def), known as an export file, for TARGETNAME.

DLLENTRY :
This macro definition specifies the function that is used as the entry point for a .dll file if the value of TARGETTYPE is set equal to DYNLINK. If no value is given for DLLENTRY, the default value is _DllMainCRTStartup

INCLUDES
:
This macro definition specifies additional paths used to find included .h files.
Use this macro only for your private .h file directories because the standard public .h file directories are automatically included. The default value is NULL.

__PROJROOT :
This macro defines the location of a project.

RELEASETYPE :
This macro definition sets two flags: RELEASEDIR and RELEASELIBDIR, which specify which output directory to place binaries and libraries in after they are built.

SOURCELIBS :
This macro definition specifies library (.lib) files to be linked with the module specified in TARGETNAME. The default value is NULL.

SOURCES :
This macro definition contains a list of files that are processed during the build process to become the contents of a library (.lib) file or dynamic-link library (.dll) file.
The list of files consists of assembly files and source files with extensions. These include the following file types: .cxx, .cpp, .c, .asm, .s, .src, .rc, .obj, .ire, .res, .h, .odl, .tlb, .i, .cs, and .resx.
Header files cannot be included in the SOURCES macro definition.

SYNCHRONIZE_DRAIN
:
This macro definition allows you to ensure that all preceding library files are built before building the current directory, which depends on the previous libraries.

TARGETLIBS :
This macro definition specifies additional library (.lib) files and object (.obj) files that should be linked into the target executable (.exe or .dll) file.

TARGETNAME :
This macro definition specifies the name of the .exe or .lib file being built, excluding the file name extension.
Build.exe creates a file named Proj2.extension, where extension can be .lib, .dll, or .exe.

TARGETPATH :
When RELEASETYPE equals CUSTOM, TARGETPATH specifies the object directory into which you are building the target device.

TARGETTYPE :
This macro definition specifies the type of file being built. (exe, lib or dll)
這裡有一篇說明提到TARGETTYPE不只這三種,有興趣可以看看 (不清楚在什麼情況下會用到) -> Utilizing a sources File template

WINCEOEM :
If a component needs to use header files and import libraries from the public projects that it depends on, set this macro definition to 1.
This setting means that the component cannot be used across releases of the system.
This macro definition should be set only by system-level components.

Thursday, July 12, 2007

Stream interface drivers

The most common driver model in Windows CE is the stream interface driver. This driver model has roots in the earliest implementations of Unix. A stream driver exports functions to open, close, read, write, seek, or control the underlying hardware.

The stream interface is appropriate for any I/O device that can be thought of logically as a data source or a data sink. That is, any peripheral that produces or consumes streams of data as its primary function is a good candidate to expose the stream interface. A good example is a serial port device. An example of a device that does not produce or consume data in the traditional sense would be a display device, and indeed, the stream interface is not exposed for controlling display hardware.

A stream interface driver receives commands from the Device Manager and from applications by means of file system calls. The driver encapsulates all of the information that is necessary to translate those commands into appropriate actions on the devices that it controls.

All stream interface drivers, whether they manage built-in devices or installable devices, or whether they are loaded at boot time or loaded dynamically, have similar interactions with other system components.

The following illustrations show the interactions between system components for a generic stream interface driver that manages a built-in device, and for a stream interface driver for a PC Card Client device. Figure below, shows the architecture for stream interface drivers for built-in devices that are loaded by the Device Manager at boot time.




Stream Interface Driver Entry Points
Here and elsewhere, XXX refers to a three character prefix you choose for your device driver. When implementing a stream interface driver replace XXX with a prefix appropriate for your specific implementation.

You can implement a driver with only Init and Deinit entry points and no device prefix. You cannot access this driver using CreateFile.

If DEVFLAGS_NAKEDENTRIES is specified in the driver's Flags registry subkey, the entry point names can be undecorated; for example, Open, Close, and so on. The sample battery driver, which is in %_WINCEROOT%\Public\Common\OAK\Drivers\Battdrvr, is an example of a driver that uses undecorated entry points. The battery driver's registry settings still must include a prefix.

Your implementations of these entry points must be declared for export from your DLL by placing __declspec(dllexport) in front of your function declaration. If you are developing in C++, your entry points must also be declared extern "C" as well.



Single Access and Multiple Access
A stream interface driver can implement either single access or multiple access by using the hOpenContext parameter passed to all file I/O functions.

To enable multiple access, each call to the XXX_Open function should return a different value for hOpenContext. The device driver must track which return values from XXX_Open are in use.

To enforce single access, only the first call to XXX_Open should return a valid hOpenContext value. As long as this value remains valid, which is until XXX_Close is called for the value, subsequent calls to XXX_Open should return NULL to the calling application to indicate failure.



Stream Interface Driver Functions
XXX_Init
Called when an instance of the driver is loaded. This function is required by drivers loaded by ActivateDeviceEx, ActivateDevice, or RegisterDevice.

The following list shows the tasks this function can perform:

  • Initialize the installed device to a default state.
  • Allocate resources used globally by the device driver.
  • Register a status callback function with PC Card Services.
    When the status of the device changes, the operating system calls this status callback function. For example, the status of a PC Card changes when you insert it or remove it.
  • Map system memory and I/O space to a PC Card device memory and I/O space.
  • Request notification on specific callback events.
  • Register an interrupt callback function for an interrupt-driven device.
    When the device generates an interrupt, the operating system calls this interrupt callback function.

XXX_Deinit
Called when an instance of the driver is unloaded. This function is required by drivers loaded by ActivateDeviceEx, ActivateDevice, or RegisterDevice.

If you have threads blocked in your driver, resources associated with the handle or device instance might not be able to be released. To avoid this, implement the XXX_PreClose (Device Manager) and XXX_PreDeinit (Device Manager) entry points.

XXX_Open
Called when a driver is opened by an application with CreateFile.

When this function executes, your device should allocate the resources that it needs for each open context and prepare for operation. This might involve preparing the device for reading or writing and initializing data structures it uses for operation.

XXX_Close
Called when a driver is closed by the application with CloseHandle.
An application calls the CloseHandle function to stop using a stream interface driver. The hFile parameter specifies the handle associated with the device context. In response to CloseHandle, the operating system invokes XXX_Close.

The file handle specified for hOpenContext is no longer valid after this function returns; if an application tries to perform stream I/O operations on that handle after calling CloseHandle, those operations fail.

XXX_IOControl
Called when the application calls DeviceIoControl. This function might or might not be required, depending on the device capabilities that the driver exposes. This function requires an implementation of XXX_Open and XXX_Close.

XXX_Read
Called when the application calls ReadFile.

XXX_Write
Called when the application calls WriteFile.

XXX_Seek
Called when the application calls SetFilePointer.

After an application calls the SetFilePointer function to move the data pointer in the device, the operating system invokes this function. If your device is capable of opening more than once, this function modifies only the data pointer for the instance specified by hOpenContext.

XXX_PowerUp
Called just before the system resumes. Optional.

The power handler functions, XXX_PowerUp and XXX_PowerDown, execute in kernel mode, and they cannot be pre-empted

XXX_PowerDown
Called just before the system suspends. Optional. It is useful only with devices that can be shut off under software control. Such devices are typically, but not exclusively, PC Cards.

XXX_PreClose
Optional. This function marks the closing handle as invalid and wakes any sleeping threads.

XXX_PreDeinit
This function marks the device instance as invalid and wakes sleeping threads. Required if the XXX_PreClose function is implemented.

Tuesday, June 12, 2007

GOOGLE 超犯規!!

google better than Limewire

難怪會一直被告 ~"~
這要保持低調啊 ><

Monday, June 11, 2007

AJAX

Asynchronous JavaScript And XML(/DHTML)
Ajax 由 HTML、JavaScript™ 技術、DHTML 和 DOM 組成,這一傑出的方法可以將笨拙的 Web 介面轉化成互動性的 Ajax 應用程式。

理解 Ajax 及其工作原理,建置網站的一種有效方法

Ajax開發教程

AJAX討論區 JavaWorld@Taiwan

APP208 Building AJAX applications on IE mobile (MEDC 2007)

AJAX in action (pdf)

Tuesday, June 5, 2007

MEDC 2007

APP321
Building World-Ready Windows Mobile© Applications by Mel Sampat

這堂演講的主題是寫程式的人該如何撰寫
讓application在轉換語言及使用設定(ex 時間日期格式)時可以輕鬆移植

Design strategies

  • Larger Text Fields -> 30% larger is a general rule.
  • Avoid Run-time string composition (各國語法不同 )
ex:
"are you sure you want to delete file?"
"are you sure you want to delete directory?"
"are you sure you want to delete subdirectory?"

char String[] = "are you sure you want to delete";
char FinalString[] = String + object + "?";

  • Avoid reusing resources (指重複相同的名詞但意義上不同會造成翻譯人員的困擾 orz)
  • Use FORMATMESSAGE instead of wsprintf (避免格式化時data buffer不足)
  • Use MUI DLLs (multilingual user interface DLLs)
  • Use NLS APIs (national language support APIs)

International API

Thursday, May 17, 2007

KernelIOControl function

Parameter Bits Win32 Type Managed Type Typical Value
dwIoControlCode 32 DWORD Int32 IOCTL_HAL_GET_DEVICEID
lpInBuf 32 LPVOID IntPtr IntPtr.Zero (no input data required)
nInBufSize 32 DWORD Int32 0 (no input data required)
lpOutBuf 32 DEVICE_ID* byte[] byte[20] (20 bytes is the size of the DEVICE_ID structure)
nOutBufSize 32 DWORD Int32 20
lpBytesReturned 32 LPDWORD ref Int32 0

On Windows CE, the Platform ID and Preset ID can be any length.
e.g. int = KernelIoControl(IOCTL_HAL_GET_DEVICEID, NULL,
sizeof(DWORD), (VOID*)val, sizeof(DEVICE_ID), NULL);


Get Device ID

轉檔

Online FLV Converter
可以把youtube上的播放檔轉成MPEG4 (AVI/MOV/MP4/MP3/3GP)
並且提供連結供下載 速度也很快
只要把檔案網址貼上然後選擇要轉的檔案 就ok了

--不知道連結啥時會失效 -- 目前還是beta版

話說SourceForge.net真是提供opensource的好地方...

Tuesday, May 15, 2007

SendMessage & PostMessage

BOOL PostMessage(

... );

LRESULT SendMessage(

... );

SendMessage的傳回值是LRESULT、PostMessage的傳回直是bool

PostMessage 是將一個訊息送往某一個視窗 handle 的Message Queue,
所以應用程式本身並不會知道也不想知道這個
Message的處理結果,
但是SendMessage便不同了,
應用程式可以由傳回值知道這個Message的處理結果
那麼, 在程式發出 SendMessage 的請求時,
我們程式便將控制權移交給接受該Message的視窗,
等待他處理結束該
Message
所以該Message並不會送往 Message Queue,
而是直接執行該處理訊息函示

PostMessage和SendMessage的區別
Message Queue


差別在於同步跟非同步...

接收broadcast訊息

how to broadcast:

#define WM_HOLDKEY_ON (WM_USER+3041)
....
void InitThread()
{
WNDCLASS wndclass;
HANDLE hEvent[n]={0};
DWORD dwStatus;

hEvent[0] = CreateEvent(NULL, FALSE, FALSE, kHoldKeyEventName);
....
while(TRUE)
{
dwStatus = WaitForMultipleObjects(n, hEvent, FALSE, INFINITE);

switch(dwStatus)
{
case (WAIT_OBJECT_0 + 0):
SendMessage(HWND_BROADCAST,WM_HOLDKEY_ON,0,0);
break;
....}
}
}

catch broadcast message using MFC:

#define WM_HOLDKEY_ON (WM_USER+3041)
....
BEGIN_MESSAGE_MAP(CCatchBroadcast, CDialog)
ON_MESSAGE(WM_HOLDKEY_ON, OnHOLDKEY_ON)
END_MESSAGE_MAP()

....
LRESULT CCatchBroadcast::OnHOLDKEY_ON(WPARAM wParam, LPARAM lParam)
{
//do whatever
return 0;
}

using WIN API(not MFC):

#define WM_HOLDKEY_ON (WM_USER+3041)
....
LRESULT CALLBACK xxxMainProc (HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)
{
switch (iMessage)
{
....
case WM_HOLDKEY_ON:
//do whatever
break;}
return FALSE;
}


The WM_USER constant is used by applications to help define private messages for use by private window classes, usually of the form WM_USER+X, where X is an integer value.
WM_HOLDKEY_ON, 3041 是自己定義的,建立溝通可用這個方式傳送及接收自己定義的訊息

MFC message map 簡單明瞭的解釋處理訊息的三種方式~ 只有MFC的寫法

Wednesday, May 2, 2007

好玩的部落格

在sidebar加上
comment: 到 最新回應程式產生器 將產生出來的程式碼貼到 HTML/Javascript 的 tag (Customize -> Add a page element -> HTML/Javascript -> Add to Blog)

bookmarks: 要先註冊hemidemi的網站,已經有新增/收藏好的書籤之後,到工具(在右上方) -> Blog工具 -> 在您的部落格輪撥最新書籤,將程式碼用跟Comment同樣的方式加到sidebar

bookshelf: 先到aNobii網站註冊,只要打入ISBN或是書名就可以找到書的資訊,收藏好之後,網站也是提供程式碼讓使用者可以剪貼到自己的部落格

Wednesday, April 25, 2007

如何讓APP跟Driver同步

//以HOLD KEY為例
//Driver side create event

#define kHoldKeyEventName TEXT("HoldKey")
#define kUnHoldKeyEventName TEXT("UnHoldKey")
HANDLE hHoldKeyEvent;
HANDLE hUnHoldKeyEvent;

IniTFunction() {
...
...
hHoldKeyEvent = CreateEvent(NULL, FALSE, FALSE, kHoldKeyEventName);
hUnHoldKeyEvent = CreateEvent(NULL, FALSE, FALSE, kUnHoldKeyEventName);
...
...
}


HandlerFunction() {
...
if(holdkey) {
...
SetEvent(hHoldKeyEvent);
... }
else {
SetEvent(hUnHoldKeyEvent);
... }
}

---------------------------------------------------------------------
//Application side
#define kHoldKeyEventName TEXT("HoldKey")
#define kUnHoldKeyEventName TEXT("UnHoldKey")

int WINAPI WinMain( HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow) {
...
InitThread();
...
}

//Single thread
void InitThread() {
HANDLE hEvent[2]={0};
DWORD dwStatus;

hEvent[0] = CreateEvent(NULL, FALSE, FALSE, kHoldKeyEventName);
hEvent[1] = CreateEvent(NULL, FALSE, FALSE, kUnHoldKeyEventName);

while(TRUE) {
dwStatus = WaitForMultipleObjects(2, hEvent, FALSE, INFINITE);

switch(dwStatus) {
case (WAIT_OBJECT_0 + 0):
break;

case (WAIT_OBJECT_0 + 1):
break; } }
}

Monday, April 23, 2007

Build process of WinCE

CESYSGEN Phase (CEBUILD.BAT, sysgen.bat)

This is the first phase of the build process. This step will process the headers and .lib files for the whole system.

BSP Phase (Build.exe)

The BSP (and later stages) are run the most when developing a new system. This phase compiles and links all of your drivers and OAL code.

BUILDREL Phase (BuildRel.BAT)

This phase is focused on collecting files from various parts of the build and copying them all to a single flat release directory (%_FLATRELEASEDIR%). The files and target folders contents from the BSP are copied in to get the modules built in the BSP Phase, along with BSP-specific configuration settings from the BSP's Files directory. When using the IDE, your Platform Builder projects are built after all the files are copied over to the _FLATRELEASEDIR.

MAKEIMG Phase (makeimg.exe)

This is the final stage in the build process. It combines everything into a binary image file(s) for placement on your target hardware. It is implemented in three primary internal stages.

The first stage merges all of the various configuration files (BIB, DAT, REG, DB—we'll detail these files in just a bit) into one master file for each type. The following table shows the files and their corresponding master-merged file.

Original files Merged file Description
Common.bib, Config.bib, Project.bib, Platform.bib Ce.bib Identifies all the Windows CE files to be combined into the operating system image.
Common.reg, Project.reg, Platform.reg Reginit.ini Provides a collection of registry entries for the operating system image.
Common.dat, Project.dat, Platform.dat Initobj.dat Provides a description of the directory and file locations for the operating system image.
Common.db, Project.db, Platform.db Initdb.ini Defines the creation of any databases in the Windows CE object store.

In the second stage following the merge, makeimg will process all of the EXE and DLL modules specified in LOC files to replace the resources for the current language specified for the build.

After the resources are updated, the makeimg will run ROMIMAGE as the third stage. This will link and locate all execute-in-place code files in the image, and create a ROM file system image for all the other files. This file system is merged with the RAM and other file systems within the Windows CE single-rooted file system. All files in ROM are located in the \Windows Folder.

RomImage will generate the final image as NK.BIN, and optionally as an SRE or as absolute binary image(s) suitable for burning directly into Flash.

from MSDN

where to check if driver is built in or not

check for dlls at
PBWorkspaces\xxx\RelDir\xxx000_Release
ce.bib
platform.bib

The .bib file details the memory layout that the boot loader will use.

--------------
如果要載入任何檔案 (e.g. bmp, exe, whatever) 到CE的Windows folder
在platform.bib的FILES區段 加入檔案敘述
並且把檔案存到相同目錄底下

Friday, April 20, 2007

PixelFormat16bppRGB565

Specifies that the format is 16 bits per pixel; 5 bits are used for the red component, 6 bits are used for the green component, and 5 bits are used for the blue component.

RGB8888(32 bit) to RGB565(16 bit) pixel format conversion

565 format represents each pixel in the following bit order:
565 format: RRRR RGGG GGGB BBBB

drop the least significant bits of each color channel, ex:

R8 = 255
Convert R8 => R5 by dropping the last bits (255 >> 3)
R5 = 31

Going the other way (R5G6B5 => R8G8B8) is trickier.
A naive implementation reverses the R8 => R3 operation by shifting up:

R5 = 31
Convert R5 => R8 by shifting up (31 << 3)
R8 = 248 (Not what we wanted, the channel is darker now).


更改winCE開機logo

用一個array存成header file
例如 320*240解析度的圖
是一個含有76800個element的array
每個element填一個color

先用bitmap tool把.bmp檔轉成header file -> logobmp_320X240.h
再把這個header file存到 platform -> snapXXX -> kernel -> OAL

不過這個header file是在哪被呼叫的呢? 還不知道~

---

每個platform的環境變數都存在 xx.bat
以螢幕大小為例:

@REM ======================================================================
@REM display resolution
@REM ======================================================================
SET BSP_DISPLAY_WIDTH=320
SET BSP_DISPLAY_HEIGHT=240

Wednesday, April 18, 2007

I2C Bus Arbitration

如果只有一個master,data corruption的情況比較難遇到
不過因為I2C是multi-master bus, 所以可能會有不只一個master的情形
假設有兩個MCU,CPU1發出START condition,
這時CPU2跟其他device會是SLAVE,不會有什麼問題發生。
但是如果CPU1發出START condition(SDA LOW, SCL LOW)時,
CPU2錯過這個訊息或是剛reset而誤以為bus目前沒人使用而拉HIGH時,
會發現line還是LOW的(CPU1還未釋放bus),
這時CPU2就會知道bus並非idle而BACK-OFF,
一直等到CPU1發出STOP condition,再去爭取主控權。

Friday, April 13, 2007

RNDIS

Remote Network Driver Interface Specification

(NDIS 網路驅動程式介面規格) Miniport 驅動程式,有兩項基本功能:

  • 管理網路介面卡,包括透過介面卡的資料傳送與接收。
  • 擔任更高層級驅動程式的介面,例如中繼驅動程式與傳輸通訊協定驅動程式。

Miniport 驅動程式與其網路介面卡及更高階層的驅動程式,是透過 NDIS 程式庫通訊,它從網路驅動程式中抽取網路硬體。NDIS 也在各層網路驅動程式之間明確界定了一個標準介面,從網路傳輸之類的上層驅動程式中,抽取出負責處理硬體的較低層級驅動程式。NDIS 並維護網路驅動程式狀態資訊及相關參數。

from Microsoft


RNDIS 連線教學
  1. set BSP_RNDIS_KITL = 1 in xxx.BAT (platform的環境變數,path在platform\xxx下)
  2. rebuild image
  3. boot device and enter eboot
  4. set mac address (option 7) = device的網路卡實體位置
  5. select i (DOWNLOAD image via USB RNDIS Ethernet)
  6. install PC USB RNDIS driver (C:\ WINCE500\ PUBLIC\ COMMON\ OAK\ CSP\ ARM\ Cxx...\ 5000\ TOOLS)
  7. 之後會自動跳出新的連線
  8. 選取原本的網路連線與新的連線,按右鍵點橋接器連接
  9. Then you can use DHCP to get IP for your device
  10. Enter platform builder, Target -> Connectivity option
  11. For option Download & Transport, select Ethernet and click on Settings, choose the model. For option Debugger, select Kdstub
  12. select Platform -> setting -> File name for runtime image -> chain.lst
  13. Select Target -> Attach device

And it will start to download image.
After image is downloaded, you could get all the retail message in platform builder console.


USB RNDIS 就是以USBclient來模仿Ethernet的傳輸數據的行為,達到實現Kitl的目的。

*
當我選橋接器連接會出現以下message:
您必須至少選取二條私人網路連線,[橋接器連線] 才能建立橋接器。
後來把網路連線 -> 內容 -> 進階 ->
允許其他使用者使用Internet的勾勾取消就可以連了


Thursday, April 12, 2007

Monolithic kernel vs Micro-kernel

Monolithic kernel based system

This is the traditional design of Unix systems. Every part which is to be accessed by most programs which cannot be put in a library is in the kernel space:

  • Device drivers
  • Scheduler
  • Memory handling
  • File systems
  • Network stacks
Micro-kernel based system

Only parts which really require to be in a privileged mode are in kernel space :

  • IPC (Inter-Process Communication, see below)
  • Basic scheduler, or scheduling primitives
  • Basic memory handling
  • Basic I/O primitives
from The Gnu Hurd

Monolithic Kernel 最主要的優勢為執行速度。而 Micro-kernel 則是 stability 與 security。

導致ecompass不準確的一些可能原因

環境磁場

引述garmin人員
被po在某網頁的回覆:
電子羅盤的IC是由許許多多具有磁性的小分子所構成的,在沒校正之前,這些小分子的排列是很紊亂的,所以得到的資料誤差就會比較大;但經過校正後,裡面的小分子會排列得很整齊,所以就可得到比較準確數值。不過校正過後,分子也不會一直都排列得很整齊,有很多原因會造成裡面分子排列變亂,環境溫度就是一個最明顯的例子;所有的磁性物質在溫度改變時,磁力分子都會產成變化,所以每過一陣子才會需要使用者校正。如:當溫度高到某個程度時,所有磁力物質的磁力都會消失,這個現象稱為"退磁"。
所有的羅盤都是反應「環境磁場」,不管是不是電子式或是傳統的羅盤。根據冷次定律,電流會產生磁場,所以不管那個羅盤在電線邊都是會受到電線所產生的磁場所影響。這並不是誤差,只是反應現場的狀況而已。

在PCB上配置不佳

1. 配線時應注意 Any wire other than the wires to ecompass is not allowable in the area over and under e-compass including both sides of PCB
2. 電流變動不可超過e-compass所能容許的範圍
3. keep magnetic parts such as speakers, vibrators, inductors or any other chips that may generate magnetic fields away from e-compass as far as possible
4. don't place e-compass on a battery

Library module

Neither correct attitude nor direction can be obtained unless a fine offset value of the geomagnetic field sensor is set to the Library Module. 如果要在系統啟動後取得正確的方向跟位置,必須先儲存offset value在FLASH or HDD, and set it to the Library Module before measurement.

Wednesday, March 28, 2007

problem: cannot open COM port

scene: xDevice --(I2C)--> xDriver --(stream interface)--> OS --(file object)--> Application

xDriver provides stream interface for COM port driver to the OS, and the OS provides file objects of a COM port device to applications. The application obtains information from xDriver through file objects to the COM port.

for example: (sample code on application layer)

BOOL xDriver::Open()
{
m_Handle = CreateFile( _T("COM7:"),
GENERIC_READ | GENERIC_WRITE,
0,
NULL,
OPEN_EXISTING,
0,
NULL);

if(m_Handle == INVALID_HANDLE_VALUE) return FALSE;
return TRUE;
}

如果return false, 一個原因可能是與registry記錄的"Index"值不同而無法開啟。
in my case,
到 "...PLATFORM\PROJECT\FILES" -> PLATFORM.REG
然後查是否有 跟ap code 相對應的driver的 registry
如果有相對應的driver存在,檢查
"Prefix"="COM"
"Index"=dword:6
可以看到此driver是透過COM6,因此只要把sample code的 COM7 改成 COM6 就可以溝通了

Monday, March 26, 2007

I2C - Bus Protocol

The I2C protocol specification states that the IC that initiates a data transfer on the bus is considered the Bus Master. Consequently, at that time, all the other ICs are regarded to be Bus Slaves.

取得控制權的IC會觸發 START condition
(當SCL high時,SDA 從 high -> low)
以引起所有slaves的注意。
transferring data 結束後 同樣的IC會觸發 STOP condition
(當SCL high 時,SDA 從 low -> high)
表示 bus 的控制權被釋放。




Transferring data

Once the START condition has been sent, a byte can be transmitted by the MASTER to the SLAVE. This first byte after a start condition will identify the slave on the bus (address) and will select the mode of operation( '1' = Read / '0' = Write ). 收到指定的SLAVE 會回傳 ACK signal by pulling the SDA line low, previously released (SDA high) by the transmitter.

Friday, March 23, 2007

eVC++ 4.0 - problem: can't find header files

probably the provider's application is built in another version of Platform builder
path : Project -> Settings -> C/C++ -> Preprocessor -> additional include directories
check WinCE version


eVC++ 4.0 - How to build SDK

Scene: Using eVC++ to develop application which have concern with hardware configuration.

solution: build custom SDK from provider's code (using Platform Builder)
path: Platform -> SDK -> Build SDK

SDK (package of header files and libraries)

Friday, March 16, 2007

CE5.0 - Problem: 設breakpoint, device無反應

Solution:

1. Platform -> Settings -> Build Options
check Enable Kernel Debugger
Enable KITL

2. Build OS -> Make Run-Time Image

CE5.0 - How to build under command line

path = ...\platform\project_name\src\drivers

> build -c (clean before building)
> makeimg (make run-time image)

Thursday, March 15, 2007

6.0 新功能

目前最新的Windows CE為Windows CE 6.0,這個版本在核心部分有很大的進步:

  • 所有系統元件都由EXE改為DLL,並移到 kernel space.
  • 全新設計的虛擬記憶體架構
  • 全新的裝置驅動程式架構,同時支援 User Mode 與 Kernel Mode 兩種驅動程式.
  • 突破只能執行 32 個工作元(process)的限制, 可以執行 32768 個工作元.
  • 每一工作元的的虛擬記憶體限制由32 M 增加到全系統總虛擬記憶體.
  • Platform Builder IDE 整合到 Microsoft Visual Studio 2005.
  • 新的安全架構, 確保只有被信任的軟體可以在系統中執行.
  • UDF 2.5 檔案系統
  • 支援 802.11i (WPA2)及 802.11e (QoS) 等無線規格, 及多重 radio support.
  • 支援 x86, ARM, SH4, MIPS 等各種處理器
  • 提供新的 Cellcore components 使系統在行動電話網路中更容易建立資料連結及啟動通話

Tuesday, March 13, 2007

I2C (Inter-Integrated Circuit) - Concept

I²C是一種串列通訊匯流排,使用多主從(multi-master bus)架構。

I²C uses two wires, serial data (SDA) and serial clock (SCL), carry information between the devices connected to the bus. Each device is recognized by a unique address (whether it’s a microcontroller, LCD driver, memory or keyboard interface) and can operate as either a transmitter or receiver, depending on the function of the device.



Additionally, a master can also be a slave, and vice-versa.

Overall, there are four distinct modes for a given bus:

  • master transmit — the node is in control of the clock and is sending data to a slave
  • master receive — the node is in control of the clock but is receiving data from a slave
  • slave transmit — the node is not in control of the clock but is sending data to a master
  • slave receive — the node is not in control of the clock but is receiving data from the master