Project

General

Profile

Statistics
| Revision:

root / trunk / code / lib / include / libdragonfly / dragonfly_lib.h @ 1461

History | View | Annotate | Download (3.32 KB)

1
/**
2
 * Copyright (c) 2007 Colony Project
3
 * 
4
 * Permission is hereby granted, free of charge, to any person
5
 * obtaining a copy of this software and associated documentation
6
 * files (the "Software"), to deal in the Software without
7
 * restriction, including without limitation the rights to use,
8
 * copy, modify, merge, publish, distribute, sublicense, and/or sell
9
 * copies of the Software, and to permit persons to whom the
10
 * Software is furnished to do so, subject to the following
11
 * conditions:
12
 * 
13
 * The above copyright notice and this permission notice shall be
14
 * included in all copies or substantial portions of the Software.
15
 * 
16
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
18
 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20
 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23
 * OTHER DEALINGS IN THE SOFTWARE.
24
 **/
25

    
26

    
27
/**
28
 * @file dragonfly_lib.h
29
 * @brief Contains other include files
30
 * 
31
 * Include this file for all the functionality of libdragonfly.
32
 *
33
 * @author Colony Project, CMU Robotics Club
34
 **/
35

    
36
#ifndef _DRAGONFLY_LIB_H_
37
#define _DRAGONFLY_LIB_H_
38

    
39
/**
40
 * @addtogroup dragonfly
41
 * @{
42
 **/
43

    
44
//return value definitions
45
#define ERROR_INIT_FAILED 1
46
#define ERROR_INIT_ALREADY_INITD 2
47

    
48
#define ERROR_LIBRARY_NOT_INITD 3
49

    
50
// Configuration definitions
51
/** @brief Initialize analog **/
52
#define ANALOG 0x01
53
/** @brief Initialize serial communications **/
54
#define SERIAL 0x02
55
/** @brief Initialize USB communications **/
56
#define USB    0x02
57
/** @brief Initialize communications **/
58
#define COMM   0x02
59
/** @brief Initialize the orb **/
60
#define ORB    0x04
61
/** @brief Initialize the motors **/
62
#define MOTORS 0x08
63
/** @brief Initialize I2C **/
64
#define I2C    0x20
65
/** @brief Initialize the buzzer **/
66
#define BUZZER 0x40
67
/** @brief Initialize the LCD screen **/
68
#define LCD    0x80
69
/** @brief Initialize the rangefinders **/
70
#define RANGE  0x0100
71
/** @brief Initialize the BOM **/
72
#define BOM  0x0200
73
/** @brief Initilize encoders **/
74
#define ENCODERS 0x400
75
/** @brief Initialize everything  **/
76
#define ALL_ON 0x07FF
77

    
78
/** @brief Initialize the board **/
79
void dragonfly_init(int config);
80

    
81
/** @} **/ //end addtogroup
82

    
83
#include <inttypes.h>
84
#include <avr/io.h>
85
#include <avr/interrupt.h>
86
#include <util/delay.h>
87
#include <util/twi.h>
88

    
89
// This file is included from the libdragonfly directory because it seems to be
90
// missing from the AVR libc distribution.
91
#include "atomic.h"
92

    
93
#include "analog.h"
94
#include "dio.h"
95
#include "time.h"
96
#include "lcd.h"
97
#include "lights.h"
98
#include "motor.h"
99
#include "serial.h"
100
#include "buzzer.h"
101
#include "rangefinder.h"
102
#include "bom.h"
103
#include "encoders.h"
104
#include "move.h"
105
#include "reset.h"
106
#include "math.h"
107
#include "eeprom.h"
108

    
109
#include <stddef.h>
110
#include <stdbool.h>
111

    
112
/** @brief shortcut for ATOMIC_BLOCK(ATOMIC_RESTORESTATE) **/
113
#define SYNC ATOMIC_BLOCK(ATOMIC_RESTORESTATE)
114

    
115
/** @brief atomically grab a lock if it is free, return otherwise **/
116
#define REQUIRE_LOCK_OR_RETURN(LOCK) do { SYNC { if (LOCK) return; LOCK=1; } } while (0)
117

    
118
/** @brief atomically release a lock **/
119
#define RELEASE_LOCK(LOCK) do { LOCK=0; } while (0)
120

    
121

    
122

    
123
#endif
124