2 * This file is part of Cleanflight and Betaflight.
4 * Cleanflight and Betaflight are free software. You can redistribute
5 * this software and/or modify this software under the terms of the
6 * GNU General Public License as published by the Free Software
7 * Foundation, either version 3 of the License, or (at your option)
10 * Cleanflight and Betaflight are distributed in the hope that they
11 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
12 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 * See the GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this software.
18 * If not, see <http://www.gnu.org/licenses/>.
23 #include "drivers/io.h"
27 #include "pg/timerio.h"
30 uint8_t timerIndexByTag(ioTag_t ioTag
)
33 for (unsigned i
= 0; i
< MAX_TIMER_PINMAP_COUNT
; i
++) {
34 if (timerIOConfig(i
)->ioTag
== ioTag
) {
35 return timerIOConfig(i
)->index
;
44 const timerHardware_t
*timerGetByTag(ioTag_t ioTag
)
50 uint8_t timerIndex
= timerIndexByTag(ioTag
);
53 for (int i
= 0; i
< (int)USABLE_TIMER_CHANNEL_COUNT
; i
++) {
54 if (timerHardware
[i
].tag
== ioTag
) {
55 if (index
== timerIndex
|| timerIndex
== 0) {
56 return &timerHardware
[i
];
64 ioTag_t
timerioTagGetByUsage(timerUsageFlag_e usageFlag
, uint8_t index
)
66 uint8_t currentIndex
= 0;
67 for (int i
= 0; i
< (int)USABLE_TIMER_CHANNEL_COUNT
; i
++) {
68 if ((timerHardware
[i
].usageFlags
& usageFlag
) == usageFlag
) {
69 if (currentIndex
== index
) {
70 return timerHardware
[i
].tag
;