初始提交
This commit is contained in:
5
application/samples/peripheral/blinky/CMakeLists.txt
Executable file
5
application/samples/peripheral/blinky/CMakeLists.txt
Executable file
@ -0,0 +1,5 @@
|
||||
#===============================================================================
|
||||
# @brief cmake file
|
||||
# Copyright (c) HiSilicon (Shanghai) Technologies Co., Ltd. 2023-2023. All rights reserved.
|
||||
#===============================================================================
|
||||
set(SOURCES "${SOURCES}" "${CMAKE_CURRENT_SOURCE_DIR}/blinky_demo.c" PARENT_SCOPE)
|
8
application/samples/peripheral/blinky/Kconfig
Executable file
8
application/samples/peripheral/blinky/Kconfig
Executable file
@ -0,0 +1,8 @@
|
||||
#===============================================================================
|
||||
# @brief Kconfig file.
|
||||
# Copyright (c) HiSilicon (Shanghai) Technologies Co., Ltd. 2024-2024. All rights reserved.
|
||||
#===============================================================================
|
||||
config BLINKY_PIN
|
||||
int
|
||||
prompt "Choose blinky pin."
|
||||
default 2
|
11
application/samples/peripheral/blinky/blinky.code-workspace
Executable file
11
application/samples/peripheral/blinky/blinky.code-workspace
Executable file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"folders": [
|
||||
{
|
||||
"path": "../../../../"
|
||||
}
|
||||
],
|
||||
"settings": {
|
||||
"debug.onTaskErrors": "debugAnyway",
|
||||
"workspace.samplePath": "./samples/peripheral/blinky"
|
||||
}
|
||||
}
|
51
application/samples/peripheral/blinky/blinky_demo.c
Executable file
51
application/samples/peripheral/blinky/blinky_demo.c
Executable file
@ -0,0 +1,51 @@
|
||||
/**
|
||||
* Copyright (c) HiSilicon (Shanghai) Technologies Co., Ltd. 2023-2023. All rights reserved.
|
||||
*
|
||||
* Description: Blinky Sample Source. \n
|
||||
*
|
||||
* History: \n
|
||||
* 2023-04-03, Create file. \n
|
||||
*/
|
||||
|
||||
#include "pinctrl.h"
|
||||
#include "gpio.h"
|
||||
#include "soc_osal.h"
|
||||
#include "app_init.h"
|
||||
|
||||
#define BLINKY_DURATION_MS 500
|
||||
|
||||
#define BLINKY_TASK_PRIO 24
|
||||
#define BLINKY_TASK_STACK_SIZE 0x1000
|
||||
|
||||
static int blinky_task(const char *arg)
|
||||
{
|
||||
unused(arg);
|
||||
|
||||
uapi_pin_set_mode(CONFIG_BLINKY_PIN, HAL_PIO_FUNC_GPIO);
|
||||
|
||||
uapi_gpio_set_dir(CONFIG_BLINKY_PIN, GPIO_DIRECTION_OUTPUT);
|
||||
uapi_gpio_set_val(CONFIG_BLINKY_PIN, GPIO_LEVEL_LOW);
|
||||
|
||||
while (1) {
|
||||
osal_msleep(BLINKY_DURATION_MS);
|
||||
uapi_gpio_toggle(CONFIG_BLINKY_PIN);
|
||||
osal_printk("Blinky working.\r\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void blinky_entry(void)
|
||||
{
|
||||
osal_task *task_handle = NULL;
|
||||
osal_kthread_lock();
|
||||
task_handle = osal_kthread_create((osal_kthread_handler)blinky_task, 0, "BlinkyTask", BLINKY_TASK_STACK_SIZE);
|
||||
if (task_handle != NULL) {
|
||||
osal_kthread_set_priority(task_handle, BLINKY_TASK_PRIO);
|
||||
osal_kfree(task_handle);
|
||||
}
|
||||
osal_kthread_unlock();
|
||||
}
|
||||
|
||||
/* Run the blinky_entry. */
|
||||
app_run(blinky_entry);
|
Reference in New Issue
Block a user