working pwm

This commit is contained in:
IMback
2017-05-16 10:37:01 +02:00
parent e2e53267c6
commit cb779f21d4
4 changed files with 115 additions and 147 deletions

20
pwm.h
View File

@ -3,7 +3,7 @@
#include <avr/io.h>
class Pwm16b
class Pwm16b //TC1 pwm on PB1 & PB2
{
public:
Pwm16b();
@ -13,4 +13,22 @@ public:
void on();
};
class Pwm8b
{
private:
volatile unsigned char *_timerControlRegisterA; //TCCRxA
volatile unsigned char *_timerControlRegisterB; //TCCRxB
volatile unsigned char *_compareRegisterA; //OCRxA
volatile unsigned char *_compareRegisterB; //OCRxB
uint8_t _speed = 0b00000011;
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, const uint8_t dutyA = 0, const uint8_t dutyB = 0 );
~Pwm8b();
void setDutyA(const uint8_t duty);
void setDutyB(const uint8_t duty);
void off();
void on();
};
#endif