chore: migrate project into clean repository

This commit is contained in:
yuuux
2026-08-13 16:50:52 +08:00
commit d1d25a09e7
27405 changed files with 9422808 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
cmake_minimum_required(VERSION 3.20)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
find_package(listenai-cmake REQUIRED HINTS $ENV{ARCS_BASE})
project(arcs)
listenai_include_directories(
./
)
listenai_add_executable(${PROJECT_NAME})
target_sources(${PROJECT_NAME} PRIVATE
test_calendar.c
set_calendar/set_calendar.c
)
target_link_libraries(${PROJECT_NAME} PRIVATE unity)

View File

@@ -0,0 +1 @@
osource "$ARCS_BASE/Kconfig"

View File

@@ -0,0 +1,177 @@
#!/bin/bash
set -e
usage() {
echo "使用方式: $0 [选项]"
echo "选项:"
echo " -S, --Source <path> 指定项目源码路径 (默认为当前脚本所在目录)"
echo " -t, --target <target> 指定构建目标 (如 menuconfig)"
echo " -C, --Clean 清理构建目录"
echo " -B, --build 构建输出目录"
echo " -h, --help 显示此帮助信息"
echo " -r, --release 以 Release 模式构建 (移除 DEBUG_PATH 信息)"
echo " -w, --warnings-as-errors 将警告视为错误"
echo " -D<var>=<value> 传递 CMake 变量 (可多次使用)"
echo ""
echo "示例:"
echo " $0 -S samples/helloworld -DBOARD=arcs_mini 指定板型构建"
echo " $0 -S samples/helloworld -DBOARD=arcs_evb 使用 EVB 板型"
echo " $0 -S samples/helloworld -t menuconfig -DBOARD=arcs_mini 运行 menuconfig"
echo " $0 -C -S samples/helloworld -DBOARD=arcs_mini 清理并重新构建"
echo " $0 -S samples/helloworld -DBOARD=my_board -DBOARD_SEARCH_PATH=/path/to/boards 使用自定义板型"
exit 1
}
SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
PROJECT_PATH="$SCRIPT_DIR"
TARGET=""
CLEAN=false
OUTPUT="build"
WARNINGS_AS_ERRORS=false
RELEASE=false
ARCS_BASE_DIR_NAME="arcs-sdk"
ARCS_DEV_TOOLS_DIR_NAME="listenai-dev-tools"
ARCS_DEV_TOOL_TOOLCHAIN_DIR_NAME="gcc"
ARCS_DEV_TOOL_LISTENAI_TOOLS_DIR_NAME="listenai-tools"
find_arcs_base() {
local current_dir=$(cd "$(dirname "$0")" && pwd)
local dir_name="$ARCS_BASE_DIR_NAME"
while [ "$current_dir" != "/" ]; do
if [ -d "$current_dir/$dir_name" ]; then
echo "Found ARCS_BASE: $current_dir/$dir_name"
export ARCS_BASE="$current_dir/$dir_name"
return 0
fi
current_dir=$(dirname "$current_dir")
done
echo "ARCS_BASE not found, Please add ARCS_BASE environment variable or set ARCS_BASE_DIR_NAME to the correct directory."
echo "Current Target ARCS_BASE directory name: $ARCS_BASE_DIR_NAME."
exit 1
}
find_dev_tools() {
local current_dir=$(cd "$(dirname "$0")" && pwd)
local dir_name="$ARCS_DEV_TOOLS_DIR_NAME"
echo "trying to find $dir_name in parent directories..."
while [ "$current_dir" != "/" ]; do
if [ -d "$current_dir/$dir_name" ]; then
echo "Found $dir_name: $current_dir/$dir_name"
if [ -d "$current_dir/$dir_name/$ARCS_DEV_TOOL_LISTENAI_TOOLS_DIR_NAME" ]; then
echo "Found LISTENAI_TOOLS_PATH: $current_dir/$dir_name/$ARCS_DEV_TOOL_LISTENAI_TOOLS_DIR_NAME"
export LISTENAI_TOOLS_PATH="$current_dir/$dir_name/$ARCS_DEV_TOOL_LISTENAI_TOOLS_DIR_NAME"
fi
if [ -d "$current_dir/$dir_name/$ARCS_DEV_TOOL_TOOLCHAIN_DIR_NAME" ]; then
echo "Found NUCLEI_TOOLCHAIN_PATH: $current_dir/$dir_name/$ARCS_DEV_TOOL_TOOLCHAIN_DIR_NAME"
export NUCLEI_TOOLCHAIN_PATH="$current_dir/$dir_name/$ARCS_DEV_TOOL_TOOLCHAIN_DIR_NAME"
fi
return 0
fi
current_dir=$(dirname "$current_dir")
done
}
while [[ $# -gt 0 ]]; do
case $1 in
-S|--Source)
PROJECT_PATH="$2"
shift 2
;;
-B|--build)
OUTPUT="$2"
shift 2
;;
-t|--target)
TARGET="$2"
shift 2
;;
-C|--Clean)
CLEAN=true
shift 1
;;
-w|--warnings-as-errors)
WARNINGS_AS_ERRORS=true
shift 1
;;
-h|--help)
usage
;;
-r|--release)
RELEASE=true
shift 1
;;
-D*)
CMAKE_VARS+=("$1")
shift 1
;;
*)
echo "未知参数: $1"
usage
;;
esac
done
echo "Source: $PROJECT_PATH"
echo "Target: $TARGET"
echo "Clean : $CLEAN"
if [ -z "$LISTENAI_TOOLS_PATH" ] || [ -z "$NUCLEI_TOOLCHAIN_PATH" ]; then
find_dev_tools
fi
if [ -z "${LISTENAI_TOOLS_PATH}" ]; then
export LISTENAI_TOOLS_PATH="请添加 LISTENAI_TOOLS_PATH 环境变量,或在此行设置正确的路径"
echo "请添加 LISTENAI_TOOLS_PATH 环境变量或者修改脚本后, 注释脚本第 $LINENO 行";exit 1;
fi
if [ -z "${NUCLEI_TOOLCHAIN_PATH}" ]; then
export NUCLEI_TOOLCHAIN_PATH="请添加 NUCLEI_TOOLCHAIN_PATH 环境变量,或在此行设置正确的路径"
echo "请添加 NUCLEI_TOOLCHAIN_PATH 环境变量或者修改脚本后, 注释脚本第 $LINENO 行";exit 1;
fi
############### 下面代码不用修改 ##################
# 构建工具的位置
CMAKE_PROGRAM="$LISTENAI_TOOLS_PATH/cmake/bin/cmake"
NINJA_PROGRAM="$LISTENAI_TOOLS_PATH/ninja/ninja"
# 配置环境变量 ARCS_BASE
if [ -z "$ARCS_BASE" ]; then
find_arcs_base
fi
if [ "$CLEAN" = true ]; then
rm -rf $OUTPUT
fi
# Initialize CMAKE_VARS array if it doesn't exist
declare -a CMAKE_VARS
# Add warnings-as-errors flag if enabled
if [ "$WARNINGS_AS_ERRORS" = true ]; then
CMAKE_VARS+=("-DCMAKE_C_FLAGS=-Werror")
CMAKE_VARS+=("-DCMAKE_CXX_FLAGS=-Werror")
echo "Treating warnings as errors"
fi
# Add release flags if enabled
if [ "$RELEASE" = true ]; then
CMAKE_VARS+=("-DENABLE_DEBUG_PATH=OFF")
echo "Release mode enabled (-DENABLE_DEBUG_PATH=OFF)"
fi
$CMAKE_PROGRAM -B "$OUTPUT" -G Ninja -S "$PROJECT_PATH" \
-DCMAKE_MAKE_PROGRAM="$NINJA_PROGRAM" \
"${CMAKE_VARS[@]}"
if [ -z "$TARGET" ]; then
$CMAKE_PROGRAM --build "$OUTPUT" -j4
else
$CMAKE_PROGRAM --build "$OUTPUT" --target "$TARGET"
fi

