mirror of
https://github.com/Theaninova/Arduino-IRremote.git
synced 2025-12-11 08:56:14 +00:00
Add support for ATtiny85
This commit is contained in:
@@ -195,6 +195,10 @@ EXTERN volatile irparams_t irparams;
|
||||
#elif defined(__AVR_ATtiny84__)
|
||||
#define IR_USE_TIMER1
|
||||
|
||||
//ATtiny85
|
||||
#elif defined(__AVR_ATtiny85__)
|
||||
#define IR_USE_TIMER_TINY0 // tx = pin 1
|
||||
|
||||
// Arduino Duemilanove, Diecimila, LilyPad, Mini, Fio, Nano, etc
|
||||
#else
|
||||
//#define IR_USE_TIMER1 // tx = pin 9
|
||||
@@ -551,7 +555,39 @@ EXTERN volatile irparams_t irparams;
|
||||
})
|
||||
#define TIMER_PWM_PIN 16
|
||||
|
||||
// defines for timer_tiny0 (8 bits)
|
||||
#elif defined(IR_USE_TIMER_TINY0)
|
||||
#define TIMER_RESET
|
||||
#define TIMER_ENABLE_PWM (TCCR0A |= _BV(COM0B1))
|
||||
#define TIMER_DISABLE_PWM (TCCR0A &= ~(_BV(COM0B1)))
|
||||
#define TIMER_ENABLE_INTR (TIMSK |= _BV(OCIE0A))
|
||||
#define TIMER_DISABLE_INTR (TIMSK &= ~(_BV(OCIE0A)))
|
||||
#define TIMER_INTR_NAME TIMER0_COMPA_vect
|
||||
#define TIMER_CONFIG_KHZ(val) ({ \
|
||||
const uint8_t pwmval = SYSCLOCK / 2000 / (val); \
|
||||
TCCR0A = _BV(WGM00); \
|
||||
TCCR0B = _BV(WGM02) | _BV(CS00); \
|
||||
OCR0A = pwmval; \
|
||||
OCR0B = pwmval / 3; \
|
||||
})
|
||||
#define TIMER_COUNT_TOP (SYSCLOCK * USECPERTICK / 1000000)
|
||||
#if (TIMER_COUNT_TOP < 256)
|
||||
#define TIMER_CONFIG_NORMAL() ({ \
|
||||
TCCR0A = _BV(WGM01); \
|
||||
TCCR0B = _BV(CS00); \
|
||||
OCR0A = TIMER_COUNT_TOP; \
|
||||
TCNT0 = 0; \
|
||||
})
|
||||
#else
|
||||
#define TIMER_CONFIG_NORMAL() ({ \
|
||||
TCCR0A = _BV(WGM01); \
|
||||
TCCR0B = _BV(CS01); \
|
||||
OCR0A = TIMER_COUNT_TOP / 8; \
|
||||
TCNT0 = 0; \
|
||||
})
|
||||
#endif
|
||||
|
||||
#define TIMER_PWM_PIN 1 /* ATtiny85 */
|
||||
|
||||
//---------------------------------------------------------
|
||||
// Unknown Timer
|
||||
|
||||
@@ -12,14 +12,11 @@ IRsend irsend;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(9600);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
if (Serial.read() != -1) {
|
||||
for (int i = 0; i < 3; i++) {
|
||||
irsend.sendSony(0xa90, 12); // Sony TV power code
|
||||
delay(40);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user