-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBit.h
27 lines (22 loc) · 968 Bytes
/
Bit.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// Permission to copy is granted provided that this header remains intact.
// This software is provided with no warranties.
////////////////////////////////////////////////////////////////////////////////
#ifndef BIT_H
#define BIT_H
////////////////////////////////////////////////////////////////////////////////
//Functionality - Sets bit on a PORTx
//Parameter: Takes in a uChar for a PORTx, the pin number and the binary value
//Returns: The new value of the PORTx
unsigned char SetBit(unsigned char pin, unsigned char number, unsigned char bin_value)
{
return (bin_value ? pin | (0x01 << number) : pin & ~(0x01 << number));
}
////////////////////////////////////////////////////////////////////////////////
//Functionality - Gets bit from a PINx
//Parameter: Takes in a uChar for a PINx and the pin number
//Returns: The value of the PINx
unsigned char GetBit(unsigned char port, unsigned char number)
{
return ( port & (0x01 << number) );
}
#endif //BIT_H