/* ** =================================================================== ** Method : Byte1_NegBit (bean ByteIO) ** ** Description : ** This method negates (invertes) the specified bit of the ** output value. ** Parameters : ** NAME - DESCRIPTION ** Bit - Number of the bit to invert (0 to 7) ** Returns : Nothing ** =================================================================== */ void Byte1_NegBit(byte BitNum) { byte Mask=Byte1_GetMsk(BitNum); /* Temporary variable - bit mask */ if (Mask) { /* Is bit mask correct? */ PORTB ^= Mask; /* Negate appropriate bit on port */ } }
/* ** =================================================================== ** Method : Byte1_PutBit (bean ByteIO) ** ** Description : ** This method writes the new value to the specified bit ** of the output value. ** Parameters : ** NAME - DESCRIPTION ** Bit - Number of the bit (0 to 7) ** Val - New value of the bit (FALSE or TRUE) ** FALSE = "0" or "Low", TRUE = "1" or "High" ** Returns : Nothing ** =================================================================== */ void Byte1_PutBit(byte Bit, bool Val) { byte const Mask = Byte1_GetMsk(Bit); /* Temporary variable - put bit mask */ if (Val) { setReg8Bits(PORTB, Mask); /* [bit Bit]=1 */ } else { /* !Val */ clrReg8Bits(PORTB, Mask); /* [bit Bit]=0 */ } /* !Val */ }
/* ** =================================================================== ** Method : Byte1_PutBit (bean ByteIO) ** ** Description : ** This method writes the new value to the specified bit ** of the output value. ** a) direction = Input : sets the value of the specified ** bit; this operation will be ** shown on output after the ** direction has been switched to ** output (SetDir(TRUE);) ** b) direction = Output : directly writes the value of the ** bit to the appropriate pin ** Parameters : ** NAME - DESCRIPTION ** Bit - Number of the bit (0 to 7) ** Val - New value of the bit (FALSE or TRUE) ** FALSE = "0" or "Low", TRUE = "1" or "High" ** Returns : Nothing ** =================================================================== */ void Byte1_PutBit(byte Bit, bool Val) { byte const Mask = Byte1_GetMsk(Bit); /* Temporary variable - put bit mask */ if (Val) { setReg8Bits(PORTB, Mask); /* [bit Bit]=1 */ Shadow_B |= Mask; /* Set appropriate bit in shadow variable */ } else { /* !Val */ clrReg8Bits(PORTB, Mask); /* [bit Bit]=0 */ Shadow_B &= (byte)~Mask; /* Clear appropriate bit in shadow variable */ } /* !Val */ }
/* ** =================================================================== ** Method : Byte1_PutBit (bean ByteIO) ** ** Description : ** This method writes the new value to the specified bit ** of the output value. ** Parameters : ** NAME - DESCRIPTION ** Bitnum - Number of the bit (0 to 7) ** Val - New value of the bit (FALSE or TRUE) ** FALSE = "0" or "Low", TRUE = "1" or "High" ** Returns : Nothing ** =================================================================== */ void Byte1_PutBit(byte BitNum, byte Value) { byte Mask=Byte1_GetMsk(BitNum); /* Temporary variable - bit mask */ if (Mask) /* Is bit mask correct? */ if (Value) { /* Is it one to be written? */ PORTB |= Mask; /* Set appropriate bit on port */ } else { /* Is it zero to be written? */ PORTB &= ~Mask; /* Clear appropriate bit on port */ } }
/* ** =================================================================== ** Method : Byte1_NegBit (bean ByteIO) ** ** Description : ** This method negates (inverts) the specified bit of the ** output value. ** Parameters : ** NAME - DESCRIPTION ** Bit - Number of the bit to invert (0 to 7) ** Returns : Nothing ** =================================================================== */ void Byte1_NegBit(byte Bit) { byte const Mask = Byte1_GetMsk(Bit); /* Temporary variable - set bit mask */ invertReg8Bits(PORTB, Mask); /* [bit Bit]=invert */ }
/* ** =================================================================== ** Method : Byte1_ClrBit (bean ByteIO) ** ** Description : ** This method clears (sets to zero) the specified bit ** of the output value. ** [ It is the same as "PutBit(Bit,FALSE);" ] ** Parameters : ** NAME - DESCRIPTION ** Bit - Number of the bit to clear (0 to 7) ** Returns : Nothing ** =================================================================== */ void Byte1_ClrBit(byte Bit) { byte const Mask = Byte1_GetMsk(Bit); /* Temporary variable - set bit mask */ clrReg8Bits(PORTB, Mask); /* [bit Bit]=0 */ }
/* ** =================================================================== ** Method : Byte1_GetBit (bean ByteIO) ** ** Description : ** This method returns the specified bit of the input value. ** a) direction = Input : reads the input value from pins ** and returns the specified bit ** b) direction = Output : returns the specified bit ** of the last written value ** Note: This bean is set to work in Output direction only. ** Parameters : ** NAME - DESCRIPTION ** Bit - Number of the bit to read (0 to 7) ** Returns : ** --- - Value of the specified bit (FALSE or TRUE) ** FALSE = "0" or "Low", TRUE = "1" or "High" ** =================================================================== */ bool Byte1_GetBit(byte Bit) { byte const Mask = Byte1_GetMsk(Bit); /* Temporary variable - bit mask to test */ return (bool)((getReg8(PORTB) & Mask) == Mask); /* Test if specified bit of port data register is set */ }
/* ** =================================================================== ** Method : Byte1_NegBit (bean ByteIO) ** ** Description : ** This method negates (inverts) the specified bit of the ** output value. ** a) direction = Input : inverts the specified bit; ** this operation will be shown on ** output after the direction has ** been switched to output ** (SetDir(TRUE);) ** b) direction = Output : directly inverts the value ** of the appropriate pin ** Parameters : ** NAME - DESCRIPTION ** Bit - Number of the bit to invert (0 to 7) ** Returns : Nothing ** =================================================================== */ void Byte1_NegBit(byte Bit) { byte const Mask = Byte1_GetMsk(Bit); /* Temporary variable - set bit mask */ invertReg8Bits(PORTB, Mask); /* [bit Bit]=invert */ Shadow_B ^= Mask; /* Set appropriate bit in shadow variable */ }
/* ** =================================================================== ** Method : Byte1_ClrBit (bean ByteIO) ** ** Description : ** This method clears (sets to zero) the specified bit ** of the output value. ** [ It is the same as "PutBit(Bit,FALSE);" ] ** a) direction = Input : sets the specified bit to "0"; ** this operation will be shown on ** output after the direction has ** beenswitched to output ** (SetDir(TRUE);) ** b) direction = Output : directly writes "0" to the ** appropriate pin ** Parameters : ** NAME - DESCRIPTION ** Bit - Number of the bit to clear (0 to 7) ** Returns : Nothing ** =================================================================== */ void Byte1_ClrBit(byte Bit) { byte const Mask = Byte1_GetMsk(Bit); /* Temporary variable - set bit mask */ clrReg8Bits(PORTB, Mask); /* [bit Bit]=0 */ Shadow_B &= (byte)~Mask; /* Set appropriate bit in shadow variable */ }