diff --git a/README.md b/README.md
index e2e848f4adf9b5ec872f759982e46ff637df1a61..734457a1eb04e8376cbe849b601a5c9b327681ea 100755
--- a/README.md
+++ b/README.md
@@ -55,6 +55,7 @@ BearPi-HM Micro开发板是一块高度集成并可运行Openharmony系统的开
- [9. 通过JS应用控制LED灯](applications/BearPi/BearPi-HM_Micro/docs/device-dev/通过JS应用控制LED灯.md)
- [10. 如何在开发板上安装HAP应用](applications/BearPi/BearPi-HM_Micro/docs/device-dev/如何在开发板上安装HAP应用.md)
- [11. 开发板Wi-Fi功能使用指导](applications/BearPi/BearPi-HM_Micro/docs/device-dev/开发板Wi-Fi功能使用指导.md)
+- [12. E53扩展板功能使用指导](applications/BearPi/BearPi-HM_Micro/docs/device-dev/E53扩展板功能使用指导.md)
3、开发者贡献(以下教程为开发者贡献)
- [1. 纯Linux搭建小熊派-鸿蒙·叔(BearPi-HM Micro)设备开发的开发环境](applications/BearPi/BearPi-HM_Micro/docs/device-dev/Linux下配置小熊派设备开发的开发环境.md)@nebula-yong
diff --git a/applications/BearPi/BearPi-HM_Micro/docs/README.md b/applications/BearPi/BearPi-HM_Micro/docs/README.md
index f612671bbd7f580db9d449ad550770dc7f734f96..c099b3c134ff2515486395403295f634e7804aec 100755
--- a/applications/BearPi/BearPi-HM_Micro/docs/README.md
+++ b/applications/BearPi/BearPi-HM_Micro/docs/README.md
@@ -55,6 +55,7 @@ BearPi-HM Micro开发板是一块高度集成并可运行Openharmony系统的开
- [9. 通过JS应用控制LED灯](device-dev/通过JS应用控制LED灯.md)
- [10. 如何在开发板上安装HAP应用](device-dev/如何在开发板上安装HAP应用.md)
- [11. 开发板Wi-Fi功能使用指导](device-dev/开发板Wi-Fi功能使用指导.md)
+- [12. E53扩展板功能使用指导](device-dev/E53扩展板功能使用指导.md)
## 四、开发板图片预览[(淘宝链接)](https://item.taobao.com/item.htm?id=662078665554)
diff --git "a/applications/BearPi/BearPi-HM_Micro/docs/device-dev/E53\346\211\251\345\261\225\346\235\277\345\212\237\350\203\275\344\275\277\347\224\250\346\214\207\345\257\274.md" "b/applications/BearPi/BearPi-HM_Micro/docs/device-dev/E53\346\211\251\345\261\225\346\235\277\345\212\237\350\203\275\344\275\277\347\224\250\346\214\207\345\257\274.md"
new file mode 100755
index 0000000000000000000000000000000000000000..99ff911d501fcab0cc5fcd56c373c5853b97be79
--- /dev/null
+++ "b/applications/BearPi/BearPi-HM_Micro/docs/device-dev/E53\346\211\251\345\261\225\346\235\277\345\212\237\350\203\275\344\275\277\347\224\250\346\214\207\345\257\274.md"
@@ -0,0 +1,583 @@
+
+
+
+# E53模组使用说明
+
+**说明:**
+ 本次E53模组主要包括E53_IA1(智慧农业模块),E53_IS1(人体感应模块),E53_SC1(智慧路灯模块),E53_SC2(智慧井盖模块),E53_SF1(可燃气体检测模块)。目前已经适配好E53接口的底层驱动放在 [E53_Driver](E53_Driver)路径下面,感兴趣的读者可以去翻阅一下。另外,E53模组的底层驱动也已经可以直接调用。用户层可以通过获取驱动发布的服务使用模块。
+
+**下面将以E53_IA1的适配过程为例讲解E53模块的使用教程**
+
+ [驱动开发](#一e53ia1驱动开发)
+ [JS接口适配](#二js接口层的适配)
+ [烧录运行](#三运行结果)
+
+
+## 一、E53_IA1驱动开发
+
+1. 确定目录结构。
+
+ 在device\st\driver路径下新建E53_IA1文件夹,并创建驱动文件E53_IA1_hdf.c和编译构建文件BUILD.gn
+ 。
+ ```
+ .
+ └─ device
+ └─ st
+ └─ driver
+ └─ E53_IA1
+ │─ E53_IA1_hdf.c
+ │─ inc
+ └─ src
+
+
+ ```
+
+2. E53_IA1驱动实现
+
+ 驱动实现包含驱动业务代码和驱动入口注册,在E53_IA1_hdf.c文件中添加以下代码:
+
+ ```C++
+ #include
+ #include
+
+ #include "E53_IA1.h"
+ #include "E53_Common.h"
+
+ #include "hdf_device_desc.h"
+ #include "hdf_log.h"
+ #include "device_resource_if.h"
+ #include "osal_io.h"
+ #include "osal_mem.h"
+ #include "gpio_if.h"
+ #include "osal_time.h"
+
+
+ E53_IA1_Data_TypeDef E53_IA1_Data;
+ static uint8_t MotorStatus,LightStatus;
+
+ typedef enum {
+ E53_IA1_Start = 0,
+ E53_IA1_Stop,
+ E53_IA1_Read,
+ E53_IA1_SetMotor,
+ E53_IA1_SetLight,
+ }E53_IA1Ctrl;
+
+
+ int32_t E53_IA1DriverDispatch(struct HdfDeviceIoClient *client, int cmdCode, struct HdfSBuf *data, struct HdfSBuf *reply)
+ {
+ int ret;
+ char *replay_buf;
+ // char* read;
+ HDF_LOGE("E53 driver dispatch");
+ if (client == NULL || client->device == NULL)
+ {
+ HDF_LOGE("E53 driver device is NULL");
+ return HDF_ERR_INVALID_OBJECT;
+ }
+ switch (cmdCode)
+ {
+ case E53_IA1_Start:
+ ret = E53_IA1_Init();
+ if(ret != 0){
+ HDF_LOGE("E53 IA1 Init err");
+ return HDF_FAILURE;
+ }
+ ret = HdfSbufWriteString(reply, "E53 IA1 Init successful");
+ if(ret ==0){
+ HDF_LOGE("reply failed");
+ return HDF_FAILURE;
+ }
+ break;
+ case E53_IA1_Stop:
+ ret = E53_IA1_DeInit();
+ if(ret != 0){
+ HDF_LOGE("E53 IA1 Init err");
+ return HDF_FAILURE;
+ }
+ ret = HdfSbufWriteString(reply, "E53 IA1 Deinit successful");
+ if(ret ==0){
+ HDF_LOGE("reply failed");
+ return HDF_FAILURE;
+ }
+ break;
+ /* 接收到用户态发来的LED_WRITE_READ命令 */
+ case E53_IA1_Read:
+ ret = E53_IA1_Read_Data();
+ if(ret != 0){
+ HDF_LOGE("E53 IA1 Read Data err");
+ return HDF_FAILURE;
+ }
+ replay_buf = OsalMemAlloc(100);
+ (void)memset_s(replay_buf, 100, 0, 100);
+ sprintf(replay_buf,"{\"Temp\":%.2f,\"Hum\":%.2f,\"Lux\":%.2f,\"Motor\":\"%s\",\"LED\":\"%s\"}",\
+ E53_IA1_Data.Temperature, \
+ E53_IA1_Data.Humidity, \
+ E53_IA1_Data.Lux, \
+ MotorStatus ? "ON" : "OFF", \
+ LightStatus ? "ON" : "OFF");
+ /* 把传感器数据写入reply, 可被带至用户程序 */
+ if (!HdfSbufWriteString(reply, replay_buf))
+ {
+ HDF_LOGE("replay is fail");
+ return HDF_FAILURE;
+ }
+ OsalMemFree(replay_buf);
+ break;
+ case E53_IA1_SetMotor:
+ const char* read = HdfSbufReadString(data);
+ if(strcmp(read,"ON") == 0){
+ ret = Motor_StatusSet(ON);
+ if(ret != 0){
+ HDF_LOGE("gpioSet E53_IA1 motor gpio err");
+ return HDF_FAILURE;
+ }
+ MotorStatus = 1;
+ }else if(strcmp(read,"OFF") == 0){
+ ret = Motor_StatusSet(OFF);
+ if(ret != 0){
+ HDF_LOGE("gpioSet E53_IA1 motor gpio err");
+ return HDF_FAILURE;
+ }
+ MotorStatus = 0;
+ }else{
+ HDF_LOGE("Command wrong!");
+ return HDF_FAILURE;
+ }
+
+ replay_buf = OsalMemAlloc(100);
+ (void)memset_s(replay_buf, 100, 0, 100);
+ sprintf(replay_buf,"{\"Temp\":%.2f,\"Hum\":%.2f,\"Lux\":%.2f,\"Motor\":\"%s\",\"LED\":\"%s\"}",\
+ E53_IA1_Data.Temperature, \
+ E53_IA1_Data.Humidity, \
+ E53_IA1_Data.Lux, \
+ MotorStatus ? "ON" : "OFF", \
+ LightStatus ? "ON" : "OFF");
+ /* 把传感器数据写入reply, 可被带至用户程序 */
+ if (!HdfSbufWriteString(reply, replay_buf))
+ {
+ HDF_LOGE("replay is fail");
+ return HDF_FAILURE;
+ }
+ OsalMemFree(replay_buf);
+
+ break;
+ case E53_IA1_SetLight:
+ const char* readdata = HdfSbufReadString(data);
+ if(strcmp(readdata,"ON") == 0){
+ ret = Light_StatusSet(ON);
+ if(ret != 0){
+ HDF_LOGE("gpioSet E53_IA1 light gpio err");
+ return HDF_FAILURE;
+ }
+ LightStatus = 1;
+ }else if(strcmp(readdata,"OFF") == 0){
+ ret = Light_StatusSet(OFF);
+ if(ret != 0){
+ HDF_LOGE("gpioSet E53_IA1 light gpio err");
+ return HDF_FAILURE;
+ }
+ LightStatus = 0;
+ }else{
+ HDF_LOGE("Command wrong!");
+ return HDF_FAILURE;
+ }
+ replay_buf = OsalMemAlloc(100);
+ (void)memset_s(replay_buf, 100, 0, 100);
+ sprintf(replay_buf,"{\"Temp\":%.2f,\"Hum\":%.2f,\"Lux\":%.2f,\"Motor\":\"%s\",\"LED\":\"%s\"}",\
+ E53_IA1_Data.Temperature, \
+ E53_IA1_Data.Humidity, \
+ E53_IA1_Data.Lux, \
+ MotorStatus ? "ON" : "OFF", \
+ LightStatus ? "ON" : "OFF");
+ /* 把传感器数据写入reply, 可被带至用户程序 */
+ if (!HdfSbufWriteString(reply, replay_buf))
+ {
+ HDF_LOGE("replay is fail");
+ return HDF_FAILURE;
+ }
+ OsalMemFree(replay_buf);
+
+ break;
+
+ default:
+ return HDF_FAILURE;
+ }
+ return HDF_SUCCESS;
+ }
+
+
+ //驱动对外提供的服务能力,将相关的服务接口绑定到HDF框架
+ static int32_t Hdf_E53_IA1_DriverBind(struct HdfDeviceObject *deviceObject)
+ {
+ if (deviceObject == NULL)
+ {
+ HDF_LOGE("e53 driver bind failed!");
+ return HDF_ERR_INVALID_OBJECT;
+ }
+ static struct IDeviceIoService e53Driver = {
+ .Dispatch = E53_IA1DriverDispatch,
+ };
+ deviceObject->service = (struct IDeviceIoService *)(&e53Driver);
+ HDF_LOGD("E53 driver bind success");
+ return HDF_SUCCESS;
+ }
+
+ static int32_t Hdf_E53_IA1_DriverInit(struct HdfDeviceObject *device)
+ {
+ return HDF_SUCCESS;
+ }
+
+ // 驱动资源释放的接口
+ void Hdf_E53_IA1_DriverRelease(struct HdfDeviceObject *deviceObject)
+ {
+ if (deviceObject == NULL)
+ {
+ HDF_LOGE("Led driver release failed!");
+ return;
+ }
+ HDF_LOGD("Led driver release success");
+ return;
+ }
+
+
+ // 定义驱动入口的对象,必须为HdfDriverEntry(在hdf_device_desc.h中定义)类型的全局变量
+ struct HdfDriverEntry g_E53_IA1DriverEntry = {
+ .moduleVersion = 1,
+ .moduleName = "HDF_E53_IA1",
+ .Bind = Hdf_E53_IA1_DriverBind,
+ .Init = Hdf_E53_IA1_DriverInit,
+ .Release = Hdf_E53_IA1_DriverRelease,
+ };
+
+ // 调用HDF_INIT将驱动入口注册到HDF框架中
+ HDF_INIT(g_E53_IA1DriverEntry);
+
+ ```
+
+
+4. 驱动编译
+
+ 在driver/BUILD.gn文件中添加以下代码,将E53_IA1_hdf.c编译成hdf_E53_adapter。
+ 添加的部分在 ##start## 和 ##end##* 之间,("##start##"和"##end##"仅用来标识位置,添加完配置后删除这两行)
+
+ ```C++
+ import("//drivers/adapter/khdf/liteos/hdf.gni")
+ hdf_driver("hdf_E53_adapter") {
+ sources = [
+ ##start##
+ "E53_IA1/src/E53_IA1.c",
+ ##end##
+ "E53_SF1/src/E53_SF1.c",
+ "E53_SC1/src/E53_SC1.c",
+ "E53_SC2/src/E53_SC2.c",
+ "E53_IS1/src/E53_IS1.c",
+
+ ##start##
+ "E53_IA1/E53_IA1_hdf.c",
+ ##end##
+
+ "E53_SF1/E53_SF1_hdf.c",
+ "E53_SC1/E53_SC1_hdf.c",
+ "E53_SC2/E53_SC2_hdf.c",
+ "E53_IS1/E53_IS1_hdf.c",
+ ]
+ sources += [
+
+ ]
+
+ include_dirs = [
+ "adapter/inc/",
+ "E53_Common/inc/",
+
+ ##start##
+ "E53_IA1/inc/",
+ ##end##
+ ]
+
+ deps = [
+ "E53_Common:E53_Common",
+ ]
+ }
+ ```
+
+5. 驱动配置
+
+ 驱动设备描述
+
+ HDF框架加载驱动所需要的信息来源于HDF框架定义的驱动设备描述,因此基于HDF框架开发的驱动必须要在HDF框架定义的device_info.hcs配置文件中添加对应的设备描述,所以我们需要在device\st\bearpi_hm_micro\liteos_a\hdf_config\device_info\device_info.hcs中添加LED设备描述。 "##start##"和"##end##"之间为新增配置("##start##"和"##end##"仅用来标识位置,添加完配置后删除这两行)
+
+ ```C++
+ device_adc :: device {
+ device0 :: deviceNode {
+ policy = 0;
+ priority = 50;
+ permission = 0644;
+ moduleName = "HDF_PLATFORM_ADC_MANAGER";
+ serviceName = "HDF_PLATFORM_ADC_MANAGER";
+ }
+ device1 :: deviceNode {
+ policy = 0;
+ priority = 55;
+ permission = 0644;
+ moduleName = "stm32mp157_adc_driver";
+ deviceMatchAttr = "st_stm32mp157_adc";
+ }
+ }
+ ##start##
+ device_e53 :: device {
+
+ priority = 30;
+ device_ia1 :: deviceNode {
+ policy = 2;
+ priority = 130;
+ preload = 1;
+ permission = 0777;
+ moduleName = "HDF_E53_IA1";
+ serviceName = "hdf_e53_ia1";
+ }
+ }
+ ##end##
+ ```
+
+## 二、JS接口层的适配
+
+1. 添加控制E53_IA1的JS API接口
+
+ 修改`foundation\ace\ace_engine_lite\frameworks\src\core\modules\app_module.h`,加入E53IA1Service JS API,("##start##"和"##end##"仅用来标识位置,添加完配置后删除这两行)
+
+ ```
+ public:
+ ACE_DISALLOW_COPY_AND_MOVE(AppModule);
+ AppModule() = default;
+ ~AppModule() = default;
+ static JSIValue GetInfo(const JSIValue thisVal, const JSIValue *args, uint8_t argsNum);
+ static JSIValue Terminate(const JSIValue thisVal, const JSIValue *args, uint8_t argsNum);
+ ##start##
+ static JSIValue E53IA1Service(const JSIValue thisVal, const JSIValue* args, uint8_t argsNum);
+ ##end##
+ #ifdef FEATURE_SCREEN_ON_VISIBLE
+ static JSIValue ScreenOnVisible(const JSIValue thisVal, const JSIValue *args, uint8_t argsNum);
+ #endif
+ ```
+
+ ```
+ void InitAppModule(JSIValue exports)
+ {
+ JSI::SetModuleAPI(exports, "getInfo", AppModule::GetInfo);
+ JSI::SetModuleAPI(exports, "terminate", AppModule::Terminate);
+ ##start##
+ JSI::SetModuleAPI(exports, "e53ia1service", AppModule::E53IA1Service);
+ ##end##
+ #ifdef FEATURE_SCREEN_ON_VISIBLE
+ JSI::SetModuleAPI(exports, "screenOnVisible", AppModule::ScreenOnVisible);
+ #endif
+ }
+ ```
+
+2. 编写控制E53_IA1的c++ 业务代码
+
+ 在`foundation\ace\ace_engine_lite\frameworks\src\core\modules\app_module.cpp`中加入控制E53_IA1的c++ 业务代码("##start##"和"##end##"仅用来标识位置,添加完配置后删除这两行)。
+
+ ```
+ #include "app_module.h"
+ #include "ace_log.h"
+ #include "js_app_context.h"
+ #ifdef FEATURE_SCREEN_ON_VISIBLE
+ #include "js_async_work.h"
+ #include "product_adapter.h"
+ #endif
+
+ ##start##
+ #include "hdf_sbuf.h"
+ #include "hdf_io_service_if.h"
+
+ #define E53_IA1_SERVICE "hdf_e53_ia1"
+ ##end##
+
+ namespace OHOS {
+ namespace ACELite {
+ const char * const AppModule::FILE_MANIFEST = "manifest.json";
+ const char * const AppModule::KEY_APP_NAME = "appName";
+ const char * const AppModule::KEY_VERSION_NAME = "versionName";
+ const char * const AppModule::KEY_VERSION_CODE = "versionCode";
+
+ ```
+
+ ```
+ struct AsyncParams : public MemoryHeap {
+ ACE_DISALLOW_COPY_AND_MOVE(AsyncParams);
+ AsyncParams() : result(nullptr), callback(nullptr), context(nullptr) {}
+
+ JSIValue result;
+ JSIValue callback;
+ JSIValue context;
+ };
+ #endif
+
+ ##start##
+
+ static int E53IA1Control(struct HdfIoService *serv, int32_t cmd, const char* buf, char **val)
+ {
+ int ret = HDF_FAILURE;
+ struct HdfSBuf *data = HdfSBufObtainDefaultSize();
+ struct HdfSBuf *reply = HdfSBufObtainDefaultSize();
+
+ if (data == NULL || reply == NULL) {
+ HILOG_ERROR(HILOG_MODULE_ACE,"fail to obtain sbuf data\n");
+ return ret;
+ }
+
+ if (!HdfSbufWriteString(data, buf))
+ {
+ HILOG_ERROR(HILOG_MODULE_ACE,"fail to write sbuf\n");
+ HdfSBufRecycle(data);
+ HdfSBufRecycle(reply);
+ return ret;
+ }
+
+ ret = serv->dispatcher->Dispatch(&serv->object, cmd, data, reply);
+ if (ret != HDF_SUCCESS)
+ {
+ HILOG_ERROR(HILOG_MODULE_ACE,"fail to send service call\n");
+ HdfSBufRecycle(data);
+ HdfSBufRecycle(reply);
+ return ret;
+ }
+
+ *val = (char *)(HdfSbufReadString(reply));
+ if(val ==NULL){
+ HILOG_ERROR(HILOG_MODULE_ACE,"fail to get service call reply\n");
+ ret = HDF_ERR_INVALID_OBJECT;
+ HdfSBufRecycle(data);
+ HdfSBufRecycle(reply);
+ return ret;
+
+ }
+
+ HILOG_ERROR(HILOG_MODULE_ACE,"Get reply is: %s\n", *val);
+
+ HdfSBufRecycle(data);
+ HdfSBufRecycle(reply);
+ return ret;
+ }
+
+ JSIValue AppModule::E53IA1Service(const JSIValue thisVal, const JSIValue *args, uint8_t argsNum)
+ {
+ struct HdfIoService *serv = HdfIoServiceBind(E53_IA1_SERVICE);
+ if (serv == NULL)
+ {
+ HILOG_ERROR(HILOG_MODULE_ACE,"fail to get service %s\n", E53_IA1_SERVICE);
+ return JSI::CreateUndefined();
+ }
+
+ if ((args == nullptr) || (argsNum == 0) || (JSI::ValueIsUndefined(args[0]))) {
+ return JSI::CreateUndefined();
+ }
+
+ JSIValue success = JSI::GetNamedProperty(args[0], CB_SUCCESS);
+ JSIValue fail = JSI::GetNamedProperty(args[0], CB_FAIL);
+ JSIValue complete = JSI::GetNamedProperty(args[0], CB_COMPLETE);
+
+ int32_t cmd = (int32_t)JSI::GetNumberProperty(args[0], "cmd");
+ char *data = (char *)JSI::GetStringProperty(args[0], "data");
+ HILOG_ERROR(HILOG_MODULE_ACE, "cmd is: %d\n", cmd);
+ HILOG_ERROR(HILOG_MODULE_ACE,"data is: %s\n", data);
+ char *replyData;
+
+ if (E53IA1Control(serv, cmd, data, &replyData))
+ {
+ HILOG_ERROR(HILOG_MODULE_ACE,"fail to send event\n");
+ JSI::CallFunction(fail, thisVal, nullptr, 0);
+ JSI::CallFunction(complete, thisVal, nullptr, 0);
+ JSI::ReleaseValueList(success, fail, complete);
+ return JSI::CreateUndefined();
+ }
+
+ JSIValue result = JSI::CreateObject();
+
+ JSI::SetStringProperty(result, "e53_ia1", replyData);
+ JSIValue argv[ARGC_ONE] = {result};
+ JSI::CallFunction(success, thisVal, argv, ARGC_ONE);
+ JSI::CallFunction(complete, thisVal, nullptr, 0);
+ JSI::ReleaseValueList(success, fail, complete, result);
+
+ HdfIoServiceRecycle(serv);
+
+ return JSI::CreateUndefined();
+ }
+
+ ##end##
+
+ JSIValue AppModule::GetInfo(const JSIValue thisVal, const JSIValue *args, uint8_t argsNum)
+ {
+ JSIValue result = JSI::CreateUndefined();
+
+ cJSON *manifest = ReadManifest();
+ if (manifest == nullptr) {
+ HILOG_ERROR(HILOG_MODULE_ACE, "Fail to get the content of manifest.");
+ return result;
+ }
+
+ cJSON *appName = cJSON_GetObjectItem(manifest, KEY_APP_NAME);
+ cJSON *versionName = cJSON_GetObjectItem(manifest, KEY_VERSION_NAME);
+ cJSON *versionCode = cJSON_GetObjectItem(manifest, KEY_VERSION_CODE);
+
+ result = JSI::CreateObject();
+ if (appName != nullptr && appName->type == cJSON_String) {
+ JSI::SetStringProperty(result, KEY_APP_NAME, appName->valuestring);
+ }
+ if (versionName != nullptr && versionName->type == cJSON_String) {
+ JSI::SetStringProperty(result, KEY_VERSION_NAME, versionName->valuestring);
+ }
+ if (versionCode != nullptr && versionCode->type == cJSON_Number) {
+ JSI::SetNumberProperty(result, KEY_VERSION_CODE, versionCode->valuedouble);
+ }
+ cJSON_Delete(manifest);
+ manifest = nullptr;
+ return result;
+ }
+ ```
+
+3. 配置HDF头文件路径
+
+ 在`foundation\ace\ace_engine_lite\ace_lite.gni`中添加HDF头文件路径。
+
+ ```
+ ace_lite_include_dirs += [
+ "//drivers/framework/ability/sbuf/include",
+ "//drivers/framework/include/core",
+ "//drivers/framework/include/utils",
+ "//drivers/adapter/uhdf/posix/include",
+ ]
+ ```
+4. 添加编译依赖
+
+ 修改`foundation\ace\ace_engine_lite\frameworks\BUILD.gn`,在`public_deps`中添加以下代码
+
+ ```
+ "//drivers/adapter/uhdf/manager:hdf_core",
+ ```
+
+ 修改`foundation\ace\ace_engine_lite\test\ace_test_config.gni`,在`extra_deps`中添加以下代码
+ ```
+ "//drivers/adapter/uhdf/manager:hdf_core",
+ ```
+
+
+## 三、运行结果
+1. **烧录:**
+
+ 参考[编译烧录](BearPi-HM_Micro开发板编译调试.md)
+
+2. **安装Hap应用:**
+ 参考[安装HAP应用](如何在开发板上安装HAP应用.md)教程安装applications/BearPi/BearPi-HM_Micro/tools/hap_tools/hap_example目录下的Micro_E53.hap应用进行测试
+
+3. **运行结果**
+ 点击屏幕图标可以对E53_IA1进行控制。
+
+
+
+ [回到文章顶部](#文章顶部)
+
+
diff --git a/applications/BearPi/BearPi-HM_Micro/docs/device-dev/figures/E53_IA1_App.png b/applications/BearPi/BearPi-HM_Micro/docs/device-dev/figures/E53_IA1_App.png
new file mode 100755
index 0000000000000000000000000000000000000000..53a1e750dd527f54e2a15fc2a225bc7a5a51346e
Binary files /dev/null and b/applications/BearPi/BearPi-HM_Micro/docs/device-dev/figures/E53_IA1_App.png differ
diff --git a/applications/BearPi/BearPi-HM_Micro/tools/hap_tools/hap_example/Micro_E53.hap b/applications/BearPi/BearPi-HM_Micro/tools/hap_tools/hap_example/Micro_E53.hap
new file mode 100755
index 0000000000000000000000000000000000000000..36972bcfb5cefa0bf7967d316a1ce4874401f035
Binary files /dev/null and b/applications/BearPi/BearPi-HM_Micro/tools/hap_tools/hap_example/Micro_E53.hap differ
diff --git a/applications/BearPi/BearPi-HM_Micro/tools/hap_tools/hap_example/bm b/applications/BearPi/BearPi-HM_Micro/tools/hap_tools/hap_example/bm
new file mode 100755
index 0000000000000000000000000000000000000000..2ccc2289b2066a851fd8aebe6615c91b86f79cd8
Binary files /dev/null and b/applications/BearPi/BearPi-HM_Micro/tools/hap_tools/hap_example/bm differ
diff --git a/device/st/bearpi_hm_micro/liteos_a/hdf_config/device_info/device_info.hcs b/device/st/bearpi_hm_micro/liteos_a/hdf_config/device_info/device_info.hcs
index fe5f1bd3a66c49878831fe85d091fd02e2f76147..e29b6f2d2953b8896bb83bc20c8826eb91462994 100755
--- a/device/st/bearpi_hm_micro/liteos_a/hdf_config/device_info/device_info.hcs
+++ b/device/st/bearpi_hm_micro/liteos_a/hdf_config/device_info/device_info.hcs
@@ -147,15 +147,41 @@
deviceMatchAttr = "st_stm32mp157_adc";
}
}
- device_e53 :: device {
- device0 :: deviceNode {
- policy = 2;
- priority = 160;
- preload = 1;
- permission = 0777;
- moduleName = "HDF_E53_IA1";
- serviceName = "hdf_e53_ia1";
- deviceMatchAttr = "stm32mp157_e53_ia1";
+ device_e53 :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0777;
+ moduleName = "HDF_E53_IA1";
+ serviceName = "hdf_e53_ia1";
+ }
+ device1 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0777;
+ moduleName = "HDF_E53_SC2";
+ serviceName = "hdf_e53_sc2";
+ }
+ device2 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0777;
+ moduleName = "HDF_E53_SC1";
+ serviceName = "hdf_e53_sc1";
+ }
+ device3 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0777;
+ moduleName = "HDF_E53_SF1";
+ serviceName = "hdf_e53_sf1";
+ }
+ device4 :: deviceNode {
+ policy = 2;
+ priority = 100;
+ permission = 0777;
+ moduleName = "HDF_E53_IS1";
+ serviceName = "hdf_e53_is1";
}
}
diff --git a/device/st/bearpi_hm_micro/liteos_a/hdf_config/e53_ia1/e53_ia1_config.hcs b/device/st/bearpi_hm_micro/liteos_a/hdf_config/e53_ia1/e53_ia1_config.hcs
deleted file mode 100755
index 662e10f213d15da5d7d2c523065304f41c98618c..0000000000000000000000000000000000000000
--- a/device/st/bearpi_hm_micro/liteos_a/hdf_config/e53_ia1/e53_ia1_config.hcs
+++ /dev/null
@@ -1,8 +0,0 @@
-root {
- E53DriverConfig {
- i2c_channel = 1; //I2C_1
- led_gpio_num = 16; //PB1
- motor_gpio_num = 6; //PA6
- match_attr = "stm32mp157_e53_ia1"; //该字段的值必须和device_info.hcs中的deviceMatchAttr值一致
- }
-}
\ No newline at end of file
diff --git a/device/st/bearpi_hm_micro/liteos_a/hdf_config/hdf.hcs b/device/st/bearpi_hm_micro/liteos_a/hdf_config/hdf.hcs
index 10aa3c9ae5a55a5129bf2962cae5365cb294ec7a..fc4f6b486fab3b707c8aff482f8ec3b8459a4af6 100755
--- a/device/st/bearpi_hm_micro/liteos_a/hdf_config/hdf.hcs
+++ b/device/st/bearpi_hm_micro/liteos_a/hdf_config/hdf.hcs
@@ -9,7 +9,6 @@
#include "ltdc/ltdc_config.hcs"
#include "wifi/wlan_platform.hcs"
#include "wifi/wlan_chip_hi3881.hcs"
-#include "e53_ia1/e53_ia1_config.hcs"
#include "pwm/pwm_config.hcs"
root {
diff --git a/device/st/drivers/BUILD.gn b/device/st/drivers/BUILD.gn
index e0ea7e2408a309fe138bd0000c010c49e64e3620..41b4a2d6e0478c6389ab53d295d127c8af56e778 100755
--- a/device/st/drivers/BUILD.gn
+++ b/device/st/drivers/BUILD.gn
@@ -21,7 +21,7 @@ group("drivers") {
"iwdg",
"i2c",
"gpio",
- "e53_ia1",
+ "e53_driver",
"stm32mp1xx_hal",
]
}
diff --git a/device/st/drivers/e53_driver/BUILD.gn b/device/st/drivers/e53_driver/BUILD.gn
new file mode 100755
index 0000000000000000000000000000000000000000..dcede146cc4ef644b5140f35a9b351e33064c1ea
--- /dev/null
+++ b/device/st/drivers/e53_driver/BUILD.gn
@@ -0,0 +1,47 @@
+# Copyright (c) 2021 Nanjing Xiaoxiongpai Intelligent Technology Co., Ltd.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+import("//drivers/adapter/khdf/liteos/hdf.gni")
+
+hdf_driver("hdf_E53_adapter") {
+ sources = [
+ "E53_IA1/src/E53_IA1.c",
+ "E53_SC1/src/E53_SC1.c",
+ "E53_SC2/src/E53_SC2.c",
+ "E53_SF1/src/E53_SF1.c",
+ "E53_IS1/src/E53_IS1.c",
+
+ "E53_IA1/E53_IA1_hdf.c",
+ "E53_SC1/E53_SC1_hdf.c",
+ "E53_SC2/E53_SC2_hdf.c",
+ "E53_SF1/E53_SF1_hdf.c",
+ "E53_IS1/E53_IS1_hdf.c",
+ ]
+
+ include_dirs = [
+ "adapter/inc/",
+ "E53_Common/inc/",
+ "E53_IA1/inc/",
+ "E53_SC1/inc",
+ "E53_SC2/inc",
+ "E53_SF1/inc",
+ "E53_IS1/inc",
+ ]
+
+ deps = [
+ "E53_Common:E53_Common",
+
+ ]
+}
+
diff --git a/device/st/drivers/e53_driver/E53_Common/BUILD.gn b/device/st/drivers/e53_driver/E53_Common/BUILD.gn
new file mode 100755
index 0000000000000000000000000000000000000000..8259baeb2d1f943b1276447ac7ec3a55468f368e
--- /dev/null
+++ b/device/st/drivers/e53_driver/E53_Common/BUILD.gn
@@ -0,0 +1,27 @@
+# Copyright (c) 2021 Nanjing Xiaoxiongpai Intelligent Technology Co., Ltd.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import("//drivers/adapter/khdf/liteos/hdf.gni")
+
+hdf_driver("hdf_E53_Common") {
+ sources = [
+ "src/BM_E53_ADC_DAC.c",
+ "src/BM_E53_IIC.c",
+ "src/BM_E53_GPIO.c",
+ "src/BM_E53_PWM.c",
+ ]
+ include_dirs = [
+ "inc/",
+ ]
+}
+
diff --git a/device/st/drivers/e53_driver/E53_Common/inc/E53_Common.h b/device/st/drivers/e53_driver/E53_Common/inc/E53_Common.h
new file mode 100755
index 0000000000000000000000000000000000000000..7d6c7e59191f0d2916cc7844fac06441f8b27228
--- /dev/null
+++ b/device/st/drivers/e53_driver/E53_Common/inc/E53_Common.h
@@ -0,0 +1,288 @@
+/*
+ * Copyright (c) 2022 Nanjing Xiaoxiongpai Intelligent Technology Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __E53_COMMON_H__
+#define __E53_COMMON_H__
+
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif
+#endif /* __cplusplus */
+
+#include
+
+#define E53_Log(fmt, ...) do { dprintf("[E53 INFO][%s][%s]: " fmt "\r\n",__FILE__,__func__, ##__VA_ARGS__);} while (0)
+
+ typedef enum {
+ E53_Ok = 0,
+ E53_Failed,
+ }E53_Status;
+
+ typedef enum {
+ E53_IO_0 = 0,
+ E53_IO_1,
+ E53_IO_2,
+ E53_IO_3,
+ E53_IO_4,
+ E53_IO_5,
+ E53_IO_6,
+ E53_IO_7,
+ E53_IO_8,
+ E53_IO_9,
+ E53_IO_10,
+ E53_IO_11,
+ E53_IO_12,
+ E53_IO_13,
+ E53_IO_14,
+ }E53_IO_Name;
+
+ typedef enum {
+ E53_IO0_Func_GPIO,
+ E53_IO0_Func_SPI_CLK,
+ }E53_IO0_Func;
+
+ typedef enum {
+ E53_IO1_Func_GPIO,
+ E53_IO1_Func_SPI_NSS,
+ }E53_IO1_Func;
+
+ typedef enum {
+ E53_IO2_Func_GPIO,
+ }E53_IO2_Func;
+
+ typedef enum {
+ E53_IO3_Func_GPIO,
+ E53_IO3_Func_ADC,
+ }E53_IO3_Func;
+
+ typedef enum {
+ E53_IO4_Func_GPIO,
+ E53_IO4_Func_DAC,
+ }E53_IO4_Func;
+
+ typedef enum {
+ E53_IO5_Func_GPIO,
+ }E53_IO5_Func;
+
+ typedef enum {
+ E53_IO6_Func_GPIO,
+ }E53_IO6_Func;
+
+ typedef enum {
+ E53_IO7_Func_GPIO,
+ E53_IO7_Func_IIC_SCL,
+ }E53_IO7_Func;
+
+ typedef enum {
+ E53_IO8_Func_GPIO,
+ E53_IO8_Func_IIC_SDA,
+ }E53_IO8_Func;
+
+ typedef enum {
+ E53_IO9_Func_GPIO,
+ }E53_IO9_Func;
+
+ typedef enum {
+ E53_IO10_Func_GPIO,
+ E53_IO10_Func_UART_RXD,
+ }E53_IO10_Func;
+
+ typedef enum {
+ E53_IO11_Func_GPIO,
+ E53_IO11_Func_UART_TXD,
+ }E53_IO11_Func;
+
+ typedef enum {
+ E53_IO12_Func_GPIO,
+ }E53_IO12_Func;
+
+ typedef enum {
+ E53_IO13_Func_GPIO,
+ E53_IO13_Func_SPI_MOSI,
+ }E53_IO13_Func;
+
+ typedef enum {
+ E53_IO14_Func_GPIO,
+ E53_IO14_Func_SPI_MISO,
+ }E53_IO14_Func;
+
+
+ typedef enum {
+ E53_Level_Down = 0,
+ E53_Level_High = 1,
+ }E53_GPIO_Level;
+
+ typedef enum {
+ E53_GPIO_Out_PullUp = 0,
+ E53_GPIO_Out_PullDown,
+ E53_GPIO_Out_PullNone,
+ E53_GPIO_Out_DrainUp,
+ E53_GPIO_Out_DrainDown,
+ E53_GPIO_In_Floating,
+ E53_GPIO_In_Up,
+ E53_GPIO_In_Down,
+ }E53_GPIO_Mode;
+
+ typedef enum {
+ E53_GPIO_IRQ_TRIGGER_NONE,
+ /** Rising edge triggered */
+ E53_GPIO_IRQ_TRIGGER_RISING,
+ /** Falling edge triggered */
+ E53_GPIO_IRQ_TRIGGER_FALLING,
+ /** High-level triggered */
+ E53_GPIO_IRQ_TRIGGER_HIGH,
+ /** Low-level triggered */
+ E53_GPIO_IRQ_TRIGGER_LOW,
+ /** execute interrupt service routine in thread context */
+ E53_GPIO_IRQ_USING_THREAD = (0x1 << 8),
+ }E53_GPIO_IRQ_Type;
+
+ typedef enum {
+ E53_I2C_FLAG_READ = (0x1 << 0),
+ /** 10-bit addressing flag. The value 1 indicates that a 10-bit address is used. */
+ E53_I2C_FLAG_ADDR_10BIT = (0x1 << 4),
+ /** Non-ACK read flag. The value 1 indicates that no ACK signal is sent during the read process. */
+ E53_I2C_FLAG_READ_NO_ACK = (0x1 << 11),
+ /** Ignoring no-ACK flag. The value 1 indicates that the non-ACK signal is ignored. */
+ E53_I2C_FLAG_IGNORE_NO_ACK = (0x1 << 12),
+ /**
+ * No START condition flag. The value 1 indicates that there is no START condition for the message
+ * transfer.
+ */
+ E53_I2C_FLAG_NO_START = (0x1 << 14),
+ /** STOP condition flag. The value 1 indicates that the current transfer ends with a STOP condition. */
+ E53_I2C_FLAG_STOP = (0x1 << 15),
+ }E53_IIC_Flag;
+
+ typedef struct {
+ /** Address of the I2C device */
+ uint16_t addr;
+ /** Address of the buffer for storing transferred data */
+ uint8_t *buf;
+ /** Length of the transferred data */
+ uint16_t len;
+ /**
+ * Transfer Mode Flag | Description
+ * ------------| -----------------------
+ * I2C_FLAG_READ | Read flag
+ * I2C_FLAG_ADDR_10BIT | 10-bit addressing flag
+ * I2C_FLAG_READ_NO_ACK | No-ACK read flag
+ * I2C_FLAG_IGNORE_NO_ACK | Ignoring no-ACK flag
+ * I2C_FLAG_NO_START | No START condition flag
+ * I2C_FLAG_STOP | STOP condition flag
+ */
+ uint16_t flags;
+
+ }E53_IIC_Msg;
+
+ typedef enum {
+ E53_UartDataBits_8 = 0,
+ E53_UartDataBits_7 = 1,
+ E53_UartDataBits_6 = 2,
+ E53_UartDataBits_5 = 3,
+ }E53_UART_DataBits;
+
+ typedef enum {
+ E53_UartParityNone = 0,
+ E53_UartParityOdd = 1,
+ E53_UartParityEven = 2,
+ E53_UartParityMark = 3,
+ }E53_UART_Parity;
+
+ typedef enum {
+ E53_UartStopBits_1 = 0,
+ E53_UartStopBits_1P5 = 1,
+ E53_UartStopBits_2 = 2,
+ }E53_UART_StopBits;
+
+ typedef struct {
+ E53_UART_DataBits dataBits;
+ E53_UART_Parity parity;
+ E53_UART_StopBits stopBits;
+ }E53_UART_Attr;
+
+
+ typedef enum {
+ E53_SPI_TimeOut_1us = 1,
+ E53_SPI_TimeOut_10us = 10,
+ E53_SPI_TimeOut_50us = 50,
+ E53_SPI_TimeOut_100us = 100,
+ E53_SPI_TimeOut_500us = 500,
+ E53_SPI_TimeOut_1ms = 1000,
+ E53_SPI_TimeOut_10ms = 10000,
+ E53_SPI_TimeOut_50ms = 50000,
+ E53_SPI_TimeOut_100ms = 100000,
+ E53_SPI_TimeOut_500ms = 500000,
+ }E53_SPI_TimeOut;
+
+ typedef int32_t(*E53_GpioIrqFunc)(uint16_t gpio, void *data);
+
+ E53_Status E53_GPIOInit(E53_IO_Name io_name, E53_GPIO_Mode mode);
+ E53_Status E53_GPIODeinit(E53_IO_Name io_name);
+ E53_Status E53_GPIOWrite(E53_IO_Name io_name, E53_GPIO_Level level);
+ E53_Status E53_GPIORead(E53_IO_Name io_name, uint16_t *ret);
+ E53_Status E53_GPIOSetIRQ(E53_IO_Name io_name, E53_GPIO_IRQ_Type type, E53_GpioIrqFunc func, void *arg);
+ E53_Status E53_GPIOUnsetIRQ(E53_IO_Name io_name);
+ E53_Status E53_GPIOStartIRQ(E53_IO_Name io_name);
+ E53_Status E53_GPIOStopIRQ(E53_IO_Name io_name);
+
+ E53_Status E53_ADCOpen(void);
+ E53_Status E53_ADCClose(void);
+ E53_Status E53_ADCRead(uint32_t* value);
+
+ E53_Status E53_DACOpen(void);
+ E53_Status E53_DACClose(void);
+ E53_Status E53_DACWrite(uint32_t value);
+
+ E53_Status E53_IICOpen(void);
+ E53_Status E53_IICClose(void);
+ E53_Status E53_IICTransmit(E53_IIC_Msg *msgs, int16_t count);
+ E53_Status E53_IICWrite(uint32_t addr, uint8_t* data, uint32_t len);
+ E53_Status E53_IICRead(uint32_t addr, uint8_t* data, uint32_t len);
+ E53_Status E53_IICWriteRead(uint32_t addr, uint8_t* wdata, uint32_t wlen, uint8_t* rdata, uint32_t rlen);
+
+ E53_Status E53_SPIOpen(void);
+ E53_Status E53_SPIClose(void);
+ E53_Status E53_SPIReceive(uint8_t *receValue, uint32_t size);
+ E53_Status E53_SPITransmit(uint8_t *writeValue, uint32_t size);
+ E53_Status E53_SPITransmitReceive(uint8_t *writeValue, uint8_t* receValue, uint32_t size, E53_SPI_TimeOut timeout);
+
+ E53_Status E53_UARTOpen(E53_UART_Attr attr);
+ E53_Status E53_UARTClose(void);
+ E53_Status E53_UARTSetBaud(uint32_t baudRate);
+ E53_Status E53_UARTGetBaud(uint32_t* baudRate);
+ E53_Status E53_UARTSendByte(uint8_t sendValue);
+ E53_Status E53_UARTSendBuffer(uint8_t* sendValue, uint32_t size);
+ E53_Status E53_UARTReadFromBuffer(uint8_t* readValue, uint32_t size);
+ E53_Status E53_UARTReceiveHandler(uint8_t* receiveValue, uint32_t size);
+
+ E53_Status E53_PWMOpen(uint32_t pwmNum);
+ E53_Status E53_PWMClose(void);
+ E53_Status E53_PWMStart(void);
+ E53_Status E53_PWMStop(void);
+ E53_Status E53_PWMSetPeriod(uint32_t period);
+ E53_Status E53_PWMSetDuty(uint32_t duty);
+ E53_Status E53_PWMSetPolarity(uint8_t polarity);
+ E53_Status E53_PWMSet(uint32_t period, uint32_t duty);
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif
+#endif /* __cplusplus */
+
+#endif // __E53_COMMON_H__
diff --git a/device/st/drivers/e53_driver/E53_Common/src/BM_E53_ADC_DAC.c b/device/st/drivers/e53_driver/E53_Common/src/BM_E53_ADC_DAC.c
new file mode 100755
index 0000000000000000000000000000000000000000..56bf14d32de9a025b2fd2e0d07142ed186571103
--- /dev/null
+++ b/device/st/drivers/e53_driver/E53_Common/src/BM_E53_ADC_DAC.c
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2022 Nanjing Xiaoxiongpai Intelligent Technology Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include
+
+#include "E53_Common.h"
+#include "adc_if.h"
+
+#define BM_E53_ADC_NUM 1
+#define BM_E53_ADC_CHANNEL_NUM 1
+
+#define BM_E53_DAC_NUM 1
+#define BM_E53_DAC_CHANNEL_NUM 1
+
+static DevHandle adcHandler = NULL;
+
+E53_Status E53_ADCOpen(void)
+{
+ if(adcHandler != NULL){
+ E53_Log("ADC has opened,please don't open it again!");
+ return E53_Failed;
+ }
+ adcHandler = AdcOpen(BM_E53_ADC_NUM);
+ if(adcHandler == NULL){
+ E53_Log("ADC Open failed");
+ return E53_Failed;
+ }
+ return E53_Ok;
+}
+
+E53_Status E53_ADCClose(void)
+{
+ if(adcHandler == NULL){
+ E53_Log("ADC has closed,please don't close it again!");
+ return E53_Failed;
+ }
+ AdcClose(adcHandler);
+ adcHandler = NULL;
+ return E53_Ok;
+}
+
+E53_Status E53_ADCRead(uint32_t* value)
+{
+ if(adcHandler == NULL){
+ E53_Log("ADC didn't open");
+ return E53_Failed;
+ }
+ if(AdcRead(adcHandler,BM_E53_ADC_CHANNEL_NUM,value) != 0){
+ E53_Log("ADC read failed!");
+ return E53_Failed;
+ }
+ return E53_Ok;
+}
diff --git a/device/st/drivers/e53_driver/E53_Common/src/BM_E53_GPIO.c b/device/st/drivers/e53_driver/E53_Common/src/BM_E53_GPIO.c
new file mode 100755
index 0000000000000000000000000000000000000000..c1ee5876f09b0580e6412dfeda14b72a66af99f8
--- /dev/null
+++ b/device/st/drivers/e53_driver/E53_Common/src/BM_E53_GPIO.c
@@ -0,0 +1,221 @@
+/*
+ * Copyright (c) 2022 Nanjing Xiaoxiongpai Intelligent Technology Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include
+
+#include "E53_Common.h"
+#include "gpio_if.h"
+
+
+int BM_E53_IO_Remap(E53_IO_Name io_name)
+{
+ if(io_name < E53_IO_0 || io_name > E53_IO_14){
+ E53_Log("E53 interface don't has io_name");
+ return -1;
+ }
+ switch (io_name)
+ {
+ case E53_IO_0:
+ return 140;
+ case E53_IO_1:
+ return 15;
+ case E53_IO_2:
+ return 16;
+ case E53_IO_3:
+ return -1;
+ case E53_IO_4:
+ return 5;
+ case E53_IO_5:
+ return 17;
+ case E53_IO_6:
+ return 6;
+ case E53_IO_7:
+ return 94;
+ case E53_IO_8:
+ return 95;
+ case E53_IO_9:
+ return 28;
+ case E53_IO_10:
+ return 21;
+ case E53_IO_11:
+ return 29;
+ case E53_IO_12:
+ return 72;
+ case E53_IO_13:
+ return 142;
+ case E53_IO_14:
+ return 141;
+ default:
+ return -1;
+ }
+}
+
+E53_Status E53_GPIOInit(E53_IO_Name io_name,E53_GPIO_Mode mode)
+{
+ int gpio_num,ret = -1;
+ gpio_num = BM_E53_IO_Remap(io_name);
+ if(gpio_num < 0){
+ E53_Log("GPIO number check failed");
+ return E53_Failed;
+ }
+ if(mode >= E53_GPIO_Out_PullUp && mode <= E53_GPIO_Out_DrainDown){
+ ret = GpioSetDir(gpio_num,GPIO_DIR_OUT);
+ }else if(mode >= E53_GPIO_In_Floating && mode <= E53_GPIO_In_Down){
+ ret = GpioSetDir(gpio_num,GPIO_DIR_IN);
+ }
+ if(ret != 0){
+ E53_Log("E53_interface set gpio direction failed!");
+ return E53_Failed;
+ }
+ return E53_Ok;
+}
+
+E53_Status E53_GPIODeinit(E53_IO_Name io_name)
+{
+ (void)io_name;
+
+ return E53_Ok;
+}
+
+
+E53_Status E53_GPIOWrite(E53_IO_Name io_name,E53_GPIO_Level level)
+{
+ int gpio_num,ret;
+ gpio_num = BM_E53_IO_Remap(io_name);
+ if(gpio_num < 0){
+ E53_Log("GPIO number check failed");
+ return E53_Failed;
+ }
+ ret = GpioWrite(gpio_num,level);
+ if(ret != 0){
+ E53_Log("E53_interface gpio write level failed!");
+ return E53_Failed;
+ }
+ return E53_Ok;
+}
+
+E53_Status E53_GPIORead(E53_IO_Name io_name,uint16_t *level)
+{
+ int gpio_num,ret;
+ gpio_num = BM_E53_IO_Remap(io_name);
+ if(gpio_num < 0){
+ E53_Log("GPIO number check failed");
+ return E53_Failed;
+ }
+ ret = GpioRead(gpio_num,(uint16_t*)level);
+ if(ret != 0){
+ E53_Log("E53_interface gpio read level failed!");
+ return E53_Failed;
+ }
+ return E53_Ok;
+}
+
+E53_Status E53_GPIOSetIRQ(E53_IO_Name io_name,E53_GPIO_IRQ_Type type,E53_GpioIrqFunc func,void *arg)
+{
+ int gpio_num,ret;
+ int irq_type;
+ gpio_num = BM_E53_IO_Remap(io_name);
+ if(gpio_num < 0){
+ E53_Log("GPIO number check failed");
+ return E53_Failed;
+ }
+ switch (type)
+ {
+ case E53_GPIO_IRQ_TRIGGER_NONE:
+ irq_type = GPIO_IRQ_TRIGGER_NONE;
+ break;
+ case E53_GPIO_IRQ_TRIGGER_RISING:
+ irq_type = GPIO_IRQ_TRIGGER_RISING;
+ break;
+ case E53_GPIO_IRQ_TRIGGER_FALLING:
+ irq_type = GPIO_IRQ_TRIGGER_FALLING;
+ break;
+ case E53_GPIO_IRQ_TRIGGER_HIGH:
+ irq_type = GPIO_IRQ_TRIGGER_HIGH;
+ break;
+ case E53_GPIO_IRQ_TRIGGER_LOW:
+ irq_type = GPIO_IRQ_TRIGGER_LOW;
+ break;
+ case E53_GPIO_IRQ_USING_THREAD:
+ irq_type = GPIO_IRQ_USING_THREAD;
+ break;
+ default:
+ break;
+ }
+ ret = GpioSetDir(gpio_num, GPIO_DIR_IN);
+ if (ret != HDF_SUCCESS) {
+ E53_Log("gpio set dir failed");
+ return ret;
+ }
+ ret = GpioSetIrq(gpio_num,irq_type,func,arg);
+ if(ret != 0){
+ E53_Log("E53_interface gpio read level failed!");
+ return E53_Failed;
+ }
+ return E53_Ok;
+}
+
+E53_Status E53_GPIOUnsetIRQ(E53_IO_Name io_name)
+{
+ int gpio_num,ret;
+ gpio_num = BM_E53_IO_Remap(io_name);
+ if(gpio_num < 0){
+ E53_Log("GPIO number check failed");
+ return E53_Failed;
+ }
+ ret = GpioUnSetIrq(gpio_num);
+ if(ret != 0){
+ E53_Log("E53_interface gpio read level failed!");
+ return E53_Failed;
+ }
+ return E53_Ok;
+}
+
+
+E53_Status E53_GPIOStartIRQ(E53_IO_Name io_name)
+{
+ int gpio_num,ret;
+ gpio_num = BM_E53_IO_Remap(io_name);
+ if(gpio_num < 0){
+ E53_Log("GPIO number check failed");
+ return E53_Failed;
+ }
+ ret = GpioEnableIrq(gpio_num);
+ if(ret != 0){
+ E53_Log("E53_interface gpio read level failed!");
+ return E53_Failed;
+ }
+ return E53_Ok;
+}
+
+
+E53_Status E53_GPIOStopIRQ(E53_IO_Name io_name)
+{
+ int gpio_num,ret;
+ gpio_num = BM_E53_IO_Remap(io_name);
+ if(gpio_num < 0){
+ E53_Log("GPIO number check failed");
+ return E53_Failed;
+ }
+ ret = GpioDisableIrq(gpio_num);
+ if(ret != 0){
+ E53_Log("E53_interface gpio read level failed!");
+ return E53_Failed;
+ }
+ return E53_Ok;
+}
+
+
+
diff --git a/device/st/drivers/e53_driver/E53_Common/src/BM_E53_IIC.c b/device/st/drivers/e53_driver/E53_Common/src/BM_E53_IIC.c
new file mode 100755
index 0000000000000000000000000000000000000000..544c292de446210f057dcf735dcc223e552c9620
--- /dev/null
+++ b/device/st/drivers/e53_driver/E53_Common/src/BM_E53_IIC.c
@@ -0,0 +1,122 @@
+/*
+ * Copyright (c) 2022 Nanjing Xiaoxiongpai Intelligent Technology Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include
+#include
+#include "osal_io.h"
+#include "osal_mem.h"
+
+#include "E53_Common.h"
+#include "i2c_if.h"
+#include "hdf_log.h"
+
+#define BM_E53_IIC_CHANNEL_NUM 1
+
+static DevHandle i2cHandler = NULL;
+
+E53_Status E53_IICOpen()
+{
+
+ if(i2cHandler != NULL){
+ E53_Log("I2C has opened,please don't open again!");
+ return E53_Failed;
+ }
+ i2cHandler = I2cOpen(BM_E53_IIC_CHANNEL_NUM);
+ if(i2cHandler == NULL){
+ E53_Log("I2C open failed!");
+ return E53_Failed;
+ }
+ return E53_Ok;
+}
+
+E53_Status E53_IICClose()
+{
+ if(i2cHandler == NULL){
+ E53_Log("I2C is closed,please don't close again!");
+ return E53_Failed;
+ }
+ I2cClose(i2cHandler);
+ i2cHandler = NULL;
+ return E53_Ok;
+}
+
+
+E53_Status E53_IICTransmit(E53_IIC_Msg *msgs, int16_t count)
+{
+ if(i2cHandler == NULL){
+ E53_Log("I2C didn't open!");
+ return E53_Failed;
+ }
+ if (I2cTransfer(i2cHandler,(struct I2cMsg*)msgs,count) != count) {
+ E53_Log("I2c read error!");
+ return E53_Failed;
+ }
+ return E53_Ok;
+}
+
+E53_Status E53_IICWrite(uint32_t addr,uint8_t* data,uint32_t len)
+{
+ E53_IIC_Msg msg[1];
+ (void)memset_s(msg, sizeof(msg), 0, sizeof(msg));
+ msg[0].addr = addr;
+ msg[0].buf = data;
+ msg[0].len = len;
+ msg[0].flags = 0;
+ if (E53_IICTransmit(msg, 1) != E53_Ok) {
+ HDF_LOGE("i2c write failed");
+ return -1;
+ }
+ return 0;
+}
+
+E53_Status E53_IICRead(uint32_t addr,uint8_t* data,uint32_t len)
+{
+ E53_IIC_Msg msg;
+ msg.addr = addr;
+ msg.buf = data;
+ msg.len = len;
+ msg.flags = E53_I2C_FLAG_READ;
+ if (E53_IICTransmit(&msg, 1) != E53_Ok) {
+ HDF_LOGE("i2c read err");
+ return -1;
+ }
+ return 0;
+}
+
+E53_Status E53_IICWriteRead(uint32_t addr,uint8_t* wdata,uint32_t wlen,uint8_t* rdata,uint32_t rlen)
+{
+ E53_IIC_Msg msg[2];
+ (void)memset_s(msg, sizeof(msg), 0, sizeof(msg));
+ msg[0].addr = addr;
+ msg[0].buf = wdata;
+ msg[0].len = wlen;
+ msg[0].flags = 0;
+ msg[1].addr = addr;
+ msg[1].buf = rdata;
+ msg[1].len = rlen;
+ msg[1].flags = E53_I2C_FLAG_READ;
+ if (E53_IICTransmit(msg, 2) != E53_Ok) {
+ HDF_LOGE("i2c write read err");
+ return -1;
+ }
+ return 0;
+}
+
+
+
+
+
+
+
diff --git a/device/st/drivers/e53_driver/E53_Common/src/BM_E53_PWM.c b/device/st/drivers/e53_driver/E53_Common/src/BM_E53_PWM.c
new file mode 100755
index 0000000000000000000000000000000000000000..b29795327193c170b67cb9682b41b186570d9e8c
--- /dev/null
+++ b/device/st/drivers/e53_driver/E53_Common/src/BM_E53_PWM.c
@@ -0,0 +1,147 @@
+/*
+ * Copyright (c) 2022 Nanjing Xiaoxiongpai Intelligent Technology Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include
+
+#include "E53_Common.h"
+#include "pwm_if.h"
+
+static DevHandle pwmHandler = NULL;
+
+E53_Status E53_PWMOpen(uint32_t pwmNum)
+{
+ if (pwmHandler != NULL) {
+ E53_Log("PWM has opened,please don't open it again!");
+ return E53_Failed;
+ }
+
+ pwmHandler = PwmOpen(pwmNum);
+ if (pwmHandler == NULL) {
+ E53_Log("PWM Open failed");
+ return E53_Failed;
+ }
+ return E53_Ok;
+}
+
+E53_Status E53_PWMClose(void)
+{
+ if (pwmHandler == NULL) {
+ E53_Log("Pwm has closed,please don't close it again!");
+ return E53_Failed;
+ }
+ PwmClose(pwmHandler);
+ pwmHandler = NULL;
+ return E53_Ok;
+}
+
+E53_Status E53_PWMStart(void)
+{
+ uint32_t ret;
+ if (pwmHandler == NULL) {
+ E53_Log("Pwm didn't opened!");
+ return E53_Failed;
+ }
+ ret = PwmEnable(pwmHandler);
+ if (ret != E53_Ok) {
+ E53_Log("Pwm Start failed!");
+ return E53_Failed;
+ }
+ return E53_Ok;
+}
+
+E53_Status E53_PWMStop(void)
+{
+ uint32_t ret;
+ if (pwmHandler == NULL) {
+ E53_Log("Pwm didn't opened!");
+ return E53_Failed;
+ }
+ ret = PwmDisable(pwmHandler);
+ if (ret != E53_Ok) {
+ E53_Log("Pwm Start failed!");
+ return E53_Failed;
+ }
+ return E53_Ok;
+}
+
+
+E53_Status E53_PWMSetPeriod(uint32_t period)
+{
+ uint32_t ret;
+ if (pwmHandler == NULL) {
+ E53_Log("Pwm didn't opened!");
+ return E53_Failed;
+ }
+ ret = PwmSetPeriod(pwmHandler, period);
+ if (ret != E53_Ok) {
+ E53_Log("Pwm set period failed!");
+ return E53_Failed;
+ }
+ E53_Log("here");
+ return E53_Ok;
+}
+
+E53_Status E53_PWMSetDuty(uint32_t duty)
+{
+ uint32_t ret;
+ if (pwmHandler == NULL) {
+ E53_Log("Pwm didn't opened!");
+ return E53_Failed;
+ }
+ ret = PwmSetDuty(pwmHandler, duty);
+ if (ret != E53_Ok) {
+ E53_Log("Pwm set duty failed!");
+ return E53_Failed;
+ }
+ E53_Log("here");
+ return E53_Ok;
+}
+
+E53_Status E53_PWMSetPolarity(uint8_t polarity)
+{
+ uint32_t ret;
+ if (pwmHandler == NULL) {
+ E53_Log("Pwm didn't opened!");
+ return E53_Failed;
+ }
+ ret = PwmSetPolarity(pwmHandler, polarity);
+ if (ret != 0) {
+ E53_Log("Pwm set polarity failed!");
+ return E53_Failed;
+ }
+ return E53_Ok;
+}
+E53_Status E53_PWMSet(uint32_t period, uint32_t duty)
+{
+ uint32_t ret;
+
+ ret = E53_PWMSetPeriod(period);
+ if (ret != E53_Ok) {
+ E53_Log("Pwm set polarity failed!");
+ return E53_Failed;
+ }
+ ret = E53_PWMSetDuty(duty);
+ if (ret != E53_Ok) {
+ E53_Log("Pwm set polarity failed!");
+ return E53_Failed;
+ }
+ return E53_Ok;
+}
+
+
+
+
+
+
diff --git a/device/st/drivers/e53_driver/E53_IA1/E53_IA1_hdf.c b/device/st/drivers/e53_driver/E53_IA1/E53_IA1_hdf.c
new file mode 100755
index 0000000000000000000000000000000000000000..5a48e200f704e84bca40eb482dfe6bde6bffd18d
--- /dev/null
+++ b/device/st/drivers/e53_driver/E53_IA1/E53_IA1_hdf.c
@@ -0,0 +1,231 @@
+/*
+ * Copyright (c) 2022 Nanjing Xiaoxiongpai Intelligent Technology Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include
+#include
+
+#include "E53_IA1.h"
+#include "E53_Common.h"
+
+#include "hdf_device_desc.h"
+#include "hdf_log.h"
+#include "device_resource_if.h"
+#include "osal_io.h"
+#include "osal_mem.h"
+#include "gpio_if.h"
+#include "osal_time.h"
+
+
+E53_IA1_Data_TypeDef E53_IA1_Data;
+static uint8_t MotorStatus,LightStatus;
+
+typedef enum {
+ E53_IA1_Start = 0,
+ E53_IA1_Stop,
+ E53_IA1_Read,
+ E53_IA1_SetMotor,
+ E53_IA1_SetLight,
+}E53_IA1Ctrl;
+
+
+int32_t E53_IA1DriverDispatch(struct HdfDeviceIoClient *client, int cmdCode, struct HdfSBuf *data, struct HdfSBuf *reply)
+{
+ int ret;
+ char *replay_buf;
+ // char* read;
+ HDF_LOGE("E53 driver dispatch");
+ if (client == NULL || client->device == NULL)
+ {
+ HDF_LOGE("E53 driver device is NULL");
+ return HDF_ERR_INVALID_OBJECT;
+ }
+ switch (cmdCode)
+ {
+ case E53_IA1_Start:
+ ret = E53_IA1_Init();
+ if(ret != 0){
+ HDF_LOGE("E53 IA1 Init err");
+ return HDF_FAILURE;
+ }
+ ret = HdfSbufWriteString(reply, "E53 IA1 Init successful");
+ if(ret ==0){
+ HDF_LOGE("reply failed");
+ return HDF_FAILURE;
+ }
+ break;
+ case E53_IA1_Stop:
+ ret = E53_IA1_DeInit();
+ if(ret != 0){
+ HDF_LOGE("E53 IA1 Init err");
+ return HDF_FAILURE;
+ }
+ ret = HdfSbufWriteString(reply, "E53 IA1 Deinit successful");
+ if(ret ==0){
+ HDF_LOGE("reply failed");
+ return HDF_FAILURE;
+ }
+ break;
+ /* 接收到用户态发来的LED_WRITE_READ命令 */
+ case E53_IA1_Read:
+ ret = E53_IA1_Read_Data();
+ if(ret != 0){
+ HDF_LOGE("E53 IA1 Read Data err");
+ return HDF_FAILURE;
+ }
+ replay_buf = OsalMemAlloc(100);
+ (void)memset_s(replay_buf, 100, 0, 100);
+ sprintf(replay_buf,"{\"Temp\":%.2f,\"Hum\":%.2f,\"Lux\":%.2f,\"Motor\":\"%s\",\"LED\":\"%s\"}",\
+ E53_IA1_Data.Temperature, \
+ E53_IA1_Data.Humidity, \
+ E53_IA1_Data.Lux, \
+ MotorStatus ? "ON" : "OFF", \
+ LightStatus ? "ON" : "OFF");
+ /* 把传感器数据写入reply, 可被带至用户程序 */
+ if (!HdfSbufWriteString(reply, replay_buf))
+ {
+ HDF_LOGE("replay is fail");
+ return HDF_FAILURE;
+ }
+ OsalMemFree(replay_buf);
+ break;
+ case E53_IA1_SetMotor:
+ const char* read = HdfSbufReadString(data);
+ if(strcmp(read,"ON") == 0){
+ ret = Motor_StatusSet(ON);
+ if(ret != 0){
+ HDF_LOGE("gpioSet E53_IA1 motor gpio err");
+ return HDF_FAILURE;
+ }
+ MotorStatus = 1;
+ }else if(strcmp(read,"OFF") == 0){
+ ret = Motor_StatusSet(OFF);
+ if(ret != 0){
+ HDF_LOGE("gpioSet E53_IA1 motor gpio err");
+ return HDF_FAILURE;
+ }
+ MotorStatus = 0;
+ }else{
+ HDF_LOGE("Command wrong!");
+ return HDF_FAILURE;
+ }
+
+ replay_buf = OsalMemAlloc(100);
+ (void)memset_s(replay_buf, 100, 0, 100);
+ sprintf(replay_buf,"{\"Temp\":%.2f,\"Hum\":%.2f,\"Lux\":%.2f,\"Motor\":\"%s\",\"LED\":\"%s\"}",\
+ E53_IA1_Data.Temperature, \
+ E53_IA1_Data.Humidity, \
+ E53_IA1_Data.Lux, \
+ MotorStatus ? "ON" : "OFF", \
+ LightStatus ? "ON" : "OFF");
+ /* 把传感器数据写入reply, 可被带至用户程序 */
+ if (!HdfSbufWriteString(reply, replay_buf))
+ {
+ HDF_LOGE("replay is fail");
+ return HDF_FAILURE;
+ }
+ OsalMemFree(replay_buf);
+
+ break;
+ case E53_IA1_SetLight:
+ const char* readdata = HdfSbufReadString(data);
+ if(strcmp(readdata,"ON") == 0){
+ ret = Light_StatusSet(ON);
+ if(ret != 0){
+ HDF_LOGE("gpioSet E53_IA1 light gpio err");
+ return HDF_FAILURE;
+ }
+ LightStatus = 1;
+ }else if(strcmp(readdata,"OFF") == 0){
+ ret = Light_StatusSet(OFF);
+ if(ret != 0){
+ HDF_LOGE("gpioSet E53_IA1 light gpio err");
+ return HDF_FAILURE;
+ }
+ LightStatus = 0;
+ }else{
+ HDF_LOGE("Command wrong!");
+ return HDF_FAILURE;
+ }
+ replay_buf = OsalMemAlloc(100);
+ (void)memset_s(replay_buf, 100, 0, 100);
+ sprintf(replay_buf,"{\"Temp\":%.2f,\"Hum\":%.2f,\"Lux\":%.2f,\"Motor\":\"%s\",\"LED\":\"%s\"}",\
+ E53_IA1_Data.Temperature, \
+ E53_IA1_Data.Humidity, \
+ E53_IA1_Data.Lux, \
+ MotorStatus ? "ON" : "OFF", \
+ LightStatus ? "ON" : "OFF");
+ /* 把传感器数据写入reply, 可被带至用户程序 */
+ if (!HdfSbufWriteString(reply, replay_buf))
+ {
+ HDF_LOGE("replay is fail");
+ return HDF_FAILURE;
+ }
+ OsalMemFree(replay_buf);
+
+ break;
+
+ default:
+ return HDF_FAILURE;
+ }
+ return HDF_SUCCESS;
+}
+
+
+//驱动对外提供的服务能力,将相关的服务接口绑定到HDF框架
+static int32_t Hdf_E53_IA1_DriverBind(struct HdfDeviceObject *deviceObject)
+{
+ if (deviceObject == NULL)
+ {
+ HDF_LOGE("e53 driver bind failed!");
+ return HDF_ERR_INVALID_OBJECT;
+ }
+ static struct IDeviceIoService e53Driver = {
+ .Dispatch = E53_IA1DriverDispatch,
+ };
+ deviceObject->service = (struct IDeviceIoService *)(&e53Driver);
+ HDF_LOGD("E53 driver bind success");
+ return HDF_SUCCESS;
+}
+
+static int32_t Hdf_E53_IA1_DriverInit(struct HdfDeviceObject *device)
+{
+ return HDF_SUCCESS;
+}
+
+// 驱动资源释放的接口
+void Hdf_E53_IA1_DriverRelease(struct HdfDeviceObject *deviceObject)
+{
+ if (deviceObject == NULL)
+ {
+ HDF_LOGE("Led driver release failed!");
+ return;
+ }
+ HDF_LOGD("Led driver release success");
+ return;
+}
+
+
+// 定义驱动入口的对象,必须为HdfDriverEntry(在hdf_device_desc.h中定义)类型的全局变量
+struct HdfDriverEntry g_E53_IA1DriverEntry = {
+ .moduleVersion = 1,
+ .moduleName = "HDF_E53_IA1",
+ .Bind = Hdf_E53_IA1_DriverBind,
+ .Init = Hdf_E53_IA1_DriverInit,
+ .Release = Hdf_E53_IA1_DriverRelease,
+};
+
+// 调用HDF_INIT将驱动入口注册到HDF框架中
+HDF_INIT(g_E53_IA1DriverEntry);
+
diff --git a/device/st/drivers/e53_driver/E53_IA1/inc/E53_IA1.h b/device/st/drivers/e53_driver/E53_IA1/inc/E53_IA1.h
new file mode 100755
index 0000000000000000000000000000000000000000..bc45d5e161f784173d454b88bd1d0c96e8f31bd2
--- /dev/null
+++ b/device/st/drivers/e53_driver/E53_IA1/inc/E53_IA1.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2022 Nanjing Xiaoxiongpai Intelligent Technology Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __E53_IA1_H__
+#define __E53_IA1_H__
+
+#include
+/***************************************************************
+* 名 称: GasStatus_ENUM
+* 说 明:枚举状态结构体
+***************************************************************/
+typedef enum
+{
+ OFF = 0,
+ ON
+} E53_IA1_Status_ENUM;
+
+/* E53_IA1传感器数据类型定义 ------------------------------------------------------------*/
+typedef struct
+{
+ float Lux; //光照强度
+ float Humidity; //湿度
+ float Temperature; //温度
+} E53_IA1_Data_TypeDef;
+
+extern E53_IA1_Data_TypeDef E53_IA1_Data;
+
+/* 寄存器宏定义 --------------------------------------------------------------------*/
+#define SHT30_Addr 0x44
+
+#define BH1750_Addr 0x23
+
+typedef enum{
+ E53_IA1_MotorGPIO = 0,
+ E53_IA1_LightGPIO
+}E53_IA1_CtrlGPIO_t;
+
+
+int E53_IA1_Init(void);
+int E53_IA1_DeInit(void);
+int E53_IA1_Read_Data(void);
+int Light_StatusSet(E53_IA1_Status_ENUM status);
+int Motor_StatusSet(E53_IA1_Status_ENUM status);
+
+
+#endif /* __E53_IA1_H__ */
+
diff --git a/device/st/drivers/e53_driver/E53_IA1/src/E53_IA1.c b/device/st/drivers/e53_driver/E53_IA1/src/E53_IA1.c
new file mode 100755
index 0000000000000000000000000000000000000000..e34dc951840fcaba5d2695f3cc33bcbc82d1201b
--- /dev/null
+++ b/device/st/drivers/e53_driver/E53_IA1/src/E53_IA1.c
@@ -0,0 +1,277 @@
+/*
+ * Copyright (c) 2022 Nanjing Xiaoxiongpai Intelligent Technology Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include
+#include
+#include
+#include
+#include "osal_mem.h"
+#include "osal_time.h"
+
+#include "E53_IA1.h"
+#include "E53_Common.h"
+
+#define E53_IA1_MOTOR_GPIO E53_IO_6
+#define E53_IA1_LIGHT_GPIO E53_IO_2
+
+
+/***************************************************************
+* 函数名称: Init_BH1750
+* 说 明: 写命令初始化BH1750
+* 参 数: 无
+* 返 回 值: 无
+***************************************************************/
+int Init_BH1750(void)
+{
+ uint8_t send_data = 0x01;
+ int ret;
+ ret = E53_IICWrite((BH1750_Addr<<1),&send_data,1);
+ return ret;
+}
+
+/***************************************************************
+* 函数名称: Start_BH1750
+* 说 明: 启动BH1750
+* 参 数: 无
+* 返 回 值: 无
+***************************************************************/
+int Start_BH1750(void)
+{
+ uint8_t send_data[1] = { 0x20 };
+ int ret;
+ ret = E53_IICWrite((BH1750_Addr<<1),send_data,1);
+ return ret;
+}
+
+/***************************************************************
+* 函数名称: SHT30_reset
+* 说 明: SHT30复位
+* 参 数: 无
+* 返 回 值: 无
+***************************************************************/
+int SHT30_reset(void)
+{
+ uint8_t send_data[2] = { 0x30,0xA2 };
+ int ret;
+ ret = E53_IICWrite((SHT30_Addr<<1),send_data,2);
+ return ret;
+}
+
+/***************************************************************
+* 函数名称: Init_SHT30
+* 说 明: 初始化SHT30,设置测量周期
+* 参 数: 无
+* 返 回 值: 无
+***************************************************************/
+int Init_SHT30(void)
+{
+ uint8_t send_data[2] = { 0x22,0x36 };
+ int ret;
+ ret = E53_IICWrite((SHT30_Addr<<1),send_data,2);
+ return ret;
+}
+
+/***************************************************************
+* 函数名称: SHT3x_CheckCrc
+* 说 明: 检查数据正确性
+* 参 数: data:读取到的数据
+ nbrOfBytes:需要校验的数量
+ checksum:读取到的校对比验值
+* 返 回 值: 校验结果,0-成功 1-失败
+***************************************************************/
+static uint8_t SHT3x_CheckCrc(uint8_t data[], uint8_t nbrOfBytes, uint8_t checksum)
+{
+
+ uint8_t crc = 0xFF;
+ uint8_t bit = 0;
+ uint8_t byteCtr ;
+ const int16_t POLYNOMIAL = 0x131;
+ //calculates 8-Bit checksum with given polynomial
+ for(byteCtr = 0; byteCtr < nbrOfBytes; ++byteCtr)
+ {
+ crc ^= (data[byteCtr]);
+ for ( bit = 8; bit > 0; --bit)
+ {
+ if (crc & 0x80) crc = (crc << 1) ^ POLYNOMIAL;
+ else crc = (crc << 1);
+ }
+ }
+
+ if(crc != checksum)
+ return 1;
+ else
+ return 0;
+
+}
+
+/***************************************************************
+* 函数名称: SHT3x_CalcTemperatureC
+* 说 明: 温度计算
+* 参 数: u16sT:读取到的温度原始数据
+* 返 回 值: 计算后的温度数据
+***************************************************************/
+static float SHT3x_CalcTemperatureC(uint16_t u16sT)
+{
+
+ float temperatureC = 0; // variable for result
+
+ u16sT &= ~0x0003; // clear bits [1..0] (status bits)
+ //-- calculate temperature [℃] --
+ temperatureC = (175 * (float)u16sT / 65535 - 45); //T = -45 + 175 * rawValue / (2^16-1)
+
+ return temperatureC;
+}
+
+/***************************************************************
+* 函数名称: SHT3x_CalcRH
+* 说 明: 湿度计算
+* 参 数: u16sRH:读取到的湿度原始数据
+* 返 回 值: 计算后的湿度数据
+***************************************************************/
+static float SHT3x_CalcRH(uint16_t u16sRH)
+{
+
+ float humidityRH = 0; // variable for result
+
+ u16sRH &= ~0x0003; // clear bits [1..0] (status bits)
+ //-- calculate relative humidity [%RH] --
+ humidityRH = (100 * (float)u16sRH / 65535); // RH = rawValue / (2^16-1) * 10
+
+ return humidityRH;
+}
+
+/***************************************************************
+* 函数名称: E53_IA1_Init
+* 说 明: 初始化E53_IA1
+* 参 数: 无
+* 返 回 值: 无
+***************************************************************/
+int E53_IA1_Init(void)
+{
+ E53_GPIOInit(E53_IA1_LIGHT_GPIO,E53_GPIO_Out_PullNone);
+ E53_GPIOInit(E53_IA1_MOTOR_GPIO,E53_GPIO_Out_PullNone);
+ E53_IICOpen();
+
+ int ret0, ret1;
+ ret0 = Init_BH1750();
+ ret1 = Init_SHT30();
+ OsalMDelay(180);
+ return ret0 | ret1;
+}
+
+/***************************************************************
+* 函数名称: E53_IA1_DeInit
+* 说 明: 初始化E53_IA1
+* 参 数: 无
+* 返 回 值: 无
+***************************************************************/
+int E53_IA1_DeInit(void)
+{
+ E53_GPIODeinit(E53_IA1_LIGHT_GPIO);
+ E53_GPIODeinit(E53_IA1_MOTOR_GPIO);
+ E53_IICClose();
+ return 0;
+}
+
+
+/***************************************************************
+* 函数名称: E53_IA1_Read_Data
+* 说 明: 测量光照强度、温度、湿度
+* 参 数: 无
+* 返 回 值: 无
+***************************************************************/
+int E53_IA1_Read_Data(void)
+{
+ Start_BH1750(); // 启动传感器采集数据
+
+ uint8_t recv_data[2] = { 0 };
+ int ret;
+ ret = E53_IICRead( (BH1750_Addr<<1),recv_data,2); // 读取传感器数据
+
+ if(ret != 0){
+ return ret;
+ }
+ E53_IA1_Data.Lux = (float)(((recv_data[0]<<8) + recv_data[1])/1.2);
+
+
+ //初始化SHT30
+ uint8_t send_data[2] = { 0xE0,0x00};
+ uint8_t rcv_buf[8]={0};
+ ret = E53_IICWrite((SHT30_Addr<<1), send_data, 2);
+ E53_IICRead((SHT30_Addr<<1), rcv_buf,6);
+
+ uint8_t data[3]; //data array for checksum verification
+ uint16_t dat,tmp;
+ // /* check tem */
+ data[0] = rcv_buf[0];
+ data[1] = rcv_buf[1];
+ data[2] = rcv_buf[2];
+ tmp=SHT3x_CheckCrc(data, 2, data[2]);
+ if( !tmp ) /* value is ture */
+ {
+ dat = ((uint16_t)data[0] << 8) | data[1];
+ E53_IA1_Data.Temperature = SHT3x_CalcTemperatureC( dat );
+ }
+ // /* check humidity */
+ data[0] = rcv_buf[3];
+ data[1] = rcv_buf[4];
+ data[2] = rcv_buf[5];
+ tmp=SHT3x_CheckCrc(data, 2, data[2]);
+ if( !tmp ) /* value is ture */
+ {
+ dat = ((uint16_t)data[0] << 8) | data[1];
+ E53_IA1_Data.Humidity = SHT3x_CalcRH( dat );
+ }
+ return 0;
+}
+
+/***************************************************************
+* 函数名称: Light_StatusSet
+* 说 明: 灯状态设置
+* 参 数: status,ENUM枚举的数据
+* OFF,关
+* ON,开
+* 返 回 值: 无
+***************************************************************/
+int Light_StatusSet(E53_IA1_Status_ENUM status)
+{
+ int ret = 0;
+ if(status == ON)
+ ret = E53_GPIOWrite(E53_IA1_LIGHT_GPIO, 1);//设置输出高电平点亮灯
+ if(status == OFF)
+ ret = E53_GPIOWrite(E53_IA1_LIGHT_GPIO, 0);//设置输出低电平关闭灯
+ return ret;
+}
+
+/***************************************************************
+* 函数名称: Motor_StatusSet
+* 说 明: 电机状态设置
+* 参 数: status,ENUM枚举的数据
+* OFF,关
+* ON,开
+* 返 回 值: 无
+***************************************************************/
+int Motor_StatusSet(E53_IA1_Status_ENUM status)
+{
+ int ret = 0;
+ if(status == ON)
+ ret = E53_GPIOWrite(E53_IA1_MOTOR_GPIO, 1);//设置输出高电平打开电机
+ if(status == OFF)
+ ret = E53_GPIOWrite(E53_IA1_MOTOR_GPIO, 0);//设置输出低电平关闭电机
+ return ret;
+}
+
+
+
diff --git a/device/st/drivers/e53_driver/E53_IS1/E53_IS1_hdf.c b/device/st/drivers/e53_driver/E53_IS1/E53_IS1_hdf.c
new file mode 100755
index 0000000000000000000000000000000000000000..86b0728693876eaf05ccf1a3c150c5654b99a3e8
--- /dev/null
+++ b/device/st/drivers/e53_driver/E53_IS1/E53_IS1_hdf.c
@@ -0,0 +1,151 @@
+/*
+ * Copyright (c) 2022 Nanjing Xiaoxiongpai Intelligent Technology Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include
+#include
+
+#include "E53_IS1.h"
+#include "E53_Common.h"
+
+#include "hdf_device_desc.h"
+#include "hdf_log.h"
+#include "device_resource_if.h"
+#include "osal_io.h"
+#include "osal_mem.h"
+#include "gpio_if.h"
+#include "osal_time.h"
+
+
+#define E53_SI1_IRQ_GPIO_PIN E53_IO_5
+
+
+typedef enum {
+ E53_IS1_Start = 0,
+ E53_IS1_Stop,
+ E53_IS1_Read,
+}E53_IS1Ctrl;
+
+
+int32_t E53_IS1_DriverDispatch(struct HdfDeviceIoClient *client, int cmdCode, struct HdfSBuf *data, struct HdfSBuf *reply)
+{
+ int ret = -1;
+ uint16_t someoneAround;
+ HDF_LOGE("E53 driver dispatch");
+ if (client == NULL || client->device == NULL) {
+ HDF_LOGE("E53 driver device is NULL");
+ return HDF_ERR_INVALID_OBJECT;
+ }
+ switch (cmdCode) {
+ case E53_IS1_Start:
+ ret = E53_IS1_Init();
+ if (ret != 0) {
+ HDF_LOGE("E53 IS1 Init err");
+ return HDF_FAILURE;
+ }
+ ret = HdfSbufWriteString(reply, "E53 IS1 Init successful");
+ if (ret == 0) {
+ HDF_LOGE("reply failed");
+ return HDF_FAILURE;
+ }
+ break;
+ case E53_IS1_Stop:
+ ret = E53_IS1_DeInit();
+ if (ret != 0) {
+ HDF_LOGE("E53 IS1 Init err");
+ return HDF_FAILURE;
+ }
+ ret = HdfSbufWriteString(reply, "E53 IS1 DeInit successful");
+ if (ret == 0) {
+ HDF_LOGE("reply failed");
+ return HDF_FAILURE;
+ }
+ break;
+ /* 接收到用户态发来的LED_WRITE_READ命令 */
+ case E53_IS1_Read:
+ ret = E53_GPIORead(E53_SI1_IRQ_GPIO_PIN, &someoneAround);
+ if (ret != 0) {
+ HDF_LOGE("E53 IS1 Read GPIO failed");
+ return HDF_FAILURE;
+ }
+ if (someoneAround) {
+ E53_IS1BeepStatusSet(E53_IS1BeepON);
+ } else {
+ E53_IS1BeepStatusSet(E53_IS1BeepOFF);
+ }
+
+ char*replay_buf = OsalMemAlloc(100);
+ (void)memset_s(replay_buf, 100, 0, 100);
+
+ sprintf(replay_buf, "{\"humanAround\":%d}", someoneAround);
+ /* 把传感器数据写入reply, 可被带至用户程序 */
+ if (!HdfSbufWriteString(reply, replay_buf)) {
+ HDF_LOGE("replay is fail");
+ return HDF_FAILURE;
+ }
+ OsalMemFree(replay_buf);
+ break;
+ default:
+ return HDF_FAILURE;
+ }
+ return HDF_SUCCESS;
+}
+
+
+//驱动对外提供的服务能力,将相关的服务接口绑定到HDF框架
+static int32_t Hdf_E53_IS1_DriverBind(struct HdfDeviceObject *deviceObject)
+{
+ if (deviceObject == NULL) {
+ HDF_LOGE("e53 driver bind failed!");
+ return HDF_ERR_INVALID_OBJECT;
+ }
+ static struct IDeviceIoService e53Driver = {
+ .Dispatch = E53_IS1_DriverDispatch,
+ };
+ deviceObject->service = (struct IDeviceIoService *)(&e53Driver);
+
+ HDF_LOGD("E53 driver bind success");
+ return HDF_SUCCESS;
+}
+
+
+static int32_t Hdf_E53_IS1_DriverInit(struct HdfDeviceObject *device)
+{
+ return HDF_SUCCESS;
+}
+
+// 驱动资源释放的接口
+void Hdf_E53_IS1_DriverRelease(struct HdfDeviceObject *deviceObject)
+{
+ if (deviceObject == NULL) {
+ HDF_LOGE("Led driver release failed!");
+ return;
+ }
+ HDF_LOGD("Led driver release success");
+ return;
+}
+
+
+// 定义驱动入口的对象,必须为HdfDriverEntry(在hdf_device_desc.h中定义)类型的全局变量
+static struct HdfDriverEntry g_E53_IS1DriverEntry = {
+ .moduleVersion = 1,
+ .moduleName = "HDF_E53_IS1",
+ .Bind = Hdf_E53_IS1_DriverBind,
+ .Init = Hdf_E53_IS1_DriverInit,
+ .Release = Hdf_E53_IS1_DriverRelease,
+};
+
+// 调用HDF_INIT将驱动入口注册到HDF框架中
+HDF_INIT(g_E53_IS1DriverEntry);
+
diff --git a/device/st/drivers/e53_driver/E53_IS1/inc/E53_IS1.h b/device/st/drivers/e53_driver/E53_IS1/inc/E53_IS1.h
new file mode 100755
index 0000000000000000000000000000000000000000..cd21ad046b272617916c2662c1e789639d04d79d
--- /dev/null
+++ b/device/st/drivers/e53_driver/E53_IS1/inc/E53_IS1.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2022 Nanjing Xiaoxiongpai Intelligent Technology Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __E53_IS1_H__
+#define __E53_IS1_H__
+#include
+
+
+#define WIFI_IOT_IO_NAME_GPIO_7 7
+#define WIFI_IOT_IO_NAME_GPIO_8 8
+#define WIFI_IOT_PWM_PORT_PWM1 1
+#define WIFI_IOT_IO_FUNC_GPIO_8_PWM1_OUT 5
+#define WIFI_IOT_IO_FUNC_GPIO_7_GPIO 0
+#define PWM_DUTY 50
+#define PWM_FREQ 4000
+
+typedef void (*E53IS1CallbackFunc) (char *arg);
+
+struct E53_IS1Hooks
+{
+ int (*E53_IS1InitPeripheral)(void);
+ int (*E53_IS1DeInitPeripheral)(void);
+ int (*E53_IS1GpioIsrSet)(E53IS1CallbackFunc func);
+ int (*E53_E53_PWMSet)(uint32_t period,uint32_t duty);
+};
+
+typedef enum {
+ E53_IS1BeepOFF = 0,
+ E53_IS1BeepON,
+} E53IS1Status;
+
+int E53_IS1_Init(void);
+int E53_IS1_DeInit(void);
+int E53_IS1RegisterHooks(struct E53_IS1Hooks* hooks);
+int E53_IS1BeepStatusSet(E53IS1Status status);
+
+#endif
diff --git a/device/st/drivers/e53_driver/E53_IS1/src/E53_IS1.c b/device/st/drivers/e53_driver/E53_IS1/src/E53_IS1.c
new file mode 100755
index 0000000000000000000000000000000000000000..93306877aaea86223ae7d62c1c23418fc91a3712
--- /dev/null
+++ b/device/st/drivers/e53_driver/E53_IS1/src/E53_IS1.c
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2022 Nanjing Xiaoxiongpai Intelligent Technology Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include
+#include
+#include
+#include
+
+#include "hdf_log.h"
+#include "osal_io.h"
+#include "hdf_device_desc.h"
+#include "hdf_log.h"
+#include "device_resource_if.h"
+
+#include "E53_IS1.h"
+#include "E53_Common.h"
+
+#define E53_SI1_IRQ_GPIO_PIN E53_IO_5
+
+/***************************************************************
+ * 函数名称: E53IS1Init
+ * 说 明: 初始化E53_IS1
+ * 参 数: 无
+ * 返 回 值: 无
+ ***************************************************************/
+int E53_IS1_Init(void)
+{
+ int ret = -1;
+
+ ret = E53_GPIOInit(E53_SI1_IRQ_GPIO_PIN, E53_GPIO_In_Down);
+ if (ret != 0) {
+ HDF_LOGE("%s: gpio init failed", __func__);
+ return HDF_FAILURE;
+ }
+
+ E53_PWMOpen(3);
+ E53_PWMSetPeriod(4000);
+ E53_PWMSetDuty(1);
+ E53_PWMSetPolarity(0);
+ E53_PWMStart();
+
+ return 0;
+}
+/***************************************************************
+ * 函数名称: E53IS1Init
+ * 说 明: 初始化E53_IS1
+ * 参 数: 无
+ * 返 回 值: 无
+ ***************************************************************/
+int E53_IS1_DeInit(void)
+{
+ E53_PWMClose();
+ E53_ADCClose();
+
+ return 0;
+}
+
+/***************************************************************
+ * 函数名称: BeepStatusSet
+ * 说 明: 蜂鸣器报警与否
+ * 参 数: status,ENUM枚举的数据
+ * OFF,蜂鸣器
+ * ON,开蜂鸣器
+ * 返 回 值: 无
+ ***************************************************************/
+int E53_IS1BeepStatusSet(E53IS1Status status)
+{
+ if (status == E53_IS1BeepON) {
+
+ E53_PWMSet(PWM_FREQ,300);
+ }
+ if (status == E53_IS1BeepOFF) {
+ E53_PWMSet(PWM_FREQ,1);
+ }
+ return 0;
+}
diff --git a/device/st/drivers/e53_driver/E53_SC1/E53_SC1_hdf.c b/device/st/drivers/e53_driver/E53_SC1/E53_SC1_hdf.c
new file mode 100755
index 0000000000000000000000000000000000000000..3faf99bfa322920afa8e11ccc6c6094adf2f344a
--- /dev/null
+++ b/device/st/drivers/e53_driver/E53_SC1/E53_SC1_hdf.c
@@ -0,0 +1,175 @@
+/*
+ * Copyright (c) 2022 Nanjing Xiaoxiongpai Intelligent Technology Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include
+#include
+
+#include "E53_SC1.h"
+#include "E53_Common.h"
+
+#include "hdf_device_desc.h"
+#include "hdf_log.h"
+#include "device_resource_if.h"
+#include "osal_io.h"
+#include "osal_mem.h"
+#include "gpio_if.h"
+#include "osal_time.h"
+
+
+static uint8_t LightStatus;
+static float lux_data;
+
+typedef enum {
+ E53_SC1_Start = 0,
+ E53_SC1_Stop,
+ E53_SC1_Read,
+ E53_SC1_SetLight,
+}E53_SC1Ctrl;
+
+int32_t E53_SC1_DriverDispatch(struct HdfDeviceIoClient *client, int cmdCode, struct HdfSBuf *data, struct HdfSBuf *reply)
+{
+ int ret = -1;
+ char *replay_buf;
+
+ HDF_LOGE("E53 driver dispatch");
+ if (client == NULL || client->device == NULL) {
+ HDF_LOGE("E53 driver device is NULL");
+ return HDF_ERR_INVALID_OBJECT;
+ }
+ switch (cmdCode) {
+ case E53_SC1_Start:
+ ret = E53_SC1Init();
+ if (ret != 0) {
+ HDF_LOGE("E53 SC1 Init err");
+ return HDF_FAILURE;
+ }
+ ret = HdfSbufWriteString(reply, "E53 SC1 Init successful");
+ if (ret == 0) {
+ HDF_LOGE("reply failed");
+ return HDF_FAILURE;
+ }
+ break;
+ case E53_SC1_Stop:
+ ret = E53_SC1DeInit();
+ if (ret != 0) {
+ HDF_LOGE("E53 SC1 DeInit err");
+ return HDF_FAILURE;
+ }
+ ret = HdfSbufWriteString(reply, "E53 SC1 DeInit successful");
+ if (ret == 0) {
+ HDF_LOGE("reply failed");
+ return HDF_FAILURE;
+ }
+ break;
+ /* 接收到用户态发来的LED_WRITE_READ命令 */
+ case E53_SC1_Read:
+ ret = E53_SC1ReadData(&lux_data);
+ if (ret != 0) {
+ HDF_LOGE("E53 SC1 Read Data err");
+ return HDF_FAILURE;
+ }
+ replay_buf = OsalMemAlloc(100);
+ (void)memset_s(replay_buf, 100, 0, 100);
+ sprintf(replay_buf, "{\"Lux\":%.2f,\"LED\":\"%s\"}", lux_data, LightStatus ? "ON" : "OFF");
+ /* 把传感器数据写入reply, 可被带至用户程序 */
+ if (!HdfSbufWriteString(reply, replay_buf)) {
+ HDF_LOGE("replay is fail");
+ return HDF_FAILURE;
+ }
+ OsalMemFree(replay_buf);
+ break;
+ case E53_SC1_SetLight:
+ const char* readdata = HdfSbufReadString(data);
+ if (strcmp(readdata, "ON") == 0) {
+ E53_SC1LightStatusSet(ON);
+ LightStatus = 1;
+ } else if (strcmp(readdata, "OFF") == 0) {
+ E53_SC1LightStatusSet(OFF);
+ LightStatus = 0;
+ } else {
+ HDF_LOGE("Command wrong!");
+ return HDF_FAILURE;
+ }
+ replay_buf = OsalMemAlloc(100);
+ (void)memset_s(replay_buf, 100, 0, 100);
+ sprintf(replay_buf, "{\"Lux\":%.2f,\"LED\":\"%s\"}", lux_data, LightStatus ? "ON" : "OFF");
+ /* 把传感器数据写入reply, 可被带至用户程序 */
+ if (!HdfSbufWriteString(reply, replay_buf)) {
+ HDF_LOGE("replay is fail");
+ return HDF_FAILURE;
+ }
+ OsalMemFree(replay_buf);
+ break;
+
+ default:
+ return HDF_FAILURE;
+ }
+ return HDF_SUCCESS;
+}
+
+
+//驱动对外提供的服务能力,将相关的服务接口绑定到HDF框架
+static int32_t Hdf_E53_SC1_DriverBind(struct HdfDeviceObject *deviceObject)
+{
+ if (deviceObject == NULL) {
+ HDF_LOGE("e53 driver bind failed!");
+ return HDF_ERR_INVALID_OBJECT;
+ }
+ static struct IDeviceIoService e53Driver = {
+ .Dispatch = E53_SC1_DriverDispatch,
+ };
+ deviceObject->service = (struct IDeviceIoService *)(&e53Driver);
+ HDF_LOGD("E53 driver bind success");
+ return HDF_SUCCESS;
+}
+
+// static struct E53_SC1Hooks hooks = {
+// .E53_SC1Init = sc1Init,
+// .E53_SC1DeInit = sc1DeInit,
+// .E53_SC1LightGpioSet = sc1GpioSet,
+// .E53_SC1_IICWriteFunc = sc1E53_IICWrite,
+// .E53_SC1_IICReadFunc = sc1E53_IICRead,
+// .E53_SC1_IICWriteReadFunc = sc1E53_IICWriteRead,
+// };
+
+static int32_t Hdf_E53_SC1_DriverInit(struct HdfDeviceObject *device)
+{
+ return HDF_SUCCESS;
+}
+
+// 驱动资源释放的接口
+void Hdf_E53_SC1_DriverRelease(struct HdfDeviceObject *deviceObject)
+{
+ if (deviceObject == NULL) {
+ HDF_LOGE("Led driver release failed!");
+ return;
+ }
+ HDF_LOGD("Led driver release success");
+ return;
+}
+
+
+// 定义驱动入口的对象,必须为HdfDriverEntry(在hdf_device_desc.h中定义)类型的全局变量
+static struct HdfDriverEntry g_E53DriverEntry = {
+ .moduleVersion = 1,
+ .moduleName = "HDF_E53_SC1",
+ .Bind = Hdf_E53_SC1_DriverBind,
+ .Init = Hdf_E53_SC1_DriverInit,
+ .Release = Hdf_E53_SC1_DriverRelease,
+};
+
+// 调用HDF_INIT将驱动入口注册到HDF框架中
+HDF_INIT(g_E53DriverEntry);
+
diff --git a/device/st/drivers/e53_driver/E53_SC1/inc/E53_SC1.h b/device/st/drivers/e53_driver/E53_SC1/inc/E53_SC1.h
new file mode 100755
index 0000000000000000000000000000000000000000..f92e8d82d3a22a487589e48a371059ebc561a3e7
--- /dev/null
+++ b/device/st/drivers/e53_driver/E53_SC1/inc/E53_SC1.h
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2022 Nanjing Xiaoxiongpai Intelligent Technology Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __E53_SC1_H__
+#define __E53_SC1_H__
+
+#include
+
+#define BH1750_ADDR 0x23
+#define BH1750_SEND_DATA_LEN 2
+#define BH1750_RECV_DATA_LEN 2
+#define BH1750_READ_DELAY_US 180000
+#define BH1750_COEFFICIENT_LUX 1.2
+#define DATA_WIDTH_8_BIT 8 // 8 bit
+
+#define E53_SC1_LIGHT_GPIO 7
+#define E53_SC1_I2C1_SDA_GPIO 0
+#define E53_SC1_I2C1_SCL_GPIO 1
+#define WIFI_IOT_IO_FUNC_GPIO_0_I2C1_SDA 6
+#define WIFI_IOT_IO_FUNC_GPIO_1_I2C1_SCL 6
+#define WIFI_IOT_IO_FUNC_GPIO_7_GPIO 0
+
+#define WIFI_IOT_I2C_IDX_1 1
+#define WIFI_IOT_I2C_BAUDRATE 400000
+
+typedef enum {
+ OFF = 0,
+ ON
+} E53SC1Status;
+
+int E53_SC1Init(void);
+int E53_SC1DeInit(void);
+int E53_SC1ReadData(float *data);
+void E53_SC1LightStatusSet(E53SC1Status status);
+
+
+#endif /* __E53_SC1_H__ */
+
diff --git a/device/st/drivers/e53_driver/E53_SC1/src/E53_SC1.c b/device/st/drivers/e53_driver/E53_SC1/src/E53_SC1.c
new file mode 100755
index 0000000000000000000000000000000000000000..14022f7a2a355fea2f35ab6d370d9a53462cd5a6
--- /dev/null
+++ b/device/st/drivers/e53_driver/E53_SC1/src/E53_SC1.c
@@ -0,0 +1,136 @@
+/*
+ * Copyright (c) 2022 Nanjing Xiaoxiongpai Intelligent Technology Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include
+#include
+#include
+#include
+
+#include "E53_SC1.h"
+#include "E53_Common.h"
+#include "osal_time.h"
+
+#define E53_SC1_Light_GPIO E53_IO_5
+
+/***************************************************************
+ * 函数名称: Init_BH1750
+ * 说 明: 写命令初始化BH1750
+ * 参 数: 无
+ * 返 回 值: 0 成功; -1 失败
+ ***************************************************************/
+static int InitBH1750(void)
+{
+ int ret;
+ uint8_t send_data[1] = { 0x01 };
+ ret = E53_IICWrite((BH1750_ADDR << 1), send_data, 1);
+ if (ret != 0) {
+ return -1;
+ }
+ return 0;
+}
+
+/***************************************************************
+ * 函数名称: Start_BH1750
+ * 说 明: 启动BH1750
+ * 参 数: 无
+ * 返 回 值: 0 成功; -1 失败
+ ***************************************************************/
+static int StartBH1750(void)
+{
+ int ret;
+ uint8_t send_data[1] = { 0x20 };
+ ret = E53_IICWrite((BH1750_ADDR << 1), send_data, 1);
+ if (ret != 0) {
+ return -1;
+ }
+ return 0;
+}
+/***************************************************************
+ * 函数名称: E53SC1Init
+ * 说 明: 初始化E53_SC1
+ * 参 数: 无
+ * 返 回 值: 0 成功; -1 失败
+ ***************************************************************/
+int E53_SC1Init(void)
+{
+ int ret;
+
+ E53_GPIOInit(E53_SC1_Light_GPIO, E53_GPIO_Out_PullNone);
+ E53_IICOpen();
+
+ ret = InitBH1750();
+ if (ret != 0) {
+ return -1;
+ }
+ return 0;
+}
+/***************************************************************
+ * 函数名称: E53SC1DeInit
+ * 说 明: 初始化E53_SC1
+ * 参 数: 无
+ * 返 回 值: 0 成功; -1 失败
+ ***************************************************************/
+int E53_SC1DeInit(void)
+{
+ int ret;
+ E53_GPIODeinit(E53_SC1_Light_GPIO);
+ E53_IICClose();
+
+ ret = InitBH1750();
+ if (ret != 0) {
+ return -1;
+ }
+ return 0;
+}
+/***************************************************************
+ * 函数名称: E53_SC1_Read_Data
+ * 说 明: 测量光照强度
+ * 参 数: data,光照强度数据指针
+ * 返 回 值: 0 成功; -1 失败
+ ***************************************************************/
+int E53_SC1ReadData(float *data)
+{
+ int ret;
+ ret = StartBH1750(); // 启动传感器采集数据
+ if (ret != 0) {
+ return -1;
+ }
+ uint8_t recv_data[BH1750_RECV_DATA_LEN] = { 0 };
+ ret = E53_IICRead((BH1750_ADDR << 1), recv_data, sizeof(recv_data)); // 读取传感器数据
+
+ if (ret != 0) {
+ return -1;
+ }
+ *data = (float)(((recv_data[0] << DATA_WIDTH_8_BIT) + recv_data[1]) / BH1750_COEFFICIENT_LUX); // 合成数据,即光照数据
+ return 0;
+}
+/***************************************************************
+ * 函数名称: LightStatusSet
+ * 说 明: 灯状态设置
+ * 参 数: status,ENUM枚举的数据
+ * OFF,光灯
+ * ON,开灯
+ * 返 回 值: 无
+ ***************************************************************/
+void E53_SC1LightStatusSet(E53SC1Status status)
+{
+ if (status == ON) {
+ E53_GPIOWrite(E53_SC1_Light_GPIO,1); // 设置GPIO输出高电平点亮LED灯
+ }
+
+ if (status == OFF) {
+ E53_GPIOWrite(E53_SC1_Light_GPIO,0); // 设置GPIO输出低电平点亮LED灯
+ }
+}
diff --git a/device/st/drivers/e53_driver/E53_SC2/E53_SC2_hdf.c b/device/st/drivers/e53_driver/E53_SC2/E53_SC2_hdf.c
new file mode 100755
index 0000000000000000000000000000000000000000..066c2bce322f2571d1ebcadd33526fb35f768c16
--- /dev/null
+++ b/device/st/drivers/e53_driver/E53_SC2/E53_SC2_hdf.c
@@ -0,0 +1,158 @@
+#include
+#include
+
+#include "E53_SC2.h"
+#include "E53_Common.h"
+
+#include "hdf_device_desc.h"
+#include "hdf_log.h"
+#include "device_resource_if.h"
+#include "osal_io.h"
+#include "osal_mem.h"
+#include "gpio_if.h"
+#include "osal_time.h"
+
+
+static E53_SC2Data sc2Data;
+static uint8_t Status;
+static int X = 0, Y = 0, Z = 0;
+
+typedef enum {
+ E53_SC2_Start = 0,
+ E53_SC2_Stop,
+ E53_SC2_Read,
+}E53_SC2Ctrl;
+
+int32_t E53_SC2_DriverDispatch(struct HdfDeviceIoClient *client, int cmdCode, struct HdfSBuf *data, struct HdfSBuf *reply)
+{
+ int ret = -1;
+ char *replay_buf;
+
+ HDF_LOGE("E53 driver dispatch");
+ if (client == NULL || client->device == NULL)
+ {
+ HDF_LOGE("E53 driver device is NULL");
+ return HDF_ERR_INVALID_OBJECT;
+ }
+ switch (cmdCode)
+ {
+ case E53_SC2_Start:
+ ret = E53_SC2Init();
+ if(ret != 0){
+ HDF_LOGE("E53 SC2 Init err");
+ return HDF_FAILURE;
+ }
+ ret = HdfSbufWriteString(reply, "E53 SC2 Init successful");
+ if(ret ==0){
+ HDF_LOGE("reply failed");
+ return HDF_FAILURE;
+ }
+ break;
+ case E53_SC2_Stop:
+ ret = E53_SC2Init();
+ if(ret != 0){
+ HDF_LOGE("E53 SC2 DeInit err");
+ return HDF_FAILURE;
+ }
+ ret = HdfSbufWriteString(reply, "E53 SC2 Init successful");
+ if(ret ==0){
+ HDF_LOGE("reply failed");
+ return HDF_FAILURE;
+ }
+ break;
+ /* 接收到用户态发来的LED_WRITE_READ命令 */
+ case E53_SC2_Read:
+ ret = E53_SC2ReadData(&sc2Data);
+ if(ret != 0){
+ HDF_LOGE("E53 SC2 Read Data err");
+ return HDF_FAILURE;
+ }
+ HDF_LOGE("\r\n**************Temperature is %d\r\n", (int)sc2Data.Temperature);
+ HDF_LOGE("\r\n**************Accel[0] is %d\r\n", (int)sc2Data.Accel[0]);
+ HDF_LOGE("\r\n**************Accel[1] is %d\r\n", (int)sc2Data.Accel[1]);
+ HDF_LOGE("\r\n**************Accel[2] is %d\r\n", (int)sc2Data.Accel[2]);
+ if (X == 0 && Y == 0 && Z == 0) {
+ X = (int)sc2Data.Accel[0];
+ Y = (int)sc2Data.Accel[1];
+ Z = (int)sc2Data.Accel[2];
+ } else {
+ if (X + 100 < sc2Data.Accel[0] || X - 100 > sc2Data.Accel[0] || Y + 100 < sc2Data.Accel[1] ||
+ Y - 100 > sc2Data.Accel[1] || Z + 100 < sc2Data.Accel[2] || Z - 100 > sc2Data.Accel[2]) {
+ E53_SC2LedD1StatusSet(0);
+ E53_SC2LedD2StatusSet(1);
+ Status = 1;
+
+ } else {
+ E53_SC2LedD1StatusSet(1);
+ E53_SC2LedD2StatusSet(0);
+ Status = 0;
+ }
+ }
+
+ replay_buf = OsalMemAlloc(100);
+ (void)memset_s(replay_buf, 100, 0, 100);
+ sprintf(replay_buf,"{\"Temp\":%d,\"Status\":%d}",\
+ sc2Data.Temperature,\
+ Status);
+ /* 把传感器数据写入reply, 可被带至用户程序 */
+ if (!HdfSbufWriteString(reply, replay_buf))
+ {
+ HDF_LOGE("replay is fail");
+ return HDF_FAILURE;
+ }
+ OsalMemFree(replay_buf);
+ break;
+ default:
+ return HDF_FAILURE;
+ }
+ return HDF_SUCCESS;
+}
+
+
+//驱动对外提供的服务能力,将相关的服务接口绑定到HDF框架
+static int32_t Hdf_E53_SC2_DriverBind(struct HdfDeviceObject *deviceObject)
+{
+ if (deviceObject == NULL)
+ {
+ HDF_LOGE("e53 driver bind failed!");
+ return HDF_ERR_INVALID_OBJECT;
+ }
+ static struct IDeviceIoService e53Driver = {
+ .Dispatch = E53_SC2_DriverDispatch,
+ };
+ deviceObject->service = (struct IDeviceIoService *)(&e53Driver);
+ HDF_LOGD("E53 driver bind success");
+ return HDF_SUCCESS;
+}
+
+
+static int32_t Hdf_E53_SC2_DriverInit(struct HdfDeviceObject *device)
+{
+ return HDF_SUCCESS;
+}
+
+// 驱动资源释放的接口
+void Hdf_E53_SC2_DriverRelease(struct HdfDeviceObject *deviceObject)
+{
+ if (deviceObject == NULL)
+ {
+ HDF_LOGE("Led driver release failed!");
+ return;
+ }
+ HDF_LOGD("Led driver release success");
+ return;
+}
+
+
+// 定义驱动入口的对象,必须为HdfDriverEntry(在hdf_device_desc.h中定义)类型的全局变量
+static struct HdfDriverEntry g_E53_SC2DriverEntry = {
+ .moduleVersion = 1,
+ .moduleName = "HDF_E53_SC2",
+ .Bind = Hdf_E53_SC2_DriverBind,
+ .Init = Hdf_E53_SC2_DriverInit,
+ .Release = Hdf_E53_SC2_DriverRelease,
+};
+
+// 调用HDF_INIT将驱动入口注册到HDF框架中
+HDF_INIT(g_E53_SC2DriverEntry);
+
diff --git a/device/st/drivers/e53_driver/E53_SC2/inc/E53_SC2.h b/device/st/drivers/e53_driver/E53_SC2/inc/E53_SC2.h
new file mode 100755
index 0000000000000000000000000000000000000000..20f2ad4b45c0bc8fa999703deafca3f42fa3e5e6
--- /dev/null
+++ b/device/st/drivers/e53_driver/E53_SC2/inc/E53_SC2.h
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2022 Nanjing Xiaoxiongpai Intelligent Technology Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __E53_SC2_H__
+#define __E53_SC2_H__
+
+#include
+/* 宏定义 --------------------------------------------------------------------*/
+#define MPU6050_GYRO_OUT 0x43 // MPU6050陀螺仪数据寄存器地址
+#define MPU6050_ACC_OUT 0x3B // MPU6050加速度数据寄存器地址
+#define MPU6050_ADDRESS 0x68 // MPU6050器件读地址
+#define MPU6050_ADDRESS_AD0_LOW 0x68 // address pin low (GND), default for InvenSense evaluation board
+#define MPU6050_RA_CONFIG 0x1A
+#define MPU6050_RA_ACCEL_CONFIG 0x1C
+#define MPU6050_RA_FF_THR 0x1D
+#define MPU6050_RA_FF_DUR 0x1E
+#define MPU6050_RA_MOT_THR 0x1F // 运动检测阀值设置寄存器
+#define MPU6050_RA_MOT_DUR 0x20 // 运动检测时间阀值
+#define MPU6050_RA_ZRMOT_THR 0x21
+#define MPU6050_RA_ZRMOT_DUR 0x22
+#define MPU6050_RA_FIFO_EN 0x23
+#define MPU6050_RA_INT_PIN_CFG 0x37 // 中断/旁路设置寄存器
+#define MPU6050_RA_INT_ENABLE 0x38 // 中断使能寄存器
+#define MPU6050_RA_TEMP_OUT_H 0x41
+#define MPU6050_RA_USER_CTRL 0x6A
+#define MPU6050_RA_PWR_MGMT_1 0x6B
+#define MPU6050_RA_WHO_AM_I 0x75
+#define MPU6050_DATA_2_BYTE 2
+#define MPU6050_DATA_256_BYTE 256
+#define MPU6050_DATA_DELAY 100
+
+#define SENSOR_DATA_WIDTH_8_BIT 8 // 8 bit
+#define ACCEL_DATA_LEN 6
+#define TEMP_DATA_LEN 2
+
+#define MPU6050_CONSTANT_1 13200
+#define MPU6050_CONSTANT_2 280
+#define MPU6050_CONSTANT_3 13
+
+#define WIFI_IOT_IO_FUNC_GPIO_0_I2C1_SDA 6
+#define WIFI_IOT_IO_FUNC_GPIO_1_I2C1_SCL 6
+#define WIFI_IOT_IO_FUNC_GPIO_8_GPIO 0
+#define WIFI_IOT_IO_FUNC_GPIO_7_GPIO 0
+#define WIFI_IOT_I2C_IDX_1 1
+#define WIFI_IOT_I2C_BAUDRATE 400000
+
+#define WIFI_IOT_IO_NAME_GPIO_7 7
+#define WIFI_IOT_IO_NAME_GPIO_8 8
+#define WIFI_IOT_IO_NAME_GPIO_0 0
+#define WIFI_IOT_IO_NAME_GPIO_1 1
+#define RESET_DELAY_US 20000
+#define READ_DATA_DELAY_US 50000
+
+typedef enum {
+ OFF = 0,
+ ON
+} E53_SC2Status;
+
+enum AccelAxisNum {
+ ACCEL_X_AXIS = 0,
+ ACCEL_Y_AXIS = 1,
+ ACCEL_Z_AXIS = 2,
+ ACCEL_AXIS_NUM = 3,
+};
+enum AccelAxisPart {
+ ACCEL_X_AXIS_LSB = 0,
+ ACCEL_X_AXIS_MSB = 1,
+ ACCEL_Y_AXIS_LSB = 2,
+ ACCEL_Y_AXIS_MSB = 3,
+ ACCEL_Z_AXIS_LSB = 4,
+ ACCEL_Z_AXIS_MSB = 5,
+ ACCEL_AXIS_BUTT,
+};
+enum TempPart {
+ TEMP_LSB = 0,
+ TEMP_MSB = 1,
+};
+/* E53_SC2传感器数据类型定义 ------------------------------------------------------------*/
+typedef struct {
+ short Temperature;
+ short Accel[3];
+} E53_SC2Data;
+
+typedef enum{
+ E53_SC2LedD1 = 0,
+ E53_SC2LedD2,
+}E53_SC2LedGpio;
+
+
+int E53_SC2Init(void);
+int E53_SC2DeInit(void);
+int E53_SC2ReadData(E53_SC2Data *ReadData);
+void E53_SC2LedD1StatusSet(E53_SC2Status status);
+void E53_SC2LedD2StatusSet(E53_SC2Status status);
+
+#endif
diff --git a/device/st/drivers/e53_driver/E53_SC2/src/E53_SC2.c b/device/st/drivers/e53_driver/E53_SC2/src/E53_SC2.c
new file mode 100755
index 0000000000000000000000000000000000000000..99b6e153f1bf7f5c4f00ac90047d79ff122ed5f0
--- /dev/null
+++ b/device/st/drivers/e53_driver/E53_SC2/src/E53_SC2.c
@@ -0,0 +1,313 @@
+/*
+ * Copyright (c) 2022 Nanjing Xiaoxiongpai Intelligent Technology Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include
+#include
+#include
+#include
+
+#include "E53_SC2.h"
+#include "E53_Common.h"
+#include "osal_time.h"
+
+#define E53_SC2_Light1_GPIO E53_IO_5
+#define E53_SC2_Light2_GPIO E53_IO_6
+
+/***************************************************************
+ * 函数功能: 通过I2C写入一个值到指定寄存器内
+ * 输入参数: Addr:I2C设备地址
+ * Reg:目标寄存器
+ * Value:值
+ * 返 回 值: 无
+ * 说 明: 无
+ **************************************************************/
+static int MPU6050WriteData(uint8_t Reg, uint8_t Value)
+{
+ uint32_t ret;
+ uint8_t send_data[MPU6050_DATA_2_BYTE] = { Reg, Value };
+
+ ret = E53_IICWrite((MPU6050_ADDRESS << 1), send_data, sizeof(send_data));
+ if (ret != 0) {
+ dprintf("[%s][%d]\r\n",__func__,__LINE__);
+ return -1;
+ }
+ return 0;
+}
+
+/***************************************************************
+ * 函数功能: 通过I2C读取一段寄存器内容存放到指定的缓冲区内
+ * 输入参数: Addr:I2C设备地址
+ * Reg:目标寄存器
+ * RegSize:寄存器尺寸(8位或者16位)
+ * pBuffer:缓冲区指针
+ * Length:缓冲区长度
+ * 返 回 值: HAL_StatusTypeDef:操作结果
+ * 说 明: 无
+ **************************************************************/
+static int MPU6050ReadBuffer(uint8_t Reg, uint8_t *pBuffer, uint16_t Length)
+{
+ uint32_t ret = 0;
+
+ uint8_t buffer[1] = { Reg };
+ ret = E53_IICWrite((MPU6050_ADDRESS << 1),buffer,1);
+ if(ret != 0){
+ dprintf("[%s][%d]\r\n",__func__,__LINE__);
+ return -1;
+ }
+ ret = E53_IICRead((MPU6050_ADDRESS << 1),pBuffer,Length);
+ for(int i = 0;i < Length;i++)
+ {
+ dprintf("read:%d\n",pBuffer[i]);
+ }
+ dprintf("debug!\n");
+ if(ret != 0){
+ dprintf("[%s][%d]\r\n",__func__,__LINE__);
+ return -1;
+ }
+ return 0;
+}
+/***************************************************************
+ * 函数功能: 写数据到MPU6050寄存器
+ * 输入参数: 无
+ * 返 回 值: 无
+ * 说 明: 无
+ ***************************************************************/
+static void MPU6050WriteReg(uint8_t reg_add, uint8_t reg_dat)
+{
+ MPU6050WriteData(reg_add, reg_dat);
+}
+
+/***************************************************************
+ * 函数功能: 从MPU6050寄存器读取数据
+ * 输入参数: 无
+ * 返 回 值: 无
+ * 说 明: 无
+ ***************************************************************/
+static int MPU6050ReadData(uint8_t reg_add, unsigned char *read, uint8_t num)
+{
+ return MPU6050ReadBuffer(reg_add, read, num);
+}
+
+/***************************************************************
+ * 函数功能: 读取MPU6050的加速度数据
+ * 输入参数: 无
+ * 返 回 值: 无
+ * 说 明: 无
+ ***************************************************************/
+static int MPU6050ReadAcc(short *accData)
+{
+ int ret;
+ uint8_t buf[ACCEL_DATA_LEN];
+ ret = MPU6050ReadData(MPU6050_ACC_OUT, buf, ACCEL_DATA_LEN);
+ if (ret != 0) {
+ return -1;
+ }
+ accData[ACCEL_X_AXIS] = (buf[ACCEL_X_AXIS_LSB] << SENSOR_DATA_WIDTH_8_BIT) | buf[ACCEL_X_AXIS_MSB];
+ accData[ACCEL_Y_AXIS] = (buf[ACCEL_Y_AXIS_LSB] << SENSOR_DATA_WIDTH_8_BIT) | buf[ACCEL_Y_AXIS_MSB];
+ accData[ACCEL_Z_AXIS] = (buf[ACCEL_Z_AXIS_LSB] << SENSOR_DATA_WIDTH_8_BIT) | buf[ACCEL_Z_AXIS_MSB];
+ return 0;
+}
+
+
+/***************************************************************
+ * 函数功能: 读取MPU6050的温度数据,转化成摄氏度
+ * 输入参数: 无
+ * 返 回 值: 无
+ * 说 明: 无
+ **************************************************************/
+static int MPU6050ReturnTemp(short *Temperature)
+{
+ int ret;
+ short temp3;
+ uint8_t buf[TEMP_DATA_LEN];
+
+ ret = MPU6050ReadData(MPU6050_RA_TEMP_OUT_H, buf, TEMP_DATA_LEN); // 读取温度值
+ if (ret != 0) {
+ return -1;
+ }
+ temp3 = (buf[TEMP_LSB] << SENSOR_DATA_WIDTH_8_BIT) | buf[TEMP_MSB];
+ *Temperature = (((double)(temp3 + MPU6050_CONSTANT_1)) / MPU6050_CONSTANT_2) - MPU6050_CONSTANT_3;
+ return 0;
+}
+
+/***************************************************************
+ * 函数功能: 自由落体中断
+ * 输入参数: 无
+ * 返 回 值: 无
+ * 说 明: 无
+ **************************************************************/
+void FreeFallInterrupt(void) // 自由落体中断
+{
+ MPU6050WriteReg(MPU6050_RA_FF_THR, 0x01); // 自由落体阈值
+ MPU6050WriteReg(MPU6050_RA_FF_DUR, 0x01); // 自由落体检测时间20ms 单位1ms 寄存器0X20
+}
+void MotionInterrupt(void) // 运动中断
+{
+ MPU6050WriteReg(MPU6050_RA_MOT_THR, 0x03); // 运动阈值
+ MPU6050WriteReg(MPU6050_RA_MOT_DUR, 0x14); // 检测时间20ms 单位1ms 寄存器0X20
+}
+void ZeroMotionInterrupt(void) // 静止中断
+{
+ MPU6050WriteReg(MPU6050_RA_ZRMOT_THR, 0x20); // 静止阈值
+ MPU6050WriteReg(MPU6050_RA_ZRMOT_DUR, 0x20); // 静止检测时间20ms 单位1ms 寄存器0X20
+}
+
+/***************************************************************
+ * 函数功能: 初始化MPU6050芯片
+ * 输入参数: 无
+ * 返 回 值: 无
+ * 说 明: 无
+ ***************************************************************/
+void MPU6050Init(void)
+{
+ MPU6050WriteReg(MPU6050_RA_PWR_MGMT_1, 0X80); // 复位MPU6050
+
+ OsalMDelay(20);
+ MPU6050WriteReg(MPU6050_RA_PWR_MGMT_1, 0X00); // 唤醒MPU6050
+ MPU6050WriteReg(MPU6050_RA_INT_ENABLE, 0X00); // 关闭所有中断
+ MPU6050WriteReg(MPU6050_RA_USER_CTRL, 0X00); // I2C主模式关闭
+ MPU6050WriteReg(MPU6050_RA_FIFO_EN, 0X00); // 关闭FIFO
+ MPU6050WriteReg(MPU6050_RA_INT_PIN_CFG,
+ 0X80); // 中断的逻辑电平模式,设置为0,中断信号为高电;设置为1,中断信号为低电平时。
+ MotionInterrupt(); // 运动中断
+ MPU6050WriteReg(MPU6050_RA_CONFIG, 0x04); // 配置外部引脚采样和DLPF数字低通滤波器
+ MPU6050WriteReg(MPU6050_RA_ACCEL_CONFIG, 0x1C); // 加速度传感器量程和高通滤波器配置
+ MPU6050WriteReg(MPU6050_RA_INT_PIN_CFG, 0X1C); // INT引脚低电平平时
+ MPU6050WriteReg(MPU6050_RA_INT_ENABLE, 0x40); // 中断使能寄存器
+}
+
+/***************************************************************
+ * 函数功能: 读取MPU6050的ID
+ * 输入参数: 无
+ * 返 回 值: 无
+ * 说 明: 无
+ ***************************************************************/
+int MPU6050ReadID(void)
+{
+ unsigned char Re = 0;
+ MPU6050ReadData(MPU6050_RA_WHO_AM_I, &Re, 1); // 读器件地址
+ if (Re != 0x68) {
+ dprintf("[%s][%d]:%d\r\n",__func__,__LINE__,Re);
+ return -1;
+ } else {
+ return 0;
+ }
+}
+/***************************************************************
+ * 函数名称: E53_SC2Init
+ * 说 明: 初始化E53_SC2
+ * 参 数: 无
+ * 返 回 值: 无
+ ***************************************************************/
+int E53_SC2Init(void)
+{
+ uint32_t ret = 0;
+ E53_GPIOInit(E53_SC2_Light1_GPIO,E53_GPIO_Out_PullNone);
+ E53_GPIOInit(E53_SC2_Light2_GPIO,E53_GPIO_Out_PullNone);
+ E53_IICOpen();
+
+ MPU6050Init();
+ ret = MPU6050ReadID();
+ if (ret != 0) {
+ return -1;
+ }
+
+ OsalMDelay(20);
+
+ return 0;
+}
+/***************************************************************
+ * 函数名称: E53_SC2DeInit
+ * 说 明: 初始化E53_SC2
+ * 参 数: 无
+ * 返 回 值: 无
+ ***************************************************************/
+int E53_SC2DeInit(void)
+{
+ E53_GPIODeinit(E53_SC2_Light1_GPIO);
+ E53_GPIODeinit(E53_SC2_Light2_GPIO);
+ E53_IICClose();
+
+ return 0;
+}
+/***************************************************************
+ * 函数名称: E53_SC2ReadData
+ * 说 明: 读取数据
+ * 参 数: 无
+ * 返 回 值: 无
+ ***************************************************************/
+int E53_SC2ReadData(E53_SC2Data *ReadData)
+{
+ int ret;
+ short Accel[ACCEL_AXIS_NUM];
+ short Temp;
+ if (MPU6050ReadID() != 0) {
+ return -1;
+ }
+ ret = MPU6050ReadAcc(Accel);
+ if (ret != 0) {
+ return -1;
+ }
+
+ ret = MPU6050ReturnTemp(&Temp);
+ if (ret != 0) {
+ return -1;
+ }
+ ReadData->Temperature = Temp;
+ ReadData->Accel[ACCEL_X_AXIS] = Accel[ACCEL_X_AXIS];
+ ReadData->Accel[ACCEL_Y_AXIS] = Accel[ACCEL_Y_AXIS];
+ ReadData->Accel[ACCEL_Z_AXIS] = Accel[ACCEL_Z_AXIS];
+ OsalMDelay(20);
+
+ return 0;
+}
+
+/***************************************************************
+ * 函数名称: LedD1StatusSet
+ * 说 明: LED_D1状态设置
+ * 参 数: status,ENUM枚举的数据
+ * OFF,关
+ * ON,开
+ * 返 回 值: 无
+ ***************************************************************/
+void E53_SC2LedD1StatusSet(E53_SC2Status status)
+{
+ if (status == ON) {
+ E53_GPIOWrite(E53_SC2_Light1_GPIO,1); // 设置GPIO输出高电平点亮LED灯
+ }
+
+ if (status == OFF) {
+ E53_GPIOWrite(E53_SC2_Light1_GPIO,0); // 设置GPIO输出低电平点亮LED灯
+ }
+}
+
+/***************************************************************
+ * 函数名称: LedD2StatusSet
+ * 说 明: LED_D2状态设置
+ * 参 数: status,ENUM枚举的数据
+ * OFF,关
+ * ON,开
+ * 返 回 值: 无
+ ***************************************************************/
+void E53_SC2LedD2StatusSet(E53_SC2Status status)
+{
+ if (status == ON) {
+ E53_GPIOWrite(E53_SC2_Light2_GPIO,1); // 设置GPIO输出高电平点亮LED灯
+ }
+
+ if (status == OFF) {
+ E53_GPIOWrite(E53_SC2_Light2_GPIO,0); // 设置GPIO输出低电平点亮LED灯
+ }
+}
diff --git a/device/st/drivers/e53_driver/E53_SF1/E53_SF1_hdf.c b/device/st/drivers/e53_driver/E53_SF1/E53_SF1_hdf.c
new file mode 100755
index 0000000000000000000000000000000000000000..41faf91d8339d762de33c0d0b9d3106f47a5c82b
--- /dev/null
+++ b/device/st/drivers/e53_driver/E53_SF1/E53_SF1_hdf.c
@@ -0,0 +1,177 @@
+/*
+ * Copyright (c) 2022 Nanjing Xiaoxiongpai Intelligent Technology Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include
+#include
+
+#include "E53_SF1.h"
+#include "E53_Common.h"
+
+#include "hdf_device_desc.h"
+#include "hdf_log.h"
+#include "device_resource_if.h"
+#include "osal_io.h"
+#include "osal_mem.h"
+#include "gpio_if.h"
+#include "osal_time.h"
+
+
+static uint8_t BeepStatus;
+static float ppm;
+
+typedef enum {
+ E53_SF1_Start = 0,
+ E53_SF1_Stop,
+ E53_SF1_Read,
+ E53_SF1_SetBeep,
+}E53_SF1Ctrl;
+
+
+int32_t E53DriverDispatch(struct HdfDeviceIoClient *client, int cmdCode, struct HdfSBuf *data, struct HdfSBuf *reply)
+{
+ int ret;
+ char *replay_buf;
+ HDF_LOGE("E53 driver dispatch");
+ if (client == NULL || client->device == NULL) {
+ HDF_LOGE("E53 driver device is NULL");
+ return HDF_ERR_INVALID_OBJECT;
+ }
+ switch (cmdCode) {
+ case E53_SF1_Start:
+
+ ret = E53_SF1_Init();
+ if (ret != 0) {
+ HDF_LOGE("E53 SF1 Init err");
+ return HDF_FAILURE;
+ }
+
+ ret = HdfSbufWriteString(reply, "E53 SF1 Init successful");
+ if (ret == 0) {
+ HDF_LOGE("replay is fail");
+ return HDF_FAILURE;
+ }
+ break;
+ case E53_SF1_Stop:
+
+ ret = E53_SF1_DeInit();
+ if (ret != 0) {
+ HDF_LOGE("E53 SF1 Init err");
+ return HDF_FAILURE;
+ }
+
+ ret = HdfSbufWriteString(reply, "E53 SF1 Init successful");
+ if (ret == 0) {
+ HDF_LOGE("replay is fail");
+ return HDF_FAILURE;
+ }
+ break;
+ /* 接收到用户态发来的LED_WRITE_READ命令 */
+ case E53_SF1_Read:
+
+ ret = GetMQ2PPM(&ppm);
+ if (ret != 0) {
+ HDF_LOGE("Get MQ2 ppm failed");
+ return HDF_FAILURE;
+ }
+ replay_buf = OsalMemAlloc(100);
+ (void)memset_s(replay_buf, 100, 0, 100);
+ sprintf(replay_buf, "{\"ppm\":%d,\"Beep\":\"%s\"}", (int)ppm, BeepStatus ? "ON" : "OFF");
+ ret = HdfSbufWriteString(reply, replay_buf);
+ if (ret != true) {
+ HDF_LOGE("replay is fail");
+ return HDF_FAILURE;
+ }
+ break;
+ case E53_SF1_SetBeep:
+ const char* read = HdfSbufReadString(data);
+ if (strcmp(read, "ON") == 0) {
+ BeepStatus = 1;
+ ret = BeepStatusSet(ON);
+ if (ret != 0) {
+ HDF_LOGE("Beep set status failed!");
+ return HDF_FAILURE;
+ }
+ } else if (strcmp(read, "OFF") == 0) {
+ BeepStatus = 0;
+ ret = BeepStatusSet(OFF);
+ if (ret != 0) {
+ HDF_LOGE("Beep set status failed!");
+ return HDF_FAILURE;
+ }
+ } else {
+ HDF_LOGE("Wrong command!");
+ return HDF_FAILURE;
+ }
+ replay_buf = OsalMemAlloc(100);
+ (void)memset_s(replay_buf, 100, 0, 100);
+ sprintf(replay_buf, "{\"ppm\":%.2f,\"Beep\":\"%s\"}", ppm, BeepStatus ? "ON" : "OFF");
+ ret = HdfSbufWriteString(reply, replay_buf);
+ if (ret != true) {
+ HDF_LOGE("replay is fail");
+ return HDF_FAILURE;
+ }
+ break;
+ default:
+ return HDF_FAILURE;
+ }
+ return HDF_SUCCESS;
+}
+
+
+//驱动对外提供的服务能力,将相关的服务接口绑定到HDF框架
+static int32_t Hdf_E53_SF1_DriverBind(struct HdfDeviceObject *deviceObject)
+{
+ if (deviceObject == NULL) {
+ HDF_LOGE("e53 driver bind failed!");
+ return HDF_ERR_INVALID_OBJECT;
+ }
+ static struct IDeviceIoService e53Driver = {
+ .Dispatch = E53DriverDispatch,
+ };
+ deviceObject->service = (struct IDeviceIoService *)(&e53Driver);
+ HDF_LOGD("E53 driver bind success");
+ return HDF_SUCCESS;
+}
+
+static int32_t Hdf_E53_SF1_DriverInit(struct HdfDeviceObject *device)
+{
+
+ return HDF_SUCCESS;
+}
+
+// 驱动资源释放的接口
+void Hdf_E53_SF1_DriverRelease(struct HdfDeviceObject *deviceObject)
+{
+ if (deviceObject == NULL) {
+ HDF_LOGE("Led driver release failed!");
+ return;
+ }
+ HDF_LOGD("Led driver release success");
+ return;
+}
+
+
+// 定义驱动入口的对象,必须为HdfDriverEntry(在hdf_device_desc.h中定义)类型的全局变量
+struct HdfDriverEntry g_E53_SF1DriverEntry = {
+ .moduleVersion = 1,
+ .moduleName = "HDF_E53_SF1",
+ .Bind = Hdf_E53_SF1_DriverBind,
+ .Init = Hdf_E53_SF1_DriverInit,
+ .Release = Hdf_E53_SF1_DriverRelease,
+};
+
+// 调用HDF_INIT将驱动入口注册到HDF框架中
+HDF_INIT(g_E53_SF1DriverEntry);
+
diff --git a/device/st/drivers/e53_driver/E53_SF1/inc/E53_SF1.h b/device/st/drivers/e53_driver/E53_SF1/inc/E53_SF1.h
new file mode 100755
index 0000000000000000000000000000000000000000..5ec8798809c45e86236d8fc9190d3fbe24b36fc6
--- /dev/null
+++ b/device/st/drivers/e53_driver/E53_SF1/inc/E53_SF1.h
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2022 Nanjing Xiaoxiongpai Intelligent Technology Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __E53_SF1_H__
+#define __E53_SF1_H__
+
+#include
+
+#define ADC_VREF_VOL 1.8
+#define ADC_COEFFICIENT 4
+#define ADC_RATIO 4096
+
+#define MQ2_CONSTANT_1 4
+#define MQ2_CONSTANT_2 613.9f
+#define MQ2_CONSTANT_3 (-2.074f)
+
+#define CAL_PPM 20 // 校准环境中PPM值
+#define RL 1 // RL阻值
+
+#define WIFI_IOT_IO_NAME_GPIO_8 8
+#define WIFI_IOT_PWM_PORT_PWM1 1
+#define WIFI_IOT_IO_FUNC_GPIO_8_PWM1_OUT 5
+#define PWM_DUTY 300
+#define PWM_FREQ 4000
+
+#define WIFI_IOT_ADC_6 6
+
+typedef enum {
+ OFF = 0,
+ ON
+} E53SF1Status;
+
+
+int E53_SF1_Init(void);
+int E53_SF1_DeInit(void);
+int MQ2PPMCalibration(void);
+int GetMQ2PPM(float *ppm);
+int BeepStatusSet(E53SF1Status status);
+
+#endif /* __E53_SF1_H__ */
+
diff --git a/device/st/drivers/e53_driver/E53_SF1/src/E53_SF1.c b/device/st/drivers/e53_driver/E53_SF1/src/E53_SF1.c
new file mode 100755
index 0000000000000000000000000000000000000000..52c5ea01f8b8579a0409870fe0cc0c579860bd59
--- /dev/null
+++ b/device/st/drivers/e53_driver/E53_SF1/src/E53_SF1.c
@@ -0,0 +1,129 @@
+/*
+ * Copyright (c) 2022 Nanjing Xiaoxiongpai Intelligent Technology Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include
+#include
+#include
+#include
+#include "hdf_log.h"
+
+
+#include "E53_SF1.h"
+#include "E53_Common.h"
+#include "osal_time.h"
+static float R0; // 元件在洁净空气中的阻值
+
+
+int E53_SF1GetVoltage(float* vol)
+{
+ uint32_t value;
+ E53_ADCRead(&value);
+ HDF_LOGE("E53 driver dispatch");
+ *vol = (float)(value * 3.3 / 255);
+ HDF_LOGE("E53_SF1 GetVoltage : %.2f V", *vol);
+ return 0;
+}
+
+/***************************************************************
+ * 函数名称: E53SF1Init
+ * 说 明: 初始化E53_SF1扩展板
+ * 参 数: 无
+ * 返 回 值: 无
+ ***************************************************************/
+int E53_SF1_Init()
+{
+ E53_PWMOpen(3);
+ E53_PWMSetPeriod(4000);
+ E53_PWMSetDuty(1);
+ E53_PWMSetPolarity(0);
+ E53_PWMStart();
+ E53_ADCOpen();
+
+ MQ2PPMCalibration();
+ OsalMDelay(1000);
+ return 0;
+}
+/***************************************************************
+ * 函数名称: E53SF1DeInit
+ * 说 明: 初始化E53_SF1扩展板
+ * 参 数: 无
+ * 返 回 值: 无
+ ***************************************************************/
+int E53_SF1_DeInit()
+{
+ E53_PWMClose();
+ E53_ADCClose();
+ return 0;
+}
+
+/***************************************************************
+ * 函数名称: GetMQ2PPM
+ * 说 明: 获取PPM函数
+ * 参 数: ppm 烟雾浓度
+ * 返 回 值: 0 成功; -1 失败
+ ***************************************************************/
+int GetMQ2PPM(float *ppm)
+{
+ unsigned int ret;
+ // unsigned short data;
+ float voltage, RS;
+ ret = E53_SF1GetVoltage(&voltage);
+ if(ret != 0){
+ return -1;
+ }
+ RS = (MQ2_CONSTANT_1 - voltage) / voltage * RL; // 计算RS
+ *ppm = MQ2_CONSTANT_2 * pow(RS / R0, MQ2_CONSTANT_3); // 计算ppm
+ return 0;
+}
+
+/***************************************************************
+ * 函数名称: MQ2PPMCalibration
+ * 说 明: 传感器校准函数
+ * 参 数: 无
+ * 返 回 值: 无
+ ***************************************************************/
+int MQ2PPMCalibration(void)
+{
+ int ret;
+ float voltage;
+ ret = E53_SF1GetVoltage(&voltage);
+ if(ret != 0){
+ return -1;
+ }
+ if (voltage != 0) {
+ float RS = (MQ2_CONSTANT_1 - voltage) / voltage * RL;
+ R0 = RS / pow(CAL_PPM / MQ2_CONSTANT_2, 1 / MQ2_CONSTANT_3);
+ }
+ return 0;
+}
+
+/***************************************************************
+ * 函数名称: BeepStatusSet
+ * 说 明: 蜂鸣器报警与否
+ * 参 数: status,ENUM枚举的数据
+ * OFF,蜂鸣器
+ * ON,开蜂鸣器
+ * 返 回 值: 无
+ ***************************************************************/
+int BeepStatusSet(E53SF1Status status)
+{
+ if (status == ON) {
+ E53_PWMSet(PWM_FREQ,PWM_DUTY);
+ }
+ if (status == OFF) {
+ E53_PWMSet(PWM_FREQ,1);
+ }
+ return 0;
+}
diff --git a/device/st/drivers/e53_ia1/BUILD.gn b/device/st/drivers/e53_ia1/BUILD.gn
deleted file mode 100755
index 5f34b146251582627f2440f707210cced77a1919..0000000000000000000000000000000000000000
--- a/device/st/drivers/e53_ia1/BUILD.gn
+++ /dev/null
@@ -1,7 +0,0 @@
-import("//drivers/adapter/khdf/liteos/hdf.gni")
-
-hdf_driver("hdf_e53_ia1") {
- sources = [
- "e53_ia1.c",
- ]
-}
\ No newline at end of file
diff --git a/device/st/drivers/e53_ia1/e53_ia1.c b/device/st/drivers/e53_ia1/e53_ia1.c
deleted file mode 100755
index a8d86d340092ec778bcb5a3bd78cd8660a1e2a11..0000000000000000000000000000000000000000
--- a/device/st/drivers/e53_ia1/e53_ia1.c
+++ /dev/null
@@ -1,370 +0,0 @@
-/*
- * Copyright (c) 2022 Nanjing Xiaoxiongpai Intelligent Technology CO., LIMITED.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "hdf_device_desc.h"
-#include "hdf_log.h"
-#include "device_resource_if.h"
-#include "osal_io.h"
-#include "osal_mem.h"
-#include "gpio_if.h"
-#include "osal_time.h"
-#include "e53_ia1.h"
-#include
-
-
-#define HDF_LOG_TAG e53_driver // 打印日志所包含的标签,如果不定义则用默认定义的HDF_TAG标签
-
-#define I2C_READ_MSG_NUM 2
-#define I2C_WRITE_MSG_NUM 1
-
-typedef enum {
- E53_IA1_Start = 0,
- E53_IA1_Read,
- E53_IA1_SetMotor,
- E53_IA1_SetLight,
-}E53_IA1Ctrl;
-
-struct Stm32Mp1e53 {
- uint32_t i2c_channel;
- uint32_t motor_gpio;
- uint32_t led_gpio;
-};
-
-static struct Stm32Mp1e53 g_Stm32Mp1e53;
-E53I2cClient *bearpi_sht30_clint = NULL;
-E53I2cClient *bearpi_bh175_clint = NULL;
-static E53Sensor bearpi_e53_sensor ;
-
-
-int32_t E53I2cWriteRead(const E53I2cClient *client, uint8_t *writeBuf, uint32_t writeLen, uint8_t *readBuf,
- uint32_t readLen)
-{
- struct I2cMsg msg[I2C_READ_MSG_NUM];
- (void)memset_s(msg, sizeof(msg), 0, sizeof(msg));
-
- msg[0].addr = client->i2cCfg.addr;
- msg[0].flags = 0;
- msg[0].len = writeLen;
- msg[0].buf = writeBuf;
-
- msg[1].addr = client->i2cCfg.addr;
- msg[1].flags = I2C_FLAG_READ;
- msg[1].len = readLen;
- msg[1].buf = readBuf;
-
- if (I2cTransfer(client->i2cHandle, msg,I2C_READ_MSG_NUM) != I2C_READ_MSG_NUM) {
- HDF_LOGE("%s: i2c read err", __func__);
- return HDF_FAILURE;
- }
- return HDF_SUCCESS;
-}
-
-int32_t E53I2cRead(const E53I2cClient *client, uint8_t *readBuf, uint32_t readLen)
-{
- struct I2cMsg msg={0};
- msg.addr = client->i2cCfg.addr;
- msg.flags = I2C_FLAG_READ;
- msg.len = readLen;
- msg.buf = readBuf;
-
- if (I2cTransfer(client->i2cHandle, &msg,1) != 1) {
- HDF_LOGE("%s: i2c read err", __func__);
- return HDF_FAILURE;
- }
- return HDF_SUCCESS;
-}
-
-int32_t E53I2cWrite(const E53I2cClient *client, uint8_t *writeBuf, uint32_t len)
-{
- struct I2cMsg msg[I2C_WRITE_MSG_NUM];
- (void)memset_s(msg, sizeof(msg), 0, sizeof(msg));
-
- msg[0].addr = client->i2cCfg.addr;
- msg[0].flags = 0;
- msg[0].len = len;
- msg[0].buf = writeBuf;
-
- if (I2cTransfer(client->i2cHandle, msg, I2C_WRITE_MSG_NUM) != I2C_WRITE_MSG_NUM) {
- HDF_LOGE("%s: i2c write err", __func__);
- return HDF_FAILURE;
- }
- return HDF_SUCCESS;
-}
-
-
-static E53I2cClient *E53DriverInstance(void)
-{
- E53I2cClient *touchDrv = (E53I2cClient *)OsalMemAlloc(sizeof(E53I2cClient));
- if (touchDrv == NULL) {
- HDF_LOGE("%s: instance touch driver failed", __func__);
- return NULL;
- }
- (void)memset_s(touchDrv, sizeof(E53I2cClient), 0, sizeof(E53I2cClient));
- return touchDrv;
-}
-
-int32_t E53_IA1_Init(struct Stm32Mp1e53 *e53)
-{
- int ret = 0;
-
- /* 将电机GPIO管脚配置为输出 */
- ret = GpioSetDir(e53->motor_gpio, GPIO_DIR_OUT);
- if (ret != 0)
- {
- HDF_LOGE("GpioSerDir: failed, ret %d\n", ret);
- return ret;
- }
- /* 将LED GPIO管脚配置为输出 */
- ret = GpioSetDir(e53->led_gpio, GPIO_DIR_OUT);
- if (ret != 0)
- {
- HDF_LOGE("GpioSerDir: failed, ret %d\n", ret);
- return ret;
- }
-
- bearpi_sht30_clint = E53DriverInstance();
- if(bearpi_sht30_clint == NULL){
- HDF_LOGI("bearpi_sht30_clint error!!!");
- }
-
- bearpi_bh175_clint = E53DriverInstance();
- if(bearpi_bh175_clint == NULL){
- HDF_LOGI("bearpi_bh175_clint error!!!");
- }
-
-
- bearpi_sht30_clint->i2cCfg.busNum = e53->i2c_channel;
- bearpi_sht30_clint->i2cCfg.addr = SHT30_ADDR_WRITE;
- bearpi_sht30_clint->i2cHandle = I2cOpen(bearpi_sht30_clint->i2cCfg.busNum);
- if(bearpi_sht30_clint->i2cHandle == NULL)
- {
- HDF_LOGI("bearpi_sht30_clint I2cOpen error!!!");
- return 0;
- }
- dprintf("\r\n bearpi_sht30_clint I2cOpen success!!! \r\n");
-
-
- bearpi_bh175_clint->i2cCfg.busNum = e53->i2c_channel;
- bearpi_bh175_clint->i2cCfg.addr = BH1750_ADDR_WRITE;
- bearpi_bh175_clint->i2cHandle = I2cOpen(bearpi_bh175_clint->i2cCfg.busNum);
- if(bearpi_bh175_clint->i2cHandle == NULL)
- {
- HDF_LOGI("bearpi_bh175_clint I2cOpen error!!!");
- return 0;
- }
- dprintf("\r\n bearpi_bh175_clint I2cOpen success!!! \r\n");
-
-
- return 1;
-}
-
-
-void GetE53IA1Data(E53Sensor* e53_sensor)
-{
- uint8_t rcv_buf[8] = {0};
- uint8_t send_buf[2] = {0};
-
- send_buf[0] = 0x20;
- E53I2cWrite(bearpi_bh175_clint, send_buf, 1);
- (void)memset_s(rcv_buf, sizeof(rcv_buf), 0, sizeof(rcv_buf));
- E53I2cRead(bearpi_bh175_clint, rcv_buf,2);
- HDF_LOGI("%x %x ---%d", rcv_buf[0], rcv_buf[1], (int)(((rcv_buf[0]<<8) |rcv_buf[1])/1.2));
- e53_sensor->light = ((rcv_buf[0]<<8) |rcv_buf[1])/1.2;
- HDF_LOGI("bearpi_bh175_clint e53_sensor.light = %.2f", e53_sensor->light);
-
- //初始化SHT30
- send_buf[0] = 0x2C;
- send_buf[1] = 0x0D;
-
- E53I2cWrite(bearpi_sht30_clint, send_buf, 2);
- (void)memset_s(rcv_buf, sizeof(rcv_buf), 0, sizeof(rcv_buf));
- E53I2cRead(bearpi_sht30_clint, rcv_buf,6);
- HDF_LOGI("%x %x %x %x %x %x", rcv_buf[0], rcv_buf[1], rcv_buf[2], rcv_buf[3], rcv_buf[4], rcv_buf[5]);
- e53_sensor->temperature = (float)((rcv_buf[0]<<8) | rcv_buf[1]) /65535 * 175 -45;
- e53_sensor->humidity = 100 * ((rcv_buf[3]<<8) | rcv_buf[4]) /65535;
- HDF_LOGI("bearpi_sht30_clint temperature: %.2f humidity: %.2f", e53_sensor->temperature, e53_sensor->humidity);
-
-}
-
-
-
-// Dispatch是用来处理用户态发下来的消息
-int32_t E53DriverDispatch(struct HdfDeviceIoClient *client, int cmdCode, struct HdfSBuf *data, struct HdfSBuf *reply)
-{
- // uint8_t contrl;
- int ret;
- HDF_LOGE("E53 driver dispatch");
- if (client == NULL || client->device == NULL)
- {
- HDF_LOGE("E53 driver device is NULL");
- return HDF_ERR_INVALID_OBJECT;
- }
-
- switch (cmdCode)
- {
- case E53_IA1_Read:
- GetE53IA1Data(&bearpi_e53_sensor);
- char*replay_buf = OsalMemAlloc(1000);
- (void)memset_s(replay_buf, 1000, 0, 1000);
- sprintf(replay_buf,"Lux:%d\n\
- Hum:%d\n\
- Tem:%d\n",\
- (int)bearpi_e53_sensor.light, \
- (int)bearpi_e53_sensor.humidity, \
- (int)bearpi_e53_sensor.temperature);
- /* 把传感器数据写入reply, 可被带至用户程序 */
- if (!HdfSbufWriteString(reply, replay_buf))
- {
- HDF_LOGE("replay is fail");
- return HDF_FAILURE;
- }
- OsalMemFree(replay_buf);
- break;
- case E53_IA1_SetMotor:
- const char* read = HdfSbufReadString(data);
- if(strcmp(read,"ON") == 0){
- GpioWrite(g_Stm32Mp1e53.motor_gpio, GPIO_VAL_HIGH);
- }else if(strcmp(read,"OFF") == 0){
- GpioWrite(g_Stm32Mp1e53.motor_gpio, GPIO_VAL_LOW);
- }else{
- HDF_LOGE("Command wrong!");
- return HDF_FAILURE;
- }
-
- ret = HdfSbufWriteString(reply, "E53 IA1 set motor successful");
- if(ret ==0)
- {
- HDF_LOGE("replay is fail");
- return HDF_FAILURE;
- }
- break;
- case E53_IA1_SetLight:
- const char* readdata = HdfSbufReadString(data);
- if(strcmp(readdata,"ON") == 0){
- GpioWrite(g_Stm32Mp1e53.led_gpio, GPIO_VAL_HIGH);
- }else if(strcmp(readdata,"OFF") == 0){
- GpioWrite(g_Stm32Mp1e53.led_gpio, GPIO_VAL_LOW);
- }else{
- HDF_LOGE("Command wrong!");
- return HDF_FAILURE;
- }
- ret = HdfSbufWriteString(reply, "E53_IA1 set light successful");
- if(ret ==0)
- {
- HDF_LOGE("replay is fail");
- return HDF_FAILURE;
- }
- break;
- default:
- break;
- }
- return HDF_SUCCESS;
-}
-
-// 读取驱动私有配置
-static int32_t HdfE53IA1ReadDrs(struct Stm32Mp1e53 *e53, const struct DeviceResourceNode *node)
-{
- int32_t ret;
- struct DeviceResourceIface *drsOps = NULL;
-
- drsOps = DeviceResourceGetIfaceInstance(HDF_CONFIG_SOURCE);
- if (drsOps == NULL || drsOps->GetUint32 == NULL) {
- HDF_LOGE("%s: invalid drs ops!", __func__);
- return HDF_FAILURE;
- }
- /* 读取led.hcs里面led_gpio_num的值 */
- ret = drsOps->GetUint32(node, "i2c_channel", &e53->i2c_channel, 0);
- if (ret != HDF_SUCCESS) {
- HDF_LOGE("%s: read e53 i2c_channel fail!", __func__);
- return ret;
- }
-
- ret = drsOps->GetUint32(node, "motor_gpio_num", &e53->motor_gpio, 0);
- if (ret != HDF_SUCCESS) {
- HDF_LOGE("%s: read e53 i2c_channel fail!", __func__);
- return ret;
- }
-
- ret = drsOps->GetUint32(node, "led_gpio_num", &e53->led_gpio, 0);
- if (ret != HDF_SUCCESS) {
- HDF_LOGE("%s: read e53 i2c_channel fail!", __func__);
- return ret;
- }
-
- return HDF_SUCCESS;
-}
-
-//驱动对外提供的服务能力,将相关的服务接口绑定到HDF框架
-int32_t HdfE53IA1DriverBind(struct HdfDeviceObject *deviceObject)
-{
- if (deviceObject == NULL)
- {
- HDF_LOGE("e53 driver bind failed!");
- return HDF_ERR_INVALID_OBJECT;
- }
- static struct IDeviceIoService e53Driver = {
- .Dispatch = E53DriverDispatch,
- };
- deviceObject->service = (struct IDeviceIoService *)(&e53Driver);
- HDF_LOGD("E53 driver bind success");
- return HDF_SUCCESS;
-}
-
-// 驱动自身业务初始的接口
-int32_t HdfE53IA1DriverInit(struct HdfDeviceObject *device)
-{
- struct Stm32Mp1e53 *e53 = &g_Stm32Mp1e53;
- int32_t ret;
-
- if (device == NULL || device->property == NULL) {
- HDF_LOGE("%s: device or property NULL!", __func__);
- return HDF_ERR_INVALID_OBJECT;
- }
- /* 读取hcs私有属性值 */
- ret = HdfE53IA1ReadDrs(e53, device->property);
- if (ret != HDF_SUCCESS) {
- HDF_LOGE("%s: get led device resource fail:%d", __func__, ret);
- return ret;
- }
-
- //初始化
- E53_IA1_Init(e53);
- dprintf("\r\n ********************e53 driver Init success *******************\r\n");
- return HDF_SUCCESS;
-}
-
-// 驱动资源释放的接口
-void HdfE53IA1DriverRelease(struct HdfDeviceObject *deviceObject)
-{
- if (deviceObject == NULL)
- {
- HDF_LOGE("Led driver release failed!");
- return;
- }
- HDF_LOGD("Led driver release success");
- return;
-}
-
-// 定义驱动入口的对象,必须为HdfDriverEntry(在hdf_device_desc.h中定义)类型的全局变量
-struct HdfDriverEntry g_E53DriverEntry = {
- .moduleVersion = 1,
- .moduleName = "HDF_E53_IA1",
- .Bind = HdfE53IA1DriverBind,
- .Init = HdfE53IA1DriverInit,
- .Release = HdfE53IA1DriverRelease,
-};
-
-// 调用HDF_INIT将驱动入口注册到HDF框架中
-HDF_INIT(g_E53DriverEntry);
diff --git a/device/st/drivers/e53_ia1/e53_ia1.h b/device/st/drivers/e53_ia1/e53_ia1.h
deleted file mode 100755
index 659e7c1d1c2e00736decf078c9f0ca914a4d1791..0000000000000000000000000000000000000000
--- a/device/st/drivers/e53_ia1/e53_ia1.h
+++ /dev/null
@@ -1,104 +0,0 @@
-
-/*
- * Copyright (c) 2022 Nanjing Xiaoxiongpai Intelligent Technology CO., LIMITED.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __E53_IA1_H__
-#define __E53_IA1_H__
-
-#include "hdf_types.h"
-#include "i2c_if.h"
-
-#define BH1750_ADDR_WRITE 0x46 //01000110
-#define BH1750_ADDR_READ 0x47 //01000111
-#define SHT30_ADDR_WRITE 0x44<<1 //10001000
-#define SHT30_ADDR_READ (0x44<<1)+1 //10001011
-
-#define CRC8_POLYNOMIAL 0x31
-
-typedef enum
-{
- POWER_OFF_CMD = 0x00, //断电:无激活状态
- POWER_ON_CMD = 0x01, //通电:等待测量指令
- RESET_REGISTER = 0x07, //重置数字寄存器(在断电状态下不起作用)
- CONT_H_MODE = 0x10, //连续H分辨率模式:在11x分辨率下开始测量,测量时间120ms
- CONT_H_MODE2 = 0x11, //连续H分辨率模式2:在0.51x分辨率下开始测量,测量时间120ms
- CONT_L_MODE = 0x13, //连续L分辨率模式:在411分辨率下开始测量,测量时间16ms
- ONCE_H_MODE = 0x20, //一次高分辨率模式:在11x分辨率下开始测量,测量时间120ms,测量后自动设置为断电模式
- ONCE_H_MODE2 = 0x21, //一次高分辨率模式2:在0.51x分辨率下开始测量,测量时间120ms,测量后自动设置为断电模式
- ONCE_L_MODE = 0x23 //一次低分辨率模式:在411x分辨率下开始测量,测量时间16ms,测量后自动设置为断电模式
-} BH1750_MODE;
-
-typedef enum
-{
- /* 软件复位命令 */
-
- SOFT_RESET_CMD = 0x30A2,
- /*
- 单次测量模式
- 命名格式:Repeatability_CS_CMD
- CS: Clock stretching
- */
- HIGH_ENABLED_CMD = 0x2C06,
- MEDIUM_ENABLED_CMD = 0x2C0D,
- LOW_ENABLED_CMD = 0x2C10,
- HIGH_DISABLED_CMD = 0x2400,
- MEDIUM_DISABLED_CMD = 0x240B,
- LOW_DISABLED_CMD = 0x2416,
-
- /*
- 周期测量模式
- 命名格式:Repeatability_MPS_CMD
- MPS:measurement per second
- */
- HIGH_0_5_CMD = 0x2032,
- MEDIUM_0_5_CMD = 0x2024,
- LOW_0_5_CMD = 0x202F,
- HIGH_1_CMD = 0x2130,
- MEDIUM_1_CMD = 0x2126,
- LOW_1_CMD = 0x212D,
- HIGH_2_CMD = 0x2236,
- MEDIUM_2_CMD = 0x2220,
- LOW_2_CMD = 0x222B,
- HIGH_4_CMD = 0x2334,
- MEDIUM_4_CMD = 0x2322,
- LOW_4_CMD = 0x2329,
- HIGH_10_CMD = 0x2737,
- MEDIUM_10_CMD = 0x2721,
- LOW_10_CMD = 0x272A,
- /* 周期测量模式读取数据命令 */
- READOUT_FOR_PERIODIC_MODE = 0xE000,
-} SHT30_CMD;
-
-
-typedef struct {
- uint16_t busNum;
- uint16_t addr;
-} I2cConfig;
-
-typedef struct {
- struct DevHandle *i2cHandle;
- I2cConfig i2cCfg;
-} E53I2cClient;
-
-
-typedef struct {
- double temperature;
- double humidity;
- double light;
- uint16_t led_status;
- uint16_t motor_status;
-} E53Sensor;
-
-#endif
\ No newline at end of file
diff --git a/foundation/ace/ace_engine_lite/ace_lite.gni b/foundation/ace/ace_engine_lite/ace_lite.gni
index 0fa93480c19445d70fd206bb9ccac1bbfb02ff26..98e0bc1ef25cec22c8d35d3e633ff49c2f6ffcd9 100755
--- a/foundation/ace/ace_engine_lite/ace_lite.gni
+++ b/foundation/ace/ace_engine_lite/ace_lite.gni
@@ -78,6 +78,12 @@ ace_lite_include_dirs += [
"//base/global/i18n_lite/interfaces/kits/i18n/include",
]
+ace_lite_include_dirs += [
+ "//drivers/framework/ability/sbuf/include",
+ "//drivers/framework/include/core",
+ "//drivers/framework/include/utils",
+ "//drivers/adapter/uhdf/posix/include",
+]
ace_lite_include_dirs_simulator = [
"$GRAPHIC_LITE_PATH/interfaces/kits/config",
"$GRAPHIC_LITE_PATH/interfaces/kits/ui/animator",
diff --git a/foundation/ace/ace_engine_lite/frameworks/BUILD.gn b/foundation/ace/ace_engine_lite/frameworks/BUILD.gn
index b2ddc55b2abfda35cf35f64fe10c3334ae331075..15c56f07b758667a9b1e5e7f110c2be794fdacc8 100755
--- a/foundation/ace/ace_engine_lite/frameworks/BUILD.gn
+++ b/foundation/ace/ace_engine_lite/frameworks/BUILD.gn
@@ -62,6 +62,7 @@ shared_library("ace_lite") {
"//third_party/jerryscript/jerry-libm:jerry-libm_shared",
"//third_party/jerryscript/jerry-port/default:jerry-port-default_shared",
"//utils/native/lite/timer_task:ace_kit_timer",
+ "//drivers/adapter/uhdf/manager:hdf_core",
]
defines = []
diff --git a/foundation/ace/ace_engine_lite/frameworks/src/core/modules/app_module.cpp b/foundation/ace/ace_engine_lite/frameworks/src/core/modules/app_module.cpp
old mode 100644
new mode 100755
index 05737434181b4c4644c41b24b96123fd38bf92aa..c97675d9c2f5dcf9453d792f43814f169f7560b7
--- a/foundation/ace/ace_engine_lite/frameworks/src/core/modules/app_module.cpp
+++ b/foundation/ace/ace_engine_lite/frameworks/src/core/modules/app_module.cpp
@@ -21,6 +21,15 @@
#include "product_adapter.h"
#endif
+#include "hdf_sbuf.h"
+#include "hdf_io_service_if.h"
+
+#define E53_IS1_SERVICE "hdf_e53_is1"
+#define E53_SF1_SERVICE "hdf_e53_sf1"
+#define E53_SC2_SERVICE "hdf_e53_sc2"
+#define E53_SC1_SERVICE "hdf_e53_sc1"
+#define E53_IA1_SERVICE "hdf_e53_ia1"
+
namespace OHOS {
namespace ACELite {
const char * const AppModule::FILE_MANIFEST = "manifest.json";
@@ -45,6 +54,458 @@ struct AsyncParams : public MemoryHeap {
};
#endif
+static int E53IS1Control(struct HdfIoService *serv, int32_t cmd, const char* buf, char **val)
+{
+ int ret = HDF_FAILURE;
+ struct HdfSBuf *data = HdfSBufObtainDefaultSize();
+ struct HdfSBuf *reply = HdfSBufObtainDefaultSize();
+
+ if (data == NULL || reply == NULL) {
+ HILOG_ERROR(HILOG_MODULE_ACE,"fail to obtain sbuf data\n");
+ return ret;
+ }
+
+ if (!HdfSbufWriteString(data, buf))
+ {
+ HILOG_ERROR(HILOG_MODULE_ACE,"fail to write sbuf\n");
+ HdfSBufRecycle(data);
+ HdfSBufRecycle(reply);
+ return ret;
+ }
+
+ ret = serv->dispatcher->Dispatch(&serv->object, cmd, data, reply);
+ if (ret != HDF_SUCCESS)
+ {
+ HILOG_ERROR(HILOG_MODULE_ACE,"fail to send service call\n");
+ HdfSBufRecycle(data);
+ HdfSBufRecycle(reply);
+ return ret;
+ }
+
+ *val = (char *)(HdfSbufReadString(reply));
+ if(val ==NULL){
+ HILOG_ERROR(HILOG_MODULE_ACE,"fail to get service call reply\n");
+ ret = HDF_ERR_INVALID_OBJECT;
+ HdfSBufRecycle(data);
+ HdfSBufRecycle(reply);
+ return ret;
+
+ }
+
+ HILOG_ERROR(HILOG_MODULE_ACE,"Get reply is: %s\n", *val);
+
+ HdfSBufRecycle(data);
+ HdfSBufRecycle(reply);
+ return ret;
+}
+
+JSIValue AppModule::E53IS1Service(const JSIValue thisVal, const JSIValue *args, uint8_t argsNum)
+{
+ struct HdfIoService *serv = HdfIoServiceBind(E53_IS1_SERVICE);
+ if (serv == NULL)
+ {
+ HILOG_ERROR(HILOG_MODULE_ACE,"fail to get service %s\n", E53_IS1_SERVICE);
+ return JSI::CreateUndefined();
+ }
+
+ if ((args == nullptr) || (argsNum == 0) || (JSI::ValueIsUndefined(args[0]))) {
+ return JSI::CreateUndefined();
+ }
+
+ JSIValue success = JSI::GetNamedProperty(args[0], CB_SUCCESS);
+ JSIValue fail = JSI::GetNamedProperty(args[0], CB_FAIL);
+ JSIValue complete = JSI::GetNamedProperty(args[0], CB_COMPLETE);
+
+ int32_t cmd = (int32_t)JSI::GetNumberProperty(args[0], "cmd");
+ char *data = (char *)JSI::GetStringProperty(args[0], "data");
+ HILOG_ERROR(HILOG_MODULE_ACE, "cmd is: %d\n", cmd);
+ HILOG_ERROR(HILOG_MODULE_ACE,"data is: %s\n", data);
+ char *replyData;
+
+ if (E53IS1Control(serv, cmd, data, &replyData))
+ {
+ HILOG_ERROR(HILOG_MODULE_ACE,"fail to send event\n");
+ JSI::CallFunction(fail, thisVal, nullptr, 0);
+ JSI::CallFunction(complete, thisVal, nullptr, 0);
+ JSI::ReleaseValueList(success, fail, complete);
+ return JSI::CreateUndefined();
+ }
+
+ JSIValue result = JSI::CreateObject();
+
+ JSI::SetStringProperty(result, "e53_is1", replyData);
+ JSIValue argv[ARGC_ONE] = {result};
+ JSI::CallFunction(success, thisVal, argv, ARGC_ONE);
+ JSI::CallFunction(complete, thisVal, nullptr, 0);
+ JSI::ReleaseValueList(success, fail, complete, result);
+
+ HdfIoServiceRecycle(serv);
+
+ return JSI::CreateUndefined();
+}
+
+static int E53SF1Control(struct HdfIoService *serv, int32_t cmd, const char* buf, char **val)
+{
+ int ret = HDF_FAILURE;
+ struct HdfSBuf *data = HdfSBufObtainDefaultSize();
+ struct HdfSBuf *reply = HdfSBufObtainDefaultSize();
+
+ if (data == NULL || reply == NULL) {
+ HILOG_ERROR(HILOG_MODULE_ACE,"fail to obtain sbuf data\n");
+ return ret;
+ }
+
+ if (!HdfSbufWriteString(data, buf))
+ {
+ HILOG_ERROR(HILOG_MODULE_ACE,"fail to write sbuf\n");
+ HdfSBufRecycle(data);
+ HdfSBufRecycle(reply);
+ return ret;
+ }
+
+ ret = serv->dispatcher->Dispatch(&serv->object, cmd, data, reply);
+ if (ret != HDF_SUCCESS)
+ {
+ HILOG_ERROR(HILOG_MODULE_ACE,"fail to send service call\n");
+ HdfSBufRecycle(data);
+ HdfSBufRecycle(reply);
+ return ret;
+ }
+
+ *val = (char *)(HdfSbufReadString(reply));
+ if(val ==NULL){
+ HILOG_ERROR(HILOG_MODULE_ACE,"fail to get service call reply\n");
+ ret = HDF_ERR_INVALID_OBJECT;
+ HdfSBufRecycle(data);
+ HdfSBufRecycle(reply);
+ return ret;
+
+ }
+
+ HILOG_ERROR(HILOG_MODULE_ACE,"Get reply is: %s\n", *val);
+
+ HdfSBufRecycle(data);
+ HdfSBufRecycle(reply);
+ return ret;
+}
+
+JSIValue AppModule::E53SF1Service(const JSIValue thisVal, const JSIValue *args, uint8_t argsNum)
+{
+ struct HdfIoService *serv = HdfIoServiceBind(E53_SF1_SERVICE);
+ if (serv == NULL)
+ {
+ HILOG_ERROR(HILOG_MODULE_ACE,"fail to get service %s\n", E53_SF1_SERVICE);
+ return JSI::CreateUndefined();
+ }
+
+ if ((args == nullptr) || (argsNum == 0) || (JSI::ValueIsUndefined(args[0]))) {
+ return JSI::CreateUndefined();
+ }
+
+ JSIValue success = JSI::GetNamedProperty(args[0], CB_SUCCESS);
+ JSIValue fail = JSI::GetNamedProperty(args[0], CB_FAIL);
+ JSIValue complete = JSI::GetNamedProperty(args[0], CB_COMPLETE);
+
+ int32_t cmd = (int32_t)JSI::GetNumberProperty(args[0], "cmd");
+ char *data = (char *)JSI::GetStringProperty(args[0], "data");
+ HILOG_ERROR(HILOG_MODULE_ACE, "cmd is: %d\n", cmd);
+ HILOG_ERROR(HILOG_MODULE_ACE,"data is: %s\n", data);
+ char *replyData;
+
+ if (E53SF1Control(serv, cmd, data, &replyData))
+ {
+ HILOG_ERROR(HILOG_MODULE_ACE,"fail to send event\n");
+ JSI::CallFunction(fail, thisVal, nullptr, 0);
+ JSI::CallFunction(complete, thisVal, nullptr, 0);
+ JSI::ReleaseValueList(success, fail, complete);
+ return JSI::CreateUndefined();
+ }
+
+ JSIValue result = JSI::CreateObject();
+
+ JSI::SetStringProperty(result, "e53_sf1", replyData);
+ JSIValue argv[ARGC_ONE] = {result};
+ JSI::CallFunction(success, thisVal, argv, ARGC_ONE);
+ JSI::CallFunction(complete, thisVal, nullptr, 0);
+ JSI::ReleaseValueList(success, fail, complete, result);
+
+ HdfIoServiceRecycle(serv);
+
+ return JSI::CreateUndefined();
+}
+
+static int E53SC2Control(struct HdfIoService *serv, int32_t cmd, const char* buf, char **val)
+{
+ int ret = HDF_FAILURE;
+ struct HdfSBuf *data = HdfSBufObtainDefaultSize();
+ struct HdfSBuf *reply = HdfSBufObtainDefaultSize();
+
+ if (data == NULL || reply == NULL) {
+ HILOG_ERROR(HILOG_MODULE_ACE,"fail to obtain sbuf data\n");
+ return ret;
+ }
+
+ if (!HdfSbufWriteString(data, buf))
+ {
+ HILOG_ERROR(HILOG_MODULE_ACE,"fail to write sbuf\n");
+ HdfSBufRecycle(data);
+ HdfSBufRecycle(reply);
+ return ret;
+ }
+
+ ret = serv->dispatcher->Dispatch(&serv->object, cmd, data, reply);
+ if (ret != HDF_SUCCESS)
+ {
+ HILOG_ERROR(HILOG_MODULE_ACE,"fail to send service call\n");
+ HdfSBufRecycle(data);
+ HdfSBufRecycle(reply);
+ return ret;
+ }
+
+ *val = (char *)(HdfSbufReadString(reply));
+ if(val ==NULL){
+ HILOG_ERROR(HILOG_MODULE_ACE,"fail to get service call reply\n");
+ ret = HDF_ERR_INVALID_OBJECT;
+ HdfSBufRecycle(data);
+ HdfSBufRecycle(reply);
+ return ret;
+
+ }
+
+ HILOG_ERROR(HILOG_MODULE_ACE,"Get reply is: %s\n", *val);
+
+ HdfSBufRecycle(data);
+ HdfSBufRecycle(reply);
+ return ret;
+}
+
+JSIValue AppModule::E53SC2Service(const JSIValue thisVal, const JSIValue *args, uint8_t argsNum)
+{
+ struct HdfIoService *serv = HdfIoServiceBind(E53_SC2_SERVICE);
+ if (serv == NULL)
+ {
+ HILOG_ERROR(HILOG_MODULE_ACE,"fail to get service %s\n", E53_SC2_SERVICE);
+ return JSI::CreateUndefined();
+ }
+
+ if ((args == nullptr) || (argsNum == 0) || (JSI::ValueIsUndefined(args[0]))) {
+ return JSI::CreateUndefined();
+ }
+
+ JSIValue success = JSI::GetNamedProperty(args[0], CB_SUCCESS);
+ JSIValue fail = JSI::GetNamedProperty(args[0], CB_FAIL);
+ JSIValue complete = JSI::GetNamedProperty(args[0], CB_COMPLETE);
+
+ int32_t cmd = (int32_t)JSI::GetNumberProperty(args[0], "cmd");
+ char *data = (char *)JSI::GetStringProperty(args[0], "data");
+ HILOG_ERROR(HILOG_MODULE_ACE, "cmd is: %d\n", cmd);
+ HILOG_ERROR(HILOG_MODULE_ACE,"data is: %s\n", data);
+ char *replyData;
+
+ if (E53SC2Control(serv, cmd, data, &replyData))
+ {
+ HILOG_ERROR(HILOG_MODULE_ACE,"fail to send event\n");
+ JSI::CallFunction(fail, thisVal, nullptr, 0);
+ JSI::CallFunction(complete, thisVal, nullptr, 0);
+ JSI::ReleaseValueList(success, fail, complete);
+ return JSI::CreateUndefined();
+ }
+
+ JSIValue result = JSI::CreateObject();
+
+ JSI::SetStringProperty(result, "e53_sc2", replyData);
+ JSIValue argv[ARGC_ONE] = {result};
+ JSI::CallFunction(success, thisVal, argv, ARGC_ONE);
+ JSI::CallFunction(complete, thisVal, nullptr, 0);
+ JSI::ReleaseValueList(success, fail, complete, result);
+
+ HdfIoServiceRecycle(serv);
+
+ return JSI::CreateUndefined();
+}
+
+
+static int E53SC1Control(struct HdfIoService *serv, int32_t cmd, const char* buf, char **val)
+{
+ int ret = HDF_FAILURE;
+ struct HdfSBuf *data = HdfSBufObtainDefaultSize();
+ struct HdfSBuf *reply = HdfSBufObtainDefaultSize();
+
+ if (data == NULL || reply == NULL) {
+ HILOG_ERROR(HILOG_MODULE_ACE,"fail to obtain sbuf data\n");
+ return ret;
+ }
+
+ if (!HdfSbufWriteString(data, buf))
+ {
+ HILOG_ERROR(HILOG_MODULE_ACE,"fail to write sbuf\n");
+ HdfSBufRecycle(data);
+ HdfSBufRecycle(reply);
+ return ret;
+ }
+
+ ret = serv->dispatcher->Dispatch(&serv->object, cmd, data, reply);
+ if (ret != HDF_SUCCESS)
+ {
+ HILOG_ERROR(HILOG_MODULE_ACE,"fail to send service call\n");
+ HdfSBufRecycle(data);
+ HdfSBufRecycle(reply);
+ return ret;
+ }
+
+ *val = (char *)(HdfSbufReadString(reply));
+ if(val ==NULL){
+ HILOG_ERROR(HILOG_MODULE_ACE,"fail to get service call reply\n");
+ ret = HDF_ERR_INVALID_OBJECT;
+ HdfSBufRecycle(data);
+ HdfSBufRecycle(reply);
+ return ret;
+
+ }
+
+ HILOG_ERROR(HILOG_MODULE_ACE,"Get reply is: %s\n", *val);
+
+ HdfSBufRecycle(data);
+ HdfSBufRecycle(reply);
+ return ret;
+}
+
+JSIValue AppModule::E53SC1Service(const JSIValue thisVal, const JSIValue *args, uint8_t argsNum)
+{
+ struct HdfIoService *serv = HdfIoServiceBind(E53_SC1_SERVICE);
+ if (serv == NULL)
+ {
+ HILOG_ERROR(HILOG_MODULE_ACE,"fail to get service %s\n", E53_SC1_SERVICE);
+ return JSI::CreateUndefined();
+ }
+
+ if ((args == nullptr) || (argsNum == 0) || (JSI::ValueIsUndefined(args[0]))) {
+ return JSI::CreateUndefined();
+ }
+
+ JSIValue success = JSI::GetNamedProperty(args[0], CB_SUCCESS);
+ JSIValue fail = JSI::GetNamedProperty(args[0], CB_FAIL);
+ JSIValue complete = JSI::GetNamedProperty(args[0], CB_COMPLETE);
+
+ int32_t cmd = (int32_t)JSI::GetNumberProperty(args[0], "cmd");
+ char *data = (char *)JSI::GetStringProperty(args[0], "data");
+ HILOG_ERROR(HILOG_MODULE_ACE, "cmd is: %d\n", cmd);
+ HILOG_ERROR(HILOG_MODULE_ACE,"data is: %s\n", data);
+ char *replyData;
+
+ if (E53SC1Control(serv, cmd, data, &replyData))
+ {
+ HILOG_ERROR(HILOG_MODULE_ACE,"fail to send event\n");
+ JSI::CallFunction(fail, thisVal, nullptr, 0);
+ JSI::CallFunction(complete, thisVal, nullptr, 0);
+ JSI::ReleaseValueList(success, fail, complete);
+ return JSI::CreateUndefined();
+ }
+
+ JSIValue result = JSI::CreateObject();
+
+ JSI::SetStringProperty(result, "e53_sc1", replyData);
+ JSIValue argv[ARGC_ONE] = {result};
+ JSI::CallFunction(success, thisVal, argv, ARGC_ONE);
+ JSI::CallFunction(complete, thisVal, nullptr, 0);
+ JSI::ReleaseValueList(success, fail, complete, result);
+
+ HdfIoServiceRecycle(serv);
+
+ return JSI::CreateUndefined();
+}
+
+
+static int E53IA1Control(struct HdfIoService *serv, int32_t cmd, const char* buf, char **val)
+{
+ int ret = HDF_FAILURE;
+ struct HdfSBuf *data = HdfSBufObtainDefaultSize();
+ struct HdfSBuf *reply = HdfSBufObtainDefaultSize();
+
+ if (data == NULL || reply == NULL) {
+ HILOG_ERROR(HILOG_MODULE_ACE,"fail to obtain sbuf data\n");
+ return ret;
+ }
+
+ if (!HdfSbufWriteString(data, buf))
+ {
+ HILOG_ERROR(HILOG_MODULE_ACE,"fail to write sbuf\n");
+ HdfSBufRecycle(data);
+ HdfSBufRecycle(reply);
+ return ret;
+ }
+
+ ret = serv->dispatcher->Dispatch(&serv->object, cmd, data, reply);
+ if (ret != HDF_SUCCESS)
+ {
+ HILOG_ERROR(HILOG_MODULE_ACE,"fail to send service call\n");
+ HdfSBufRecycle(data);
+ HdfSBufRecycle(reply);
+ return ret;
+ }
+
+ *val = (char *)(HdfSbufReadString(reply));
+ if(val ==NULL){
+ HILOG_ERROR(HILOG_MODULE_ACE,"fail to get service call reply\n");
+ ret = HDF_ERR_INVALID_OBJECT;
+ HdfSBufRecycle(data);
+ HdfSBufRecycle(reply);
+ return ret;
+
+ }
+
+ HILOG_ERROR(HILOG_MODULE_ACE,"Get reply is: %s\n", *val);
+
+ HdfSBufRecycle(data);
+ HdfSBufRecycle(reply);
+ return ret;
+}
+
+JSIValue AppModule::E53IA1Service(const JSIValue thisVal, const JSIValue *args, uint8_t argsNum)
+{
+ struct HdfIoService *serv = HdfIoServiceBind(E53_IA1_SERVICE);
+ if (serv == NULL)
+ {
+ HILOG_ERROR(HILOG_MODULE_ACE,"fail to get service %s\n", E53_IA1_SERVICE);
+ return JSI::CreateUndefined();
+ }
+
+ if ((args == nullptr) || (argsNum == 0) || (JSI::ValueIsUndefined(args[0]))) {
+ return JSI::CreateUndefined();
+ }
+
+ JSIValue success = JSI::GetNamedProperty(args[0], CB_SUCCESS);
+ JSIValue fail = JSI::GetNamedProperty(args[0], CB_FAIL);
+ JSIValue complete = JSI::GetNamedProperty(args[0], CB_COMPLETE);
+
+ int32_t cmd = (int32_t)JSI::GetNumberProperty(args[0], "cmd");
+ char *data = (char *)JSI::GetStringProperty(args[0], "data");
+ HILOG_ERROR(HILOG_MODULE_ACE, "cmd is: %d\n", cmd);
+ HILOG_ERROR(HILOG_MODULE_ACE,"data is: %s\n", data);
+ char *replyData;
+
+ if (E53IA1Control(serv, cmd, data, &replyData))
+ {
+ HILOG_ERROR(HILOG_MODULE_ACE,"fail to send event\n");
+ JSI::CallFunction(fail, thisVal, nullptr, 0);
+ JSI::CallFunction(complete, thisVal, nullptr, 0);
+ JSI::ReleaseValueList(success, fail, complete);
+ return JSI::CreateUndefined();
+ }
+
+ JSIValue result = JSI::CreateObject();
+
+ JSI::SetStringProperty(result, "e53_ia1", replyData);
+ JSIValue argv[ARGC_ONE] = {result};
+ JSI::CallFunction(success, thisVal, argv, ARGC_ONE);
+ JSI::CallFunction(complete, thisVal, nullptr, 0);
+ JSI::ReleaseValueList(success, fail, complete, result);
+
+ HdfIoServiceRecycle(serv);
+
+ return JSI::CreateUndefined();
+}
+
JSIValue AppModule::GetInfo(const JSIValue thisVal, const JSIValue *args, uint8_t argsNum)
{
JSIValue result = JSI::CreateUndefined();
diff --git a/foundation/ace/ace_engine_lite/frameworks/src/core/modules/app_module.h b/foundation/ace/ace_engine_lite/frameworks/src/core/modules/app_module.h
old mode 100644
new mode 100755
index ea843f71ea56d13e3528855226643fad8c1ca4e3..3e5c9bbd850263791b4b0bab9f8665a75863bc1e
--- a/foundation/ace/ace_engine_lite/frameworks/src/core/modules/app_module.h
+++ b/foundation/ace/ace_engine_lite/frameworks/src/core/modules/app_module.h
@@ -30,6 +30,11 @@ public:
~AppModule() = default;
static JSIValue GetInfo(const JSIValue thisVal, const JSIValue *args, uint8_t argsNum);
static JSIValue Terminate(const JSIValue thisVal, const JSIValue *args, uint8_t argsNum);
+ static JSIValue E53IA1Service(const JSIValue thisVal, const JSIValue* args, uint8_t argsNum);
+ static JSIValue E53SF1Service(const JSIValue thisVal, const JSIValue* args, uint8_t argsNum);
+ static JSIValue E53IS1Service(const JSIValue thisVal, const JSIValue* args, uint8_t argsNum);
+ static JSIValue E53SC1Service(const JSIValue thisVal, const JSIValue* args, uint8_t argsNum);
+ static JSIValue E53SC2Service(const JSIValue thisVal, const JSIValue* args, uint8_t argsNum);
#ifdef FEATURE_SCREEN_ON_VISIBLE
static JSIValue ScreenOnVisible(const JSIValue thisVal, const JSIValue *args, uint8_t argsNum);
#endif
@@ -61,6 +66,11 @@ void InitAppModule(JSIValue exports)
{
JSI::SetModuleAPI(exports, "getInfo", AppModule::GetInfo);
JSI::SetModuleAPI(exports, "terminate", AppModule::Terminate);
+ JSI::SetModuleAPI(exports, "e53ia1service", AppModule::E53IA1Service);
+ JSI::SetModuleAPI(exports, "e53sf1service", AppModule::E53SF1Service);
+ JSI::SetModuleAPI(exports, "e53is1service", AppModule::E53IS1Service);
+ JSI::SetModuleAPI(exports, "e53sc1service", AppModule::E53SC1Service);
+ JSI::SetModuleAPI(exports, "e53sc2service", AppModule::E53SC2Service);
#ifdef FEATURE_SCREEN_ON_VISIBLE
JSI::SetModuleAPI(exports, "screenOnVisible", AppModule::ScreenOnVisible);
#endif
diff --git a/foundation/ace/ace_engine_lite/test/ace_test_config.gni b/foundation/ace/ace_engine_lite/test/ace_test_config.gni
index 7f95bee144126ee1e2f64e945a6fd288e00c283e..d07fe6f5c6896237ed20f3027ddb6d16f2184448 100755
--- a/foundation/ace/ace_engine_lite/test/ace_test_config.gni
+++ b/foundation/ace/ace_engine_lite/test/ace_test_config.gni
@@ -108,6 +108,7 @@ extra_deps = [
"//third_party/jerryscript/jerry-libm:jerry-libm_shared",
"//third_party/jerryscript/jerry-port/default:jerry-port-default_shared",
"//utils/native/lite/timer_task:ace_kit_timer",
+ "//drivers/adapter/uhdf/manager:hdf_core",
]
all_external_deps = ace_test_deps + extra_deps