Subversion Repositories svnkaklik

Rev

Rev 507 | Details | Compare with Previous | Last modification | View Log

Rev Author Line No. Line
507 kaklik 1
/*! \file avrlibdefs.h \brief AVRlib global defines and macros. */
2
//*****************************************************************************
3
//
4
// File Name	: 'avrlibdefs.h'
5
// Title		: AVRlib global defines and macros include file
6
// Author		: Pascal Stang
7
// Created		: 7/12/2001
8
// Revised		: 9/30/2002
9
// Version		: 1.1
10
// Target MCU	: Atmel AVR series
11
// Editor Tabs	: 4
12
//
13
//	Description : This include file is designed to contain items useful to all
14
//					code files and projects, regardless of specific implementation.
15
//
16
// This code is distributed under the GNU Public License
17
//		which can be found at http://www.gnu.org/licenses/gpl.txt
18
//
19
//*****************************************************************************
20
 
21
 
22
#ifndef AVRLIBDEFS_H
23
#define AVRLIBDEFS_H
24
 
25
// Code compatibility to new AVR-libc
26
// outb(), inb(), inw(), outw(), BV(), sbi(), cbi(), sei(), cli()
27
#ifndef outb
28
	#define	outb(addr, data)	addr = (data)
29
#endif
30
#ifndef inb
31
	#define	inb(addr)			(addr)
32
#endif
33
#ifndef outw
34
	#define	outw(addr, data)	addr = (data)
35
#endif
36
#ifndef inw
37
	#define	inw(addr)			(addr)
38
#endif
39
#ifndef BV
40
	#define BV(bit)			(1<<(bit))
41
#endif
42
#ifndef cbi
43
	#define cbi(reg,bit)	reg &= ~(BV(bit))
44
#endif
45
#ifndef sbi
46
	#define sbi(reg,bit)	reg |= (BV(bit))
47
#endif
48
#ifndef cli
49
	#define cli()			__asm__ __volatile__ ("cli" ::)
50
#endif
51
#ifndef sei
52
	#define sei()			__asm__ __volatile__ ("sei" ::)
53
#endif
54
 
55
// support for individual port pin naming in the mega128
56
// see port128.h for details
57
#ifdef __AVR_ATmega128__
58
// not currently necessary due to inclusion
59
// of these defines in newest AVR-GCC
60
// do a quick test to see if include is needed
61
#ifndef PD0
62
	#include "port128.h"
63
#endif
64
#endif
65
 
66
// use this for packed structures
67
// (this is seldom necessary on an 8-bit architecture like AVR,
68
//  but can assist in code portability to AVR)
69
#define GNUC_PACKED __attribute__((packed)) 
70
 
71
// port address helpers
72
#define DDR(x) ((x)-1)    // address of data direction register of port x
73
#define PIN(x) ((x)-2)    // address of input register of port x
74
 
75
// MIN/MAX/ABS macros
76
#define MIN(a,b)			((a<b)?(a):(b))
77
#define MAX(a,b)			((a>b)?(a):(b))
78
#define ABS(x)				((x>0)?(x):(-x))
79
 
80
// constants
81
#define PI		3.14159265359
82
 
83
#endif