Merge #149 into xts_origin from refs/changes/149/head
author彭磊 <1624952103@qq.com>
Wed, 8 May 2024 12:28:11 +0000 (12:28 +0000)
committersnickersun@163.com <accounts_62b90f7fcf51ade33b6f628e@mail.teambition.com>
Wed, 8 May 2024 12:28:11 +0000 (12:28 +0000)
优化产测代码,添加alipay测试,优化睡眠模式

* refs/changes/149/head: (1 commits squashed)

  - 优化产测代码,添加alipay测试,优化睡眠模式

Signed-off-by: aliyun6865282430 <1624952103@qq.com>
Reviewed-by: snickersun@163.com <accounts_62b90f7fcf51ade33b6f628e@mail.teambition.com>
Merged-by: snickersun@163.com <accounts_62b90f7fcf51ade33b6f628e@mail.teambition.com>
link: https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230/change/149
18 files changed:
code/sdk/application/wearable/alipay/driver_adapt/IIC_Master_Driver.h
code/sdk/application/wearable/alipay/driver_adapt/soc_adapt.c
code/sdk/application/wearable/alipay/service/alipay_feature.c
code/sdk/application/wearable/alipay/service/alipay_feature.h
code/sdk/application/wearable/service/factorytest_service/factorytest_protocol.c
code/sdk/application/wearable/service/factorytest_service/factorytest_protocol.h
code/sdk/drivers/boards/brandy_evb/board_config/board_evb.h
code/sdk/drivers/peripheral/cywee/Inc/cywee_hal.h
code/sdk/drivers/peripheral/cywee/Inc/cywee_service.h
code/sdk/drivers/peripheral/cywee/service/cywee_service.c
code/sdk/drivers/peripheral/cywee/src/main_dml.c
code/sdk/drivers/peripheral/utils/custom_utils.c
code/sdk/drivers/peripheral/utils/custom_utils.h
code/sdk/drivers/peripheral/utils/custom_utils_at_cmd.c
code/sdk/vendor/alipay_sdk/alipay_sec_sdk_v3.0.0/lib/rv70_llvm/hal/csi/inc/vendor_csi.h
code/sdk/vendor/alipay_sdk/alipay_sec_sdk_v3.0.0/soc/se/hsec/hsc32i1/hs_private.c
code/sdk/vendor/alipay_sdk/alipay_sec_sdk_v3.0.0/soc/se/hsec/hsc32i1/hs_private.h
code/sdk/vendor/alipay_sdk/alipay_sec_sdk_v3.0.0/soc/se/hsec/vendor_ssp.c

