Example #1
0
INTERRUPT_HANDLER(radioIrq, EXTI1_vector)
{
  uint8_t status = radio.readStatus ();
  radio.writeRegister (STATUS, status);
  //status &=0xF0;
  if (status&(1 << 6))
  {
     value.previus = value.current;
      radio.writeRegister (STATUS, status);
      value.current = radio.receiveByte ();
      uart1.transmit ("Data received: ");
      uart1.transmit (value.current);
      for (uint8_t i=0;i<5;++i)
      {
        if (value.current& (1 << i))triacs [i]->set();
        else triacs [i]->clear ();
      }
  }
  /*switch (status>>4)
  {
  case 1:
    {
      radio.comm (FLUSH_TX);
      uart1.transmit ("Max number retransmit");
      break;
    }
  case 2:
    {
      uart1.transmit ("Data sent");
      break;
    }
  case 4:
    {
      value.previus = value.current;
      radio.writeRegister (STATUS, status);
      value.current = radio.receiveByte ();
      uart1.transmit ("Data received: ");
      uart1.transmit (value.current);
      for (uint8_t i=0;i<5;++i)
      {
        if (value.current& (1 << i))triacs [i]->set();
        else triacs [i]->clear ();
      }
      break;
    }
  }   */
  
}
Example #2
0
int main() {
    char buf[5] = {'h', 'e', 'l', 'l', 'o'};
    Uart test = Uart(1);
    test.transmit(buf, 5);
    
}
Example #3
0
INTERRUPT_HANDLER(irdaChannel, TIM1_CAPCOM_CC1IF_vector)
{
  static uint8_t i=0;
  if (flag.start&&flag.ready==0)
  {
    falling [i] = TIM1->CCR1H << 8;
    falling [i]|= TIM1->CCR1L;
    ++i;
  }  
  if (!flag.start)
  {
    uint16_t value;
    value = TIM1->CCR1H << 8;
    value |= TIM1->CCR1L;
    if (value>startL&&value<startH) flag.start =1;
  }

  if (i==33) 
  {
    i=0;
    flag.ready = 1;
    disableInterrupts() ;
  }
  irda.clearFlag();
  if (flag.ready)
  {
    c_.full = 0;
    uint32_t v;
    
    for (uint8_t j=0;j<16;++j)
    {
      if (falling [31-j]>bit1)
      {
        v = 1 << j;
        c_.half[1] |= v;
      }
    }
    for (uint8_t j=0;j<16;++j)
    {
      if (falling [16-j]>bit1)
      {
        v = 1 << j;
        c_.half[0] |= v;
      }
    }    
#ifdef CODE
    for (uint8_t i=0;i<4;++i)
    {
      uart0.transmit (c_.quater[i]);
    }
#endif
#ifdef ARRAY
    for (uint8_t i=0;i<32;++i)
    {
      
      uart0.transmit (falling[i]);
    }    
    
#endif
    
    flag.ready = 0;
    flag.start = 0;
  }
}