#ifndef PWM_H #define PWM_H #include class Pwm16b //TC1 pwm on PB1 & PB2 { private: volatile unsigned char *_timerControlRegisterA; //TCCRxA volatile uint16_t *_compareRegisterA; //OCRxA volatile uint16_t *_compareRegisterB; //OCRxB bool _enableA; bool _enableB; public: Pwm16b( volatile unsigned char *timerControlRegisterA, volatile unsigned char *timerControlRegisterB, volatile uint16_t *compareRegisterA, volatile uint16_t *compareRegisterB, volatile uint16_t *inputCaptureRegister, const uint8_t speed = 0b00000011, const bool enableA = true, const bool enableB = true); ~Pwm16b(); void setDutyA(const uint16_t duty); void setDutyB(const uint16_t duty); uint16_t getValueA(); uint16_t getValueB(); bool isOn(); void off(); void on(); }; class Pwm8b { private: volatile unsigned char *_timerControlRegisterA; //TCCRxA volatile unsigned char *_compareRegisterA; //OCRxA volatile unsigned char *_compareRegisterB; //OCRxB bool _enableA; bool _enableB; public: Pwm8b( volatile unsigned char *timerControlRegisterA, volatile unsigned char *timerControlRegisterB, volatile unsigned char *compareRegisterA, volatile unsigned char *compareRegisterB, const uint8_t speed = 0b00000011, const bool enableA = true, const bool enableB = true); ~Pwm8b(); void setDutyA(const uint8_t duty); void setDutyB(const uint8_t duty); uint8_t getValueA(); uint8_t getValueB(); bool isOn(); void off(); void on(); }; #endif