PX4 Firmware
PX4 Autopilot Software http://px4.io
timer_registers.h
Go to the documentation of this file.
1
/****************************************************************************
2
*
3
* Copyright (C) 2019 PX4 Development Team. All rights reserved.
4
*
5
* Redistribution and use in source and binary forms, with or without
6
* modification, are permitted provided that the following conditions
7
* are met:
8
*
9
* 1. Redistributions of source code must retain the above copyright
10
* notice, this list of conditions and the following disclaimer.
11
* 2. Redistributions in binary form must reproduce the above copyright
12
* notice, this list of conditions and the following disclaimer in
13
* the documentation and/or other materials provided with the
14
* distribution.
15
* 3. Neither the name PX4 nor the names of its contributors may be
16
* used to endorse or promote products derived from this software
17
* without specific prior written permission.
18
*
19
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
22
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
24
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
25
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
26
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
27
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
29
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30
* POSSIBILITY OF SUCH DAMAGE.
31
*
32
****************************************************************************/
33
34
/**
35
* @file timer_registers.h
36
*
37
* Get architecture-specific timer register defines.
38
* Usage:
39
* #define INPUT_TIMER <timer>
40
* #include "timer_registers.h"
41
* # define <xy>_TIMER_BASE TIMER_BASE
42
* # define <xy>_TIMER_CLOCK TIMER_CLOCK
43
* # define <xy>_TIMER_POWER_REG TIMER_CLOCK_POWER_REG
44
* # define <xy>_TIMER_POWER_BIT TIMER_CLOCK_POWER_BIT
45
* # define <xy>_TIMER_VECTOR TIMER_IRQ_REG
46
*
47
*/
48
49
#include <px4_platform_common/px4_config.h>
50
51
#ifndef INPUT_TIMER
52
# error "need to define INPUT_TIMER to use this header"
53
#endif
54
55
#ifdef TIMER_BASE
56
#undef TIMER_BASE
57
#endif
58
#ifdef TIMER_CLOCK_POWER_REG
59
#undef TIMER_CLOCK_POWER_REG
60
#endif
61
#ifdef TIMER_CLOCK_POWER_BIT
62
#undef TIMER_CLOCK_POWER_BIT
63
#endif
64
#ifdef TIMER_CLOCK
65
#undef TIMER_CLOCK
66
#endif
67
#ifdef TIMER_IRQ_REG
68
#undef TIMER_IRQ_REG
69
#endif
70
71
72
73
#if defined(CONFIG_ARCH_CHIP_STM32H7)
74
75
#if INPUT_TIMER == 1
76
# define TIMER_BASE STM32_TIM1_BASE
77
# define TIMER_CLOCK_POWER_REG STM32_RCC_APB2ENR
78
# define TIMER_CLOCK_POWER_BIT RCC_APB2ENR_TIM1EN
79
# define TIMER_IRQ_REG STM32_IRQ_TIMCC
80
# define TIMER_CLOCK STM32_APB2_TIM1_CLKIN
81
#elif INPUT_TIMER == 2
82
# define TIMER_BASE STM32_TIM2_BASE
83
# define TIMER_CLOCK_POWER_REG STM32_RCC_APB1LENR
84
# define TIMER_CLOCK_POWER_BIT RCC_APB1LENR_TIM2EN
85
# define TIMER_IRQ_REG STM32_IRQ_TIM2
86
# define TIMER_CLOCK STM32_APB1_TIM2_CLKIN
87
#elif INPUT_TIMER == 3
88
# define TIMER_BASE STM32_TIM3_BASE
89
# define TIMER_CLOCK_POWER_REG STM32_RCC_APB1LENR
90
# define TIMER_CLOCK_POWER_BIT RCC_APB1LENR_TIM3EN
91
# define TIMER_IRQ_REG STM32_IRQ_TIM3
92
# define TIMER_CLOCK STM32_APB1_TIM3_CLKIN
93
#elif INPUT_TIMER == 4
94
# define TIMER_BASE STM32_TIM4_BASE
95
# define TIMER_CLOCK_POWER_REG STM32_RCC_APB1LENR
96
# define TIMER_CLOCK_POWER_BIT RCC_APB1LENR_TIM4EN
97
# define TIMER_IRQ_REG STM32_IRQ_TIM4
98
# define TIMER_CLOCK STM32_APB1_TIM4_CLKIN
99
#elif INPUT_TIMER == 5
100
# define TIMER_BASE STM32_TIM5_BASE
101
# define TIMER_CLOCK_POWER_REG STM32_RCC_APB1LENR
102
# define TIMER_CLOCK_POWER_BIT RCC_APB1LENR_TIM5EN
103
# define TIMER_IRQ_REG STM32_IRQ_TIM5
104
# define TIMER_CLOCK STM32_APB1_TIM5_CLKIN
105
#elif INPUT_TIMER == 8
106
# define TIMER_BASE STM32_TIM8_BASE
107
# define TIMER_CLOCK_POWER_REG STM32_RCC_APB2ENR
108
# define TIMER_CLOCK_POWER_BIT RCC_APB2ENR_TIM8EN
109
# define TIMER_IRQ_REG STM32_IRQ_TIM8CC
110
# define TIMER_CLOCK STM32_APB2_TIM8_CLKIN
111
#elif INPUT_TIMER == 12
112
# define TIMER_BASE STM32_TIM12_BASE
113
# define TIMER_CLOCK_POWER_REG STM32_RCC_APB1LENR
114
# define TIMER_CLOCK_POWER_BIT RCC_APB1LENR_TIM12EN
115
# define TIMER_IRQ_REG STM32_IRQ_TIM12
116
# define TIMER_CLOCK STM32_APB1_TIM12_CLKIN
117
#else
118
# error INPUT_TIMER must be a value between 1 and 12
119
#endif
120
121
122
#else // F4, F7
123
124
#if INPUT_TIMER == 1
125
# define TIMER_BASE STM32_TIM1_BASE
126
# define TIMER_CLOCK_POWER_REG STM32_RCC_APB2ENR
127
# define TIMER_CLOCK_POWER_BIT RCC_APB2ENR_TIM1EN
128
# define TIMER_IRQ_REG STM32_IRQ_TIM1CC
129
# define TIMER_CLOCK STM32_APB2_TIM1_CLKIN
130
#elif INPUT_TIMER == 2
131
# define TIMER_BASE STM32_TIM2_BASE
132
# define TIMER_CLOCK_POWER_REG STM32_RCC_APB1ENR
133
# define TIMER_CLOCK_POWER_BIT RCC_APB1ENR_TIM2EN
134
# define TIMER_IRQ_REG STM32_IRQ_TIM2
135
# define TIMER_CLOCK STM32_APB1_TIM2_CLKIN
136
#elif INPUT_TIMER == 3
137
# define TIMER_BASE STM32_TIM3_BASE
138
# define TIMER_CLOCK_POWER_REG STM32_RCC_APB1ENR
139
# define TIMER_CLOCK_POWER_BIT RCC_APB1ENR_TIM3EN
140
# define TIMER_IRQ_REG STM32_IRQ_TIM3
141
# define TIMER_CLOCK STM32_APB1_TIM3_CLKIN
142
#elif INPUT_TIMER == 4
143
# define TIMER_BASE STM32_TIM4_BASE
144
# define TIMER_CLOCK_POWER_REG STM32_RCC_APB1ENR
145
# define TIMER_CLOCK_POWER_BIT RCC_APB1ENR_TIM4EN
146
# define TIMER_IRQ_REG STM32_IRQ_TIM4
147
# define TIMER_CLOCK STM32_APB1_TIM4_CLKIN
148
#elif INPUT_TIMER == 5
149
# define TIMER_BASE STM32_TIM5_BASE
150
# define TIMER_CLOCK_POWER_REG STM32_RCC_APB1ENR
151
# define TIMER_CLOCK_POWER_BIT RCC_APB1ENR_TIM5EN
152
# define TIMER_IRQ_REG STM32_IRQ_TIM5
153
# define TIMER_CLOCK STM32_APB1_TIM5_CLKIN
154
#elif INPUT_TIMER == 8
155
# define TIMER_BASE STM32_TIM8_BASE
156
# define TIMER_CLOCK_POWER_REG STM32_RCC_APB2ENR
157
# define TIMER_CLOCK_POWER_BIT RCC_APB2ENR_TIM8EN
158
# define TIMER_IRQ_REG STM32_IRQ_TIM8CC
159
# define TIMER_CLOCK STM32_APB2_TIM8_CLKIN
160
#elif INPUT_TIMER == 9
161
# define TIMER_BASE STM32_TIM9_BASE
162
# define TIMER_CLOCK_POWER_REG STM32_RCC_APB2ENR
163
# define TIMER_CLOCK_POWER_BIT RCC_APB2ENR_TIM9EN
164
# define TIMER_IRQ_REG STM32_IRQ_TIM1BRK
165
# define TIMER_CLOCK STM32_APB2_TIM9_CLKIN
166
#elif INPUT_TIMER == 10
167
# define TIMER_BASE STM32_TIM10_BASE
168
# define TIMER_CLOCK_POWER_REG STM32_RCC_APB2ENR
169
# define TIMER_CLOCK_POWER_BIT RCC_APB2ENR_TIM10EN
170
# define TIMER_IRQ_REG STM32_IRQ_TIM1UP
171
# define TIMER_CLOCK STM32_APB2_TIM10_CLKIN
172
#elif INPUT_TIMER == 11
173
# define TIMER_BASE STM32_TIM11_BASE
174
# define TIMER_CLOCK_POWER_REG STM32_RCC_APB2ENR
175
# define TIMER_CLOCK_POWER_BIT RCC_APB2ENR_TIM11EN
176
# define TIMER_IRQ_REG STM32_IRQ_TIM1TRGCOM
177
# define TIMER_CLOCK STM32_APB2_TIM11_CLKIN
178
#elif INPUT_TIMER == 12
179
# define TIMER_BASE STM32_TIM12_BASE
180
# define TIMER_CLOCK_POWER_REG STM32_RCC_APB1ENR
181
# define TIMER_CLOCK_POWER_BIT RCC_APB1ENR_TIM12EN
182
# define TIMER_IRQ_REG STM32_IRQ_TIM8BRK
183
# define TIMER_CLOCK STM32_APB1_TIM12_CLKIN
184
#else
185
# error INPUT_TIMER must be a value between 1 and 12
186
#endif
187
188
#endif
src
drivers
pwm_input
timer_registers.h
Generated by
1.8.13