Ejemplo n.º 1
0
static be_jse_symbol_t * adc_open(void){

	int32_t len = -1;
	char * data = NULL;
	int8_t ret = -1;
	int8_t result = -1;
	item_handle_t adc_handle;
	adc_handle.handle = 0xFFFFFFFF;
	be_jse_symbol_t * arg0 = NULL;
	adc_dev_t * adc_device = NULL;
	be_jse_handle_function(0,&arg0,NULL,NULL,NULL);
	if(!arg0 || !symbol_is_string(arg0)){
		goto out;
	}
	
	len = symbol_str_len(arg0);
	data = calloc(1,sizeof(char)*(len+1));
	if(NULL == data){
		goto out;
	}
	symbol_to_str(arg0,data,len);
	
	ret = board_attach_item(MODULE_ADC,data,&adc_handle);
	if(0 != ret){
		be_error("adc","board_attach_item fail!\n");
		goto out;
	}

	be_debug("adc","adc handle:%u\n",adc_handle.handle);
	adc_device = board_get_node_by_handle(MODULE_ADC,&adc_handle);
	if(NULL == adc_device){
		be_error("adc","board_get_node_by_handle fail!\n");
		goto out;
	}
	result =hal_adc_init(adc_device);
out:

	if(NULL != data){
		free(data);
		data = NULL;
	}
	symbol_unlock(arg0);
	if(0 != result){
		board_disattach_item(MODULE_ADC,&adc_handle);
		return new_int_symbol(-1);
	}
	return new_int_symbol(adc_handle.handle);
}
Ejemplo n.º 2
0
void dev_temperature_sensor_init(void)
{
    hal_adc_init();
}