2
0
mirror of https://github.com/xcat2/xNBA.git synced 2024-12-14 07:11:32 +00:00

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

This commit is contained in:
Michael Brown 2006-06-12 19:29:50 +00:00
parent 2e49441535
commit 51a36f1cfb
3 changed files with 7 additions and 3 deletions

View File

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

View File

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

View File

@ -82,7 +82,9 @@ struct i2c_bit_basher {
/** Bit indices used for I2C bit-bashing interface */
enum {
/** Serial clock */
I2C_BIT_SCL = 0,
/** Serial data */
I2C_BIT_SDA,
};