Esempio n. 1
0
File: asic.c Progetto: zyh329/CEmu
static void plug_devices(void) {
    /* Port ranges 0x0 -> 0xF */
    port_map[0x0] = init_control();
    port_map[0x1] = init_flash();
    port_map[0x2] = init_sha256();
    port_map[0x3] = init_usb();
    port_map[0x4] = init_lcd();
    port_map[0x5] = init_intrpt();
    port_map[0x6] = init_watchdog();
    port_map[0x7] = init_gpt();
    port_map[0x8] = init_rtc();
    port_map[0x9] = init_protected();
    port_map[0xA] = init_keypad();
    port_map[0xB] = init_backlight();
    port_map[0xC] = init_cxxx();
    port_map[0xD] = init_dxxx();
    port_map[0xE] = init_exxx();
    port_map[0xF] = init_fxxx();

    reset_proc_count = 0;

    /* Populate reset callbacks */
    add_reset_proc(lcd_reset);
    add_reset_proc(keypad_reset);
    add_reset_proc(gpt_reset);
    add_reset_proc(rtc_reset);
    add_reset_proc(watchdog_reset);
    add_reset_proc(cpu_reset);

    gui_console_printf("[CEmu] Initialized APB...\n");
}
Esempio n. 2
0
/** List available usb devices. */
void
list_devices()
{
  bool tmp_ctx = false;
  if( __ctx == NULL ) {
    // try creating a temporary context
    error_t err = init_usb();
    if( err != ERROR_NONE )
       throw KinDrvException(err, "Failed to initialize temporary libusb context");
    else
      tmp_ctx = true;
  }

  // Get devices
  ssize_t cnt;
  cnt = libusb_get_device_list(__ctx, &__devices);
  if( cnt<0 ) {
    fprintf( stderr, "Get_device_list error: %zi \n", cnt);
  } else {
    printf("%zi USB devices detected \n", cnt);

    list_devices(__devices);

    // Clear devices list
    libusb_free_device_list(__devices, /*auto-unref*/ true);
  }

  if( tmp_ctx )
    close_usb();
}
Esempio n. 3
0
int main(int argc, char* argv[])
{
   printf("payload compiled " __DATE__ " " __TIME__ "\n");
   disable_watchdog(); printf("watchdog disabled.\n");
   init_tcp();
   init_usb();
   printf("usbmux initialized\n");
   return socket_listen(); 
}
Esempio n. 4
0
usb_handle *usb_open(ifc_match_func callback) {
    usb_handle *handle = NULL;

    if (init_usb(callback, &handle) < 0) {
        /* Something went wrong initializing USB. */
        return NULL;
    }

    return handle;
}
Esempio n. 5
0
UsbTransport* usb_open(ifc_match_func callback, uint32_t timeout_ms) {
    std::unique_ptr<usb_handle> handle;

    if (init_usb(callback, &handle) < 0) {
        /* Something went wrong initializing USB. */
        return nullptr;
    }

    return new OsxUsbTransport(std::move(handle), timeout_ms);
}
Esempio n. 6
0
void main(void)
{
    init_boot();
    init_usb();

    while(1)
    {
        usb_sleep();
        dispatch_usb_event();
        if((application_data.invalid == 0) &&
           (GET_ACTIVE_CONFIGURATION() > FLASH_CONFIGURATION))
        {
            application_data.main();

            INTCON = 0; // Forbid interrupts
        }
    }
}
Esempio n. 7
0
File: main.c Progetto: texane/slosyn
void main(void)
{
  initialize();

  init_usb();

  slosyn_setup();

  while(1)
  {
    INTCON = 0;

    usb_sleep();
    dispatch_usb_event();

    slosyn_schedule();
  }
}
Esempio n. 8
0
static LIBMTP_error_number_t get_mtp_usb_device_list(mtpdevice_list_t ** mtp_device_list)
{
  struct usb_bus *bus = init_usb();
  for (; bus != NULL; bus = bus->next) {
    struct usb_device *dev = bus->devices;
    for (; dev != NULL; dev = dev->next) {
      if (dev->descriptor.bDeviceClass != USB_CLASS_HUB) {
	int i;
        int found = 0;

	
	
	
        for(i = 0; i < mtp_device_table_size; i++) {
          if(dev->descriptor.idVendor == mtp_device_table[i].vendor_id &&
            dev->descriptor.idProduct == mtp_device_table[i].product_id) {
            
            *mtp_device_list = append_to_mtpdevice_list(*mtp_device_list, 
							dev, 
							bus->location);
            found = 1;
            break;
          }
        }
	
        if (!found) {
          if (probe_device_descriptor(dev, NULL)) {
            
            *mtp_device_list = append_to_mtpdevice_list(*mtp_device_list, 
							dev,
							bus->location);
          }
        }
      }
    }
  }
  
  
  if(*mtp_device_list == NULL) {
    return LIBMTP_ERROR_NO_DEVICE_ATTACHED;
  }
  return LIBMTP_ERROR_NONE;
}
Esempio n. 9
0
void main(void) {
	rcc_clock_setup_in_hse_8mhz_out_72mhz();

	init_systick();
	init_usb();
	power_init();
	lock_init();

	// configure status LED
	rcc_periph_clock_enable(RCC_GPIOC);
	gpio_set_mode(GPIOC, GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, GPIO13);

	// configure buzzer input
	rcc_periph_clock_enable(RCC_GPIOB);
	gpio_set_mode(GPIOB, GPIO_MODE_INPUT, GPIO_CNF_INPUT_PULL_UPDOWN, GPIO9);
	gpio_set(GPIOB, GPIO9); // pull up

	set_state(CLOSED);

	uint32_t button_start = 0;
	while(1) {
		usb_poll();

		if(get_state() == CLOSED)
			gpio_set(GPIOC, GPIO13);
		else
			gpio_clear(GPIOC, GPIO13);

		if(gpio_get(GPIOB, GPIO9) == 0) {
			if(button_start == 0)
				button_start = ticks;
		} else
			button_start = 0;

		if(button_start && time_after(ticks, button_start + (HZ/10)) && get_state() == CLOSED)
			lock();

		if(button_start && time_after(ticks, button_start + HZ * 15))
			lock();
	}
}
// Program entry point
void main()
{
  rfcon = 0x06; // enable RF clock
  rfctl = 0x10; // enable SPI
  ien0 = 0x80;  // enable interrupts
  TICKDV = 0xFF; // set the tick divider

  // Initialise and connect the USB controller
  init_usb();

  // Flush the radio FIFOs
  flush_rx();
  flush_tx();

  // Everything is triggered via interrupts, so now we wait
  while(1)
  {
    REGXH = 0xFF;
    REGXL = 0xFF;
    REGXC = 0x08;
    delay_us(1000);
  }
}
Esempio n. 11
0
/** Constructor.
 * Connects to first available/free arm on USB port. */
JacoArm::JacoArm() :
  __devh( 0 )
{
  if( __ctx == NULL ) {
    // initialize libusb
    error_t e = init_usb();
    if( e != ERROR_NONE )
      throw KinDrvException(e, "Abort creating JacoArm, libusb could not be initialized");
    __auto_ctx = true;
  }

  //  refreshing the devices list
  get_connected_devs();

  // Open first unconnected device
  if( __connected_arms->size() == 0)
    throw KinDrvException("No Kinova Jaco Arm connected!" );

  // Find first free device
  std::list<usb_device_t>::iterator it;
  for (it=__connected_arms->begin(); it != __connected_arms->end(); ++it) {
    if( !(*it).connected )
      break;
  }
  if( it == __connected_arms->end() )
    throw KinDrvException("All identified arms are already connected and have a USB handle!");
  else
    Create(*it);

  // flush possible leftovers on device
  _flush();

  // get and store client information
  _update_client_config();
  memcpy((*it).client_name, __client_config.name, 20);
}
Esempio n. 12
0
/*
 * Our main
 */
