at91_tc.h

Go to the documentation of this file.
00001 
00041 /*
00042  * Copyright (C) 2005-2006 by egnite Software GmbH. All rights reserved.
00043  *
00044  * Redistribution and use in source and binary forms, with or without
00045  * modification, are permitted provided that the following conditions
00046  * are met:
00047  *
00048  * 1. Redistributions of source code must retain the above copyright
00049  *    notice, this list of conditions and the following disclaimer.
00050  * 2. Redistributions in binary form must reproduce the above copyright
00051  *    notice, this list of conditions and the following disclaimer in the
00052  *    documentation and/or other materials provided with the distribution.
00053  * 3. Neither the name of the copyright holders nor the names of
00054  *    contributors may be used to endorse or promote products derived
00055  *    from this software without specific prior written permission.
00056  *
00057  * THIS SOFTWARE IS PROVIDED BY EGNITE SOFTWARE GMBH AND CONTRIBUTORS
00058  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00059  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00060  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL EGNITE
00061  * SOFTWARE GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00062  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00063  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
00064  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
00065  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00066  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
00067  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00068  * SUCH DAMAGE.
00069  *
00070  * For additional information see http://www.ethernut.de/
00071  */
00072 
00073 #ifndef AT91_TC_H
00074 #define AT91_TC_H
00075 
00076 
00080 #define TC_TC0_OFF              0x00000000     
00081 #define TC_TC1_OFF              0x00000040     
00082 #define TC_TC2_OFF              0x00000080     
00083 #define TC0_CCR         (*((reg32_t *)(TC_BASE + TC_TC0_OFF))) 
00084 #define TC1_CCR         (*((reg32_t *)(TC_BASE + TC_TC1_OFF))) 
00085 #define TC2_CCR         (*((reg32_t *)(TC_BASE + TC_TC2_OFF))) 
00086 #define TC_CLKEN                         0      
00087 #define TC_CLKDIS                        1      
00088 #define TC_SWTRG                         2      
00089 
00090 
00093 #define TC_CMR_OFF              0x00000004      
00094 #define TC0_CMR         (*((reg32_t *)(TC_BASE + TC_TC0_OFF + TC_CMR_OFF))) 
00095 #define TC1_CMR         (*((reg32_t *)(TC_BASE + TC_TC1_OFF + TC_CMR_OFF))) 
00096 #define TC2_CMR         (*((reg32_t *)(TC_BASE + TC_TC2_OFF + TC_CMR_OFF))) 
00097 
00098 #define TC_CLKS_MASK            0x00000007      
00099 #define TC_CLKS_MCK2            0x00000000      
00100 #define TC_CLKS_MCK8            0x00000001      
00101 #define TC_CLKS_MCK32           0x00000002      
00102 #define TC_CLKS_MCK128          0x00000003      
00103 #define TC_CLKS_MCK1024         0x00000004      
00104 #define TC_CLKS_XC0             0x00000005      
00105 #define TC_CLKS_XC1             0x00000006      
00106 #define TC_CLKS_XC2             0x00000007      
00107 
00108 #define TC_CLKI                          3      
00109 
00110 #define TC_BURST_MASK           0x00000030      
00111 #define TC_BURST_NONE           0x00000000      
00112 #define TC_BUSRT_XC0            0x00000010      
00113 #define TC_BURST_XC1            0x00000020      
00114 #define TC_BURST_XC2            0x00000030      
00115 
00116 
00117 
00118 #define TC_WAVE                         15      
00119 //To select capture mode you must set TC_WAVE bit to 0.
00120 //#define TC_CAPT                         15      ///< Selects capture mode.
00121 
00125 #define TC_CPCTRG                       14      
00126 #define TC_LDBSTOP                       6      
00127 #define TC_LDBDIS                        7      
00128 
00129 #define TC_ETRGEDG_MASK         0x00000300      
00130 #define TC_ETRGEDG_RISING_EDGE  0x00000100      
00131 #define TC_ETRGEDG_FALLING_EDGE 0x00000200      
00132 #define TC_ETRGEDG_BOTH_EDGE    0x00000300      
00133 
00134 #define TC_ABETRG_MASK          0x00000400      
00135 #define TC_ABETRG_TIOA                  10      
00136 //To use external trigger TIOB you must set TC_ABETRG_TIOA bit to 0.
00137 //#define TC_ABETRG_TIOB                  10      ///< TIOB used as an external trigger.
00138 
00139 
00140 #define TC_LDRA_MASK            0x00030000      
00141 #define TC_LDRA_RISING_EDGE     0x00010000      
00142 #define TC_LDRA_FALLING_EDGE    0x00020000      
00143 #define TC_LDRA_BOTH_EDGE       0x00030000      
00144 
00145 #define TC_LDRB_MASK            0x000C0000      
00146 #define TC_LDRB_RISING_EDGE     0x00040000      
00147 #define TC_LDRB_FALLING_EDGE    0x00080000      
00148 #define TC_LDRB_BOTH_EDGE       0x000C0000      
00149 
00150 
00154 #define TC_CPCSTOP                       6      
00155 #define TC_CPCDIS                        7      
00156 
00157 #define TC_EEVTEDG_MASK         0x00000300      
00158 #define TC_EEVTEDG_RISING_EDGE  0x00000100      
00159 #define TC_EEVTEDG_FALLING_EDGE 0x00000200      
00160 #define TC_EEVTEDG_BOTH_EDGE    0x00000300      
00161 
00162 #define TC_EEVT_MASK            0x00000C00      
00163 #define TC_EEVT_TIOB            0x00000000      
00164 #define TC_EEVT_XC0             0x00000400      
00165 #define TC_EEVT_XC1             0x00000800      
00166 #define TC_EEVT_XC2             0x00000C00      
00167 
00168 #define TC_ENETRG                       12      
00169 
00170 #define TC_WAVSEL_MASK          0x00006000      
00171 #define TC_WAVSEL_UP            0x00000000      
00172 #define TC_WAVSEL_UP_RC_TRG     0x00004000      
00173 #define TC_WAVSEL_UPDOWN        0x00002000      
00174 #define TC_WAVSEL_UPDOWN_RC_TRG 0x00003000      
00175 
00176 
00177 #define TC_ACPA_MASK            0x00030000      
00178 #define TC_ACPA_SET_OUTPUT      0x00010000      
00179 #define TC_ACPA_CLEAR_OUTPUT    0x00020000      
00180 #define TC_ACPA_TOGGLE_OUTPUT   0x00030000      
00181 
00182 #define TC_ACPC_MASK            0x000C0000      
00183 #define TC_ACPC_SET_OUTPUT      0x00040000      
00184 #define TC_ACPC_CLEAR_OUTPUT    0x00080000      
00185 #define TC_ACPC_TOGGLE_OUTPUT   0x000C0000      
00186 
00187 #define TC_AEEVT_MASK           0x00300000      
00188 #define TC_AEEVT_SET_OUTPUT     0x00100000      
00189 #define TC_AEEVT_CLEAR_OUTPUT   0x00200000      
00190 #define TC_AEEVT_TOGGLE_OUTPUT  0x00300000      
00191 
00192 #define TC_ASWTRG_MASK          0x00C00000      
00193 #define TC_ASWTRG_SET_OUTPUT    0x00400000      
00194 #define TC_ASWTRG_CLEAR_OUTPUT  0x00800000      
00195 #define TC_ASWTRG_TOGGLE_OUTPUT 0x00C00000      
00196 
00197 #define TC_BCPB_MASK            0x03000000      
00198 #define TC_BCPB_SET_OUTPUT      0x01000000      
00199 #define TC_BCPB_CLEAR_OUTPUT    0x02000000      
00200 #define TC_BCPB_TOGGLE_OUTPUT   0x03000000      
00201 
00202 #define TC_BCPC_MASK            0x0C000000      
00203 #define TC_BCPC_SET_OUTPUT      0x04000000      
00204 #define TC_BCPC_CLEAR_OUTPUT    0x08000000      
00205 #define TC_BCPC_TOGGLE_OUTPUT   0x0C000000      
00206 
00207 #define TC_BEEVT_MASK           0x30000000      
00208 #define TC_BEEVT_SET_OUTPUT     0x10000000      
00209 #define TC_BEEVT_CLEAR_OUTPUT   0x20000000      
00210 #define TC_BEEVT_TOGGLE_OUTPUT  0x30000000      
00211 
00212 #define TC_BSWTRG_MASK          0xC0000000      
00213 #define TC_BSWTRG_SET_OUTPUT    0x40000000      
00214 #define TC_BSWTRG_CLEAR_OUTPUT  0x80000000      
00215 #define TC_BSWTRG_TOGGLE_OUTPUT 0xC0000000      
00216 
00217 
00220 #define TC_CV_OFF               0x00000010      
00221 #define TC0_CV          (*((reg32_t *)(TC_BASE + TC_TC0_OFF + TC_CV_OFF))) 
00222 #define TC1_CV          (*((reg32_t *)(TC_BASE + TC_TC1_OFF + TC_CV_OFF))) 
00223 #define TC2_CV          (*((reg32_t *)(TC_BASE + TC_TC2_OFF + TC_CV_OFF))) 
00224 
00225 
00228 #define TC_RA_OFF               0x00000014      
00229 #define TC0_RA          (*((reg32_t *)(TC_BASE + TC_TC0_OFF + TC_RA_OFF))) 
00230 #define TC1_RA          (*((reg32_t *)(TC_BASE + TC_TC1_OFF + TC_RA_OFF))) 
00231 #define TC2_RA          (*((reg32_t *)(TC_BASE + TC_TC2_OFF + TC_RA_OFF))) 
00232 
00233 
00237 #define TC_RB_OFF               0x00000018      
00238 #define TC0_RB           (*((reg32_t *)(TC_BASE + TC_TC0_OFF + TC_RB_OFF))) 
00239 #define TC1_RB           (*((reg32_t *)(TC_BASE + TC_TC1_OFF + TC_RB_OFF))) 
00240 #define TC2_RB           (*((reg32_t *)(TC_BASE + TC_TC2_OFF + TC_RB_OFF))) 
00241 
00242 
00246 #define TC_RC_OFF               0x0000001C      
00247 #define TC0_RC          (*((reg32_t *)(TC_BASE + TC_TC0_OFF + TC_RC_OFF))) 
00248 #define TC1_RC          (*((reg32_t *)(TC_BASE + TC_TC1_OFF + TC_RC_OFF))) 
00249 #define TC2_RC          (*((reg32_t *)(TC_BASE + TC_TC2_OFF + TC_RC_OFF))) 
00250 
00251 
00252 
00256 #define TC_SR_OFF               0x00000020      
00257 #define TC0_SR          (*((reg32_t *)(TC_BASE + TC_TC0_OFF + TC_SR_OFF))) 
00258 #define TC1_SR          (*((reg32_t *)(TC_BASE + TC_TC1_OFF + TC_SR_OFF))) 
00259 #define TC2_SR          (*((reg32_t *)(TC_BASE + TC_TC2_OFF + TC_SR_OFF))) 
00260 
00261 #define TC_IER_OFF              0x00000024      
00262 #define TC0_IER         (*((reg32_t *)(TC_BASE + TC_TC0_OFF + TC_IER_OFF))) 
00263 #define TC1_IER         (*((reg32_t *)(TC_BASE + TC_TC1_OFF + TC_IER_OFF))) 
00264 #define TC2_IER         (*((reg32_t *)(TC_BASE + TC_TC2_OFF + TC_IER_OFF))) 
00265 
00266 #define TC_IDR_OFF              0x00000028      
00267 #define TC0_IDR        (*((reg32_t *)(TC_BASE + TC_TC0_OFF + TC_IDR_OFF))) 
00268 #define TC1_IDR        (*((reg32_t *)(TC_BASE + TC_TC1_OFF + TC_IDR_OFF))) 
00269 #define TC2_IDR        (*((reg32_t *)(TC_BASE + TC_TC2_OFF + TC_IDR_OFF))) 
00270 
00271 #define TC_IMR_OFF              0x0000002C      
00272 #define TC0_IMR        (*((reg32_t *)(TC_BASE + TC_TC0_OFF + TC_IMR_OFF))) 
00273 #define TC1_IMR        (*((reg32_t *)(TC_BASE + TC_TC1_OFF + TC_IMR_OFF))) 
00274 #define TC2_IMR        (*((reg32_t *)(TC_BASE + TC_TC2_OFF + TC_IMR_OFF))) 
00275 
00276 #define TC_COVFS                         0      
00277 #define TC_LOVRS                         1      
00278 #define TC_CPAS                          2      
00279 #define TC_CPBS                          3      
00280 #define TC_CPCS                          4      
00281 #define TC_LDRAS                         5      
00282 #define TC_LDRBS                         6      
00283 #define TC_ETRGS                         7      
00284 #define TC_CLKSTA                       16      
00285 #define TC_MTIOA                        17      
00286 #define TC_MTIOB                        18      
00287 
00288 
00292 #define TC_BCR_OFF              0x000000C0      
00293 #define TC_BCR         (*((reg32_t *)(TC_BASE + TC_BCR_OFF))) 
00294 #define TC_SYNC                          0      
00295 
00296 
00300 #define TC_BMR_OFF              0x000000C4      
00301 #define TC_BMR         (*((reg32_t *)(TC_BASE + TC_BMR_OFF))) 
00302 #define TC_TC0XC0S              0x00000003      
00303 #define TC_TCLK0XC0             0x00000000      
00304 #define TC_NONEXC0              0x00000001      
00305 #define TC_TIOA1XC0             0x00000002      
00306 #define TC_TIOA2XC0             0x00000003      
00307 
00308 #define TC_TC1XC1S              0x0000000C      
00309 #define TC_TCLK1XC1             0x00000000      
00310 #define TC_NONEXC1              0x00000004      
00311 #define TC_TIOA0XC1             0x00000008      
00312 #define TC_TIOA2XC1             0x0000000C      
00313 
00314 #define TC_TC2XC2S              0x00000030      
00315 #define TC_TCLK2XC2             0x00000000      
00316 #define TC_NONEXC2              0x00000010      
00317 #define TC_TIOA0XC2             0x00000020      
00318 #define TC_TIOA1XC2             0x00000030      
00319 
00320 
00321 #endif /* AT91_TC_H */