char hardware_flashlightIsOn() { if(isOut(LED_PIN) && !isHigh(LED_PIN)) return 1; return 0; }
/** Main program entry point. This routine configures the hardware required by the application, then * enters a loop to run the application tasks in sequence. */ int main(void) { SetupHardware(); setOut(LED_PIN); puts_P(PSTR( "Still Image Host Demo running.\r\n" )); // LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); sei(); uint32_t count = 0; for (;;) { Camera_Task(); USB_USBTask(); if(count++ >= 1000) { count = 0; if(isOut(LED_PIN) && !isHigh(LED_PIN)) { setHigh(LED_PIN); } else { setLow(LED_PIN); } } } }
//This function takes input as which pin to read and returns the corr ADC value char get_adc_data(char mux_num) { char acc_data; //Setting config registers ADMUX = (0b01110000 + mux_num); //ADMUX = _BV(REFS1) | _BV(REFS0) | _BV(ADLAR) | (0<<MUX3) | (0<<MUX3) |(0<<MUX1) |(0<<MUX0); ADCSRA = _BV(ADEN) | (0<<ADSC) | (0<<ADFR) | _BV(ADIE) | (0<<ADPS2) | (0<<ADPS1) | (0<<ADPS0); ADCSRA |= _BV(ADSC); _delay_us(1); while(!(isHigh(ADCSRA,ADIF))); //Wait for conversion to complete //now data is available acc_data = ADCH; ADCSRA |= _BV(ADIF); return (acc_data); }