7.09.2009

業餘跟職業的差別

最近看了Robert Kiyosaki 的文章裡提到的一段話,感同深受

"People say amateurs play for the love of the game and professionals play for money. That is not true. Amateurs are amateurs because they do not love the game enough. When it is cold and rainy, a professional golfer will play. The amateur will not. When they are sick, the professional will play. The amateur stays in bed. When they are losing, the professional will practice harder and enter more tournaments. The amateur will quit and take up tennis."

記得還是小學的時候,很喜歡玩棒球,常常在中午大熱天,同學想休息的時候,拉著他們一起去玩。很懷念那時單純渴望的感覺。那時如果我爸繼續讓我打球,也許現在我也是王建民 :P

現在看看自己再做的事,不至於厭惡,但也沒有小時的熱誠。我也算是業餘在我這一行 = ="

5.21.2009

USB On-The-Go Basics - Cable

在 USB 的世界裡,有分Host跟Peripheral ,任何的傳輸動作都是 Host先 send 封包出來,所以知道誰是 Host 誰是 Peripheral 是很重要的在USB的protocol 裡, 再因為 USB cable 是決定OTG devcie是當A-Device(Host)還是B-Device(peripheral)的依據,所以我們先認識一下USB OTG 的 cable.



  1. 一般標準的USB cable 的頭就有分A 頭跟B 頭,A頭就是接Host, B頭就是接peripheral.





  2. 後來多了一個叫 mini-USB 的B頭,是給像隨身聽這類小產品用的,也都只是當peripheral




  3. 後來又出了一個叫 OTG mini-AB receptacle.就是專給 OTG deivce 用的母頭. 它可接mini-A公頭也可接mini-B公頭



  4. 下圖上方,是Camera 當 Host, Printer當 Peripheral ,它可能的功能就是讓Camera 裡的照片直接透過Printer印出。下方那一個,兩個Camera 都是用OTG Mini-AB 母頭,也就是可插A頭也可插B頭,那要怎麼區分誰是 Host? 誰是 Peripheral呢? 就是靠 cable 的接頭來決定。在A頭跟B頭裡面的 ID pin 是不同的,A頭裡 ID是pull low, B頭裡ID是pull hi。而 device 再依照ID pin 來決定自己是Host 還是peripheral。



  5. 因為Mini-AB母頭可接A or B, 在這樣的情形下 user 有可能會接反,如下圖,原本Camera是要當Host,因為接反插入 B 頭而變為 Peripheral, 而 Printer 也是一樣,那不就不能動了。好再OTG 架構也想到這個問題,所以提供了一個叫 Host Negotiation Protocol (HNP) 來結決這個問題,讓 user 不用換 calbe 也可繼續用。






5.12.2009

設計者的悲哀

在吉米丘的blog 上看到的,好笑到不行



真是道盡設計者的悲哀

5.11.2009

USB OTG flow at Qaulcomm

BOOL Cl13611OTG::ISTProcess() @ Cl13611.cpp (\wm\platform\qcmsm\src\drivers\usb\highspeed\otg)

-> BOOL Cl13611OTG::UpdateInput()
-> BOOL Cl13611OTG::EventNotification()

-> BOOL USBOTG::EventNotification() @ Usbotg.cpp (\wm\public\common\oak\drivers\usbotg\mdd)

do

-> BOOL Cl13611OTG::UpdateInput() @ Cl13611.cpp (\wm\platform\qcmsm\src\drivers\usb\highspeed\otg)
-> USBOTG_STATES USBOTG::StateChange(USBOTG_STATES usbOtgState) @ Usbotg.cpp (\wm\public\common\oak\drivers\usbotg\mdd)
-> BOOL USBOTG::EnterState(USBOTG_STATES usbOtgState)
if (OTG state has changed)

BOOL Cl13611OTG::NewStateAction(USBOTG_STATES usbOtgState , USBOTG_OUTPUT usbOtgOutput) @Cl13611.cpp (\wm\platform\qcmsm\src\drivers\usb\highspeed\otg)

-> BOOL Cl13611OTG::SetupTransCtr(USBOTG_OUTPUT usbOtgOutput)

if(usbOtgOutput.bit.drv_vbus)(A-device is driving Vbus)

turn on Vbus

else

turn off Vbus


if (usbOtgOutput.bit.loc_sof = true) (loccal device is generating activity on the bus)

LoadUnloadHCD(TRUE)

else

LoadUnloadUSBFN(TRUE)

-> BOOL USBOTG::NewStateAction(USBOTG_STATES usbOtgState , USBOTG_OUTPUT usbOtgOutput )


else
break while()



while(OTG state != USBOTG_states_unknow)


