Lamp-Da
0.1
A compact lantern project
Loading...
Searching...
No Matches
src
depends
arduinoFFT
src
defs.h
1
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
//#define F_CPU 4000000
26
#define MEM_TYPE 1
27
28
// Code compatibility to new AVR-libc
29
// outb(), inb(), inw(), outw(), BV(), sbi(), cbi(), sei(), cli()
30
#ifndef outb
31
#define outb(addr, data) addr = (data)
32
#endif
33
#ifndef inb
34
#define inb(addr) (addr)
35
#endif
36
#ifndef outw
37
#define outw(addr, data) addr = (data)
38
#endif
39
#ifndef inw
40
#define inw(addr) (addr)
41
#endif
42
#ifndef BV
43
#define BV(bit) (1<<(bit))
44
#endif
45
//#ifndef cbi
46
// #define cbi(reg,bit) reg &= ~(BV(bit))
47
//#endif
48
//#ifndef sbi
49
// #define sbi(reg,bit) reg |= (BV(bit))
50
//#endif
51
#ifndef cli
52
#define cli() __asm__ __volatile__ ("cli"
::)
53
#endif
54
#ifndef sei
55
#define sei() __asm__ __volatile__ ("sei"
::)
56
#endif
57
58
// support for individual port pin naming in the mega128
59
// see port128.h for details
60
#ifdef __AVR_ATmega128__
61
// not currently necessary due to inclusion
62
// of these defines in newest AVR-GCC
63
// do a quick test to see if include is needed
64
#ifndef PD0
65
//#include "port128.h"
66
#endif
67
#endif
68
69
// use this for packed structures
70
// (this is seldom necessary on an 8-bit architecture like AVR,
71
// but can assist in code portability to AVR)
72
#define GNUC_PACKED __attribute__((packed))
73
74
// port address helpers
75
#define DDR(x) ((x)-1)
// address of data direction register of port x
76
#define PIN(x) ((x)-2)
// address of input register of port x
77
78
// MIN/MAX/ABS macros
79
#define MIN(a,b) ((a<b)?(a):(b))
80
#define MAX(a,b) ((a>b)?(a):(b))
81
#define ABS(x) ((x>0)?(x):(-x))
82
83
// constants
84
#define PI 3.14159265359
85
86
//Math
87
#define sq(x) ((x)*(x))
88
#define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt)))
89
90
#endif
Generated by
1.9.6