更新als的read接口和中间件接口定义
authorzf zf <2919300294@qq.com>
Mon, 19 Jun 2023 02:45:12 +0000 (10:45 +0800)
committerzf zf <2919300294@qq.com>
Mon, 19 Jun 2023 02:45:12 +0000 (10:45 +0800)
TW8013中间件接口定义.md
als/inc/als.h
als/src/als.c

index 7de8b69a36998da20c7849f63ef09de345f08c96..457d689cf1041adb68febe697f8b261020cb28f3 100755 (executable)
     返回值: 无\r
 \r
 #### 读取ALS信息\r
-    void mg_als_read( mg_als_t * als_ctrl, als_info_t *info );\r
-    参数定义:\r
+    als_info_t * mg_als_read( mg_als_t * als_ctrl )\r
+    参数定义:\r
         als_ctrl: 按键控制器\r
-        info:     传感器信息\r
-    返回值: 无\r
+    返回值:\r
+        读取失败,返回NULL;\r
+        成功,返回传感器信息\r
 \r
 #### 设置阈值\r
     void mg_als_cfg( mg_als_t * als_ctrl, uint32_t threshold_high, uint32_t threshold_low );\r
index 580fe309ae8c9064c376bca17f7265b4db144ac1..b7ed2caf669c63dfb893c718a1429f6494f9dcdd 100644 (file)
@@ -27,7 +27,7 @@ typedef struct mg_als mg_als_t;
 
 mg_als_t * mg_als_open( void );
 void mg_als_close( mg_als_t * als_ctrl );
-void mg_als_read( mg_als_t * als_ctrl, als_info_t *info );
+als_info_t * mg_als_read( mg_als_t * als_ctrl );
 void mg_als_cfg( mg_als_t * als_ctrl, uint32_t threshold_high, uint32_t threshold_low );
 
 #endif //_ALS__H__
index f4f4188c157e588b43c4a7d28db9217f8756cf57..2381469a6b580255129254e4bb5c137145de9c39 100644 (file)
@@ -95,18 +95,14 @@ void mg_als_close( mg_als_t * als_ctrl )
 }
 
 
-void mg_als_read( mg_als_t * als_ctrl, als_info_t *info )
+als_info_t * mg_als_read( mg_als_t * als_ctrl )
 {
- 
     usleep(5000);
     if(!stop){
-         info->ad_value = als_ctrl->data.ad_value;
+        return &als_ctrl->data;
     }else{
-        info->ad_value = 44444;  //Invalid value
+        return NULL;
     }
-    info->threshold_high = als_ctrl->data.threshold_high;
-    info->threshold_low  = als_ctrl->data.threshold_low;
-    info->status         = als_ctrl->data.status;
 }