saved some bytes
This commit is contained in:
parent
63ff73a066
commit
a109991e7a
10 changed files with 94 additions and 50 deletions
13
writepin.cpp
13
writepin.cpp
|
|
@ -1,19 +1,20 @@
|
|||
#include "writepin.h"
|
||||
|
||||
void writePin(volatile unsigned char *port, const unsigned char pin, const bool state) //waste 2 cycles
|
||||
void writePin(volatile unsigned char * const port, const unsigned char pin, const bool state)
|
||||
{
|
||||
if(!state) *port &= ~(1 << pin);
|
||||
else *port |= (1 << pin);
|
||||
*port = (*port & ~(1 << pin)) | (1 << pin)*state;
|
||||
//if(!state) *port &= ~(1 << pin);
|
||||
//else *port |= (1 << pin);
|
||||
}
|
||||
|
||||
void setBit( volatile unsigned char *reg, const unsigned char bit, bool value )
|
||||
void setBit( volatile unsigned char * const reg, const unsigned char bit, const bool value )
|
||||
{
|
||||
writePin(reg, bit, value);
|
||||
}
|
||||
|
||||
void setDirection( volatile unsigned char *portDirReg, const unsigned char pin, bool makeOutput )
|
||||
void setDirection( volatile unsigned char * const portDirReg, const unsigned char pin, const bool makeOutput )
|
||||
{
|
||||
writePin(portDirReg, pin, makeOutput);
|
||||
}
|
||||
|
||||
bool readPin( volatile unsigned char *inPort, const unsigned char pin){ return (bool) (*inPort & (1 << pin));}
|
||||
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