Tuer-Schild/Door/Door.cpp

79 lines
1.7 KiB
C++
Raw Normal View History

2014-09-05 01:39:40 +02:00
/*
* Door.cpp
*
* Created: 04.09.2014 22:06:23
* Author: netz
*/
2014-11-16 18:10:00 +01:00
#define F_CPU 20000000
2014-09-05 01:39:40 +02:00
#include <avr/io.h>
#include <util/delay.h>
2014-11-16 18:10:00 +01:00
/*void Init_AIN()
2014-09-05 01:39:40 +02:00
{
// Analog Comparator initialization
// Analog Comparator: On
// The Analog Comparator's positive input is
// connected to the AIN0 pin
// The Analog Comparator's negative input is
// connected to the AIN1 pin
// Analog Comparator Input Capture by Timer/Counter 1: Off
ACSR=(0<<ACD) | (0<<ACBG) | (0<<ACO) | (0<<ACI) | (0<<ACIE) | (0<<ACIC) | (0<<ACIS1) | (0<<ACIS0);
// Digital input buffer on AIN0: Off
// Digital input buffer on AIN1: Off
DIDR=(1<<AIN0D) | (1<<AIN1D);
2014-11-16 18:10:00 +01:00
}*/
2014-09-05 01:39:40 +02:00
2014-11-16 18:10:00 +01:00
/*void Init_Output()
2014-09-05 01:39:40 +02:00
{
DDRB |= (1<<PINB2);
DDRD |= (1<<PIND5);
2014-11-16 18:10:00 +01:00
}*/
2014-09-05 01:39:40 +02:00
2014-11-16 18:10:00 +01:00
/*void Init_Timer()
2014-09-05 01:39:40 +02:00
{
// Timer/Counter 0 initialization
// Clock source: System Clock
// Clock value: 8000,000 kHz
// Mode: Phase correct PWM top=0xFF
// OC0A output: Non-Inverted PWM
// OC0B output: Inverted PWM
// Timer Period: 0,06375 ms
// Output Pulse(s):
// OC0A Period: 0,06375 ms Width: 0,25 us
// OC0B Period: 0,06375 ms Width: 0,06325 ms
TCCR0A=(1<<COM0A1) | (0<<COM0A0) | (1<<COM0B1) | (1<<COM0B0) | (0<<WGM01) | (1<<WGM00);
TCCR0B=(0<<WGM02) | (0<<CS02) | (0<<CS01) | (1<<CS00);
TCNT0=0x00;
OCR0A=0x00;
OCR0B=0x00;
2014-11-16 18:10:00 +01:00
}*/
2014-09-05 01:39:40 +02:00
int main(void)
{
2014-11-16 18:10:00 +01:00
//Init_AIN();
//Init_Output();
//Init_Timer();
DDRB |= (1<<PINB0) | (1<<PINB1);
PORTB |= (1<<PINB0);
2014-09-05 01:39:40 +02:00
while(1)
{
2014-11-16 18:10:00 +01:00
PORTB ^= (1<<PINB0);
PORTB ^= (1<<PINB1);
_delay_ms(500);
/*if(ACSR & (1<<ACO)) {
2014-09-05 01:39:40 +02:00
if(OCR0A != 0) {
OCR0A--;
OCR0B--;
_delay_ms(1);
}
} else {
if(OCR0A != 0xFF) {
OCR0A++;
OCR0B++;
_delay_ms(6);
}
2014-11-16 18:10:00 +01:00
}*/
2014-09-05 01:39:40 +02:00
}
}