00001 /* Copyright (c) 2002, Marek Michalkiewicz 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 are met: 00006 00007 * Redistributions of source code must retain the above copyright 00008 notice, this list of conditions and the following disclaimer. 00009 * Redistributions in binary form must reproduce the above copyright 00010 notice, this list of conditions and the following disclaimer in 00011 the documentation and/or other materials provided with the 00012 distribution. 00013 * Neither the name of the copyright holders nor the names of 00014 contributors may be used to endorse or promote products derived 00015 from this software 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 /* 00030 ina90.h 00031 00032 Contributors: 00033 Created by Marek Michalkiewicz <marekm@linux.org.pl> 00034 */ 00035 00036 /* 00037 ina90.h - this is an attempt to provide some compatibility with 00038 header files that come with IAR C, to make porting applications 00039 between different compilers easier. No 100% compatibility though. 00040 */ 00041 00042 #ifndef _INA90_H_ 00043 #define _INA90_H_ 1 00044 00045 #define _CLI() __asm__ __volatile__ ("cli") 00046 #define _SEI() __asm__ __volatile__ ("sei") 00047 #define _NOP() __asm__ __volatile__ ("nop") 00048 #define _WDR() __asm__ __volatile__ ("wdr") 00049 #define _SLEEP() __asm__ __volatile__ ("sleep") 00050 #define _OPC(op) __asm__ __volatile__ (".word %0" : : "n" (op)) 00051 00052 /* _LPM, _ELPM */ 00053 #include <avr/pgmspace.h> 00054 #define _LPM(x) __LPM(x) 00055 #define _ELPM(x) __ELPM(x) 00056 00057 /* _EEGET, _EEPUT */ 00058 #include <avr/eeprom.h> 00059 00060 #define input(port) inb(port) 00061 #define output(port, val) outb(port, val) 00062 00063 #define __inp_blk__(port, addr, cnt, op) { \ 00064 unsigned char __i = (cnt); \ 00065 unsigned char *__addr = (addr); \ 00066 while (__i) { \ 00067 *(__addr op) = input(port); \ 00068 __i--; \ 00069 } \ 00070 } 00071 00072 #define input_block_inc(port, addr, cnt) __inp_blk__(port, addr, cnt, ++) 00073 #define input_block_dec(port, addr, cnt) __inp_blk__(port, addr, cnt, --) 00074 00075 #define __out_blk__(port, addr, cnt, op) { \ 00076 unsigned char __i = (cnt); \ 00077 const unsigned char *__addr = (addr); \ 00078 while (__i) { \ 00079 output(port, *(__addr op)); \ 00080 __i--; \ 00081 } \ 00082 } 00083 00084 #define output_block_inc(port, addr, cnt, op) __out_blk__(port, addr, cnt, ++) 00085 #define output_block_dec(port, addr, cnt, op) __out_blk__(port, addr, cnt, --) 00086 00087 #endif 00088