root / branches / init_refactor / code / projects / libdragonfly / dragonfly_defs.h @ 1547
History | View | Annotate | Download (3.33 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_def.h
|
29 |
* @brief Contains definitions for dragonfly library
|
30 |
*
|
31 |
* Should be included in all dragonfly library source files.
|
32 |
* Does not need to be included by user programs.
|
33 |
*
|
34 |
* @author Colony Project, CMU Robotics Club
|
35 |
**/
|
36 |
|
37 |
#ifndef _DRAGONFLY_DEFS_H_
|
38 |
#define _DRAGONFLY_DEFS_H_
|
39 |
|
40 |
/**
|
41 |
* @addtogroup dragonfly
|
42 |
* @{
|
43 |
**/
|
44 |
|
45 |
//return value definitions
|
46 |
/** @brief Error code for init failure **/
|
47 |
#define ERROR_INIT_FAILED 1 |
48 |
/** @brief Error code for duplicate init calls **/
|
49 |
#define ERROR_INIT_ALREADY_INITD 2 |
50 |
/** @brief Error code for not calling init **/
|
51 |
#define ERROR_LIBRARY_NOT_INITD 3 |
52 |
|
53 |
// Configuration definitions
|
54 |
/** @brief Initialize analog **/
|
55 |
#define ANALOG 0x01 |
56 |
/** @brief Initialize serial communications **/
|
57 |
#define SERIAL 0x02 |
58 |
/** @brief Initialize USB communications **/
|
59 |
#define USB 0x02 |
60 |
/** @brief Initialize communications **/
|
61 |
#define COMM 0x02 |
62 |
/** @brief Initialize the orb **/
|
63 |
#define ORB 0x04 |
64 |
/** @brief Initialize the motors **/
|
65 |
#define MOTORS 0x08 |
66 |
/** @brief Initialize I2C **/
|
67 |
#define I2C 0x20 |
68 |
/** @brief Initialize the buzzer **/
|
69 |
#define BUZZER 0x40 |
70 |
/** @brief Initialize the LCD screen **/
|
71 |
#define LCD 0x80 |
72 |
/** @brief Initialize the rangefinders **/
|
73 |
#define RANGE 0x0100 |
74 |
/** @brief Initialize the BOM **/
|
75 |
#define BOM 0x0200 |
76 |
/** @brief Initilize encoders **/
|
77 |
#define ENCODERS 0x400 |
78 |
/** @brief Initialize everything **/
|
79 |
#define ALL_ON 0x07FF |
80 |
|
81 |
/** @} **/ //end addtogroup |
82 |
|
83 |
/** @brief shortcut for ATOMIC_BLOCK(ATOMIC_RESTORESTATE) **/
|
84 |
#define SYNC ATOMIC_BLOCK(ATOMIC_RESTORESTATE)
|
85 |
|
86 |
/** @brief atomically grab a lock if it is free, return otherwise **/
|
87 |
#define REQUIRE_LOCK_OR_RETURN(LOCK) do { SYNC { if (LOCK) return; LOCK=1; } } while (0) |
88 |
|
89 |
/** @brief atomically release a lock **/
|
90 |
#define RELEASE_LOCK(LOCK) do { LOCK=0; } while (0) |
91 |
|
92 |
|
93 |
#define __TO_STR_(s) #s |
94 |
#define __TO_STR(s) __TO_STR_(s)
|
95 |
|
96 |
#ifdef DRAGONFLY_DEBUG
|
97 |
#define DRAGONFLY_DEBUG_PRINT(s) usb_puts(__FILE__ ":" __TO_STR(__LINE__) ">" s ) |
98 |
#define DRAGONFLY_DEBUG_PRINT_STR(s) usb_puts(s)
|
99 |
#define DRAGONFLY_DEBUG_PRINT_INT(i) usb_puti(i)
|
100 |
#else
|
101 |
#define DRAGONFLY_DEBUG_PRINT(s)
|
102 |
#define DRAGONFLY_DEBUG_PRINT_STR(s)
|
103 |
#define DRAGONFLY_DEBUG_PRINT_INT(i)
|
104 |
#endif
|
105 |
|
106 |
//TODO: write a STR_ERROR function which returns strings for the error codes
|
107 |
|
108 |
#endif
|