This commit is contained in:
IMback 2017-09-14 18:10:46 +02:00
commit dd6f37a960
15 changed files with 1841 additions and 0 deletions

43
pwm.h Normal file
View file

@ -0,0 +1,43 @@
#ifndef PWM_H
#define PWM_H
#include <avr/io.h>
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);
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);
void off();
void on();
};
#endif