int main(void)
{    
    /* Check if the firmware asked to start the bootloader */
    if (bootloader_start_var == 0xBEEF)
    {
        wdt_disable();
        start_bootloader();
    }
    
    /* Pull PC3 low to enable boot loader */
    PORTC_DIRCLR = PIN3_bm;                         // PC3 input
    PORTC.PIN3CTRL = PORT_OPC_PULLUP_gc;            // Pullup PC3
    _delay_ms(10);                                  // Small delay
    if((PORTC_IN & PIN3_bm) == 0)                   // Check PC3
    {
        start_bootloader();
    }
    
    /* Normal boot */
    switch_to_32MHz_clock();                        // Switch to 32MHz
    _delay_ms(1000);                                // Wait for power to settle
    init_serial_port();                             // Initialize serial port    
    init_dac();                                     // Init DAC
    init_adc();                                     // Init ADC
    init_ios();                                     // Init IOs
    init_calibration();                             // Init calibration
    enable_interrupts();                            // Enable interrupts
    init_usb();                                     // Init USB comms
    functional_test();                              // Functional test if started for the first time

    uint8_t current_fw_mode = MODE_IDLE;
    while(1)
    {
        if (current_fw_mode == MODE_CAP_MES)
        {
            // If we are in cap measurement mode and have a report to send
            if(cap_measurement_loop(&cap_report) == TRUE)
            {
                maindprintf_P(PSTR("*"));
                usb_packet.length = sizeof(cap_report);
                usb_packet.command_id = CMD_CAP_MES_REPORT;
                memcpy((void*)usb_packet.payload, (void*)&cap_report, sizeof(cap_report));
                usb_send_data((uint8_t*)&usb_packet);
            }
        }
        
        // USB command parser
        if (usb_receive_data((uint8_t*)&usb_packet) == TRUE)
        {
            switch(usb_packet.command_id)
            {
                case CMD_BOOTLOADER_START:
                {
                    maindprintf_P(PSTR("USB- Bootloader start"));
                    bootloader_start_var = 0xBEEF;
                    wdt_enable(WDTO_1S);
                    while(1);
                }
                case CMD_PING: 
                {
                    maindprintf_P(PSTR("."));
                    // Ping packet, resend the same one
                    usb_send_data((uint8_t*)&usb_packet);
                    break;
                }
                case CMD_VERSION:
                {
                    maindprintf_P(PSTR("USB- Version\r\n"));
                    // Version request packet
                    strcpy((char*)usb_packet.payload, CAPMETER_VER);
                    usb_packet.length = sizeof(CAPMETER_VER);
                    usb_send_data((uint8_t*)&usb_packet);
                    break;
                }
                case CMD_OE_CALIB_STATE:
                {
                    maindprintf_P(PSTR("USB- Calib state\r\n"));
                    // Get open ended calibration state.
                    if (is_platform_calibrated() == TRUE)
                    {
                        // Calibrated, return calibration data
                        usb_packet.length = get_openended_calibration_data(usb_packet.payload);
                    } 
                    else
                    {
                        // Not calibrated, return 0
                        usb_packet.length = 1;
                        usb_packet.payload[0] = 0;
                    }
                    usb_send_data((uint8_t*)&usb_packet);    
                    break;                
                }
                case CMD_OE_CALIB_START:
                {
                    maindprintf_P(PSTR("USB- Calib start\r\n"));
                    // Check if we are in idle mode
                    if (current_fw_mode == MODE_IDLE)
                    {
                        // Calibration start
                        start_openended_calibration(usb_packet.payload[0], usb_packet.payload[1], usb_packet.payload[2]);
                        usb_packet.length = get_openended_calibration_data(usb_packet.payload);
                    }
                    else
                    {
                        usb_packet.length = 1;
                        usb_packet.payload[0] = USB_RETURN_ERROR;
                    }
                    usb_send_data((uint8_t*)&usb_packet);    
                    break;                
                }
                case CMD_GET_OE_CALIB:
                {
                    maindprintf_P(PSTR("USB- Calib data\r\n"));
                    // Get calibration data
                    usb_packet.length = get_openended_calibration_data(usb_packet.payload);
                    usb_send_data((uint8_t*)&usb_packet);    
                    break;                
                }
                case CMD_SET_VBIAS:
                {
                    // Check that we are not measuring anything and if so, skip samples and stop oscillation
                    if (current_fw_mode == MODE_CAP_MES)
                    {
                        pause_capacitance_measurement_mode();
                    }
                    
                    // Enable and set vbias... can also be called to update it
                    uint16_t* temp_vbias = (uint16_t*)usb_packet.payload;
                    uint16_t set_vbias = enable_bias_voltage(*temp_vbias);
                    uint16_t cur_dacv = get_current_vbias_dac_value();
                    usb_packet.length = 4;
                    memcpy((void*)usb_packet.payload, (void*)&set_vbias, sizeof(set_vbias));
                    memcpy((void*)&usb_packet.payload[2], (void*)&cur_dacv, sizeof(cur_dacv));
                    usb_send_data((uint8_t*)&usb_packet);
                    
                    // If we are measuring anything, resume measurements
                    if (current_fw_mode == MODE_CAP_MES)
                    {
                        resume_capacitance_measurement_mode();
                    }                    
                    break;
                }
                case CMD_DISABLE_VBIAS:
                {
                    // Disable vbias
                    usb_packet.length = 0;
                    disable_bias_voltage();
                    usb_send_data((uint8_t*)&usb_packet);
                    break;
                }
                case CMD_CUR_MES_MODE:
                {
                    // Enable current measurement or start another measurement
                    if (current_fw_mode == MODE_IDLE)
                    {
                        set_current_measurement_mode(usb_packet.payload[0]);
                        current_fw_mode = MODE_CURRENT_MES;
                    } 
                    // Check if we are in the right mode to start a measurement
                    if (current_fw_mode == MODE_CURRENT_MES)
                    {
                        // We either just set current measurement mode or another measurement was requested
                        if (get_configured_adc_ampl() != usb_packet.payload[0])
                        {
                            // If the amplification isn't the same one as requested
                            set_current_measurement_mode(usb_packet.payload[0]);
                        }
                        // Start measurement
                        usb_packet.length = 2;
                        uint16_t return_value = cur_measurement_loop(usb_packet.payload[1]);
                        memcpy((void*)usb_packet.payload, (void*)&return_value, sizeof(return_value));
                        usb_send_data((uint8_t*)&usb_packet);
                    }
                    else
                    {
                        usb_packet.length = 1;
                        usb_packet.payload[0] = USB_RETURN_ERROR;
                        usb_send_data((uint8_t*)&usb_packet);
                    }
                    break;
                }
                case CMD_CUR_MES_MODE_EXIT:
                {
                    if (current_fw_mode == MODE_CURRENT_MES)
                    {
                        usb_packet.payload[0] = USB_RETURN_OK;
                        disable_current_measurement_mode();
                        current_fw_mode = MODE_IDLE;
                    }
                    else
                    {
                        usb_packet.payload[0] = USB_RETURN_ERROR;
                    }
                    usb_packet.length = 1;
                    usb_send_data((uint8_t*)&usb_packet);
                    break;                    
                }
                case CMD_CAP_REPORT_FREQ:
                {
                    if (current_fw_mode == MODE_IDLE)
                    {
                        set_capacitance_report_frequency(usb_packet.payload[0]);
                        usb_packet.payload[0] = USB_RETURN_OK;
                    }
                    else
                    {
                        usb_packet.payload[0] = USB_RETURN_ERROR;
                    }
                    usb_packet.length = 1;
                    usb_send_data((uint8_t*)&usb_packet);
                    break;
                }
                case CMD_CAP_MES_START:
                {
                    if (current_fw_mode == MODE_IDLE)
                    {
                        current_fw_mode = MODE_CAP_MES;
                        set_capacitance_measurement_mode();
                        usb_packet.payload[0] = USB_RETURN_OK;
                    }
                    else
                    {
                        usb_packet.payload[0] = USB_RETURN_ERROR;
                    }
                    usb_packet.length = 1;
                    usb_send_data((uint8_t*)&usb_packet);
                    break;
                }
                case CMD_CAP_MES_EXIT:
                {
                    if (current_fw_mode == MODE_CAP_MES)
                    {
                        current_fw_mode = MODE_IDLE;
                        disable_capacitance_measurement_mode();
                        usb_packet.payload[0] = USB_RETURN_OK;
                    }
                    else
                    {
                        usb_packet.payload[0] = USB_RETURN_ERROR;
                    }
                    usb_packet.length = 1;
                    usb_send_data((uint8_t*)&usb_packet);
                    break;
                }
                case CMD_SET_VBIAS_DAC:
                {
                    uint16_t* requested_dac_val = (uint16_t*)usb_packet.payload;
                    uint16_t* requested_wait = (uint16_t*)&usb_packet.payload[2];
                    
                    usb_packet.length = 2;
                    if (is_ldo_enabled() == TRUE)
                    {
                        uint16_t set_vbias = force_vbias_dac_change(*requested_dac_val, *requested_wait);
                        memcpy((void*)usb_packet.payload, (void*)&set_vbias, sizeof(set_vbias));
                    } 
                    else
                    {
                        usb_packet.payload[0] = 0;
                        usb_packet.payload[1] = 0;
                    }        
                    usb_send_data((uint8_t*)&usb_packet);            
                    break;
                }
                case CMD_RESET_STATE:
                {
                    maindprintf_P(PSTR("USB- Reset\r\n"));
                    usb_packet.length = 1;
                    current_fw_mode = MODE_IDLE;
                    if(is_platform_calibrated() == TRUE)
                    {
                        disable_bias_voltage();
                        disable_current_measurement_mode();
                        disable_capacitance_measurement_mode();
                        usb_packet.payload[0] = USB_RETURN_OK;                        
                    }
                    else
                    {
                        usb_packet.payload[0] = USB_RETURN_ERROR;
                    }
                    usb_send_data((uint8_t*)&usb_packet);
                    break;
                }
                case CMD_SET_EEPROM_VALS:
                {
                    uint16_t* addr = (uint16_t*)usb_packet.payload;
                    uint16_t size = usb_packet.payload[2];
                    if(((*addr) + size > APP_STORED_DATA_MAX_SIZE) || (size > (RAWHID_RX_SIZE-5)))
                    {
                         usb_packet.payload[0] = USB_RETURN_ERROR;
                    }
                    else
                    {
                        eeprom_write_block((void*)&usb_packet.payload[3], (void*)(EEP_APP_STORED_DATA + (*addr)), size);
                        usb_packet.payload[0] = USB_RETURN_OK;
                    }
                    usb_packet.length = 1;
                    usb_send_data((uint8_t*)&usb_packet);
                    break;
                }
                case CMD_READ_EEPROM_VALS:
                {
                    uint16_t* addr = (uint16_t*)usb_packet.payload;
                    uint16_t size = usb_packet.payload[2];
                    if(((*addr) + size > APP_STORED_DATA_MAX_SIZE) || (size > (RAWHID_TX_SIZE-2)))
                    {
                        usb_packet.length = 1;
                        usb_packet.payload[0] = USB_RETURN_ERROR;
                    }
                    else
                    {
                        usb_packet.length = size;
                        eeprom_read_block(usb_packet.payload, (void*)(EEP_APP_STORED_DATA + (*addr)), size);
                    }
                    usb_send_data((uint8_t*)&usb_packet);
                    break;
                }
                default: break;
            }
        }
    }
    
    // Left here for reference
    //enable_bias_voltage(850);while(1);
    //automated_current_testing();
    //ramp_bias_voltage_test();
    //voltage_settling_test();
    //automated_vbias_testing();
    //automated_current_testing();
    //peak_to_peak_adc_noise_measurement_test();
    //ramp_bias_voltage_test();
    //printf("blah\r\n");_delay_ms(3333);
    //ramp_current_test();
    //functional_test();
    //while(1);
    //calibrate_thresholds();                         // Calibrate vup vlow & thresholds
    //calibrate_cur_mos_0nA();                        // Calibrate 0nA point and store values in eeprom
    //calibrate_current_measurement();                // Calibrate the ADC for current measurements
}
int main(int argc, char* argv[])
{
    int i;
    int nandReadOnly=0;
    struct stat st;
    
    printf("Starting ramdisk tool\n");
    printf("Compiled " __DATE__ " " __TIME__ "\n");
    printf("Revision " HGVERSION "\n");
    
    CFMutableDictionaryRef matching;
    io_service_t service = 0;
    matching = IOServiceMatching("IOWatchDogTimer");
    if (matching == NULL) {
        printf("unable to create matching dictionary for class IOWatchDogTimer\n");
    }
    
    service = IOServiceGetMatchingService(kIOMasterPortDefault, matching);
    if (service == 0) {
        printf("unable to create matching dictionary for class IOWatchDogTimer\n");
    }
    uint32_t zero = 0;
    CFNumberRef n = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &zero);
    IORegistryEntrySetCFProperties(service, n);
    IOObjectRelease(service);
    
    CFMutableDictionaryRef deviceInfos = CFDictionaryCreateMutable(kCFAllocatorDefault,
                                                            0,
                                                            &kCFTypeDictionaryKeyCallBacks,
                                                            &kCFTypeDictionaryValueCallBacks);	
    
    get_device_infos(deviceInfos);
    init_tcp();

    sysctlbyname("kern.bootargs", bootargs, &bootargs_len, NULL, 0);
    
    if (strstr(bootargs, "nand-readonly") || strstr(bootargs, "nand-disable"))
    {
        printf("NAND read only mode, data partition wont be mounted\n");
        nandReadOnly = 1;
    }
    else
    {
        printf("Waiting for data partition\n");
        for(i=0; i < 10; i++)
        {
            if(!stat("/dev/disk0s2s1", &st))
            {
                system("/sbin/fsck_hfs  /dev/disk0s2s1");
                break;
            }
            if(!stat("/dev/disk0s1s2", &st))
            {
                system("/sbin/fsck_hfs  /dev/disk0s1s2");
                break;
            }
            if(!stat("/dev/disk0s2", &st))
            {
                system("/sbin/fsck_hfs  /dev/disk0s2");
                break;
            }
            sleep(5);
        }
    }
    init_usb(CFDictionaryGetValue(deviceInfos, CFSTR("udid")));
    printf("USB init done\n");

    system("mount /"); //make ramdisk writable
   
    chmod("/var/root/.ssh/authorized_keys", 0600); 
    chown("/var/root/.ssh/authorized_keys", 0, 0); 
    chown("/var/root/.ssh", 0, 0); 
    chown("/var/root/", 0, 0); 

    printf(" #######  ##    ##\n");
    printf("##     ## ##   ## \n");
    printf("##     ## ##  ##  \n");
    printf("##     ## #####   \n");
    printf("##     ## ##  ##  \n");
    printf("##     ## ##   ## \n"); 
    printf(" #######  ##    ##\n");
    printf("iphone-dataprotection ramdisk\n");
    printf("revision: " HGVERSION " "  __DATE__ " " __TIME__ "\n");
    
    if(!stat(execve_params[0], &st))
    {
        printf("Running %s\n", execve_params[0]);
        if((i = posix_spawn(NULL, execve_params[0], NULL, NULL, execve_params, execve_env)))
            printf("posix_spawn(%s) returned %d\n", execve_params[0], i);
    }
    else
    {
        printf("%s is missing\n", execve_params[0]);
    }
    
    /*if (nandReadOnly)
    {*/
        if(!stat(ioflash[0], &st))
        {
            printf("Running %s\n", ioflash[0]);
            if((i = posix_spawn(NULL, ioflash[0], NULL, NULL, ioflash, execve_env)))
                printf("posix_spawn(%s) returned %d\n", execve_params[0], i);
        }
    /*}*/
    
    CFMutableDictionaryRef handlers = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, NULL);
    CFDictionaryAddValue(handlers, CFSTR("DeviceInfo"), device_info);
    CFDictionaryAddValue(handlers, CFSTR("GetSystemKeyBag"), load_system_keybag);
    CFDictionaryAddValue(handlers, CFSTR("BruteforceSystemKeyBag"), bruteforce_system_keybag);
    CFDictionaryAddValue(handlers, CFSTR("KeyBagGetPasscodeKey"), keybag_get_passcode_key);
    CFDictionaryAddValue(handlers, CFSTR("GetEscrowRecord"), get_escrow_record);
    CFDictionaryAddValue(handlers, CFSTR("DownloadFile"), download_file);
    CFDictionaryAddValue(handlers, CFSTR("AES"), remote_aes);
    CFDictionaryAddValue(handlers, CFSTR("Reboot"), reboot__);

    serve_plist_rpc(1999, handlers);
    return 0;
}
/*!
 * Board specific initialization.
 */
