/**
 *file    sys_gpio.c
 *brief   
 * 
 *par     Copyright (c) 2022  Unicmicro Corp., Ltd. All Rights Reserved.
 *author  James
 *date    2023-06-27
 *version 
 * 
 *history 
 *  Date        Note
 *  2018-03-20  Original Creation
 * 
 */

#include "drivers.h"
#include "libc.h"
#include "sys_gpio.h"
#include "sys_pd_hook.h"
#include "sc8002_reg_defs.h"

void sc8002_init()
{

	    drv_gpio_val_set(SC8002_EN,0);
	    drv_gpio_oe_set(SC8002_EN,1);
	    drv_gpio_en_set(SC8002_EN,1);



		drv_gpio_en_set(SC8002_FB_PWM,0);
		drv_gpio_oe_set(SC8002_FB_PWM,1);
		drv_gpio_val_set(SC8002_FB_PWM,0);


	    drv_pwm_init_set(PWM_CHNL,0,SC_PWMHZ100K);
	    drv_pwm_set(PWM_CHNL,0,SC_PWMHZ100K,SC_DEF5V,SC_PWMHZ100K);  //PWM

	    drv_pwm_duty_set(PWM_CHNL,SC_DEF5V,SC_PWMHZ100K);   //
	    drv_pwm_en_set(PWM_CHNL,1);


}


void sc8002_enable(u8_t en)
{

	drv_gpio_val_set(SC8002_EN,en);
}

/*
 * 输入占空比就是电压，电压设置
 */
void sc_setvol(u16_t vol)
{


	drv_pwm_duty_set(PWM_CHNL,vol,SC_PWMHZ100K);
	drv_pwm_en_set(PWM_CHNL,1);
}