5.05.2009

USB and Chargering

在USBIF 裡有測到下列狀況的VBUS電流:
1. USB 有認到時的電流: 100mA/500mA
2. USB 沒(還沒)認到時的電流: 100mA/500mA
3. 電腦 suspend 時的電流: 2.5mA
4. 正常運作時的電流: 100mA/500mA

所以有兩個地方,USB 需通知charging driver
1. 電腦認到 USB 時
2. 電腦 suspend 時

*以下是 Quallcomm 認到通知的flow(quallcomm 是以有被設了new address 才開始充電)

UfnPdd_SetAddress() @Msm_usbhs.cpp (\wm\platform\qcmsm\src\drivers\usb\highspeed\fn)

-> UfnPDD_NotifyChargerCurrent(), 帶pdd->dChargerCurrent進去,init 在 s_deviceRegParams @Msm_subhs.cpp, 目前設定100, 意思是 100 mA

-> DeviceIOControl 帶IOCTL_OTG_SET_REMOTE_DEV_A_INFO 參數,和要充的電流大小
Cl13611OTG::IOControl() @Cl13611.cpp (\wm\platform\qcmsm\src\drivers\usb\highspeed\otg)

這裡會收到 IOCTL_OTG_SET_REMOTE_DEV_A_INFO , pBufIn 就是要充的電流大小

*以下是 電腦 suspend 通知的 flow
UfnPDD_NotifySuspend() @Msm_usbhs.cpp (\wm\platform\qcmsm\src\drivers\usb\highspeed\fn)
這個不是WINAPI ,找不到從哪裡call 來,可能是 Quallcomm 的lib

-> UfnPDD_NotifyChargerCurrent(), 帶current 變數進去,如果是suspend, current=0
如果不是,current=100

-> DeviceIOControl 帶IOCTL_OTG_SET_REMOTE_DEV_A_INFO 參數,和要充的電流大小
Cl13611OTG::IOControl() @Cl13611.cpp (\wm\platform\qcmsm\src\drivers\usb\highspeed\otg)

這裡會收到 IOCTL_OTG_SET_REMOTE_DEV_A_INFO , pBufIn 就是要充的電流大小

4.29.2009

add external jar file as part of a system library

FWIW, it appears that if you add the external jar file as part of a user library, specify that the user library is a system library, and add the user library to the Java Build Path then it will work.


For completeness to do this you can do the following:
1. Right-click the project in Eclipse and select "Build Path -> Add Libraries...".
2. Select User Library from the list and click Next.
3. Click the "User Libraries..." button.
4. Click "New..." in the User Libraries dialog.
5. Give the user library a name and select the System library checkbox and click OK.
6. Highlight the newly added user library in the list and click the "Add JARs..." button and add the desired jar files.
7. Click OK on the User Libraries dialog.
8. Make sure the new user library is checked in the Add Library dialog and click Finish.

4.28.2009

AVD(Android Viutual Device)的注意事項

當你正在選擇system image target for 你的AVD時,請心存下列三項

Keep these points in mind when you are selecting a system image target for your AVD:

1. target 的 API level 很重要,因為你的應用程式沒辦法在比它的 API Level 還少的 system image 上跑,在應用程式的 manifest 檔的 attribute 裡的 minSdkVersion 有定義.想知道更多資訊有關 system API Level 跟應用程式 minSdkVersion 之間的關系,請看Specifying Minimum System API Version

The API Level of the target is important, because your application will not be able to run on a system image whose API Level is less than that required by your application, as specified in the minSdkVersion attribute of the application's manifest file. For more information about the relationship between system API Level and application minSdkVersion, see Specifying Minimum System API Version.

2. 強烈鼓勵,建立至少一個AVD, 它的 API Level 大於你的應用程式, 因為這可以讓你測試你的應用程式的forward-compatibility. forward-compatibility 的測試可用來保證,使用者透過system update download 你的應用程式之後,可以運作正常。

Creating at least one AVD that uses a target whose API Level is greater than that required by your application is strongly encouraged, because it allows you to test the forward-compatibility of your application. Forward-compatibility testing ensures that, when users who have downloaded your application receive a system update, your application will continue to function normally.

3. 如果你的應用程式宣告了一個 user-library 元件在它的 manifest 檔,那這個應用程式只能跑在有外部 library 的 system image.如果你要你的應用程試跑在你建立的 AVD 上, 請確定應用程式的 uses-library element 還有所選的 system image target 有無 includes 那個 library.

If your application declares a uses-library element in its manifest file, the application can only run on a system image in which that external library is present. If you want your application to run on the AVD you are creating, check the application's uses-library element and select a system image target that includes that library.