打印
[开发工具]

HC32L17X_SDK

[复制链接]
774|4
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
sdk, sd, HC, AC
20191023100741xz.rar (8.27 MB)


使用特权

评论回复
沙发
xuanhuanzi|  楼主 | 2019-10-31 22:48 | 只看该作者

使用特权

评论回复
板凳
xuanhuanzi|  楼主 | 2019-10-31 22:49 | 只看该作者
/******************************************************************************
* Copyright (C) 2018, Huada Semiconductor Co.,Ltd All rights reserved.
*
* This software is owned and published by:
* Huada Semiconductor Co.,Ltd ("HDSC").
*
* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND
* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT.
*
* This software contains source code for use with HDSC
* components. This software is licensed by HDSC to be adapted only
* for use in systems utilizing HDSC components. HDSC shall not be
* responsible for misuse or illegal use of this software for devices not
* supported herein. HDSC is providing this software "AS IS" and will
* not be responsible for issues arising from incorrect user implementation
* of the software.
*
* Disclaimer:
* HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE,
* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS),
* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING,
* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED
* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED
* WARRANTY OF NONINFRINGEMENT.
* HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT,
* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT
* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION,
* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR
* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA,
* SAVINGS OR PROFITS,
* EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR
* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED
* FROM, THE SOFTWARE.
*
* This software may be replicated in part or whole for the licensed use,
* with the restriction that this Disclaimer and Copyright notice must be
* included with each copy of this software, whether used in part or whole,
* at all times.
*/
/******************************************************************************/
/** \file main.c
**
** A detailed description is available at
** [url=home.php?mod=space&uid=48136]@link[/url] Sample Group Some description @endlink
**
**   - 2018-05-08  1.0  Lux First version for Device Driver Library of Module.
**
******************************************************************************/

/******************************************************************************
* Include files
******************************************************************************/
#include "gpio.h"

/******************************************************************************
* Local pre-processor symbols/macros ('#define')
******************************************************************************/

/******************************************************************************
* Global variable definitions (declared in header file with 'extern')
******************************************************************************/

/******************************************************************************
* Local type definitions ('typedef')
******************************************************************************/

/******************************************************************************
* Local function prototypes ('static')
******************************************************************************/
static void App_UserKeyInit(void);
static void App_LedInit(void);
  
/******************************************************************************
* Local variable definitions ('static')                                      *
******************************************************************************/

/******************************************************************************
* Local pre-processor symbols/macros ('#define')
******************************************************************************/

/*****************************************************************************
* Function implementation - global ('extern') and local ('static')
******************************************************************************/
/**
******************************************************************************
** \brief  Main function of project
**
** \return uint32_t return value, if needed
**
** This sample
**
******************************************************************************/
int32_t main(void)
{
    ///< 按键端口初始化
    App_UserKeyInit();
   
    ///< LED端口初始化
    App_LedInit();
   
    ///< 打开并配置USER KEY为下降沿中断
    Gpio_EnableIrq(STK_USER_PORT, STK_USER_PIN, GpioIrqFalling);
    ///< 使能端口PORTA系统中断
    EnableNvic(PORTA_IRQn, IrqLevel3, TRUE);
   
    while(1)
    {
        ;
    }
}

///< PortA中断服务函数
void PortA_IRQHandler(void)
{
    if(TRUE == Gpio_GetIrqStatus(STK_USER_PORT, STK_USER_PIN))
    {            
        ///< LED点亮
        Gpio_SetIO(STK_LED_PORT, STK_LED_PIN);
        
        delay1ms(2000);
        
        ///< LED关闭
        Gpio_ClrIO(STK_LED_PORT, STK_LED_PIN);  

        Gpio_ClearIrq(STK_USER_PORT, STK_USER_PIN);   
    }

}  

static void App_UserKeyInit(void)
{
    stc_gpio_cfg_t stcGpioCfg;
   
    ///< 打开GPIO外设时钟门控
    Sysctrl_SetPeripheralGate(SysctrlPeripheralGpio, TRUE);
   
    ///< 端口方向配置->输入
    stcGpioCfg.enDir = GpioDirIn;
    ///< 端口驱动能力配置->高驱动能力
    stcGpioCfg.enDrv = GpioDrvL;
    ///< 端口上下拉配置->无
    stcGpioCfg.enPu = GpioPuDisable;
    stcGpioCfg.enPd = GpioPdDisable;
    ///< 端口开漏输出配置->开漏输出关闭
    stcGpioCfg.enOD = GpioOdDisable;
    ///< 端口输入/输出值寄存器总线控制模式配置->AHB
    stcGpioCfg.enCtrlMode = GpioAHB;
    ///< GPIO IO USER KEY初始化
    Gpio_Init(STK_USER_PORT, STK_USER_PIN, &stcGpioCfg);
}


static void App_LedInit(void)
{
    stc_gpio_cfg_t stcGpioCfg;
   
    ///< 打开GPIO外设时钟门控
    Sysctrl_SetPeripheralGate(SysctrlPeripheralGpio, TRUE);
   
    ///< 端口方向配置->输出(其它参数与以上(输入)配置参数一致)
    stcGpioCfg.enDir = GpioDirOut;
    ///< 端口上下拉配置->下拉
    stcGpioCfg.enPu = GpioPuDisable;
    stcGpioCfg.enPd = GpioPdEnable;
   
    ///< LED关闭
    Gpio_ClrIO(STK_LED_PORT, STK_LED_PIN);
   
    ///< GPIO IO LED端口初始化
    Gpio_Init(STK_LED_PORT, STK_LED_PIN, &stcGpioCfg);
   

}

/******************************************************************************
* EOF (not truncated)
******************************************************************************/


使用特权

评论回复
地板
天灵灵地灵灵| | 2019-10-31 23:48 | 只看该作者
下载学习一下。

使用特权

评论回复
5
天灵灵地灵灵| | 2019-10-31 23:48 | 只看该作者
竟然还有中文注释,给力。

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

172

主题

2200

帖子

3

粉丝