Esempio n. 1
0
/**
 * MAIN
 */
int main(void)
{
  timer sensor_time = timer_msec;
  
  sei();  /* global interrupt enable */
  
  /* start timing function */
  timer0_init_1khz();
  
  lcd_init(LCD_DISP_ON);
  
  CANMSG("CAN senzor");
  
  init_fsm(&fsm_sensor,&fsm_sensor_init);
  
  
  while(1) {
    
    if (timer_msec >= (sensor_time + 100)) {
      sensor_time = timer_msec;
      debug(1,timer_msec);
      
      /* run fsm every x ms*/
      run_fsm(&fsm_sensor);
    }
    
    /* if new msg recived, configure sensor according to new parameters */
    if (rx_msg.status == NEW) {
      rx_msg.status = NONE;
      sensor_config(&rx_msg,&fsm_sensor);
    }    
  }
  
  return 0;
}
Esempio n. 2
0
/*!
 * camera sensor display and capture test.
 *
 * @return error information
 */
int32_t sensor_capture(void)
{
    int32_t ipu_index = 1, read_value = 1;
    ips_dev_panel_t *panel;
    camera_profile_t *sensor;
    uint8_t revchar;
    int32_t ret = TEST_PASSED;

    /*step 1: enable panel */
    panel = search_panel("HannStar XGA LVDS");
    panel->panel_init(&ipu_index);

    /*step 2: setup IPU: from csi to display */
    ipu1_iomux_config();
    ipu_sw_reset(ipu_index, 1000);
    ipu_capture_setup(ipu_index, CSI_PARALLEL, 640, 480, 640, 480, panel);

    /*step 3: setup sensor */
    sensor = sensor_search();
    if (sensor == NULL)
        return TEST_FAILED;
    sensor_config(sensor);

    /*step 4: enable ipu display channel */
    ipu_enable_display(ipu_index);

    /*test 1: capture image from sensor */
    printf("Do you see the captured image (y or n)?\n");
    do {
        revchar = getchar();
    } while (revchar == (uint8_t) 0xFF);
    if (!(revchar == 'Y' || revchar == 'y')) {
        ret = TEST_FAILED;
        goto err;
    }

    /*test 2: sensor auto focus */
    if (sensor->auto_focus_enable) {
        printf("Do you want to test auto focus function? [y/n]\n");
        if (is_input_char('y', NULL)) {
            sensor_autofocus_init(sensor);
            while (is_input_char('y', NULL)) {
                sensor_af_trigger(sensor);
                printf("Do you see the viewfiner in the middle of camera?[y/n]\n");
                if (!is_input_char('y', NULL)) {
                    ret = TEST_FAILED;
                    goto err;
                }
                printf("Trigger more? [y/n]\n");
            }
        }
    }

    /*test 3: sensor standby */
    printf("Do you want to test standby mode? [y/n]\n");
    while (is_input_char('y', NULL)) {
        sensor_standby(read_value);
        if (read_value == 1) {
            printf("Do you see the still camera image? [y/n]\n");
            if (!is_input_char('y', NULL)) {
                ret = TEST_FAILED;
                goto err;
            }
        }
        read_value = 1 - read_value;
        printf("Trigger more? [y/n]\n");
    }

err:
    ipu_capture_streamoff(ipu_index);
    return ret;
}