コード例 #1
0
ファイル: main.c プロジェクト: HashFast/hashfast-uc
int main(void) {
    uint32_t suffix[4];

    /* disable watchdog */
    AVR32_WDT.ctrl = (0x55 << AVR32_WDT_CTRL_KEY_OFFSET);
    AVR32_WDT.ctrl = (0xaa << AVR32_WDT_CTRL_KEY_OFFSET);

    interruptsInit();

    interruptsDisable();

    clocksInit();

    flashEraseAllFuses();

    flashEraseWrite((void *) update_data_start, update_data,
                    update_data_length);

    memset(suffix, 0xff, sizeof(suffix));
    flashEraseWrite((void *) ((uint32_t) _FlashAppStart +
                              (uint32_t) _FlashAppLength -
                              sizeof(suffix)),
                    suffix, sizeof(suffix));

    flashWriteAllFuses(CONFIG_GP_FUSES);

    utilsReboot(0, UTILS_REBOOT_MODE_LOADER);

    return 0; /* not reached */
}
コード例 #2
0
ファイル: main.c プロジェクト: markrosier/UsageDisplay
//*****************************************************************************
//	Function:	Initialise
//	Arguments: 	None
//	Action: 	Program Initialisation
//	Returns: 	None
//*****************************************************************************
void initialise( void )
{
  hardwareInit();
  timerInit();
//  eventHandlerInit();
//  motorControlInit();
//  batteryMonitorInit();
//  soundsInit();
  usageCounterInit();
  interruptsInit();
  configInit();
//    asm("SLEEP");

}
コード例 #3
0
/* ------------------------------------------------------------------------- */
int main(void)
{
  unsigned int i;
  uchar   calibrationValue;

  calibrationValue = eeprom_read_byte(0); /* calibration value from last time */
  if(calibrationValue != 0xff) {
      OSCCAL = calibrationValue;
  }
  //odDebugInit();

  //Production Test Routine - Turn on white LED.
  DDRB |= _BV(PB1);   /* output for LED */

  sbi(PORTB, PB1);
    for(i=0;i<20;i++) {  /* 300 ms disconnect */
        _delay_ms(15);
    }
  cbi(PORTB, PB1);

  //Initialize the USB Connection with the host computer.
  usbDeviceDisconnect();
  for(i=0;i<20;i++){  /* 300 ms disconnect */
      _delay_ms(15);
  }
  usbDeviceConnect();
  
  wdt_enable(WDTO_1S);
 
  pinsInit();
  interruptsInit(); 
  timerInit();
  usbInit();  //Initialize USB comm.
  sei();
  for(;;)
  {    /* main event loop */
    wdt_reset();
    usbPoll();  //Check to see if it's time to send a USB packet
    if (isRecBufBusy && nextDigit==NULL)
    {
#ifndef DECODE
      if (rbcur>rbidx)
        isRecBufBusy = 0; 
      else 
        reportChar(rbuff[rbcur++], 1);
#else
      uchar command;
      command = decodeBuffer();
      if (0!=command)
      {
        if (command!=cmdPrev)
        {
          reportChar(pgm_read_byte(&lookupTable[command & 0b00111111]), 0); // 64 values maximum
          cmdPrev = command;
          cmdCounter = 1;
        }
        else if (++cmdCounter==3)
        {
          cmdCounter = 0;
          cmdPrev = 0;
        }
      }
      isRecBufBusy = 0;
#endif
    }
    if(usbInterruptIsReady() && nextDigit!=NULL)
    { /* we can send another key */
      buildReport();  //Get the next 'key press' to send to the host. 
      usbSetInterrupt(reportBuffer, sizeof(reportBuffer));
      if(*++nextDigit == 0xff)    /* this was terminator character */
        nextDigit = NULL;
    }
  }
 
  return 0;
}