|
|
发表于 2009-10-13 14:24:33
|
显示全部楼层
回复 3# huyibo 的帖子
如果你说只考虑status中的bit 0,我想你的程序应该是不够严谨的。有时候我们其实不用考虑全部情况就可以把信息读出来这是有可能的。但是正如你现在遇到的问题,假如我们不把我们的程序考虑的完全点,那么我们的程序就可能有潜在的bug,也许一两次你还发现不了。smbus的操作一共有N个步骤,而且每个步骤都必须要去检查某些状态位等等(比如说data准备好了没有呀,bus是不是还在被占用呀什么的。。。我都忘记了,是不是data)。个人建议你还是参考一下bios code里的操作吧,这样比较严谨点。橘皮书上也有关于读取spd的操作。* d+ ~- ^0 p( |3 x- q
这个链接里有比较简单的介绍,(但是判断状态位还是没有写出来,有点担心会侵权之类的。。。)2 K8 V9 w0 Y F. k1 E2 _7 @4 _* M
http://blog.csdn.net/lightseed/archive/2009/07/30/4392697.aspx* J/ ^6 [4 X: u$ k: Q
总之,你的状态位判断尽量多点,这样会更加严密。否则就会出现莫名其妙的错误。
& P B+ m2 H4 f& K( s; i, J& c7 c& b; w2 j% f8 j3 z
一下是在程式设计俱乐部上的一篇帖子的一部分,供你参考希望对你有用。" S* H+ H' ]5 C R- |
>Step 1.Make sure status bits is clear(in SMB Host Status)
6 z# A5 L' K; Y* W# V, [: X>Step 2.write the slave address to SMB Host Address(make care bit 0 is+ D& p5 e; d( [1 k# [6 o
>Write)5 V4 Y. B& \* j2 H1 t6 ^' d
>Step 3.write EEPROM byte index to SMB Host Command
& d5 \1 n. T/ ~3 i>Step 4.write the slave address to SMB Host Address(make care bit 0 is
: ]2 M% m, o# F H; L* {>Read)
( b! Y1 ?7 |5 B3 `9 `& P>Step 5.Set byte read/wirte protocol with start bits enable to SMB Host Control0 O: P U; M1 b. o. S' Q0 f) X
>Step 6.Check status BUSY bit to make sure transation is complete8 M) ~* |- t) K$ I5 e- W3 B. D1 _4 j
>(in SMB Host Status)
4 \. y# f& ]3 o9 }1 v! e& C>Step 7.Read data From SMB Host Data 05 {7 u8 z& k: @/ p& f9 h
>Step 8.If no error, return to step 12 ]( O) d% `3 b9 |
1. step 1 & 2 中間可能需要 kill bus...(depends on platform design)
& {) q$ }2 W% J% }8 {; R2. step 2 & 4 不是很懂...想表達的是 ?
. R* Y; R: ~! W2 F# w; e/ ?3. Step 6時,除了check complete status,也要 check error status...
/ b. _. s! x |$ S6 mif complete then get data' o- A' F0 O& f- \% w
if error then do error handling
2 Z ~+ P5 W% o0 A5 W7 u3 |( Ex. kill bus->clear status...etc, depends on platform design )
& |7 R" K# T. P& t0 V$ ?0 @/ w8 ?4 A( {
[ 本帖最后由 LightSeed 于 2009-10-13 14:33 编辑 ] |
|