index 6d0a283..3221479 100755 (executable)
@@ -1,3 +1,13 @@
+/*
+ * @Author: penglei 1624952103@qq.com
+ * @Date: 2024-03-13 15:08:38
+ * @LastEditors: penglei 1624952103@qq.com
+ * @LastEditTime: 2024-05-08 20:14:46
+ * @FilePath: /fd230new/code/sdk/application/wearable/alipay/driver_adapt/IIC_Master_Driver.h
+ * @Description: 
+ * 
+ * Copyright (c) 2024 by ${git_name_email}, All Rights Reserved. 
+ */
 /**
  * Copyright (c) CompanyNameMagicTag 2021-2022. All rights reserved.
  * Description: Alipay sec soc driver adapt.
@@ -12,7 +22,7 @@
 
 unsigned char *IIC_Master_Init(void);
 
-void IIC_Master_Send(unsigned char byAddr, unsigned char *pData, unsigned short wLen);
+int IIC_Master_Send(unsigned char byAddr, unsigned char *pData, unsigned short wLen);
 
 void IIC_Master_Receive(unsigned char byAddr, unsigned char *pData, unsigned short wLen);
 
index 60b4096..3f676ec 100755 (executable)
@@ -31,7 +31,7 @@ unsigned char *IIC_Master_Init(void)
     return g_alipay_i2c_mempool;\r
 }\r
 \r
-void IIC_Master_Send(unsigned char byAddr, unsigned char *pData, unsigned short wLen)\r
+int IIC_Master_Send(unsigned char byAddr, unsigned char *pData, unsigned short wLen)\r
 {\r
     errcode_t ret;\r
     uint32_t retry;\r
@@ -69,7 +69,7 @@ void IIC_Master_Send(unsigned char byAddr, unsigned char *pData, unsigned short
     MyPrintf("se i2c data write byAddr(0x%x),pData(0x%s),wLen(%d),ret=0x%x",byAddr, printbuf,wLen,ret);\r
 #endif\r
    \r
-    return;\r
+    return ret;\r
 }\r
 \r
 void IIC_Master_Receive(unsigned char byAddr, unsigned char *pData, unsigned short wLen)\r
index 8d3a53b..653cd25 100644 (file)
@@ -208,11 +208,10 @@ void svr_alipay_enter_lpm(void)
     return;
 }
 
-void svr_alipay_exit_lpm(void)
+int svr_alipay_exit_lpm(void)
 {
     uint32_t data;
-    csi_exit_lpm((void *)&data);
-    return;
+    return csi_exit_lpm((void *)&data);
 }
 
 int32_t svr_alipay_trans_get_last_code(char *title, uint8_t *transitcode, uint32_t *len)
index 750cd50..e933c02 100755 (executable)
@@ -244,7 +244,7 @@ typedef struct alipay_svr_api {
      * so there is generally no need to explicitly call the interface.
      * @return NULL
      */
-    void (*exit_lpm)(void);
+    int (*exit_lpm)(void);
 
     /*
      * @ingroup service api
index 3f1982b..3803d2b 100644 (file)
@@ -862,7 +862,7 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint
                 //LCD显示颜色\r
                 uint8_t send_data = 0x00;\r
                 char *color_buf[5] ={"0Xffff0000","0xff00ff00","0xff0000ff","0xffffffff","0xff000000"};\r
-\r
+                mcu_pm_lcd_on(0,0);\r
                 switch (*data)\r
                 {\r
                     case 1:\r
@@ -1350,6 +1350,21 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint
                         1);\r
             }\r
             break;\r
+        case BLE_TEST_CMD_SOFT_TEST_SUB_MODE_ALIPAY:\r
+            if(testitem == 0x01)\r
+            {\r
+                //alipay test\r
+                uint8_t send_data[2] = {0};\r
+\r
+                send_data[1] = custom_exit_lpm();\r
+                \r
+                factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST,\r
+                        BLE_TEST_CMD_SOFT_TEST_SUB_MODE_ALIPAY,\r
+                        0x01,\r
+                        send_data,\r
+                        2);\r
+            }\r
+            break;\r
         default:\r
             printf("");\r
             break;\r
index 3809216..c2478b8 100644 (file)
@@ -93,6 +93,8 @@ extern "C" {
 #define BLE_TEST_CMD_SOFT_TEST_SUB_MODE_CAT1  0x1A
 //软件测试 子模式ID  通讯录
 #define BLE_TEST_CMD_SOFT_TEST_SUB_MODE_CONTACTS  0x30
+//软件测试 子模式ID  支付宝
+#define BLE_TEST_CMD_SOFT_TEST_SUB_MODE_ALIPAY  0x31
 /**
  * 
  * encode cmd msg string and send to ble
index 7c2bf4a..7b233fc 100755 (executable)
@@ -16,7 +16,7 @@
 #endif
 
 #ifdef ENABLE_CYWEE
-extern void cywee_int1_callback(pin_t pin, uintptr_t param);
+extern void cywee_int_callback(pin_t pin, uintptr_t param);
 #endif
 /**
  * @addtogroup connectivity_config_boards
@@ -291,8 +291,8 @@ const hal_gpio_config_t g_gpio_function_config[PIN_MAX_NUMBER] = {
 
 #ifdef ENABLE_CYWEE
     /**G sensor G_INT1 S_AGPIO_L11 G_INT2 S_AGPIO_L19*/
