2022-01-10 20:04:48 +08:00
|
|
|
/*
|
|
|
|
* @Description:
|
|
|
|
* @Date: 2022-01-10 17:05:41
|
|
|
|
* @LastEditors: CK.Zh
|
2022-01-11 19:51:25 +08:00
|
|
|
* @LastEditTime: 2022-01-11 16:59:05
|
|
|
|
* @FilePath: /motion_ec/applications/main.c
|
2022-01-10 20:04:48 +08:00
|
|
|
*/
|
2022-01-10 16:20:39 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2021, Huada Semiconductor Co., Ltd.
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*
|
|
|
|
* Change Logs:
|
|
|
|
* Date Author Notes
|
|
|
|
* 2021-09-07 PJQ first version
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* Include files
|
|
|
|
******************************************************************************/
|
|
|
|
#include "board.h"
|
|
|
|
|
|
|
|
#include <rtthread.h>
|
|
|
|
#include <rtdevice.h>
|
|
|
|
|
2022-01-11 19:51:25 +08:00
|
|
|
|
|
|
|
#define LOG_TAG "MAIN"
|
|
|
|
#define LOG_LVL LOG_LVL_DBG
|
|
|
|
#include <ulog.h>
|
|
|
|
|
2022-01-10 16:20:39 +08:00
|
|
|
/*******************************************************************************
|
|
|
|
* Local type definitions ('typedef')
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* Local pre-processor symbols/macros ('#define')
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
/* defined the LED pin: PC9 */
|
2022-01-10 20:04:48 +08:00
|
|
|
|
2022-01-10 16:20:39 +08:00
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* Global variable definitions (declared in header file with 'extern')
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* Local function prototypes ('static')
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* Local variable definitions ('static')
|
|
|
|
******************************************************************************/
|
|
|
|
uint8_t flag;
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* Function implementation - global ('extern') and local ('static')
|
|
|
|
******************************************************************************/
|
|
|
|
void key_handler(void *param)
|
|
|
|
{
|
|
|
|
flag = ~flag;
|
2022-01-11 19:51:25 +08:00
|
|
|
|
2022-01-10 16:20:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*******************************************************************************
|
|
|
|
** \brief Main function of GPIO output
|
|
|
|
**
|
|
|
|
** \param None
|
|
|
|
**
|
|
|
|
** \retval int32_t Return value, if needed
|
|
|
|
**
|
|
|
|
******************************************************************************/
|
|
|
|
int32_t main(void)
|
|
|
|
{
|
2022-01-11 19:51:25 +08:00
|
|
|
LOG_I("Go to main function");
|
|
|
|
rt_pin_mode(BUZZ_CTL_PIN, PIN_MODE_OUTPUT);
|
|
|
|
rt_pin_mode(PWR_LED_PIN, PIN_MODE_OUTPUT);
|
|
|
|
|
|
|
|
rt_pin_mode(PWR_BTN, PIN_MODE_INPUT);
|
|
|
|
rt_pin_mode(FUN_BTN, PIN_MODE_INPUT);
|
|
|
|
|
|
|
|
|
|
|
|
rt_pin_attach_irq(PWR_BTN, PIN_IRQ_MODE_FALLING, key_handler, RT_NULL);
|
|
|
|
rt_pin_irq_enable(PWR_BTN, PIN_IRQ_ENABLE);
|
|
|
|
rt_pin_attach_irq(FUN_BTN, PIN_IRQ_MODE_FALLING, key_handler, RT_NULL);
|
|
|
|
rt_pin_irq_enable(FUN_BTN, PIN_IRQ_ENABLE);
|
2022-01-10 16:20:39 +08:00
|
|
|
|
2022-01-11 19:51:25 +08:00
|
|
|
|
|
|
|
|
2022-01-10 16:20:39 +08:00
|
|
|
while(1)
|
|
|
|
{
|
|
|
|
if (flag == 0)
|
|
|
|
{
|
2022-01-11 19:51:25 +08:00
|
|
|
rt_pin_write(PWR_LED_PIN, PIN_HIGH);
|
2022-01-10 16:20:39 +08:00
|
|
|
rt_thread_delay(500);
|
2022-01-11 19:51:25 +08:00
|
|
|
rt_pin_write(PWR_LED_PIN, PIN_LOW);
|
2022-01-10 16:20:39 +08:00
|
|
|
rt_thread_delay(500);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-01-11 19:51:25 +08:00
|
|
|
rt_pin_write(PWR_LED_PIN, PIN_HIGH);
|
2022-01-10 16:20:39 +08:00
|
|
|
rt_thread_delay(2000);
|
2022-01-11 19:51:25 +08:00
|
|
|
rt_pin_write(PWR_LED_PIN, PIN_LOW);
|
2022-01-10 16:20:39 +08:00
|
|
|
rt_thread_delay(2000);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* EOF (not truncated)
|
|
|
|
******************************************************************************/
|