/*
 * bsp_ds90ub948.c
 *
 *  Created on: 2025年4月10日
 *      Author: 22332
 */

#include "cola_init.h"
#include "cola_device.h"
#include "drv_slave_iic.h"



static cola_device_t g_dev_ds90ub948;

static int bsp_ds90ub948_open(cola_device_t *dev, int oflag){

	bsp_drv_slave_iic_init();
    return 0;
}

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


static int bsp_ds90ub948_read(cola_device_t *dev, int pos, void *buffer, int size){
	bsp_drv_slave_iic_read(buffer,size);
    return size;
}

static int  bsp_ds90ub948_write(cola_device_t *dev, int pos, const void *buffer, int size){
	bsp_drv_slave_iic_write(buffer,size);
    return size;
}

static int bsp_ds90ub948_config(cola_device_t *dev, void *args, void *var)
{
    bsp_drv_slave_iic_cfg(args,var);
    return 0;
}

static int bsp_ds90ub948_ctrl(cola_device_t *dev, int cmd, void *args)
{
	if(cmd == 0)
		bsp_drv_slave_iic_ctrl_task(args);
	if(cmd == 1)
		bsp_drv_slave_iic_ctrl_buf(args);
    return 0;
}

static struct cola_device_ops ds90ub948_Ops ={
    .open   = bsp_ds90ub948_open,
    .close  = bsp_ds90ub948_close,
    .read   = bsp_ds90ub948_read,
    .write  = bsp_ds90ub948_write,
	.config = bsp_ds90ub948_config,
	.control= bsp_ds90ub948_ctrl
};

static void bsp_ds90ub948_configuration(void){
    g_dev_ds90ub948.name = "DS90UB948";
    g_dev_ds90ub948.dops = &ds90ub948_Ops;
    cola_device_register(&g_dev_ds90ub948);
}
register_initcall(bsp_ds90ub948_configuration);

