#include <avr/io.h>
#include <avr/interrupt.h>
#include <util/delay.h>
Go to the source code of this file.
Classes | |
struct | long_to_byte_t |
Macros | |
#define | FALSE (1!=1) |
#define | NULL ((void*)0) |
Nullzeiger. More... | |
#define | TRUE (1==1) |
Nützliches | |
#define | DEGREE_TO_RAD(x) ((x * M_PI) / 180) |
#define | HIGH_BYTE(x) ((uint8_t) (x >> 8)) |
#define | HIGH_WORD(x) ((uint16_t) (x >> 16)) |
#define | LOW_BYTE(x) ((uint8_t) (x & 0xff)) |
#define | LOW_WORD(x) ((uint16_t) (x & 0xffff)) |
Volatile Zugriff auf Variablen | |
#define | vs16(x) (*(volatile int16_t*)&(x)) |
#define | vs32(x) (*(volatile int32_t*)&(x)) |
#define | vs8(x) (*(volatile int8_t*)&(x)) |
#define | vu16(x) (*(volatile uint16_t*)&(x)) |
#define | vu32(x) (*(volatile uint32_t*)&(x)) |
#define | vu8(x) (*(volatile uint8_t*)&(x)) |
Port-Makros | |
Die Makros RESET(), SET(), SET_OUTPUT(), SET_INPUT() und IS_SET() beziehen sich immer auf ein bestimmtes Bit eines Ports und helfen somit den Code sehr portabel zu gestalten. Beispiel: #define LED D,5 // PORTD, Pin 5
SET_OUTPUT(LED); // Pin als Ausgang schalten (wird z.B. zu DDRD |= (1<<5);)
SET(LED); // LED aktivieren
oder auch: Somit muss nur ein Define geändert werden sobald ein anderer Pin verwendet werden soll. Außerdem muss nicht immer noch ein extra Define für den entsprechenden Port angelegt werden wie es bisher immer der Fall war. | |
#define | _ddr2(x) DDR ## x |
#define | _pin2(x) PIN ## x |
#define | _pin_num(x, y) y |
#define | _port2(x) PORT ## x |
#define | _reg(x, y) x |
#define | DDR(x) _ddr2(x) |
#define | IS_SET(x) IS_SET2(x) |
#define | IS_SET2(x, y) ((PIN(x) & (1<<y)) != 0) |
#define | PIN(x) _pin2(x) |
#define | PIN_NUM(x) _pin_num(x) |
#define | PORT(x) _port2(x) |
#define | REG(x) _reg(x) |
#define | RESET(x) RESET2(x) |
#define | RESET2(x, y) PORT(x) &= ~(1<<y) |
#define | SET(x) SET2(x) |
#define | SET2(x, y) PORT(x) |= (1<<y) |
#define | SET_INPUT(x) SET_INPUT2(x) |
#define | SET_INPUT2(x, y) DDR(x) &= ~(1<<y) |
#define | SET_INPUT_WITH_PULLUP(x) SET_INPUT_WITH_PULLUP2(x) |
#define | SET_INPUT_WITH_PULLUP2(x, y) SET_INPUT2(x,y);SET2(x,y) |
#define | SET_OUTPUT(x) SET_OUTPUT2(x) |
#define | SET_OUTPUT2(x, y) DDR(x) |= (1<<y) |
#define | SET_PULLUP(x) SET2(x) |
#define | TOGGLE(x) TOGGLE2(x) |
#define | TOGGLE2(x, y) PORT(x) ^= (1<<y) |
Kritische Sektionen (Interrupts sperren) | |
#define | ENTER_CRITICAL_SECTION do { unsigned char sreg_ = SREG; cli(); |
#define | LEAVE_CRITICAL_SECTION SREG = sreg_; } while (0); |
static uint8_t | read_and_replace_atomar (volatile uint8_t *data, uint8_t new_data) |
atomare Operationen More... | |
weitere nuetzliche Makros | |
#define | _bit_is_clear(pin, bit) (!(pin & (1<<bit))) |
#define | _bit_is_set(pin, bit) (pin & (1<<bit)) |
#define | _STRING(x) #x |
static uint8_t | bit_count32 (uint32_t n) |
Zählt die Anzahl der gesetzten Bits in einem Byte. More... | |
static uint8_t | bit_count8 (uint8_t n) |
Zählt die Anzahl der gesetzten Bits in einem Byte. More... | |
#define | DEBUG_PRINT(s, ...) |
More... | |
#define | END_TIMED_BLOCK |
#define | MASK_00001111 (((uint32_t)(-1))/17) |
#define | MASK_00110011 (((uint32_t)(-1))/5) |
#define | MASK_01010101 (((uint32_t)(-1))/3) |
#define | START_TIMED_BLOCK(time, gettime) |
#define | STRING(x) _STRING(x) |
static uint8_t | swap (uint8_t x) |
Dreht die beiden Nibble in einem Byte um. More... | |
#define | TO_DEG(x) (x * 180.0 / M_PI) |
#define | TO_RAD(x) (x * M_PI / 180.0) |
#define | USE_IT(x) (void) x |
Macro to supress "unused argument" warnings from the compiler. More... | |
#define ENTER_CRITICAL_SECTION do { unsigned char sreg_ = SREG; cli(); |
#define SET_INPUT | ( | x | ) | SET_INPUT2(x) |
#define SET_INPUT_WITH_PULLUP | ( | x | ) | SET_INPUT_WITH_PULLUP2(x) |
#define SET_INPUT_WITH_PULLUP2 | ( | x, | |
y | |||
) | SET_INPUT2(x,y);SET2(x,y) |
#define SET_OUTPUT | ( | x | ) | SET_OUTPUT2(x) |
#define START_TIMED_BLOCK | ( | time, | |
gettime | |||
) |
#define USE_IT | ( | x | ) | (void) x |