Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef HEIKO_H
- #define HEIKO_H 1
- #define INLINE __attribute__((always_inline));
- #define NOP() asm volatile ("nop")
- #define NOP2() asm volatile ("rjmp 1f\n 1:")
- typedef unsigned char byte;
- typedef unsigned int uint;
- typedef unsigned long ulong;
- typedef union
- {
- struct
- {
- byte low;
- byte high;
- };
- uint word;
- } WORD;
- #define nullptr ((void*) 0)
- // Highbyte / Lowbyte of variables
- #define LOW_BYTE(var) (((unsigned char *)&(var))[0])
- #define HIGH_BYTE(var) (((unsigned char *)&(var))[1])
- #define MK_WORD(low,high) (low | (high<<8))
- //______________________________________________________
- #define S(bit) (1<<bit)
- #define R(bit) (~(1<<bit))
- #define C(bit) (~(1<<bit))
- //____ Bit functions __________________________________
- #define BM(bit) (1<<bit)
- #define BS(bit) (1<<bit)
- #define BC(bit) (0<<bit)
- #define IsSET(port,bit) ((port & BM(bit)) != 0)
- #define IsCLEAR(port,bit) ((port & BM(bit)) == 0)
- #define SetBit(port,bit) port |= BM(bit)
- #define ClearBit(port,bit) port &= ~BM(bit)
- //____ Port functions __________________________________
- #define DDR(port) __CONCAT(DDR, port)
- #define PIN(port) __CONCAT(PIN, port)
- #define PORT(port) __CONCAT(PORT, port)
- #define DIRIN(port,bit) __CONCAT(DDR, port) &= (byte) ~BM(bit)
- #define DIROUT(port,bit) __CONCAT(DDR, port) |= (byte) BM(bit)
- #define SETHIGH(port,bit) __CONCAT(PORT, port) |= (byte) BM(bit)
- #define SETLOW(port,bit) __CONCAT(PORT, port) &= (byte) ~BM(bit)
- #define TOGGLE(port,bit) __CONCAT(PIN, port) |= (byte) BM(bit)
- #define ISHIGH(port,bit) ((__CONCAT(PIN, port) & BM(bit)) != 0)
- #define ISLOW(port,bit) ((__CONCAT(PIN, port) & BM(bit)) == 0)
- #define PULLUPON(port,bit) __CONCAT(PORT, port) |= (byte) BM(bit)
- #define PULLUPOFF(port,bit) __CONCAT(PORT, port) &= (byte) ~BM(bit)
- //____ Open Collector assumes a 0 at the pins_________
- #define OCHIGH(port,bit) __CONCAT(DDR, port) &= ~BM(bit)
- #define OCLOW(port,bit) __CONCAT(DDR, port) |= BM(bit)
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement