#ifndef __myavr_h__ #define __myavr_h__ #ifndef sbi #define sbi(port, bit) (port) |= (1 << (bit)) #endif #ifndef cbi #define cbi(port, bit) (port) &= ~(1 << (bit)) #endif #ifndef BIT0 #define BIT0 1 #endif #ifndef BIT1 #define BIT1 2 #endif #ifndef BIT2 #define BIT2 4 #endif #ifndef BIT3 #define BIT3 8 #endif #ifndef BIT4 #define BIT4 16 #endif #ifndef BIT5 #define BIT5 32 #endif #ifndef BIT6 #define BIT6 64 #endif #ifndef BIT7 #define BIT7 128 #endif typedef uint8_t byte; typedef uint8_t U8; typedef uint16_t U16; //------------------------------------------------------------------------- // Verwendung der Makros: // Deklaration der Bits z.B.: // #define LEDrot myPin(PORTB,2) // #define PumpeKH myPin(PORTB,1) // Schalten der Bits z.B.: // on(LEDrot); // off(LEDrot); //------------------------------------------------------------------------- #ifndef outb #define outb(xPORT,xBYTE) \ {{ \ asm volatile ("st Z, %1" : : "z" ((uint8_t)0xff&(uint16_t)(&xPORT)), "a" (xBYTE) ); \ }} #endif #define SetPins(xPORT,xBITS) \ {{ \ asm volatile ("ld r16,Z" "\n\t" "or r16,%1" "\n\t" "st Z, r16" : : "z" ((uint8_t)0xff&(uint16_t)(&xPORT)), "a" (xBITS) : "r16"); \ }} #define ClearPins(xPORT,xBITS) \ {{ \ asm volatile ("ld r16,Z" "\n\t" "and r16,%1" "\n\t" "st Z, r16" : : "z" ((uint8_t)0xff&(uint16_t)(&xPORT)), "a" (~xBITS) : "r16"); \ }} #define _setPins(xPORT,xBITS) \ {{ \ asm volatile ("ld r16,Z" "\n\t" "or r16,%1" "\n\t" "st Z, r16" : : "z" (xPORT), "a" (xBITS) : "r16"); \ }} #define _clrPins(xPORT,xBITS) \ {{ \ asm volatile ("ld r16,Z" "\n\t" "and r16,%1" "\n\t" "st Z, r16" : : "z" (xPORT), "a" (~xBITS) : "r16"); \ }} #define MyPinOn(xMyPin) _setPins(xMyPin&0xff,xMyPin/0x100) #define MyPinOff(xMyPin) _clrPins(xMyPin&0xff,(xMyPin/0x100)) #define MyPin(xPORT,xBIT) (((uint8_t)0xff&(uint16_t)(&xPORT))+(1<