2008年5月5日 星期一

整理_5


PMU: POWER UNIT、PWR I2C I/F
  • Power Manager I2C Interface / I2C Interface
    The PXA27x processor contains a dedicated I2C module for communicating with an external regulator. “I2C Bus Interface Unit” for a full description. The only differences
    between the power manager I2C (PWR_I2C) and the standard I2C interfaces are the register addresses.
POWER MICRO: SSP I/F
  • It is a low-power CMOS 8-bit microcontroller based on the AVR enhanced RISC architecture. By executing powerful instructions in a single clock cycle, the MCU achieves throughputs approaching 1 MIPS per MHz allowing the system designer to optimize power consumption versus processing speed.
  • The SSP ports are a synchronous serial interfaces that connect to a variety of external analog-todigital(A/D) converters, audio and telecommunication Codecs, and many other devices that useserial protocols for data transfer. The SSP ports provide support for the following protocols:
    • Texas Instruments (TI) Synchronous Serial Protocol
    • Motorola Serial Peripheral Interface (SPI) protocol
    • National Semiconductor Microwire
    • Programmable Serial Protocol (PSP)
    The SSP ports operate as full-duplex devices for the TI Synchronous Serial Protocol, SPI, and PSP protocols and as a half-duplex device for the Microwire protocol.
    The FIFOs can be loaded or emptied by the CPU using programmed I/O or by DMA burst
    transfers.
LCM: SPI I/F、LCD I/F


燒錄BT mac address
mon>man bt 00:00:00:00:00:00
確認BT mac address
mon>man bt
00:00:00:00:00:00

Gerber out
RD畫電路→給Layout lay電路→PCB送洗

整理_4


CAMERA: IMAGE I/F、I2C I/F
1D/2D IMAGER: IMAGE I/F、I2C I/F
KEYBOARD: I2C I/F

整理_3



WLAN: SDIO
Micro SD: SDIO
GPS: FF-UART
DUAL UART: CPLD External Bus
MDOC: PXA270 External Bus
SDRAM: PXA270 External Bus
CPLD: PXA270 External Bus、JTAG
  • CPLD is designed for both high performance and low power applications.
    This lends power savings to high-end communication equipment and high speed to battery operated devices. Due to the low power stand-by and dynamic operation, overall system reliability
    is improved.This device consists of sixteen Function Blocks inter-connected
    by a low power Advanced Interconnect Matrix (AIM).


2008年4月30日 星期三

整理_2






  • BT/WWAN---DUAL UART


WWAN: FF-UART (2.5G / 802.20 )---GPRS、GSM : The FFUART supports modem- control capability. The maximum baud rate is 921,600 bps.




BT: BT UART---Handset、Handfree : The BTUART is a high-speed UART that supports baud rates up to 921,600 bps and can beconnected to a Bluetooth module. It supports only two modem control pins (nCTS and nRTS).





STD UART : The STUART supports all functions, but does not support modem-control capability. The maximum baud rate is 921,600 bps.





Features:


The UARTs share the following features:


• Functionally compatible with the 16550A and 16750


• Ability to add or delete standard asynchronous communication bits (start, stop, and parity) inthe serial data


• Independently controlled transmit, receive, line status, and data-set interrupts


• Programmable baud-rate generator that allows the internal clock to be divided by 1 to (216 – 1)to generate an internal 16X clock


• Modem control functions (nCTS, nRTS, nDSR, nDTR, nRI, and nDCD)


• Auto-flow capability controls data I/O without generating interrupts:— nRTS (output) controlled by UART receive FIFO— nCTS (input) from modem controls UART transmitter


• Fully programmable serial interface:— 5-, 6-, 7-, or 8-bit characters— Even, odd, and no-parity detection— 1, 1½, or 2 stop-bit generation— Baud-rate generation up to 921 kbps for all UARTs— False start-bit detection


• 64-byte transmit FIFO


• Complete status-reporting capability


• Ability to generate and detect line breaks


• Internal diagnostic capabilities that include:


— Loopback controls for communications-link fault isolation


— Break, parity, and framing-error simulation


• Fully prioritized interrupt system controls


• Separate DMA requests for transmit and receive data services


• Slow infrared asynchronous interface that conforms to the Infrared Data Association (IrDA)specificationAudio CODEC





WM9714: AC97


The AC-link is a synchronous, fixed-rate serial bus interface to thedigital AC ’97 controller for transferring digital audio, modem, microphone input (MIC-in), Codecregister control, and status information.

The AC ’97 controller and the I2S controller cannot be used at the same time.