View File

@@ -0,0 +1,49 @@
# 项目可根据需要在此文件中设置对应的配置
CONFIG_ARCS_HAL_WARNING_DISABLE=y
CONFIG_LISA_DISPLAY=y
# 项目可根据需要在此文件中设置对应的配置
CONFIG_ARCS_HAL_WARNING_DISABLE=y
CONFIG_SDK_MODULE_EASYLOGGER=n
CONFIG_LISA_DISPLAY_AXS15231B=y
CONFIG_ARCS_CP_CORE=y
# CONFIG_ARCS_HAL_DEBUG=y
CONFIG_MODULE_FREERTOS=y
CONFIG_MODULE_HEAP=y
CONFIG_LINK_OPTION_NOSYS_SPECS=y
CONFIG_EASYLOGGER_ASYNC_BUF_SIZE=0x1000
CONFIG_MODULE_HEAP=y
CONFIG_LOG=y
CONFIG_SYSLOG_PRINTK_REDIRECT=y
CONFIG_SYSLOG_UART_TX_PIN=3
CONFIG_SYSLOG_UART_TX_PIN_FUNC_SEL=2
CONFIG_SYSLOG_UART_PORT=0
CONFIG_SYSLOG_UART_BAUDRATE=921600
CONFIG_FREERTOS_STATIC_ALLOCATION_ENABLE=y
CONFIG_DCACHE_ENABLE=n
CONFIG_BACK_TRACE=y
CONFIG_HEAP_SIZE=0x3C00
CONFIG_PSRAM_HEAP_SIZE=0x3b0000
# 使能collection-c
CONFIG_SDK_MODULE_COLLECTIONS_C=y
CONFIG_SDK_MODULE_MBEDTLS=n
CONFIG_TEST_UNITY=y

