示例#1
0
文件: irmp.c 项目: EtherGraf/ethersex
void
irmp_init(void)
{
#ifdef IRMP_RX_SUPPORT
  /* configure TSOP input, disable pullup */
  DDR_CONFIG_IN(IRMP_RX);
  PIN_CLEAR(IRMP_RX);
#endif

#ifdef STATUSLED_IRMP_RX_SUPPORT
  DDR_CONFIG_OUT(STATUSLED_IRMP_RX);
  IRMP_RX_LED_OFF;
#endif

#ifdef STATUSLED_IRMP_TX_SUPPORT
  DDR_CONFIG_OUT(STATUSLED_IRMP_TX);
  IRMP_TX_LED_OFF;
#endif

  /* init timer0/2 to expire after 1000/IRMP_HZ ms */
#ifdef IRMP_USE_TIMER2
  SET_HW_PRESCALER;
  TC2_COUNTER_COMPARE = SW_PRESCALER - 1;
  TC2_COUNTER_CURRENT = 0;
  TC2_INT_COMPARE_ON;           /* enable interrupt */
#else
  SET_HW_PRESCALER;
  TC0_COUNTER_COMPARE = SW_PRESCALER - 1;
  TC0_COUNTER_CURRENT = 0;
  TC0_INT_COMPARE_ON;           /* enable interrupt */
#endif

#ifdef IRMP_TX_SUPPORT
  PIN_CLEAR(IRMP_TX);
  DDR_CONFIG_OUT(IRMP_TX);
#ifndef IRMP_EXTERNAL_MODULATOR
#ifdef IRMP_USE_TIMER2
  TC0_MODE_CTC;
  TC0_PRESCALER_1;
#else
  TC2_MODE_CTC;
  TC2_PRESCALER_1;
#endif
#endif
  irmp_tx_set_freq(IRSND_FREQ_36_KHZ);  /* default frequency */
#endif
}
示例#2
0
文件: irmp.c 项目: shendriks/ethersex
void
irmp_init (void)
{
    /* configure TSOP input, disable pullup */
    DDR_CONFIG_IN (IRMP_RX);
    PIN_CLEAR (IRMP_RX);

#ifdef IRMP_RX_LED
    DDR_CONFIG_OUT (STATUSLED_RX);
    IRMP_RX_LED_OFF;
#endif

    /* init timer0/2 to expire after 1000/IRMP_HZ ms */
#ifdef IRMP_USE_TIMER2
    _TCCR2_PRESCALE = HW_PRESCALER_MASK;
    _OUTPUT_COMPARE_REG2 = SW_PRESCALER - 1;
    _TCNT2 = 0;
    _TIMSK_TIMER2 |= _BV (_OUTPUT_COMPARE_IE2);	/* enable interrupt */
#else
    _TCCR0_PRESCALE = HW_PRESCALER_MASK;
    _OUTPUT_COMPARE_REG0 = SW_PRESCALER - 1;
    _TCNT0 = 0;
    _TIMSK_TIMER0 |= _BV (_OUTPUT_COMPARE_IE0);	/* enable interrupt */
#endif

#ifdef IRSND_SUPPORT
    PIN_CLEAR (IRMP_TX);
    DDR_CONFIG_OUT (IRMP_TX);
#ifdef IRMP_USE_TIMER2
    _TCCR0_PRESCALE = _BV (_WGM01) | _BV (_CS00);	/* CTC mode, 0x01, start Timer 0, no prescaling */
#else
    _TCCR2_PRESCALE = _BV (_WGM21) | _BV (_CS20);	/* CTC mode, 0x01, start Timer 2, no prescaling */
#endif
    irmp_tx_set_freq (IRSND_FREQ_36_KHZ);	/* default frequency */
#endif
}