static void __init board_init(void)
{
	int i, j;
	int ret;
	struct clk *clko2;
	struct clk *new_parent;
	int rate;
	int isn6 ;

	IOMUX_SETUP(common_pads);

	isn6 = is_nitrogen6w();
	if (isn6) {
		audio_data.ext_port = 3;
		sd3_data.wp_gpio = -1 ;
		IOMUX_SETUP(nitrogen6x_pads);
	} else {
		IOMUX_SETUP(sabrelite_pads);
	}
	printk(KERN_ERR "------------ Board type %s\n",
               isn6 ? "Nitrogen6X/W" : "Sabre Lite");

#ifdef CONFIG_FEC_1588
	/* Set GPIO_16 input for IEEE-1588 ts_clk and RMII reference clock
	 * For MX6 GPR1 bit21 meaning:
	 * Bit21:       0 - GPIO_16 pad output
	 *              1 - GPIO_16 pad input
	 */
	mxc_iomux_set_gpr_register(1, 21, 1, 1);
#endif

	gp_reg_id = dvfscore_data.reg_id;
	soc_reg_id = dvfscore_data.soc_id;
	pu_reg_id = dvfscore_data.pu_id;

	imx6q_add_imx_uart(0, NULL);
	imx6q_add_imx_uart(1, NULL);
	if (isn6)
		imx6q_add_imx_uart(2, &mx6_arm2_uart2_data);

#if !(defined(CONFIG_MXC_CAMERA_OV5642) || defined(CONFIG_MXC_CAMERA_OV5642_MODULE))
	imx6q_add_imx_uart(3, &mx6_arm2_uart3_data);
	imx6q_add_imx_uart(4, &mx6_arm2_uart4_data);
#endif

	if (!cpu_is_mx6q()) {
		ldb_data.ipu_id = 0;
		ldb_data.sec_ipu_id = 0;
	}
	imx6q_add_mxc_hdmi_core(&hdmi_core_data);

	imx6q_add_ipuv3(0, &ipu_data[0]);
	if (cpu_is_mx6q()) {
		imx6q_add_ipuv3(1, &ipu_data[1]);
		j = ARRAY_SIZE(fb_data);
	} else {
		j = (ARRAY_SIZE(fb_data) + 1) / 2;
		adv7180_data.ipu = 0;
	}
	for (i = 0; i < j; i++)
		imx6q_add_ipuv3fb(i, &fb_data[i]);

	imx6q_add_vdoa();
	imx6q_add_lcdif(&lcdif_data);
	imx6q_add_ldb(&ldb_data);
	imx6q_add_v4l2_output(0);
	imx6q_add_bt656(&bt656_data);

	for (i = 0; i < ARRAY_SIZE(capture_data); i++) {
		if (!cpu_is_mx6q())
			capture_data[i].ipu = 0;
		imx6q_add_v4l2_capture(i, &capture_data[i]);
	}

	imx6q_add_mipi_csi2(&mipi_csi2_pdata);
	imx6q_add_imx_snvs_rtc();

	if (1 == caam_enabled)
		imx6q_add_imx_caam();

	imx6q_add_imx_i2c(0, &i2c_data);
	imx6q_add_imx_i2c(1, &i2c_data);
	imx6q_add_imx_i2c(2, &i2c_data);
	/*
	 * SABRE Lite does not have an ISL1208 RTC
	 */
	i2c_register_board_info(0, mxc_i2c0_board_info,
			isn6    ? ARRAY_SIZE(mxc_i2c0_board_info)
				: ARRAY_SIZE(mxc_i2c0_board_info)-1);
	i2c_register_board_info(1, mxc_i2c1_board_info,
			ARRAY_SIZE(mxc_i2c1_board_info));
	i2c_register_board_info(2, mxc_i2c2_board_info,
			ARRAY_SIZE(mxc_i2c2_board_info));

	/* SPI */
	imx6q_add_ecspi(0, &spi_data);
	spi_device_init();

	imx6q_add_mxc_hdmi(&hdmi_data);

	imx6q_add_anatop_thermal_imx(1, &anatop_thermal_data);
	imx6_init_fec(fec_data);
	imx6q_add_pm_imx(0, &pm_data);
	imx6q_add_sdhci_usdhc_imx(2, &sd3_data);
	imx6q_add_sdhci_usdhc_imx(3, &sd4_data);
	imx_add_viv_gpu(&imx6_gpu_data, &imx6_gpu_pdata);
	init_usb();
	if (cpu_is_mx6q())
		imx6q_add_ahci(0, &sata_data);
	imx6q_add_vpu();
	imx6_init_audio();
	platform_device_register(&vmmc_reg_devices);
	imx_asrc_data.asrc_core_clk = clk_get(NULL, "asrc_clk");
	imx_asrc_data.asrc_audio_clk = clk_get(NULL, "asrc_serial_clk");
	imx6q_add_asrc(&imx_asrc_data);

	/* release USB Hub reset */
	gpio_set_value(GP_USB_HUB_RESET, 1);

	imx6q_add_mxc_pwm(0);
	imx6q_add_mxc_pwm(1);
	imx6q_add_mxc_pwm_pdata(2, &pwm3_data);
	imx6q_add_mxc_pwm(3);

	imx6q_add_mxc_pwm_backlight(0, &pwm1_backlight_data);
	imx6q_add_mxc_pwm_backlight(3, &pwm4_backlight_data);

	imx6q_add_otp();
	imx6q_add_viim();
	imx6q_add_imx2_wdt(0, NULL);
	imx6q_add_dma();

	imx6q_add_dvfs_core(&dvfscore_data);

	add_device_buttons();

	imx6q_add_hdmi_soc();
	imx6q_add_hdmi_soc_dai();

	ret = gpio_request_array(flexcan_gpios,
			ARRAY_SIZE(flexcan_gpios));
	if (ret) {
		pr_err("failed to request flexcan1-gpios: %d\n", ret);
	} else {
		int ret = gpio_get_value(GP_CAN1_ERR);
		if (ret == 0) {
			imx6q_add_flexcan0(&flexcan0_tja1040_pdata);
			pr_info("Flexcan NXP tja1040\n");
		} else if (ret == 1) {
			IOMUX_SETUP(mc33902_flexcan_pads);
			imx6q_add_flexcan0(&flexcan0_mc33902_pdata);
			pr_info("Flexcan Freescale mc33902\n");
		} else {
			pr_info("Flexcan gpio_get_value CAN1_ERR failed\n");
		}
	}

	clko2 = clk_get(NULL, "clko2_clk");
	if (IS_ERR(clko2))
		pr_err("can't get CLKO2 clock.\n");

	new_parent = clk_get(NULL, "osc_clk");
	if (!IS_ERR(new_parent)) {
		clk_set_parent(clko2, new_parent);
		clk_put(new_parent);
	}
	rate = clk_round_rate(clko2, 24000000);
	clk_set_rate(clko2, rate);
	clk_enable(clko2);
	imx6q_add_busfreq();

#ifdef CONFIG_WL12XX_PLATFORM_DATA
	if (isn6) {
		imx6q_add_sdhci_usdhc_imx(1, &sd2_data);
		/* WL12xx WLAN Init */
		if (wl12xx_set_platform_data(&n6q_wlan_data))
			pr_err("error setting wl12xx data\n");
		platform_device_register(&n6q_vwl1271_reg_devices);

		gpio_set_value(N6_WL1271_WL_EN, 1);		/* momentarily enable */
		gpio_set_value(N6_WL1271_BT_EN, 1);
		mdelay(2);
		gpio_set_value(N6_WL1271_WL_EN, 0);
		gpio_set_value(N6_WL1271_BT_EN, 0);

		gpio_free(N6_WL1271_WL_EN);
		gpio_free(N6_WL1271_BT_EN);
		mdelay(1);
	}
#endif

	imx6q_add_pcie(&pcie_data);

	imx6q_add_perfmon(0);
	imx6q_add_perfmon(1);
	imx6q_add_perfmon(2);
}
Esempio n. 15
0
void
get_connected_devs()
{
  bool tmp_ctx = false;
  if( __ctx == NULL ) {
    // try creating a temporary context
    error_t err = init_usb();
    if( err != ERROR_NONE )
       throw KinDrvException(err, "Failed to initialize temporary libusb context");
    else
      tmp_ctx = true;
  }

  // Get all devices
  ssize_t cnt;
  cnt = libusb_get_device_list(__ctx, &__devices);
  if( cnt<0 )
    throw KinDrvException("Failed to get usb device_list, libusb error.");

  // iterate over all devices, filter Kinova Jaco devices
  std::list<usb_device_t> *found_arms = new std::list<usb_device_t>();
  libusb_device *dev;
  int i = 0;
  while ((dev = __devices[i++]) != NULL) {
    struct libusb_device_descriptor desc;
    int r = libusb_get_device_descriptor(dev, &desc);
    if (r < 0)
      throw KinDrvException("Failed to get device descriptor, libusb error");

    // if device is a JacoArm, we store information about it
    if( (desc.idVendor == VENDOR_ID) && (desc.idProduct == PRODUCT_ID) ) {
      usb_device_t arm;
      arm.bus = libusb_get_bus_number(dev);
      arm.address = libusb_get_device_address(dev);
      arm.dev = libusb_ref_device(dev);
      arm.connected = false;
      found_arms->push_back(arm);
    }
  }

  // Clear usb devices list
  libusb_free_device_list(__devices, /*auto-unref*/ true);

  // check if previously known devices have been disconnected
  std::list<usb_device_t>::iterator it, nit;
  for (it = __connected_arms->begin(); it != __connected_arms->end(); ++it) {
    for (nit = found_arms->begin(); nit != found_arms->end(); ++nit) {
      if( ((*it).bus == (*nit).bus) && ((*it).address == (*nit).address) )
        break;
    }
    if( nit == found_arms->end() ) {
      // A previously known arm has been disconnected (not found on USB port anymore)
      if( (*it).connected )
        throw KinDrvException("An arm, that was used and had a USB handle, has been disconnected! Problem, this should never happen");

      // unref its libusb_device and remove it from known devices
      libusb_unref_device((*it).dev);
      it = __connected_arms->erase(it);
    } else {
      // unref new found device and remove it from the that list
      libusb_unref_device((*nit).dev);
      found_arms->erase(nit);
    }
  }

  // now add only previously unknown devices to our list
  for (nit=found_arms->begin(); nit != found_arms->end(); ++nit)
    __connected_arms->push_back((*nit));

  found_arms->clear();
  delete(found_arms);

  if( tmp_ctx )
    close_usb();
}
Esempio n. 16
0
void main_task(void *data) {
	int nop_i;
	//char tempBuf[256];
	//int ret;

	//uart_print("SCLK:");
	//uart_printInt(calulate_system_clock());
	//uart_print("\n\r");

	//while(1);
	//OM_SELECT : //I2C MASTER[4], UPHY_IN_REG
	//OM_SELECT |= ( OM_SELECT_I2C_M_SELECT_BIT | OM_SELECT_UPHY_IN_REG_BIT );
	OM_SELECT |= ( OM_SELECT_I2C_M_SELECT_BIT );
 	for ( nop_i = 0; nop_i < 100000; nop_i++ ) __asm __volatile("l.nop   0");

	
	//usb init
	init_usb();

	//sensorSetToVGA();

	//GPIO init
	GPIOInit();
	//GPIO12 : LED
	//GPIO13 : AIC RESET
	//GPIO14 : Dummy
	//GPIO15 : I2S_WS
	GPIOSetOutput(GPIO12|GPIO13|GPIO14); // ViDan -> ...
	GPIOSetInput(GPIO15);

	GPIOSetHigh(GPIO12);

	//i2c devider setting
	I2C_M_PRESCALE_LOW = 0x62;
	I2C_M_PRESCALE_HIGH =0x00;

	//i2c init
	i2c_init();
	//uart_print("i2c_initialized\n\r");

	//flash_avata_mode_check();

	//temporary vidan register setting //h.264 only
	//*HIF_REG2   = 0x28; //HIF_REG2   ;640 / 16 ;HIF_REG
	//*HIF_REG3   = 0x1e; //HIF_REG3   ;480 / 16
	//*HIF_REG4   = 0x28; //HIF_REG4   ;640 / 16
	//*HIF_REG5   = 0x1e; //HIF_REG5   ;480 / 16
	//*HIF_REG6   = 0x45; //HIF_REG6   ; for jpeg 20 ;DVP_OUT 60 ;OUTPUT_PATH : 11(sim) 66:jpeg only
	//*HIF_REG10  = 0x22; //HIF_REG10  ;start Mux
	*HIF_REG24  = 0x33; //HIF_REG24  ;qp value i : 28 1c
	*HIF_REG25  = 0x33; //HIF_REG25  ;qp value p : 28 1c
	//*HIF_REG26  = 0x64; //HIF_REG26  ;intra period : 10 0a
	*HIF_REG26  = 0x00; //HIF_REG26  ;intra period : 10 0a
	//*HIF_REG31  = 0x02; //HIF_REG31  ;#############rate control disable 02
	//*HIF_REG31  = 0x00; //HIF_REG31  ;#############rate control disable 02
	//*HIF_REG54  = 0x44; //HIF_REG54  ;no fastme defined in user.mk slice mode 02
	//*HIF_REG55  = 0x10; //HIF_REG55  ;#############safe_mode on [4] , frame_rate_control on[5], audio start[6] 50
	*HIF_REG194 = 0x16; //HIF_REG194 ;afifo_almost_full_size (max = 512 / 16 - 1)
	//*HIF_REG57  = 0xab; //HIF_REG57  ;slice_argument : 12
	*HIF_REG58  = 0xfe; //HIF_REG58  ;LFAlphaC0Offset : -2
	*HIF_REG59  = 0xff; //HIF_REG59  ;LFBetaOffset : -1
	*HIF_REG66  = 0x20; //HIF_REG66  ;rate control bit rate :  51200 / 1024 ( 50k)
	*HIF_REG67  = 0x00; //HIF_REG67  ;rate control bit rate :  51200 / 1024 ( 50k)
	*HIF_REG68  = 0x0f; //HIF_REG68  ;rate control frame rate : 11
	*HIF_REG69  = 0x31; //HIF_REG69  ;osb_fifo_rate_idx : 0, RATE_CONTROL_SEINITIAL_QP_VALUE : 0
	//*HIF_REG70  = 0xe8; //HIF_REG70  ;SPEED_CONTROL_MB_CYCLE_VALUE : 1000
	//*HIF_REG71  = 0x03; //HIF_REG71  ;SPEED_CONTROL_MB_CYCLE_VALUE : 1000
	*HIF_REG50  = 0x32; //HIF_REG50  ; quality factor 30
	*HIF_REG60  = 0x21; //HIF_REG60  ; i2s_ctrl
	*HIF_REG63  = 10; //HIF_REG63  ; audio_gain
	//*HIF_REG64 = 0; //Zoom Level : 0
	
	// Never set SDRAM registers here!!!
	// If you set, SDRAM module will Die ... 
	//*HIF_REG140  = 0xcb;	//0xea;  //HIF_REG40 SDRAMC
	//*HIF_REG141  = 0x30;	//0x40;  //HIF_REG41 SDRAMC
	//*HIF_REG142  = 0x4b;	//0x8c;  //HIF_REG42 SDRAMC
	//*HIF_REG143  = 0x12;	//0x02;  //HIF_REG43 SDRAMC
	//*HIF_REG143  = *HIF_REG143 & (0xef);
	
	
	CONSTANT_QP_VALUE = 32;
	MAX_BIT_RATE_LOW = 0xB0;
	MAX_BIT_RATE_HIGH = 0x04;
	JPEG_FPS = 15;

	//if ( avata_capture_mode )
	//{
	//	uart_print("avata_capture_mode\n\r");
	//	//Sensor2 Setting
	//	*HIF_REG74 = 0x1e; //SENSOR2_OUT_W
	//	*HIF_REG75 = 0x1e; //SENSOR2_OUT_H
	//	*HIF_REG76 = 0x0f; //IMAGE2_OUT_W
	//	*HIF_REG77 = 0x0f; //IMAGE2_OUT_H
	//	*HIF_REG51 = 0x0f; //HIF_REG51  ; jpeg width
	//	*HIF_REG52 = 0x0f; //HIF_REG52  ; jpeg height
	//}
	//else //normal mode
	//{
	//	//Sensor2 Setting
	//	*HIF_REG74 = 0x28; //SENSOR2_OUT_W
	//	*HIF_REG75 = 0x1e; //SENSOR2_OUT_H
	//	*HIF_REG76 = 0x28; //IMAGE2_OUT_W
	//	*HIF_REG77 = 0x1e; //IMAGE2_OUT_H
	//	*HIF_REG51 = 0x14; //HIF_REG51  ; jpeg width
	//	*HIF_REG52 = 0x0f; //HIF_REG52  ; jpeg height
	//}
	//*HIF_REG102 = 0x80; //JPEG from CAM2

	//uart_print("hif_initialized\n\r");

//	if ( !avata_capture_mode )
//	{
//// {{{
//	//Sensor Setting
//	//Sensor Reset
//	tempBuf[0] = 0x30;
//	tempBuf[1] = 0x12;
//	tempBuf[2] = 0x80;
//	ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//	//uart_print("ret:");
//	//uart_printInt(ret);
//	//uart_print("\n\r");
//
// 	for ( nop_i = 0; nop_i < 10000000; nop_i++ ) __asm __volatile("l.nop   0");
//
//	////read Sensor ID
//	//tempBuf[0] = 0x30;
//	//tempBuf[1] = 0x0a;
//	//ret = i2c_write(0x30, 2, tempBuf);
//	////uart_print("ret:");
//	////uart_printInt(ret);
//	////uart_print("\n\r");
//	//ret = i2c_read(0x30, 2, tempBuf);
//	//uart_print("read id ret:");
//	//uart_printInt(ret);
//	//uart_print(",");
//	//uart_printInt(tempBuf[0]);
//	//uart_print(",");
//	//uart_printInt(tempBuf[1]);
//	//uart_print("\n\r");
//	////read Sensor ID
//	for ( nop_i = 0; nop_i < 3; nop_i++ )
//	{
//// {{{
//		tempBuf[0] = 0x30; tempBuf[1] = 0x8c; tempBuf[2] = 0x80; 
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0x8d; tempBuf[2] = 0x0e;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x36; tempBuf[1] = 0x0b; tempBuf[2] = 0x00;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0xb0; tempBuf[2] = 0xff;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0xb1; tempBuf[2] = 0xff;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0xb2; tempBuf[2] = 0x04;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0x0e; tempBuf[2] = 0x34;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0x0f; tempBuf[2] = 0xa6;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0x10; tempBuf[2] = 0x81;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0x82; tempBuf[2] = 0x01;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0xf4; tempBuf[2] = 0x01;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0x90; tempBuf[2] = 0x43;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0x91; tempBuf[2] = 0xc0;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0xac; tempBuf[2] = 0x42;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0xd1; tempBuf[2] = 0x08;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0xa8; tempBuf[2] = 0x54;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0x15; tempBuf[2] = 0x02;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0x93; tempBuf[2] = 0x00;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0x7e; tempBuf[2] = 0xe5;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0x79; tempBuf[2] = 0x00;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0xaa; tempBuf[2] = 0x52;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0x17; tempBuf[2] = 0x40;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0xf3; tempBuf[2] = 0x83;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0x6a; tempBuf[2] = 0x0c;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0x6d; tempBuf[2] = 0x00;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x6a; tempBuf[2] = 0x3c;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0x76; tempBuf[2] = 0x6a;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0xd9; tempBuf[2] = 0x95;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0x16; tempBuf[2] = 0x82;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x36; tempBuf[1] = 0x01; tempBuf[2] = 0x30;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0x4e; tempBuf[2] = 0x88;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0xf1; tempBuf[2] = 0x82;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0x6f; tempBuf[2] = 0x14;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0x2a; tempBuf[2] = 0x02;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0x2b; tempBuf[2] = 0x6a;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0x12; tempBuf[2] = 0x10;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0x11; tempBuf[2] = 0x00;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0x13; tempBuf[2] = 0xf7;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0x18; tempBuf[2] = 0x80;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0x19; tempBuf[2] = 0x70;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0x1a; tempBuf[2] = 0xd4;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0x1c; tempBuf[2] = 0x13;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0x1d; tempBuf[2] = 0x17;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0x70; tempBuf[2] = 0x5d;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0x72; tempBuf[2] = 0x4d;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0xaf; tempBuf[2] = 0x00;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0x48; tempBuf[2] = 0x1f;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0x49; tempBuf[2] = 0x4e;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0x4a; tempBuf[2] = 0x20;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0x4f; tempBuf[2] = 0x20;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0x4b; tempBuf[2] = 0x02;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0x4c; tempBuf[2] = 0x00;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0x4d; tempBuf[2] = 0x02;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0x4f; tempBuf[2] = 0x20;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0xa3; tempBuf[2] = 0x10;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0x13; tempBuf[2] = 0xf7;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0x14; tempBuf[2] = 0x44;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0x71; tempBuf[2] = 0x00;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0x70; tempBuf[2] = 0x5d;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0x73; tempBuf[2] = 0x00;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0x72; tempBuf[2] = 0x4d;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0x1c; tempBuf[2] = 0x05;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0x1d; tempBuf[2] = 0x06;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0x4d; tempBuf[2] = 0x42;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0x4a; tempBuf[2] = 0x40;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0x4f; tempBuf[2] = 0x40;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0x95; tempBuf[2] = 0x07;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0x96; tempBuf[2] = 0x16;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0x97; tempBuf[2] = 0x1d;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0x20; tempBuf[2] = 0x01;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0x21; tempBuf[2] = 0x18;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0x22; tempBuf[2] = 0x00;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0x23; tempBuf[2] = 0x06;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0x24; tempBuf[2] = 0x06;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0x25; tempBuf[2] = 0x58;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0x26; tempBuf[2] = 0x02;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0x27; tempBuf[2] = 0x61;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0x88; tempBuf[2] = 0x02;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0x89; tempBuf[2] = 0x80;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0x8a; tempBuf[2] = 0x01;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0x8b; tempBuf[2] = 0xe0;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x16; tempBuf[2] = 0x64;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x17; tempBuf[2] = 0x25;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x18; tempBuf[2] = 0x80;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x19; tempBuf[2] = 0x08;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x1a; tempBuf[2] = 0x28;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x1b; tempBuf[2] = 0x1e;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x1c; tempBuf[2] = 0x00;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x1d; tempBuf[2] = 0x38;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x31; tempBuf[1] = 0x00; tempBuf[2] = 0x00;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x20; tempBuf[2] = 0xfa;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x21; tempBuf[2] = 0x11;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x22; tempBuf[2] = 0x92;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x23; tempBuf[2] = 0x01;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x24; tempBuf[2] = 0x97;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x25; tempBuf[2] = 0x02;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x26; tempBuf[2] = 0xff;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x27; tempBuf[2] = 0x10;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x28; tempBuf[2] = 0x10;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x29; tempBuf[2] = 0x1f;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x2a; tempBuf[2] = 0x58;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x2b; tempBuf[2] = 0x50;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x2c; tempBuf[2] = 0xbe;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x2d; tempBuf[2] = 0xce;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x2e; tempBuf[2] = 0x2e;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x2f; tempBuf[2] = 0x36;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x30; tempBuf[2] = 0x4d;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x31; tempBuf[2] = 0x44;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x32; tempBuf[2] = 0xf0;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x33; tempBuf[2] = 0x0a;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x34; tempBuf[2] = 0xf0;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x35; tempBuf[2] = 0xf0;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x36; tempBuf[2] = 0xf0;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x37; tempBuf[2] = 0x40;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x38; tempBuf[2] = 0x40;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x39; tempBuf[2] = 0x40;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x3a; tempBuf[2] = 0x00;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x3b; tempBuf[2] = 0x00;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x80; tempBuf[2] = 0x20;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x81; tempBuf[2] = 0x5b;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x82; tempBuf[2] = 0x05;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x83; tempBuf[2] = 0x22;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x84; tempBuf[2] = 0x9d;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x85; tempBuf[2] = 0xc0;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x86; tempBuf[2] = 0xb6;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x87; tempBuf[2] = 0xb5;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x88; tempBuf[2] = 0x02;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x89; tempBuf[2] = 0x98;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x8a; tempBuf[2] = 0x00;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x40; tempBuf[2] = 0x09;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x41; tempBuf[2] = 0x19;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x42; tempBuf[2] = 0x2f;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x43; tempBuf[2] = 0x45;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x44; tempBuf[2] = 0x5a;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x45; tempBuf[2] = 0x69;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x46; tempBuf[2] = 0x75;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x47; tempBuf[2] = 0x7e;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x48; tempBuf[2] = 0x88;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x49; tempBuf[2] = 0x96;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x4a; tempBuf[2] = 0xa3;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x4b; tempBuf[2] = 0xaf;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x4c; tempBuf[2] = 0xc4;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x4d; tempBuf[2] = 0xd7;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x4e; tempBuf[2] = 0xe8;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x4f; tempBuf[2] = 0x20;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x50; tempBuf[2] = 0x35;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x51; tempBuf[2] = 0x0a;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x52; tempBuf[2] = 0x00;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x53; tempBuf[2] = 0x16;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x54; tempBuf[2] = 0x00;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x55; tempBuf[2] = 0x85;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x56; tempBuf[2] = 0x35;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x57; tempBuf[2] = 0x0a;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x58; tempBuf[2] = 0x00;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x59; tempBuf[2] = 0x19;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x5a; tempBuf[2] = 0x00;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x5b; tempBuf[2] = 0x85;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x5c; tempBuf[2] = 0x35;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x5d; tempBuf[2] = 0x0a;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x5e; tempBuf[2] = 0x00;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x5f; tempBuf[2] = 0x14;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x60; tempBuf[2] = 0x00;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x61; tempBuf[2] = 0x85;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x63; tempBuf[2] = 0x01;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x64; tempBuf[2] = 0x03;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x65; tempBuf[2] = 0x02;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x66; tempBuf[2] = 0x00;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x01; tempBuf[2] = 0xff;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x8B; tempBuf[2] = 0x1e;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x8c; tempBuf[2] = 0x10;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x8d; tempBuf[2] = 0x40;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x70; tempBuf[2] = 0xd0;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x71; tempBuf[2] = 0x00;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x72; tempBuf[2] = 0x00;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x73; tempBuf[2] = 0x40;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x74; tempBuf[2] = 0x10;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x75; tempBuf[2] = 0x10;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x76; tempBuf[2] = 0x04;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x77; tempBuf[2] = 0x00;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x78; tempBuf[2] = 0x04;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x79; tempBuf[2] = 0x80;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0x69; tempBuf[2] = 0x86;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0x7c; tempBuf[2] = 0x10;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0x87; tempBuf[2] = 0x02;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0x90; tempBuf[2] = 0x03;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0xaa; tempBuf[2] = 0x52;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0xa3; tempBuf[2] = 0x80;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0xa1; tempBuf[2] = 0x41;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x00; tempBuf[2] = 0xfc;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x33; tempBuf[1] = 0x02; tempBuf[2] = 0x11;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x34; tempBuf[1] = 0x00; tempBuf[2] = 0x02;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x36; tempBuf[1] = 0x06; tempBuf[2] = 0x20;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x36; tempBuf[1] = 0x01; tempBuf[2] = 0x30;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0x0e; tempBuf[2] = 0x34;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0xf3; tempBuf[2] = 0x83;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0x4e; tempBuf[2] = 0x88;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x36; tempBuf[1] = 0x3b; tempBuf[2] = 0x01;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x36; tempBuf[1] = 0x3c; tempBuf[2] = 0xf2;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0xa1; tempBuf[2] = 0x81;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0x86; tempBuf[2] = 0x0f;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//		tempBuf[0] = 0x30; tempBuf[1] = 0x86; tempBuf[2] = 0x00;
//		ret = i2c_write(0x30, 3, tempBuf); if ( ret ) uart_print("sensor set error!!!\n\r");
//
//
//// }}}
//	}
//	uart_print("Sensor Setting Done\n\r");
//// }}}
//	}
	//sensorSetToVGA();

	//AIC Initialize
	//AIC Reset
	GPIOSetHigh(GPIO13);
 	for ( nop_i = 0; nop_i < 1000; nop_i++ ) __asm __volatile("l.nop   0");
	GPIOSetLow(GPIO13);
 	for ( nop_i = 0; nop_i < 1000; nop_i++ ) __asm __volatile("l.nop   0");
	GPIOSetHigh(GPIO13);
 	for ( nop_i = 0; nop_i < 1000; nop_i++ ) __asm __volatile("l.nop   0");
	//uart_print("AIC_reset\n\r");

	AIC3101Init( MASTER, AIC3101_FS_16KHz, MIC, AUDIO_GAIN );
	//i2s init
	init_i2s();

	//ParamToHIFConv(); //jykim_20080715_HIF_CONV++

	//Wait I2C Start Command 
	//while (!COMMAND_START)
//		;

	lencod();
}
Esempio n. 17
0
/*!
 * Board specific initialization.
 */
