skullc-peripherals/Inc/peripherals_pwm_channel.hpp

47 lines
677 B
C++

/*
* peripherals_pwm.hpp
*
* Created on: Feb 24, 2021
* Author: erki
*/
#ifndef PERIPHERALS_PWM_CHANNEL_HPP_
#define PERIPHERALS_PWM_CHANNEL_HPP_
#include <cstdint>
#include <tim.h>
#include "peripherals_io.hpp"
namespace Peripherals
{
struct PwmChannel
{
TIM_HandleTypeDef* timer;
std::uint32_t channel;
std::uint32_t timer_code;
IO pin;
PwmChannel() = delete;
PwmChannel(TIM_HandleTypeDef* timer,
const std::uint32_t channel,
const std::uint32_t timer_code,
const IO& pin);
void PinToPwm();
void PinToGpio();
void Enable();
void Disable();
void SetCompare(const std::uint32_t compare);
};
}
#endif /* PERIPHERALS_PWM_CHANNEL_HPP_ */