Fang-Robotics-MCB
Fang Robotics Team Codebase
Loading...
Searching...
No Matches
pwm.hpp
Go to the documentation of this file.
1/*****************************************************************************/
2/********** !!! WARNING: CODE GENERATED BY TAPROOT. DO NOT EDIT !!! **********/
3/*****************************************************************************/
4
5/*
6 * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington <robomstr@uw.edu>
7 *
8 * This file is part of Taproot.
9 *
10 * Taproot is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation, either version 3 of the License, or
13 * (at your option) any later version.
14 *
15 * Taproot is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with Taproot. If not, see <https://www.gnu.org/licenses/>.
22 */
23
24#ifndef TAPROOT_PWM_HPP_
25#define TAPROOT_PWM_HPP_
26
27#include <cstdint>
28
29#include "tap/util_macros.hpp"
30
31namespace tap
32{
33namespace gpio
34{
42class Pwm
43{
44public:
45
46 static constexpr uint32_t DEFAULT_TIMER1_FREQUENCY = 2000;
47
48 static constexpr uint32_t DEFAULT_TIMER8_FREQUENCY = 2000;
49
50 static constexpr uint32_t DEFAULT_TIMER4_FREQUENCY = 2000;
51
52 static constexpr uint32_t DEFAULT_TIMER10_FREQUENCY = 2000;
53
54 Pwm() = default;
56 mockable ~Pwm() = default;
57
70
78
79 mockable void init();
80
85
93 mockable void write(float duty, Pwm::Pin pin);
94
98 mockable void setTimerFrequency(Timer timer, uint32_t frequency);
99
100 mockable void pause(Timer timer);
101
102 mockable void start(Timer timer);
103
104private:
105 static constexpr int BUZZER_CHANNEL = 1;
106 static constexpr int HEATER_CHANNEL = 2;
107
108 enum Ch
109 {
110 Ch1 = 1,
111 Ch2 = 2,
112 Ch3 = 3,
113 Ch4 = 4,
114 };
115
121 uint16_t timer1CalculatedOverflow;
127 uint16_t timer8CalculatedOverflow;
133 uint16_t timer4CalculatedOverflow;
139 uint16_t timer10CalculatedOverflow;
140}; // class Pwm
141
142} // namespace gpio
143
144} // namespace tap
145
146#endif // TAPROOT_PWM_HPP_
Definition pwm.hpp:43
mockable void pause(Timer timer)
Definition pwm.cpp:182
Timer
Definition pwm.hpp:72
@ TIMER8
Definition pwm.hpp:74
@ TIMER10
Definition pwm.hpp:76
@ TIMER4
Definition pwm.hpp:75
@ TIMER1
Definition pwm.hpp:73
static constexpr uint32_t DEFAULT_TIMER1_FREQUENCY
Definition pwm.hpp:46
mockable void setTimerFrequency(Timer timer, uint32_t frequency)
Definition pwm.cpp:158
mockable void init()
Definition pwm.cpp:37
Pwm()=default
static constexpr uint32_t DEFAULT_TIMER10_FREQUENCY
Definition pwm.hpp:52
mockable void start(Timer timer)
Definition pwm.cpp:205
mockable void writeAllZeros()
Definition pwm.cpp:74
static constexpr uint32_t DEFAULT_TIMER8_FREQUENCY
Definition pwm.hpp:48
Pin
Definition pwm.hpp:59
@ C6
Definition pwm.hpp:65
@ C2
Definition pwm.hpp:61
@ C3
Definition pwm.hpp:62
@ C5
Definition pwm.hpp:64
@ C1
Definition pwm.hpp:60
@ ImuHeater
Definition pwm.hpp:68
@ Buzzer
Definition pwm.hpp:67
@ C4
Definition pwm.hpp:63
@ C7
Definition pwm.hpp:66
mockable void write(float duty, Pwm::Pin pin)
Definition pwm.cpp:89
static constexpr uint32_t DEFAULT_TIMER4_FREQUENCY
Definition pwm.hpp:50
Definition ballistics.cpp:29
#define mockable
Wrap class functions that are not already virtual in this function if you wish to mock them.
Definition util_macros.hpp:38
#define DISALLOW_COPY_AND_ASSIGN(Typename)
Definition util_macros.hpp:27