示例#1
0
void ADXL335::begin()
{
    pinsInit();
    scale = (float)SENSITIVITY*ADC_AMPLITUDE/ADC_REF;
}
示例#2
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;
}
示例#3
0
void smartbusInit(uint32_t sbPeriod, uint8_t sbIdent, uint8_t sbPrio) {
    sbPriority = sbPrio;
    sbID = sbIdent;
    Timer5_Init(&tickTask, sbPriority, sbPeriod);
    pinsInit(&PC6High, &PC7High, sbPriority);
}