inital commit working
This commit is contained in:
19
writepin.cpp
Normal file
19
writepin.cpp
Normal file
@ -0,0 +1,19 @@
|
||||
#include "writepin.h"
|
||||
|
||||
void writePin(volatile unsigned char *port, const unsigned char pin, const bool state) //waste 2 cycles
|
||||
{
|
||||
if(!state) *port &= ~(1 << pin);
|
||||
else *port |= (1 << pin);
|
||||
}
|
||||
|
||||
void setBit( volatile unsigned char *reg, const unsigned char bit, bool value )
|
||||
{
|
||||
writePin(reg, bit, value);
|
||||
}
|
||||
|
||||
void setDirection( volatile unsigned char *portDirReg, const unsigned char pin, bool makeOutput )
|
||||
{
|
||||
writePin(portDirReg, pin, makeOutput);
|
||||
}
|
||||
|
||||
bool readPin( volatile unsigned char *inPort, const unsigned char pin){ return (bool) (*inPort & (1 << pin));}
|
Reference in New Issue
Block a user