Add dacc sam3x register definitions.
[bertos.git] / bertos / cpu / cortex-m3 / io / sam3_dacc.h
1 /**
2  * \file
3  * <!--
4  * This file is part of BeRTOS.
5  *
6  * Bertos is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19  *
20  * As a special exception, you may use this file as part of a free software
21  * library without restriction.  Specifically, if other files instantiate
22  * templates or use macros or inline functions from this file, or you compile
23  * this file and link it with other files to produce an executable, this
24  * file does not by itself cause the resulting executable to be covered by
25  * the GNU General Public License.  This exception does not however
26  * invalidate any other reasons why the executable file might be covered by
27  * the GNU General Public License.
28  *
29  * Copyright 2011 Develer S.r.l. (http://www.develer.com/)
30  *
31  * -->
32  *
33  * \author Daniele Basile <asterix@develer.com>
34  *
35  * SAM3 Digital to Analog to Converter.
36  *
37  * $WIZ$
38  */
39
40
41 #ifndef SAM3_DACC_H
42 #define SAM3_DACC_H
43
44 /** DACC registers base. */
45 #define DACC_BASE               0x400C8000
46
47 /**
48  * DACC control register
49  * \{
50  */
51 #define DACC_CR_OFF              0x00000000     ///< Control register offeset.
52 #define DACC_CR          (*((reg32_t *)(DACC_BASE + DACC_CR_OFF))) ///< Control register address.
53 #define DACC_SWRST                        0      ///< Software reset.
54 /* \} */
55
56 /**
57  * DACC mode register
58  * \{
59  */
60 #define DACC_MR_OFF              0x00000004     ///< Mode register offeset.
61 #define DACC_MR          (*((reg32_t *)(DACC_BASE + DACC_MR_OFF))) ///< Mode register address.
62 #define DACC_TRGEN                        0      ///< Trigger enable.
63 #define DACC_TRGSEL_MASK               0x14      ///< Trigger selection mask.
64 #define DACC_TRGSEL_SHIFT                 1      ///< Trigger selection shift.
65 #define DACC_WORD                         4      ///< Word transfer.
66 #define DACC_SLEEP                        5      ///< Sleep mode.Fast Wake up Mode
67 #define DACC_FASTWKUP                     6      ///< Fast Wake up Mode
68 #define DACC_REFRESH_MASK            0xFF00      ///< Refresh Period mask
69 #define DACC_REFRESH_SHIFT                8      ///< Refresh Period shift
70 #define DACC_USER_SEL_MASK          0x30000      ///< User Channel Selection mask
71 #define DACC_USER_SEL_SHIFT              16      ///< User Channel Selection shift
72 #define DACC_TAG                         20      ///< Tag selection mode
73 #define DACC_MAXS                        21      ///< Max speed mode
74 #define DACC_STARTUP_MASK        0x3F000000      ///< Startup time selection
75 #define DACC_STARTUP_SHIFT               24      ///< Startup time selsection shift
76
77 #define DACC_MR_STARTUP_0                 0      ///< 0 periods of DACClock
78 #define DACC_MR_STARTUP_8                 1      ///< 8 periods of DACClock
79 #define DACC_MR_STARTUP_16                2      ///< 16 periods of of DACClock
80 #define DACC_MR_STARTUP_24                3      ///< 24 periods of of DACClock
81 #define DACC_MR_STARTUP_64                4      ///< 64 periods of of DACClock
82 #define DACC_MR_STARTUP_80                5      ///< 70 periods of of DACClock
83 #define DACC_MR_STARTUP_96                6      ///< 96 periods of of DACClock
84 #define DACC_MR_STARTUP_112               7      ///< 112 periods of of DACClock
85 #define DACC_MR_STARTUP_512               8      ///< 512 periods of DACClock
86 #define DACC_MR_STARTUP_576               9      ///< 576 periods of DACClock
87 #define DACC_MR_STARTUP_640               10     ///< 640 periods of DACClock
88 #define DACC_MR_STARTUP_704               11     ///< 704 periods of DACClock
89 #define DACC_MR_STARTUP_768               12     ///< 768 periods of DACClock
90 #define DACC_MR_STARTUP_832               13     ///< 832 periods of DACClock
91 #define DACC_MR_STARTUP_896               14     ///< 896 periods of DACClock
92 #define DACC_MR_STARTUP_960               15     ///< 960 periods of DACClock
93 #define DACC_MR_STARTUP_1024              16     ///< 1024 periods of DACClock
94 #define DACC_MR_STARTUP_1088              17     ///< 1088 periods of DACClock
95 #define DACC_MR_STARTUP_1152              18     ///< 1152 periods of DACClock
96 #define DACC_MR_STARTUP_1216              19     ///< 1216 periods of DACClock
97 #define DACC_MR_STARTUP_1280              20     ///< 1280 periods of DACClock
98 #define DACC_MR_STARTUP_1344              21     ///< 1344 periods of DACClock
99 #define DACC_MR_STARTUP_1408              22     ///< 1408 periods of DACClock
100 #define DACC_MR_STARTUP_1472              23     ///< 1472 periods of DACClock
101 #define DACC_MR_STARTUP_1536              24     ///< 1536 periods of DACClock
102 #define DACC_MR_STARTUP_1600              25     ///< 1600 periods of DACClock
103 #define DACC_MR_STARTUP_1664              26     ///< 1664 periods of DACClock
104 #define DACC_MR_STARTUP_1728              27     ///< 1728 periods of DACClock
105 #define DACC_MR_STARTUP_1792              28     ///< 1792 periods of DACClock
106 #define DACC_MR_STARTUP_1856              29     ///< 1856 periods of DACClock
107 #define DACC_MR_STARTUP_1920              30     ///< 1920 periods of DACClock
108 #define DACC_MR_STARTUP_1984              31     ///< 1984 periods of DACClock
109 /* \} */
110
111 /**
112  * DACC channel enable register
113  */
114 #define DACC_CHER_OFF             0x00000010     ///< Channel enable register offeset.
115 #define DACC_CHER          (*((reg32_t *)(DACC_BASE + DACC_CHER_OFF))) ///< Channel enable register address.
116
117 /**
118  * DACC channel disable register
119  */
120 #define DACC_CHDR_OFF             0x00000014     ///< Channel disable register offeset.
121 #define DACC_CHDR          (*((reg32_t *)(DACC_BASE + DACC_CHDR_OFF))) ///< Channel  disable register address.
122
123 /**
124  * DACC channel status register
125  */
126 #define DACC_CHSR_OFF             0x00000018     ///< Channel status register offeset.
127 #define DACC_CHSR          (*((reg32_t *)(DACC_BASE + DACC_CHSR_OFF))) ///< Channel  status register address.
128
129 #define DACC_CH0                           0      ///< Channel 0.
130 #define DACC_CH1                           1      ///< Channel 1.
131 /* \} */
132
133 /**
134  * DACC Conversion data register
135  */
136 #define DACC_CDR_OFF             0x00000020     ///< Conversion data register offeset.
137 #define DACC_CDR          (*((reg32_t *)(DACC_BASE + DACC_CDR_OFF))) ///< Conversion data register address.
138
139
140 /**
141  * DACC Interrupt enable register
142  */
143 #define DACC_IER_OFF             0x00000024     ///< Interrupt enable register offeset.
144 #define DACC_IER          (*((reg32_t *)(DACC_BASE + DACC_IER_OFF))) ///< Interrupt enable register address.
145
146 /**
147  * DACC Interrupt disable register
148  */
149 #define DACC_IDR_OFF             0x00000028     ///< Interrupt disable register offeset.
150 #define DACC_IDR          (*((reg32_t *)(DACC_BASE + DACC_IDR_OFF))) ///< Interrupt disable register address.
151
152 /**
153  * DACC Interrupt disable register
154  */
155 #define DACC_IMR_OFF             0x0000002C     ///< Interrupt disable register offeset.
156 #define DACC_IMR          (*((reg32_t *)(DACC_BASE + DACC_IMR_OFF))) ///< Interrupt disable register address.
157
158 /**
159  * DACC Interrupt status register
160  */
161 #define DACC_ISR_OFF             0x00000030    ///< Interrupt disable status offeset.
162 #define DACC_ISR          (*((reg32_t *)(DACC_BASE + DACC_ISR_OFF))) ///< Interrupt status register address.
163
164 #define DACC_TXRDY                        0     ///< Transmit ready interrupt
165 #define DACC_EOC                          1     ///< End of conversion interrupt
166 #define DACC_ENDTX                        2     ///< End of transmit buffer interrupt
167 #define DACC_TXBUFFE                      3     ///< Transmit buffer empty interrupt
168
169
170 #endif /* SAM3_DACC_H */