/* Copyright Statement:
 *
 * This software/firmware and related documentation ("AutoChips Software") are
 * protected under relevant copyright laws. The information contained herein is
 * confidential and proprietary to AutoChips Inc. and/or its licensors. Without
 * the prior written permission of AutoChips inc. and/or its licensors, any
 * reproduction, modification, use or disclosure of AutoChips Software, and
 * information contained herein, in whole or in part, shall be strictly
 * prohibited.
 *
 * AutoChips Inc. (C) 2022. All rights reserved.
 *
 * BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
 * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("AUTOCHIPS SOFTWARE")
 * RECEIVED FROM AUTOCHIPS AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER
 * ON AN "AS-IS" BASIS ONLY. AUTOCHIPS EXPRESSLY DISCLAIMS ANY AND ALL
 * WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
 * NONINFRINGEMENT. NEITHER DOES AUTOCHIPS PROVIDE ANY WARRANTY WHATSOEVER WITH
 * RESPECT TO THE SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY,
 * INCORPORATED IN, OR SUPPLIED WITH THE AUTOCHIPS SOFTWARE, AND RECEIVER AGREES
 * TO LOOK ONLY TO SUCH THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO.
 * RECEIVER EXPRESSLY ACKNOWLEDGES THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO
 * OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES CONTAINED IN AUTOCHIPS
 * SOFTWARE. AUTOCHIPS SHALL ALSO NOT BE RESPONSIBLE FOR ANY AUTOCHIPS SOFTWARE
 * RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
 * STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND AUTOCHIPS'S
 * ENTIRE AND CUMULATIVE LIABILITY WITH RESPECT TO THE AUTOCHIPS SOFTWARE
 * RELEASED HEREUNDER WILL BE, AT AUTOCHIPS'S OPTION, TO REVISE OR REPLACE THE
 * AUTOCHIPS SOFTWARE AT ISSUE, OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE
 * CHARGE PAID BY RECEIVER TO AUTOCHIPS FOR SUCH AUTOCHIPS SOFTWARE AT ISSUE.
 */
/******************************************************************************
 * @version: V1.0.0 demo
 ******************************************************************************/

/*!
 *例程说明：
 *1.PWM2模块初始化，将PWM0_CH0，PWM0_CH1,PWM0_CH2,PWM0_CH3,配置为独立通道输出PWM，向上计数模式，频率为1KHZ;CH0占空比20%，CH1占空比50%，CH2占空比60%，CH3占空比70%
 *2.在主循环中，对CH0和CH1输出屏蔽10ms，解除屏蔽10ms;对CH2和CH3软件控制输出电平10ms，解除软件控制10ms
 */

/*!
 * @file main.c
 *
 * @brief This file is main.c.
 *
 */

/* ===========================================  Includes  =========================================== */
#include "pwm.h"
#include "ac780x_gpio.h"
#include "ac780x_pwm_reg.h"
#include "system_ac7802x.h"

/* ============================================  Define  ============================================ */


/* ===========================================  Typedef  ============================================ */


/* ==========================================  Variables  =========================================== */


/* ====================================  Functions declaration  ===================================== */


/* ======================================  Functions define  ======================================== */
/*!
 * @brief   main函数
 *
 * @param   none
 * @return  int
 */
int main(void)
{
    InitDelay();
    InitDebug();

    PWM2_OutputIndependent_Init();

    while (1)
    {
        mdelay(10); /*延时1ms*/
        PWM_SetChannelOutputMask(PWM2, PWM_CH_0, ENABLE);                   /*使能PWM3_CH0的屏蔽功能，该通道输出将变为无效电平 */
        PWM_SetChannelOutputMask(PWM2, PWM_CH_1, ENABLE);                   /*使能PWM3_CH1的屏蔽功能，该通道输出将变为无效电平 */
        PWM_SoftControlChannelLevel(PWM2, PWM_CH_2, PWM_HIGH_LEVEL, ENABLE);/*使能PWM3_CH2的软件控制功能，并设置该通道输出电平为高电平*/
        PWM_SoftControlChannelLevel(PWM2, PWM_CH_3, PWM_LOW_LEVEL, ENABLE); /*使能PWM3_CH4的软件控制功能，并设置该通道输出电平为低电平*/

        mdelay(10);
        PWM_SetChannelOutputMask(PWM2, PWM_CH_0, DISABLE);                 /*关闭PWM3_CH0的屏蔽功能，该通道输出将恢复正常PWM输出 */
        PWM_SetChannelOutputMask(PWM2, PWM_CH_1, DISABLE);                 /*关闭PWM3_CH1的屏蔽功能，该通道输出将恢复正常PWM输出 */
        PWM_SetChannelSoftControl(PWM2, PWM_CH_2, DISABLE);                /*关闭PWM3_CH2的软件控制功能，该通道输出将恢复正常PWM输出 */
        PWM_SetChannelSoftControl(PWM2, PWM_CH_3, DISABLE);                /*关闭PWM3_CH2的软件控制功能，该通道输出将恢复正常PWM输出 */

    }

}

/* =============================================  EOF  ============================================== */
