static void capture_test_1 (int argc, char** argv, const rtems_monitor_command_arg_t* command_arg, bool verbose) { rtems_status_code sc; rtems_name name; rtems_id id[3]; rtems_id mutex; int loops; capture_CT1a_deleted = 0; capture_CT1b_deleted = 0; capture_CT1c_deleted = 0; name = rtems_build_name('C', 'T', 'm', '1'); sc = rtems_semaphore_create (name, 1, RTEMS_PRIORITY | RTEMS_BINARY_SEMAPHORE | RTEMS_INHERIT_PRIORITY, 0, &mutex); if (sc != RTEMS_SUCCESSFUL) { printf ("error: Test 1: cannot mutex: %s\n", rtems_status_text (sc)); return; } name = rtems_build_name('C', 'T', '1', 'a'); sc = rtems_task_create (name, 102, 2 * 1024, RTEMS_NO_FLOATING_POINT | RTEMS_LOCAL, RTEMS_PREEMPT | RTEMS_TIMESLICE | RTEMS_NO_ASR, &id[0]); if (sc != RTEMS_SUCCESSFUL) { printf ("error: Test 1: cannot create CT1a: %s\n", rtems_status_text (sc)); rtems_semaphore_delete (mutex); return; } sc = rtems_task_start (id[0], capture_CT1a, (rtems_task_argument) mutex); if (sc != RTEMS_SUCCESSFUL) { printf ("error: Test 1: cannot start CT1a: %s\n", rtems_status_text (sc)); rtems_task_delete (id[0]); rtems_semaphore_delete (mutex); return; } capture_wait (1000); name = rtems_build_name('C', 'T', '1', 'b'); sc = rtems_task_create (name, 101, 2 * 1024, RTEMS_NO_FLOATING_POINT | RTEMS_LOCAL, RTEMS_PREEMPT | RTEMS_TIMESLICE | RTEMS_NO_ASR, &id[1]); if (sc != RTEMS_SUCCESSFUL) { printf ("error: Test 1: cannot create CT1b: %s\n", rtems_status_text (sc)); rtems_task_delete (id[0]); rtems_semaphore_delete (mutex); return; } sc = rtems_task_start (id[1], capture_CT1b, 0); if (sc != RTEMS_SUCCESSFUL) { printf ("error: Test 1: cannot start CT1b: %s\n", rtems_status_text (sc)); rtems_task_delete (id[1]); rtems_task_delete (id[0]); rtems_semaphore_delete (mutex); return; } capture_wait (1000); name = rtems_build_name('C', 'T', '1', 'c'); sc = rtems_task_create (name, 100, 2 * 1024, RTEMS_NO_FLOATING_POINT | RTEMS_LOCAL, RTEMS_PREEMPT | RTEMS_TIMESLICE | RTEMS_NO_ASR, &id[2]); if (sc != RTEMS_SUCCESSFUL) { printf ("error: Test 1: cannot create CT1c: %s\n", rtems_status_text (sc)); rtems_task_delete (id[1]); rtems_task_delete (id[0]); rtems_semaphore_delete (mutex); return; } sc = rtems_task_start (id[2], capture_CT1c, (rtems_task_argument) mutex); if (sc != RTEMS_SUCCESSFUL) { printf ("error: Test 1: cannot start CT1c: %s\n", rtems_status_text (sc)); rtems_task_delete (id[2]); rtems_task_delete (id[1]); rtems_task_delete (id[0]); rtems_semaphore_delete (mutex); return; } loops = 15; while (!(capture_CT1a_deleted || capture_CT1b_deleted || capture_CT1c_deleted) && loops) { loops--; capture_wait (1000); } if (!loops) { printf ("error: Test 1: test tasks did not delete\n"); rtems_task_delete (id[2]); rtems_task_delete (id[1]); rtems_task_delete (id[0]); } sc = rtems_semaphore_delete (mutex); if (sc != RTEMS_SUCCESSFUL) printf ("error: Test 1: deleting the mutex: %s\n", rtems_status_text (sc)); }
/* * Wait for a sync pulse of 3 ms */ static void wait_for_sync( uint8_t hi, uint8_t flag ) { uint16_t diff; uint16_t stop; outp( 0x00, PORTC ); do { uint16_t start; /* * Catch the start of the sync pulse. * Rising for hi sync, falling for low sync */ if( hi ) capture_rising_edge(); else capture_falling_edge(); capture_clear_flag(); start = capture_wait(); /* * Catch the end of the sync pulse. * Falling for hi sync, rising for lo sync. */ if( hi ) capture_falling_edge(); else capture_rising_edge(); capture_clear_flag(); stop = capture_wait(); diff = stop - start; } while( diff < 2500 * CLOCK ); #if 0 /* Wait for the next edge */ if( hi ) capture_rising_edge(); else capture_falling_edge(); capture_clear_flag(); stop = capture_wait(); #endif outp( flag, PORTC ); /* * The bit clock is always 300 useconds long. * We don't actually need the length of the sync pulse. */ compare_set( stop + sync_offset ); compare_clear_flag(); /* Reset our counters for the interrupt routine */ bit_counter = 10; pcm_ready = 0; /* Enable our interrupt */ compare_enable(); }
static void capture_loop(struct chameleon_camera *c1, struct chameleon_camera *c2, float framerate, const char *basename, bool testonly, bool eight_bit_mode) { char *basenames[2]; unsigned count=0; asprintf(&basenames[0], "%s-0", basename); asprintf(&basenames[1], "%s-1", basename); start_timer(); while (true) { struct timeval tv; uint32_t trigger_v; count++; if (c1 && c1->bad_frames > 10) { printf("RESETTING CAMERA 1\n"); camera_setup(c1, false); c1->bad_frames = 0; } if (c2 && c2->bad_frames > 10) { printf("RESETTING CAMERA 2\n"); camera_setup(c2, false); c2->bad_frames = 0; } if (c1) { do { CHECK(chameleon_get_control_register(c1, 0x62C, &trigger_v)); } while (trigger_v & 0x80000000); } if (c2) { do { CHECK(chameleon_get_control_register(c2, 0x62C, &trigger_v)); } while (trigger_v & 0x80000000); } while (end_timer() < 1.0/framerate) { usleep(100); } gettimeofday(&tv, NULL); if (c1) { CHECK(chameleon_set_control_register(c1, 0x62C, 0x80000000)); } if (c2) { CHECK(chameleon_set_control_register(c2, 0x62C, 0x80000000)); } start_timer(); if (c1) { capture_wait(c1, basenames[0], testonly, eight_bit_mode, &tv); } if (c2) { capture_wait(c2, basenames[1], testonly, eight_bit_mode, &tv); } } }