#ifndef HARDWARE_H
#define HARDWARE_H

/* stdint.h isn't provided until gcc-3.4 */
/* #include <stdint.h> */
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
typedef signed char int8_t;
typedef signed short int16_t;
typedef signed int int32_t;

/* I/O ports */
#define porta  ((volatile uint8_t *)0x1000)
#define portb  ((volatile uint8_t *)0x1004)
#define portc  ((volatile uint8_t *)0x1003)
#define portd  ((volatile uint8_t *)0x1008)
#define porte  ((volatile uint8_t *)0x100A)
#define ddrc   ((volatile uint8_t *)0x1007)
#define ddrd   ((volatile uint8_t *)0x1009)
#define pioc   ((volatile uint8_t *)0x1002)
#define portcl ((volatile uint8_t *)0x1005)

/* Analog to Digital converter */
#define adctl ((volatile uint8_t *)0x1030)
#define adr1  ((const volatile uint8_t *)0x1031)
#define adr2  ((const volatile uint8_t *)0x1032)
#define adr3  ((const volatile uint8_t *)0x1033)
#define adr4  ((const volatile uint8_t *)0x1034)

/* Configuration Control */
#define config ((const volatile uint8_t *)0x103F)
#define option ((volatile uint8_t *)0x1039)
#define init   ((volatile uint8_t *)0x103D)

/* Highest Priority Interrupt and Miscellaneous Register */
#define hprio ((volatile uint8_t *)0x103C)

/* Watchdog timer */
#define coprst ((volatile uint8_t *)0x103A)

/* EPROM/EEPROM Programming Control */
#define eprog ((volatile uint8_t *)0x1036)
#define pprog ((volatile uint8_t *)0x103B)
#define bprot ((volatile uint8_t *)0x1035)

/* Timer */
#define tcnt ((const volatile uint16_t *)0x100E)

#define tic1  ((volatile uint16_t *)0x1010)
#define tic2  ((volatile uint16_t *)0x1012)
#define tic3  ((volatile uint16_t *)0x1014)
#define ti4o5 ((volatile uint16_t *)0x101E) /* tic4 or toc5 */
#define toc1  ((volatile uint16_t *)0x1016)
#define toc2  ((volatile uint16_t *)0x1018)
#define toc3  ((volatile uint16_t *)0x101A)
#define toc4  ((volatile uint16_t *)0x101C)

#define cforc ((volatile uint8_t *)0x100B)
#define oc1m  ((volatile uint8_t *)0x100C)
#define oc1d  ((volatile uint8_t *)0x100D)

#define tctl1 ((volatile uint8_t *)0x1020)
#define tctl2 ((volatile uint8_t *)0x1021)
#define tmsk1 ((volatile uint8_t *)0x1022)
#define tflg1 ((volatile uint8_t *)0x1023)
#define tmsk2 ((volatile uint8_t *)0x1024)
#define tflg2 ((volatile uint8_t *)0x1025)

#define pactl ((volatile uint8_t *)0x1026)
#define pacnt ((volatile uint8_t *)0x1027)

/* Serial Communications Interface */
#define scdr ((volatile uint8_t *)0x102F)
#define sccr1 ((volatile uint8_t *)0x102C)
#define sccr2 ((volatile uint8_t *)0x102D)
#define scsr ((volatile uint8_t *)0x102E)
#define baud ((volatile uint8_t *)0x102B)

/* Serial Peripheral Interface */
#define spcr ((volatile uint8_t *)0x1028)
#define spsr ((volatile uint8_t *)0x1029)
#define spdr ((volatile uint8_t *)0x102A)

static inline void cli()
{
  __asm__("cli");
}

static inline void sei()
{
  __asm__("sei");
}

#endif /* header guard */

(download)