/*********************************************************************** * * Slave-Flash with Attiny24 * * Description: * A photo-diode registers a flash and counts an internal counter * if the counter reaches the limit an second flash is triggered. * * Ports: * PB3 Reset, active low, 10k to VCC, pushbutton to GND * PB2 Interrupt int0, active high, 1k to Pushbutton, 10k to GND Pulldown * PB1 Clock (Xtal2), UNUSED * PB0 * PA7 * PA6 * PA5 fire * PA4 statusled * PA3 * PA2 * PA1 * PA0 * * power consumption: 0.5mA in normal mode, 2mA when LED lights, 8mA when firing * * Date: 15.7.2011 ***********************************************************************/ #ifndef F_CPU // #warning "F_CPU not defined, is set to 1MHz" #define F_CPU 1000000UL #endif #include #include #include #include #include #include "slaveflash.h" void init(void) { statusledport &= ~(1< 0) if (flashcount == flashesneeded) fire(); sei(); } int main(void) { init(); // Set all Registers and initialise _delay_ms(100); // Wait a 'bit' signal(2); // signal correct startup sei(); // enable interrupts for(;;); // do nothing, everything important is done in the interrupt routines return 0; } void signal(uint8_t counter) { uint8_t i; for(i = 0; i