顯示具有 工作 標籤的文章。 顯示所有文章
顯示具有 工作 標籤的文章。 顯示所有文章

2010年4月28日 星期三

複習C

以前沒學好C,為了接下來的project,先趕緊把C再複習一下!!

指標
結構
指標常數
指標變數


取址運算子&
* 是一個單元 (unary) 的運算子 (operator), 功能是 "將其後所接的運算式之數值算出, 當成一個記憶体位址, 並讀取該記憶体位址內 (適當格式) 之資料做為此運算之結果"。
int x;
&x取得變數 x 所使用的二個位元組記憶體中第一個位元組的位址!
float y;
&y取得變數 y 所使用的四個位元組記憶體中第一個位元組的位址!

取內容運算子*(Dereferenceing Operator或Indirection Operator)
& 是一個單元 (unary) 的運算符號, 其後必須要是一個變數, 它的功能是 "找出其後變數的位址, 做為該運算的結果"


2010年4月15日 星期四

eSATA Removable屬性設定資料

資料來源:http://www.microsoft.com/whdc/Device/DeviceExperience/ContainerIDs.mspx


eSATA Devices

·         If the eSATA port is a hot-plug-capable port, the following register bit is set:
Advanced Host Controller Interface (AHCI), Port x Command and Status (PxCMD) register  (Offset 18h), bit location 18 (Hot Plug Capable Port (HPCP))
When set to “1”, indicates that this port’s signal and power connectors are externally available through a joint signal and power connector for blindmate device hot plug.

·         If the eSATA port is a signal-only port, the following two register bits are set:
Advanced Host Controller Interface (AHCI), HBA Capabilities (CAP) register (Offset 00h), bit location 5 (Supports External SATA (SXS))
When set to ”1”, indicates that the host bus adapter (HBA) has one or more SATA ports that have a signal-only connector that is externally available (such as an eSATA connector). If this bit is set to ”1”, software can refer to the PxCMD.ESP bit to determine whether a specific port has its signal connector externally available as a signal-only connector (that is, power is not part of that connector).
When the bit is cleared to ”0”, indicates that the HBA has no SATA ports that have a signal-only connector that is externally available.


Advanced Host Controller Interface (AHCI), Port x Command and Status (PxCMD) register  (Offset 18h), bit location 21 (External SATA Port (ESP))
When set to ”1”, indicates that this port’s signal connector is externally available on a signal-only connector (such as an eSATA connector). When set to ”1”, CAP.SXS shall be set to ”1”. ESP is mutually exclusive with the HPCP bit in this register. If ESP is set to ”1”, then the port may experience hot plug events.

Note that these conditions are mutually exclusive. An eSATA port may declare itself to be an external hot-plug-capable port or an external signal-only port, but not both. If either condition is set for an eSATA port, the ATA driver marks as removable any device that is attached to the port.
For additional details, refer to the Serial ATA AHCI 1.3 specification.

2010年4月13日 星期二

USB HID入門

參考文件






節錄文章資料(USB 之人性化介面裝置的報告描述元(3))
      從表 8 看出,鍵盤的輸入報告中最低的 8 位元分別代表鍵盤上的 8 個修飾鍵(亦即左和右邊的 Control 鍵、Shift 鍵、Alt 鍵、和 Windows 鍵),平常每位元的值為0,當對應的修飾鍵被壓下時則位元值為 1。鍵盤報告描述元中第一個 Input 項目必須宣告這 8 位元的格式。這 8 個修飾鍵為用途類頁 Key Codes 中的第 224 個鍵到第 231 鍵,所以用 Usage Minimum (224)和 Usage Maximum (231)來宣告。每一個按鍵的邏輯值不是 0 就是 1,所以用 Logical Minimum(0)和 Logical Maximum (1)來宣告。很顯然的,每一個鍵佔用一個數據位元,而共需 8 個位元,因此 Report Size ( 1),而 Report Count (8)。請特別注意,最低位元對應到 Usage Minimum 的宣告,而最高位元所對應的為 Usage Maximum 的資料內容。這 8 個位元值是可變的數據,每一個位元是獨立的變數,提供的值不須與前次的值有相對關係。總結而言,該 8 位元的主項目必須為 Input (Data, Variable, Absolute)。

      鍵盤的輸入報告中次高的位元組被保留,該位元組的值無意義,也不需更新,所以用 Input (Constant)來填充(padding)。而最高的 6 個位元組則是最近同時被壓下的 6  個按鍵之代碼。這個鍵盤裝置有 101 個鍵,而報告格式的最高的 6 個位元組中任何一個位元組都可以代表 101 個鍵之任一鍵,所以這 101 鍵再加上無鍵被壓下狀態(代碼為 0x00)構成一組操控陣列,這個裝置允許同時壓下 6  個鍵。鍵盤報告描述元中 Input (Data, Array)即在宣告這 6 個位元組的數據格式,注意這個數據格式的邏輯值宣告和用途代碼宣告具有相同的資料值(即 0 和 101)。


gary註:鍵盤的keycode對應於Usage ID,可在USB HID Usage Tables中查得,往host PC丟的鍵盤值,就是丟Usage ID!!而鍵盤上的Alt,Ctrl,Shift稱為Modifier Key(修飾鍵),在Byte0相對應的位置填1送出即可達成組合鍵的目的(如Ctrl+P)!


       鍵盤有一個輸出報告,長度為 1 個位元組,但是只用到最低 5 個位元來代表五個LED 的操控,所以最高的 3 個位元需要用 Output (Constant)項目來填充。輸出報告的用途類頁不再是 Key Codes,而是 Page of LEDs,所以要重新宣告 Usage Page,而主項目為 Output (Data, Variable, Absolute)。這個項目的資料內容如同輸入報告的最低 8 位元所宣告的主項目之資料內容,不再作說明。因為鍵盤介面的端點描述元只有宣告一個中斷型輸入端點,所以輸出報告需要依賴內定控制型端點 0 來傳送。輸入報告由宣告的輸入端點作中斷型輸入傳輸,當然也可以依需要用內定控制型端點 0 來作控制型讀入傳輸。



2010年4月8日 星期四

PIC初入門

記錄PIC使用過程,準備工具如下: