command interpreter and epprom

This commit is contained in:
IMback
2017-05-19 09:48:19 +02:00
parent cb779f21d4
commit ecd7ad677b
9 changed files with 282 additions and 58 deletions

23
pwm.cpp
View File

@ -39,37 +39,40 @@ Pwm16b::~Pwm16b()
Pwm8b::Pwm8b( volatile unsigned char *timerControlRegisterA, volatile unsigned char *timerControlRegisterB, volatile unsigned char *compareRegisterA, volatile unsigned char *compareRegisterB, const uint8_t speed, const bool enableA, const bool enableB, const uint8_t dutyA, const uint8_t dutyB)
{
_timerControlRegisterA = timerControlRegisterA;
_timerControlRegisterB = timerControlRegisterB;
_compareRegisterA = compareRegisterA;
_compareRegisterB = compareRegisterB;
_speed=speed;
_enableA =enableA;
_enableB =enableB;
*_timerControlRegisterA = 0x00;
off();
*timerControlRegisterB = 0x00;
//off();
//fast 8 bit PWM pwm A
if(enableA) *_timerControlRegisterA|= (1<<COM0A1);
if(enableB) *_timerControlRegisterA|= (1<<COM0B1);
if(_enableA) *_timerControlRegisterA|= (1<<COM0A1);
if(_enableB) *_timerControlRegisterA|= (1<<COM0B1);
*_timerControlRegisterA|= (1<<WGM01) | (1<<WGM00);
*timerControlRegisterB |= 0b00000111 & speed;
*_compareRegisterA = 0; //0% pwm to start0
*_compareRegisterB = 0; //0% pwm to start0
on();
//on();
}
void Pwm8b::off()
{
*_timerControlRegisterB = 0x00;
*_timerControlRegisterA &= 0b00000011;
}
void Pwm8b::on()
{
off();
//start with /1024 prescaller
//*_timerControlRegisterB =(1 << CS00) | (1 << CS01);
*_timerControlRegisterB |= _speed;
if(_enableA) *_timerControlRegisterA|= (1<<COM0A1);
if(_enableB) *_timerControlRegisterA|= (1<<COM0B1);
}
void Pwm8b::setDutyA(const uint8_t duty)