Nut/OS  5.0.5
API Reference
lpc_tim.h
Go to the documentation of this file.
00001 #ifndef _ARCH_CM3_NXP_MACH_LPC_TIM_H_
00002 #define _ARCH_CM3_NXP_MACH_LPC_TIM_H_
00003 
00004 /*
00005  * Copyright 2011 by egnite GmbH
00006  *
00007  * Redistribution and use in source and binary forms, with or without
00008  * modification, are permitted provided that the following conditions
00009  * are met:
00010  *
00011  * 1. Redistributions of source code must retain the above copyright
00012  *    notice, this list of conditions and the following disclaimer.
00013  * 2. Redistributions in binary form must reproduce the above copyright
00014  *    notice, this list of conditions and the following disclaimer in the
00015  *    documentation and/or other materials provided with the distribution.
00016  * 3. Neither the name of the copyright holders nor the names of
00017  *    contributors may be used to endorse or promote products derived
00018  *    from this software without specific prior written permission.
00019  *
00020  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00021  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00022  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00023  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00024  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00025  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00026  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
00027  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
00028  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00029  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
00030  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00031  * SUCH DAMAGE.
00032  *
00033  * For additional information see http://www.ethernut.de/
00034  */
00035 
00049 
00050 
00053 #define TIM_IR_OFF          0x00000000
00054 
00055 #define TIM_IR_MR0          0x00000001
00056 #define TIM_IR_MR1          0x00000002
00057 #define TIM_IR_MR2          0x00000004
00058 #define TIM_IR_MR3          0x00000008
00059 #define TIM_IR_MR(x)        _BV(x)
00060 #define TIM_IR_CR0          0x00000010
00061 #define TIM_IR_CR1          0x00000020
00062 #define TIM_IR_CR(x)        _BV((x) + 4)
00063 
00067 #define TIM_TCR_OFF         0x00000004
00068 
00069 #define TIM_TCR_ENA         0x00000001
00070 #define TIM_ENABLE          TIM_TCR_ENA
00071 #define TIM_TCR_RST         0x00000002
00072 #define TIM_RESET           TIM_TCR_RST
00073 
00077 #define TIM_TC_OFF          0x00000008
00078 
00082 #define TIM_PR_OFF          0x0000000C
00083 
00087 #define TIM_PC_OFF          0x00000010
00088 
00092 #define TIM_MCR_OFF         0x00000014
00093 #define TIM_MCR_MR0I        0x00000001
00094 #define TIM_MCR_MR0R        0x00000002
00095 #define TIM_MCR_MR0S        0x00000004
00096 #define TIM_MCR_MR1I        0x00000008
00097 #define TIM_MCR_MR1R        0x00000010
00098 #define TIM_MCR_MR1S        0x00000020
00099 #define TIM_MCR_MR2I        0x00000040
00100 #define TIM_MCR_MR2R        0x00000080
00101 #define TIM_MCR_MR2S        0x00000100
00102 #define TIM_MCR_MR3I        0x00000200
00103 #define TIM_MCR_MR3R        0x00000400
00104 #define TIM_MCR_MR3S        0x00000800
00105 
00106 #define TIM_INT_ON_MATCH(x)     _BV((x) * 3)
00107 #define TIM_RESET_ON_MATCH(x)   _BV((x) * 3 + 1)
00108 #define TIM_STOP_ON_MATCH(x)    _BV((x) * 3 + 2)
00109 #define TIM_MCR_CHANNEL_MASK(x) (7 << ((x) * 3))
00110 
00114 #define TIM_MR_OFF(x)       (0x00000018 + ((x) * 4))
00115 
00119 #define TIM_CCR_OFF         0x00000028
00120 #define TIM_CAP_RISING(x)   _BV((x) * 3)
00121 #define TIM_CAP_FALLING(x)  _BV((x) * 3 + 1)
00122 #define TIM_INT_ON_CAP(x)   _BV((x) * 3 + 2)
00123 #define TIM_EDGE_MASK(x)    (3 << ((x) * 3))
00124 #define TIM_CCR_CHANNEL_MASK(x) (7 << ((x) * 3))
00125 
00129 #define TIM_CR_OFF(x)       (0x0000002C + ((x) * 4)
00130 
00134 #define TIM_EMR_OFF         0x0000003C
00135 
00136 #define TIM_EM(x)           _BV(x)
00137 #define TIM_EM_NOTHING      0x0
00138 #define TIM_EM_LOW          0x1
00139 #define TIM_EM_HIGH         0x2
00140 #define TIM_EM_TOGGLE       0x3
00141 #define TIM_EM_SET(x,f)     ((f) << ((x) + 4))
00142 #define TIM_EM_MASK(x)      (3 << ((x) + 4))
00143 
00147 #define TIM_CTCR_OFF        0x00000070
00148 
00149 #define TIM_TIMER_MODE           0
00150 #define TIM_COUNTER_RISING_MODE  1
00151 #define TIM_COUNTER_FALLING_MODE 2
00152 #define TIM_COUNTER_ANY_MODE     3
00153 #define TIM_CTCR_MODE_LSB   0
00154 #define TIM_CTCR_MODE_MSK   0x3
00155 #define TIM_CTCR_INPUT_LSB  2
00156 #define TIM_CTCR_INPUT_MSK  0xC
00157 
00160 #if defined(LPC_TIM0_BASE)
00161 #define TIM0IR    (LPC_TIM0_BASE + TIM_IR_OFF)
00162 #define TIM0TCR   (LPC_TIM0_BASE + TIM_TCR_OFF)
00163 #define TIM0TC    (LPC_TIM0_BASE + TIM_TC_OFF)
00164 #define TIM0PR    (LPC_TIM0_BASE + TIM_PR_OFF)
00165 #define TIM0PC    (LPC_TIM0_BASE + TIM_PC_OFF)
00166 #define TIM0MCR   (LPC_TIM0_BASE + TIM_MCR_OFF)
00167 #define TIM0MR(x) (LPC_TIM0_BASE + TIM_MR_OFF(x))
00168 #define TIM0CCR   (LPC_TIM0_BASE + TIM_CCR_OFF)
00169 #define TIM0CR(x) (LPC_TIM0_BASE + TIM_CR_OFF(x))
00170 #define TIM0EMR   (LPC_TIM0_BASE + TIM_EMR_OFF)
00171 #define TIM0CTCR  (LPC_TIM0_BASE + TIM_CTCR_OFF)
00172 #endif
00173 
00174 #if defined(LPC_TIM1_BASE)
00175 #define TIM1IR    (LPC_TIM1_BASE + TIM_IR_OFF)
00176 #define TIM1TCR   (LPC_TIM1_BASE + TIM_TCR_OFF)
00177 #define TIM1TC    (LPC_TIM1_BASE + TIM_TC_OFF)
00178 #define TIM1PR    (LPC_TIM1_BASE + TIM_PR_OFF)
00179 #define TIM1PC    (LPC_TIM1_BASE + TIM_PC_OFF)
00180 #define TIM1MCR   (LPC_TIM1_BASE + TIM_MCR_OFF)
00181 #define TIM1MR(x) (LPC_TIM1_BASE + TIM_MR_OFF(x))
00182 #define TIM1CCR   (LPC_TIM1_BASE + TIM_CCR_OFF)
00183 #define TIM1CR(x) (LPC_TIM1_BASE + TIM_CR_OFF(x))
00184 #define TIM1EMR   (LPC_TIM1_BASE + TIM_EMR_OFF)
00185 #define TIM1CTCR  (LPC_TIM1_BASE + TIM_CTCR_OFF)
00186 #endif
00187 
00188 #if defined(LPC_TIM2_BASE)
00189 #define TIM2IR    (LPC_TIM2_BASE + TIM_IR_OFF)
00190 #define TIM2TCR   (LPC_TIM2_BASE + TIM_TCR_OFF)
00191 #define TIM2TC    (LPC_TIM2_BASE + TIM_TC_OFF)
00192 #define TIM2PR    (LPC_TIM2_BASE + TIM_PR_OFF)
00193 #define TIM2PC    (LPC_TIM2_BASE + TIM_PC_OFF)
00194 #define TIM2MCR   (LPC_TIM2_BASE + TIM_MCR_OFF)
00195 #define TIM2MR(x) (LPC_TIM2_BASE + TIM_MR_OFF(x))
00196 #define TIM2CCR   (LPC_TIM2_BASE + TIM_CCR_OFF)
00197 #define TIM2CR(x) (LPC_TIM2_BASE + TIM_CR_OFF(x))
00198 #define TIM2EMR   (LPC_TIM2_BASE + TIM_EMR_OFF)
00199 #define TIM2CTCR  (LPC_TIM2_BASE + TIM_CTCR_OFF)
00200 #endif
00201 
00202 #if defined(LPC_TIM3_BASE)
00203 #define TIM3IR    (LPC_TIM3_BASE + TIM_IR_OFF)
00204 #define TIM3TCR   (LPC_TIM3_BASE + TIM_TCR_OFF)
00205 #define TIM3TC    (LPC_TIM3_BASE + TIM_TC_OFF)
00206 #define TIM3PR    (LPC_TIM3_BASE + TIM_PR_OFF)
00207 #define TIM3PC    (LPC_TIM3_BASE + TIM_PC_OFF)
00208 #define TIM3MCR   (LPC_TIM3_BASE + TIM_MCR_OFF)
00209 #define TIM3MR(x) (LPC_TIM3_BASE + TIM_MR_OFF(x))
00210 #define TIM3CCR   (LPC_TIM3_BASE + TIM_CCR_OFF)
00211 #define TIM3CR(x) (LPC_TIM3_BASE + TIM_CR_OFF(x))
00212 #define TIM3EMR   (LPC_TIM3_BASE + TIM_EMR_OFF)
00213 #define TIM3CTCR  (LPC_TIM3_BASE + TIM_CTCR_OFF)
00214 #endif
00215 
00217 #endif