整理_1

  • WLAN 802.11d <不同區域的運作country selection>
    由於各國使用的射頻不同,802.11d主要解決在不同區域或國家透過此漫遊機制標準告知系統用什麼頻率來傳送資料以確保資料傳輸無誤



  • MDOC開機流程
    起始位址:0X00000000
    開始會執行IPL(包含Start HOST boot process的code),接著IPL會去Load Bootloader到RAM上執行,BootLoader會Init UART、SDRAM…,之後BootLoader會Load OSImage到RAM上執行。


  • 70階=>板接
    75階=>組裝 80階=>包材


  • A Band---802.11a (5G頻段,帶寬54M)
    B Band---802.11b/g (2.4G頻段,帶寬11/54M)
    5574 / 5504 b/g
    5590 a/b/g


  • WWAN(Wireless Wide Area Network)
    是指傳輸範圍可跨越國家或不同城市之間的無線網路,由於範圍廣大,通常都需由特殊的服務提供者來架設及維護整個網路,一般人只是單純以終端連線裝置來使用無線廣域網路。例如:行動電話使用的 GSM(Global System for Mobile Communications) 通訊系統就屬於 WWAN。

2008年4月22日 星期二

WLAN 802.11d / WWAN~

  1. 802.11d〈不同區域的運作 country selection〉。由於各國使用的射頻頻譜不同,802.11d主要解決在不同區域或國家透過此漫遊機制標準,告知系統用什麼頻率來傳送資料,以確保資料傳輸無誤。
  2. WWAN(Wireless Wide Area Network) 是指傳輸範圍可跨越國家或不同城市之間的無線網路,由於範圍廣大,通常都需由特殊的服務提供者來架設及維護整個網路,一般人只是單純以終端連線裝置來使用無線廣域網路。例如:行動電話使用的 GSM(Global System for Mobile Communications) 通訊系統就屬於 WWAN。
  • [1G] 第一代行動通訊為AMPS系統,這個系統提供了類比式的語音服務。
  • [2G] 第二代的行動通訊系統改進為提供數位式的語音服務,並提供更嚴密的安全機制。目前較為普遍的三種技術為GSM, CDMA和D-AMPS。

‧GSM為歐規的系統,採用TDMA 的技術,是目前世界上使用者最多的系統。

‧CDMA 系統採用code division 的技術,佔有亞太北美的市場。

‧D-AMPS 則是改進第一代行動電話系統AMPS 所制定的數位系統。

  • [2.5G] 功能與傳輸速率介在第二代和第三代行動通訊系統之間的通訊技術,泛稱為2.5代的系統。 所謂2.5 代的系統, 主要是改進原本第二代系統只提供單純的語音服務與少量的數據服務而設計的。 因此2.5代的系統並不是一個獨立的系統,它們皆是架構於原本2G 的系統,利用原本2G 系統的基礎結構(infrastructure),提供較高速且大量的數據傳輸。 因此從無線電通訊技術的觀點來看, 2.5 代的系統算是第二代技術的演進(evolution), 而非像進入第三代是一種創新的革命(revolution)。 架構於GSM 的系統之上, 稱得上是2.5 代的系統, 包括HSCSD, GPRS, EDGE。
  • [3G] 發展3G 是起源於ITU (International Telecommunication Union) 的會議WARC (World Administrative Radio Conference), ITU 從1986 年開始, 便開始研究如何達到下一代全球個人通信(Global Personal Telecommunication) 的目標. 其內容包含陸地上通訊與衛星。

2007年12月25日 星期二

語音信號處理

語音信號的處理流程:

語音信號輸入
↓
數位取樣 → 類比轉數位(類比信號→取樣→量化→編碼→數位信號)
↓
標準化→將原始語音信號做等比例的放大或縮小,使其取樣值都落在同一範圍中。
↓
取音框→短時段被單獨處理的語音信號,等性固定。
↓
端點偵測→將語音前後靜音部分去除,讓辨識結果較正確。(能量量測、越零率、折返率)
↓
預強調→利用高通濾波器,補償衰減掉的高頻部分。
漢明窗
↓
特徵參數求取→(線性預估編碼、倒頻譜係數、濾波器組)
↓
特徵參數輸出

2007年12月18日 星期二

語音辨識技術

參考出處:
http://ace136.auto.fcu.edu.tw/~cslin/scteach/scteach88/Tidsp/n5.htm
http://www.ascc.sinica.edu.tw/nl/87/1407/04.txt

機器辨識技術的對象,主要有聲音和影像兩大類。影像辨識所涵蓋的範圍較廣,諸如文字辨識、指紋辨識、簽名辨識、臉孔辨識、瞳孔辨識、包括上面提到的偽鈔辨識都是。聲音辨識則包括人類發出的語音、樂器發出的音樂、機器發出的噪音、動物的叫聲、聲納、大自然的聲音都是。簡單的說,就是以機器進行人類「眼睛」和 「耳朵」等兩個器官的功能「視覺」及「聽覺」,來達到自動化的效果。順帶一提的是,以機器進行「嗅覺」(人工鼻)、「觸覺」和「味覺」,雖非機器辨識技術的主流,也各有研究進行中。