View File

@@ -0,0 +1,123 @@
#include "set_calendar.h"
void *calendar_handler = NULL;
static volatile uint32_t calendar_flag = 0;
static CSK_CALENDAR_TIME last_stime;
static void calendar_eventcallback(uint32_t event, void *workspace)
{
calendar_flag = 1;
CALENDAR_GetTime(calendar_handler, &last_stime);
}
bool set_calendar_sec_value()
{
CSK_CALENDAR_TIME stime = {0, 0, 0, 0, 0, 0, 0};
CALENDAR_Initialize(calendar_handler, calendar_eventcallback, NULL);
CALENDAR_PowerControl(calendar_handler, CSK_POWER_FULL);
CALENDAR_SetTime(calendar_handler, &stime);
CALENDAR_Control(calendar_handler, CSK_CALENDAR_CTRL_SEC_INT, 1);
CALENDAR_Control(calendar_handler, CSK_CALENDAR_CTRL_CALIBRATION_EN, 1);
while (calendar_flag == 0);
calendar_flag = 0;
bool set_sec_status = false;
if (last_stime.sec == 1) {
set_sec_status = true;
} else {
set_sec_status = false;
}
CALENDAR_Control(calendar_handler, CSK_CALENDAR_CTRL_SEC_INT, 0);
CALENDAR_PowerControl(calendar_handler, CSK_POWER_OFF);
CALENDAR_Uninitialize(calendar_handler);
return set_sec_status;
}
bool set_calendar_min_value()
{
CSK_CALENDAR_TIME stime = {0, 0, 0, 0, 0, 0, 59};
CALENDAR_Initialize(calendar_handler, calendar_eventcallback, NULL);
CALENDAR_PowerControl(calendar_handler, CSK_POWER_FULL);
CALENDAR_SetTime(calendar_handler, &stime);
CALENDAR_Control(calendar_handler, CSK_CALENDAR_CTRL_MIN_INT, 1);
CALENDAR_Control(calendar_handler, CSK_CALENDAR_CTRL_CALIBRATION_EN, 1);
while (calendar_flag == 0);
calendar_flag = 0;
bool set_min_status = false;
if (last_stime.sec == 0 && last_stime.min == 1) {
set_min_status = true;
} else {
set_min_status = false;
}
CALENDAR_Control(calendar_handler, CSK_CALENDAR_CTRL_MIN_INT, 0);
CALENDAR_PowerControl(calendar_handler, CSK_POWER_OFF);
CALENDAR_Uninitialize(calendar_handler);
return set_min_status;
}
bool set_calendar_hour_value()
{
CSK_CALENDAR_TIME stime = {0, 0, 0, 0, 0, 59, 59};
CALENDAR_Initialize(calendar_handler, calendar_eventcallback, NULL);
CALENDAR_PowerControl(calendar_handler, CSK_POWER_FULL);
CALENDAR_SetTime(calendar_handler, &stime);
CALENDAR_Control(calendar_handler, CSK_CALENDAR_CTRL_HOUR_INT, 1);
CALENDAR_Control(calendar_handler, CSK_CALENDAR_CTRL_CALIBRATION_EN, 1);
while (calendar_flag == 0);
calendar_flag = 0;
bool set_hour_status = false;
if (last_stime.hour == 1 && last_stime.min == 0 && last_stime.sec == 0) {
set_hour_status = true;
} else {
set_hour_status = false;
}
CALENDAR_Control(calendar_handler, CSK_CALENDAR_CTRL_HOUR_INT, 0);
CALENDAR_PowerControl(calendar_handler, CSK_POWER_OFF);
CALENDAR_Uninitialize(calendar_handler);
return set_hour_status;
}
bool set_calendar_alarm_value()
{
CSK_CALENDAR_TIME stime = {0, 0, 0, 0, 0, 0, 0};
CSK_CALENDAR_ALARM satime = {0, 0, 0, 0, 0, 1};
CALENDAR_Initialize(calendar_handler, calendar_eventcallback, NULL);
CALENDAR_PowerControl(calendar_handler, CSK_POWER_FULL);
CALENDAR_SetTime(calendar_handler, &stime);
CALENDAR_SetAlarm(calendar_handler, &satime);
CALENDAR_Control(calendar_handler, CSK_CALENDAR_CTRL_ALARM_EN, 1);
while (calendar_flag == 0);
calendar_flag = 0;
bool set_alarm_status = false;
if (last_stime.hour == satime.hour &&
last_stime.min == satime.min &&
last_stime.sec == satime.sec) {
set_alarm_status = true;
} else {
set_alarm_status = false;
}
CALENDAR_Control(calendar_handler, CSK_CALENDAR_CTRL_ALARM_EN, 0);
CALENDAR_PowerControl(calendar_handler, CSK_POWER_OFF);
CALENDAR_Uninitialize(calendar_handler);
return set_alarm_status;
}