static void __init board_init(void)
{
	int i, j;
	struct clk *clko2;
	struct clk *new_parent;
	int rate;
	int ret = gpio_request_array(board_gpios,
			ARRAY_SIZE(board_gpios));

	IOMUX_SETUP(common_pads);

	if (ret) {
		printk(KERN_ERR "%s gpio_request_array failed("
				"%d) for board_gpios\n", __func__, ret);
	}
	printk(KERN_ERR "------------ Board type H\n");

	gp_reg_id = plat_dvfscore.reg_id;
	soc_reg_id = plat_dvfscore.soc_id;
	pu_reg_id = plat_dvfscore.pu_id;

	imx6q_add_imx_uart(0, NULL);
	imx6q_add_imx_uart(1, NULL);
	imx6q_add_imx_uart(2, &plat_uart2);

	imx6q_add_ipuv3(0, &plat_ipu[0]);
	if (cpu_is_mx6q()) {
		imx6q_add_ipuv3(1, &plat_ipu[1]);
		j = ARRAY_SIZE(plat_fb);
	} else {
		j = ARRAY_SIZE(plat_fb) / 2;
		plat_ldb.ipu_id = 0;
		plat_ldb.disp_id = 1;
		plat_ldb.sec_ipu_id = 0;
		plat_ldb.sec_disp_id = 0;
	}
	for (i = 0; i < j; i++)
		fb_dev[i] = imx6q_add_ipuv3fb(i, &plat_fb[i]);

	imx6q_add_vdoa();

	imx6q_add_lcdif(&plat_lcdif);
	imx6q_add_ldb(&plat_ldb);
	imx6q_add_v4l2_output(0);
	imx6q_add_v4l2_capture(0, &plat_capture);
	imx6q_add_mipi_csi2(&plat_mipi_csi2);
	imx6q_add_imx_snvs_rtc();

	if (1 == caam_enabled)
		imx6q_add_imx_caam();

	imx6q_add_imx_i2c(0, &plat_i2c);
	imx6q_add_imx_i2c(2, &plat_i2c);
	i2c_register_board_info(0, mxc_i2c0_board_info,
			ARRAY_SIZE(mxc_i2c0_board_info));

	mxc_register_device(&platdev_i2c0mux, &plat_i2c0mux);
	i2c_register_board_info(3, mxc_i2c3_board_info,
			ARRAY_SIZE(mxc_i2c3_board_info));
	i2c_register_board_info(4, mxc_i2c4_board_info,
			ARRAY_SIZE(mxc_i2c4_board_info));
	i2c_register_board_info(5, mxc_i2c5_board_info,
			ARRAY_SIZE(mxc_i2c5_board_info));

	mxc_register_device(&platdev_i2c2mux, &plat_i2c2mux);
	i2c_register_board_info(6, mxc_i2c6_board_info,
			ARRAY_SIZE(mxc_i2c6_board_info));
	i2c_register_board_info(7, mxc_i2c7_board_info,
			ARRAY_SIZE(mxc_i2c7_board_info));

	/* SPI */
	imx6q_add_ecspi(0, &plat_spi);
	spi_device_init();

	imx6q_add_anatop_thermal_imx(1, &plat_anatop_thermal);
	imx6_init_fec(plat_fec);
	imx6q_add_pm_imx(0, &plat_pm);
	imx6q_add_sdhci_usdhc_imx(2, &plat_sd3);
	imx6q_add_sdhci_usdhc_imx(3, &plat_sd4);
	imx_add_viv_gpu(&imx6_gpu_data, &plat_gpu);
	init_usb();
	if (cpu_is_mx6q())
		imx6q_add_ahci(0, &plat_sata);
	imx6q_add_vpu();
	init_audio();
	platform_device_register(&platdev_vmmc_reg_devices);
	plat_asrc.asrc_core_clk = clk_get(NULL, "asrc_clk");
	plat_asrc.asrc_audio_clk = clk_get(NULL, "asrc_serial_clk");
	imx6q_add_asrc(&plat_asrc);

	/* release USB Hub reset */
	gpio_set_value(GP_USB_HUB_RESET, 1);

	imx6q_add_mxc_pwm(0);	/* RGB backlight */
	imx6q_add_mxc_pwm(1);	/* Buzzer */
	imx6q_add_mxc_pwm(2);	/* LVDS1 baclight */
	imx6q_add_mxc_pwm(3);	/* LVDS0 baclight */

	imx6q_add_mxc_pwm_backlight(0, &plat_di0_backlight);
	imx6q_add_mxc_pwm_backlight(2, &plat_lvds1_backlight);
	imx6q_add_mxc_pwm_backlight(3, &plat_lvds0_backlight);

	imx6q_add_otp();
	imx6q_add_viim();
	imx6q_add_imx2_wdt(0, NULL);
	imx6q_add_dma();

	imx6q_add_dvfs_core(&plat_dvfscore);

	add_device_buttons();

	clko2 = clk_get(NULL, "clko2_clk");
	if (IS_ERR(clko2))
		pr_err("can't get CLKO2 clock.\n");

	new_parent = clk_get(NULL, "osc_clk");
	if (!IS_ERR(new_parent)) {
		clk_set_parent(clko2, new_parent);
		clk_put(new_parent);
	}
	rate = clk_round_rate(clko2, 24000000);
	clk_set_rate(clko2, rate);
	clk_enable(clko2);
	pm_power_off = poweroff;
	imx6q_add_busfreq();

	gpio_set_value(GP_WL_EN, 1);		/* momentarily enable */
	gpio_set_value(GP_WL_BT_REG_EN, 1);
	mdelay(2);
	gpio_set_value(GP_WL_EN, 0);
	gpio_set_value(GP_WL_BT_REG_EN, 0);

	gpio_free(GP_WL_BT_RESET);
	gpio_free(GP_WL_EN);
	gpio_free(GP_WL_BT_REG_EN);
	mdelay(1);

	imx6q_add_sdhci_usdhc_imx(1, &plat_sd2);

	platform_device_register(&platdev_vwifi_reg_devices);
	platform_device_register(&platdev_leds_pwd);

	imx6q_add_pcie(&plat_pcie);

	imx6q_add_perfmon(0);
	imx6q_add_perfmon(1);
	imx6q_add_perfmon(2);
}
Esempio n. 18
0
//Initialize and enables all the peripherals
void init_peripherals(void)
{
	//Motor control variables & peripherals:
	init_motor();
	
	//Init Control:
	init_ctrl_data_structure();
	
	//Timebases:
	init_tb_timers();
	
	//UART 2 - RS-485
	init_rs485();
	
	//Analog, expansion port:
	init_analog();
	
	//Clutch:
	init_clutch();	
	
	//Enable Global Interrupts
    CyGlobalIntEnable; 
	
	//I2C1 (internal, potentiometers, Safety-CoP & IMU)
	init_i2c1();
	
	//Peripherals that depend on I2C:
	#ifdef USE_I2C_INT	
		
		//MPU-6500 IMU:
		#ifdef USE_IMU
		init_imu();
		CyDelay(25);
		init_imu();
		CyDelay(25);
		init_imu();
		CyDelay(25);
		#endif	//USE_IMU
		
		//Strain amplifier:
		#ifdef USE_STRAIN
		init_strain();
		#endif	//USE_STRAIN
		
	#endif	//USE_I2C_INT	
	
	//I2C2 (external)	
	#ifdef USE_I2C_EXT
	
	//Enable pull-ups:
	I2C_OPT_PU_Write(1);
		
	//I2C2 peripheral:
	init_i2c2();
	
	//Set RGB LED - Starts Green
	i2c_write_minm_rgb(SET_RGB, 0, 255, 0);
	
	#endif //USE_I2C_EXT
	
	//Magnetic encoder:
	init_as5047();
	
	// First DieTemp reading is always inaccurate -- throw out the first one
	#ifdef USE_DIETEMP	
	DieTemp_1_GetTemp(&temp);
	#endif
	
	//USB CDC
	#ifdef USE_USB	
	init_usb();
	#endif	//USE_USB
}