void uc_pushb_init(int_isr p_pb1_callback, int_isr p_pb2_callback) { g_pb1_callback = p_pb1_callback; g_pb2_callback = p_pb2_callback; //void gpio_port_init(int p_port, int p_pin, int p_funct, int p_data_dir, int p_state) gpio_port_init(gpio_port_ta, uc_pb_1, gpio_funct_primary, gpio_data_dir_in, gpio_pin_state_high); gpio_port_init(gpio_port_ta, uc_pb_2, gpio_funct_primary, gpio_data_dir_in, gpio_pin_state_high); //Call gpt_disable() gpt_disable(); //Call gpt_incap_config() to configure pin 0 for input capture on the falling edge gpt_incap_config(gpt_pin_0,gpt_incap_edge_rising); //Call gpt_incap_config() to configure pin 1 for input capture on the falling edge gpt_incap_config(gpt_pin_1,gpt_incap_edge_rising); //Call int_configure(gpt0_int_src, gpt0_int_level, gpt0_int_priority, uc_pushb1_isr) int_config(gpt0_int_src, gpt0_int_level, gpt0_int_priority, uc_pushb1_isr); //Call int_configure(gpt1_int_src, gpt1_int_level, gpt1_int_priority, uc_pushb2_isr) int_config(gpt1_int_src, gpt1_int_level, gpt1_int_priority, uc_pushb2_isr); //Call gpt_enable() to enable the GPT module gpt_enable(); }
int main() { printf ("\n"); printf ("HEIA-FR - Embedded Systems 2 Laboratory\n"); printf ("TP13: - TP5 Optimizations\n"); printf (" Fabio Valverde & Samuel Mertenat\n"); printf ("----------------------------------------------------\n"); // initializes the LCD and displays an image imx27_lcdc_init(); imx27_lcdc_enable(); // initialization of the different modules... interrupt_init(); exception_init(); aitc_init(); interrupt_enable(); gpt_init(); imx27_gpio_init(); imx27_mmu_init(); // variables to store the beginning / end of the procedure uint32_t start = 0; uint32_t stop = 0; uint32_t result = 0; // struct used for the chronometer (incremented by the gpt) struct chronometer chrono; chrono.timer = 0; // enables the timer gpt_enable(GPT1, 1, increment_timer, &chrono); //---------- NO CACHE ---------- // gets the initial time start = chrono.timer; // converts & displays the small image struct xpm_image img = linear_convert_xpm_image(tour_S); display_image(&img, 0, 0); // gets the final time stop = chrono.timer; result = stop - start; printf("Linear search - No cache\n"); printf("Small image: %u [ms]\n", result); start = chrono.timer; img = linear_convert_xpm_image(tour_M); display_image(&img, 0, 0); stop = chrono.timer; result = stop - start; printf("Medium image: %u [ms]\n", result); start = chrono.timer; img = linear_convert_xpm_image(tour_L); display_image(&img, 0, 0); stop = chrono.timer; result = stop - start; printf("Large image: %u [ms]\n", result); start = chrono.timer; img = linear_convert_xpm_image(tour_XL); display_image(&img, 0, 0); stop = chrono.timer; result = stop - start; printf("Extra-large image: %u [ms]\n\n", result); start = chrono.timer; // converts & displays the small image img = binary_convert_xpm_image(tour_S); display_image(&img, 0, 0); // gets the final time stop = chrono.timer; result = stop - start; printf("Binary search - No cache\n"); printf("Small image: %u [ms]\n", result); start = chrono.timer; img = binary_convert_xpm_image(tour_M); display_image(&img, 0, 0); stop = chrono.timer; result = stop - start; printf("Medium image: %u [ms]\n", result); start = chrono.timer; img = binary_convert_xpm_image(tour_L); display_image(&img, 0, 0); stop = chrono.timer; result = stop - start; printf("Large image: %u [ms]\n", result); start = chrono.timer; img = binary_convert_xpm_image(tour_XL); display_image(&img, 0, 0); stop = chrono.timer; result = stop - start; printf("Extra-large image: %u [ms]\n", result); //---------- DATA CACHE ---------- printf ("----------------------------------------------------\n"); imx27_mmu_enable_dcache(); start = chrono.timer; img = linear_convert_xpm_image(tour_S); display_image(&img, 0, 0); stop = chrono.timer; result = stop - start; printf("Linear search - Data cache\n"); printf("Small image: %u [ms]\n", result); start = chrono.timer; img = linear_convert_xpm_image(tour_M); display_image(&img, 0, 0); stop = chrono.timer; result = stop - start; printf("Medium image: %u [ms]\n", result); start = chrono.timer; img = linear_convert_xpm_image(tour_L); display_image(&img, 0, 0); stop = chrono.timer; result = stop - start; printf("Large image: %u [ms]\n", result); start = chrono.timer; img = linear_convert_xpm_image(tour_XL); display_image(&img, 0, 0); stop = chrono.timer; result = stop - start; printf("Extra-large image: %u [ms]\n\n", result); printf("Binary search - Data cache\n"); start = chrono.timer; img = binary_convert_xpm_image(tour_S); display_image(&img, 0, 0); stop = chrono.timer; result = stop - start; printf("Small image: %u [ms]\n", result); start = chrono.timer; img = binary_convert_xpm_image(tour_M); display_image(&img, 0, 0); stop = chrono.timer; result = stop - start; printf("Medium image: %u [ms]\n", result); start = chrono.timer; img = binary_convert_xpm_image(tour_L); display_image(&img, 0, 0); stop = chrono.timer; result = stop - start; printf("Large image: %u [ms]\n", result); start = chrono.timer; img = binary_convert_xpm_image(tour_XL); display_image(&img, 0, 0); stop = chrono.timer; result = stop - start; printf("Extra-large image: %u [ms]\n", result); //---------- DATA + INSTRUCTIONS CACHEs ---------- printf ("----------------------------------------------------\n"); imx27_mmu_enable_icache(); start = chrono.timer; img = linear_convert_xpm_image(tour_S); display_image(&img, 0, 0); stop = chrono.timer; result = stop - start; printf("Linear search - Data + instructions caches\n"); printf("Small image: %u [ms]\n", result); start = chrono.timer; img = linear_convert_xpm_image(tour_M); display_image(&img, 0, 0); stop = chrono.timer; result = stop - start; printf("Medium image: %u [ms]\n", result); start = chrono.timer; img = linear_convert_xpm_image(tour_L); display_image(&img, 0, 0); stop = chrono.timer; result = stop - start; printf("Large image: %u [ms]\n", result); start = chrono.timer; img = linear_convert_xpm_image(tour_XL); display_image(&img, 0, 0); stop = chrono.timer; result = stop - start; printf("Extra-large image: %u [ms]\n\n", result); printf("Binary search - Data + instructions caches\n"); start = chrono.timer; img = binary_convert_xpm_image(tour_S); display_image(&img, 0, 0); stop = chrono.timer; result = stop - start; printf("Small image: %u [ms]\n", result); start = chrono.timer; img = binary_convert_xpm_image(tour_M); display_image(&img, 0, 0); stop = chrono.timer; result = stop - start; printf("Medium image: %u [ms]\n", result); start = chrono.timer; img = binary_convert_xpm_image(tour_L); display_image(&img, 0, 0); stop = chrono.timer; result = stop - start; printf("Large image: %u [ms]\n", result); start = chrono.timer; img = binary_convert_xpm_image(tour_XL); display_image(&img, 0, 0); stop = chrono.timer; result = stop - start; printf("Extra-large image: %u [ms]\n", result); /* //---------- Instructions CACHE ---------- imx27_mmu_enable_icache(); // gets the initial time start = chrono.timer; // converts & displays the small image struct xpm_image img = linear_convert_xpm_image(tour_S); display_image(&img, 0, 0); // gets the final time stop = chrono.timer; result = stop - start; printf("Linear search - Instructions cache\n"); printf("Small image: %u [ms]\n", result); start = chrono.timer; img = linear_convert_xpm_image(tour_M); display_image(&img, 0, 0); stop = chrono.timer; result = stop - start; printf("Medium image: %u [ms]\n", result); start = chrono.timer; img = linear_convert_xpm_image(tour_L); display_image(&img, 0, 0); stop = chrono.timer; result = stop - start; printf("Large image: %u [ms]\n", result); start = chrono.timer; img = linear_convert_xpm_image(tour_XL); display_image(&img, 0, 0); stop = chrono.timer; result = stop - start; printf("Extra-large image: %u [ms]\n\n", result); start = chrono.timer; // converts & displays the small image img = binary_convert_xpm_image(tour_S); display_image(&img, 0, 0); // gets the final time stop = chrono.timer; result = stop - start; printf("Binary search - Instructions cache\n"); printf("Small image: %u [ms]\n", result); start = chrono.timer; img = binary_convert_xpm_image(tour_M); display_image(&img, 0, 0); stop = chrono.timer; result = stop - start; printf("Medium image: %u [ms]\n", result); start = chrono.timer; img = binary_convert_xpm_image(tour_L); display_image(&img, 0, 0); stop = chrono.timer; result = stop - start; printf("Large image: %u [ms]\n", result); start = chrono.timer; img = binary_convert_xpm_image(tour_XL); display_image(&img, 0, 0); stop = chrono.timer; result = stop - start; printf("Extra-large image: %u [ms]\n", result); */ return 0; }
void obiomputmr_attach(device_t parent, device_t self, void *aux) { struct mputmr_softc *sc = device_private(self); struct obio_attach_args *obio = aux; int ints_per_sec; sc->sc_dev = self; sc->sc_iot = obio->obio_iot; sc->sc_intr = obio->obio_intr; if (bus_space_map(obio->obio_iot, obio->obio_addr, obio->obio_size, 0, &sc->sc_ioh)) panic("%s: Cannot map registers", device_xname(self)); switch (device_unit(self)) { /* XXX broken */ case 0: clock_sc = sc; ints_per_sec = hz; break; case 1: stat_sc = sc; ints_per_sec = profhz = stathz = STATHZ; break; case 2: ref_sc = sc; ints_per_sec = hz; /* Same rate as clock */ break; default: ints_per_sec = hz; /* Better value? */ break; } aprint_normal(": OMAP MPU Timer"); gpt_enable(sc, obio, gpt_lookup(obio)); aprint_normal("\n"); aprint_naive("\n"); #if defined(OMAP_2430) || defined(OMAP_2420) /* Stop the timer from counting, but keep the timer module working. */ bus_space_write_4(sc->sc_iot, sc->sc_ioh, MPU_CNTL_TIMER, MPU_CLOCK_ENABLE); #endif timer_factors tf; calc_timer_factors(ints_per_sec, &tf); switch (device_unit(self)) { /* XXX broken */ case 0: #ifndef ARM11_PMC counts_per_hz = tf.reload + 1; counts_per_usec = tf.counts_per_usec; #endif break; case 2: /* * The microtime reference clock for all practical purposes * just wraps around as an unsigned int. */ tf.reload = 0xffffffff; break; default: break; } #if defined(OMAP_2430) || defined(OMAP_2420) /* Set the reload value. */ bus_space_write_4(sc->sc_iot, sc->sc_ioh, MPU_LOAD_TIMER, tf.reload); /* Set the PTV and the other required bits and pieces. */ bus_space_write_4(sc->sc_iot, sc->sc_ioh, MPU_CNTL_TIMER, ( MPU_CLOCK_ENABLE | (tf.ptv << MPU_PTV_SHIFT) | MPU_AR | MPU_ST)); /* The clock is now running, but is not generating interrupts. */ #endif }