/* ---------- 受光モジュールからの信号 ---------- */
IR_RCV_INT()
{
  if (ctx.state == IDLE) {
    DM_SIG_INT_DISABLE();
    OUTPUT_MODE(DM_SIG_PIN);
    BIT_SET(RE_LED_PIN);
    ctx.state = RECV;
  }
  if (BIT_READ(IR_RCV_PIN) != 0) {
    BIT_SET(DM_SIG_PIN);
  } else {
    BIT_CLR(DM_SIG_PIN);
  }
  ctx.count++;
  if (ctx.count >= 36) {
    ctx.count = 0;
    BIT_SET(DM_SIG_PIN);
    INPUT_MODE(DM_SIG_PIN);
    BIT_CLR(RE_LED_PIN);
    ctx.state = IDLE;
    _delay_us(500);
    DM_SIG_INT_FLG_CLR();
    DM_SIG_INT_ENABLE();
  }
}
Exemple #2
0
	// Get number of the most significant set alarm flag. If no flags are set, 0 is returned.
	uint8_t GetAlarmDigit () const
	{
		if (activeFlags)
		{
			for(uint8_t i = 0; i < 8; i++)
			{
				if (BIT_READ(activeFlags, i))
				{
					return i;
				}
			}
		}
		return 0;
	}
/* ---------- 育成ギアからの信号 ---------- */
DM_SIG_INT()
{
  if (ctx.state == IDLE) {
    IR_RCV_INT_DISABLE();
    BIT_SET(GR_LED_PIN);
    ctx.state = XMIT;
  }
  if (BIT_READ(DM_SIG_PIN) != 0) {
    IR_LED_OFF();
  } else {
    IR_LED_ON();
  }
  ctx.count++;
  if (ctx.count >= 36) {
    ctx.count = 0;
    IR_LED_OFF();
    BIT_CLR(GR_LED_PIN);
    ctx.state = IDLE;
    _delay_us(500);
    IR_RCV_INT_FLG_CLR();
    IR_RCV_INT_ENABLE();
  }
}