w9添加陀螺仪和表冠底层驱动服务,产测UI加入陀螺仪测试UI,优化w9底层服务 1751/1
authorpenglei <1624952103@qq.com>
Thu, 15 May 2025 03:10:25 +0000 (11:10 +0800)
committerpenglei <1624952103@qq.com>
Thu, 15 May 2025 03:10:25 +0000 (11:10 +0800)
46 files changed:
code/sdk/application/brandy/brandy_standard/thread_pri_init.c
code/sdk/application/wearable/fd230/service/broadcast/include/broadcast_feature.h
code/sdk/application/wearable/fd230/service/broadcast/src/broadcast_implement.c
code/sdk/application/wearable/fd230/service/msg_center/src/msg_center_customer.cpp
code/sdk/application/wearable/service/broadcast/include/broadcast_feature.h
code/sdk/application/wearable/service/broadcast/src/broadcast_implement.c
code/sdk/build/config/target_config/brandy/config.py
code/sdk/drivers/boards/brandy_evb/board_config/board_w9.h
code/sdk/drivers/drivers/driver/touch/ft6x46_touch/ft6x46_touch1.c
code/sdk/zhihui/UI/producttest/CMakeLists.txt
code/sdk/zhihui/UI/producttest/include/testPresenter.h
code/sdk/zhihui/UI/producttest/include/testView.h
code/sdk/zhihui/UI/producttest/include/testgyro.h [new file with mode: 0644]
code/sdk/zhihui/UI/producttest/src/testView.cpp
code/sdk/zhihui/UI/producttest/src/testgyro.cpp [new file with mode: 0644]
code/sdk/zhihui/drivers/charge/CMakeLists.txt
code/sdk/zhihui/drivers/cywee/Inc/cywee_hal.h
code/sdk/zhihui/drivers/cywee/service/cywee_service.c
code/sdk/zhihui/drivers/cywee/src/main_dml.c
code/sdk/zhihui/drivers/gyro/CMakeLists.txt
code/sdk/zhihui/drivers/gyro/service/gyro_at_cmd.c
code/sdk/zhihui/drivers/gyro/service/gyro_hal.c [new file with mode: 0644]
code/sdk/zhihui/drivers/gyro/service/gyro_hal.h [new file with mode: 0644]
code/sdk/zhihui/drivers/gyro/service/gyro_service.c
code/sdk/zhihui/drivers/gyro/service/gyro_service.h
code/sdk/zhihui/drivers/gyro/sh5001/sh5001.c
code/sdk/zhihui/drivers/gyro/sh5001/sh5001.h
code/sdk/zhihui/drivers/ppg/gh3x2x/src/gh3x2x_hal.c
code/sdk/zhihui/drivers/ppg/hx3695/hx3695.c
code/sdk/zhihui/drivers/ppg/hx3695/hx3695.h
code/sdk/zhihui/drivers/rotary_encoder/CMakeLists.txt
code/sdk/zhihui/drivers/rotary_encoder/hx3508/hx3508_hal.h
code/sdk/zhihui/drivers/rotary_encoder/mixo/mixo_at_cmd.c
code/sdk/zhihui/drivers/rotary_encoder/mixo/mixo_hal.c [new file with mode: 0644]
code/sdk/zhihui/drivers/rotary_encoder/mixo/mixo_hal.h [new file with mode: 0644]
code/sdk/zhihui/drivers/rotary_encoder/mixo/mixo_ots_driver.c
code/sdk/zhihui/drivers/rotary_encoder/mixo/mixo_ots_driver.h
code/sdk/zhihui/drivers/rotary_encoder/mixo/mixo_service.c [new file with mode: 0644]
code/sdk/zhihui/drivers/rotary_encoder/mixo/mixo_service.h [new file with mode: 0644]
code/sdk/zhihui/drivers/rotary_encoder/rotary_encoder_drv.c
code/sdk/zhihui/services/battery/service/battery_driver.cpp
code/sdk/zhihui/services/battery/service/battery_service.cpp
code/sdk/zhihui/services/factorytest_service/factorytest_protocol.c
code/sdk/zhihui/services/factorytest_service/factorytest_protocol.h
code/sdk/zhihui/utils/custom_utils.c
code/sdk/zhihui/utils/custom_utils.h

index fece0ba..cc5570e 100644 (file)
 #include "bp_service.h"\r
 #endif\r
 \r
+#ifdef ENABLE_GYRO\r
+#include "gyro_service.h"\r
+#endif\r
+\r
+#ifdef ROTARYENCODER_MIXO\r
+#include "mixo_service.h"\r
+#endif\r
+\r
 #define EMMC_BASE_ADDR              0x52062000\r
 #define TASK_PRIORITY_APP           (osPriority_t)(17)\r
 #define TICK_TEN_MS                 (10U)\r
@@ -504,8 +512,6 @@ uapi_pm_remove_sleep_veto(PM_ID_DEBUG);
 #endif\r
     \r
 #ifdef ENABLE_CUSTOM_I2C\r
-    custom_i2c_init(I2C_BUS_3);\r
-    custom_i2c_init(I2C_BUS_0);\r
     custom_i2c_init(I2C_BUS_2);\r
 \r
 #ifdef MAG_MMC5603\r
@@ -528,10 +534,14 @@ uapi_pm_remove_sleep_veto(PM_ID_DEBUG);
     uapi_bp_service_init();\r
 #endif\r
 \r
+#ifdef ENABLE_GYRO\r
+    uapi_gyro_service_init();\r
+#endif\r
+\r
+#ifdef ROTARYENCODER_MIXO\r
+    uapi_mixo_service_init();\r
 #endif\r
 \r
-#ifdef ENABLE_CUSTOM_SPI\r
-    custom_spi_init(SPI_BUS_0);\r
 #endif\r
 \r
     /*启动蓝牙ble服务,cywee有重置 mac地址的操作,会需要把 蓝牙服务开启放在cywee服务之后*/\r
