55 lines
1.0 KiB
C++
55 lines
1.0 KiB
C++
/*
|
|
* peripherals_motors.hpp
|
|
*
|
|
* Created on: Feb 24, 2021
|
|
* Author: erki
|
|
*/
|
|
|
|
#ifndef PERIPHERALS_MOTORS_HPP_
|
|
#define PERIPHERALS_MOTORS_HPP_
|
|
|
|
#include "peripherals_io.hpp"
|
|
|
|
#include <tim.h>
|
|
|
|
#include "peripherals_pwm_channel.hpp"
|
|
|
|
namespace Peripherals
|
|
{
|
|
|
|
class IMotors
|
|
{
|
|
public:
|
|
struct TwoChannelMotorData
|
|
{
|
|
PwmChannel forward;
|
|
PwmChannel backward;
|
|
};
|
|
|
|
virtual void Set(const std::int16_t left, const std::int16_t right) = 0;
|
|
virtual void Coast() = 0;
|
|
virtual void Break() = 0;
|
|
virtual void Unbreak() = 0;
|
|
};
|
|
|
|
class DualDrvMotors : public IMotors
|
|
{
|
|
public:
|
|
DualDrvMotors(const IMotors::TwoChannelMotorData& left, const IMotors::TwoChannelMotorData& right, const IO& sleep_pin);
|
|
|
|
virtual void Set(const std::int16_t left, const std::int16_t right) override;
|
|
virtual void Coast() override;
|
|
virtual void Break() override;
|
|
virtual void Unbreak() override;
|
|
|
|
private:
|
|
IMotors::TwoChannelMotorData _left;
|
|
IMotors::TwoChannelMotorData _right;
|
|
IO _sleep_pin;
|
|
};
|
|
|
|
}
|
|
|
|
|
|
#endif /* PERIPHERALS_MOTORS_HPP_ */
|