Browse Source

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

tags/v0.9.3
Michael Brown 18 years ago
parent
commit
51a36f1cfb
3 changed files with 7 additions and 3 deletions
  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 View File

48
  * @v bit_id		Bit number
48
  * @v bit_id		Bit number
49
  * @ret data		Value read
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
 int read_bit ( struct bit_basher *basher, unsigned int bit_id ) {
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 View File

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

+ 2
- 0
src/include/gpxe/i2c.h View File

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

Loading…
Cancel
Save