int main (void) { // Insert system clock initialization code here (sysclk_init()). board_init(); sysclk_init(); // Insert application code here, after the board has been initialized. //Initiera delay delay_init(); //Initiera LCD LCDInit(); //Initiera AD-omvandlare adc_setup(); //Starta upp LCD setupLCD(); //Initiera interupt configure_tc(); int delay_time = 200000; /* variable determining the length of a delay */ PIOB_init(27); for (;;) /* repeat blink in infinity */ { letterS(delay_time); paus(delay_time * 3); letterO(delay_time); paus(delay_time * 3); letterS(delay_time); paus(delay_time * 5); clearDisplay(); delay(delay_time); printNumber(result); } return 0; }
int main(void) { setupLCD(); //Fix rfid setup while(1) { //transportMode(); } }
main(int argc, char *argv[]) { int n; int rows, cols; int drawButtons; char *btn_font, *disp_font; /* GtkWidget *main_w; */ GtkWidget *vbox; GtkWidget *menu; GtkWidget *mdisp; GtkWidget *lcd; GtkWidget *btns; GdkFont *new_font; GtkStyle *default_style, *new_style; GdkBitmap *icon_bitmap; #ifdef USE_GNOME GnomeAppBar *appbar; #endif setlocale(LC_ALL, "C"); #ifdef USE_GNOME gnome_init("grpn", "1.0", argc, argv); gnome_app_new("grpn", "grpn"); #else /* initialize gtk */ gtk_init(&argc, &argv); #endif /* initial values */ drawButtons = 1; rows = 8; cols = 30; btn_font = disp_font = NULL; /* process command line args */ n = 1; while(n < argc){ if(0 == strcmp("-fn", argv[n])){ n++; if(n >= argc){ usage("Missing required argument for -fn."); exit(0); } btn_font = disp_font = argv[n]; } else if(0 == strcmp("-btn-fn", argv[n])){ n++; if(n >= argc){ usage("Missing required argument for -btn-fn."); exit(0); } btn_font = argv[n]; } else if(0 == strcmp("-disp-fn", argv[n])){ n++; if(n >= argc){ usage("Missing required argument for -disp-fn."); exit(0); } disp_font = argv[n]; } else if(0 == strcmp("-rows", argv[n])){ n++; if(n >= argc){ usage("Missing required argument for -rows."); exit(0); } if(1 != sscanf(argv[n], "%d", &rows)){ usage("Unable to read number or rows."); exit(0); } } else if(0 == strcmp("-cols", argv[n])){ n++; if(n >= argc){ usage("Missing required argument for -cols."); exit(0); } if(1 != sscanf(argv[n], "%d", &cols)){ usage("Unable to read number or cols."); exit(0); } } else if(0 == strcmp("-b", argv[n])){ drawButtons = 0; } else if(0 == strcmp("-bm", argv[n])){ n++; if(n >= argc){ usage("Missing required argument for -m."); exit(0); } if (0 == strcmp("dec", argv[n])){ setBaseMode(DECIMAL); } else if (0 == strcmp("eng", argv[n])){ setBaseMode(DECIMAL_ENG); } else if (0 == strcmp("bin", argv[n])){ setBaseMode(BINARY); } else if (0 == strcmp("oct", argv[n])){ setBaseMode(OCTAL); } else if (0 == strcmp("hex", argv[n])){ setBaseMode(HEXADECIMAL); } else { usage("Specify dec, eng, bin, oct or hex for -m."); exit(0); } } else { usage("Unknown Argument."); exit(0); } n++; } /* set up any constants we may use */ setup_constant(); /* initialize the undo system */ initUndoSystem(); /* setup the stack */ if(0 == setup_stack()){ fprintf(stderr, "Error: Could not initalize data structures.\n"); exit(0); } /* set the font if told */ if(btn_font != NULL){ default_style = gtk_widget_get_default_style(); if(NULL == (new_font = gdk_font_load(btn_font))){ fprintf(stderr, "Unable to load font %s.\n", btn_font); exit(0); } new_style = gtk_style_copy(default_style); new_style->font_desc = new_font; /* BDD - No longer in Gtk2.x */ /* gtk_widget_set_default_style(new_style); */ } #ifdef USE_GNOME main_w = gnome_app_new("grpn", "grpn"); setup_menu(main_w); appbar = GNOME_APPBAR(gnome_appbar_new(FALSE, FALSE, FALSE)); gnome_app_set_statusbar(GNOME_APP(main_w), GTK_WIDGET(appbar)); /*create the box that everyone goes in */ vbox = gtk_vbox_new(FALSE, 0); gnome_app_set_contents(GNOME_APP(main_w), vbox); gtk_widget_show(vbox); #else /* the main window contains the work area and the menubar */ main_w = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_widget_set_name(main_w, "grpn"); /*create the box that everyone goes in */ vbox = gtk_vbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(main_w), vbox); gtk_widget_show(vbox); /* set up the menu bar */ menu = setup_menu(vbox); #endif /* handle window manager close */ gtk_signal_connect(GTK_OBJECT(main_w), "delete_event", GTK_SIGNAL_FUNC(delete_event), NULL); gtk_signal_connect(GTK_OBJECT(main_w), "destroy", GTK_SIGNAL_FUNC(destroy), NULL); /* create the varrious subsystems */ mdisp = setupModeDisplay(vbox); if(drawButtons) btns = setupButtons(vbox); lcd = setupLCD(vbox, rows, cols, disp_font); /* Create pixmap of depth 1 (bitmap) for icon */ gtk_widget_realize(main_w); icon_bitmap = gdk_bitmap_create_from_data(main_w->window, icon_bitmap_bits, icon_bitmap_width, icon_bitmap_height); gdk_window_set_icon(main_w->window, NULL, icon_bitmap, NULL); gtk_widget_show(main_w); gtk_main(); }
void updateSenderLCD() { setupLCD(); clear(); sendIntDec(value); }
// Séquence d'initialisation (Attention à l'ordre d'exécution!) void setup(void) { /* Fréquence d'entrée : résonateur XT 10 MHz * Fréquence des cycles d'instructions (FCY) : 40 MIPS */ _PLLPRE = 0; // N1 = 2 _PLLDIV = 32; // M = 32 _PLLPOST = 0; // N2 = 2 /* Setup des pins configurables */ SETUP_PIN_19(); SETUP_PIN_20(); SETUP_PIN_21(); SETUP_PIN_22(); SETUP_PIN_23(); SETUP_PIN_24(); SETUP_PIN_25(); SETUP_PIN_26(); /* Setup des pins de synchro */ SETUP_PIN_9(); SETUP_PIN_8(); SETUP_PIN_3(); SETUP_PIN_2(); SETUP_PIN_1(); SETUP_PIN_44(); SETUP_PIN_43(); SETUP_PIN_42(); // Setup de la LED SETUP_LED(); // Setup du switch SELECT SETUP_SELECT(); /* Setup du PWM */ SETUP_PWM_MODE(); SETUP_PWM_PERIOD(); SETUP_PWM_M1(); SETUP_PWM_M2(); SETUP_BRAKE(); SETUP_DUTY_CYCLE(); SETUP_DEAD_TIME(); ENABLE_PWM; /* Setup de l'interruption principale et du timer associé */ T2CONbits.TON = 0; // Desactive le timer 2 T2CONbits.TGATE = 0; // Desactive le GATE T2CONbits.TSIDL = 0; T2CONbits.TCS = 0; // Utilise l'horloge interne T2CONbits.T32 = 0; // Sélectionne le mode 16 bits T2CONbits.TCKPS = 0b11; // Selectionne l'echelle 1:256 TMR2 = 0x00; // Efface le registre PR2 = 781; // Fixe la frequence a 200Hz ( 40000000 / (F * 256) ) IPC1bits.T2IP = 0x01; // Fixe la priorite IFS0bits.T2IF = 0; // Efface le drapeau de l'interruption IEC0bits.T2IE = 1; // Active l'interruption /* Setup de l'encodeur QE1 */ ADPCFG |= 0x0038; // Configure QEI pins as digital inputs RPINR14bits.QEA1R = 20; // Pin RP20 RPINR14bits.QEB1R = 21; // Pin RP21 QEI1CONbits.QEIM = 0; // Disable QEI Module QEI1CONbits.CNTERR = 0; // Clear any count errors QEI1CONbits.QEISIDL = 0; // Continue operation during sleep QEI1CONbits.SWPAB = 1; // QEA and QEB swapped QEI1CONbits.PCDOUT = 0; // Normal I/O pin operation DFLT1CONbits.CEID = 1; // Count error interrupts disabled DFLT1CONbits.QEOUT = 1; // Digital filters output enabled for QEn pins DFLT1CONbits.QECK = 5; // 1:64 clock divide for digital filter for QEn POS1CNT = 32768; // Remise du compteur a 0 MAX1CNT = 65535; // Valeur max QEI1CONbits.QEIM = 6; // X4 mode with position counter reset by Index /* Setup de l'encodeur QE2 */ RPINR16bits.QEA2R = 25; // Pin RP25 RPINR16bits.QEB2R = 24; // Pin RP24 QEI2CONbits.QEIM = 0; // Disable QEI Module QEI2CONbits.CNTERR = 0; // Clear any count errors QEI2CONbits.QEISIDL = 0; // Continue operation during sleep QEI2CONbits.SWPAB = 0; // QEA and QEB not swapped QEI2CONbits.PCDOUT = 0; // Normal I/O pin operation DFLT2CONbits.CEID = 1; // Count error interrupts disabled DFLT2CONbits.QEOUT = 1; // Digital filters output enabled for QEn pins DFLT2CONbits.QECK = 5; // 1:64 clock divide for digital filter for QEn POS2CNT = 32768; // Remise du compteur a 0 MAX2CNT = 65535; // Valeur max QEI2CONbits.QEIM = 6; // X4 mode with position counter reset by Index // Setup de l'écran setupLCD(); // Setup ADC ADC_ON(); }