From 090d18667cd92ce901d8b4b9a16755d95ed69d0e Mon Sep 17 00:00:00 2001 From: YuzukiTsuru Date: Wed, 27 Dec 2023 23:11:19 +0800 Subject: [PATCH] [app] H618 support cli --- board/longanpi-3h/CMakeLists.txt | 4 ++- board/longanpi-3h/cli_test/CMakeLists.txt | 5 +++ board/longanpi-3h/cli_test/main.c | 41 +++++++++++++++++++++++ src/drivers/sun50iw9/CMakeLists.txt | 3 ++ src/drivers/sun50iw9/sys-wdt.c | 16 +++++++++ 5 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 board/longanpi-3h/cli_test/CMakeLists.txt create mode 100644 board/longanpi-3h/cli_test/main.c create mode 100644 src/drivers/sun50iw9/sys-wdt.c diff --git a/board/longanpi-3h/CMakeLists.txt b/board/longanpi-3h/CMakeLists.txt index d45bda34..a344e012 100644 --- a/board/longanpi-3h/CMakeLists.txt +++ b/board/longanpi-3h/CMakeLists.txt @@ -7,4 +7,6 @@ set(APP_COMMON_SOURCE add_subdirectory(hello_world) -add_subdirectory(init_dram) \ No newline at end of file +add_subdirectory(init_dram) + +add_subdirectory(cli_test) \ No newline at end of file diff --git a/board/longanpi-3h/cli_test/CMakeLists.txt b/board/longanpi-3h/cli_test/CMakeLists.txt new file mode 100644 index 00000000..e2505e8e --- /dev/null +++ b/board/longanpi-3h/cli_test/CMakeLists.txt @@ -0,0 +1,5 @@ +# SPDX-License-Identifier: Apache-2.0 + +add_syterkit_app(cli_test + main.c +) \ No newline at end of file diff --git a/board/longanpi-3h/cli_test/main.c b/board/longanpi-3h/cli_test/main.c new file mode 100644 index 00000000..4410288f --- /dev/null +++ b/board/longanpi-3h/cli_test/main.c @@ -0,0 +1,41 @@ +/* SPDX-License-Identifier: Apache-2.0 */ + +#include +#include +#include +#include + +#include + +#include + +#include +#include +#include + +extern sunxi_serial_t uart_dbg; + +msh_declare_command(helloworld); + +msh_define_help(helloworld, "display helloworld", "Usage: helloworld\n"); +int cmd_helloworld(int argc, const char **argv) { + printk(LOG_LEVEL_MUTE, "Hello World!\n"); + return 0; +} + +const msh_command_entry commands[] = { + msh_define_command(helloworld), + msh_command_end, +}; + +int main(void) { + sunxi_serial_init(&uart_dbg); + + sunxi_clk_init(); + + printk(LOG_LEVEL_INFO, "Hello World!\n"); + + syterkit_shell_attach(commands); + + return 0; +} \ No newline at end of file diff --git a/src/drivers/sun50iw9/CMakeLists.txt b/src/drivers/sun50iw9/CMakeLists.txt index 11ed7436..85ef8974 100644 --- a/src/drivers/sun50iw9/CMakeLists.txt +++ b/src/drivers/sun50iw9/CMakeLists.txt @@ -1,5 +1,8 @@ +# SPDX-License-Identifier: Apache-2.0 + add_library(chip_drivers-obj OBJECT sys-clk.c sys-dram.c sys-sid.c + sys-wdt.c ) \ No newline at end of file diff --git a/src/drivers/sun50iw9/sys-wdt.c b/src/drivers/sun50iw9/sys-wdt.c new file mode 100644 index 00000000..476fb51d --- /dev/null +++ b/src/drivers/sun50iw9/sys-wdt.c @@ -0,0 +1,16 @@ +/* SPDX-License-Identifier: Apache-2.0 */ + +#include +#include +#include +#include +#include +#include + +#include + +#include + +void sys_reset() { + write32(SUNXI_WDOG_BASE + 0x08, (0x16aa << 16) | (0x1 << 0)); +} \ No newline at end of file