-    //{   S_AGPIO_L11, HAL_GPIO_DIRECTION_INPUT, HAL_GPIO_LEVEL_LOW, GPIO_INTERRUPT_RISING_EDGE, cywee_int1_callback },
-    {   S_AGPIO_L19, HAL_GPIO_DIRECTION_INPUT, NULL, GPIO_INTERRUPT_DEDGE, cywee_int1_callback },
+    //{   S_AGPIO_L11, HAL_GPIO_DIRECTION_INPUT, HAL_GPIO_LEVEL_LOW, GPIO_INTERRUPT_RISING_EDGE, cywee_int_callback },
+    {   S_AGPIO_L19, HAL_GPIO_DIRECTION_INPUT, NULL, HAL_GPIO_LEVEL_HIGH, cywee_int_callback },
     // {   S_AGPIO_L19, HAL_GPIO_DIRECTION_INPUT, HAL_GPIO_LEVEL_LOW, 0, NULL },
 #endif   
     /**S_AGPIO_R1 GPO alipay默认resetpin*/
index f91ff78..50ece22 100644 (file)
@@ -502,6 +502,7 @@ void cywee_oncharging_update(int oncharging_status);
 void cywee_wearstatus_update(int wearstatus);
 void cywee_hrs_wearstatus_update(int hrs_data,int wearstatus);
 void cywee_set_user_info(int age,int gender,int weight,int height,int wearing_method);
+void cywee_get_sleep_data(void);
 
 extern uint8_t hrs_mode_state;
 
@@ -525,13 +526,17 @@ extern uint8_t hrs_mode_state;
 int cywee_main_dml(void);
 void cywee_int_handler(void);
 
-void set_user_info(int age,int gender,double weight,int height,int wearing_method);
+void cywee_set_user_info(int age,int gender,int weight,int height,int wearing_method);
+void cywee_reset_daily_data(void);
+void cywee_get_sleep_data(void);
 
 void cyw_inactivity_mode_change(int mode);
 void cyw_activity_mode_change(int mode);
 
 void hand_updown_switch(int cmd);
 
+
+
 #ifdef __cplusplus
 #if __cplusplus
 }
index 4704837..c303064 100644 (file)
@@ -74,7 +74,7 @@ void uapi_cywee_service_deinit(void);
  * 测试指令 参数cmd 选项: ACC_SERVICE_CMD_START_CHECK,ACC_SERVICE_CMD_STOP_CHECK
 */
 void do_cywee_service_check_msg(int cmd, int data[2]);
-void cywee_int1_callback(pin_t pin, uintptr_t param);
+void cywee_int_callback(pin_t pin, uintptr_t param);
 
 #ifdef __cplusplus
 }
index 06d1edc..735823e 100644 (file)
@@ -401,7 +401,7 @@ errcode_t uapi_cywee_service_init(void)
     return ERRCODE_SUCC;
 }
 
-void cywee_int1_callback(pin_t pin, uintptr_t param)
+void cywee_int_callback(pin_t pin, uintptr_t param)
 {
     // PRINT("cywee_int1_callback %d 0x%X\n",pin,param);
     uapi_gpio_clear_interrupt(pin);
index 8aa607a..772c6ca 100644 (file)
@@ -49,15 +49,22 @@ void hand_updown_switch(int cmd)
         CWM_Sensor_Disable(IDX_ALGO_WATCH_HANDUP);
 }
 
