inital commit
This commit is contained in:
commit
51a5e6fc28
10 changed files with 489 additions and 0 deletions
20
writepin.cpp
Normal file
20
writepin.cpp
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
#include "writepin.h"
|
||||
|
||||
void writePin(volatile unsigned char * const port, const unsigned char pin, const bool state)
|
||||
{
|
||||
*port = (*port & ~(1 << pin)) | (1 << pin)*state;
|
||||
//if(!state) *port &= ~(1 << pin);
|
||||
//else *port |= (1 << pin);
|
||||
}
|
||||
|
||||
void setBit( volatile unsigned char * const reg, const unsigned char bit, const bool value )
|
||||
{
|
||||
writePin(reg, bit, value);
|
||||
}
|
||||
|
||||
void setDirection( volatile unsigned char * const portDirReg, const unsigned char pin, const bool makeOutput )
|
||||
{
|
||||
writePin(portDirReg, pin, makeOutput);
|
||||
}
|
||||
|
||||
bool readPin( volatile const unsigned char * const inPort, const unsigned char pin){ return (bool) (*inPort & (1 << pin));}
|
||||
Loading…
Add table
Add a link
Reference in a new issue