Changed Sensor Output formating

This commit is contained in:
IMback
2018-10-29 18:21:42 +01:00
parent 2fa8104164
commit 5dac2e5ff9
7 changed files with 318 additions and 12 deletions

View File

@ -2,12 +2,25 @@
#define WRITEPIN_H
#include <avr/io.h>
inline void writePin(volatile unsigned char *port, const unsigned char pin, const bool state) //waste 2 cycles
{
*port &= ~(1 << pin);
if(state) *port |= (1 << pin);
}
inline void setBit( volatile unsigned char *reg, const unsigned char bit, bool value )
{
writePin(reg, bit, value);
}
inline void setDirection( volatile unsigned char *portDirReg, const unsigned char pin, bool makeOutput )
{
writePin(portDirReg, pin, makeOutput);
}
inline bool readPin( volatile unsigned char *inPort, const unsigned char pin){ return (bool) (*inPort & (1 << pin));}
#endif