-void get_sleep_data(void)
+
+void cywee_reset_daily_data(void)
+{
+    memset(&scl, 0, sizeof(scl));
+    CWM_SettingControl(SCL_RESET_DAILY_INFO, &scl);
+}
+
+
+void cywee_get_sleep_data(void)
 {
     memset(&scl, 0, sizeof(scl));
     scl.iData[0] = 1;
-    scl.iData[1] = 0;
+    scl.iData[1] = 0; //0 立即输出,但不中止睡眠。 1 立即输出且中止睡眠
     CWM_SettingControl(SCL_REQ_SLEEPING_DATA, &scl);
 }
 
-
 void cywee_set_user_info(int age,int gender,int weight,int height,int wearing_method)
 {
     memset(&scl, 0, sizeof(scl));
@@ -70,7 +77,7 @@ void cywee_set_user_info(int age,int gender,int weight,int height,int wearing_me
     CWM_SettingControl(SCL_USER_INFO, &scl);
 }
 
-void cywee_inactivity_time_sync(void)
+void cywee_time_sync(void)
 {
     time_t rawtime;
     struct tm* timeinfo;
@@ -140,7 +147,7 @@ void activity_mode_setstatus(int cmd)
 
 void cyw_inactivity_mode_change(int mode)
 {
-    cywee_inactivity_time_sync();
+    cywee_time_sync();
     switch (mode)
     {
         //無作用
@@ -170,17 +177,6 @@ void cyw_inactivity_mode_change(int mode)
 
         //久坐、有效站立和小睡
         case INACTIVITY_MODE_SEDENTARY_AND_NAP:
-             /*
-            SCL_REQ_SLEEPING_DATA
-            int[0] = 1
-            int[1] = terminate_sleep
-            (0: 立刻輸出狀態,但不中止此段睡眠偵測, 
-            1: 立刻輸出狀態,並中止此段睡眠偵測)
-            */
-            memset(&scl, 0, sizeof(scl));
-            scl.iData[0] = 1;
-            scl.iData[1] = 1;
-            CWM_SettingControl(SCL_REQ_SLEEPING_DATA, &scl);
             memset(&scl, 0, sizeof(scl));
             scl.iData[0] = 1;
             scl.iData[1] = 3;
@@ -836,7 +832,7 @@ int cywee_main_dml(void)
     // scl.iData[4] = 5;
     // scl.iData[7] = -1;
     // CWM_SettingControl(SCL_LOG, &scl); 
-    // CWM_SettingControl(SCL_LOG, &scl);
+
 
     //呼叫任一個CWM_Sensor_Enable 前呼叫此指令 设置手动或自动模式
     memset(&scl, 0, sizeof(scl));
@@ -847,11 +843,6 @@ int cywee_main_dml(void)
     CWM_SettingControl(SCL_DML_DRV_ENABLE, &scl);
     //CWM_OS_dbgPrintf("[DBG] %s %d\n", __func__,__LINE__);
 
-    // memset(&scl, 0, sizeof(scl));
-    // scl.iData[0] = 1;
-    // scl.iData[3] = 3;
-    // scl.iData[4] = 5;
-
     CWM_Sensor_Enable(IDX_REQUEST_SENSOR);
     // //CWM_OS_dbgPrintf("[DBG] %s %d\n", __func__,__LINE__);
     CWM_Sensor_Enable(IDX_ALGO_WATCH_HANDUP);
@@ -872,18 +863,6 @@ int cywee_main_dml(void)
     
     cyw_inactivity_mode_change(INACTIVITY_MODE_SEDENTARY);
 
-    // cyw_activity_mode_change(cmd);
-    // if(cmd == SPORT_ACTIVE_MODE_NORMAL)
-    // {
-    //     cyw_inactivity_mode_change(INACTIVITY_MODE_SEDENTARY);
-    // }
-    // memset(&scl, 0, sizeof(scl));
-    // scl.iData[0] = 1;
-    // scl.iData[1] = SPORT_ACTIVE_MODE_NORMAL; //ACTIVITY_MODE_NORMAL 1001
-    // CWM_SettingControl(SCL_SET_ACTIVITY_MODE, &scl);
-    // CWM_SettingControl(SCL_SET_INACTIVITY_MODE, &scl);
-    //CWM_OS_dbgPrintf("[DBG] %s %d\n", __func__,__LINE__);
-
     return 0;
 }
 
index fe4c7c0..9114c2e 100644 (file)
@@ -1717,4 +1717,33 @@ void uapi_exit_power_saving_mode(void)
 
     //开启心率周期检测
     
-}
\ No newline at end of file
+}
+
+void uapi_get_sleeping_data(void)
+{
+    cywee_get_sleep_data();
+}
+
+void cywee_get_id(void)
+{
+    uint8_t id = 0;
+    custom_i2c_read_regs(0x19,0x0FU,1,&id,1,I2C_BUS_2);
+    PRINT("cywee id : 0x%X \r\n",id);
+}
+
+#ifdef SUPPORT_ALIPAY_SEC
+#include "alipay_feature.h"
+int custom_exit_lpm(void)
+{
+    int ret;
+    const alipay_svr_api_t *alipay_api = alipay_svr_get_api();
+    ret = alipay_api->exit_lpm();
+
+    if(ret == 0)
+        PRINT("ALIPAY TEST SUCCED !!! \r\n");
+    else
+        PRINT("ALIPAY TEST FAILED !!! \r\n");
+
+    return ret;
+}
+#endif
\ No newline at end of file
index 6cd128c..c809038 100644 (file)
@@ -162,6 +162,11 @@ errcode_t custom_i2c_transfer(uint16_t slaveAddr, uint16_t reg, int regLength, u
 uint32_t custom_i2c_suspend(void);
 uint32_t custom_i2c_resume(void);
 
+void uapi_get_sleeping_data(void);
+void cywee_get_id(void);
+int custom_exit_lpm(void);
+
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
index 6e58ff7..5e78446 100644 (file)
@@ -368,10 +368,53 @@ static uint32_t custom_get_mmc_id(uint8_t *para, uint32_t paraLen, char *strComm
 
     unsigned char id;
     mmc5603_getid(&id);
+    PRINT("mmc5603 id : 0x%X \r\n",id);
+    return ERRCODE_SUCC;
+}
+
+static uint32_t custom_get_sleeping_data(uint8_t *para, uint32_t paraLen, char *strCommonCmd)
+{
+
+    UNUSED(strCommonCmd);
+
+    uapi_get_sleeping_data();
  
     return ERRCODE_SUCC;
 }
 
+static uint32_t custom_iic_reset(uint8_t *para, uint32_t paraLen, char *strCommonCmd)
+{
+
+    UNUSED(strCommonCmd);
+
+    custom_i2c_reset();
+ 
+    return ERRCODE_SUCC;
+}
+
+
+
+static uint32_t custom_get_cywee_id(uint8_t *para, uint32_t paraLen, char *strCommonCmd)
+{
+
+    UNUSED(strCommonCmd);
+
+    cywee_get_id();
+ 
+    return ERRCODE_SUCC;
+}
+
+static uint32_t custom_alipay_exit_test(uint8_t *para, uint32_t paraLen, char *strCommonCmd)
+{
+
+    UNUSED(strCommonCmd);
+
+    custom_exit_lpm();
+
+    return ERRCODE_SUCC;
+}
+
+
 static const at_cmd_table_t g_custom_utils_cmd[] = {
     { (char *)"AT^CUSTOM_SN",      custom_utils_setsn, (char *)"123456789ABCDEF2345678" },
     { (char *)"AT^CUSTOM_SN_REQ",  custom_utils_getsn, (char *)" " },
@@ -405,6 +448,12 @@ static const at_cmd_table_t g_custom_utils_cmd[] = {
 
     { (char *)"AT^GETMMCID",      custom_get_mmc_id, (char *)" " },
 
+    { (char *)"AT^IICRESET",      custom_iic_reset, (char *)" " },
+
+    { (char *)"AT^GETCYWEEID",      custom_get_cywee_id, (char *)" " },
+
+    { (char *)"AT^EXITLPM",      custom_alipay_exit_test, (char *)" " },
+
 };
 
 at_cmd_table_t *get_custom_utils_cmd_table(uint32_t *cmd_count)
index b200ffc..85382f2 100644 (file)
@@ -11,7 +11,7 @@ EXTERNC void csi_enter_lpm(void *ctx);
 /*\r
 *退出低功耗模式\r
 */\r
-EXTERNC void csi_exit_lpm(void *ctx);\r
+EXTERNC int csi_exit_lpm(void *ctx);\r
 \r
 /*\r
 *发送请求\r
index 72b418e..357aee4 100755 (executable)
@@ -148,9 +148,9 @@ void HS_IIC_Init(void)
 
 //发送:      C8 + LEN(2) + { 命令及数据} ^ g_TransTmpKey + CRC
 //返回FALSE表示接收指令或数据CRC校验错误
-void HS_IIC_Send_Cmd(unsigned char *pData, unsigned short wLen)
+int HS_IIC_Send_Cmd(unsigned char *pData, unsigned short wLen)
 {
-       IIC_Master_Send(0xC8, pData, wLen);
+       return IIC_Master_Send(0xC8, pData, wLen);
 }
 
 //接收:      C9 + 55
index 00872e7..6670fe8 100755 (executable)
@@ -1,3 +1,13 @@
+/*
+ * @Author: penglei 1624952103@qq.com
+ * @Date: 2024-03-13 15:09:15
+ * @LastEditors: penglei 1624952103@qq.com
+ * @LastEditTime: 2024-05-08 17:23:56
+ * @FilePath: /FD230/code/sdk/vendor/alipay_sdk/alipay_sec_sdk_v3.0.0/soc/se/hsec/hsc32i1/hs_private.h
+ * @Description: 
+ * 
+ * Copyright (c) 2024 by ${git_name_email}, All Rights Reserved. 
+ */
 #ifndef        __HS_PRIVATE_H__
 #define        __HS_PRIVATE_H__
 
@@ -18,7 +28,7 @@ extern unsigned char lmemcmp(unsigned char *pBuf1, unsigned char *pBuf2, unsigne
 
 
 extern void HS_IIC_Init(void);
-extern void HS_IIC_Send_Cmd(unsigned char *pData, unsigned short wLen);
+extern int HS_IIC_Send_Cmd(unsigned char *pData, unsigned short wLen);
 extern unsigned char HS_IIC_Recv_Resp(unsigned char *pData, unsigned short wLen);
 
 extern void Delay_Ms(unsigned char byMilliSec);
index d7bb6c3..89261f9 100755 (executable)
@@ -589,10 +589,11 @@ void csi_enter_lpm(void *ctx)
     ■ ctx - 保存进入低功耗前的需要保存的上下文
   ○ 返回值
     ■ 无*/
-void csi_exit_lpm(void *ctx)
+int csi_exit_lpm(void *ctx)
 {
        unsigned char abyVer[8];
        unsigned char i;
+       int ret = 0;
 
        g_HSI2CBuf[0] = 0x00;
        g_HSI2CBuf[1] = 0x05;
@@ -620,17 +621,17 @@ void csi_exit_lpm(void *ctx)
 
                Delay_Ms(15);
 
-               HS_IIC_Send_Cmd(g_HSI2CBuf, 9);
+               ret = HS_IIC_Send_Cmd(g_HSI2CBuf, 9);
                if(0 == HS_IIC_Recv_Resp(abyVer, 8))
                {
                        if((abyVer[0] == 'V') && (abyVer[2] == '.'))
                        {
-                               return ;
+                               return ret;
                        }
                }
        }
                        
-       return ;
+       return ret;
 }