ソースを参照

Change read_bit() to return 0 or -1UL, rather than 0 or 1.

tags/v0.9.3
Michael Brown 18年前
コミット
51a36f1cfb
3個のファイルの変更7行の追加3行の削除
  1. 4
    2
      src/drivers/bitbash/bitbash.c
  2. 1
    1
      src/drivers/bitbash/i2c_bit.c
  3. 2
    0
      src/include/gpxe/i2c.h

+ 4
- 2
src/drivers/bitbash/bitbash.c ファイルの表示

@@ -48,8 +48,10 @@ void write_bit ( struct bit_basher *basher, unsigned int bit_id,
48 48
  * @v bit_id		Bit number
49 49
  * @ret data		Value read
50 50
  *
51
- * @c data will always be either 0 or 1.
51
+ * @c data will always be either 0 or -1UL.  The idea is that the
52
+ * caller can simply binary-AND the returned value with whatever mask
53
+ * it needs to apply.
52 54
  */
53 55
 int read_bit ( struct bit_basher *basher, unsigned int bit_id ) {
54
-	return ( basher->read ( basher, bit_id ) ? 1 : 0 );
56
+	return ( basher->read ( basher, bit_id ) ? -1UL : 0 );
55 57
 }

+ 1
- 1
src/drivers/bitbash/i2c_bit.c ファイルの表示

@@ -153,7 +153,7 @@ static uint8_t i2c_recv_byte ( struct bit_basher *basher ) {
153 153
 	/* Receive byte */
154 154
 	for ( i = 8 ; i ; i-- ) {
155 155
 		value <<= 1;
156
-		value |= i2c_recv_bit ( basher );
156
+		value |= ( i2c_recv_bit ( basher ) & 0x1 );
157 157
 	}
158 158
 
159 159
 	/* Send NACK */

+ 2
- 0
src/include/gpxe/i2c.h ファイルの表示

@@ -82,7 +82,9 @@ struct i2c_bit_basher {
82 82
 
83 83
 /** Bit indices used for I2C bit-bashing interface */
84 84
 enum {
85
+	/** Serial clock */
85 86
 	I2C_BIT_SCL = 0,
87
+	/** Serial data */
86 88
 	I2C_BIT_SDA,
87 89
 };
88 90
 

読み込み中…
キャンセル
保存