Nut/OS  4.10.3
API Reference
xnut.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2005-2007 proconX Pty Ltd <www.proconx.com>
00003  *
00004  * $Id: xnut.h 1928 2007-09-08 01:50:49Z hwmaier $
00005  *
00006  * Redistribution and use in source and binary forms, with or without
00007  * modification, are permitted provided that the following conditions
00008  * are met:
00009  *
00010  * 1. Redistributions of source code must retain the above copyright
00011  *    notice, this list of conditions and the following disclaimer.
00012  * 2. Redistributions in binary form must reproduce the above copyright
00013  *    notice, this list of conditions and the following disclaimer in the
00014  *    documentation and/or other materials provided with the distribution.
00015  * 3. Neither the name of the copyright holders nor the names of
00016  *    contributors may be used to endorse or promote products derived
00017  *    from this software without specific prior written permission.
00018  *
00019  * THIS SOFTWARE IS PROVIDED BY EGNITE SOFTWARE GMBH AND CONTRIBUTORS
00020  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00021  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00022  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL EGNITE
00023  * SOFTWARE GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00024  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00025  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
00026  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
00027  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00028  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
00029  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00030  * SUCH DAMAGE.
00031  *
00032  * For additional information see http://www.ethernut.de/
00033  */
00034 
00035 
00036 #ifndef _CFG_XNUT_H_
00037 #define _CFG_XNUT_H_
00038 
00039 #ifndef _XNUT_XXX_H_INCLUDED
00040 #  define _XNUT_XXX_H_INCLUDED "cfg/xnut.h"
00041 #else
00042 #  error "Attempt to include more than one <xnut-xxx.h> file"
00043 #endif
00044 
00045 
00046 #include <cfg/os.h>
00047 #include <cfg/memory.h>
00048 #include <cfg/arch.h>
00049 #include <cfg/eeprom.h>
00050 #include <arch/avr.h>
00051 #include <cfg/arch/avrpio.h>
00052 
00053 /* Validate F_CPU setting */
00054 #if F_CPU == 1000000UL
00055 #  error "F_CPU is set to avr-lib default 1 MHz! Please include <avr/delay.h> after <xnut.h>"
00056 #endif
00057 #define F_CPU NUT_CPU_FREQ
00058 
00059 
00073 
00074 /*****************************************************************************
00075  * LED control macros
00076  *****************************************************************************/
00077 
00084 
00086 #define LED_S1_OFF()         do {PORTF &= ~_BV(2); PORTF &= ~_BV(3);} while(0)
00087 
00088 #define LED_S1_RED()         do {PORTF &= ~_BV(2); PORTF |= _BV(3);} while(0)
00089 
00090 #define LED_S1_RED_TOGGLE()  do {PORTF &= ~_BV(2); PORTF ^= _BV(3);} while(0)
00091 
00092 #define LED_S1_GREEN()       do {PORTF |= _BV(2); PORTF &= ~_BV(3);} while(0)
00093 
00094 #define LED_S1_GREEN_TOGGLE() do {PORTF ^= _BV(2); PORTF &= ~_BV(3);} while(0)
00095 #define LED_S1_RED_GREEN_TOGGLE() do {PORTF ^= _BV(2); if (bit_is_set(PORTF, 2)) \
00096    PORTF &= ~_BV(3); else PORTF |= _BV(3);} while(0)
00097 
00099 #define LED_S2_OFF()         do {PORTF &= ~_BV(0); PORTF &= ~_BV(1);} while(0)
00100 
00101 #define LED_S2_RED()         do {PORTF &= ~_BV(0); PORTF |= _BV(1);} while(0)
00102 
00103 #define LED_S2_RED_TOGGLE()  do {PORTF &= ~_BV(0); PORTF ^= _BV(1);} while(0)
00104 
00105 #define LED_S2_GREEN()       do {PORTF |= _BV(0); PORTF &= ~_BV(1);} while(0)
00106 
00107 #define LED_S2_GREEN_TOGGLE() do {PORTF ^= _BV(0); PORTF &= ~_BV(1);} while(0)
00108 #define LED_S2_RED_GREEN_TOGGLE() do {PORTF ^= _BV(0); if (bit_is_set(PORTF, 0)) \
00109    PORTF &= ~_BV(1); else PORTF |= _BV(1);} while(0)
00110 
00112 
00113 
00114 /*****************************************************************************
00115  * UART control macros
00116  *****************************************************************************/
00117 
00124 
00131 #define SER0_RS232_MODE()    (PORTB |= _BV(0))
00132 
00139 #define SER0_RS485_MODE()    (PORTB &= ~_BV(0))
00140 
00147 #define SER0_RS485_DRV_ON()   (PORTB |= _BV(1))
00148 
00152 #define SER0_RS485_DRV_OFF()  (PORTB &= ~_BV(1))
00153 
00160 #define SER1_RS232_MODE()    (PORTB |= _BV(2))
00161 
00168 #define SER1_RS485_MODE()    (PORTB &= ~_BV(2))
00169 
00176 #define SER1_RS485_DRV_ON()   (PORTB |= _BV(3))
00177 
00181 #define SER1_RS485_DRV_OFF()  (PORTB &= ~_BV(3))
00182 
00189 #define SER0_GET_CD()        bit_is_set(PINB, 6)
00190 
00197 #define SER0_GET_RI()        bit_is_clear(PINB, 7)
00198 
00205 #define SER0_GET_CTS()       bit_is_clear(PINE, 6)
00206 
00215 #define SER0_GET_DSR()       bit_is_clear(PINE, 4)
00216 
00217 
00221 #define SER0_SET_RTS()       (PORTB &= ~_BV(4))
00222 
00226 #define SER0_CLR_RTS()       (PORTB |= _BV(4))
00227 
00235 #define SER0_SET_DTR()       (PORTB &= ~_BV(5))
00236 
00244 #define SER0_CLR_DTR()       (PORTB |= _BV(5))
00245 
00247 
00249 
00250 #endif // ifdef ..._H_INCLUDED
00251