// initialize Timer and IO pins, needs to be called once void IrWidget::setup(boolean pullup) { #ifdef ARDUINO // configure signal capture ICP pin as input cbi(CAT2(DDR, CAP_PORT), CAP_PIN); if (pullup) sbi(CAT2(PORT, CAP_PORT), CAP_PIN); // enable the internal 10k pull-up resistor #if defined(DEBUG_PIN) && defined(DEBUG_PORT) sbi(CAT2(DDR, DEBUG_PORT), DEBUG_PIN); // configure logic analyzer debug pin as output #endif // init timer, disable power save mode of timer #ifdef PRR0 // for ATmega32U4 and ATmega2560 #if PRTIM <= 2 cbi(PRR0, CAT2(PRTIM, CAP_TIM)); // for ATmega32U4 and ATmega2560 #else cbi(PRR1, CAT2(PRTIM, CAP_TIM)); // for ATmega2560 #endif #else cbi(PRR, CAT2(PRTIM, CAP_TIM)); #endif CAT3(TCCR, CAP_TIM, A) = 0; // Timer mode 0 = normal CAT3(TCCR, CAP_TIM, B) = _BV(CAT2(ICNC, CAP_TIM)) | CAPTURE_PRESCALER_SETTING; // prescaler according to setting, enable noise canceler #else std::cout << "pinMode(CAPTURE_PIN_1, " << (pullup ? "INPUT_PULLUP)" : "INPUT)") << std::endl; #endif }
static byte_t usb_tx_state; // TX_STATE_*, see enum above static byte_t usb_tx_total; // total transmit size static byte_t* usb_tx_data; // pointer to data to transmit static byte_t new_address; // new device address #if defined USBTINY_VENDOR_NAME struct { byte_t length; byte_t type; int string[sizeof(USBTINY_VENDOR_NAME)-1]; } string_vendor PROGMEM = { 2 * sizeof(USBTINY_VENDOR_NAME), DESCRIPTOR_TYPE_STRING, { CAT2(L, USBTINY_VENDOR_NAME) } }; # define VENDOR_NAME_ID 1 #else # define VENDOR_NAME_ID 0 #endif #if defined USBTINY_DEVICE_NAME struct { byte_t length; byte_t type; int string[sizeof(USBTINY_DEVICE_NAME)-1]; } string_device PROGMEM = { 2 * sizeof(USBTINY_DEVICE_NAME),