/*
 * bsp_gpio.c
 *
 *  Created on: 2025年4月8日
 *      Author: 22332
 */
#include "sdk_project_config.h"
#include "cola_init.h"
#include "cola_device.h"
#include"drv_gpio.h"

static cola_device_t g_dev_gpio;






static int bsp_gpio_open(cola_device_t *dev, int oflag){
    bsp_gpio_cfg_input();
    bsp_gpio_cfg_output();
    return 0;
}
static int bsp_gpio_close(cola_device_t *dev){
    return 0;
}


static int bsp_gpio_write(cola_device_t *dev, int pos, const void *buffer, int size){
    bsp_gpio_pin_write(pos,(gpio_pin_level_t)size);
	return 0;
}

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

static struct cola_device_ops GPIO_Ops ={
    .open    = bsp_gpio_open,
    .close   = bsp_gpio_close,
	.write   = bsp_gpio_write,
    .read    = bsp_gpio_read,
    //.control = bsp_gpio_ctrl
};

static void bsp_gpio_configuration(void){
    g_dev_gpio.name = "GPIO";
    g_dev_gpio.dops = &GPIO_Ops;
    cola_device_register(&g_dev_gpio);
}
register_initcall(bsp_gpio_configuration);
