avr-libc  2.0.0
Standard C library for AVR-GCC

AVR Libc Home Page

AVRs

AVR Libc Development Pages

Main Page

User Manual

Library Reference

FAQ

Example Projects

ina90.h
1 /* Copyright (c) 2002,2004 Marek Michalkiewicz
2  All rights reserved.
3 
4  Redistribution and use in source and binary forms, with or without
5  modification, are permitted provided that the following conditions are met:
6 
7  * Redistributions of source code must retain the above copyright
8  notice, this list of conditions and the following disclaimer.
9 
10  * Redistributions in binary form must reproduce the above copyright
11  notice, this list of conditions and the following disclaimer in
12  the documentation and/or other materials provided with the
13  distribution.
14 
15  * Neither the name of the copyright holders nor the names of
16  contributors may be used to endorse or promote products derived
17  from this software without specific prior written permission.
18 
19  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  POSSIBILITY OF SUCH DAMAGE. */
30 
31 /* $Id: ina90_8h_source.html,v 1.1.1.6 2016/02/09 07:13:53 joerg_wunsch Exp $ */
32 /* copied from: Id: avr/ina90.h,v 1.8 2004/11/09 19:16:09 arcanum Exp */
33 
34 /*
35  ina90.h
36 
37  Contributors:
38  Created by Marek Michalkiewicz <marekm@linux.org.pl>
39  */
40 
41 /**
42  \defgroup compat_ina90 <compat/ina90.h>: Compatibility with IAR EWB 3.x
43 
44  \code #include <compat/ina90.h> \endcode
45 
46  This is an attempt to provide some compatibility with
47  header files that come with IAR C, to make porting applications
48  between different compilers easier. No 100% compatibility though.
49 
50  \note For actual documentation, please see the IAR manual.
51  */
52 
53 #ifndef _INA90_H_
54 #define _INA90_H_ 1
55 
56 #define _CLI() do { __asm__ __volatile__ ("cli"); } while (0)
57 #define _SEI() do { __asm__ __volatile__ ("sei"); } while (0)
58 #define _NOP() do { __asm__ __volatile__ ("nop"); } while (0)
59 #define _WDR() do { __asm__ __volatile__ ("wdr"); } while (0)
60 #define _SLEEP() do { __asm__ __volatile__ ("sleep"); } while (0)
61 #define _OPC(op) do { __asm__ __volatile__ (".word %0" : : "n" (op)); } while (0)
62 
63 /* _LPM, _ELPM */
64 #include <avr/pgmspace.h>
65 #define _LPM(x) do { __LPM(x); } while (0)
66 #define _ELPM(x) do { __ELPM(x); } while (0)
67 
68 /* _EEGET, _EEPUT */
69 #include <avr/eeprom.h>
70 
71 #define input(port) (port)
72 #define output(port, val) do { (port) = (val); } while (0)
73 
74 #define __inp_blk__(port, addr, cnt, op) do { \
75  unsigned char __i = (cnt); \
76  unsigned char *__addr = (addr); \
77  while (__i) { \
78  *(__addr op) = input(port); \
79  __i--; \
80  } \
81  } while (0)
82 
83 #define input_block_inc(port, addr, cnt) __inp_blk__(port, addr, cnt, ++)
84 #define input_block_dec(port, addr, cnt) __inp_blk__(port, addr, cnt, --)
85 
86 #define __out_blk__(port, addr, cnt, op) do { \
87  unsigned char __i = (cnt); \
88  const unsigned char *__addr = (addr); \
89  while (__i) { \
90  output(port, *(__addr op)); \
91  __i--; \
92  } \
93  } while (0)
94 
95 #define output_block_inc(port, addr, cnt) __out_blk__(port, addr, cnt, ++)
96 #define output_block_dec(port, addr, cnt) __out_blk__(port, addr, cnt, --)
97 
98 #endif
99