Exemple #1
0
int
main(void)
{
  wdt_disable();
#ifdef HAS_16MHZ_CLOCK
  /* set clock to 16MHz/2 = 8Mhz */
  clock_prescale_set(clock_div_2);
#endif

//  LED_ON_DDR  |= _BV( LED_ON_PIN );
//  LED_ON_PORT |= _BV( LED_ON_PIN );

  led_init();
  LED_ON();

  spi_init();
 // init_adcw();

  //eeprom_factory_reset("xx");
  eeprom_init();

  // Setup the timers. Are needed for watchdog-reset
  OCR0A  = 249;                            // Timer0: 0.008s = 8MHz/256/250 == 125Hz
  TCCR0B = _BV(CS02);
  TCCR0A = _BV(WGM01);
  TIMSK0 = _BV(OCIE0A);

  TCCR1A = 0;
  TCCR1B = _BV(CS11) | _BV(WGM12);         // Timer1: 1us = 8MHz/8


  MCUSR &= ~(1 << WDRF);                   // Enable the watchdog
  wdt_enable(WDTO_2S);

#ifdef HAS_16MHZ_CLOCK
  uart_init( UART_BAUD_SELECT(UART_BAUD_RATE,F_CPU) );
#else
  uart_init( UART_BAUD_SELECT_DOUBLE_SPEED(UART_BAUD_RATE,F_CPU) );
#endif
  fht_init();
  tx_init();
  input_handle_func = analyze_ttydata;

  display_channel = DISPLAY_USB;

#ifdef HAS_RF_ROUTER
  rf_router_init();
  display_channel |= DISPLAY_RFROUTER;
#endif

  LED_OFF();

  sei();

  for(;;) {
    uart_task();
    RfAnalyze_Task();
    Minute_Task();
#ifdef HAS_FASTRF
    FastRF_Task();
#endif
#ifdef HAS_RF_ROUTER
    rf_router_task();
#endif
#ifdef HAS_ASKSIN
    rf_asksin_task();
#endif
#ifdef HAS_MORITZ
    rf_moritz_task();
#endif
#ifdef HAS_RWE
    rf_rwe_task();
#endif
#ifdef HAS_MBUS
    rf_mbus_task();
#endif
  }

}
Exemple #2
0
int
main(void)
{
  wdt_disable();
  clock_prescale_set(clock_div_1);

  LED_ON_DDR  |= _BV( LED_ON_PIN );
  LED_ON_PORT |= _BV( LED_ON_PIN );

  led_init();
  LED_ON();

  spi_init();

//  eeprom_factory_reset("xx");
  eeprom_init();

// Setup OneWire and make a full search at the beginning (takes some time)
#ifdef HAS_ONEWIRE
  i2c_init();
	onewire_Init();
	onewire_FullSearch();
#endif

  // Setup the timers. Are needed for watchdog-reset
#if defined (HAS_IRRX) || defined (HAS_IRTX)
  ir_init();
  // IR uses highspeed TIMER0 for sampling 
  OCR0A  = 1;                              // Timer0: 0.008s = 8MHz/256/2   == 15625Hz
#else
  OCR0A  = 249;                            // Timer0: 0.008s = 8MHz/256/250 == 125Hz
#endif
  TCCR0B = _BV(CS02);
  TCCR0A = _BV(WGM01);
  TIMSK0 = _BV(OCIE0A);

  TCCR1A = 0;
  TCCR1B = _BV(CS11) | _BV(WGM12);         // Timer1: 1us = 8MHz/8


  MCUSR &= ~(1 << WDRF);                   // Enable the watchdog
  wdt_enable(WDTO_2S);

  uart_init( UART_BAUD_SELECT_DOUBLE_SPEED(UART_BAUD_RATE,F_CPU) );

  fht_init();
  tx_init();
  input_handle_func = analyze_ttydata;

  display_channel = DISPLAY_USB;

#ifdef HAS_RF_ROUTER
  rf_router_init();
  display_channel |= DISPLAY_RFROUTER;
#endif

  checkFrequency(); 
  LED_OFF();

  sei();

  for(;;) {
    uart_task();
    RfAnalyze_Task();
    Minute_Task();
#ifdef HAS_FASTRF
    FastRF_Task();
#endif
#ifdef HAS_RF_ROUTER
    rf_router_task();
#endif
#ifdef HAS_ASKSIN
    rf_asksin_task();
#endif
#ifdef HAS_MORITZ
    rf_moritz_task();
#endif
#ifdef HAS_RWE
    rf_rwe_task();
#endif
#if defined(HAS_IRRX) || defined(HAS_IRTX)
    ir_task();
#endif
#ifdef HAS_MBUS
    rf_mbus_task();
#endif
  }

}
Exemple #3
0
int
main(void)
{
  wdt_disable();

  // un-reset ethernet
  ENC28J60_RESET_DDR  |= _BV( ENC28J60_RESET_BIT );
  ENC28J60_RESET_PORT |= _BV( ENC28J60_RESET_BIT );
  
  led_init();
  LED_ON();

  spi_init();

  eeprom_init();

  // if we had been restarted by watchdog check the REQ BootLoader byte in the
  // EEPROM ...
  if(bit_is_set(MCUSR,WDRF) && eeprom_read_byte(EE_REQBL)) {
    eeprom_write_byte( EE_REQBL, 0 ); // clear flag
// TBD: This is useless as button needs to be pressed - needs moving into bootloader directly
//    start_bootloader();
  }


// Setup OneWire and make a full search at the beginning (takes some time)
#ifdef HAS_ONEWIRE
  i2c_init();
  onewire_Init();
  onewire_FullSearch();
#endif

  // Setup the timers. Are needed for watchdog-reset

#if defined (HAS_IRRX) || defined (HAS_IRTX)
  ir_init();
  // IR uses highspeed TIMER0 for sampling 
  OCR0A  = 1;                              // Timer0: 0.008s = 8MHz/256/2   == 15625Hz
#else
  OCR0A  = 249;                            // Timer0: 0.008s = 8MHz/256/250 == 125Hz
#endif

  TCCR0B = _BV(CS02);
  TCCR0A = _BV(WGM01);
  TIMSK0 = _BV(OCIE0A);

  TCCR1A = 0;
  TCCR1B = _BV(CS11) | _BV(WGM12);         // Timer1: 1us = 8MHz/8

  clock_prescale_set(clock_div_1);

  MCUSR &= ~(1 << WDRF);                   // Enable the watchdog
  wdt_enable(WDTO_2S);

  uart_init( UART_BAUD_SELECT_DOUBLE_SPEED(UART_BAUD_RATE,F_CPU) );

  fht_init();
  tx_init();
  input_handle_func = analyze_ttydata;
#ifdef HAS_RF_ROUTER
  rf_router_init();
  display_channel = (DISPLAY_USB|DISPLAY_RFROUTER);
#else
  display_channel = DISPLAY_USB;
#endif

  ethernet_init();
    
  LED_OFF();

  sei();

  for(;;) {
    uart_task();
    RfAnalyze_Task();
    Minute_Task();
#ifdef HAS_FASTRF
    FastRF_Task();
#endif
#ifdef HAS_RF_ROUTER
    rf_router_task();
#endif
#ifdef HAS_ASKSIN
    rf_asksin_task();
#endif
#ifdef HAS_IRRX
    ir_task();
#endif
#ifdef HAS_ETHERNET
    Ethernet_Task();
#endif
  }

}
Exemple #4
0
//------------------------------------------------------------------------------
/// Application entry point. Configures the DBGU, PIT, TC0, LEDs and buttons
/// and makes LED\#1 blink in its infinite loop, using the Wait function.
/// \return Unused (ANSI-C compatibility).
//------------------------------------------------------------------------------
int main(void)
{


  // DBGU configuration
  TRACE_CONFIGURE(DBGU_STANDARD, 115200, BOARD_MCK);
  TRACE_INFO_WP("\n\r");
  TRACE_INFO("Getting new Started Project --\n\r");
  TRACE_INFO("%s\n\r", BOARD_NAME);
  TRACE_INFO("Compiled: %s %s --\n\r", __DATE__, __TIME__);

  //Configure Reset Controller
  AT91C_BASE_RSTC->RSTC_RMR= 0xa5<<24;

  // Configure EMAC PINS
  PIO_Configure(emacRstPins, PIO_LISTSIZE(emacRstPins));

  // Execute reset
  RSTC_SetExtResetLength(0xd);
  RSTC_ExtReset();

  // Wait for end hardware reset
  while (!RSTC_GetNrstLevel());

  TRACE_INFO("init Flash\n\r");
  flash_init();

  TRACE_INFO("init Timer\n\r");
  // Configure timer 0
  ticks=0;
  extern void ISR_Timer0();
  AT91C_BASE_PMC->PMC_PCER = (1 << AT91C_ID_TC0);
  AT91C_BASE_TC0->TC_CCR = AT91C_TC_CLKDIS;
  AT91C_BASE_TC0->TC_IDR = 0xFFFFFFFF;
  AT91C_BASE_TC0->TC_SR;
  AT91C_BASE_TC0->TC_CMR = AT91C_TC_CLKS_TIMER_DIV5_CLOCK | AT91C_TC_CPCTRG;
  AT91C_BASE_TC0->TC_RC = 375;
  AT91C_BASE_TC0->TC_IER = AT91C_TC_CPCS;
  AIC_ConfigureIT(AT91C_ID_TC0, AT91C_AIC_PRIOR_LOWEST, ISR_Timer0);
  AIC_EnableIT(AT91C_ID_TC0);
  AT91C_BASE_TC0->TC_CCR = AT91C_TC_CLKEN | AT91C_TC_SWTRG;

  // Configure timer 1
  extern void ISR_Timer1();
  AT91C_BASE_PMC->PMC_PCER = (1 << AT91C_ID_TC1);
  AT91C_BASE_TC1->TC_CCR = AT91C_TC_CLKDIS;	//Stop clock
  AT91C_BASE_TC1->TC_IDR = 0xFFFFFFFF;		//Disable Interrupts
  AT91C_BASE_TC1->TC_SR;						//Read Status register
  AT91C_BASE_TC1->TC_CMR = AT91C_TC_CLKS_TIMER_DIV4_CLOCK | AT91C_TC_CPCTRG;  // Timer1: 2,666us = 48MHz/128
  AT91C_BASE_TC1->TC_RC = 0xffff;
  AT91C_BASE_TC1->TC_IER = AT91C_TC_CPCS;
  AIC_ConfigureIT(AT91C_ID_TC1, 1, ISR_Timer1);
  AT91C_BASE_TC1->TC_CCR = AT91C_TC_CLKEN | AT91C_TC_SWTRG;

  led_init();

  TRACE_INFO("init EEprom\n\r");
  eeprom_init();

  rb_reset(&TTY_Rx_Buffer);
  rb_reset(&TTY_Tx_Buffer);

  input_handle_func = analyze_ttydata;

  LED_OFF();
  LED2_OFF();
  LED3_OFF();

  spi_init();
  fht_init();
  tx_init();

  #ifdef HAS_ETHERNET

  ethernet_init();

  #endif

  TRACE_INFO("init USB\n\r");
  CDCDSerialDriver_Initialize();
  USBD_Connect();

  wdt_enable(WDTO_2S);

  fastrf_on=0;

  display_channel = DISPLAY_USB;

  TRACE_INFO("init Complete\n\r");

  checkFrequency();

  // Main loop
  while (1) {

    CDC_Task();
    Minute_Task();
    RfAnalyze_Task();

    #ifdef HAS_FASTRF
      FastRF_Task();
    #endif
    #ifdef HAS_RF_ROUTER
      rf_router_task();
    #endif
    #ifdef HAS_ASKSIN
      rf_asksin_task();
    #endif
    #ifdef HAS_MORITZ
      rf_moritz_task();
    #endif
    #ifdef HAS_RWE
      rf_rwe_task();
    #endif
    #ifdef HAS_MBUS
      rf_mbus_task();
    #endif
    #ifdef HAS_MAICO
      rf_maico_task();
    #endif

    #ifdef HAS_ETHERNET
      Ethernet_Task();
    #endif

#ifdef DBGU_UNIT_IN
    if(DBGU_IsRxReady()){
      unsigned char volatile * const ram = (unsigned char *) AT91C_ISRAM;
      unsigned char x;

      x=DBGU_GetChar();
      switch(x) {

      case 'd':
        puts("USB disconnect\n\r");
        USBD_Disconnect();
        break;
      case 'c':
        USBD_Connect();
        puts("USB Connect\n\r");
        break;
      case 'r':
        //Configure Reset Controller
        AT91C_BASE_RSTC->RSTC_RMR=AT91C_RSTC_URSTEN | 0xa5<<24;
        break;
      case 'S':
        USBD_Disconnect();

        my_delay_ms(250);
        my_delay_ms(250);

        //Reset
        *ram = 0xaa;
        AT91C_BASE_RSTC->RSTC_RCR = AT91C_RSTC_PROCRST | AT91C_RSTC_PERRST | AT91C_RSTC_EXTRST   | 0xA5<<24;
        while (1);
        break;
      default:
        rb_put(&TTY_Tx_Buffer, x);
      }
    }
#endif

    if (USBD_GetState() == USBD_STATE_CONFIGURED) {
      if( USBState == STATE_IDLE ) {
        CDCDSerialDriver_Read(usbBuffer,
                              DATABUFFERSIZE,
                              (TransferCallback) UsbDataReceived,
                              0);
        LED3_ON();
        USBState=STATE_RX;
      }
    }
    if( USBState == STATE_SUSPEND ) {
      TRACE_INFO("suspend  !\n\r");
      USBState = STATE_IDLE;
    }
    if( USBState == STATE_RESUME ) {
      TRACE_INFO("resume !\n\r");
      USBState = STATE_IDLE;
    }

  }
}
Exemple #5
0
int
main(void)
{
  wdt_disable();

#ifdef CSMV4

  LED_ON_DDR  |= _BV( LED_ON_PIN );
  LED_ON_PORT |= _BV( LED_ON_PIN );

#endif

  led_init();
  LED_ON();

  spi_init();

//  eeprom_factory_reset("xx");
  eeprom_init();

//  led_mode = 2;

  // if we had been restarted by watchdog check the REQ BootLoader byte in the
  // EEPROM ...
//  if(bit_is_set(MCUSR,WDRF) && eeprom_read_byte(EE_REQBL)) {
//    eeprom_write_byte( EE_REQBL, 0 ); // clear flag
//    start_bootloader();
//  }

  // Setup the timers. Are needed for watchdog-reset
#ifdef HAS_IRRX
  ir_init();
  // IR uses highspeed TIMER0 for sampling
  OCR0A  = 1;                              // Timer0: 0.008s = 8MHz/256/2   == 15625Hz
#else
  OCR0A  = 249;                            // Timer0: 0.008s = 8MHz/256/250 == 125Hz
#endif
  TCCR0B = _BV(CS02);
  TCCR0A = _BV(WGM01);
  TIMSK0 = _BV(OCIE0A);

  TCCR1A = 0;
  TCCR1B = _BV(CS11) | _BV(WGM12);         // Timer1: 1us = 8MHz/8

  clock_prescale_set(clock_div_1);

  MCUSR &= ~(1 << WDRF);                   // Enable the watchdog
  wdt_enable(WDTO_2S);

  uart_init( UART_BAUD_SELECT_DOUBLE_SPEED(UART_BAUD_RATE,F_CPU) );

#ifdef HAS_DOGM
  dogm_init();
#endif

  fht_init();
  tx_init();
  input_handle_func = analyze_ttydata;

  display_channel = DISPLAY_USB;

#ifdef HAS_RF_ROUTER
  rf_router_init();
  display_channel |= DISPLAY_RFROUTER;
#endif

#ifdef HAS_DOGM
  display_channel |= DISPLAY_DOGM;
#endif

  LED_OFF();

  sei();

  for(;;) {
    uart_task();
    RfAnalyze_Task();
    Minute_Task();
#ifdef HAS_FASTRF
    FastRF_Task();
#endif
#ifdef HAS_RF_ROUTER
    rf_router_task();
#endif
#ifdef HAS_ASKSIN
    rf_asksin_task();
#endif
#ifdef HAS_MORITZ
    rf_moritz_task();
#endif
#ifdef HAS_IRRX
    ir_task();
#endif
  }

}
Exemple #6
0
int
main(void)
{
  wdt_enable(WDTO_2S);
#if defined(CUL_ARDUINO)
  clock_prescale_set(clock_div_1); 		// for 8MHz clock div schould be 1
#endif

  MARK433_PORT |= _BV( MARK433_BIT ); // Pull 433MHz marker
  MARK915_PORT |= _BV( MARK915_BIT ); // Pull 915MHz marker

  // if we had been restarted by watchdog check the REQ BootLoader byte in the
  // EEPROM ...
  if(bit_is_set(MCUSR,WDRF) && erb(EE_REQBL)) {
    ewb( EE_REQBL, 0 ); // clear flag
    start_bootloader();
  }


  // Setup the timers. Are needed for watchdog-reset
  OCR0A  = 249;                            // Timer0: 0.008s = 8MHz/256/250
  TCCR0B = _BV(CS02);
  TCCR0A = _BV(WGM01);
  TIMSK0 = _BV(OCIE0A);

  TCCR1A = 0;
  TCCR1B = _BV(CS11) | _BV(WGM12);         // Timer1: 1us = 8MHz/8

  MCUSR &= ~(1 << WDRF);                   // Enable the watchdog

  led_init();
  spi_init();
  eeprom_init();
  USB_Init();
  fht_init();
  tx_init();
  input_handle_func = analyze_ttydata;
#ifdef HAS_RF_ROUTER
  rf_router_init();
  display_channel = (DISPLAY_USB|DISPLAY_RFROUTER);
#else
  display_channel = DISPLAY_USB;
#endif

  checkFrequency(); 
  LED_OFF();

  for(;;) {
    USB_USBTask();
    CDC_Task();
    RfAnalyze_Task();
    Minute_Task();
#ifdef HAS_FASTRF
    FastRF_Task();
#endif
#ifdef HAS_RF_ROUTER
    rf_router_task();
#endif
#ifdef HAS_ASKSIN
    rf_asksin_task();
#endif
#ifdef HAS_MORITZ
    rf_moritz_task();
#endif
#ifdef HAS_RWE
    rf_rwe_task();
#endif
#ifdef HAS_RFNATIVE
    native_task();
#endif
#ifdef HAS_KOPP_FC
    kopp_fc_task();
#endif
#ifdef HAS_MBUS
    rf_mbus_task();
#endif
#ifdef HAS_ZWAVE
    rf_zwave_task();
#endif

  }
}
Exemple #7
0
int
main(void)
{
//  wdt_disable();

    clock_prescale_set(clock_div_1);

    MARK433_PORT |= _BV( MARK433_BIT ); // Pull 433MHz marker
    MARK915_PORT |= _BV( MARK915_BIT ); // Pull 915MHz marker

    led_init();

    spi_init();

    // Setup the timers. Are needed for watchdog-reset
    OCR0A  = 249;                            // Timer0: 0.008s = 8MHz/256/250 == 125Hz
    TCCR0B = _BV(CS02);
    TCCR0A = _BV(WGM01);
    TIMSK0 = _BV(OCIE0A);

    TCCR1A = 0;
    TCCR1B = _BV(CS11) | _BV(WGM12);         // Timer1: 1us = 8MHz/8

    //eeprom_factory_reset("xx");
    eeprom_init();

    MCUSR &= ~(1 << WDRF);                   // Enable the watchdog
    wdt_enable(WDTO_2S);

    //uart_init( UART_BAUD_SELECT_DOUBLE_SPEED(UART_BAUD_RATE,F_CPU) );
    uart_init( UART_BAUD_SELECT_DOUBLE_SPEED(UART_BAUD_RATE,F_CPU) );

    fht_init();
    tx_init();
    input_handle_func = analyze_ttydata;

    display_channel = DISPLAY_USB;

#ifdef HAS_RF_ROUTER
    rf_router_init();
    display_channel |= DISPLAY_RFROUTER;
#endif

    checkFrequency();
    sei();

    for(;;) {
        uart_task();
        RfAnalyze_Task();
        Minute_Task();
#ifdef HAS_FASTRF
        FastRF_Task();
#endif
#ifdef HAS_RF_ROUTER
        rf_router_task();
#endif
#ifdef HAS_ASKSIN
        rf_asksin_task();
#endif
#ifdef HAS_MORITZ
        rf_moritz_task();
#endif
#ifdef HAS_RWE
        rf_rwe_task();
#endif
#ifdef HAS_RFNATIVE
        native_task();
#endif
#ifdef HAS_KOPP_FC
        kopp_fc_task();
#endif
#ifdef HAS_MBUS
        rf_mbus_task();
#endif
#ifdef HAS_ZWAVE
        rf_zwave_task();
#endif
    }

}
Exemple #8
0
int
main(void)
{
  wdt_disable();

  led_init();
  LED_ON();

  MARK433_PORT |= _BV( MARK433_BIT );
  MARK915_PORT |= _BV( MARK915_BIT );

  spi_init();

//  eeprom_factory_reset("xx");
  eeprom_init();

//  led_mode = 2;

  // if we had been restarted by watchdog check the REQ BootLoader byte in the
  // EEPROM ...
//  if(bit_is_set(MCUSR,WDRF) && eeprom_read_byte(EE_REQBL)) {
//    eeprom_write_byte( EE_REQBL, 0 ); // clear flag
//    start_bootloader();
//  }

  // Setup the timers. Are needed for watchdog-reset
  OCR0A  = 249;                            // Timer0: 0.008s = 8MHz/256/250 == 125Hz
  TCCR0B = _BV(CS02);
  TCCR0A = _BV(WGM01);
  TIMSK0 = _BV(OCIE0A);

  TCCR1A = 0;
  TCCR1B = _BV(CS11) | _BV(WGM12);         // Timer1: 1us = 8MHz/8

  clock_prescale_set(clock_div_1);

  MCUSR &= ~(1 << WDRF);                   // Enable the watchdog
  wdt_enable(WDTO_2S);

  uart_init( UART_BAUD_SELECT_DOUBLE_SPEED(UART_BAUD_RATE,F_CPU) );

#ifdef HAS_STACKING
  stacking_initialize();

  // make sure i2c is inactive
  DDRC  &= 0xfc;
  PORTC &= 0xfc;

#endif

  fht_init();
  tx_init();
  input_handle_func = analyze_ttydata;

  display_channel = DISPLAY_USB;

#ifdef HAS_RF_ROUTER
  rf_router_init();
  display_channel |= DISPLAY_RFROUTER;
#endif

  LED_OFF();
  checkFrequency(); 

  sei();

  for(;;) {
    uart_task();
    RfAnalyze_Task();
    Minute_Task();
#ifdef HAS_FASTRF
    FastRF_Task();
#endif
#ifdef HAS_RF_ROUTER
    rf_router_task();
#endif
#ifdef HAS_ASKSIN
    rf_asksin_task();
#endif
#ifdef HAS_MORITZ
    rf_moritz_task();
#endif
#ifdef HAS_STACKING
  stacking_task();
#endif
#ifdef HAS_MBUS
    rf_mbus_task();
#endif

  }

}
Exemple #9
0
int
main(void)
{
  wdt_disable();

  // un-reset ethernet
  ENC28J60_RESET_DDR  |= _BV( ENC28J60_RESET_BIT );
  ENC28J60_RESET_PORT |= _BV( ENC28J60_RESET_BIT );

  MARK433_PORT |= _BV( MARK433_BIT ); // Pull 433MHz marker
  MARK915_PORT |= _BV( MARK915_BIT ); // Pull 915MHz marker
  
  led_init();
  LED_ON();

  spi_init();

  eeprom_init();
  
  // Reset the "Request Bootloader" flag in EEPROM, to avoid a permanent loop
  eeprom_update_byte( EE_REQBL, 0);

// Setup OneWire and make a full search at the beginning (takes some time)
#ifdef HAS_ONEWIRE
  i2c_init();
  onewire_Init();
  onewire_FullSearch();
#endif

  // Setup the timers. Are needed for watchdog-reset

#if defined (HAS_IRRX) || defined (HAS_IRTX)
  ir_init();
  // IR uses highspeed TIMER0 for sampling 
  OCR0A  = 1;                              // Timer0: 0.008s = 8MHz/256/2   == 15625Hz Fac: 125
#else
  OCR0A  = 249;                            // Timer0: 0.008s = 8MHz/256/250 == 125Hz
#endif

  TCCR0B = _BV(CS02);
  TCCR0A = _BV(WGM01);
  TIMSK0 = _BV(OCIE0A);

  TCCR1A = 0;
  TCCR1B = _BV(CS11) | _BV(WGM12);         // Timer1: 1us = 8MHz/8

  clock_prescale_set(clock_div_1);

  MCUSR &= ~(1 << WDRF);                   // Enable the watchdog
  wdt_enable(WDTO_2S);

  uart_init( UART_BAUD_SELECT_DOUBLE_SPEED(UART_BAUD_RATE,F_CPU) );

  fht_init();
  tx_init();
  input_handle_func = analyze_ttydata;
#ifdef HAS_RF_ROUTER
  rf_router_init();
  display_channel = (DISPLAY_USB|DISPLAY_RFROUTER);
#else
  display_channel = DISPLAY_USB;
#endif

#ifdef HAS_VZ
  vz_init();
#endif

  ethernet_init();
    
  LED_OFF();

#ifdef HAS_DMX
#ifdef DMX_CHANNELS
  dmx_initialize(DMX_CHANNELS);
#else
  dmx_initialize(16);
#endif
#endif

#ifdef HAS_HM485
  hm485_initialize();
#endif

#ifdef HAS_HELIOS
  helios_initialize();
#endif

#ifdef HAS_CUNOTTY
rf_cunotty_init();
#endif

  sei();

#ifdef HAS_DMX
  dmx_start();
#endif

  for(;;) {
    uart_task();
    RfAnalyze_Task();
    Minute_Task();
#ifdef HAS_FASTRF
    FastRF_Task();
#endif
#ifdef HAS_RF_ROUTER
    rf_router_task();
#endif
#ifdef HAS_CUNOTTY
	rf_cunotty_task();
#endif
#ifdef HAS_ASKSIN
    rf_asksin_task();
#endif
#ifdef HAS_IRRX
    ir_task();
#endif
#ifdef HAS_ETHERNET
    Ethernet_Task();
#endif
#ifdef HAS_VZ
    vz_task();
#endif
#ifdef HAS_MORITZ
    rf_moritz_task();
#endif
#ifdef HAS_HM485
    hm485_task();
#endif    
#ifdef HAS_HELIOS
    helios_task();
#endif    
  }

}
Exemple #10
0
int
main(void)
{
  wdt_enable(WDTO_2S); 
  clock_prescale_set(clock_div_1);         // Disable Clock Division

  // if we had been restarted by watchdog check the REQ BootLoader byte in the
  // EEPROM ...
  if (bit_is_set(MCUSR,WDRF) && erb(EE_REQBL)) {
     ewb( EE_REQBL, 0 ); // clear flag
     start_bootloader();
  }

  // Setup the timers. Are needed for watchdog-reset
  OCR0A  = 249;                            // Timer0: 0.008s = 8MHz/256/250
  TCCR0B = _BV(CS02);       
  TCCR0A = _BV(WGM01);
  TIMSK0 = _BV(OCIE0A);

  TCCR1A = 0;
  TCCR1B = _BV(CS11) | _BV(WGM12);         // Timer1: 1us = 8MHz/8

#ifdef CURV3
  // Timer3 is used by the LCD backlight (PWM)
  TCCR3A =  _BV(COM3A1)| _BV(WGM30);       // Fast PWM, 8-bit, clear on match
  TCCR3B =  _BV(WGM32) | _BV(CS31);        // Prescaler 8MHz/8: 3.9KHz 
#endif

  MCUSR &= ~(1 << WDRF);                   // Enable the watchdog

  led_init();
  spi_init();
  eeprom_init();
  USB_Init();
  fht_init();
  tx_init();
  joy_init();                   // lcd init is done manually from menu_init
  bat_init();
  df_init(&df);
  fs_init(&fs, df, 0);          // needs df_init
  rtc_init();                   // does i2c_init too
  log_init();                   // needs fs_init & rtc_init
  menu_init();                  // needs fs_init
  input_handle_func = analyze_ttydata;
  log_enabled = erb(EE_LOGENABLED);
  display_channel = DISPLAY_USB|DISPLAY_LCD|DISPLAY_RFROUTER;
  rf_router_init();

  checkFrequency(); 
  LED_OFF();

  for(;;) {
    USB_USBTask();
    CDC_Task();
    RfAnalyze_Task();
    Minute_Task();
    FastRF_Task();
    rf_router_task();
    JOY_Task();
  }
}
Exemple #11
0
int
main(void)
{

  led_init();

#ifdef LED_RGB
  led_off(LED_CHANNEL_GREEN);
  led_off(LED_CHANNEL_RED);
  led_off(LED_CHANNEL_BLUE);
#else
  LED_ON();
#endif


  spi_init();


  OCR0A  = 249;                            // Timer0: 0.008s = 8MHz/256/250 == 125Hz
  TCCR0B = _BV(CS02);
  TCCR0A = _BV(WGM01);
  TIMSK0 = _BV(OCIE0A);

  TCCR1A = 0;
  TCCR1B = _BV(CS11) | _BV(WGM12);         // Timer1: 1us = 8MHz/8

  clock_prescale_set(clock_div_1);

  MCUSR &= ~(1 << WDRF);                   // Enable the watchdog

  uart_init( UART_BAUD_SELECT_DOUBLE_SPEED(UART_BAUD_RATE,F_CPU) );

  input_handle_func = analyze_ttydata;

  display_channel = DISPLAY_USB;

#ifdef LED_RGB
  my_delay_ms(200);
  led_on(LED_CHANNEL_RED);
  my_delay_ms(200);
  led_off(LED_CHANNEL_RED);
  led_on(LED_CHANNEL_GREEN);
  my_delay_ms(200);
  led_off(LED_CHANNEL_GREEN);
  led_on(LED_CHANNEL_BLUE);
  my_delay_ms(200);
  led_off(LED_CHANNEL_BLUE);
#else
  LED_OFF();
#endif

  sei();

  /* start moritz function */
  moritz_func("Zr\n");
  for(;;) {
	led_process(ticks);

    uart_task();
    Minute_Task();
    rf_asksin_task();
    rf_moritz_task();
    if (rf_moritz_data_available()) {
        DC('Z');
        uint8_t *rf_data = (uint8_t*) &max_data;
        for (uint8_t i=0; i<=*rf_data; i++) {
        	DH2( *rf_data++ );
        }
        DNL();
        DS("length: ");
        DU(max_data.length, 2);
        DNL();
        DS("msg count: ");
        DU(max_data.message_count, 2);
        DNL();
        DS("msg type: ");
        DU(max_data.message_type, 2);
        DNL();
    }
  }

}
Exemple #12
0
int
main(void)
{
  //ewb((uint8_t*)0x80, erb((uint8_t*)0x80)+1);
  wdt_enable(WDTO_2S);                     // Avoid an early reboot
  clock_prescale_set(clock_div_1);         // Disable Clock Division:1->8MHz
#ifdef HAS_XRAM
  init_memory_mapped(); // First initialize the RAM
#endif

  // if we had been restarted by watchdog check the REQ BootLoader byte in the
  // EEPROM
  if(bit_is_set(MCUSR,WDRF) && erb(EE_REQBL)) {
    ewb( EE_REQBL, 0 ); // clear flag
    start_bootloader();
  }
  while(tx_report);                     // reboot if the bss is not initialized

  // Setup the timers. Are needed for watchdog-reset
  OCR0A  = 249;                            // Timer0: 0.008s = 8MHz/256/250
  TCCR0B = _BV(CS02);       
  TCCR0A = _BV(WGM01);
  TIMSK0 = _BV(OCIE0A);

  TCCR1A = 0;
  TCCR1B = _BV(CS11) | _BV(WGM12);         // Timer1: 1us = 8MHz/8

  MCUSR &= ~(1 << WDRF);                   // Enable the watchdog

  led_init();                              // So we can debug 
  spi_init();
  eeprom_init();
  USB_Init();
  fht_init();
  tx_init();
  ethernet_init();
#ifdef HAS_FS
  df_init(&df);
  fs_init(&fs, df, 0);          // needs df_init
  log_init();                   // needs fs_init & rtc_init
  log_enabled = erb(EE_LOGENABLED);
#endif
  input_handle_func = analyze_ttydata;
  display_channel = DISPLAY_USB;

  LED_OFF();

  for(;;) {
    USB_USBTask();
    CDC_Task();
    RfAnalyze_Task();
    Minute_Task();
    FastRF_Task();
    rf_router_task();
#ifdef HAS_ASKSIN
    rf_asksin_task();
#endif
#ifdef HAS_ETHERNET
    Ethernet_Task();
#endif
  }
}