#include "output.h"
#include "timer.h"
+#define POLARITY PORTD2
+#define ENABLE PORTD3
+#define BIT(x) (1<<(x))
+
OutputPacket packet;
uint8_t out_bit;
uint8_t out_time;
void output_init()
{
DDRD = (DDRD&0xF3)|0x0C;
- PORTD &= ~0x08;
+ PORTD &= ~BIT(ENABLE);
timer_start_hz(0, 80000, 1);
}
void output_set_power(uint8_t p)
{
if(p==POWER_ON)
- PORTD |= 0x08;
+ PORTD |= BIT(ENABLE);
else
- PORTD &= ~0x08;
+ PORTD &= ~BIT(ENABLE);
}
uint8_t output_command()
++out_bit;
if(out_bit>=packet.length)
{
- PORTD &= ~0x04;
+ PORTD &= ~BIT(POLARITY);
if(packet.repeat_count>1)
{
if(packet.repeat_count<0xFF)
out_data >>= 1;
if(out_data&1)
- PORTD |= 0x04;
+ PORTD |= BIT(POLARITY);
else
- PORTD &= ~0x04;
+ PORTD &= ~BIT(POLARITY);
out_time = packet.bit_duration;
}
out_time = packet.bit_duration;
out_data = packet.data[0];
if(out_data&1)
- PORTD |= 0x04;
+ PORTD |= BIT(POLARITY);
else
- PORTD &= ~0x04;
+ PORTD &= ~BIT(POLARITY);
}
}