//main function int main(void) { char key ; //1. system initialazation STARTUP; //2. initialise peripherals init_pioa() ; //3. initially turn led off led_off() ; //4. initialize timer init_tc() ; //5. initialize interrupt controller init_aic() ; tc -> Channel_0.CCR = 0x5; //6. start the timer //7. wait until the user presses 'x' while ( (key = getchar() != 'x')) {} //8. then cleanup peripherals and system clear_aic(); clear_tc() ; led_off() ; //9. turn off led CLEANUP; //and exit return 0 ; }
int main(int ac, char **av) { t_a *t; t = xmalloc(sizeof(*t)); t->nb_line = NB_LINE; t->nb_col = NB_COL; t->turn = 1; t->board = my_strdup(" | ||| ||||| |||||||"); t->head = xmalloc(sizeof(*t->head)); init_tc(t); if (init_board(t)) return (my_putstr(BOR_ERR)); display_board(t); t->term.c_lflag |= ECHO; t->term.c_lflag |= ICANON; xtcset(t); return (0); }
int main(void) { sysclk_init(); init_dbg_rs232(FMCK_HZ); init_gpio(); assign_main_event_handlers(); init_events(); init_tc(); init_spi(); init_adc(); irq_initialize_vectors(); register_interrupts(); cpu_irq_enable(); init_usb_host(); init_monome(); if(flash_is_fresh()) { // nothing has been stored in the flash memory so far // so you need to initialize any variables you store in flash here with appropriate default values } else { // read from flash flash_read(); } clock_pulse = &clock; clock_external = !gpio_get_pin_value(B09); // start timers that track clock, ADCs (including the clock and the param knobs) and the front panel button timer_add(&clockTimer,120,&clockTimer_callback, NULL); timer_add(&keyTimer,50,&keyTimer_callback, NULL); timer_add(&adcTimer,100,&adcTimer_callback, NULL); clock_temp = 10000; // out of ADC range to force tempo // main loop - you probably don't need to do anything here as everything should be done by handlers while (true) { check_events(); } }
//main function int main(void) { char key ; STARTUP; init_pioa() ; init_tc() ; init_aic() ; while ( (key = getchar() != 'e')) {} clear_aic(); clear_tc() ; CLEANUP; //and exit return 0 ; }
// top-level peripheral init static void init_avr32(void) { volatile avr32_tc_t *tc = APP_TC; // clocks // setup clocks sysclk_init(); // not sure why but when need to explictly enable clock for static mem ctlr sysclk_enable_pbb_module(SYSCLK_SMC_REGS); flashc_set_bus_freq(FCPU_HZ); // need this for high-speed operation flashc_set_wait_state(1); /// interrupts // print_dbg("\r\n irq_initialize_vectors() "); irq_initialize_vectors(); // disable all interrupts for now // print_dbg("\r\n cpu_irq_disable() "); cpu_irq_disable(); // serial usb print_dbg("\r\n init_ftdi_usart() "); init_ftdi_usart(); // external sram print_dbg("\r\n smc_init(FHSB_HZ) "); smc_init(FHSB_HZ); // initialize spi1: OLED, ADC, SD/MMC print_dbg("\r\n init_spi1() "); init_spi1(); // initialize PDCA controller print_dbg("\r\n init_local_pdca() "); init_local_pdca(); // initialize blackfin resources print_dbg("\r\n init_bfin_resources() "); init_bfin_resources(); // initialize application timer print_dbg("\r\n init_tc(tc) "); init_tc(tc); // initialize other GPIO print_dbg("\r\n init_gpio() "); init_gpio(); // register interrupts print_dbg("\r\n register_interrupts() "); register_interrupts(); // initialize the OLED screen print_dbg("\r\n init_oled() "); init_oled(); // enable interrupts print_dbg("\r\n cpu_irq_enable() "); cpu_irq_enable(); // usb host controller init_usb_host(); // initialize usb classes print_dbg("\r\n init_monome "); init_monome(); // init_midi(); // init_hid(); }
int main(void) { u8 i1; sysclk_init(); init_dbg_rs232(FMCK_HZ); init_gpio(); assign_main_event_handlers(); init_events(); init_tc(); init_spi(); init_adc(); irq_initialize_vectors(); register_interrupts(); cpu_irq_enable(); init_usb_host(); init_monome(); init_i2c_slave(0x30); print_dbg("\r\n\n// meadowphysics //////////////////////////////// "); print_dbg_ulong(sizeof(flashy)); print_dbg(" "); print_dbg_ulong(sizeof(m)); if(flash_is_fresh()) { print_dbg("\r\nfirst run."); flash_unfresh(); flashc_memset32((void*)&(flashy.preset_select), 0, 4, true); // clear out some reasonable defaults for(i1=0;i1<8;i1++) { m.positions[i1] = i1; m.points[i1] = i1; m.points_save[i1] = i1; m.triggers[i1] = 0; m.trig_dests[i1] = 0; m.rules[i1] = 0; m.rule_dests[i1] = i1; } m.positions[0] = m.points[0] = 3; m.trig_dests[0] = 254; // save all presets, clear glyphs for(i1=0;i1<8;i1++) { flashc_memcpy((void *)&flashy.m[i1], &m, sizeof(m), true); glyph[i1] = (1<<i1); flashc_memcpy((void *)&flashy.glyph[i1], &glyph, sizeof(glyph), true); } } else { // load from flash at startup preset_select = flashy.preset_select; flash_read(); for(i1=0;i1<8;i1++) glyph[i1] = flashy.glyph[preset_select][i1]; } LENGTH = 15; SIZE = 16; re = &refresh; process_ii = &mp_process_ii; clock_pulse = &clock; clock_external = !gpio_get_pin_value(B09); timer_add(&clockTimer,120,&clockTimer_callback, NULL); timer_add(&keyTimer,50,&keyTimer_callback, NULL); timer_add(&adcTimer,100,&adcTimer_callback, NULL); clock_temp = 10000; // out of ADC range to force tempo while (true) { check_events(); } }
int main (int argc, char *argv[]) { if (argc != 5) { printf("%s <array length> <max min quicksort (20)> " "<times> <threads>\n", argv[0]); exit(1); } srand(time(NULL) * rand()); int64_t length = atoi(argv[1]); int64_t max_min_q = atoi(argv[2]); int64_t average = atoi(argv[3]); int64_t n_threads = atoi(argv[4]); int64_t *ary1 = malloc(sizeof(int64_t) * length); int64_t i, k; int64_t sorted = 1; int64_t sorted_all = 1; init_tc((uint32_t) log2((double) length), n_threads); QISTA_t args; args.ary = (void *) ary1; args.base = sizeof(int64_t); args.length = length; args.min = max_min_q; args.bigger = p_bigger; args.smaler = p_smaler; args.equal = p_equal; args.n_threads = n_threads; for (k = 0; k < average; k++) { for (i = 0; i < length; i++) { ary1[i] = rand() % length; } quickinsersort_min(ary1, length, max_min_q, sizeof(int64_t), p_smaler, p_bigger, p_equal); for (i = 0; i < length-1; i++) { if (ary1[i] > ary1[i+1]) { sorted = 0; sorted_all = 0; } } if (!sorted) printf("[ERROR] quickinsersort_min FAILED!\n"); sorted = 1; for (i = 0; i < length; i++) { ary1[i] = rand() % length; } QUICK_INSERT_SORT_MIN(int64_t, ary1, length, bigger, smaler, equal, max_min_q); for (i = 0; i < length-1; i++) { if (ary1[i] > ary1[i+1]) { sorted = 0; sorted_all = 0; } } if (!sorted) printf("[ERROR] QUICK_INSERT_SORT_MIN FAILED!\n"); sorted = 1; for (i = 0; i < length; i++) { ary1[i] = rand() % length; } parallel_quickinsersort_min(&args); for (i = 0; i < length-1; i++) { if (ary1[i] > ary1[i+1]) { sorted = 0; sorted_all = 0; } } if (!sorted) printf("[ERROR] t_quickinsersort_min FAILED!\n"); sorted = 1; for (i = 0; i < length; i++) { ary1[i] = rand() % length; } pt_parallel_quickinsersort_min(&args); for (i = 0; i < length-1; i++) { if (ary1[i] > ary1[i+1]) { sorted = 0; sorted_all = 0; } } if (!sorted) printf("[ERROR] pthread_quickinsersort_min FAILED!\n"); sorted = 1; for (i = 0; i < length; i++) { ary1[i] = rand() % length; } quickinsersort_max(ary1, length, max_min_q, sizeof(int64_t), p_smaler, p_bigger, p_equal); for (i = 0; i < length-1; i++) { if (ary1[i] < ary1[i+1]) { sorted = 0; sorted_all = 0; } } if (!sorted) printf("[ERROR] quickinsersort_max FAILED!\n"); sorted = 1; for (i = 0; i < length; i++) { ary1[i] = rand() % length; } QUICK_INSERT_SORT_MAX(int64_t, ary1, length, bigger, smaler, equal, max_min_q); for (i = 0; i < length-1; i++) { if (ary1[i] < ary1[i+1]) { sorted = 0; sorted_all = 0; } } if (!sorted) printf("[ERROR] QUICK_INSERT_SORT_MAX FAILED!\n"); sorted = 1; for (i = 0; i < length; i++) { ary1[i] = rand() % length; } parallel_quickinsersort_max(&args); for (i = 0; i < length-1; i++) { if (ary1[i] < ary1[i+1]) { sorted = 0; sorted_all = 0; } } if (!sorted) printf("[ERROR] t_quickinsersort_max FAILED!\n"); sorted = 1; for (i = 0; i < length; i++) { ary1[i] = rand() % length; } pt_parallel_quickinsersort_max(&args); for (i = 0; i < length-1; i++) { if (ary1[i] < ary1[i+1]) { sorted = 0; sorted_all = 0; } } if (!sorted) printf("[ERROR] pthread_quickinsersort_max FAILED!\n"); sorted = 1; for (i = 0; i < length; i++) { ary1[i] = rand() % length; } qsort(ary1, length, sizeof(int64_t), comp); for (i = 0; i < length-1; i++) { if (ary1[i] > ary1[i+1]) { sorted = 0; sorted_all = 0; } } if (!sorted) printf("[ERROR] stdlib qsort FAILED!\n"); sorted = 1; } if (sorted_all) printf("Everything went fine, arrays are sorted :-)\n"); return 0; }