ISR(TIMER0_OVF_vect, ISR_NOBLOCK) // ISR kann unterbrochen werden { static int pos_7seg = 0; //position in 7segment static uint8_t output0 = SEG_X; static uint8_t output1 = SEG_0; static uint8_t output2 = SEG_0; static uint8_t output3 = SEG_X; // set Data if PB3 is high -> register is written on rising edge if ( (PINB & (1<<PINB3)) ) { if (pos_7seg == 0) { BIT_CLEAR(&PORTA, PA2); BIT_SET(&PORTA, PA0); //not reset } if(pos_7seg <= 9) { if( !(output0 & (1<< pos_7seg))) { BIT_SET(&PORTA, PA3); } else { BIT_CLEAR(&PORTA, PA3); } if( !(output1 & (1<< pos_7seg))) { BIT_SET(&PORTA, PA1); } else { BIT_CLEAR(&PORTA, PA1); } if( !(output2 & (1<< pos_7seg))) { BIT_SET(&PORTC, PC0); } else { BIT_CLEAR(&PORTC, PC0); } if( !(output3 & (1<< pos_7seg))) { BIT_SET(&PORTD, PD7); } else { BIT_CLEAR(&PORTD, PD7); } if (pos_7seg == 8 ) { BIT_SET(&PORTA, PA2); //write data to output } if (pos_7seg == 9 ) { BIT_CLEAR(&PORTA, PA0); //reset } pos_7seg ++; } else { pos_7seg = 0; output_set(main_time.minutes_l, &output3); output_set(main_time.minutes_h, &output2); output_set(main_time.hours_l, &output1); output_set(main_time.hours_h, &output0); } } }
static int parse_args_post(int argc, char *argv[]) { DBG("Parsing arguments post state"); optind = 1; for (;;) { char *gostr = "i:o:p:r:R:s:aUb" \ "L:hvVf:"; struct option long_opts[] = { {"input", 1, 0, 'i'}, {"output", 1, 0, 'o'}, {"policy", 1, 0, 'p'}, {"read-interval", 1, 0, 'r'}, {"rate-interval", 1, 0, 'R'}, {"sleep-interval", 1, 0, 's'}, {"show-all", 0, 0, 'a'}, {"use-si", 0, 0, 'U'}, {"use-bit", 0, 0, 'b'}, {"lifetime", 1, 0, 'L'}, {0, 0, 0, 0}, }; int c = getopt_long(argc, argv, gostr, long_opts, NULL); if (c == -1) break; switch (c) { case 'i': if (input_set(optarg)) return 1; break; case 'o': if (output_set(optarg)) return 1; break; case 'p': cfg_setstr(cfg, "policy", optarg); break; case 'r': cfg_setfloat(cfg, "read_interval", strtod(optarg, NULL)); break; case 'R': cfg_setfloat(cfg, "rate_interval", strtod(optarg, NULL)); break; case 's': cfg_setint(cfg, "sleep_time", strtoul(optarg, NULL, 0)); break; case 'a': cfg_setbool(cfg, "show_all", cfg_true); break; case 'U': cfg_setbool(cfg, "use_si", cfg_true); break; case 'b': cfg_setbool(cfg, "use_bit", cfg_true); break; case 'L': cfg_setint(cfg, "lifetime", strtoul(optarg, NULL, 0)); break; case 'f': /* Already handled in pre getopt loop */ break; default: quit("Aborting...\n"); break; } } return 0; }
static void parse_args_post(int argc, char *argv[]) { optind = 1; for (;;) { char *gostr = "i:I:o:O:p:r:R:s:S:P:wadu:U" \ "L:g:hvVf:"; #ifdef HAVE_GETOPT_LONG struct option long_opts[] = { {"input", 1, 0, 'i'}, {"secondary-input", 1, 0, 'I'}, {"output", 1, 0, 'o'}, {"secondary-output", 1, 0, 'O'}, {"policy", 1, 0, 'p'}, {"read-interval", 1, 0, 'r'}, {"rate-interval", 1, 0, 'R'}, {"sleep-interval", 1, 0, 's'}, {"send-signal", 1, 0, 'S'}, {"pidfile", 1, 0, 'P'}, {"wait-for-signal", 0, 0, 'w'}, {"show-all", 0, 0, 'a'}, {"daemon", 0, 0, 'd'}, {"uid", 1, 0, 'u'}, {"use-si", 0, 0, 'U'}, {"lifetime", 1, 0, 'L'}, {"gid", 1, 0, 'g'}, {0, 0, 0, 0}, }; int c = getopt_long(argc, argv, gostr, long_opts, NULL); #else int c = getopt(argc, argv, gostr; #endif if (c == -1) break; switch (c) { case 'i': input_set(optarg); break; case 'I': input_set_secondary(optarg); break; case 'o': output_set(optarg); break; case 'O': output_set_secondary(optarg); break; case 'p': cfg_setstr(cfg, "policy", optarg); break; case 'r': cfg_setfloat(cfg, "read_interval", strtod(optarg, NULL)); break; case 'R': cfg_setfloat(cfg, "rate_interval", strtod(optarg, NULL)); break; case 's': cfg_setint(cfg, "sleep_time", strtoul(optarg, NULL, 0)); break; case 'S': signal_send(optarg); exit(0); case 'w': cfg_setint(cfg, "signal_driven", 1); break; case 'P': cfg_setstr(cfg, "pidfile", optarg); break; case 'a': cfg_setint(cfg, "show_all", 1); break; case 'd': cfg_setbool(cfg, "daemon", cfg_true); break; case 'u': cfg_setstr(cfg, "uid", optarg); break; case 'U': cfg_setbool(cfg, "use_si", cfg_true); break; case 'L': cfg_setint(cfg, "lifetime", strtoul(optarg, NULL, 0)); break; case 'g': cfg_setstr(cfg, "gid", optarg); break; case 'f': /* Already handled in pre getopt loop */ break; default: quit("Aborting...\n"); break; } } }