Esempio n. 1
0
void Dx_UninitIO(void)  // Config IO for external device
{

    // Disable adc control logic
    adc_setEnable(FALSE);
    adc_close(ADC_CH_VOLDET_BATTERY);
    adc_close(ADC_CH_VOLDET_KEY1);
    adc_close(ADC_CH_VOLDET_KEY2);
}
Esempio n. 2
0
        void Dx_UninitIO(void)  // Config IO for external device
        {
            // Disable adc control logic
            adc_setEnable(FALSE);
            adc_close(ADC_CH_VOLDET_BATTERY);
            adc_close(ADC_CH_VOLDET_KEY1);
            adc_close(ADC_CH_VOLDET_KEY2);

            // turn off TI 913Q power
            //gpio_clearPin(GPIO_913Q_PCTL);
        }
Esempio n. 3
0
static int boot_rockbox(void)
{
    int rc;
    void (*kernel_entry)(void);

    printf("Mounting disk...");
    rc = disk_mount_all();
    if (rc <= 0)
        error(EDISK,rc, true);

    printf("Loading firmware...");
    rc = load_firmware((unsigned char *)CONFIG_SDRAM_START, BOOTFILE, 0x400000);
    if(rc <= EFILE_EMPTY)
        return rc;
    else
    {
        printf("Starting Rockbox...");
        adc_close(); /* Disable SADC, seems to fix the re-init Rockbox does */

        disable_interrupt();
        kernel_entry = (void*) CONFIG_SDRAM_START;
        kernel_entry();

        return 0; /* Shouldn't happen */
    }
}
Esempio n. 4
0
File: main.c Progetto: L3w1s-L1u/uav
int main( int argc,char *argv[])
{
	int ret = -1;
	while (ret < 0 ){
		ret = poweron_self_check();
	}
	while (get_flying_status() < AIRCRAFT_READY) {
		usleep(500000);
		flying_status_return();
	}
	while (get_flying_status() < AIRCRAFT_TAKEOFF) {
		flying_status_return();
		usleep(40000);
	}
	auto_flying_start();
	while (1) {
		usleep(20000);
		flying_status_return();
	}
	sensor_close();
	adc_close();
	spi_close();
	exit(0);
	return 0;
}
void __exit
nick_adc_exit (void)
{
	adc_close();
	unregister_chrdev(ADC_MAJOR, "nick_adc");
	printk ("module exit\n");
	return ;
}
Esempio n. 6
0
unsigned int io_read_analog(unsigned char port)

{
    unsigned int    result;
    unsigned char   channel;
#ifndef SDCC
    static unsigned char inputs[] = {
	ADC_CH0, ADC_CH1, ADC_CH2, ADC_CH3,
	ADC_CH4, ADC_CH5, ADC_CH6, ADC_CH7,
	ADC_CH8, ADC_CH9, ADC_CH10, ADC_CH11,
	ADC_CH12, ADC_CH13, ADC_CH14, ADC_CH15 };
#endif

    /* Make sure port does not exceed current Analog_ports */
    if ( ! VALID_ANALOG_PORT(port) )
	return OV_BAD_PARAM;

#ifdef SDCC
    result = 0;

    channel = port - 1;

    /*
     *  SDCC generic adc_open() doesn't work for the 8520.  Lots of
     *  stuff missing.
     */
    adc_open8520(channel);

    /* Allow settling time before starting a conversion */
    delay10tcy(10);
    
    adc_conv();
    while ( adc_busy() )
	;
    result = adc_read();
    adc_close();

#else   /* MCC18 */

    channel = inputs[port - 1];

    OpenADC(ADC_FOSC_RC & ADC_RIGHT_JUST & Analog_ports_const,
	  channel & ADC_INT_OFF & ADC_VREFPLUS_VDD & ADC_VREFMINUS_VSS);
    Delay10TCYx(10);
    ConvertADC();
    while (BusyADC())
	;
    ReadADC();
    CloseADC();
    result = (unsigned int)ADRESH << 8 | ADRESL;
#endif

    return result;
}
Esempio n. 7
0
static be_jse_symbol_t * adc_module_handle_cb(be_jse_vm_ctx_t *execInfo, be_jse_symbol_t *var, const char *name){

	if(0 == strcmp(name,"open")){
		return adc_open();
	}
	if(0 == strcmp(name,"read")){
		return adc_read();
	}
	if(0 == strcmp(name,"close")){
		return adc_close();
	}
	return (BE_JSE_FUNC_UNHANDLED);
}
int main()
{
	int ret1,ret2;
	u16 set_timeout;
	u16 get_timeout;

	//环境初始化
	inittest();
	adc_init();

	//测试用例1
	set_timeout = 12;
	ret1 = adc_setwaittime(set_timeout);
	ret2 = adc_getwaittime(&get_timeout);
	assert(((ret1 == 0) && (ret1 == 0) && (set_timeout == get_timeout)),\
			"adc_setwaittime,adc_getwaittime 1 error");

	//测试用例2
	set_timeout = 0xffff;
	ret1 = adc_setwaittime(set_timeout);
	ret2 = adc_getwaittime(&get_timeout);
	assert(((ret1 == 0) && (ret1 == 0) && (set_timeout == get_timeout)),\
			"adc_setwaittime,adc_getwaittime 2 error");

	//测试用例3
	set_timeout = 0;
	ret1 = adc_setwaittime(set_timeout);
	assert(ret1 == -ERR_INVAL,\
			"adc_setwaittime,adc_getwaittime 3 error");

	//测试用例4
	adc_close();
	set_timeout = 12;
	ret1 = adc_setwaittime(set_timeout);
	assert(ret1 == -ERR_NOINIT,\
			"adc_setwaittime,adc_getwaittime 4 error");
	printf("ret1 = %d\r\n",ret1);



	finaltest();
	return 0;
}
Esempio n. 9
0
/* Close the sensor. Usually power off the force the sensor module into sleep mode
 * in the close function 
 */
void light_close( TiLightSensor * light )
{
	adc_close( light->adc );
}