何謂語音辨識
語音辨識(Speech Recognition)最主要的目的是希望電腦聽懂人類說話的聲音,進而命令電腦執行相對應的工作。當聲音藉由類比到數位的轉換裝置輸入電腦內部,並以數值方式儲存後,語音辨識程式便開始已事先儲存好的聲音樣本與輸入的測試聲音樣本進行比對工作。比對完成後點腦集輸入一個它認為最“像”的聲音樣本序號,我們就可以知道使用者剛剛唸進去的聲音代表何意,進而命令電腦做事。
設計一個語音辨識程式,至少又有兩方面的知識:
1.瞭解如何把外界的聲音訊號抓到電腦內部處理
2.瞭解聲音比對原理

語音辨識之技術分類
在「辨識技術」這個領域,依辨識對象的變化程度,而有不同的困難度。
語音特性的變化因素包括
(1)不同語者的變化:聲帶特徵、說話方式、連音耦合效應、口音等;
(2) 同一語者的變化:情緒、壓力、感冒、Lombard 效應;
(3)噪聲:汽車噪聲、空調噪聲、電話鈴聲、印表機噪聲、多人同時講話等;
(4)環境變化:反射(Re flection)、回音(Reverberation)、麥克風特性及與語者的距離等。
一般把語音辨識技術,根據詞彙大小、系統訓練、及發音方式做不同組合的分類。
詞彙大小分為
小字彙(小於 100 詞)、
中字彙(100 - 1000 詞)、
大字彙(1001 - 10000 詞)、
極大字彙(大於10000 詞)等。
系統訓練則有
(1)特定語者(Speaker-Dependent):使用前需訓練數十分鐘至數小時;
(2) 非特定語者(Speaker-Independent):不需訓練,可立即使用;
(3)系統調適(Speaker-Adaptation):數分鐘至數十分鐘的調適訓練。
至於發音方式有
(1)單字音:字與字需斷開;
(2)單詞連續發音:又細分為孤立詞、及詞詞斷開,連接成句兩種;
(3)整句連續語音: 又細分為關鍵詞萃取(Keyword Spotting)及全句辨識等兩種。
實際應用:
聽寫機(Dictation Machine)和語音指令&控制(Voice Command/Control)。
市面上的聽寫機一般為特定語者、單字音或單詞、極大字彙的語音辨識技術。
音指令&控制則為特定語者或非特定語者、單詞、中或小字彙的技術。
語音辨識的作法
電腦採用數位化的語音取樣資料,我們要知道對電腦而言,即使同一個人在同一個環境使用同樣的麥克風連續發出兩次同樣的語音,語音取樣資料也不可能完全相同,因此如何把語音做正確的歸類 ,異中求同,就是問題所在。一般常見的作法是(事先或現場)蒐集足夠的語音樣本,經過抽取適當的語音特徵(Feature Extration)之後,透過訓練程序(Training Procedure),建立參考聲學模型( Acoustic Model)所需的參數。而在使用者辨識的階段,將輸入的語音樣本抽取語音特徵之後,和辨識字彙中的參考聲學模型比對,找出最接近的字彙,是為辨識結果。看似簡單,其實各步驟均有許多變化,尤其是聲學模型比對步驟的兩大問題:時序校準( Time Alignment)及參數模型比對。時序校準在於找出正確的聲學單位(如詞、音節、次音節、聲韻母、音素等)的起點跟終點,在連續音的情況下問題更為嚴重;這也是為什麼單字音比連音詞容易辨識,而連音詞又比整句連續語音容易辨識的主要原因。參數模型比對則在以什麼參數、多少參數建構參考模型,可以是語音原始樣本,也可以是語音特徵樣本,但更多的是離散(discrete )或連續密度的(continuous density)機率分佈模型。
聲學模型作法可大致分為下列幾種:
(1)語音模版(Template)法–適用於小字彙、特定語者的應用;
(2)動態時間校準(Dynamic Time Warping;
(3)隱馬可夫模型 (HMM,Hidden Markov Model):又可細分為利用向量量化(Vector Quantization) 技巧的離散的、
連續密度的、半連續的 (semi-continuous) 隱馬可夫模型及簡化的分段機率模型(SPM, Segmental Probabilistic Model);
(4)人工神經網路(Neural Networks);
(5)聲學知識模型;
(6)混合式(Hybrid) 作法等等。
除了小字彙的應用之外,不論在實驗室雛型或商用產品,語音辨識系統大多採用隱馬可夫模型或其變型。
實用化語音辨識技術的考慮
在選擇語音辨識技術或產品的必須考慮的因素有下列幾點:
(1) 技術分類合適性: 詞彙大小、特定語者/非特定語者/系統調適、發音方式(單字/孤立詞/詞詞斷開/關鍵詞萃取/全句辨識);
(2) 辨識率;(3) 辨識速度;(4) 使用平台 (Platform) : 操作系統、CPU、Memory、音效卡/DSP卡、麥克風(種類與距離);
(5)成本;
(6)抗噪音能力;
(7) 是否透過電話線;
(8) 拒認能力: 提高可靠度,寧願拒認,不要錯認;
(9) 多國語言;
(10) 標準應用程式介面 (API):易於開發應用程式。
語音辨識技術之應用
TMA Associates市調公司在最近的一份調查報告中,把語音辨識產品分為四大類:
(1)電腦產品:麥克風直接連接電腦,可以電腦螢幕顯示回饋辨識結果,由於電腦使用者常為固定而長時間使用,可採用特定語者或語者調適技術;
應用舉例如語音聽寫、PC語音控制、語音資料存取、遊戲軟體、語言訓練等;
(2)電話產品:語音透過有線或無線傳輸給辨識器,以聲音回饋給使用者,非特定麥克風,經常為短暫交談互動,宜採用非特定語者技術;
應用舉例如電話網路之語音撥號或其他辨識/驗證服務、以語音而非按鍵控制之互動語音回應系統、PC上之電話語音辨識;
(3)消費性電子產品:麥克風為產品之一部分,小或無螢幕顯示,小包裝,常為電池供電,中低價位;
應用舉例如電話機內建的語音撥號、可攜式電子記事簿、電視遙控、語音撥號行動電話、聲控玩具、語言學習;
(4)汽車及工業應用產品:高噪聲環境,眼及雙手忙碌,特殊裝備需求,應用免手持麥克風;
應用舉例如汽車導覽系統、收音機控制工業品管、包裝處理、車用行動電話等。

2007年12月14日 星期五

[轉載] GPS start-up

出處:http://bbs.100gps.com/thread-1312-1-1.html

GPS開機定位分為冷啟動、溫啟動和熱啟動三種:

冷啟動:以下幾種情況開機均屬冷啟動。
初次使用時;電池耗盡導致星曆訊息丟失時;關機狀態下將接收機移動1000公里以上距離。

溫啟動:距離上次定位的時間超過兩個小時的啟動。

熱啟動:距離上次定位的時間小於兩個小時的啟動。

有時候如果機器有軟件問題,需要進行冷啟動,冷啟動可以使用gpsviewer進行。

2007年12月6日 星期四

BattDrv_saving power issue

將battery polling時間拉長至五分鐘
當usb發生中斷將電池狀態通知ce
int WINAPI CheckACChargerThread()
{
SYSTEM_POWER_STATUS_EX2 tmpst;
PBATTERY_CONTEXT pbc = (PBATTERY_CONTEXT) &gBatteryContext;

RETAILMSG(1, (TEXT("++CheckACChargerThread \r\n")));

while(TRUE)
{
InterruptDone(SYSINTR_ACChargerDetect);

WaitForSingleObject(g_hACChargerDetect, INFINITE);

//////////////////////////////////////
// update battery status information
LockBattery();
BatteryAPIGetSystemPowerStatusEx2(&tmpst, sizeof(tmpst), TRUE);
UnlockBattery();

// has anything changed?
if(memcmp(&tmpst, &pbc->st, sizeof(pbc->st)) != 0)
{
// yes, update our global variable and notify the power manager
pbc->st = tmpst;
PowerPolicyNotify(PPN_POWERCHANGE, 0);
}
//////////////////////////////////////

if(PIO_READ_INPUT(GPIO, GPIO_GROUP(0),GPIO_INDEX(2)))
{
RETAILMSG(1,(TEXT("++CheckACChargerThread USB IN!!!\r\n")));

}
else
{
RETAILMSG(1,(TEXT("++CheckACChargerThread USB OUT!!!\r\n")));

}
}
}

2007年10月16日 星期二

把code從public移到flatform

把code從public搬到platform下需要注意幾點,通常不外乎就是dirs和sources.cmm
以mainstoneⅢ LCD driver為例子
Ariel把在
WINCE500\PUBLIC\csp_pxa27x\oak\pxa27x下的xllp folder搬至WINCE500\PLATFORM\MC55\src下
  • dirs內需將xllp加入


WINCE500\PUBLIC\csp_pxa27x\oak\pxa27x下的display folder搬至WINCE500\PLATFORM\MC55\src\drivers下
  • dirs內需將display加入


接著修改WINCE500\PLATFORM\MC55下的sources.cmm
這樣才能找的到include的檔案


大至上只需要一些些小步驟要注意,這樣就不會出現complier過不了了。

2007年10月15日 星期一

SD QC搬移需注意的地方

SD QC從528搬到TANJAY
在XBOOT\Boards\TANJAY內自己新建立DRIVERS folder需要注意幾點:
基本上的一些般移動作就不多加說明,重要的是一些makefile要多加注意,以下是Ariel有遇過的問題還有覺得較需注意的地方,可以參考看看
  • XBOOT\Boards\TANJAY\DRIVERS\Makefile要修改
(Ariel因為忘了把makefike做修改所以導致build code build不過,浪費了很多時間,所以要多注意每個folder下的makefile哦!!)
  • XBOOT\Make\tanjay.cfg要修改
(這地方也是需要注意的哦,makefile改了這地方若沒有加入的話會讓complier link不到)
  • XBOOT\Boards\TANJAY\platform.c內clock要注意是否有設好
(control要能動,記得給電是非常重要的)
  • XBOOT\Boards\TANJAY\H\bspgpio.h要注意GPIO是不是符合電路圖
(別光搬code,每個板子的GPIO有可能是不一樣的,這要也檢查檢查)

2007年9月17日 星期一

MDD與PDD

分層Driver的架構分成MDD與 PDD兩部份,前者和具體的設備綁定在一起,是針對特定設備特定型號的,後者是同一類設備驅動中公用的部分,主要由CE的系統支持提供,通常不需要修改。(意思就是說MDD是MS寫好的,PDD則要vendor自己來implement)

以Audio driver舉例:
若我們要implement一個stream interface driver,我們可以使用Microsoft提供的MDD(model device driver) library, Wavemdd.lib, 透過audio device driver service-provider interface(DDSI) function來實現stream interface function.
使用Wavemdd.lib,那我們就要create 一個對應的PDD(platform-dependent driver) library來implement audio DDSI function.
PDD library 通常會被稱為Wavepdd.lib,僅管它可能是不需要的, 但這兩個library會從audio driver被link起來 成為一個.dll的檔案,Wavedev.dll。
如圖所示:

2007年8月30日 星期四

I2C Bus

概觀
  • I2C 為 Inter-Integrated Circuit的縮寫,I2C Bus顧名思義就是IC之間溝通的匯流排
  • I2C Bus為飛利浦(Philips)在1980年代所發展的雙向二線式的串列匯流排(Serial Bus)標準
    • 資料線:Serial data line (SDA)
    • 時脈線:Serial clock line (SCL)
  • I2C Unit允許Processor透過I2C Bus來服務master和slave 裝置
  • 資料在I2C Bus上可以用三種速度被傳送
    • Standard-mode: 100 kbit/s
    • Fast-mode: 400 kbit/s
    • High-speed mode: 3.4 Mbit/s
I2C Bus的優點
  • 相較傳統平行匯流排(Parallel Bus)
    • 架構簡單,只需要二條線就能傳送資料,可靠度及安全性佳
    • 省去平行匯流排所須的解碼電路
    • 降低平行匯流排可能因接線太多而造成的電磁干擾和靜電放電的副作用
I2C Bus適用的情況
  • 系統包含μC及其他周邊
  • 希望將連接的成本降至最低
  • 系統不需要很快的傳輸速度
  • 希望應用於Multi-Master系統
I2C Bus的硬體特性
  • I2C Bus介面本身為Open Drain或是Open Collector構造,因此應用時需外加電源及提升電阻才能運作

I2C Bus功能說明
  • I2C Bus定義一個由序列資料/位址線(SDA) 和序列時脈線(SCL)組成的序列協定給I2C Bus上的處理器來處理通過的資訊
  • I2C Bus上的每個裝置是由一個獨特的7bits address來識別而且可以在master或slave模式下當成傳送端或接收端來操作


  • for example

    • 當Processor 在I2C Bus上作用為master時,它定址一個EEPROM為slave來接收資料。當Processor定址EEPROM時,它是一個master傳送端而EEPROM是一個slave接收端。當Processor讀取資料時,它是一個master接收端而EEPROM是一個slave傳送端。不管它是傳送端或是接收端,master會產生時脈信號,起始傳送,還有終止傳送。
  • I2C Bus是一種同步傳輸協定,其資料傳送形態包含
    • 開始(Start)
    • 位址(Address)
    • 讀/寫(R/nW)
    • 資料(Data)
    • 確認(Acknowledge)
    • 停止(Stop)
I2C Bus信號變化原則

  • SDA若要變化,只有在SCL為低電位時才可以改變,而SCL在高電位時,其對應同時SDA的狀態(高電位或低電位)就是其傳送的位元(1 or 0)
I2C Bus資料傳送形態
  • 開始(Start)
    • Master必須送出”start”信號才能取得I2C Bus的控制權
    • 當I2C Bus沒有動作時,SCL和SDA都保持在高電位
    • I2C Bus動作時,master先在SDA送出低電位,經過一小段時間後,再將SCL變成低電位

  • 停止(Stop)
    • 和”start”信號的動作相反
    • Master完成和slave的動作後,先將SCL釋放至高電位,經一小段時間在將SDA放至高電位

  • 位址(Address)
    • 每一個送到Bus上的資料都必須是8bit
    • 以standard mode為例,Address有7個bit,master會先傳送MSB到Bus上,再依次傳出其他bit
  • 讀/寫(R/nW)
    • 緊接著Address,只佔一個bit 為LSB,高電位時為Read,低電位時為Write

  • 確認(Acknowledge)
    • Slave正確地收到資料後,會發出”ACK”信號向master表示收到
    • Master會將SDA釋放成高電位,slave確認時會將SDA拉至低電位
    • Slave未能正確地收到資料,slave則不動作,SDA會維持在高電位

  • 資料(Data)
    • 和Address及R/nW一樣,只不過資料可能由master或slave送出,由master或slave接收,而Address及R/nW則是由master送出,slave接收
    • 資料的意義隨著裝置的不同而不同

I2C Bus的操作
  • 簡單的溝通原理
  • Uc要對memory寫入資料
  1. Uc發出start訊號告訴其他device它要動作了,接著發出”device address”(每個deivce都有一個唯一的address)和讀寫訊號
  2. Memory收到uc要它做讀寫動作,便發出ack告訴uc我收到了
  3. 然後uc傳送欲寫入的address(這裡是指memory address)給memroy
  4. Memory再發出ack給uc
  5. Uc再將欲寫入的資料送給memory
  6. 寫入完畢後,memroy又發出ack給uc
  7. 接著uc送出stop告訴bus上的所有device我的事做完了

  • Master接收Slave傳送 / 重複START / Master傳送Slave接收

Multi-Master
  • Single-Master: 只有一個μC發號施令,主控整個系統
  • Multi-Master: 系統有二個以上的μC發號施令,其他的μC(slave)只能受主控的μC (master)控制,在不對外界送出命令時,master本身又可以變成slave

  • 就是說有兩個以上的μC時,只有一個主控的master μc,其他的μc均當成slave
  • Multi-master就只靠scl和sda這兩條線來完成,在兩條線上有很多個master傳送資料,那不是很容易發生衝突嗎? 靠著open collector (drain)的特性,scl和sda均可作wired_and動作,這些問題都可以解決。達成arbitration 和 synchronization的功能以確保bus正常運作。
Arbitration
  • Multi-master功能需要I2C Bus arbitration(調停),當二或多個master在最短的停留時間產生START信號時調停將發生
  • 使用wired-AND硬體線路,因此多個master發出同樣狀態的信號,傳輸不會遺失資料
  • 假如包含的address和R/nW或是data不一樣時,master會發出高電位狀態來表示調停失敗並關閉它的SDA,然後回到slave模式

  • 當兩個以上的master送出不同的位址時,低位址會擁有優先權
Synchronization
  • 每個I2C Bus上的master為了在SCL上的資料傳輸會產生它自己的時脈
  • 不同頻率的時脈連接到SCL,當時脈是在高電位期間時資料是有效的
  • Master擁有最長的時脈週期者會將SCL維持在低電位
  • 當兩個master發出的信號頻率不同時,SCL的頻率會以最低的為標準
Clock synchronizing mechanism
  • Service an internal interrupt
    • If a slave can’treceive or transmit another complete byte of data until ithas performed some other function, for example servicing an internal interrupt, it can hold the clock line SCL LOW to force the master into a wait state. Data transfer then continues when the slave is ready for another byte of data and releases clock line SCL.
  • Handshake
    • The clock synchronization mechanism can be used to enable receivers to cope with fast data transfers, on either a byte level or a bit level. On the byte level, a device may be able to receive bytes of data at a fast rate, but needs more time to store a received byte or prepare another byte to be transmitted. Slaves can then hold the SCL line LOW after reception and acknowledgment of a byte to force the master into a wait state until the slave is ready for the next byte transfer in a type of handshake procedure.


A good web for I2C BUS protocol
http://www.esacademy.com/faq/i2c/

2007年7月20日 星期五

How to load a driver into user mode

在CE6.0中一般driver default都是run在kernel mode
要如何將driver load 到 user mode?
其實很簡單
只需要設定platform.reg中Flags的value為 DEVFLAGS_LOAD_AS_USERPROC(0x10)
n

及platform.bib即可。

以上次建出來的Driver為範例。

platform.reg
//===============================
[HKEY_LOCAL_MACHINE\Drivers\BuiltIn\Cin]
"Dll" = "CIN.dll"
"Prefix" ="CIN"
"Index"= dword:1
"Order"= dword:0
"FriendlyName" = "CIN Demo Driver"
"Ioctl" = dword:0
"Flags" = dword:10
; Flags==0x10 is DEVFLAGS_LOAD_AS_USERPROC

//===============================

platform.bib
//===============================
CIN.dll $(_FLATRELEASEDIR)\CIN.dll NK SH
//===============================


run 出來的結果


千萬要注意哦
bib檔的SHK要改成SH哦,沒改的話會出現錯誤。
run出來的結果

How to create a CE 6.0 driver

其實建CE 6.0 的driver與5.0的雷同,先前也曾介紹過。
1.首先在BSP底下建你要的driver folder。

\WINCE600\PLATFORM\DEVICEEMULATOR\SRC\DRIVERS


2.接著建立所需的makefile、.def、sources、.c(or .cpp)檔。
內容設定如下:簡略說明,可參閱stream driver文章。
D:\WINCE600\PLATFORM\DEVICEEMULATOR\SRC\DRIVERS\CINTEST


.def檔

//=========================================

LIBRARY CINTEST // driver folder 名稱

EXPORTS
// 要export 的function
XXX_Init

XXX_Deinit
XXX_Open
XXX_Close
XXX_IOControl
XXX_PowerUp
XXX_PowerDown
XXX_Read
XXX_Write
XXX_Seek

//=========================================


source檔
//=========================================
SYNCHRONIZE_DRAIN=1

TARGETNAME=CIN //.dll的名稱
RELEASETYPE=PLATFORM
TARGETTYPE=DYNLINK

TARGETLIBS= \
$(_SYSGENSDKROOT)\lib\$(_CPUINDPATH)\coredll.lib \ //會呼叫到的library

SOURCES= \
cin.c \\用到的.c檔
//=========================================


3.修改platform.reg和platform.bib檔
\WINCE600\PLATFORM\DEVICEEMULATOR\FILES

platform.reg
//=========================================
[HKEY_LOCAL_MACHINE\Drivers\BuiltIn\Cin]
"Dll" = "CIN.dll"
"Prefix" ="CIN"
"Index"= dword:1
"Order"= dword:0
"FriendlyName" = "CIN Demo Driver"
"Ioctl" = dword:0

//=========================================


platform.bib
//=========================================
CIN.dll $(_FLATRELEASEDIR)\CIN.dll NK SHK
//=========================================

2007年7月13日 星期五

system calls

In compupting, a system call is the mechanism used by an application program to request service from the operating system.
簡言之就是應用程式與作業系統的介面

2007年7月4日 星期三

User Mode Driver Framework

User Mode Driver Framework Development Concepts
  • allows an intermediate driver to load in user mode
  • cannot directly access hardware
  • some drivers will be more stable in user mode
  • reflector in kernel makes a user mode driver work as if it was a kernel mode driver
User Mode Driver Framework Architecture



The user mode driver framework is divided into two physical components.
  • the user mode driver reflector, which reside inside the device manager.
    • manages the user mode driver host processor.
    • forwards the requests that are issued by the device manager.
    • provides services for a user mode driver.
  • the user mode driver host, which is a user mode application that is launched and managed bye the user mode driver reflector.
    • it is used at the kernel's request to launch and to manage a user mode driver.
    • it is responsible for mounting the API of a volume in order to receive forwarded requests from the user mode driver reflector.
Registry
  • stores configuration information for applications, drivers, and the OS.
  • OS uses registry to locate and load device drivers.
  • Same basic setup as the desktop windows OS registry.
  • space is limited, so keep any new entries short.
Device Manager
  • manages devices and their interfaces.
  • decides which drivers to load.
  • uses registry to find drivers.
  • runs continuously.

Kernel Mode Drviers VS. User Mode Drivers

The development team at Microsoft has made a number of changes to the architecture of Windows CE in version 6.0. One of these is a new model for loading device drivers that can provide for increased security, robustness or performance.

Prior to CE6, device drivers primarily resided in the device.exe process.
The new kernel architecture provides more flexibility by providing two different driver models. The old device.exe functionality has been moved into the kernel, and a new user device process (udevice.exe) has been introduced. This change results in two different driver models, kernel mode drivers and user mode drivers. BSP developers must choose how each of their drivers will be implemented on a particular platform.

Kernel Mode Drivers

Kernel mode drivers are loaded by device.dll inside of the kernel. This is the default behavior, and most closely resembles the old device.exe model. The big win here is performance – the expensive interprocess calls (thunks) have been eliminated. There is no need for the user mode process initiating a driver access to be switched out, because the user mode process coexists with the kernel. The kernel includes the file system and device drivers so everything is resident in memory at the same time.

This new performance benefit comes at a price. Kernel mode drivers are now a part of the kernel, and they have full privileges for the entire kernel address space. A driver failure that results in memory corruption could easily bring down the kernel and with it the entire system. Therefore it’s critical that kernel mode drivers be robust.


User Mode Drivers

CE6 provides a new mechanism to load drivers into individual user mode processes (called udevice.exe) instead of into the kernel. A driver that loads in this fashion is called a user mode driver, and it gives up a level of performance in return for increased system robustness and security. In addition, since user mode drivers run inside a user mode process they are restricted in their use of certain APIs . This security feature restricts drivers loading in user mode from arbitrarily accessing any hardware resource in the system.

Microsoft has designed the user mode driver model to have a very high level of compatibility with kernel mode drivers. There are very few differences between the two models, and a driver written for user mode can be loaded into kernel mode with no changes. A new kernel component called the user mode driver reflector handles the interface between user mode applications and the user mode driver. This means that applications do not need to be aware of how a particular driver was loaded.

It’s a simple matter to load a driver into user mode instead of the default kernel mode. There is a new bit defined in the Flags registry key that if set tells the kernel to load the corresponding driver into user mode. That’s it – nothing more to it. The user mode driver will run in its own process isolated from the kernel and the rest of the system. If the driver fails for some reason only its copy of udevice.exe is affected, the rest of the system should remain intact.

BSP developers now have the option of choosing between a high performance kernel mode driver and a more protected user mode driver. Untrusted third party drivers can be loaded into user mode to increase system security and robustness. Unstable or otherwise questionable drivers can start life in user mode and then be moved to kernel mode as they become proven.


參考來源:http://www.bsquare.com/blog/default-aug_21.asp

2007年6月20日 星期三

MDOC Read

HANDLE hDoc=INVALID_HANDLE_VALUE;

//output、input record for Bindary partition
flOutputStatusRecord outputStatusRecord;
flBDKOperationInput bdkOperationInput;

//output、input record for Disk partition
flReadWriteInputFH readWriteInput;
flReadWriteOutput readWriteOutput;
flMountInputFH mountInput;
flOutputStatusRecord outputStatusRecord;

DWORD bytesReturned;

//open DOC driver
hDoc = CreateFile(L"DSK6:",GENERIC_READ|GENERIC_WRITE,FILE_SHARE_READ|FILE_SHARE_WRITE,
NULL, OPEN_EXISTING, 0, 0);

if (INVALID_HANDLE_VALUE == hDoc)
{
return 0;
}

//Read Bindary partition=================================
// Initialize for BDK read
bdkOperationInput.type = BDK_INIT_READ;
bdkOperationInput.partitionNumber = 1;
bdkOperationInput.bdkStruct.startingBlock = UnitNumber;
bdkOperationInput.bdkStruct.length = kDocBlockSize;
bdkOperationInput.bdkStruct.oldSign[0] = 'B';
bdkOperationInput.bdkStruct.oldSign[1] = 'I';
bdkOperationInput.bdkStruct.oldSign[2] = 'P';
bdkOperationInput.bdkStruct.oldSign[3] = 'O';
bdkOperationInput.bdkStruct.signOffset = 8;

if (!DeviceIoControl(hDoc, FL_IOCTL_BDK_OPERATION, &bdkOperationInput, sizeof(bdkOperationInput), &outputStatusRecord, sizeof(outputStatusRecord), &bytesReturned, NULL))
{
return 0;
}

//Read BDK blocks
bdkOperationInput.type = BDK_READ;
bdkOperationInput.partitionNumber = 1;
bdkOperationInput.bdkStruct.length = kDocBlockSize;
bdkOperationInput.bdkStruct.bdkBuffer = gBuffer;

if (!DeviceIoControl(hDoc, FL_IOCTL_BDK_OPERATION, &bdkOperationInput, sizeof(bdkOperationInput), &outputStatusRecord, sizeof(outputStatusRecord), &bytesReturned, NULL))
{
return 0;
}
//==============================================================
//Read Disk partition==========================================
// calling for FL_IOCTL_MOUNT_VOLUME_FH/FL_MOUNT
mountInput.partitionNumber = 0x2; //BDTL2
mountInput.type = FL_MOUNT;

if (!DeviceIoControl(hDoc, FL_IOCTL_MOUNT_VOLUME_FH,&mountInput,sizeof(mountInput),&outputStatusRecord,sizeof(outputStatusRecord), &bytesReturned, NULL))
{
return 0;
}

// calling for FL_IOCTL_WRITE_SECTORS_FH
readWriteInput.partitionNumber = 0x2; //BDTL2
readWriteInput.firstSector = 0;
readWriteInput.numberOfSectors = SectorNumber;
readWriteInput.buf = gBuffer;

if (!DeviceIoControl(hDoc, FL_IOCTL_READ_SECTORS_FH, &readWriteInput, sizeof(readWriteInput), &readWriteOutput, sizeof(readWriteOutput), &bytesReturned, NULL))
{
return 0;
}

//calling for FL_IOCTL_MOUNT_VOLUME_FH/FL_DISMOUNT
mountInput.type = FL_DISMOUNT;

if (!DeviceIoControl(hDoc, FL_IOCTL_MOUNT_VOLUME_FH,&mountInput,sizeof(mountInput),&outputStatusRecord,sizeof(outputStatusRecord), &bytesReturned, NULL))
{
return 0;
}
//===================================================================

//close Doc handle
if(hDoc)
{
CloseHandle(hDoc);
}