- Main Page
- Related Pages
- Modules
- Data Structures
- Files

# board.h

Go to the documentation of this file.

    00001 /* Copyright (c) 2007-2009 Axel Wachtler
    00002    All rights reserved.
    00003
    00004    Redistribution and use in source and binary forms, with or without
    00005    modification, are permitted provided that the following conditions
    00006    are met:
    00007
    00008    * Redistributions of source code must retain the above copyright
    00009      notice, this list of conditions and the following disclaimer.
    00010    * Redistributions in binary form must reproduce the above copyright
    00011      notice, this list of conditions and the following disclaimer in the
    00012      documentation and/or other materials provided with the distribution.
    00013    * Neither the name of the authors nor the names of its contributors
    00014      may be used to endorse or promote products derived from this software
    00015      without specific prior written permission.
    00016
    00017    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
    00018    AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    00019    IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    00020    ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
    00021    LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    00022    CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
    00023    SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
    00024    INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
    00025    CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
    00026    ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    00027    POSSIBILITY OF SUCH DAMAGE. */
    00028
    00029 /* $Id: board.h,v 1.26 2009/11/03 21:48:51 awachtler Exp $ */
    00035 #ifndef BOARD_H
    00036 #define BOARD_H
    00037
    00038 #ifndef F_CPU
    00039 # error "F_CPU is undefined"
    00040 #endif
    00041
    00042 #include <stdlib.h>
    00043 #include <stdint.h>
    00044 #include <inttypes.h>
    00045 #include <avr/io.h>
    00046 #include <avr/sleep.h>
    00047 #include <avr/interrupt.h>
    00048 #include <util/delay.h>
    00049 #include "const.h"
    00050 #include "board_cfg.h"
    00051
    00064 #define DELAY_US(x)  _delay_ms(x/1000.0)
    00065
    00068 #define DELAY_MS(x)  _delay_ms(x)
    00069
    00070 #ifndef PULLUP_KEYS
    00071
    00074 # define PULLUP_KEYS (0)
    00075 #endif
    00076
    00077
    00081 #define SLEEP_ON_IDLE()\
    00082         do{\
    00083             set_sleep_mode(SLEEP_MODE_IDLE);\
    00084             sleep_mode();\
    00085         }while(0);
    00086
    00087
    00088 #ifdef NO_TIMER
    00089 //# define HAVE_MALLOC_TIMERS
    00091 # define TIMER_POOL_SIZE  (0)
    00092 # define TIMER_INIT() do{}while(0)
    00093 # define TIMER_IRQ   TIMER1_OVF_vect
    00094 #endif
    00095
    00096 #ifndef HIF_TYPE
    00097
    00098 # define NO_HIF (1)
    00099 # define HIF_TYPE (HIF_NONE)
    00100 #endif
    00101
    00102 #ifndef HIF_IO_ENABLE
    00103
    00104 # define HIF_IO_ENABLE() do{}while(0)
    00105 #endif
    00106
    00107 #define HIF_TYPE_IS_UART  ((HIF_TYPE >= HIF_UART_0) && ( HIF_TYPE <= HIF_UART_1))
    00108 #define HIF_TYPE_IS_USB   ((HIF_TYPE == HIF_FT245) || (HIF_TYPE == HIF_AT90USB))
    00109
    00110 /* === Radio Control Pins === */
    00111 #ifndef TRX_RESET_INIT
    00112
    00113 # define TRX_RESET_INIT() DDR_TRX_RESET |= MASK_TRX_RESET
    00114 #endif
    00115
    00116 #ifndef TRX_RESET_HIGH
    00117
    00118 # define TRX_RESET_HIGH() PORT_TRX_RESET |= MASK_TRX_RESET
    00119 #endif
    00120
    00121 #ifndef TRX_RESET_LOW
    00122
    00123 # define TRX_RESET_LOW()  PORT_TRX_RESET &= ~MASK_TRX_RESET
    00124 #endif
    00125
    00126 #ifndef TRX_SLPTR_INIT
    00127
    00128 # define TRX_SLPTR_INIT() DDR_TRX_SLPTR |= MASK_TRX_SLPTR
    00129 #endif
    00130
    00131 #ifndef TRX_SLPTR_HIGH
    00132
    00133 # define TRX_SLPTR_HIGH() PORT_TRX_SLPTR |= MASK_TRX_SLPTR
    00134 #endif
    00135
    00136 #ifndef TRX_SLPTR_LOW
    00137
    00138 # define TRX_SLPTR_LOW()  PORT_TRX_SLPTR &= ~MASK_TRX_SLPTR
    00139 #endif
    00140
    00141
    00142 #if defined (DBG_PORT) && defined (DBG_DDR) && defined (DBG_PIN)
    00143 # define DBG_INIT() do{DBG_DDR |= DBG_PIN; DBG_PORT &= ~DBG_PIN;}while(0)
    00144 # define DBG_SET() do{DBG_PORT |= DBG_PIN;}while(0)
    00145 # define DBG_CLR() do{DBG_PORT &= ~DBG_PIN;}while(0)
    00146 # define DBG_TOGGLE() do{DBG_PORT ^= DBG_PIN;}while(0)
    00147 #else
    00148 # define DBG_INIT() do{}while(0)
    00149 # define DBG_SET() do{}while(0)
    00150 # define DBG_CLR() do{}while(0)
    00151 # define DBG_TOGGLE() do{}while(0)
    00152 #endif
    00153
    00154 #endif /* #ifndef BOARD_H */