Index: dragonfly_lib.h
===================================================================
--- dragonfly_lib.h	(revision 1344)
+++ dragonfly_lib.h	(revision 1345)
@@ -1,74 +1,115 @@
-/**
- * @file dragonfly_lib.h
- * @brief Contains other include files
- * 
- * Include this file for all the functionality of libdragonfly.
- *
- * @author Colony Project, CMU Robotics Club
- **/
-
-#ifndef _DRAGONFLY_LIB_H_
-#define _DRAGONFLY_LIB_H_
-
-/**
- * @addtogroup dragonfly
- * @{
- **/
-
-// Configuration definitions
-/** @brief Initialize analog **/
-#define ANALOG 0x01
-/** @brief Initialize serial communications **/
-#define SERIAL 0x02
-/** @brief Initialize USB communications **/
-#define USB    0x02
-/** @brief Initialize communications **/
-#define COMM   0x02
-/** @brief Initialize the orb **/
-#define ORB    0x04
-/** @brief Initialize the motors **/
-#define MOTORS 0x08
-/** @brief Initialize the servos **/
-#define SERVOS 0x10
-/** @brief Initialize I2C **/
-#define I2C    0x20
-/** @brief Initialize the buzzer **/
-#define BUZZER 0x40
-/** @brief Initialize the LCD screen **/
-#define LCD    0x80
-/** @brief Initialize everything **/
-#define ALL_ON 0xFF
-
-
-/** @brief Initialize the board **/
-void dragonfly_init(int config);
-
-/** @} **/ //end addtogroup
-
-#include <inttypes.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <avr/io.h>
-#include <avr/interrupt.h>
-#include <util/delay.h>
-#include <util/twi.h>
-
-#include <analog.h>
-#include <dio.h>
-#include <time.h>
-#include <lcd.h>
-#include <lights.h>
-#include <motor.h>
-#include <serial.h>
-#include <buzzer.h>
-#include <rangefinder.h>
-#include <bom.h>
-#include <move.h>
-#include <reset.h>
-#include <math.h>
-
-#include <spi.h>
-#include <encoders.h>
-
-#endif
-
+/**
+ * Copyright (c) 2007 Colony Project
+ * 
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ * 
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ **/
+
+
+/**
+ * @file dragonfly_lib.h
+ * @brief Contains other include files
+ * 
+ * Include this file for all the functionality of libdragonfly.
+ *
+ * @author Colony Project, CMU Robotics Club
+ **/
+
+#ifndef _DRAGONFLY_LIB_H_
+#define _DRAGONFLY_LIB_H_
+
+/**
+ * @addtogroup dragonfly
+ * @{
+ **/
+
+// Configuration definitions
+/** @brief Initialize analog **/
+#define ANALOG 0x01
+/** @brief Initialize serial communications **/
+#define SERIAL 0x02
+/** @brief Initialize USB communications **/
+#define USB    0x02
+/** @brief Initialize communications **/
+#define COMM   0x02
+/** @brief Initialize the orb **/
+#define ORB    0x04
+/** @brief Initialize the motors **/
+#define MOTORS 0x08
+/** @brief Initialize I2C **/
+#define I2C    0x20
+/** @brief Initialize the buzzer **/
+#define BUZZER 0x40
+/** @brief Initialize the LCD screen **/
+#define LCD    0x80
+/** @brief Initialize the rangefinders **/
+#define RANGE  0x0100
+/** @brief Initialize the BOM **/
+#define BOM  0x0200
+/** @brief Initialize everything  **/
+#define ALL_ON 0x03FF
+
+/** @brief Initialize the board **/
+void dragonfly_init(int config);
+
+/** @} **/ //end addtogroup
+
+#include <inttypes.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <avr/io.h>
+#include <avr/interrupt.h>
+#include <util/delay.h>
+#include <util/twi.h>
+
+// This file is included from the libdragonfly directory because it seems to be
+// missing from the AVR libc distribution.
+#include "atomic.h"
+
+#include <analog.h>
+#include <dio.h>
+#include <time.h>
+#include <lcd.h>
+#include <lights.h>
+#include <motor.h>
+#include <serial.h>
+#include <buzzer.h>
+#include <rangefinder.h>
+#include <bom.h>
+#include <move.h>
+#include <reset.h>
+#include <math.h>
+#include <eeprom.h>
+#include <stdbool.h>
+
+/** @brief shortcut for ATOMIC_BLOCK(ATOMIC_RESTORESTATE) **/
+#define SYNC ATOMIC_BLOCK(ATOMIC_RESTORESTATE)
+
+/** @brief atomically grab a lock if it is free, return otherwise **/
+#define REQUIRE_LOCK_OR_RETURN(LOCK) do { SYNC { if (LOCK) return; LOCK=1; } } while (0)
+
+/** @brief atomically release a lock **/
+#define RELEASE_LOCK(LOCK) do { LOCK=0; } while (0)
+
+
+
+#endif
+
