return v ? 0 : 1;
}
-static
-void init_temperature_sensor(void){
- ADMUX = 0x8F;
- ADCSRA = 0x87;
-}
-
-static
-uint16_t read_temperture_sensor(void){
- ADCSRA |= 0x40;
- while(ADCSRA & 0x40)
- ;
- return ADC;
-}
-
usbMsgLen_t usbFunctionSetup(uchar data[8])
{
usbRequest_t *rq = (usbRequest_t *)data;
uni_buffer.w8[0] = button_get_debounced(25);
usbMsgPtr = uni_buffer.w8;
return 1;
- case CUSTOM_RQ_READ_TMPSENS:
- uni_buffer.w16[0] = read_temperture_sensor();
- usbMsgPtr = uni_buffer.w8;
- return 2;
}
}
DDRB &= ~_BV(BUTTON_PIN); /* make button pin input */
PORTB |= _BV(BUTTON_PIN); /* turn on pull-up resistor */
- init_temperature_sensor();
counter_init();
usbInit();
usbDeviceDisconnect(); /* enforce re-enumeration, do this while interrupts are disabled! */