View File

@@ -0,0 +1,28 @@
/**
* Copyright (c) 2025, LISTENAI
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#include "Driver_CALENDAR.h"
#include "PowerManager.h"
#include <string.h>
#include <assert.h>
#include <string.h>
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
bool set_calendar_sec_value();
bool set_calendar_min_value();
bool set_calendar_hour_value();
bool set_calendar_alarm_value();
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,83 @@
/* AUTOGENERATED FILE. DO NOT EDIT. */
/*=======Test Runner Used To Run Each Test Below=====*/
#define RUN_TEST(TestFunc, TestLineNum) \
{ \
Unity.CurrentTestName = #TestFunc; \
Unity.CurrentTestLineNumber = TestLineNum; \
Unity.NumberOfTests++; \
if (TEST_PROTECT()) { \
setUp(); \
TestFunc(); \
} \
if (TEST_PROTECT()) { \
tearDown(); \
} \
UnityConcludeTest(); \
}
/*=======Automagically Detected Files To Include=====*/
#include "unity.h"
#include <setjmp.h>
#include <stdio.h>
/*======= Functions This Runner Calls=====*/
#include "set_calendar/set_calendar.h"
extern void *calendar_handler;
void setUp(void)
{
/* This is run before EACH TEST */
calendar_handler = CALENDAR();
}
void tearDown(void)
{
}
void test_calendar_pointer_verify(void)
{
TEST_ASSERT_NOT_NULL(calendar_handler);
}
void test_calendar_sec_value(void)
{
TEST_ASSERT_EQUAL(true, set_calendar_sec_value());
}
void test_calendar_min_value(void)
{
TEST_ASSERT_EQUAL(true, set_calendar_min_value());
}
void test_calendar_hour_value(void)
{
TEST_ASSERT_EQUAL(true, set_calendar_hour_value());
}
void test_calendar_alarm_value(void)
{
TEST_ASSERT_EQUAL(true, set_calendar_alarm_value());
}
/*=======Test Reset Option=====*/
void resetTest(void);
void resetTest(void)
{
tearDown();
setUp();
}
/*=======MAIN=====*/
int main(void)
{
UnityBegin("test/driver/calendar/test_calendar.c");
RUN_TEST(test_calendar_pointer_verify, __LINE__);
RUN_TEST(test_calendar_sec_value, __LINE__);
RUN_TEST(test_calendar_min_value, __LINE__);
RUN_TEST(test_calendar_hour_value, __LINE__);
RUN_TEST(test_calendar_alarm_value, __LINE__);
return (UnityEnd());
}

View File

@@ -0,0 +1,6 @@
tests:
test.driver.calendar:
programmer: arcs
runner: uart
log_analyzer: Unity