From: penglei <1624952103@qq.com> Date: Thu, 30 May 2024 07:34:14 +0000 (+0800) Subject: 更新cywee算法,修改gsensor为中断模式,优化久坐提醒,优化next day触发机制。 X-Git-Url: http://git.snicker.com.cn/?a=commitdiff_plain;h=refs%2Fchanges%2F199%2Fhead;p=mirrors%2FFD230.git 更新cywee算法,修改gsensor为中断模式,优化久坐提醒,优化next day触发机制。 --- diff --git a/code/sdk/application/wearable/fd230app/nativeui/alarmclocktimerconfig/include/AlarmClockTimerConfig.h b/code/sdk/application/wearable/fd230app/nativeui/alarmclocktimerconfig/include/AlarmClockTimerConfig.h index 747b380dd..5c6376744 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/alarmclocktimerconfig/include/AlarmClockTimerConfig.h +++ b/code/sdk/application/wearable/fd230app/nativeui/alarmclocktimerconfig/include/AlarmClockTimerConfig.h @@ -39,6 +39,7 @@ typedef struct { uint8_t week; uint8_t hour; uint8_t minute; + uint8_t second; uint8_t reserved; } AlarmInfo; diff --git a/code/sdk/application/wearable/fd230app/nativeui/alarmclocktimerconfig/src/AlarmClockTimerConfig.cpp b/code/sdk/application/wearable/fd230app/nativeui/alarmclocktimerconfig/src/AlarmClockTimerConfig.cpp index 28adda236..c799928e7 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/alarmclocktimerconfig/src/AlarmClockTimerConfig.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/alarmclocktimerconfig/src/AlarmClockTimerConfig.cpp @@ -116,9 +116,10 @@ void AlarmScan(void *arg) if (g_alarmCtrB.state == ALARM_STATUS_RUNNING) { if ((g_alarmCtrB.callback != NULL) && - (g_alarmCtrB.info.week == curTime.tm_wday) && + //(g_alarmCtrB.info.week == curTime.tm_wday) && (g_alarmCtrB.info.hour == curTime.tm_hour) && - (g_alarmCtrB.info.minute == curTime.tm_min)) { + (g_alarmCtrB.info.minute == curTime.tm_min) && + (g_alarmCtrB.info.second == curTime.tm_sec)) { g_alarmCtrB.callback(); g_alarmCtrB.state = ALARM_STATUS_CREATED; } @@ -180,6 +181,7 @@ int32_t SetAlarm(AlarmType type, uint8_t week, uint8_t hour, uint8_t minute) g_alarmCtrB.info.week = week; g_alarmCtrB.info.hour = hour; g_alarmCtrB.info.minute = minute; + g_alarmCtrB.info.second = 1; } else { return ERRCODE_FAIL; } diff --git a/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp b/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp index 8bd10ae7c..640f12ded 100644 --- a/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp +++ b/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp @@ -881,7 +881,7 @@ void MsgCenterNotifyInactivityProc(const Topic topic, Request *req) switch (cywee_Inactivity_Info->output_number) { case INACTIVITY_MODE_SEDENTARY_OUTPUT: - if(cywee_Inactivity_Info->sedentary_status == 3) + if(cywee_Inactivity_Info->sedentary_status == 1) { NotificationManager::GetInstance()->ShowNotify(showSedentaryReminderNotify, (uint16_t)topic, true); // if(SedentaryReminderViewEventListener::GetInstance().IsReminderTime() == true) diff --git a/code/sdk/drivers/boards/brandy_evb/board_config/board_evb.h b/code/sdk/drivers/boards/brandy_evb/board_config/board_evb.h index 121d8d1b8..3ed74a4dc 100755 --- a/code/sdk/drivers/boards/brandy_evb/board_config/board_evb.h +++ b/code/sdk/drivers/boards/brandy_evb/board_config/board_evb.h @@ -161,7 +161,7 @@ const hal_pio_config_t g_pio_function_config[PIN_MAX_NUMBER] = { { HAL_PIO_FUNC_GPIO, HAL_PIO_DRIVE_MAX, HAL_PIO_PULL_MAX, HAL_PIO_IE_ENBALE }, // S_AGPIO_L9 dsp uart TP35 { HAL_PIO_FUNC_GPIO, HAL_PIO_DRIVE_MAX, HAL_PIO_PULL_MAX, HAL_PIO_IE_ENBALE }, // S_AGPIO_L10 dsp uart TP36 #endif - { HAL_PIO_FUNC_GPIO, HAL_PIO_DRIVE_MAX, HAL_PIO_PULL_DOWN, HAL_PIO_IE_DISABLE }, // S_AGPIO_L11 G_INT1 + { HAL_PIO_FUNC_GPIO, HAL_PIO_DRIVE_MAX, HAL_PIO_PULL_DOWN, HAL_PIO_IE_ENBALE }, // S_AGPIO_L11 G_INT1 { HAL_PIO_FUNC_GPIO, HAL_PIO_DRIVE_MAX, HAL_PIO_PULL_MAX, HAL_PIO_IE_ENBALE }, // S_AGPIO_L12 i2c data HX3507_SDIO { HAL_PIO_FUNC_GPIO, HAL_PIO_DRIVE_MAX, HAL_PIO_PULL_MAX, HAL_PIO_IE_DISABLE }, // S_AGPIO_L13 i2c CLK HX3507_SCLK @@ -291,7 +291,7 @@ const hal_gpio_config_t g_gpio_function_config[PIN_MAX_NUMBER] = { #ifdef ENABLE_CYWEE /**G sensor G_INT1 S_AGPIO_L11 G_INT2 S_AGPIO_L19 采用timer 时这些中断要屏蔽*/ - //{ S_AGPIO_L11, HAL_GPIO_DIRECTION_INPUT, NULL, GPIO_INTERRUPT_RISING_EDGE, cywee_int_callback }, + { S_AGPIO_L11, HAL_GPIO_DIRECTION_INPUT, NULL, GPIO_INTERRUPT_RISING_EDGE, cywee_int_callback }, //{ S_AGPIO_L19, HAL_GPIO_DIRECTION_INPUT, NULL, GPIO_INTERRUPT_DEDGE, cywee_int_callback }, #endif /**S_AGPIO_R1 GPO alipay默认resetpin*/ diff --git a/code/sdk/drivers/peripheral/cywee/CMakeLists.txt b/code/sdk/drivers/peripheral/cywee/CMakeLists.txt index 8501dbf13..05b6d8379 100644 --- a/code/sdk/drivers/peripheral/cywee/CMakeLists.txt +++ b/code/sdk/drivers/peripheral/cywee/CMakeLists.txt @@ -49,7 +49,7 @@ set(MAIN_COMPONENT if("SUPPORT_AT_CYWEE" IN_LIST DEFINES) find_library(LIB_PATH_CWM_LIB_DML Lib/CWM_LIB_DML_clang_riscv.a ${CMAKE_CURRENT_SOURCE_DIR}) - find_library(LIB_PATH_CWM_LIB Lib/CWM_LIB_clang_riscv.p3.a ${CMAKE_CURRENT_SOURCE_DIR}) + find_library(LIB_PATH_CWM_LIB Lib/CWM_LIB_clang_riscv.a ${CMAKE_CURRENT_SOURCE_DIR}) target_link_libraries(${TARGET_NAME} PRIVATE -Wl,--whole-archive ${LIB_PATH_CWM_LIB_DML} ${LIB_PATH_CWM_LIB} PRIVATE -Wl,--whole-archive) endif() diff --git a/code/sdk/drivers/peripheral/cywee/Inc/CWM_EventStructure.h b/code/sdk/drivers/peripheral/cywee/Inc/CWM_EventStructure.h index 611cbb1ed..f875e94ad 100644 --- a/code/sdk/drivers/peripheral/cywee/Inc/CWM_EventStructure.h +++ b/code/sdk/drivers/peripheral/cywee/Inc/CWM_EventStructure.h @@ -1,6 +1,7 @@ #ifndef __CWM_EVENT_STRUCTURE_H__ #define __CWM_EVENT_STRUCTURE_H__ #include +#include /** * @brief CyweeMotion task handle event structure. */ diff --git a/code/sdk/drivers/peripheral/cywee/Inc/OsApi.h b/code/sdk/drivers/peripheral/cywee/Inc/OsApi.h index 4ae3003ed..49b35b160 100644 --- a/code/sdk/drivers/peripheral/cywee/Inc/OsApi.h +++ b/code/sdk/drivers/peripheral/cywee/Inc/OsApi.h @@ -1,6 +1,6 @@ #ifndef __OS_API_H__ #define __OS_API_H__ -#include + /** * @brief System/OS/Peripheral API structure. */ @@ -25,19 +25,7 @@ typedef struct{ int (*spiRead)(uint16_t reg, int regLength, uint8_t *readData, int readDataSize, int busIndex); int (*spiWrite)(uint16_t reg, int regLength, uint8_t *writeData, int writeDataSize, int busIndex); } OsAPI, *pOsAPI; -#if USE_P813 -typedef struct{ - int (*dbgOutput)(const char*); - uint64_t (*GetTimeNs)(void); - void (*uSleep)(uint32_t); - int (*i2cRead)(uint16_t slaveAddr, uint16_t reg, int regLength, uint8_t *readData, int readDataSize, int busIndex); - int (*i2cWrite)(uint16_t slaveAddr, uint16_t reg, int regLength, uint8_t *writeData, int writeDataSize, int busIndex); - void *(*malloc)(int size); - void (*free)(void* ptr); - int (*spiRead)(uint16_t reg, int regLength, uint8_t *readData, int readDataSize, int busIndex); - int (*spiWrite)(uint16_t reg, int regLength, uint8_t *writeData, int writeDataSize, int busIndex); -} os_api; -#else + typedef OsAPI os_api; -#endif + #endif /* __OS_API_H__ */ diff --git a/code/sdk/drivers/peripheral/cywee/Inc/cwm_lib.h b/code/sdk/drivers/peripheral/cywee/Inc/cwm_lib.h index bf3cc3145..50c3087c3 100644 --- a/code/sdk/drivers/peripheral/cywee/Inc/cwm_lib.h +++ b/code/sdk/drivers/peripheral/cywee/Inc/cwm_lib.h @@ -1,8 +1,8 @@ #ifndef __CWM_LIB_H__ #define __CWM_LIB_H__ -#include -#include "OsApi.h" + #include "CWM_EventStructure.h" +#include "OsApi.h" #include "CWM_CustomDataStruct.h" /** @@ -27,17 +27,6 @@ #define SCL_SWIM_CONFIG 13 #define SCL_BIKING_CONFIG 14 #define SCL_ACTIVITY_PAUSE 15 -/** - * int[0] = 1 -int[1] = up_range (抬手反應範圍)(default: 5) -(0: default, 3: 範圍大, 4, 5, 6: 範圍小) -int[2] = down_range (放手反應範圍)(default: 5) -(0: default, 3: 範圍大, 4, 5, 6: 範圍小) -int[3] = sensitivity (反應速度)(default: 5) -(0: default, 3: 反應速度快, 4, 5, 6: 反應速度慢) -int[4] = horizontal_range (亮屏手肘傾斜範圍)(default: 5) -(0: default, 1: 範圍大, 2, 3, 4, 5, 6, 7, 8, 9: 範圍小) -*/ #define SCL_HAND_UPDOWN_CONFIG 16 #define SCL_CHIP_VENDOR_CONFIG 17 #define SCL_SLEEP_CONFIG 18 @@ -54,11 +43,14 @@ int[4] = horizontal_range (亮屏手肘傾斜範圍)(default: 5) #define SCL_ACT_INFO_CONFIG 30 #define SCL_REQ_ACTIVITY_EXIT 31 #define SCL_ACT_PAI_INFO 33 +#define SCL_HAND_WRIST_CONFIG 34 #define SCL_ACT_INTSY_INFO 35 #define SCL_DUMP_WI_INFO 36 #define SCL_ACT_ZONE_TIME 37 #define SCL_ACT_TRAINING_INFO 38 +#define SCL_HAND_SHAKE_CONFIG 39 #define SCL_WATCH_INTF_RESET 40 +#define SCL_HAND_RUB_CONFIG 41 #define SCL_PEDO_CONFIG2 42 #define SCL_HG_INTF_CONFIG 43 #define SCL_ACT_AUTO_PAUSE_CFG 44 diff --git a/code/sdk/drivers/peripheral/cywee/Lib/CWM_LIB_clang_riscv.a b/code/sdk/drivers/peripheral/cywee/Lib/CWM_LIB_clang_riscv.a new file mode 100644 index 000000000..a74ed8668 Binary files /dev/null and b/code/sdk/drivers/peripheral/cywee/Lib/CWM_LIB_clang_riscv.a differ diff --git a/code/sdk/drivers/peripheral/cywee/Lib/CWM_LIB_clang_riscv.p3.a b/code/sdk/drivers/peripheral/cywee/Lib/CWM_LIB_clang_riscv.p3.a deleted file mode 100644 index c42a47d7b..000000000 Binary files a/code/sdk/drivers/peripheral/cywee/Lib/CWM_LIB_clang_riscv.p3.a and /dev/null differ diff --git a/code/sdk/drivers/peripheral/cywee/Lib/CWM_LIB_clang_riscv.p813.a b/code/sdk/drivers/peripheral/cywee/Lib/CWM_LIB_clang_riscv.p813.a deleted file mode 100644 index afbcedcbc..000000000 Binary files a/code/sdk/drivers/peripheral/cywee/Lib/CWM_LIB_clang_riscv.p813.a and /dev/null differ diff --git a/code/sdk/drivers/peripheral/cywee/service/cywee_service.c b/code/sdk/drivers/peripheral/cywee/service/cywee_service.c index e007f1a13..4059dab40 100644 --- a/code/sdk/drivers/peripheral/cywee/service/cywee_service.c +++ b/code/sdk/drivers/peripheral/cywee/service/cywee_service.c @@ -273,9 +273,9 @@ static void cywee_service_check_task(void const *arg) break; case CYWEE_SERVICE_CMD_START_CHECK: - cywee_service_running_stat = true; + //cywee_service_running_stat = true; cywee_main_dml(); - cywee_service_timer_start_check(CYWEE_CHECK_MS); + //cywee_service_timer_start_check(CYWEE_CHECK_MS); break; case CYWEE_SERVICE_CMD_STOP_CHECK: diff --git a/code/sdk/drivers/peripheral/cywee/src/config.h b/code/sdk/drivers/peripheral/cywee/src/config.h new file mode 100644 index 000000000..fd0a0105a --- /dev/null +++ b/code/sdk/drivers/peripheral/cywee/src/config.h @@ -0,0 +1,13 @@ +#ifndef __CWM_SAMPLE_PROJ_CONFIG_H__ +#define __CWM_SAMPLE_PROJ_CONFIG_H__ + +//#define RUN_TEST_API_PROCESS + +//#define PRINTF_FROM_UART + +//#define CHECK_LOG_TOOL + +//#define SIGNAL_SIMULATE_PROCESS +//#define INPUT_DATA_WITH_FIFO_MODE + +#endif //__CWM_SAMPLE_PROJ_CONFIG_H__ diff --git a/code/sdk/drivers/peripheral/cywee/src/main.c b/code/sdk/drivers/peripheral/cywee/src/main.c index d2528c48a..77f99ae4b 100644 --- a/code/sdk/drivers/peripheral/cywee/src/main.c +++ b/code/sdk/drivers/peripheral/cywee/src/main.c @@ -1,56 +1,103 @@ -#include +/*********************/ +/*** Include Files ***/ +/*********************/ #include +#include #include -#include #include "cwm_lib.h" +#include "config.h" +#include "simulate_signal.h" -int CWM_OS_dbgOutput(const char * format) { - printf("%s", format); - return 0; -} +/*********************/ +/*** Macro Defines ***/ +/*********************/ -int CWM_OS_dbgPrintf(const char * format,...) { - va_list argList; - int size = 0; - static char tBuffer[256]; - va_start(argList, format); - size = vsnprintf(tBuffer, sizeof(tBuffer), format, argList); - va_end(argList); - - //strcat(tBuffer, "\n"); - CWM_OS_dbgOutput(tBuffer); - return size; -} +/*************************/ +/*** Variables Defines ***/ +/*************************/ +static const char* REQ_SENS_NAME[] = {"acc", "gyro", "mag", "baro", "temp", "hr", "gnss", "ob", "oc", "accany"}; +static int m_req_sensor_state = 0; -uint64_t CWM_OS_GetTimeNs(void) { - uint64_t timeNow_us; +/************************/ +/*** Function Defines ***/ +/************************/ - timeNow_us = 0; +extern void board_init(void); +extern void CWM_OS_uSleep(uint32_t time); +extern uint64_t CWM_OS_GetTimeNs(void); +extern void* CWM_OS_malloc(int size); +extern void CWM_OS_free(void *ptr); +extern int CWM_OS_dbgOutput(const char * format); +extern int CWM_OS_dbgOutput_checkLog(const char * format); +extern int CWM_OS_dbgPrintf(const char * format,...); +extern void test_api(void); - return timeNow_us * 1000; +/********************************/ +/*** Function Implementations ***/ +/********************************/ +int getReqSensor(int index) { + if (m_req_sensor_state & (1<sensorType) { - case 0: - CWM_OS_dbgPrintf("acc: x=%.3f, y=%.3f, z=%.3f\n", + case IDX_REQUEST_SENSOR: + if (sensorEVT->fData[2] != 0) + m_req_sensor_state |= (1<<(int)sensorEVT->fData[1]); + else + m_req_sensor_state &= ~(1<<(int)sensorEVT->fData[1]); + + CWM_OS_dbgPrintf("req_sensor input_sensor: %s(%.1f), switch: %.1f\n",\ + REQ_SENS_NAME[(int)sensorEVT->fData[1]], sensorEVT->fData[1], sensorEVT->fData[2]); + CWM_OS_dbgPrintf("input_sensor now: acc=%d gyro=%d mag=%d baro=%d temp=%d hr=%d gnss=%d ob=%d oc=%d accany=%d\n",\ + getReqSensor(0), getReqSensor(1), getReqSensor(2), getReqSensor(3), getReqSensor(4),\ + getReqSensor(5), getReqSensor(6), getReqSensor(7), getReqSensor(8), getReqSensor(9)); + break; + + case IDX_ACCEL: + CWM_OS_dbgPrintf("%s: %.4f, %.4f, %.4f\n", "accel", sensorEVT->fData[0], sensorEVT->fData[1], - sensorEVT->fData[2] - ); - break; + sensorEVT->fData[2]); + break; - case 1: - CWM_OS_dbgPrintf("gyro: x=%.3f, y=%.3f, z=%.3f\n", + case IDX_ALGO_ACTIVITY_OUTPUT: + CWM_OS_dbgPrintf("%s: %.4f, %.4f, %.4f, %.4f, "\ + "%.4f, %.4f, %.4f, %.4f, "\ + "%.4f, %.4f, %.4f, %.4f, "\ + "%.4f, %.4f, %.4f, %.4f\n", "activity output", sensorEVT->fData[0], sensorEVT->fData[1], - sensorEVT->fData[2] - ); - break; + sensorEVT->fData[2], + sensorEVT->fData[3], + sensorEVT->fData[4], + sensorEVT->fData[5], + sensorEVT->fData[6], + sensorEVT->fData[7], + sensorEVT->fData[8], + sensorEVT->fData[9], + sensorEVT->fData[10], + sensorEVT->fData[11], + sensorEVT->fData[12], + sensorEVT->fData[13], + sensorEVT->fData[14], + sensorEVT->fData[15]); + break; default: - CWM_OS_dbgPrintf("IDX[%d]: %.3f, %.3f, %.3f, %.3f, %.3f, %.3f, %.3f, %.3f\n", sensorEVT->sensorType, + CWM_OS_dbgPrintf("%d: %.4f, %.4f, %.4f, %.4f, "\ + "%.4f, %.4f, %.4f, %.4f, "\ + "%.4f, %.4f, %.4f, %.4f, "\ + "%.4f, %.4f, %.4f, %.4f", sensorEVT->sensorType, sensorEVT->fData[0], sensorEVT->fData[1], sensorEVT->fData[2], @@ -58,33 +105,140 @@ void CWM_AP_SensorListen(pSensorEVT_t sensorEVT) { sensorEVT->fData[4], sensorEVT->fData[5], sensorEVT->fData[6], - sensorEVT->fData[7] - ); + sensorEVT->fData[7], + sensorEVT->fData[8], + sensorEVT->fData[9], + sensorEVT->fData[10], + sensorEVT->fData[11], + sensorEVT->fData[12], + sensorEVT->fData[13], + sensorEVT->fData[14], + sensorEVT->fData[15]); + break; + } +} + +#ifdef SIGNAL_SIMULATE_PROCESS +#define SIGNAL_SIMULATE_FIFO_COUNT 10 + +static void sample_fifo_input_data(time_axis_data *taxis) { + int i; + float acc[3]; + CWM_CustomSensorInput_Fifo_Start(CUSTOM_ACC, + simulate_fake_get_time_ns(), + 20 * 1000000); + + for (i=0; i 0) { + /* Do Low power process here + */ + + CWM_OS_uSleep(next_duration / 1000); } - } - return 0; + CWM_process(); + } } - diff --git a/code/sdk/drivers/peripheral/cywee/src/main_dml.c b/code/sdk/drivers/peripheral/cywee/src/main_dml.c index 337b9cda3..ab21c9ad5 100644 --- a/code/sdk/drivers/peripheral/cywee/src/main_dml.c +++ b/code/sdk/drivers/peripheral/cywee/src/main_dml.c @@ -41,11 +41,14 @@ static uint8_t hrs = 0; uint8_t hrs_mode_state = 0; -int history_step = 0; -int stepcount = 0; +static int history_step = 0; +static int stepcount = 0; int history_step_=0;//存一个小时前的步数数据,每次保存步数时会更新改数据 +int cm__hs1__init(void); +int cm__hs1__deinit(void); + void cywee_save_data(void) { CWM_OS_saveData(&stepcount,sizeof(int)); @@ -745,7 +748,7 @@ int cywee_main_dml(void) //CWM_OS_dbgPrintf("[DBG] %s %d\n", __func__,__LINE__); //set mcu_chip information, must call this before CWM_LibPostInit() - +#if 0 memset(&scl, 0, sizeof(scl)); scl.iData[0] = 1; scl.iData[1] = 2; // 0: mcu_auto_detect 2: skip_mcu_auto_detect @@ -755,7 +758,7 @@ int cywee_main_dml(void) CWM_LibPostInit(CWM_AP_SensorListen); //CWM_OS_dbgPrintf("[DBG] %s %d\n", __func__,__LINE__); -#if 0 +#else memset(&scl, 0, sizeof(scl)); scl.iData[0] = 1; scl.iData[1] = 31010100; @@ -818,7 +821,7 @@ int cywee_main_dml(void) memset(&scl, 0, sizeof(scl)); scl.iData[0] = 1; scl.iData[7] = 5; //轴向配置 -#if 1 +#if 0 scl.iData[3] = 2; scl.iData[4] = 1; //1 anytime 2 fifo scl.iData[6] = 25; //先設定5 diff --git a/code/sdk/drivers/peripheral/cywee/src/test_api.c b/code/sdk/drivers/peripheral/cywee/src/test_api.c index bbaa85aa4..b4af5e4e8 100644 --- a/code/sdk/drivers/peripheral/cywee/src/test_api.c +++ b/code/sdk/drivers/peripheral/cywee/src/test_api.c @@ -2,9 +2,6 @@ #include #include #include -#include "cmsis_os2.h" -#include "errcode.h" -#include "los_task_base.h" extern void CWM_OS_uSleep(uint32_t time); extern uint64_t CWM_OS_GetTimeNs(void); @@ -45,8 +42,7 @@ __FAIL: return 0; } -int test_free_1(void) -{ +int test_free_1(void) { char *pBuf1; char *pBuf2; int alloc_size; @@ -79,8 +75,7 @@ __FAIL: return 0; } -void test_GetTimeNs_0(void) -{ +void test_GetTimeNs_0(void) { uint64_t timeNow; CWM_OS_dbgPrintf("[test_GetTimeNs_0] test up_time start\r\n"); @@ -94,8 +89,7 @@ void test_GetTimeNs_0(void) } } -void test_GetTimeNs_1(void) -{ +void test_GetTimeNs_1(void) { uint64_t timeNow, timeLast, timeDiff; CWM_OS_dbgPrintf("[test_GetTimeNs_1] test 10 seconds start\r\n"); @@ -112,8 +106,7 @@ void test_GetTimeNs_1(void) } } -void test_GetTimeNs_2(void) -{ +void test_GetTimeNs_2(void) { uint64_t timeNow, timeLast, timeDiff; uint64_t count; @@ -137,8 +130,7 @@ void test_GetTimeNs_2(void) } } -void test_GetTimeNs_3(void) -{ +void test_GetTimeNs_3(void) { uint64_t timeNow, timeLast, timeDiff; CWM_OS_dbgPrintf("[test_GetTimeNs_3] test 20 minutes start\r\n"); @@ -148,15 +140,14 @@ void test_GetTimeNs_3(void) timeNow = CWM_OS_GetTimeNs(); timeDiff = timeNow - timeLast; //CWM_OS_dbgPrintf("timeNow=%lld\ttimeLast=%lld\ttimeDiff=%lld\n", timeNow, timeLast, timeDiff); - if (timeDiff >= (uint64_t)1 * 60 * 1000000000) { + if (timeDiff >= (uint64_t)20 * 60 * 1000000000) { CWM_OS_dbgPrintf("[test_GetTimeNs_3] test 20 minutes end\r\n"); break; } } } -void test_uSleep_1(void) -{ +void test_uSleep_1(void) { CWM_OS_dbgPrintf("[test_uSleep_1] test 10 seconds start\r\n"); @@ -181,15 +172,12 @@ void test_uSleep_2(void) { void test_uSleep_3(void) { int i, j, k; - //CWM_OS_uSleep 只能到ms,所以实际上等于10000秒 + CWM_OS_dbgPrintf("[test_uSleep_3] test 10 seconds start\r\n"); for (j = 0; j < 10; j ++) { - CWM_OS_dbgPrintf("j=%d\n",j); for (i = 0; i < 1000; i ++) { - if (i%10 == 0) CWM_OS_dbgPrintf("i=%d\n",i); for (k = 0; k < 1000; k ++) { - // if (k%100 == 0) CWM_OS_dbgPrintf("k=%d\n",k); CWM_OS_uSleep(1); } } @@ -199,7 +187,7 @@ void test_uSleep_3(void) { } #ifndef CHECK_STACK_TIME_MS -#define CHECK_STACK_TIME_MS (uint64_t)(1 * 60 * 1000) +#define CHECK_STACK_TIME_MS (uint64_t)(5 * 60 * 1000) #endif void test_stack(void) { @@ -219,8 +207,8 @@ void test_stack(void) { while (1) { for (int i=0; i< sizeof(buff); i++) { - if ( (buff[i]&0xFF) != 0x96) { - CWM_OS_dbgPrintf("[test_stack] somebody touch my stack!!! buf[%d]=0x%X\r\n",i, buff[i]); + if (buff[i] != 0x96) { + CWM_OS_dbgPrintf("[test_stack] somebody touch my stack!!!\r\n"); CWM_OS_dbgPrintf("[test_stack] test for %lld ms end\r\n", CHECK_STACK_TIME_MS); return; } @@ -240,55 +228,17 @@ void test_stack(void) { CWM_OS_dbgPrintf("[test_stack] test for %lld ms end\r\n", CHECK_STACK_TIME_MS); } - -static errcode_t pcm_stream_task_body(void *data) -{ - - - test_malloc_1(); - test_free_1(); +void test_api(void) { test_GetTimeNs_0(); // up_time, accumulate ts_ns from zero test_GetTimeNs_1(); // 10 seconds test_GetTimeNs_2(); // 10 seconds, accurate to 1ms + test_GetTimeNs_3(); // 20 minutes + + test_malloc_1(); + test_free_1(); test_uSleep_1(); // 10 seconds test_uSleep_2(); // 10 seconds, accurate to 1ms - - test_stack(); - test_GetTimeNs_3(); // 20 minutes test_uSleep_3(); // 10 seconds, accurate to 1us - - return ERRCODE_SUCC; } - -#define TASK_PRIORITY_PCM_STREAM (osPriority_t)(osPriorityLow3) -#define PCM_STREAM_MSG_STACK_SIZE 0x1C00 -static osThreadId_t g_test_thread = NULL; -void test_api(void) { - - if (g_test_thread == NULL) - { - osThreadAttr_t attr = {"cywee_test", 0, NULL, 0, NULL, PCM_STREAM_MSG_STACK_SIZE, TASK_PRIORITY_PCM_STREAM, 0, 0 }; - g_test_thread = osThreadNew((osThreadFunc_t)pcm_stream_task_body, NULL, &attr); - if (g_test_thread == NULL) { - CWM_OS_dbgPrintf( "create cywee_test task fail!\r\n"); - }else{ - - } - }else{ - - - osThreadTerminate(g_test_thread); - g_test_thread = NULL; - CWM_OS_dbgPrintf( "create cywee_test task already running stop it !\r\n"); - - } - - -} - - - - - \ No newline at end of file