index 230fd4a..405a235 100644 (file)
@@ -19,9 +19,9 @@ extern "C" {
 #endif\r
 #endif\r
 \r
-#ifdef SUPPORT_CAT1_SERVICE\r
-#define SUPPORT_CAT1_MODEM\r
-#endif\r
+// #ifdef SUPPORT_CAT1_SERVICE\r
+// #define SUPPORT_CAT1_SERVICE\r
+// #endif\r
 \r
 #ifndef BROADCAST_FEATURE_NAME\r
 #define BROADCAST_FEATURE_NAME "BROADCAST"\r
@@ -74,7 +74,7 @@ typedef enum {
     TOPIC_EVENT_GRAYCARD_UPDATA,\r
     TOPIC_EVENT_LEAKLIGHT_UPDATA,\r
 #endif\r
-#ifdef SUPPORT_CAT1_MODEM\r
+#ifdef SUPPORT_CAT1_SERVICE\r
     TOPIC_EVENT_CAT1_INCOMMING,\r
     TOPIC_EVENT_CAT1_CALLCONNTED,\r
     TOPIC_EVENT_CAT1_CALLENDED,\r
index 7404f17..f12386d 100644 (file)
@@ -77,7 +77,7 @@ static const TopicToCore topicToCoreArray[] = {
     {TOPIC_EVENT_SLEEPNOTE,A_CORE_MASK, 1},
     {TOPIC_EVENT_DEBUGOUTPUT,A_CORE_MASK, 1},
     {TOPIC_EVENT_SHUTDOWN_ANIMATIOR,A_CORE_MASK, 1},
-#ifdef SUPPORT_CAT1_MODEM
+#ifdef SUPPORT_CAT1_SERVICE
     {TOPIC_EVENT_CAT1_INCOMMING, A_CORE_MASK, 1},
     {TOPIC_EVENT_CAT1_CALLCONNTED, A_CORE_MASK, 1},
     {TOPIC_EVENT_CAT1_CALLENDED, A_CORE_MASK, 1},
index 7265709..a0af788 100644 (file)
@@ -135,7 +135,7 @@ const PriorityMapper PRI_MAPPER[] = {
     {TOPIC_EVENT_HFP_PHONE_TO_WATCH, PRIORITY_ONE},
     {TOPIC_EVENT_HFP_HINT, PRIORITY_ONE},
     
-#ifdef SUPPORT_CAT1_MODEM
+#ifdef SUPPORT_CAT1_SERVICE
     {TOPIC_EVENT_CAT1_INCOMMING, PRIORITY_ONE},
     {TOPIC_EVENT_CAT1_CALLCONNTED, PRIORITY_ONE},
     {TOPIC_EVENT_CAT1_CALLENDED, PRIORITY_ONE},
@@ -224,7 +224,7 @@ void MsgCenterSubscribe()
     MsgCenterSubscribeTopic(TOPIC_EVENT_GRAYCARD_UPDATA);
     MsgCenterSubscribeTopic(TOPIC_EVENT_LEAKLIGHT_UPDATA);
 #endif
-#ifdef SUPPORT_CAT1_MODEM
+#ifdef SUPPORT_CAT1_SERVICE
     MsgCenterSubscribeTopic(TOPIC_EVENT_CAT1_INCOMMING);
     MsgCenterSubscribeTopic(TOPIC_EVENT_CAT1_CALLCONNTED);
     MsgCenterSubscribeTopic(TOPIC_EVENT_CAT1_CALLENDED);
@@ -1068,7 +1068,7 @@ void MsgCenterNotifySleepProc(const Topic topic, Request* req)
 }
 #endif
 
-#ifdef SUPPORT_CAT1_MODEM
+#ifdef SUPPORT_CAT1_SERVICE
 //来电处理函数
 void MsgCenterNotifyCatIncomingCallProc(const Topic topic, Request* req)
 {
@@ -1914,7 +1914,7 @@ static MsgCenterNotifyTable g_msgCenterNotifyTable[] = {
     {TOPIC_EVENT_GRAYCARD_UPDATA,       MsgCenterNotifyCardProc},
     {TOPIC_EVENT_LEAKLIGHT_UPDATA,      MsgCenterNotifyleaklightProc},
 #endif
-#ifdef SUPPORT_CAT1_MODEM
+#ifdef SUPPORT_CAT1_SERVICE
     {TOPIC_EVENT_CAT1_INCOMMING,        MsgCenterNotifyCatIncomingCallProc},
     {TOPIC_EVENT_CAT1_CALLCONNTED,      MsgCenterNotifyCat1CallConnectedProc},
     {TOPIC_EVENT_CAT1_CALLENDED,        MsgCenterNotifyCat1CallEndedProc},
index 3c9fcf0..bd1d065 100644 (file)
@@ -19,7 +19,7 @@ extern "C" {
 #endif\r
 #endif\r
 \r
-#define SUPPORT_CAT1_MODEM\r
+#define SUPPORT_CAT1_SERVICE\r
 \r
 #ifndef BROADCAST_FEATURE_NAME\r
 #define BROADCAST_FEATURE_NAME "BROADCAST"\r
@@ -72,7 +72,7 @@ typedef enum {
     TOPIC_EVENT_GRAYCARD_UPDATA,\r
     TOPIC_EVENT_LEAKLIGHT_UPDATA,\r
 #endif\r
-#ifdef SUPPORT_CAT1_MODEM\r
+#ifdef SUPPORT_CAT1_SERVICE\r
     TOPIC_EVENT_CAT1_INCOMMING,\r
     TOPIC_EVENT_CAT1_CALLCONNTED,\r
     TOPIC_EVENT_CAT1_CALLENDED,\r
index 7404f17..f12386d 100644 (file)
@@ -77,7 +77,7 @@ static const TopicToCore topicToCoreArray[] = {
     {TOPIC_EVENT_SLEEPNOTE,A_CORE_MASK, 1},
     {TOPIC_EVENT_DEBUGOUTPUT,A_CORE_MASK, 1},
     {TOPIC_EVENT_SHUTDOWN_ANIMATIOR,A_CORE_MASK, 1},
-#ifdef SUPPORT_CAT1_MODEM
+#ifdef SUPPORT_CAT1_SERVICE
     {TOPIC_EVENT_CAT1_INCOMMING, A_CORE_MASK, 1},
     {TOPIC_EVENT_CAT1_CALLCONNTED, A_CORE_MASK, 1},
     {TOPIC_EVENT_CAT1_CALLENDED, A_CORE_MASK, 1},
index 2e40b9e..1312d53 100644 (file)
@@ -568,12 +568,13 @@ target = {
                     'SUPPORT_AT_CUSTOMUTILS',
                     'CYWEE_SPORT',
                     'CYWEE_MAC_ACTIVE',
+                    'SUPPORT_CAT1_SERVICE',
                     'SUPPORT_TCPIP',                                   
                     'SUPPORT_HID_SERVICE',
                     'SUPPORT_BAIDU_MAP',
-                    'CFG_FLASH_SIZE=8',
+                    'CFG_FLASH_SIZE=16',
                     'SUPPORT_BLE_SERVICE',
-                    # 'FD230',
+                    'FD230',
                     #"MEM_CHECK",
                     #'ENABLE_WEBSOCKET',
                     'SINGLE_USER_PARTITION',
@@ -588,9 +589,11 @@ target = {
                     'TEST_4G_UI',
                     'TEST_GPS_UI',
                     'NANDFLASH_F35UQA',
-                    #'BLE_INSTRUCT',
+                    'BLE_INSTRUCT',
                     'FACTORYTEST_SERVICE',
                     'PPG_GH3X2X',
+                    'GYRO_SH5001',
+                    'ROTARYENCODER_MIXO',
                     ],
                'ram_component': [
                         #'baidumapsdk',
@@ -605,7 +608,7 @@ target = {
                         "slip",
                         "cat1_service",
                         "audio_manager",
-                        #"CustomUIcomponentTool",
+                        "CustomUIcomponentTool",
                         "custom_utils",
                         "custom_utilscpp",
                         "custom_config",
@@ -615,19 +618,20 @@ target = {
                         "gnss",
                         "gnss_sample",
                         #    "acc_sensor",
-                           "batterry_service",
-                           "bleservice",
-                           "ppgBleService",
-                           #"blemoder",
-                          "factorytest_service",
-                         "hid_service",
-                         "producttest",
+                        "batterry_service",
+                        "bleservice",
+                        "ppgBleService",
+                        "blemoder",
+                        "factorytest_service",
+                        "hid_service",
+                        "producttest",
                         "cywee",
                         "ppg_sensor_gh3x2x",
                         "bp_sensor",
+                        'gyro',
                            ],
                'image_analysis': False,
-               'fs_image_path':'evb',
+               'fs_image_path':'fd230',
                'fs_image': True
     },
     'brandy-native-js-w9-r': {
@@ -635,9 +639,9 @@ target = {
         #自定义配置项,选择硬件及功能参数
         'defines': [
             'BOARD_W9',
-            'CFG_FLASH_SIZE=8',
+            'FD230',
+            'CFG_FLASH_SIZE=16',
             'FT_SINGLE_UART',
-            'CFG_FLASH_SIZE=8',
             'SINGLE_USER_PARTITION',
             'TPTYPE_CST86XX',
             'NANDFLASH_F35UQA'
@@ -649,12 +653,13 @@ target = {
         #自定义配置项,选择硬件及功能参数
         'defines': [
             'BOARD_W9',
+            'FD230',
             'FT_SINGLE_UART',
             'ENABLE_ECC',
             'CFG_DRIVERS_NANDFLASH',
             'SINGLE_USER_PARTITION',
             'GPIO_POWERON_FLASH',
-            'CFG_FLASH_SIZE=8',
+            'CFG_FLASH_SIZE=16',
             'NANDFLASH_F35UQA'            
         ]
     },
index b506e9c..d43bff4 100644 (file)
@@ -19,6 +19,15 @@ extern void bp_int_callback(pin_t pin, uintptr_t param);
 extern void ppg_int_callback(pin_t pin, uintptr_t param);
 #endif
 
+#ifdef ENABLE_GYRO
+extern void gyro_int_callback(pin_t pin, uintptr_t param);
+#endif
+
+#ifdef ROTARYENCODER_MIXO
+extern void mixo_int_callback(pin_t pin, uintptr_t param);
+#endif
+
+
 /**
  * @addtogroup connectivity_config_boards
  * @{
@@ -153,6 +162,7 @@ const hal_pio_config_t g_pio_function_config[PIN_MAX_NUMBER] = {
     { HAL_PIO_FUNC_GPIO, HAL_PIO_DRIVE_MAX, HAL_PIO_PULL_DOWN, HAL_PIO_IE_DISABLE },     // S_MGPIO37 uart tx  NC
     { HAL_PIO_FUNC_GPIO, HAL_PIO_DRIVE_MAX, HAL_PIO_PULL_DOWN, HAL_PIO_IE_DISABLE },       // S_MGPIO38 uart rx  NC
 #endif
+
     { HAL_PIO_FUNC_GPIO, HAL_PIO_DRIVE_MAX, HAL_PIO_PULL_MAX, HAL_PIO_IE_ENBALE },     // S_AGPIO_L0  NC
 
     { HAL_PIO_FUNC_I2S1_M1, HAL_PIO_DRIVE_MAX, HAL_PIO_PULL_MAX, HAL_PIO_IE_ENBALE },   // S_AGPIO_L1 i2s1
@@ -320,7 +330,7 @@ const hal_gpio_config_t g_gpio_function_config[PIN_MAX_NUMBER] = {
 
 #endif
 #ifdef ENABLE_GYRO
-     {   S_AGPIO_R8, HAL_GPIO_DIRECTION_OUTPUT, HAL_GPIO_LEVEL_HIGH, 0, NULL },
+     {   S_AGPIO_R8, HAL_GPIO_DIRECTION_INPUT, NULL, GPIO_INTERRUPT_RISING_EDGE, gyro_int_callback },
 #else
   /**S_AGPIO_L32 GPO gps reset*/
     // {   S_AGPIO_L32, HAL_GPIO_DIRECTION_OUTPUT, HAL_GPIO_LEVEL_LOW, 0, NULL },
@@ -331,6 +341,9 @@ const hal_gpio_config_t g_gpio_function_config[PIN_MAX_NUMBER] = {
 #ifdef PPG_GH3X2X
     // {   S_AGPIO_R6, HAL_GPIO_DIRECTION_INPUT, NULL, GPIO_INTERRUPT_RISING_EDGE,  ppg_int_callback},
 #endif
+#ifdef ROTARYENCODER_MIXO
+    // {   S_AGPIO_L0, HAL_GPIO_DIRECTION_INPUT, NULL, GPIO_INTERRUPT_DEDGE,  mixo_int_callback},
+#endif
 };
 /**
  * @}
index aa6f91c..d5b3894 100644 (file)
@@ -392,15 +392,15 @@ static ext_errno ft6x46_power_sequence(void)
     /*get chip id*/
     ret = tp_ft6x46_i2c_data_read(FTS_REG_CHIP_ID, &chip_id[0], 1);
     if (ret != EXT_ERR_SUCCESS) {
-        tp_err("222222222get ic information, error1");
+        tp_err("get ic information, error1");
         return EXT_ERR_TP_ZTW523_POWERUP_READ_CHIPID;
     }
     ret = tp_ft6x46_i2c_data_read(FTS_REG_CHIP_ID2, &chip_id[1], 1);
     if (ret != EXT_ERR_SUCCESS) {
-        tp_err("3333333get ic information, error2");
+        tp_err("get ic information, error2");
         return EXT_ERR_TP_ZTW523_POWERUP_READ_CHIPID;
     }
-    // tp_print("11111111111111get ic information, chip id = 0x%02x%02x",  chip_id[0], chip_id[1]);
+    // tp_print("get ic information, chip id = 0x%02x%02x",  chip_id[0], chip_id[1]);
     if ((FTS_CHIP_IDH == chip_id[0]) && (FTS_CHIP_IDL == chip_id[1])) {
         tp_warning("get ic information, chip id = 0x%02x%02x",  chip_id[0], chip_id[1]);
         return EXT_ERR_SUCCESS;
index e3e73c1..b4b984b 100644 (file)
@@ -27,6 +27,7 @@ set(SOURCES
     ${CMAKE_CURRENT_SOURCE_DIR}/src/testPing.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/src/testGPS.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/src/testpressure.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/src/testgyro.cpp
     
 )
 
index e1aedea..15eeac5 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: penglei 1624952103@qq.com\r
  * @Date: 2024-08-23 10:50:37\r
  * @LastEditors: penglei 1624952103@qq.com\r
- * @LastEditTime: 2024-11-05 14:34:43\r
+ * @LastEditTime: 2025-05-13 18:35:42\r
  * @FilePath: /FD230/code/sdk/application/wearable/fd230/nativeapp/nativeui/producttest/include/testPresenter.h\r
  * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE\r
  */\r
@@ -37,7 +37,7 @@ namespace OHOS
         CHARG,\r
         SPEAK,\r
         MOTOR,\r
-#ifdef SUPPORT_CAT1_MODEM\r
+#ifdef SUPPORT_CAT1_SERVICE\r
         CAT1,\r
 #endif\r
         BUTTON,\r
@@ -47,10 +47,15 @@ namespace OHOS
         BTTEST,\r
         SEChipTest,\r
         PingTest,\r
-\r
+#ifdef SUPPORT_GNSS\r
         GPSTEST,\r
-        // pressuretest,\r
+#endif\r
+#ifdef ENABLE_LQBP002TA\r
         PRESSURETEST,\r
+#endif\r
+#ifdef ENABLE_GYRO\r
+        GYROTEST,\r
+#endif\r
         OLDTEST,\r
         DEEPSLEEP,\r
         \r
index 9c0d29c..5899ada 100644 (file)
@@ -31,6 +31,7 @@
 #include "producttest/include/testPing.h"\r
 #include "producttest/include/testGPS.h"\r
 #include "producttest/include/testpressure.h"\r
+#include "producttest/include/testgyro.h"\r
 \r
 #ifdef SUPPORT_A5133_SERVICE\r
 #include "producttest/include/testA5133.h"\r
@@ -101,6 +102,7 @@ namespace OHOS
         bool ChangePingTESTView(int16_t thisView);\r
         bool ChangeGPSTESTView(int16_t thisView);\r
         bool ChangepressureTestTESTView(int16_t thisView);\r
+        bool ChangegyroTestTESTView(int16_t thisView);\r
     #ifdef SUPPORT_A5133_SERVICE\r
         bool ChangeA5133TESTView(int16_t thisView);\r
     #endif\r
@@ -128,7 +130,7 @@ namespace OHOS
         testCHANINGView *test_charging_view{nullptr};\r
         testSPEAKView *test_speak_view{nullptr};\r
         testMOTORView *test_motor_view{nullptr};\r
-        // #ifdef SUPPORT_CAT1_MODEM\r
+        // #ifdef SUPPORT_CAT1_SERVICE\r
         testcat1View *test_cat1_view{nullptr};\r
         // #endif\r
         testbuttonView *test_KEY_view{nullptr};\r
@@ -144,6 +146,7 @@ namespace OHOS
         testPingView *test_Ping_view{nullptr};\r
         testGPSView *test_GPS_view{nullptr};\r
         testpressureView * test_pressure_view{nullptr};\r
+        testgyroView * test_gyro_view{nullptr};\r
         \r
     #ifdef SUPPORT_A5133_SERVICE\r
         testA5133View  *test_A5133_view{nullptr};\r
diff --git a/code/sdk/zhihui/UI/producttest/include/testgyro.h b/code/sdk/zhihui/UI/producttest/include/testgyro.h
new file mode 100644 (file)
index 0000000..cc4b8fa
--- /dev/null
@@ -0,0 +1,88 @@
+/*
+ * @Author: penglei 1624952103@qq.com
+ * @Date: 2025-05-12 15:44:33
+ * @LastEditors: penglei 1624952103@qq.com
+ * @LastEditTime: 2025-05-13 15:38:45
+ * @FilePath: /sdk615/code/sdk/zhihui/UI/producttest/include/testgyro.h
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
+ */
+#ifndef TEST_GYRO_VIEW_H
+#define TEST_GYRO_VIEW_H
+
+#include "BaseView.h"
+#include "View.h"
+#include "components/ui_scroll_view.h"
+#include "components/ui_label.h"
+#include "components/ui_label_ext.h"
+#include "components/ui_button.h"
+#include "components/ui_image_view.h"
+#include "components/ui_label_button_ext.h"
+
+//#include "cmsis_os.h"
+#include <iostream>
+namespace OHOS
+{
+
+    class testgyroView
+    {
+
+    public:
+       struct ButtonConfig_ext_t
+        {
+            int x;
+            int y;
+            int w;
+            int h;
+            const char *str;
+            const char *ViewId;
+            const char *ImageSrc;
+
+            //label
+            int label_x;
+            int label_y;
+            uint8_t ALIGN;
+            int  Fontsize;
+        
+        };
+
+
+        
+        struct LabelConfig
+        {
+            int16_t left;
+            int16_t top;
+            int16_t width;
+            int16_t height;
+            int16_t fontSize;      // 字体大小
+            int16_t lineHeigh;     // 行高
+            char *text;      // 文本
+            uint8_t lineBreakMode; // 断行模式。
+        };
+
+
+       
+        
+        testgyroView();
+        virtual ~testgyroView();
+        static testgyroView *GetInstance(void);
+   
+        UIScrollView *testgyroInitIView(uint8_t);
+        void  gyrodataTimerCallBack(void);
+
+        void ClearAll(void);
+    private:
+        UILabelButtonExt *SetTheButton_ext(ButtonConfig_ext_t &buttonconfig);//, UIView::OnTouchListener *clickListener);
+        UILabel *InitLabel(LabelConfig &labelConfig);
+        bool testgyroScrollViewcrollViewinit(uint8_t);
+        UIScrollView *testgyroScrollView{nullptr};
+        UILabel *label_1_MSG=NULL;
+        UILabel *label_2_MSG{nullptr};
+        UILabel *label_3_MSG{nullptr};
+
+        UILabelButtonExt* labelButton_next = nullptr;
+        bool initViewStatus{false};
+        UILabel *Title{nullptr};           // 标题
+
+    };
+}
+#endif
\ No newline at end of file
index bbb64bd..e7072d1 100644 (file)
@@ -33,7 +33,7 @@ namespace OHOS
         {SPEAK,"speakButton","speak","speakButton_next" ,&testView::ChangspeakTESTView,true},\r
 \r
         {MOTOR,"motorButton","motor","motorButton_next" ,&testView::ChangmotorTESTView,true},\r
-    #ifdef SUPPORT_CAT1_MODEM\r
+    #ifdef SUPPORT_CAT1_SERVICE\r
         {CAT1,"cat1button","CAT1", "cat1button_next",&testView::ChangeCAT1TESTView,true},\r
     #endif\r
         {BUTTON,"buttonbutton","button" ,"buttonbutton_next",&testView::ChangKEYTESTView,true},\r
@@ -47,10 +47,15 @@ namespace OHOS
 #if defined(SUPPORT_GNSS)\r
         {GPSTEST,"GPSTestbutton","GPSTest","GPSTestbutton_next" ,&testView::ChangeGPSTESTView,true},\r
 #endif\r
+#if defined(ENABLE_LQBP002TA)\r
         {PRESSURETEST,"pressureTestbutton","pressureTest","pressureTestbutton_next" ,&testView::ChangepressureTestTESTView,true},\r
-    #ifdef AGINGTEST\r
+#endif\r
+#if defined(ENABLE_GYRO)\r
+        {GYROTEST,"gyroTestbutton","gyroTest","gyroTestbutton_next" ,&testView::ChangegyroTestTESTView,true},\r
+#endif\r
+#ifdef AGINGTEST\r
         {OLDTEST,"oldtestbutton","aging" ,"oldtestexit",&testView::ChangeoldTESTView,true},\r
-    #endif\r
+#endif\r
         {DEEPSLEEP,"deepsleep","DeepSleepCurrent","xxxxxxxxx" ,&testView::ChangeoldTESTView,true},\r
         {shutdown,"shutdown","shutdown", "xxxxxxxxx",&testView::ChangeoldTESTView,true},\r
         {RESET,"reset","reset", "xxxxxxxxx",&testView::ChangeoldTESTView,true},\r
@@ -129,7 +134,7 @@ namespace OHOS
             delete test_motor_view;//7\r
             test_motor_view = nullptr;\r
             }\r
-#ifdef SUPPORT_CAT1_MODEM\r
+#ifdef SUPPORT_CAT1_SERVICE\r
             if(test_cat1_view)\r
             {\r
             delete test_cat1_view;//8\r
@@ -650,7 +655,7 @@ SystemScrollView[TESTVIEW]->SetStyle(STYLE_BORDER_RADIUS, 0);
 \r
      bool testView::ChangepressureTestTESTView(int16_t thisView)\r
     {\r
-\r
+#if defined(ENABLE_LQBP002TA)\r
         if (SystemScrollView[thisView] == nullptr)\r
         {\r
             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::ChangeSEChipTESTView");\r
@@ -664,6 +669,26 @@ SystemScrollView[TESTVIEW]->SetStyle(STYLE_BORDER_RADIUS, 0);
             RootView::GetInstance()->Add(SystemScrollView[thisView]);\r
         }\r
 \r
+#endif\r
+        return true;\r
+    }\r
+\r
+    bool testView::ChangegyroTestTESTView(int16_t thisView)\r
+    {\r
+#if defined(ENABLE_GYRO)\r
+        if (SystemScrollView[thisView] == nullptr)\r
+        {\r
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::ChangeSEChipTESTView");\r
+            test_gyro_view = new testgyroView();\r
+            if (test_gyro_view == nullptr)\r
+            {\r
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView:: new scrollView[%d] fail", thisView);\r
+                return false;\r
+            }\r
+            SystemScrollView[thisView] = test_gyro_view->testgyroInitIView((uint8_t)thisView);\r
+            RootView::GetInstance()->Add(SystemScrollView[thisView]);\r
+        }\r
+#endif\r
         return true;\r
     }\r
 \r
@@ -784,7 +809,7 @@ SystemScrollView[TESTVIEW]->SetStyle(STYLE_BORDER_RADIUS, 0);
                 test_motor_view = nullptr;\r
                  SystemScrollView[hideView]=nullptr;\r
             break;\r
-#ifdef SUPPORT_CAT1_MODEM\r
+#ifdef SUPPORT_CAT1_SERVICE\r
              case CAT1:\r
                 RootView::GetInstance()->Remove(SystemScrollView[hideView]);\r
                 delete test_cat1_view;  \r
@@ -856,12 +881,22 @@ SystemScrollView[TESTVIEW]->SetStyle(STYLE_BORDER_RADIUS, 0);
                 SystemScrollView[hideView]=nullptr;\r
                 break;\r
 #endif\r
+#if defined(ENABLE_LQBP002TA)\r
              case PRESSURETEST:\r
                 RootView::GetInstance()->Remove(SystemScrollView[hideView]);\r
                 delete test_pressure_view;  \r
                 test_pressure_view = nullptr;\r
                 SystemScrollView[hideView]=nullptr;\r
                 break;\r
+#endif\r
+#if defined(ENABLE_GYRO)\r
+             case GYROTEST:\r
+                RootView::GetInstance()->Remove(SystemScrollView[hideView]);\r
+                delete test_gyro_view;  \r
+                test_gyro_view = nullptr;\r
+                SystemScrollView[hideView]=nullptr;\r
+                break;\r
+#endif\r
 \r
            default:\r
             break;\r
diff --git a/code/sdk/zhihui/UI/producttest/src/testgyro.cpp b/code/sdk/zhihui/UI/producttest/src/testgyro.cpp
new file mode 100644 (file)
index 0000000..1cd7277
--- /dev/null
@@ -0,0 +1,291 @@
+#include "wearable_log.h"
+#include "custom_utils.h"
+#include "producttest/include/testPresenter.h"
+
+#include "cmsis_os2.h"
+#include "producttest/include/testView.h"
+#include "producttest/include/testgyro.h"
+// #include "gnss_sample.h"
+#include "graphic_service.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C"
+{
+#endif
+#endif
+#ifdef ENABLE_GYRO
+#include "gyro_service.h"
+#include "gyro_hal.h"
+#endif
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif
+#endif
+
+
+
+namespace OHOS
+{
+
+    static testgyroView *g_pSystemAboutTheWatchView{nullptr};
+
+    testgyroView::testgyroView()
+    {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemAboutTheWatchView::SystemAboutTheWatchView");
+        g_pSystemAboutTheWatchView = this;
+    }
+
+    testgyroView::~testgyroView()
+    {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "testgyroView::~testgyroView");
+        ClearAll();
+        //g_pSystemAboutTheWatchView = nullptr;
+    }
+
+    testgyroView *testgyroView::GetInstance()
+    {
+
+        return g_pSystemAboutTheWatchView;
+    }
+    static osTimerId_t  P_TEST_timer=NULL;
+
+    void testgyroView::ClearAll()
+    {
+#ifdef ENABLE_GYRO
+        gyro_stop();
+#endif
+        if(testgyroScrollView)
+        {
+            testgyroScrollView->RemoveAll();
+
+            if (P_TEST_timer != NULL) {
+                osTimerStop(P_TEST_timer);
+                osTimerDelete(P_TEST_timer);
+                P_TEST_timer = NULL;
+            }
+            if(labelButton_next)
+            {
+                delete labelButton_next;
+                labelButton_next=nullptr;
+            }
+            if(label_1_MSG)
+            {
+                delete label_1_MSG;
+                label_1_MSG=nullptr;
+            }
+
+            if(label_2_MSG)
+            {
+                delete label_2_MSG;
+                label_2_MSG=nullptr;
+            }
+
+            if(label_3_MSG)
+            {
+                delete label_3_MSG;
+                label_3_MSG=nullptr;
+            }
+
+            if(Title)
+            {
+                delete Title;
+                Title=nullptr;
+            }
+        
+            delete testgyroScrollView;
+            testgyroScrollView=nullptr;
+       }
+    }
+   
+    UILabelButtonExt *testgyroView::SetTheButton_ext(ButtonConfig_ext_t &buttonconfig)
+    {
+        UILabelButtonExt *button = new UILabelButtonExt();
+        if (button == nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " SystemView::SetTheButton: button new  fail!");
+            return nullptr;
+        }
+        button->SetPosition(buttonconfig.x, buttonconfig.y, buttonconfig.w, buttonconfig.h);
+        button->SetViewId(buttonconfig.ViewId);
+        button->SetStyle(STYLE_BACKGROUND_COLOR, Color::Blue().full);
+        //button->SetStyle(STYLE_BORDER_RADIUS,0);
+        button->SetStyleForState(STYLE_BACKGROUND_COLOR, Color::Black().full, UIButton::PRESSED);
+        //button->SetStyleForState(STYLE_BORDER_RADIUS,0, UIButton::PRESSED);
+        button->SetTouchable(true);
+        button->SetStyle(STYLE_BACKGROUND_OPA, 0x80);
+        button->SetText(buttonconfig.str);
+        button->SetAlign(TEXT_ALIGNMENT_LEFT);
+        button->SetLabelPosition(buttonconfig.label_x,buttonconfig.label_y );
+        button->SetFont(DEFAULT_VECTOR_FONT_FILENAME_EN, buttonconfig.Fontsize);
+        UIView:: OnClickListener *touchListener = static_cast<UIView::OnClickListener *>(testPresenter::GetInstance());
+        button->SetOnClickListener(touchListener);
+
+        return button;
+    }
+   
+     UILabel *testgyroView::InitLabel(LabelConfig &labelConfig)
+    {
+        UILabel *label = new UILabel();
+        if (label == nullptr)
+        {
+            return nullptr;
+        }
+        label->SetPosition(labelConfig.left, labelConfig.top, labelConfig.width, labelConfig.height); // 位置大小
+        label->SetStyle(STYLE_TEXT_FONT, labelConfig.fontSize);                                       // 字体大小
+        label->SetStyle(STYLE_LINE_HEIGHT, labelConfig.lineHeigh);                                    // 字体行高
+        label->SetText(labelConfig.text);                                                             // 内容
+        label->SetLineBreakMode(labelConfig.lineBreakMode);                                           // 断行模式。
+        label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_TOP);
+        label->SetFont(DEFAULT_VECTOR_FONT_FILENAME_EN, labelConfig.fontSize);
+        label->SetAlign(TEXT_ALIGNMENT_LEFT);
+        return label;
+    }
+    
+
+    void testgyroView:: gyrodataTimerCallBack(void)
+    {
+        //此处实现数据刷新
+        char buf1[32]={0};
+        char buf2[32]={0};
+        char buf3[32]={0};
+#ifdef ENABLE_GYRO
+        gyro_data_t data = gyro_get_data();
+
+        // printf("gyro.x:%.2f gyro.y:%.2f gyro.z:%.2f \n",data.x,data.y,data.z);
+
+        sprintf(buf1,"gyro.x:%.2f",data.x);
+        sprintf(buf2,"gyro.y:%.2f",data.y);
+        sprintf(buf3,"gyro.z:%.2f",data.z);
+#endif
+        label_1_MSG->SetText(buf1);
+        label_2_MSG->SetText(buf2);
+        label_3_MSG->SetText(buf3);
+        RootView::GetInstance()->Invalidate();
+    }
+
+    void gyrodataTimerCallBackproc()
+    {
+         GraphicService::GetInstance()->PostGraphicEvent(std::bind(&testgyroView::gyrodataTimerCallBack,testgyroView::GetInstance()));
+    }
+
+    
+    bool testgyroView::testgyroScrollViewcrollViewinit(uint8_t id)
+    {
+
+        testgyroScrollView = new UIScrollView();
+        if (testgyroScrollView == nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemAboutTheWatchView::testgyroScrollView new fail!");
+            return false;
+        }
+        testgyroScrollView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());
+        testgyroScrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
+        testgyroScrollView->SetStyle(STYLE_BORDER_RADIUS, 0);
+        testgyroScrollView->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full);
+        testgyroScrollView->SetStyle(STYLE_BORDER_COLOR, Color::Yellow().blue);
+
+
+        UIView::OnDragListener *draglistener = static_cast<UIView::OnDragListener *>(testPresenter::GetInstance());
+        if (draglistener == nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::draglistener can not be nullptr!");
+            return false;
+        }
+       testgyroScrollView->SetOnDragListener(draglistener);
+
+        LabelConfig Config = {
+            .left = 100,
+            .top = 100,
+            .width = 300,
+            .height = 35,
+            .fontSize = 40,
+            .lineHeigh = 35,
+            .text = "",
+            .lineBreakMode = UILabel::LINE_BREAK_WRAP,
+        };
+        label_1_MSG= InitLabel(Config);
+        if (label_1_MSG == nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::SystemAboutTheWatchTitle new fail!");
+            return false;
+        }
+        testgyroScrollView->Add(label_1_MSG);
+
+        Config = {
+            .left = 100,
+            .top = 180,
+            .width = 300,
+            .height = 35,
+            .fontSize = 40,
+            .lineHeigh = 35,
+            .text = "",
+            .lineBreakMode = UILabel::LINE_BREAK_WRAP,
+        };
+        label_2_MSG= InitLabel(Config);
+        if (label_2_MSG == nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::SystemAboutTheWatchTitle new fail!");
+            return false;
+        }
+        testgyroScrollView->Add(label_2_MSG);
+
+        Config = {
+            .left = 100,
+            .top = 260,
+            .width = 300,
+            .height = 35,
+            .fontSize = 40,
+            .lineHeigh = 35,
+            .text = "",
+            .lineBreakMode = UILabel::LINE_BREAK_WRAP,
+        };
+        label_3_MSG= InitLabel(Config);
+        if (label_3_MSG == nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::SystemAboutTheWatchTitle new fail!");
+            return false;
+        }
+        testgyroScrollView->Add(label_3_MSG);
+
+        labelButton_next= testAboutView::GetInstance()->init_button_next(267,320,Test_ViewMapper_t[id].viewid_str_next);
+        testgyroScrollView->Add(labelButton_next);
+        
+        Title= testAboutView::GetInstance()->init_title(125,45,"GYRO_TEST");
+        testgyroScrollView->Add(Title);
+
+
+        testgyroScrollView->SetTouchable(true);
+        testgyroScrollView->SetDraggable(true);
+
+#ifdef ENABLE_GYRO
+        gyro_start();
+#endif
+
+        uint32_t tick;
+        osStatus_t retTimer;
+        P_TEST_timer = osTimerNew((osTimerFunc_t)gyrodataTimerCallBackproc, osTimerPeriodic, NULL, NULL);
+        tick =2000;// osMs2Tick(1000);
+        retTimer = osTimerStart(P_TEST_timer, tick);
+        if (retTimer != osOK && P_TEST_timer != NULL) {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"StartCallTimer osTimerStart failed, ret = %lx!!", retTimer);
+            osTimerDelete(P_TEST_timer);
+            P_TEST_timer = NULL;
+            return false;
+        }
+        return true;
+    }
+
+    UIScrollView *testgyroView::testgyroInitIView(uint8_t id)
+    {
+        if (!testgyroScrollViewcrollViewinit(id))
+        {
+            return nullptr;
+        }
+        return testgyroScrollView;
+    }
+}
+
+// #endif
index 97149a1..7648073 100644 (file)
@@ -26,7 +26,7 @@ set(PRIVATE_DEFINES
 
 set(PUBLIC_DEFINES
 SUPPORT_AT_CHARGE
-ENABLE_HP4507
+ENABLE_HP4570
 )
 
 # use this when you want to add ccflags like -include xxx
index 4a86e89..216fd97 100644 (file)
@@ -527,7 +527,7 @@ cywee_msg_callback_t cywee_get_send_msg_callback_func(void);
 void activity_mode_setstatus(int cmd);
 void cywee_oncharging_update(int oncharging_status);
 void cywee_wearstatus_update(int wearstatus);
-void cywee_hrs_update(int hrs_data);
+void cywee_hrs_update(void);
 void cywee_set_user_info(void);
 void cywee_get_sleep_data(int cmd);
 void cywee_reset_daily_data(void);
index b40f7a2..85ccbd3 100644 (file)
@@ -321,7 +321,7 @@ static void cywee_service_check_task(void const *arg)
             break;
 
             case CYWEE_SERVICE_CMD_HRS_CHANGE:
-                cywee_hrs_update(mail.data);
+                // cywee_hrs_update(mail.data);
             break;
 
             case CYWEE_SERVICE_CMD_SEDENTARY_MODE:
@@ -462,7 +462,7 @@ errcode_t uapi_cywee_service_init(void)
 
 void cywee_int_callback(pin_t pin, uintptr_t param)
 {
-    //PRINT("cywee_int1_callback %d 0x%X\n",pin,param);
+    // PRINT("cywee_int1_callback %d 0x%X\n",pin,param);
     uapi_gpio_clear_interrupt(pin);
     do_cywee_service_check_msg(CYWEE_SERVICE_CMD_TIMER_CHECK, NULL);
 }
index 38ea99f..c21b2b7 100644 (file)
 #endif
 #include "custom_save_runtime.h"
 
+#ifdef SUPPORT_GNSS
+#include "gnss_ctl.h"
+#include "NMEA0183.h"
+#endif
+
+#ifdef PPG_HX3695
+#include "hx3695.h"
+#endif
+
 #define AP_ENABLE_DML_SDO_LISTEN
 
 #define GSENSON_MSG_COUNT   64
@@ -128,6 +137,85 @@ static uint8_t timeout = 0;
 
 static uint8_t wake_up_flag = 0;
 
+static osTimerId_t g_sport_timer = NULL;
+static bool g_sport_stat = false;
+#define SPORT_CHECK_MS 1000
+
+void cywee_gnss_update(void)
+{
+#ifdef SUPPORT_GNSS
+    gps_data_t *gps_data = getGPSGlobaldata();
+    if(gps_data == NULL)
+    {
+        PRINT("gps_data == NULL \n");
+        return;
+    }
+
+    if(gps_data->status < 1)
+        return;
+
+    memset(&csd, 0, sizeof(CUSTOM_GNSS));
+    csd.sensorType = CUSTOM_GNSS;
+    csd.dData[0] = gps_data->location.lat;//latitude (degrees)  (range: -90~90);  //纬度
+    csd.dData[1] = gps_data->location.lng;//longitude (degrees) (range: -180~180) //经度
+    csd.dData[2] =  gps_data->location.alt;//altitude   (meters)  //海拔
+    csd.dData[3] = gps_data->ground_course;//bearing  (heading in degrees)  //方位角
+    csd.dData[4] = gps_data->ground_speed;//speed (m/s) //速度
+    csd.dData[5] = gps_data->hdop;//Horizontal_Accuracy (meters) //水平精度
+    csd.dData[6] = gps_data->vdop;//Vertical_Accuracy (meters) //垂直精度
+    csd.dData[7] = 0;  //水平精度衰减因子
+    csd.dData[8] = 0; //垂直精度衰减因子
+    CWM_CustomSensorInput(&csd); 
+#endif
+}
+
+
+void cywee_hrs_update(void)
+{
+    uint8_t hrs_data = 0;
+#ifdef PPG_HX3695
+    // hrs = hrs_data;
+    // CWM_OS_dbgPrintf("hrs_data : %d\r\n",hrs_data);
+    hrs_data = hx3695_get_hrs();
+#endif
+    memset(&csd, 0, sizeof(CUSTOM_HEARTRATE));
+    csd.sensorType = CUSTOM_HEARTRATE;
+    csd.fData[0] = hrs_data;
+    CWM_CustomSensorInput(&csd); 
+}
+
+static void cywee_service_check_timer_callback(void)
+{
+    cywee_hrs_update();
+    cywee_gnss_update();
+}
+
+static void cywee_sport_timer_start_check(uint32_t rtc_ms)
+{
+    if (g_sport_timer == NULL)
+        return;
+
+    if (!g_sport_stat)
+    {
+        osTimerStart(g_sport_timer, rtc_ms);
+        g_sport_stat = true;
+    }
+
+}
+
+static void cywee_sport_timer_stop_check(void)
+{
+    if (g_sport_timer == NULL)
+        return;
+
+    if (g_sport_stat)
+    {
+        osTimerStop(g_sport_timer);
+        g_sport_stat = false;
+    }
+}
+
+
 #ifdef CYWEE_MAC_ACTIVE
 int cm__hs1__mac_c1_init(void);
 int cm__hs1__deinit(void);
@@ -842,16 +930,6 @@ void cywee_time_sync(void)
     uapi_create_folder(dir_path);
 }
 
-void cywee_hrs_update(int hrs_data)
-{
-    // hrs = hrs_data;
-    // CWM_OS_dbgPrintf("hrs_data : %d\r\n",hrs_data);
-    memset(&csd, 0, sizeof(CUSTOM_HEARTRATE));
-    csd.sensorType = CUSTOM_HEARTRATE;
-    csd.fData[0] = hrs_data;
-    CWM_CustomSensorInput(&csd); 
-}
-
 void cywee_oncharging_update(int oncharging_status)
 {
     // CWM_OS_dbgPrintf("oncharging : %d\r\n",oncharging_status);
@@ -972,6 +1050,11 @@ void cywee_inactivity_mode_change(int mode)
 
 void cywee_activity_mode_change(int mode)
 {
+    if(mode != SPORT_ACTIVE_MODE_NORMAL)
+        cywee_sport_timer_start_check(SPORT_CHECK_MS);
+    else
+        cywee_sport_timer_stop_check();
+    
     switch (mode)
     {
         //一般模式(生活模式)
@@ -1089,11 +1172,11 @@ void CWM_AP_SensorListen(pSensorEVT_t sensorEVT) {
         gxyz_t.y = sensorEVT->fData[1];
         gxyz_t.z = sensorEVT->fData[2];
 
-        // CWM_OS_dbgPrintf("acc: x=%.3f, y=%.3f, z=%.3f\n",
-        //                                            sensorEVT->fData[0],
-        //                                            sensorEVT->fData[1],
-        //                                            sensorEVT->fData[2]
-        //                                             );
+        CWM_OS_dbgPrintf("acc: x=%.3f, y=%.3f, z=%.3f\n",
+                                                   sensorEVT->fData[0],
+                                                   sensorEVT->fData[1],
+                                                   sensorEVT->fData[2]
+                                                    );
 
             if(num_falg==GSENSON_MSG_COUNT)
             {
@@ -1208,6 +1291,21 @@ void CWM_AP_SensorListen(pSensorEVT_t sensorEVT) {
                     hrs_mode_state = 0;
                     uapi_save_runtime_log(RUNTIME_LOG_OXYGEN_SPORT_MEASURE_END);
                 }
+            }
+            if((int)sensorEVT->fData[1] == CUSTOM_GNSS)
+            {
+                CWM_OS_dbgPrintf("CUSTOM_GNSS !!! \r\n");
+#ifdef SUPPORT_GNSS
+                if((int)sensorEVT->fData[2] == 1)
+                {
+
+                    gnss_start();
+                }
+                else
+                {
+                    gnss_stop();
+                }
+#endif
             }
              break;
         case IDX_ALGO_SHAKE:
@@ -1864,6 +1962,8 @@ int cywee_main_dml(void)
     cywee_activity_mode_change(SPORT_ACTIVE_MODE_NORMAL);
 
     cywee_oncharging_update(get_charge_stat()); //初始化时检查充电状态
+
+    g_sport_timer = osTimerNew((osTimerFunc_t)cywee_service_check_timer_callback, osTimerPeriodic, NULL, NULL);
     //cywee_inactivity_mode_change(INACTIVITY_MODE_SEDENTARY_AND_NAP);
 
     //cywee_inactivity_mode_change(INACTIVITY_MODE_SLEEPING);
index 161f02e..6811030 100644 (file)
@@ -8,6 +8,7 @@ set(SOURCES ${SOURCES}
     ${CMAKE_CURRENT_SOURCE_DIR}/sh5001/sh5001.c
     ${CMAKE_CURRENT_SOURCE_DIR}/service/gyro_at_cmd.c
     ${CMAKE_CURRENT_SOURCE_DIR}/service/gyro_service.c
+    ${CMAKE_CURRENT_SOURCE_DIR}/service/gyro_hal.c
 )
 set(PUBLIC_HEADER
     ${CMAKE_CURRENT_SOURCE_DIR}/sh5001
index 300f46f..ef0237f 100644 (file)
@@ -2,14 +2,14 @@
  * @Author: penglei 1624952103@qq.com
  * @Date: 2024-12-16 20:49:09
  * @LastEditors: penglei 1624952103@qq.com
- * @LastEditTime: 2025-01-04 17:01:37
+ * @LastEditTime: 2025-05-12 17:47:30
  * @FilePath: /sdk615/code/sdk/drivers/peripheral/GYRO/service/lqbp_at_cmd.c
  * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
  */
 #include "at_cmd_api.h"
 #include "pm_control.h"
 #include "gyro_service.h"
-#include "sh5001.h"
+#include "gyro_hal.h"
 
 #define ARRAY_COUNT(array) (sizeof(array) / sizeof(array[0]))
 #define GYRO_MAX_ARGC            8
@@ -52,8 +52,7 @@ static uint32_t gyro_start_test(uint8_t *para, uint32_t paraLen, char *strCommon
     UNUSED(strCommonCmd);
     UNUSED(paraLen);
     UNUSED(para);
-    // do_lqbp_service_check_msg(GYRO_SERVICE_CMD_START_CHECK);
-    SH5001_init();
+    gyro_start();
     return ERRCODE_SUCC;
 }
 static uint32_t gyro_stop_test(uint8_t *para, uint32_t paraLen, char *strCommonCmd)
@@ -61,7 +60,7 @@ static uint32_t gyro_stop_test(uint8_t *para, uint32_t paraLen, char *strCommonC
     UNUSED(strCommonCmd);
     UNUSED(paraLen);
     UNUSED(para);
-    // do_lqbp_service_check_msg(GYRO_SERVICE_CMD_STOP_CHECK);
+    gyro_stop();
     return ERRCODE_SUCC;
 }
 static const at_cmd_table_t g_gyro_cmd[] = {
diff --git a/code/sdk/zhihui/drivers/gyro/service/gyro_hal.c b/code/sdk/zhihui/drivers/gyro/service/gyro_hal.c
new file mode 100644 (file)
index 0000000..9e0f083
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ * @Author: penglei 1624952103@qq.com
+ * @Date: 2025-05-12 09:59:09
+ * @LastEditors: penglei 1624952103@qq.com
+ * @LastEditTime: 2025-05-12 17:45:29
+ * @FilePath: /sdk615/code/sdk/zhihui/drivers/gyro/service/gyro_hal.c
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AEin
+ */
+#include <stdio.h>
+#include <stdbool.h>
+#include "gyro_hal.h"
+
+#ifdef GYRO_SH5001
+#include "sh5001.h"
+#endif
+
+void gyro_power_on(void)
+{
+#ifdef GYRO_SH5001
+    if(SH5001_init() == SH5001_TRUE)
+        printf("sh5001 init successful \n");
+    else
+        printf("sh5001 init failed \n");
+
+    if(SH5001_SwitchPowerMode(SH5001_NORMAL_MODE) == SH5001_TRUE)
+        printf("sh5001 start successful \n");
+    else
+        printf("sh5001 start failed \n");
+#endif
+}
+
+void gyro_power_off(void)
+{
+#ifdef GYRO_SH5001
+    if(SH5001_SwitchPowerMode(SH5001_POWERDOWN_MODE) == SH5001_TRUE)
+        printf("sh5001 stop successful \n");
+    else
+        printf("sh5001 stop failed \n");
+#endif   
+}
+
+void gyro_check(void)
+{
+#ifdef GYRO_SH5001
+    SH5001_ReadFIFO();
+#endif
+}
+
+bool gyro_check_exist(void)
+{
+#ifdef GYRO_SH5001
+    if(gyro_get_chip_id() != SH5001_ID)
+        return false;
+    else
+        return true;
+#endif 
+    return false;
+}
+
+gyro_data_t gyro_get_data(void)
+{
+    gyro_data_t data = {0};
+#ifdef GYRO_SH5001
+    data = sh5001_get_gyro_data();
+    // printf("%.3f %.3f %.3f\r\n",data.x,data.y,data.z);
+#endif 
+    return data;
+}
+
+uint8_t gyro_get_chip_id(void)
+{
+#ifdef GYRO_SH5001
+    return SH5001_get_chip_id();
+#endif 
+    return 0;
+}
\ No newline at end of file
diff --git a/code/sdk/zhihui/drivers/gyro/service/gyro_hal.h b/code/sdk/zhihui/drivers/gyro/service/gyro_hal.h
new file mode 100644 (file)
index 0000000..0caa961
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * @Author: penglei 1624952103@qq.com
+ * @Date: 2025-05-12 10:00:46
+ * @LastEditors: penglei 1624952103@qq.com
+ * @LastEditTime: 2025-05-12 17:52:36
+ * @FilePath: /sdk615/code/sdk/zhihui/drivers/gyro/service/gyro_hal.h
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
+ */
+#ifndef GYRO_HAL_H__
+#define GYRO_HAL_H__
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+#endif /* __cplusplus */
+
+#include "stdint.h"
+#include "errcode.h"
+
+typedef struct {
+    float x;
+    float y;
+    float z;
+} gyro_data_t;
+
+
+void gyro_power_on(void);
+void gyro_power_off(void);
+void gyro_check(void);
+gyro_data_t gyro_get_data(void);
+uint8_t gyro_get_chip_id(void);
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cplusplus */
+#endif /* __cplusplus */
+
+#endif
\ No newline at end of file
index ef6bae7..521391d 100644 (file)
@@ -9,71 +9,28 @@
 #include "input_app.h"
 #include "cmsis_os2.h"
 #include "custom_utils.h"
-#include "sh5001.h"
+#include "gyro_hal.h"
 #include "gyro_service.h"
+#ifdef ROTARYENCODER_MIXO
+#include "mixo_service.h"
+#endif
 // #include "custom_runtime.h"
 /***
  * 其他cmd在Header里定义,对外开放
 */
 #define GYRO_SERVICE_CMD_TIMER_CHECK 0x11
 
-#define GYRO_CHECK_MS 30
-
 static bool g_gyro_service_initialled = false;
 
-osTimerId_t g_gyro_service_timer = NULL;
 
 static bool g_gyro_sensor_exist = false;
 
-static bool g_bat_timer_is_running = false;
 
 static unsigned long g_app_queue= 0xFFFFFFFF;
 
-static bool gyro_service_running_stat = false;
-
-static void gyro_service_check_timer_callback(void* data);
 
-static void gyro_service_timer_start_check(uint32_t rtc_ms)
-{
-    
-    if (g_bat_timer_is_running )  
-        osTimerStop(g_gyro_service_timer);
-    
-    if (gyro_service_running_stat == true)
-        osTimerStart(g_gyro_service_timer, rtc_ms);
-    
-    g_bat_timer_is_running = true;
-    
-}
 void do_gyro_service_check_msg(int cmd);
 
-static void gyro_service_check_timer_callback(void * data)
-{
-    unused(data);
-
-    g_bat_timer_is_running = false;
-
-    if(gyro_service_running_stat == true){
-        // mmc5603_check(); //此处只能直接加到timer callback中,采用queue的话,新能跟不上,系统资源会挂掉。
-        do_gyro_service_check_msg(GYRO_SERVICE_CMD_TIMER_CHECK);
-        // gyro_service_timer_start_check(gyro_CHECK_MS);
-    }
-   
-     
-   
-}
-void uapi_gyro_service_deinit(void)
-{
-    /* Stop the time and clear the pin map */
-    osTimerStop(g_gyro_service_timer);
-    osTimerDelete(g_gyro_service_timer);
-
-    g_bat_timer_is_running = false;
-    g_gyro_service_timer = NULL;
-}
-
-
-
 void do_gyro_service_check_msg(int cmd)
 {
     int ret;
@@ -105,15 +62,9 @@ static void gyro_service_check_task(void const *arg)
         if (mail.comm.app == GYRO_SERVICE_CMD_TIMER_CHECK) {
             gyro_check();
         }else if (mail.comm.app == GYRO_SERVICE_CMD_START_CHECK){
-            gyro_start();
-            LOS_Mdelay(30);
-            gyro_service_running_stat = true;
-            gyro_service_timer_start_check(GYRO_CHECK_MS);
+            gyro_power_on();
         }else if (mail.comm.app == GYRO_SERVICE_CMD_STOP_CHECK){
-            gyro_service_running_stat = false;
-            osTimerStop(g_gyro_service_timer);
-            gyro_stop();
-            LOS_Mdelay(20);
+            gyro_power_off();
         }
 
 
@@ -135,7 +86,7 @@ errcode_t uapi_gyro_service_init(void)
 
     if(!gyro_check_exist())
     {
-        //TODO 设置气压计检测是否存在标识
+        //TODO 设置陀螺仪检测是否存在标识
         PRINT("gyro not found!\r\n");
         return ERRCODE_FAIL;
     }
@@ -156,18 +107,28 @@ errcode_t uapi_gyro_service_init(void)
         return ERRCODE_FAIL;
     }
 
-    g_gyro_service_timer = osTimerNew((osTimerFunc_t)gyro_service_check_timer_callback, osTimerPeriodic, NULL, NULL);
-  
-
     return ERRCODE_SUCC;
 }
 
-// void gyro_service_service_resume(void)
-// {
-//     MMC_LOG("gyro_service_service resume!\r\n");
-//     gyro_service_check_timer_callback(0);
-// }
-// void gyro_service_service_suspend(void)
-// {
-//     MMC_LOG("gyro_service_service suspend!\r\n");
-// }
\ No newline at end of file
+void gyro_int_callback(pin_t pin, uintptr_t param)
+{
+    // PRINT("gyro_int_callback %d 0x%X\n",pin,param);
+    uapi_gpio_clear_interrupt(pin);
+    do_gyro_service_check_msg(GYRO_SERVICE_CMD_TIMER_CHECK);
+}
+
+void gyro_start(void)
+{
+    do_gyro_service_check_msg(GYRO_SERVICE_CMD_START_CHECK);
+#ifdef ROTARYENCODER_MIXO
+    mixo_stop();
+#endif
+}
+
+void gyro_stop(void)
+{
+    do_gyro_service_check_msg(GYRO_SERVICE_CMD_STOP_CHECK);
+#ifdef ROTARYENCODER_MIXO
+    mixo_start();
+#endif
+}
index 27f9f1d..3dd1288 100644 (file)
@@ -1,3 +1,11 @@
+/*
+ * @Author: penglei 1624952103@qq.com
+ * @Date: 2024-12-23 15:12:01
+ * @LastEditors: penglei 1624952103@qq.com
+ * @LastEditTime: 2025-05-12 17:47:11
+ * @FilePath: /sdk615/code/sdk/zhihui/drivers/gyro/service/gyro_service.h
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
+ */
 /**
  * Copyright (c) @CompanyNameMagicTag 2022-2022. All rights reserved. \n
  *
@@ -18,7 +26,7 @@ extern "C" {
 
 #include "stdint.h"
 #include "errcode.h"
-
+#include "platform_core.h"
 
 #define GYRO_SERVICE_CMD_START_CHECK 0x12
 #define GYRO_SERVICE_CMD_STOP_CHECK 0x13
@@ -26,8 +34,9 @@ extern "C" {
 errcode_t uapi_gyro_service_init(void);
 void uapi_gyro_service_deinit(void);
 void do_gyro_service_check_msg(int cmd);
-
-
+void gyro_int_callback(pin_t pin, uintptr_t param);
+void gyro_start(void);
+void gyro_stop(void);
 #ifdef __cplusplus
 #if __cplusplus
 }
index 77ff6b8..27035be 100644 (file)
@@ -23,6 +23,8 @@
 \r
 #define SH5001_I2C_BUS I2C_BUS_2\r
 \r
+static gyro_data_t gyro_data = {0};\r
+\r
 /******************************************************************\r
 * Description: I2C or SPI bus interface functions      and delay time function\r
 *\r
@@ -1920,7 +1922,7 @@ void SH5001_ReadFIFO(void)
 \r
        SH5001_FIFO_Read_Data(fifoData, fifoEntriesCount);\r
 \r
-       printf("fc %d\r\n", fifoEntriesCount);\r
+       // printf("fc %d\r\n", fifoEntriesCount);\r
 \r
        for(i = 0; i < dataGroup; i++) \r
        {                               \r
@@ -1931,14 +1933,18 @@ void SH5001_ReadFIFO(void)
                gyroData[1] = ((short)fifoData[j+9] << 8) | fifoData[j+8];\r
                gyroData[2] = ((short)fifoData[j+11] << 8) | fifoData[j+10];    \r
 \r
-               printf("%d %d %d %d %d %d\r\n", accData[0], accData[1], accData[2],gyroData[0], gyroData[1], gyroData[2]);\r
+               gyro_data.x = (float)gyroData[0];\r
+               gyro_data.y = (float)gyroData[1];\r
+               gyro_data.z = (float)gyroData[2];\r
+\r
+               // printf("%d %d %d %d %d %d\r\n", accData[0], accData[1], accData[2],gyroData[0], gyroData[1], gyroData[2]);\r
        \r
                j = j + SH5001_WATERMARK_DIV;\r
        }       \r
     \r
         \r
     // clear INT    \r
-   // SH5001_INT_Read_Status01();\r
+   SH5001_INT_Read_Status01();\r
 \r
 \r
 }  \r
@@ -2077,6 +2083,26 @@ void SH5001_Get_Otpoffset(short vacc[3])
 * return:      SH5001_TRUE or SH5001_FALSE\r
 *\r
 ******************************************************************/\r
+\r
+uint8_t SH5001_get_chip_id(void)\r
+{\r
+       unsigned char regData = 0;\r
+       unsigned char i = 0;\r
+\r
+       // SH5001 chipID = 0xA1;        \r
+       while((regData != 0xA1U) && (i++ < 3U))\r
+       {\r
+               SH5001_read(SH5001_ADDRESS, SH5001_CHIP_ID, 1, &regData);       \r
+               if((i == 3) && (regData != 0xA1U))\r
+               {\r
+                       printf("SH5001 init fail, Chip ID = 0x%x\r\n", regData);\r
+                       return SH5001_FALSE;\r
+               }       \r
+       }\r
+       printf("SH5001 Chip ID = 0x%x\r\n", regData);\r
+       return regData;\r
+}\r
+\r
 unsigned char SH5001_init(void) \r
 {\r
        unsigned char regData = 0;\r
@@ -3051,4 +3077,10 @@ void SH5001_Get_Adc_Polarity(short gyroPolarity[3])
 int sh5001_get_version(void)\r
 {\r
        return MCU_VERSION_SH5001;\r
+}\r
+\r
+gyro_data_t sh5001_get_gyro_data(void)\r
+{\r
+    gyro_data_t data = gyro_data;\r
+       return data;\r
 }
\ No newline at end of file
index 58ee98b..08cd2cd 100644 (file)
@@ -1,7 +1,9 @@
 #ifndef __SH5001_H \r
 #define __SH5001_H\r
 \r
-//#define SH5001_FIFO_WM_INT\r
+#include "gyro_hal.h"\r
+\r
+#define SH5001_FIFO_WM_INT\r
 //#define SH5001_ACTIVITY_INT\r
 //#define SH5001_DATA_READY_INT\r
 \r
@@ -12,6 +14,7 @@
 ******************************************************************/\r
 #define SH5001_ADDRESS                         (0x36U)         \r
 #define SENODIA_VDD_3V3 1\r
+#define SH5001_ID                      0xA1\r
 \r
 /******************************************************************\r
 *      SH5001 Registers Macro Definitions \r
@@ -690,6 +693,8 @@ extern void SH5001_FastOffsetComp(unsigned char SH5001Positon);
 extern void SH5001_initFIFO(void);                                    \r
     \r
 extern void SH5001_ReadFIFO(void);      \r
-                                    \r
+\r
+unsigned char SH5001_get_chip_id(void);\r
+gyro_data_t sh5001_get_gyro_data(void);\r
 #endif\r
 \r
index 5a6f1ec..2a84d34 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: penglei 1624952103@qq.com
  * @Date: 2024-03-13 15:08:38
  * @LastEditors: penglei 1624952103@qq.com
- * @LastEditTime: 2025-02-18 14:35:27
+ * @LastEditTime: 2025-05-13 16:48:04
  * @FilePath: /FD230/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_hal.c
  * @Description: 
  * 
@@ -30,15 +30,7 @@ uint32_t tyhx_poweron(void)
     uapi_pin_set_mode(GPIO_PIN_PRG_LED_ON, (pin_mode_t)HAL_PIO_FUNC_GPIO);
     uapi_gpio_set_dir(GPIO_PIN_PRG_LED_ON, GPIO_DIRECTION_OUTPUT);
     uapi_gpio_set_val(GPIO_PIN_PRG_LED_ON, GPIO_LEVEL_HIGH);
-    LOS_Mdelay(10);
-    uapi_pin_set_mode(S_AGPIO_L24, (pin_mode_t)HAL_PIO_FUNC_GPIO);
-    uapi_gpio_set_dir(S_AGPIO_L24, GPIO_DIRECTION_OUTPUT);
-    uapi_gpio_set_val(S_AGPIO_L24, GPIO_LEVEL_LOW);
-    LOS_Mdelay(10);
-    uapi_pin_set_mode(S_MGPIO0, (pin_mode_t)HAL_PIO_FUNC_GPIO);
-    uapi_gpio_set_dir(S_MGPIO0, GPIO_DIRECTION_OUTPUT);
-    uapi_gpio_set_val(S_MGPIO0, GPIO_LEVEL_LOW);
-    LOS_Mdelay(10);
+    
     uapi_pin_set_mode(GPIO_PIN_PRG_RESET, (pin_mode_t)HAL_PIO_FUNC_GPIO);
     uapi_gpio_set_dir(GPIO_PIN_PRG_RESET, GPIO_DIRECTION_OUTPUT);
     uapi_gpio_set_val(GPIO_PIN_PRG_RESET, GPIO_LEVEL_HIGH);
index 224305c..a847f5a 100644 (file)
@@ -125,7 +125,7 @@ uint8_t alg_ram[11 * 1024] __attribute__((aligned(4)));
 //uint8_t alg_ram[10] = {0};\r
 ppg_sensor_data_t ppg_s_data;\r
 \r
-static int cywee_data = 0;\r
+static int cywee_hrs_data = 0;\r
 static int history_wear_status = -1;\r
 static int cywee_wear_status = 0;\r
 \r
@@ -2715,6 +2715,11 @@ static void get_avg_hrs(int32_t hrs)
     }\r
 }\r
 \r
+uint8_t hx3695_get_hrs(void)\r
+{\r
+    return cywee_hrs_data;\r
+}\r
+\r
 void hx3695_set_hrs_ble_swtich(uint8_t cmd)\r
 {\r
   hrs_ble_falg = cmd;\r
@@ -2732,8 +2737,7 @@ void hx3695_wearstatus_update(void)
     if(history_wear_status != cywee_wear_status)\r
     {\r
         history_wear_status = cywee_wear_status;\r
-        cywee_data = history_wear_status;\r
-        do_cywee_service_check_msg(CYWEE_SERVICE_CMD_WEAR_STATUS_CHANGE,&cywee_data);\r
+        do_cywee_service_check_msg(CYWEE_SERVICE_CMD_WEAR_STATUS_CHANGE,&cywee_wear_status);\r
     }\r
 }\r
   //脱腕上报未佩戴信息\r
@@ -2755,8 +2759,8 @@ void hx3695_unwearstatus_update(void)
   {\r
       cywee_wear_status = 0;\r
       hx3695_wearstatus_update();\r
-      cywee_data = 0;\r
-      do_cywee_service_check_msg(CYWEE_SERVICE_CMD_HRS_CHANGE,&cywee_data);\r
+      cywee_hrs_data = 0;\r
+      // do_cywee_service_check_msg(CYWEE_SERVICE_CMD_HRS_CHANGE,&cywee_data);\r
   }\r
 }                              \r
 \r
@@ -3027,8 +3031,8 @@ void hx3695_hrs_ppg_Int_handle(void)
           if(uapi_dev_runtime_get_train_status())\r
           {\r
               hx3695_wearstatus_update();\r
-              cywee_data = hrsresult.lastesthrs;\r
-              do_cywee_service_check_msg(CYWEE_SERVICE_CMD_HRS_CHANGE,&cywee_data);\r
+              cywee_hrs_data = hrsresult.lastesthrs;\r
+              // do_cywee_service_check_msg(CYWEE_SERVICE_CMD_HRS_CHANGE,&cywee_data);\r
           }\r
     }\r
 \r
index 228abb1..0e78bf5 100644 (file)
@@ -301,6 +301,7 @@ void hx3695_wearstatus_update(void);
 void hx3695_unwearstatus_update(void);\r
 void hx3695_set_hrs_ble_swtich(uint8_t cmd);\r
 uint8_t hx3695_get_hrs_ble_swtich(void);\r
+uint8_t hx3695_get_hrs(void);\r
 #include "hx3695_hal.h"\r
 \r
 #endif\r
index 2553256..8fbccd6 100644 (file)
@@ -48,6 +48,8 @@ set(SOURCES
     ${CMAKE_CURRENT_SOURCE_DIR}/mixo/mixo_ots_driver.c
     ${CMAKE_CURRENT_SOURCE_DIR}/mixo/mixo_ots_access.c
     ${CMAKE_CURRENT_SOURCE_DIR}/mixo/mixo_at_cmd.c
+    ${CMAKE_CURRENT_SOURCE_DIR}/mixo/mixo_hal.c
+    ${CMAKE_CURRENT_SOURCE_DIR}/mixo/mixo_service.c
 )
 set(PUBLIC_HEADER
     ${CMAKE_CURRENT_SOURCE_DIR}/mixo
index 740d4f3..9b357fc 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: penglei 1624952103@qq.com
  * @Date: 2024-12-23 15:11:25
  * @LastEditors: penglei 1624952103@qq.com
- * @LastEditTime: 2025-01-02 19:43:35
+ * @LastEditTime: 2025-05-13 17:09:24
  * @FilePath: /sdk615/code/sdk/zhihui/drivers/rotary_encoder/hx3508/hx3508_hal.h
  * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE;
  */
@@ -14,8 +14,8 @@
  * History: \n
  * 2022-07-20, Create file. \n
  */
-#ifndef HX3507_HAL_H
-#define HX3507_HAL_H
+#ifndef HX3508_HAL_H
+#define HX3508_HAL_H
 
 #include <stdint.h>
 #include <stdio.h>
index b81485d..95cf9be 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: penglei 1624952103@qq.com
  * @Date: 2024-12-18 10:23:22
  * @LastEditors: penglei 1624952103@qq.com
- * @LastEditTime: 2025-01-04 11:21:49
+ * @LastEditTime: 2025-05-14 16:30:48
  * @FilePath: /sdk615/code/sdk/drivers/peripheral/rotary_encoder/mixo/mixo_at_cmd.c
  * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
  */
@@ -15,6 +15,7 @@
 #include "debug_print.h"
 #include "mixo_ots_driver.h"
 #include "custom_utils.h"
+#include "mixo_service.h"
 
 
 #define ARRAY_COUNT(array) (sizeof(array) / sizeof(array[0]))
@@ -78,7 +79,7 @@ static uint32_t mixo_test(uint8_t *para, uint32_t paraLen, char *strCommonCmd)
         //     PRINT("SKIP mixotest start, already started\r\n");
         //     return 0;
         // }
-        mixo_ots_init();
+        mixo_start();
         // mixo_start();
         g_mixo_test_started = 1;
     }else if (start == 2){
@@ -87,7 +88,7 @@ static uint32_t mixo_test(uint8_t *para, uint32_t paraLen, char *strCommonCmd)
             PRINT("SKIP mixotest stop, already stopped\r\n");
             return 0;
         }
-        // mixo_stop();
+        mixo_stop();
         g_mixo_test_started = 0 ;
     }
     return ERRCODE_SUCC;
diff --git a/code/sdk/zhihui/drivers/rotary_encoder/mixo/mixo_hal.c b/code/sdk/zhihui/drivers/rotary_encoder/mixo/mixo_hal.c
new file mode 100644 (file)
index 0000000..551e98e
--- /dev/null
@@ -0,0 +1,151 @@
+#include "at_cmd_api.h"
+#include "pm_control.h"
+#include "rotary_encoder_def.h"
+#include "debug_print.h"
+#include "mixo_ots_driver.h"
+#include "custom_utils.h"
+#include "pinctrl_porting.h"
+#include "mixo_service.h"
+
+#define MIXO_INT_PIN S_AGPIO_L0
+#define INT_MODE 1
+#define TIMER_MODE 0
+
+static uint8_t g_mixo_test_started = 0;
+encoder_callback g_encoder_callback = NULL;
+
+void mixo_int_callback(pin_t pin, uintptr_t param)
+{
+    PRINT("mixo_int_callback %d 0x%X\n",pin,param);
+    uapi_gpio_clear_interrupt(pin);
+    // uapi_pin_set_ie(MIXO_INT_PIN,HAL_PIO_IE_DISABLE);
+    mixo_start();           // 启动定时器
+}
+
+void mixo_check(void)
+{
+    if(mixo_get_check_mode() == TIMER_MODE)
+        mixo_ots_timer_callback();
+    // else if(mixo_get_check_mode() == INT_MODE)
+    // {
+    //     mixo_stop();           // 关闭定时器
+    //     // uapi_pin_set_ie(MIXO_INT_PIN,HAL_PIO_IE_ENBALE);
+    // }
+}
+
+
+void mixo_suspend(void)
+{
+    mixo_ots_enter_suspend_mode(1);
+}
+
+void mixo_resume(void)
+{
+    mixo_ots_enter_suspend_mode(0);
+}
+
+
+uint32_t mixo_init(void)
+{
+    if(mixo_ots_init() != ERRCODE_SUCC)
+        return ERRCODE_FAIL;
+
+    return ERRCODE_SUCC;
+}
+
+static ext_errno mixo_encoder_init(void *attr)
+{
+    re_print("mixo_encoder_init\r\n");
+    return EXT_ERR_SUCCESS;
+}
+static ext_errno mixo_encoder_deinit(void)
+{
+    re_print("mixo_encoder_deinit\r\n");
+    return EXT_ERR_SUCCESS;
+}
+static ext_errno mixo_encoder_get_encoderinfo(uint8_t *data, uint8_t data_len)
+{;
+    if (data_len != sizeof(re_input_event_info))
+        return EXT_ERR_NOT_SUPPORT;
+    re_input_event_info *encoder_info = (re_input_event_info*)data;
+    int16_t diff = mixo_get_crown_result();
+    int16_t stand_still = mixo_get_stand_still();
+    // re_print("mixo_encoder_get_encoderinfo diff %d stand_still %d\n",diff,stand_still);
+    if (stand_still == 1 )
+    {
+        encoder_info->re_event = MC_RE_COVER;
+    }else {
+        encoder_info->re_event = MC_RE_MOVE;
+    }
+    encoder_info->re_event_info.x_axis[0] = diff;
+    encoder_info->re_event_info.y_axis[0] = diff;
+    encoder_info->re_event_info.z_axis[0] = diff;
+    encoder_info->finger_id = 0 ;
+    encoder_info->point_num = 0 ;
+    encoder_info->tv_usec = (uint32_t)uapi_tcxo_get_ms();
+    //re_print("mixo_encoder_get_encoderinfo  %s rotate %d\r\n",encoder_info->re_event == MC_RE_SLIDE_UP?"MC_RE_SLIDE_UP":"MC_RE_SLIDE_DOWN",diff);
+
+    return EXT_ERR_SUCCESS;
+}
+static ext_errno mixo_encoder_suspend(void)
+{
+    re_print("mixo_encoder_suspend\r\n");
+    return EXT_ERR_SUCCESS;
+}
+static ext_errno mixo_encoder_resume(void)
+{
+    re_print("mixo_encoder_resume\r\n");
+    mixo_start();
+    return EXT_ERR_SUCCESS;
+}
+static ext_errno mixo_encoder_sleep(void)
+{
+    re_print("mixo_encoder_sleep\r\n");
+    mixo_stop();
+    return EXT_ERR_SUCCESS;
+}
+static ext_errno mixo_encoder_reset(void)
+{
+    re_print("mixo_encoder_reset\r\n");
+    return EXT_ERR_SUCCESS;
+}
+static ext_errno mixo_encoder_bus_init(void *private_data)
+{
+    return EXT_ERR_SUCCESS;
+}
+static ext_errno mixo_register_callback(void *peri_data, encoder_callback func)
+{
+    re_print("mixo_register_callback\r\n");
+    g_encoder_callback = func;
+    return EXT_ERR_SUCCESS;
+}
+static ext_errno mixo_unregister_callback(void *peri_data)
+{
+    re_print("mixo_unregister_callback\r\n");
+    g_encoder_callback = NULL;
+    return EXT_ERR_SUCCESS;
+}
+
+encoder_peripheral_api g_mixo_api = {
+    .encoder_init = mixo_encoder_init,
+    .encoder_deinit = mixo_encoder_deinit,
+    .encoder_get_encoderinfo = mixo_encoder_get_encoderinfo,
+    .encoder_suspend = mixo_encoder_suspend,
+    .encoder_resume = mixo_encoder_resume,
+    .encoder_sleep = mixo_encoder_sleep,
+    .encoder_reset = mixo_encoder_reset,
+    .encoder_bus_init = mixo_encoder_bus_init,
+    .register_callback = mixo_register_callback,
+    .unregister_callback = mixo_unregister_callback,
+};
+
+
+void *rotary_encoder_get_mixo_api(void)
+{
+    return ((void *)&g_mixo_api);
+}
+
+void *rotary_encoder_get_mixo_peri_attr(void)
+{
+    return ((void *)NULL);
+}
\ No newline at end of file
diff --git a/code/sdk/zhihui/drivers/rotary_encoder/mixo/mixo_hal.h b/code/sdk/zhihui/drivers/rotary_encoder/mixo/mixo_hal.h
new file mode 100644 (file)
index 0000000..7b677ad
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * @Author: penglei 1624952103@qq.com
+ * @Date: 2024-12-23 15:11:25
+ * @LastEditors: penglei 1624952103@qq.com
+ * @LastEditTime: 2025-05-14 16:37:32
+ * @FilePath: /sdk615/code/sdk/zhihui/drivers/rotary_encoder/hx3508/hx3508_hal.h
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE;
+ */
+/**
+ * Copyright (c) @CompanyNameMagicTag 2022-2022. All rights reserved. \n
+ *
+ * Description: Provides at cmd register func \n
+ * Author: @CompanyNameTag \n
+ * History: \n
+ * 2022-07-20, Create file. \n
+ */
+#ifndef MIXO_HAL_H
+#define MIXO_HAL_H
+
+#include <stdint.h>
+#include <stdio.h>
+#include "errcode.h"
+#include "soc_osal.h"
+#include "rotary_encoder_def.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+#endif /* __cplusplus */
+
+void *rotary_encoder_get_mixo_api(void);
+void *rotary_encoder_get_mixo_peri_attr(void);
+
+uint32_t mixo_init(void);
+
+void mixo_check(void);
+
+void mixo_suspend(void);
+void mixo_resume(void);
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cplusplus */
+#endif /* __cplusplus */
+
+#endif
index 21e6ed8..d502132 100644 (file)
@@ -1,10 +1,10 @@
 #include "mixo_ots_driver.h"
-
 #include <stdlib.h>
 #include <string.h>
-
 #include "mixo_ots_access.h"
 #include "cmsis_os2.h"
+#include "debug_print.h"
+#include "mixo_hal.h"
 
 #ifndef ABS
 #define ABS(x) ((x) > 0 ? (x) : -(x))
 
 static int dx_sum = 0;
 
-static bool ots_timer_running = false; //ots定时器是否运行标志
+static uint16_t timer_cnt = 0;
+
+static int16_t ots_result = 0;//ots结果
+static int16_t stand_still = 1; //静止标志 1 静止,0 转动
+
+static uint8_t int_mode = 0;
+
+extern encoder_callback g_encoder_callback;
+
+
+static void put_crown_result(int16_t x)
+{
+    if(abs(x)<=1 )
+    {   
+        return;
+    }
+    if(abs(x)>=4 )
+    {
+        ots_result += x/4; //大于4的值除以4, 代表角度, 单位0.5°
+    }
+    else
+    {
+        if(x>0)
+        {
+            ots_result+=1; //2~4 默认一个单位, 0.5°
+        }
+        else
+        {
+            ots_result-=1; //2~4 默认一个单位, 0.5°
+        }
+    }
 
-static osTimerId_t g_ots_timer = NULL;
+   if (g_encoder_callback != NULL)
+        g_encoder_callback();
+}
 
 
-static void ots_timer_callback(void)
+void mixo_ots_timer_callback(void)
 {
     uint8_t mot_status = 0x00;
     mixo_ots_get_mot_status(&mot_status);
+
     if ((mot_status & 0x80) == 0x80)
     {
+        timer_cnt = 0;
+        int_mode = 0;
         // Get raw datas
         raw_data_t raw_data;
         mixo_ots_get_raw_data(&raw_data);
@@ -34,35 +69,33 @@ static void ots_timer_callback(void)
 
         // Output raw data
         // printf("%ld,%d,%d,%d,%d\r\n", timestamp, raw_data.dx, raw_data.dy, mot_status, dx_sum);
-    }
-}
+        // PRINT("%d,%d,%d,%d\r\n",raw_data.dx, raw_data.dy, mot_status, dx_sum);
 
-void mixo_ots_start(void)
-{
-    if(ots_timer_running == false && g_ots_timer)
-    {
-        osTimerStart(g_ots_timer,10);
-        ots_timer_running = true;
-    }
-}
+        put_crown_result(raw_data.dx);
+        stand_still = 0;
 
-void mixo_ots_stop(void)
-{
-    if(ots_timer_running == true && g_ots_timer)
+        if (g_encoder_callback != NULL)
+            g_encoder_callback();
+
+    }
+    else
     {
-        osTimerStop(g_ots_timer);
-        ots_timer_running = false;
+        // timer_cnt++;
+        // if (timer_cnt == 20)  // 20*10 = // 200ms:200ms内sensor没有检测到表冠转动就会关闭定时器重新开启中断响应
+        // {
+        //     printf("mixo enter int mode\n");
+        //     /**
+        //      * 此处注意 mixo_ots_forced_clear_int
+        //      * 必须放在 external_int_init 之前去做
+        //      * 否则可能造成功耗异常的问题
+        //      */
+        //     mixo_ots_forced_clear_int();  // 强制拉高MOT脚
+        //     int_mode = 1;
+        // }
+        stand_still = 1;
     }
 }
 
-void mixo_ots_timer_init(void)
-{
-    g_ots_timer = osTimerNew((osTimerFunc_t)ots_timer_callback, osTimerPeriodic, NULL, NULL);
-    
-    if(!g_ots_timer)
-        PRINT("g_ots_timer init failed \n");
-}
-
 
 /**
  * @brief 接收1byte数据
@@ -142,7 +175,7 @@ int mixo_ots_get_raw_data(raw_data_t* raw_data)
     // If overflowed, clear out the data
     if ((ABS(raw_data->dx) == 2047) || (ABS(raw_data->dy) == 2047))
     {
-        printf("dy/dx overflowed.");
+        // printf("dy/dx overflowed.");
         mixo_ots_reg_read(0x02, &tmp);
 
         mixo_ots_reg_read(0x02, &tmp);
@@ -246,10 +279,13 @@ int callisto_2x_init(void)
     return ret;
 }
 
-
+static uint8_t mixo_installized = 0;
 
 int mixo_ots_init(void)
 {
+    if(mixo_installized)
+        return 0;
+
     int rc             = 0;
     uint8_t HardWareId = 0;
 
@@ -269,11 +305,13 @@ int mixo_ots_init(void)
             break;
         default:
             printf("OTS Sensor Not Support!\n");
+            rc = -1;
             break;
     }
 
     if(rc == 0)
     {
+        mixo_installized = 1;
         printf("mixo_ots_init succed !!! \n");
     }
     else
@@ -283,3 +321,26 @@ int mixo_ots_init(void)
     return rc;
 }
 
+int16_t mixo_get_stand_still(void)
+{
+    return stand_still;
+}
+
+void mixo_clean_result(void)
+{
+    ots_result = 0;
+}
+
+
+int16_t mixo_get_crown_result(void)
+{
+    int16_t resulttemp;
+    resulttemp=ots_result;
+    ots_result = 0;
+    return resulttemp;
+}
+
+uint8_t mixo_get_check_mode(void)
+{
+    return int_mode;
+}
index 5093bb2..a991947 100644 (file)
@@ -1,3 +1,11 @@
+/*
+ * @Author: penglei 1624952103@qq.com
+ * @Date: 2025-01-04 10:53:54
+ * @LastEditors: penglei 1624952103@qq.com
+ * @LastEditTime: 2025-05-14 17:13:14
+ * @FilePath: /sdk615/code/sdk/zhihui/drivers/rotary_encoder/mixo/mixo_ots_driver.h
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
+ */
 /*
  * Copyright (c) 2019 MixoSense Technology Ltd <contact@mixosense.com>.
  *
@@ -26,4 +34,13 @@ int mixo_ots_get_raw_data(raw_data_t* raw_data);
 void mixo_ots_forced_clear_int(void);
 void mixo_ots_enter_suspend_mode(uint8_t true_or_false);
 
+void mixo_ots_start(void);
+void mixo_ots_stop(void);
+
+int16_t mixo_get_stand_still(void);
+int16_t mixo_get_crown_result(void);
+void mixo_ots_timer_callback(void);
+void mixo_clean_result(void);
+uint8_t mixo_get_check_mode(void);
+
 #endif  //_MXS_DRIVER_H_
diff --git a/code/sdk/zhihui/drivers/rotary_encoder/mixo/mixo_service.c b/code/sdk/zhihui/drivers/rotary_encoder/mixo/mixo_service.c
new file mode 100644 (file)
index 0000000..c918c73
--- /dev/null
@@ -0,0 +1,157 @@
+
+#include "debug_print.h"
+#include "soc_osal.h"
+#include "tcxo.h"
+#include "irmalloc.h"
+#include "errcode.h"
+#include "common_def.h"
+#include "tcxo.h"
+#include "input_app.h"
+#include "cmsis_os2.h"
+#include "custom_utils.h"
+#include "mixo_hal.h"
+#include "mixo_service.h"
+#include "pinctrl_porting.h"
+
+// #include "custom_runtime.h"
+/***
+ * 其他cmd在Header里定义,对外开放
+*/
+#define MIXO_SERVICE_CMD_TIMER_CHECK 0x11
+
+#define MIXO_SERVICE_TIMER_CHECK_MS  40
+
+static bool g_mixo_service_initialled = false;
+
+static bool g_mixo_sensor_exist = false;
+
+static unsigned long g_app_queue= 0xFFFFFFFF;
+
+static bool mixo_service_timer_running = false; //ots定时器是否运行标志
+
+static osTimerId_t g_mixo_service_timer = NULL;
+
+void do_mixo_service_check_msg(int cmd);
+
+static void mixo_service_timer_callback(void)
+{
+    do_mixo_service_check_msg(MIXO_SERVICE_CMD_TIMER_CHECK);
+}
+
+void mixo_service_timer_start(void)
+{
+    if(mixo_service_timer_running == false && g_mixo_service_timer)
+    {
+        mixo_resume();
+        osTimerStart(g_mixo_service_timer,MIXO_SERVICE_TIMER_CHECK_MS);
+        mixo_service_timer_running = true;
+    }
+}
+
+void mixo_service_timer_stop(void)
+{
+    if(mixo_service_timer_running == true && g_mixo_service_timer)
+    {
+        mixo_suspend();
+        mixo_clean_result();
+        osTimerStop(g_mixo_service_timer);
+        mixo_service_timer_running = false;
+    }
+}
+
+void mixo_start(void)
+{
+    do_mixo_service_check_msg(MIXO_SERVICE_CMD_START_CHECK);
+}
+
+void mixo_stop(void)
+{
+    do_mixo_service_check_msg(MIXO_SERVICE_CMD_STOP_CHECK);
+}
+
+
+void do_mixo_service_check_msg(int cmd)
+{
+    int ret;
+    if (g_mixo_sensor_exist == false)
+        return ;
+    common_notify_mail_t mail = {0};
+    mail.comm.app = cmd;
+    ret = osal_msg_queue_write_copy(g_app_queue, (void *)&mail,
+                                    sizeof(common_notify_mail_t), 0);
+    if (ret != OSAL_SUCCESS) {
+        PRINT("Error mixo Check MSG 0x%02X send failed! err=0x%x! \r\n",cmd, ret);
+    }
+    
+}
+
+static void mixo_service_check_task(void const *arg)
+{
+    unused(arg);
+    int32_t ret;
+    common_notify_mail_t mail;
+    uint32_t msgsize = (uint32_t)sizeof(common_notify_mail_t);
+    while (1) {
+        ret = osal_msg_queue_read_copy(g_app_queue, (void *)&mail, &msgsize,
+                                       OSAL_MSGQ_WAIT_FOREVER);
+        if (ret != OSAL_SUCCESS) {
+            continue;
+        }
+
+        if (mail.comm.app == MIXO_SERVICE_CMD_TIMER_CHECK) {
+            mixo_check();
+        }else if (mail.comm.app == MIXO_SERVICE_CMD_START_CHECK){
+            mixo_service_timer_start();
+        }else if (mail.comm.app == MIXO_SERVICE_CMD_STOP_CHECK){
+            mixo_service_timer_stop();
+        }
+
+
+    }
+}
+void create_mixo_queue(void)
+{
+
+    if (osal_msg_queue_create("mixo_service_queue", APP_BOARD_MSG_COUNT, &g_app_queue,
+                              0, sizeof(common_notify_mail_t)) != ERRCODE_SUCC) {
+        PRINT("[mixo][service] app create mail fail\n");
+    }
+}
+
+#define MIXO_BOARD_TASK_SIZE   0x1000
+errcode_t uapi_mixo_service_init(void)
+{
+    PRINT("uapi_mixo_service_init !\r\n");
+
+    if(mixo_init() != ERRCODE_SUCC)
+    {
+        //TODO 设置光电编码器检测是否存在标识
+        PRINT("mixo not found!\r\n");
+        return ERRCODE_FAIL;
+    }
+    g_mixo_sensor_exist = true;
+
+    app_task_definition_t taskcfg={0};
+    taskcfg.create_queue_handle = create_mixo_queue;
+    taskcfg.attr.name="mixo_service";
+    taskcfg.attr.priority = osPriorityBelowNormal5;
+    taskcfg.attr.stack_size = MIXO_BOARD_TASK_SIZE;
+    taskcfg.func = mixo_service_check_task;
+    taskcfg.use_mem = USE_EXTEND_MEM;
+    
+    errcode_t ret=uapi_create_osThread_custom(&taskcfg);
+    if(ret != ERRCODE_SUCC)
+    {
+        PRINT("create mixo_service failed %d!\r\n",ret);
+        return ERRCODE_FAIL;
+    }
+
+    mixo_init();
+    
+    g_mixo_service_timer = osTimerNew((osTimerFunc_t)mixo_service_timer_callback, osTimerPeriodic, NULL, NULL);
+
+    mixo_start();
+
+    return ERRCODE_SUCC;
+}
+
diff --git a/code/sdk/zhihui/drivers/rotary_encoder/mixo/mixo_service.h b/code/sdk/zhihui/drivers/rotary_encoder/mixo/mixo_service.h
new file mode 100644 (file)
index 0000000..60ded83
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * @Author: penglei 1624952103@qq.com
+ * @Date: 2024-12-23 15:12:01
+ * @LastEditors: penglei 1624952103@qq.com
+ * @LastEditTime: 2025-05-14 16:29:38
+ * @FilePath: /sdk615/code/sdk/zhihui/drivers/mixo/service/mixo_service.h
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
+ */
+/**
+ * Copyright (c) @CompanyNameMagicTag 2022-2022. All rights reserved. \n
+ *
+ * Description: Test adc header \n
+ * Author: @CompanyNameTag \n
+ * History: \n
+ * 2022-08-16, Create file. \n
+ */
+
+#ifndef MIXO_SERVICE_H__
+#define MIXO_SERVICE_H__
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+#endif /* __cplusplus */
+
+#include "stdint.h"
+#include "errcode.h"
+#include "platform_core.h"
+
+#define MIXO_SERVICE_CMD_START_CHECK 0x12
+#define MIXO_SERVICE_CMD_STOP_CHECK 0x13
+
+errcode_t uapi_mixo_service_init(void);
+void uapi_mixo_service_deinit(void);
+void do_mixo_service_check_msg(int cmd);
+void mixo_start(void);
+void mixo_stop(void);
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cplusplus */
+#endif /* __cplusplus */
+
+#endif
\ No newline at end of file
index 6d1e531..e20f867 100644 (file)
 #ifdef ROTARYENCODER_U8
 #include "crown_hal.h"
 #endif
+
+#ifdef ROTARYENCODER_MIXO
+#include "mixo_hal.h"
+#endif
+
 // #if defined(TPTYPE_TMA525B)
 // #include "tma525b_drv1.h"
 // #include "tma525b_ctrl.h"
@@ -431,6 +436,9 @@ uint32_t re_init(void)
 #elif defined ROTARYENCODER_U8
     g_encoder_drv.private_data = rotary_encoder_get_crown_peri_attr();
     g_encoder_drv.encoder_api = rotary_encoder_get_crown_api();
+#elif defined ROTARYENCODER_MIXO
+    g_encoder_drv.private_data = rotary_encoder_get_mixo_peri_attr();
+    g_encoder_drv.encoder_api = rotary_encoder_get_mixo_api();
 #endif
     g_encoder_drv.ops = &g_re_status_ops;
     redd = rotary_encoder_get_driver_data();
@@ -475,6 +483,8 @@ void rotary_encoder_suspend(void)
     encoder_ptr = rotary_encoder_get_hx3508_api();
 #elif defined ROTARYENCODER_U8
     encoder_ptr = rotary_encoder_get_crown_api();
+#elif defined ROTARYENCODER_MIXO
+    encoder_ptr = rotary_encoder_get_mixo_api();
 #endif
     if(encoder_ptr == NULL)
         return;
@@ -492,6 +502,8 @@ void rotary_encoder_resume(void)
     encoder_ptr = (encoder_peripheral_api*)rotary_encoder_get_hx3508_api();
 #elif defined ROTARYENCODER_U8
     encoder_ptr = (encoder_peripheral_api*)rotary_encoder_get_crown_api();
+#elif defined ROTARYENCODER_MIXO
+    encoder_ptr = (encoder_peripheral_api*)rotary_encoder_get_mixo_api();
 #endif
     if(encoder_ptr == NULL)
         return;
index 0ee9844..8209abd 100644 (file)
@@ -231,29 +231,6 @@ float battery_ntc_map[][2]={
 
 
 float battery_percent_map[][2]={
-#ifdef BOARD_U8
-    {3.8, 100},
-    {3.782, 95},
-    {3.764, 90},
-    {3.746, 85},
-    {3.728, 80},
-    {3.71, 75},
-    {3.692, 70},
-    {3.674, 65},
-    {3.656, 60},
-    {3.638, 55},
-    {3.62, 50},
-    {3.602, 45},
-    {3.584, 40},
-    {3.566, 35},
-    {3.548, 30},
-    {3.53, 25},
-    {3.512, 20},
-    {3.494, 15},
-    {3.476, 10},
-    {3.405, 5},
-    {3.3, 0}
-#else
     {4.3,100},
     {4.264,95},
     {4.228,90},
@@ -275,7 +252,6 @@ float battery_percent_map[][2]={
     {3.652,10},
     {3.41,5},
     {3.3,0}
-#endif
 };
 
 #ifdef BOARD_U8
@@ -818,10 +794,12 @@ void enable_02c(void)
 
 uint8_t get_02c_value(void)
 {
+#if defined(BOARD_FD230) || defined(BOARD_W9)
     if (GPIO_LEVEL_LOW ==  uapi_gpio_get_output_val(GPIO_PIN_ENABLE_CHARGE_0_2C))
         return 0;
     else 
         return 1;
+#endif
 }
 void disable_02c(void)
 {
index b7567ff..eda3da9 100644 (file)
@@ -45,6 +45,10 @@ extern "C" {
 
 #include "cywee_service.h"
 
+#ifdef ENABLE_HP4570
+#include "hp4570.h"
+#endif
+
 #define BAT_FILE_COUNT 180
 
 #define BAT_FILE_PATH "user/log/bat_data.bin"
@@ -274,10 +278,13 @@ void send_battery_svr_cmd_msg(uint8_t cmd)
 */
 uint8_t get_charge_stat(void)
 {
-    if(uapi_get_charger_plug_status())
-        return 1;
-    else
-        return 0;
+    uint8_t stat = 0;
+#ifdef ENABLE_HP4570
+    stat = !hp45xxx_read_chrg_stat_not_chrg();
+#else
+    stat = uapi_get_charger_plug_status();
+#endif
+    return stat;
 }
 
 static uint8_t bat_temp_cnt = 0;
@@ -685,6 +692,16 @@ void uapi_battery_create_queue(void)
 #define BATTERY_TASK_SIZE 0x1C00
 errcode_t uapi_battery_init(void)
 {
+
+#ifdef ENABLE_HP4570
+#ifdef BOARD_L22
+    custom_i2c_init(I2C_BUS_0);
+#elif defined BOARD_U8
+    custom_i2c_init(I2C_BUS_3);
+#endif
+    hp45xxx_init(HP4570C9);
+#endif
+
     battery_check_voltage();
     battery_percent_init(0); //先读历史电量
 
index 14a98d4..6f714c6 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: penglei 1624952103@qq.com\r
  * @Date: 2024-06-17 14:31:08\r
  * @LastEditors: penglei 1624952103@qq.com\r
- * @LastEditTime: 2025-02-20 18:34:13\r
+ * @LastEditTime: 2025-05-12 18:56:38\r
  * @FilePath: /FD230/code/sdk/application/wearable/service/factorytest_service/factorytest_protocol.c\r
  * @Description: \r
  * \r
@@ -58,7 +58,7 @@
 #include "lqbp_service.h"\r
 #include "lqbp002ta.h"\r
 #endif\r
-#ifdef ENABLE_HP4507\r
+#ifdef ENABLE_HP4570\r
 #include "hp4570.h"\r
 #endif\r
 #ifdef PPG_VC9202\r
@@ -74,6 +74,11 @@ static gps_data_t send_gps_data = {0};
 #include "bp_ble_service.h"\r
 #endif\r
 \r
+#ifdef ENABLE_GYRO\r
+#include "gyro_service.h"\r
+#include "gyro_hal.h"\r
+#endif\r
+\r
 #pragma pack(1)\r
 typedef struct factorytest_cmd_header_t\r
 {\r
@@ -403,7 +408,7 @@ void aging_task(void)
             }\r
             uapi_get_timestampe_ss(&current_time);\r
             send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_DO_SINGLE_CHECK_MODE_TEST);\r
-            LOS_Msleep(200);\r
+            LOS_Msleep(1000);\r
             #ifdef PPG_HX3695\r
             FT_RESULTS_t ft_result = hx3695_factroy_test(SINGLE_CHECK_TEST);\r
             #endif\r
@@ -1480,7 +1485,7 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint
 #elif defined PPG_VC9202\r
                 send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_DO_PPG_TEST);\r
 #endif\r
-                LOS_Msleep(500);\r
+                LOS_Msleep(1000);\r
                 uint8_t databuf[4] = {0};\r
 #ifdef PPG_HX3695\r
                 FT_RESULTS_t ft_result = hx3695_factroy_test(SINGLE_CHECK_TEST);\r
@@ -1490,6 +1495,12 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint
                 databuf[3] = (uint8_t)((ft_result.gr_data_final & 0x000000FF) >> 0);\r
 #elif defined PPG_VC9202\r
                 uint32_t ppg_data = vc9202_get_hr_ppg_data();\r
+                if(!ppg_data)\r
+                {\r
+                    LOS_Msleep(1000);\r
+                    ppg_data = vc9202_get_hr_ppg_data();\r
+                }\r
+\r
                 PRINT("ppg_data : %d \n",ppg_data);\r
                 databuf[0] = (uint8_t)((ppg_data & 0xFF000000) >> 24);\r
                 databuf[1] = (uint8_t)((ppg_data & 0x00FF0000) >> 16);\r
@@ -1515,7 +1526,7 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint
 #elif defined PPG_VC9202\r
                 send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_DO_SPO2_TEST);\r
 #endif\r
-                LOS_Msleep(500);\r
+                LOS_Msleep(1000);\r
                 uint8_t databuf[8] = {0};\r
 #ifdef PPG_HX3695\r
                 FT_RESULTS_t ft_result = hx3695_factroy_test(SINGLE_CHECK_TEST);\r
@@ -1525,9 +1536,16 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint
                 databuf[3] = (uint8_t)((ft_result.red_data_final & 0x000000FF) >> 0);\r
 #elif defined PPG_VC9202\r
                 uint32_t red_data = 0;\r
-                uint32_t ir_data = 9;\r
+                uint32_t ir_data = 0;\r
                 vc9202_get_spo2_ppg_data(&ir_data,&red_data);\r
                 PRINT("ir_data : %d ,red_data : %d \n",ir_data,red_data);\r
+\r
+                if(!ir_data && !red_data)\r
+                {\r
+                    LOS_Msleep(1000);\r
+                    vc9202_get_spo2_ppg_data(&ir_data,&red_data);\r
+                }\r
+                \r
                 databuf[0] = (uint8_t)((ir_data & 0xFF000000) >> 24);\r
                 databuf[1] = (uint8_t)((ir_data & 0x00FF0000) >> 16);\r
                 databuf[2] = (uint8_t)((ir_data & 0x0000FF00) >> 8);\r
@@ -1552,7 +1570,7 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint
             {\r
                 //灰卡测试\r
                 send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_DO_GRAYCARD_TEST);\r
-                LOS_Msleep(500);\r
+                LOS_Msleep(1000);\r
 #ifdef PPG_HX3695\r
                 uint8_t databuf[12] = {0};\r
                 FT_RESULTS_t ft_result = hx3695_factroy_test(GRAY_CARD_TEST);\r
@@ -1610,7 +1628,7 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint
             {\r
                 //漏光测试\r
                 send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_DO_LEAKLIGHT_TEST);\r
-                LOS_Msleep(500);\r
+                LOS_Msleep(1000);\r
                 uint8_t databuf[12] = {0};\r
 #ifdef PPG_HX3695\r
                 FT_RESULTS_t ft_result = hx3695_factroy_test(LEAK_LIGHT_TEST);\r
@@ -1635,6 +1653,13 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint
                 uint32_t aps_val = 9;\r
                 vc9202_get_leaklight_data(&led_cur,&apre_val,&aps_val);\r
                 PRINT("led_cur : %d ,apre_val : %d ,aps_val : %d \n",led_cur,apre_val,aps_val);\r
+\r
+                if(!led_cur && !apre_val && !aps_val)\r
+                {\r
+                    LOS_Msleep(1000);\r
+                    vc9202_get_leaklight_data(&led_cur,&apre_val,&aps_val);\r
+                }\r
+\r
                 databuf[0] = (uint8_t)((led_cur & 0xFF000000) >> 24);\r
                 databuf[1] = (uint8_t)((led_cur & 0x00FF0000) >> 16);\r
                 databuf[2] = (uint8_t)((led_cur & 0x0000FF00) >> 8);\r
@@ -1709,7 +1734,7 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint
             {\r
                 //获取充电IC ID\r
                 uint8_t chip_id = 0;\r
-#ifdef ENABLE_HP4507\r
+#ifdef ENABLE_HP4570\r
                 chip_id = hp4507_get_id();\r
                 PRINT("chip id = 0x%x\n",chip_id);\r
 #endif\r
@@ -1779,13 +1804,17 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint
             {\r
                 //切换vbus供电测电流\r
                 uint8_t send_data = 0x00;\r
-#ifdef ENABLE_HP4507\r
-                hp45xxx_init(HP4570C9);\r
+#ifdef ENABLE_HP4570\r
+                // hp45xxx_init(HP4570C9);\r
                 hp45xxx_set_batfet_dis(true);\r
-                // hp45xxx_set_ceb_en(true);\r
+                LOS_Mdelay(50);\r
+                hp45xxx_set_ceb_en(false);\r
+                LOS_Mdelay(50);\r
                 hp45xxx_set_hiz_en(false);\r
                 LOS_Mdelay(50);\r
-                if (hp45xxx_read_status_vbus_pg()) \r
+\r
+                send_data = hp45xxx_read_status_vbus_pg();\r
+                if (send_data) \r
                     PRINT("VBUS is in Power Good state\n");\r
                 else \r
                     PRINT("VBUS is not in Power Good state\n");\r
@@ -1796,6 +1825,31 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint
                 0x06,\r
                 &send_data,\r
                 1);\r
+            } else if(testitem == 0x07)\r
+            {\r
+                //切换电池供电\r
+                uint8_t send_data = 0x00;\r
+#ifdef ENABLE_HP4570\r
+                hp45xxx_set_batfet_dis(false);\r
+                LOS_Mdelay(50);\r
+                hp45xxx_set_hiz_en(true);\r
+                LOS_Mdelay(50);\r
+                hp45xxx_set_ceb_en(true);\r
+                LOS_Mdelay(50);\r
+                send_data = hp45xxx_read_status_vbus_pg();\r
+\r
+                if (send_data) \r
+                    PRINT("VBUS is in Power Good state\n");\r
+                else \r
+                    PRINT("VBUS is not in Power Good state\n");\r
+            \r
+                send_data = !send_data;\r
+#endif\r
+                factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST,\r
+                BLE_TEST_CMD_SOFT_TEST_SUB_MODE_PM,\r
+                0x07,\r
+                &send_data,\r
+                1);\r
             }\r
             \r
 \r
@@ -2371,6 +2425,40 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint
 \r
             break;\r
 \r
+        case BLE_TEST_CMD_SOFT_TEST_SUB_MODE_GYRO:\r
+\r
+            if (testitem == 0x01)\r
+            {\r
+                uint8_t send_data = 0x00;\r
+#ifdef ENABLE_GYRO\r
+                send_data = gyro_get_chip_id();\r
+                PRINT("send_data : 0x%x \n",send_data);\r
+#endif\r
+                factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST,\r
+                        BLE_TEST_CMD_SOFT_TEST_SUB_MODE_GYRO,\r
+                        0x01,\r
+                        &send_data,\r
+                        1);\r
+            } else if(testitem == 0x02)\r
+            {\r
+#ifdef ENABLE_GYRO\r
+                uint8_t databuf[6];\r
+                get_gsensor_single(databuf);\r
+                for(int i = 0; i < 5 ; i++)\r
+                {\r
+                    get_gyro_single(databuf);\r
+\r
+                    factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST,\r
+                    BLE_TEST_CMD_SOFT_TEST_SUB_MODE_GYRO,\r
+                    0x02,\r
+                    databuf,\r
+                    6);\r
+                    LOS_Msleep(1000);\r
+                }\r
+#endif\r
+            } \r
+            break;\r
+\r
         default:\r
             printf("");\r
             break;\r
index b2cbec6..5e6f31e 100644 (file)
@@ -97,6 +97,8 @@ extern "C" {
 #define BLE_TEST_CMD_SOFT_TEST_SUB_MODE_LQBP  0x1C
 //软件测试 子模式ID  GPS
 #define BLE_TEST_CMD_SOFT_TEST_SUB_MODE_GPS  0x1D
+//软件测试 子模式ID  陀螺仪
+#define BLE_TEST_CMD_SOFT_TEST_SUB_MODE_GYRO  0x1E
 
 //软件测试 子模式ID  通讯录
 #define BLE_TEST_CMD_SOFT_TEST_SUB_MODE_CONTACTS  0x30
index 91d30d3..93c4bff 100644 (file)
@@ -103,6 +103,10 @@ void system_init_uart(void){}
 #include "bleEvent.h"
 #endif
 
+#ifdef ENABLE_GYRO
+#include "gyro_hal.h"
+#endif
+
 errcode_t uapi_create_osThread_custom(app_task_definition_t *task_cfg)
 {
     if (task_cfg==NULL)
@@ -1471,7 +1475,7 @@ int uapi_callVolumeGet(void)
 
 void power_on_cat1(void)
 {
-    #ifdef FD230
+    #if defined(FD230) && !defined(BOARD_W9)
     uapi_cat1_power_on(1);    
     uapi_cat1_reset(0);
     #else
@@ -1522,6 +1526,11 @@ void uapi_set4GCapability(bool isopen)
         // uapi_custom_set_uart_rx_enable_flag(false);
 
         #ifdef SUPPORT_TCPIP
+            if(tcp_thread_id == NULL)
+            {
+                PRINT("tcp_thread_id is NULL\n");
+                return;
+            }
             tcp_thread_id = tcp_get_thread_id();
             ret = uapi_resume_thread(tcp_thread_id);
             if(ret != ERRCODE_SUCC)
@@ -1547,6 +1556,11 @@ void uapi_set4GCapability(bool isopen)
         }
 
         #ifdef SUPPORT_TCPIP
+            if(tcp_thread_id == NULL)
+            {
+                PRINT("tcp_thread_id is NULL\n");
+                return;
+            }
             tcp_thread_id = tcp_get_thread_id();
             ret = uapi_suspend_thread(tcp_thread_id);
             if(ret != ERRCODE_SUCC)
@@ -2066,6 +2080,34 @@ void get_gsensor_single(uint8_t *databuf) {
     PRINT("GSENSOR: %02X %02X %02X %02X %02X %02X\r\n", databuf[0], databuf[1], databuf[2], databuf[3], databuf[4], databuf[5]);
 }
 
+void get_gyro_single(uint8_t *databuf) 
+{
+
+    if(databuf == NULL)
+        return;
+
+#ifdef ENABLE_GYRO
+    gyro_data_t data = gyro_get_data();
+
+    int16_t x, y, z;
+    x = data.x * 2048;
+    y = data.y * 2048;
+    z = data.z * 2048;
+
+    databuf[0] = (uint8_t)((x & 0xFF00) >> 8);
+    databuf[1] = (uint8_t)(x & 0x00FF);
+
+    databuf[2] = (uint8_t)((y & 0xFF00) >> 8);
+    databuf[3] = (uint8_t)(y & 0x00FF);
+    databuf[4] = (uint8_t)((z & 0xFF00) >> 8);
+    databuf[5] = (uint8_t)(z & 0x00FF);
+
+    PRINT("x : %.2f, y : %.2f, z : %.2f \r\n",data.x,data.y,data.z);
+    PRINT("x : %d, y : %d, z : %d \r\n", x, y, z);
+    PRINT("gyro: %02X %02X %02X %02X %02X %02X\r\n", databuf[0], databuf[1], databuf[2], databuf[3], databuf[4], databuf[5]);
+#endif
+}
+
 void gsensor_get_single_data(gsenson_t *t)
 {
     get_gsonsen_xyz(t);
@@ -2512,7 +2554,8 @@ void custom_i2c_reset(uint8_t i2cbus, uint16_t i2c_clock)
 
 errcode_t custom_i2c_init(uint8_t bus_index)
 {
-    errcode_t result;
+    if(i2c_installed == 1)
+        return ERRCODE_SUCC;
 
 // #ifdef CONFIG_I2C_SUPPORT_DMA
 // #if CONFIG_I2C_SUPPORT_DMA
@@ -2521,18 +2564,17 @@ errcode_t custom_i2c_init(uint8_t bus_index)
 // #warning CONFIG_I2C_SUPPORT_DMA = 0
 // #endif
 // #endif
-    // if(i2c_installed == 0)
-    // {
-    result = uapi_i2c_master_init(bus_index, 400000, I2C_SPEED_MODE_FS); /* 400000: 400KHz */
+
+    errcode_t result = uapi_i2c_master_init(bus_index, 400000, I2C_SPEED_MODE_FS); /* 400000: 400KHz */
 
     if (result != ERRCODE_SUCC) {
         PRINT("cywee i2c init fail! ret=0x%x\n", result);
         return ERRCODE_FAIL;
     }
 
-    // i2c_installed = 1;
+    i2c_installed = 1;
     return ERRCODE_SUCC;
-    // }
+    
     // else
     //     return ERRCODE_FAIL;
 }
index ed203be..1ee8c8c 100644 (file)
@@ -454,6 +454,8 @@ uint8_t get_crc_from_lrc(uint8_t lrcValue);
 
 uint8_t calculate_lrc(uint8_t *data,uint16_t len,uint8_t _lrcValue);
 
+void get_gyro_single(uint8_t *databuf);
+
 #include "custom_utilscpp.h"