Sistema l'errore da me commesso in fase di conversione...
[bertos.git] / hw / hw_mcp41.h
1 /**
2  * \file
3  * <!--
4  * Copyright 2005 Develer S.r.l. (http://www.develer.com/)
5  * -->
6  *
7  * \version $Id$
8  *
9  * \brief MCP41 hardware-specific definitions
10  *
11  * \version $Id$
12  * \author Francesco Sacchi <batt@develer.com>
13  */
14
15 #ifndef HW_MCP41_H
16 #define HW_MCP41_H
17
18 #include <mcp41_map.h>
19 #include <cfg/compiler.h>
20 #include <cfg/cpu.h>
21 #include <avr/io.h>
22
23 extern const uint16_t mcp41_ports[MCP41_CNT];
24 extern const uint8_t  mcp41_pins[MCP41_CNT];
25
26 /**
27  * Set MCP41 port associated with \a dev to output.
28  */
29 INLINE void SET_MCP41_DDR(Mcp41Dev dev)
30 {
31         /* DDR port is 1 address before PORT */
32         ATOMIC(_SFR_IO8(mcp41_ports[dev] - 1) |= mcp41_pins[dev]);
33 }
34
35 INLINE void MCP41_ON(Mcp41Dev i)
36 {
37         ATOMIC(_SFR_IO8(mcp41_ports[i]) &= ~mcp41_pins[i]);
38 }
39
40 INLINE void MCP41_OFF(Mcp41Dev i)
41 {
42         ATOMIC(_SFR_IO8(mcp41_ports[i]) |= mcp41_pins[i]);
43 }
44
45
46 #endif /* HW_MCP41_H */