/*
 * bsp_adc.c
 *
 *  Created on: 2025年4月7日
 *      Author: 22332
 */



#include "cola_init.h"
#include "cola_device.h"
#include "drv_adc.h"

static cola_device_t g_dev_adc;

static int bsp_adc_open(cola_device_t *dev, int oflag){
	bsp_drv_adc_init();
    return 0;
}

static int bsp_adc_close(cola_device_t *dev){
    return 0;
}


static int bsp_adc_read(cola_device_t *dev, int pos, void *buffer, int size){
	uint16_t adc_read_vaule;
	switch (pos)
	{
	case 1:
		adc_read_vaule = bsp_drv_adc1_read();//mcu板载热采集
		break;
	case 2:
		adc_read_vaule = bsp_drv_adc2_read();//电池电压采集
		break;
	case 3:
		adc_read_vaule = bsp_drv_adc3_read();//背光温度采集
		break;
	 default:
	    break;
	}


    return adc_read_vaule;
}






static struct cola_device_ops master_adc_Ops ={
    .open   = bsp_adc_open,
    .close  = bsp_adc_close,
    .read   = bsp_adc_read,
};

static void bsp_adc_configuration(void){
	g_dev_adc.name = "DEVICE_ADC";
	g_dev_adc.dops = &master_adc_Ops;
    cola_device_register(&g_dev_adc);
}
register_initcall(bsp_adc_configuration);




