cywee 更新位p3版本 此次添加了翻腕功能
authorSnickerSun <snickersun@163.com>
Tue, 26 Mar 2024 11:49:42 +0000 (19:49 +0800)
committerSnickerSun <snickersun@163.com>
Tue, 26 Mar 2024 11:49:42 +0000 (19:49 +0800)
code/sdk/drivers/peripheral/cywee/CMakeLists.txt
code/sdk/drivers/peripheral/cywee/Inc/OsApi.h
code/sdk/drivers/peripheral/cywee/Inc/cwm_lib.h
code/sdk/drivers/peripheral/cywee/Lib/CWM_LIB_clang_riscv.p3.a
code/sdk/drivers/peripheral/cywee/service/cywee_service.c
code/sdk/drivers/peripheral/cywee/src/main_dml.c

index bde9d55..568a75f 100644 (file)
@@ -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.p813.a ${CMAKE_CURRENT_SOURCE_DIR})
+    find_library(LIB_PATH_CWM_LIB Lib/CWM_LIB_clang_riscv.p3.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()
 
index 753b230..4ae3003 100644 (file)
@@ -25,8 +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);
@@ -38,7 +37,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);
 } os_api;
-
-// typedef OsAPI os_api;
-
+#else
+typedef OsAPI os_api;
+#endif
 #endif /* __OS_API_H__ */
index 266e876..bf3cc31 100644 (file)
 #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
index 4275ca2..c42a47d 100644 (file)
Binary files a/code/sdk/drivers/peripheral/cywee/Lib/CWM_LIB_clang_riscv.p3.a and b/code/sdk/drivers/peripheral/cywee/Lib/CWM_LIB_clang_riscv.p3.a differ
index 2f2adf0..1f61fae 100644 (file)
@@ -148,7 +148,7 @@ errcode_t uapi_cywee_service_init(void)
     taskcfg.attr.priority = TASK_PRIORITY_APP;
     taskcfg.attr.stack_size = CYWEE_APP_BOARD_TASK_SIZE;
     taskcfg.func = cywee_service_check_task;
-    taskcfg.use_mem = USE_EXTEND_MEM;
+    taskcfg.use_mem = USE_DTCM_MEM;
     
     errcode_t ret=uapi_create_osThread_custom(&taskcfg);
     if(ret != ERRCODE_SUCC)
index 4cad5fe..5922f39 100644 (file)
@@ -189,6 +189,7 @@ int cywee_main_dml(void) {
     CWM_SettingControl(SCL_GET_LIB_INFO, &scl);
     CWM_OS_dbgPrintf("version:%d.%d.%d.%d product:%d model:%d\n", scl.iData[1], scl.iData[2], scl.iData[3], scl.iData[4], scl.iData[5], scl.iData[6]);
     CWM_OS_dbgPrintf("[DBG] ach: %d\n", scl.iData[7]);
+#if USE_P813
     os_api api = {
         .GetTimeNs    = CWM_OS_GetTimeNs,
         .dbgOutput    = CWM_OS_dbgOutput,
@@ -200,6 +201,9 @@ int cywee_main_dml(void) {
         .spiRead      = NULL,
         .spiWrite      = NULL,
     };
+    CWM_LibPreInit(&api);
+
+#else
     OsAPI apiOS = {
         .GetTimeNs    = CWM_OS_GetTimeNs,
         .dbgOutput    = CWM_OS_dbgOutput,
@@ -218,7 +222,8 @@ int cywee_main_dml(void) {
         .enableGpioIRQ      = NULL,
         .disableGpioIRQ      = NULL,
     };
-    CWM_LibPreInit(&api);
+    CWM_LibPreInit(&apiOS);
+#endif
     //CWM_OS_dbgPrintf("[DBG] %s %d\n", __func__,__LINE__);
 
     //set mcu_chip information, must call this before CWM_LibPostInit()
@@ -276,7 +281,8 @@ int cywee_main_dml(void) {
     memset(&scl, 0, sizeof(scl));
     scl.iData[0] = 1;
     scl.iData[3] = 2;
-    scl.iData[4] = 2;
+    scl.iData[4] = 1; //anytime
+    scl.iData[6] = 5; //先設定5
     scl.iData[7] = 5;
     scl.iData[8] = 25; // for st sensor(52Hz)
     CWM_SettingControl(SCL_DML_DRV_AG_CONFIG, &scl);
@@ -307,6 +313,15 @@ int cywee_main_dml(void) {
         CWM_OS_dbgPrintf("DML device[%d]: hw_id=%d hw_attr=%d\n", i, scl.iData[6 + i * 2], scl.iData[7 + i * 2]);
     }
 
+    memset(&scl, 0, sizeof(scl));
+    scl.iData[0] = 1;
+    scl.iData[1] = 5;
+    scl.iData[2] = 5;
+    scl.iData[3] = 5;
+    scl.iData[4] = 5;
+    CWM_SettingControl(SCL_HAND_UPDOWN_CONFIG, &scl);
+   
+
     memset(&scl, 0, sizeof(scl));
     scl.iData[0] = 1;
     scl.iData[1] = 1;
@@ -336,6 +351,7 @@ int cywee_main_dml(void) {
     // CWM_Sensor_Enable(IDX_ALGO_ANY_MOTIOIN);
     CWM_Sensor_Enable(IDX_ALGO_ABSOLUTE_STATIC);
     //CWM_OS_dbgPrintf("[DBG] %s %d\n", __func__,__LINE__);
+    CWM_Sensor_Enable(IDX_ALGO_WATCH_HANDUP);
 
     memset(&scl, 0, sizeof(scl));
     scl.iData[0] = 1;