From a482a467c1841da1da93c063277e2608b8714073 Mon Sep 17 00:00:00 2001 From: qtpl456 Date: Tue, 29 Mar 2022 14:46:15 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0HDF=E6=A1=86=E6=9E=B6?= =?UTF-8?q?=E9=80=82=E9=85=8D=E4=BB=A3=E7=A0=81=E5=92=8Cdemo=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: qtpl456 --- Makefile | 3 + model/network/wifi/hdfwifi.mk | 2 +- osal/src/osal_cdev.c | 1 + osal/src/osal_time.c | 15 ++ osal/src/osal_timer.c | 9 + platform/Kconfig | 7 + platform/Makefile | 1 + platform/common/plat_common.c | 1 + platform/emmc/emmc_adapter.c | 10 +- platform/gpio/gpio_adapter.c | 13 ++ platform/rtc/rtc_adapter.c | 5 + platform/sdio/sdio_adapter.c | 18 ++ platform/test/Makefile | 21 ++ platform/test/s700_gpio_test.c | 330 +++++++++++++++++++++++++++++ platform/test/s700_pwm_test.c | 148 +++++++++++++ platform/test/s700_rtc_test.c | 188 ++++++++++++++++ platform/test/s700_uart_test.c | 192 +++++++++++++++++ platform/test/s700_watchdog_test.c | 170 +++++++++++++++ 18 files changed, 1132 insertions(+), 2 deletions(-) create mode 100755 platform/test/Makefile create mode 100755 platform/test/s700_gpio_test.c create mode 100755 platform/test/s700_pwm_test.c create mode 100755 platform/test/s700_rtc_test.c create mode 100755 platform/test/s700_uart_test.c create mode 100755 platform/test/s700_watchdog_test.c diff --git a/Makefile b/Makefile index 33c8c23..2fdb21d 100644 --- a/Makefile +++ b/Makefile @@ -51,3 +51,6 @@ obj-$(CONFIG_DRIVERS_HDF_BT) += model/network/bluetooth/ obj-$(CONFIG_DRIVERS_HDF_VIBRATOR) += model/misc/vibrator/ obj-$(CONFIG_DRIVERS_HDF_AUDIO) += model/audio/ obj-$(CONFIG_DRIVERS_HDF_DSOFTBUS) += model/misc/dsoftbus/ +obj-y += network/ +obj-y += ../../../../device/actions/s700/drivers/ethernet/adapter/ +obj-$(CONFIG_DRIVERS_HDF_WIFI) += ../../../../device/actions/s700/drivers/wifi/ap6212/ diff --git a/model/network/wifi/hdfwifi.mk b/model/network/wifi/hdfwifi.mk index 63703c3..7aa5a76 100644 --- a/model/network/wifi/hdfwifi.mk +++ b/model/network/wifi/hdfwifi.mk @@ -14,7 +14,7 @@ HDF_WIFI_FRAMEWORKS_ROOT = $(HDF_DIR_PREFIX)/framework/model/network/wifi HDF_WIFI_KHDF_FRAMEWORKS_ROOT = $(HDF_DIR_PREFIX)/adapter/khdf/linux/model/network/wifi -HDF_WIFI_VENDOR_ROOT = $(HDF_VENDOR_PREFIX)/device/hisilicon/drivers/wifi/driver +HDF_WIFI_VENDOR_ROOT = $(HDF_VENDOR_PREFIX)/device/actions/s700/drivers/wifi HDF_FRAMEWORKS_INC := \ -Idrivers/hdf/framework/ability/sbuf/include \ -Idrivers/hdf/framework/core/common/include/host \ diff --git a/osal/src/osal_cdev.c b/osal/src/osal_cdev.c index ca113ef..e72c05b 100644 --- a/osal/src/osal_cdev.c +++ b/osal/src/osal_cdev.c @@ -18,6 +18,7 @@ #include #include #include +#include #include "osal_cdev.h" #include "hdf_log.h" #include "osal_file.h" diff --git a/osal/src/osal_time.c b/osal/src/osal_time.c index 20d121e..807ba44 100755 --- a/osal/src/osal_time.c +++ b/osal/src/osal_time.c @@ -21,7 +21,13 @@ #include #include #include +#include +#if LINUX_VERSION_CODE <= KERNEL_VERSION(3,12,0) +#include +#else #include +#endif + #include "hdf_log.h" #include "osal_math.h" #include "securec.h" @@ -33,7 +39,11 @@ int32_t OsalGetTime(OsalTimespec *time) { +#if LINUX_VERSION_CODE <= KERNEL_VERSION(3,12,0) + struct timespec ts; +#else struct timespec64 ts; +#endif if (time == NULL) { HDF_LOGE("%s invalid para", __func__); @@ -41,7 +51,12 @@ int32_t OsalGetTime(OsalTimespec *time) } (void)memset_s(&ts, sizeof(ts), 0, sizeof(ts)); +#if LINUX_VERSION_CODE <= KERNEL_VERSION(3,12,0) + ktime_get_ts(&ts); +#else ktime_get_ts64(&ts); +#endif + time->sec = ts.tv_sec; time->usec = ts.tv_nsec / HDF_KILO_UNIT; diff --git a/osal/src/osal_timer.c b/osal/src/osal_timer.c index 960828a..8fdcaed 100644 --- a/osal/src/osal_timer.c +++ b/osal/src/osal_timer.c @@ -21,6 +21,7 @@ #include #include #include +#include #include "hdf_log.h" #include "osal_mem.h" #include "osal_mutex.h" @@ -52,7 +53,11 @@ static void osal_timer_callback(struct timer_list *arg) return; } +#if LINUX_VERSION_CODE <= KERNEL_VERSION(3,12,0) + ktimer = container_of(arg, struct osal_ktimer, timer); +#else ktimer = from_timer(ktimer, arg, timer); +#endif OsalMutexTimedLock(&ktimer->mutex, HDF_WAIT_FOREVER); msec = ktimer->msec; @@ -111,7 +116,11 @@ static int32_t OsalTimerStart(OsalTimer *timer, OsalTimerMode mode) ktimer = (struct osal_ktimer *)timer->realTimer; timer_id = &ktimer->timer; +#if LINUX_VERSION_CODE <= KERNEL_VERSION(3,12,0) + setup_timer(timer_id, osal_timer_callback, 0); +#else timer_setup(timer_id, osal_timer_callback, 0); +#endif ktimer->mode = mode; timer_id->expires = jiffies + msecs_to_jiffies(ktimer->msec); add_timer(timer_id); diff --git a/platform/Kconfig b/platform/Kconfig index 658fbf5..bce9994 100644 --- a/platform/Kconfig +++ b/platform/Kconfig @@ -85,3 +85,10 @@ config DRIVERS_HDF_PLATFORM_RTC depends on DRIVERS_HDF_PLATFORM help Answer Y to enable HDF platform rtc driver. + +config DRIVERS_S700_HDF_TEST + bool "Enable S700 HDF TEST driver" + default n + depends on DRIVERS_HDF_PLATFORM + help + Answer Y to enable S700 HDF TEST driver. \ No newline at end of file diff --git a/platform/Makefile b/platform/Makefile index 40eb613..71bdec4 100644 --- a/platform/Makefile +++ b/platform/Makefile @@ -24,3 +24,4 @@ obj-$(CONFIG_DRIVERS_HDF_PLATFORM_SDIO) += sdio/ obj-$(CONFIG_DRIVERS_HDF_PLATFORM_EMMC) += emmc/ obj-$(CONFIG_DRIVERS_HDF_PLATFORM_SPI) += spi/ obj-$(CONFIG_DRIVERS_HDF_PLATFORM_RTC) += rtc/ +obj-$(CONFIG_DRIVERS_S700_HDF_TEST) += test/ diff --git a/platform/common/plat_common.c b/platform/common/plat_common.c index 7c1c017..408ec20 100644 --- a/platform/common/plat_common.c +++ b/platform/common/plat_common.c @@ -19,6 +19,7 @@ #include "platform_core.h" #include +#include bool PlatInIrqContext(void) { diff --git a/platform/emmc/emmc_adapter.c b/platform/emmc/emmc_adapter.c index 449cab0..b70583d 100644 --- a/platform/emmc/emmc_adapter.c +++ b/platform/emmc/emmc_adapter.c @@ -19,6 +19,7 @@ #include #include #include +#include #include "mmc_corex.h" #include "mmc_emmc.h" #include "device_resource_if.h" @@ -27,7 +28,11 @@ #define HDF_LOG_TAG emmc_adapter_c +#if LINUX_VERSION_CODE <= KERNEL_VERSION(3,12,0) +struct mmc_host *owl_get_mmc_host(int slot); +#else struct mmc_host *himci_get_mmc_host(int slot); +#endif int32_t Hi35xxLinuxEmmcGetCid(struct EmmcDevice *dev, uint8_t *cid, uint32_t size) { @@ -139,8 +144,11 @@ static int32_t Hi35xxLinuxEmmcBind(struct HdfDeviceObject *obj) HDF_LOGE("Hi35xxLinuxEmmcBind: cntlr parse fail."); goto _ERR; } +#if LINUX_VERSION_CODE <= KERNEL_VERSION(3,12,0) + cntlr->priv = (void *)owl_get_mmc_host((int32_t)cntlr->index); +#else cntlr->priv = (void *)himci_get_mmc_host((int32_t)cntlr->index); - +#endif ret = MmcCntlrAdd(cntlr); if (ret != HDF_SUCCESS) { HDF_LOGE("Hi35xxLinuxEmmcBind: cntlr add fail."); diff --git a/platform/gpio/gpio_adapter.c b/platform/gpio/gpio_adapter.c index 4139273..6cf3535 100644 --- a/platform/gpio/gpio_adapter.c +++ b/platform/gpio/gpio_adapter.c @@ -16,8 +16,13 @@ * */ +#include #include +#if LINUX_VERSION_CODE <= KERNEL_VERSION(3,12,0) +#include +#else #include +#endif #include #include #include "device_resource_if.h" @@ -88,6 +93,13 @@ static int32_t LinuxGpioSetDir(struct GpioCntlr *cntlr, uint16_t local, uint16_t return HDF_SUCCESS; } +#if LINUX_VERSION_CODE <= KERNEL_VERSION(3,12,0) +static int32_t LinuxGpioGetDir(struct GpioCntlr *cntlr, uint16_t local, uint16_t *dir) +{ + pr_err("========= NOTE: don't support this function"); + return HDF_ERR_BSP_PLT_API_ERR; +} +#else static int32_t LinuxGpioGetDir(struct GpioCntlr *cntlr, uint16_t local, uint16_t *dir) { int dirGet; @@ -102,6 +114,7 @@ static int32_t LinuxGpioGetDir(struct GpioCntlr *cntlr, uint16_t local, uint16_t *dir = (dirGet == GPIOF_DIR_IN) ? GPIO_DIR_IN : GPIO_DIR_OUT; return HDF_SUCCESS; } +#endif static irqreturn_t LinuxGpioIrqBridge(int irq, void *data) { diff --git a/platform/rtc/rtc_adapter.c b/platform/rtc/rtc_adapter.c index 41262fd..6098e36 100644 --- a/platform/rtc/rtc_adapter.c +++ b/platform/rtc/rtc_adapter.c @@ -16,6 +16,7 @@ * */ +#include #include #include "device_resource_if.h" #include "hdf_device_desc.h" @@ -51,7 +52,11 @@ static inline void LinuxTimeToHdfTime(struct RtcTime *hdfTime, const struct rtc_ static inline struct rtc_device *HdfGetRtcDevice(void) { +#if LINUX_VERSION_CODE <= KERNEL_VERSION(3,12,0) + struct rtc_device *dev = rtc_class_open(CONFIG_RTC_HCTOSYS_DEVICE); +#else struct rtc_device *dev = rtc_class_open(CONFIG_RTC_SYSTOHC_DEVICE); +#endif if (dev == NULL) { HDF_LOGE("%s: failed to get rtc device", __func__); diff --git a/platform/sdio/sdio_adapter.c b/platform/sdio/sdio_adapter.c index 59fdba5..a146570 100644 --- a/platform/sdio/sdio_adapter.c +++ b/platform/sdio/sdio_adapter.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include "plat_log.h" #include "device_resource_if.h" @@ -33,8 +34,13 @@ #define MMC_SLOT_NUM 3 #define SDIO_RESCAN_WAIT_TIME 40 +#if LINUX_VERSION_CODE <= KERNEL_VERSION(3,12,0) +struct mmc_host *owl_get_mmc_host(int slot); +void action_sdio_rescan(int slot); +#else struct mmc_host *himci_get_mmc_host(int slot); void hisi_sdio_rescan(int slot); +#endif static struct sdio_func *Hi35xxLinuxSdioGetFunc(struct SdioDevice *dev) { @@ -366,7 +372,11 @@ static struct sdio_func *Hi35xxLinuxSdioSearchFunc(uint32_t funcNum, uint16_t ve uint32_t i, j; for (i = 0; i < MMC_SLOT_NUM; i++) { +#if LINUX_VERSION_CODE <= KERNEL_VERSION(3,12,0) + host = owl_get_mmc_host(i); +#else host = himci_get_mmc_host(i); +#endif if (host == NULL) { continue; } @@ -430,7 +440,11 @@ static bool Hi35xxLinuxSdioRescanFinish(struct MmcCntlr *cntlr) struct mmc_host *host = NULL; struct mmc_card *card = NULL; +#if LINUX_VERSION_CODE <= KERNEL_VERSION(3,12,0) + host = owl_get_mmc_host(cntlr->index); +#else host = himci_get_mmc_host(cntlr->index); +#endif if (host == NULL) { return false; } @@ -455,7 +469,11 @@ static int32_t Hi35xxLinuxSdioRescan(struct MmcCntlr *cntlr) return HDF_ERR_INVALID_OBJECT; } +#if LINUX_VERSION_CODE <= KERNEL_VERSION(3,12,0) + action_sdio_rescan(cntlr->index); +#else hisi_sdio_rescan(cntlr->index); +#endif while (rescanFinish == false && count < SDIO_RESCAN_WAIT_TIME) { OsalMSleep(50); count++; diff --git a/platform/test/Makefile b/platform/test/Makefile new file mode 100755 index 0000000..4518ba4 --- /dev/null +++ b/platform/test/Makefile @@ -0,0 +1,21 @@ +# +# Copyright (c) 2022 Huawei Device Co., Ltd. +# +# This software is licensed under the terms of the GNU General Public +# License version 2, as published by the Free Software Foundation, and +# may be copied, distributed, and modified under those terms. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# + +include drivers/hdf/khdf/platform/platform.mk + +obj-$(CONFIG_DRIVERS_HDF_PLATFORM_GPIO) += ./s700_gpio_test.o +obj-$(CONFIG_DRIVERS_HDF_PLATFORM_PWM) +=./s700_pwm_test.o +obj-$(CONFIG_DRIVERS_HDF_PLATFORM_WATCHDOG) +=./s700_watchdog_test.o +obj-$(CONFIG_DRIVERS_HDF_PLATFORM_RTC) +=./s700_rtc_test.o +obj-$(CONFIG_DRIVERS_HDF_PLATFORM_UART) +=./s700_uart_test.o diff --git a/platform/test/s700_gpio_test.c b/platform/test/s700_gpio_test.c new file mode 100755 index 0000000..43eb468 --- /dev/null +++ b/platform/test/s700_gpio_test.c @@ -0,0 +1,330 @@ +/* + * s700_gpio_test.c + * + * gpio driver test of linux + * + * Copyright (c) 2022-2022 Huawei Device Co., Ltd. + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include +#include "hdf_log.h" +#include "hdf_base.h" +#include "hdf_device_desc.h" +#include "gpio_if.h" +#include "osal_io.h" +#include "osal_irq.h" +#include "osal_time.h" + +#define HDF_LOG_TAG gpio_driver_test + +// 设置cmd编号,类似于Linux的ioctl命令码。 +#define CMD_GPIO_RW_TEST 100 +#define CMD_GPIO_IRQ_TEST 101 +#define CMD_GPIO_WATER_LAMP_TEST 102 + +// GPIO NUM +#define GPIO_NUM_GPIOD_12 108 // 3*32+12 +#define GPIO_NUM_GPIOD_14 110 // 3*32+14 +#define GPIO_NUM_GPIOD_16 112 // 3*32+16 +#define GPIO_NUM_GPIOD_17 113 // 3*32+17 + +static uint32_t g_irqCnt; + +// 中断服务函数 +static int32_t TestCaseGpioIrqHandler(uint16_t gpio, void *data) +{ + HDF_LOGE("%s: irq triggered! on gpio:%u, data=%p", __func__, gpio, data); + g_irqCnt++; // 如果中断服务函数触发执行,则将全局中断计数加1 + return GpioDisableIrq(gpio); +} + +// 测试用例函数 +static int32_t gpio_test_irq(void) +{ + int32_t ret; + uint16_t valRead; + uint16_t mode; + uint16_t gpio = GPIO_NUM_GPIOD_12; // 待测试的GPIO管脚号 + uint32_t timeout; + + // 将管脚方向设置为输入 + ret = GpioSetDir(gpio, GPIO_DIR_IN); + if (ret != HDF_SUCCESS) { + HDF_LOGE("%s: set dir fail! ret:%d\n", __func__, ret); + return ret; + } + + // 先禁止该管脚中断 + ret = GpioDisableIrq(gpio); + if (ret != HDF_SUCCESS) { + HDF_LOGE("%s: disable irq fail! ret:%d\n", __func__, ret); + return ret; + } + + // 为管脚设置中断服务函数,触发模式为高电平触发 + mode = OSAL_IRQF_TRIGGER_HIGH; + HDF_LOGE("%s: mode:%0x\n", __func__, mode); + ret = GpioSetIrq(gpio, mode, TestCaseGpioIrqHandler, NULL); + if (ret != HDF_SUCCESS) { + HDF_LOGE("%s: set irq fail! ret:%d\n", __func__, ret); + return ret; + } + + // 使能此管脚中断 + ret = GpioEnableIrq(gpio); + if (ret != HDF_SUCCESS) { + HDF_LOGE("%s: enable irq fail! ret:%d\n", __func__, ret); + (void)GpioUnSetIrq(gpio); + return ret; + } + + g_irqCnt = 0; // 清除全局计数器 + timeout = 0; // 等待时间清零 + // 等待此管脚中断服务函数触发,等待超时时间为5000毫秒 + while (g_irqCnt <= 0 && timeout < 5000) { + (void)GpioRead(gpio, &valRead); + HDF_LOGE("[owl] gpio108=%d", valRead); + //(void)GpioWrite(gpio, (valRead == GPIO_VAL_LOW) ? GPIO_VAL_HIGH : GPIO_VAL_LOW); + HDF_LOGE("%s: wait irq timeout:%u\n", __func__, timeout); + OsalMDelay(200); // wait for irq trigger + timeout += 200; + } + (void)GpioUnSetIrq(gpio); + return (g_irqCnt > 0) ? HDF_SUCCESS : HDF_FAILURE; +} + +static int gpio_test_rw(uint16_t gpio) +{ + int32_t ret; + int i = 0; + uint16_t val; + + // 将管脚方向设置为输出 + ret = GpioSetDir(gpio, GPIO_DIR_OUT); + if (ret != HDF_SUCCESS) { + HDF_LOGE("%s: set dir fail! ret:%d\n", __func__, ret); + return ret; + } + + for (i = 0; i < 3; i++) { + ret = GpioWrite(gpio, GPIO_VAL_HIGH); + if (ret != HDF_SUCCESS) { + HDF_LOGE("GpioWrite: failed, ret %d\n", ret); + return ret; + } + OsalMSleep(500); + /* 读取108号GPIO管脚的电平值 */ + ret = GpioRead(gpio, &val); + if (ret != HDF_SUCCESS) { + HDF_LOGE("GpioWrite: failed, ret %d\n", ret); + return ret; + } else { + HDF_LOGE("GpioRead: succ, gpio108=%d", val); + } + + ret = GpioWrite(gpio, GPIO_VAL_LOW); + if (ret != HDF_SUCCESS) { + HDF_LOGE("GpioWrite: failed, ret %d\n", ret); + return ret; + } + OsalMSleep(500); + /* 读取108号GPIO管脚的电平值 */ + ret = GpioRead(gpio, &val); + if (ret != HDF_SUCCESS) { + HDF_LOGE("GpioWrite: failed, ret %d\n", ret); + return ret; + } else { + HDF_LOGE("GpioRead: succ, gpio108=%d", val); + } + } + + return HDF_SUCCESS; +} + +static int gpio_test_set_dir(uint16_t gpio) +{ + int32_t ret; + + // 将管脚方向设置为输出 + ret = GpioSetDir(gpio, GPIO_DIR_OUT); + if (ret != HDF_SUCCESS) { + HDF_LOGE("%s: set dir fail! ret:%d\n", __func__, ret); + return ret; + } + + return HDF_SUCCESS; +} + +static int gpio_test_water_lamp(uint16_t gpio) +{ + int32_t ret, i; + + ret = GpioWrite(gpio, GPIO_VAL_HIGH); + if (ret != HDF_SUCCESS) { + HDF_LOGE("GpioWrite: failed, ret %d\n", ret); + return ret; + } + OsalMSleep(500); + + ret = GpioWrite(gpio, GPIO_VAL_LOW); + if (ret != HDF_SUCCESS) { + HDF_LOGE("GpioWrite: failed, ret %d\n", ret); + return ret; + } + OsalMSleep(500); + + return HDF_SUCCESS; +} + + + +// Dispatch是驱动中用来处理用户态发下来的消息的函数。 +static int32_t GpioSampleDriverDispatch(struct HdfDeviceIoClient *deviceIoClient, int id, struct HdfSBuf *data, struct HdfSBuf *reply) +{ + int32_t ret, i, j; + int32_t gpio_num[4] = {GPIO_NUM_GPIOD_12, GPIO_NUM_GPIOD_14, GPIO_NUM_GPIOD_16, GPIO_NUM_GPIOD_17}; + + HDF_LOGE("%s: received cmd %d", __func__, id); + + switch (id) { + case CMD_GPIO_IRQ_TEST: { + const char *readData = HdfSbufReadString(data); // 内核从用户空间获取数据,类似Linux的copy_from_user。 + if (readData != NULL) { + HDF_LOGE("%s: read data is: %s", __func__, readData); // 内核打印从用户空间独到的数据。 + } + + // GPIO中断检测 + ret = gpio_test_irq(); + if (ret != HDF_SUCCESS) { + HDF_LOGE("GpioTestIrq: failed, ret %d\n", ret); + return ret; + } + + // 将向用户空间返回内容修改为字符串 + char *sendData = "come from kernel sapce: CMD_GPIO_IRQ_TEST"; + if (!HdfSbufWriteString(reply, sendData)) { + HDF_LOGE("%s: fail to write sbuf", __func__); + } + + // 通HdfDeviceSendEvent函数触发用户空间获取驱动上报数据。 + return HdfDeviceSendEvent(deviceIoClient->device, id, data); + } + + case CMD_GPIO_RW_TEST: { + const char *readData = HdfSbufReadString(data); // 内核从用户空间获取数据,类似Linux的copy_from_user。 + if (readData != NULL) { + HDF_LOGE("%s: read data is: %s", __func__, readData); // 内核打印从用户空间读到的数据。 + } + + // GPIO test + ret = gpio_test_rw(GPIO_NUM_GPIOD_12); + if (ret != 0) { + HDF_LOGE("GpioTest: failed, ret %d\n", ret); + return ret; + } + + // 将向用户空间返回内容修改为字符串 + char *sendData = "come from kernel sapce: CMD_GPIO_RW_TEST"; + if (!HdfSbufWriteString(reply, sendData)) { + HDF_LOGE("%s: fail to write sbuf", __func__); + } + + // 通HdfDeviceSendEvent函数触发用户空间获取驱动上报数据。 + return HdfDeviceSendEvent(deviceIoClient->device, id, data); + } + + case CMD_GPIO_WATER_LAMP_TEST: { + const char *readData = HdfSbufReadString(data); // 内核从用户空间获取数据,类似Linux的copy_from_user。 + if (readData != NULL) { + HDF_LOGE("%s: read data is: %s", __func__, readData); // 内核打印从用户空间读到的数据。 + } + + for(i = 0; i < 4; i++) { + ret = gpio_test_set_dir(gpio_num[i]); + if (ret != 0) { + HDF_LOGE("GpioSetDir: failed, ret %d\n", ret); + return ret; + } + } + + for (j = 0; j < 500; j++) { /* 500*4 is 30min */ + for(i = 0; i < 4; i++) { + ret = gpio_test_water_lamp(gpio_num[i]); + if (ret != 0) { + HDF_LOGE("GpioWaterLamp: failed, ret %d\n", ret); + return ret; + } + } + } + + // 将向用户空间返回内容修改为字符串 + char *sendData = "come from kernel sapce: CMD_GPIO_WATER_LAMP_TEST"; + if (!HdfSbufWriteString(reply, sendData)) { + HDF_LOGE("%s: fail to write sbuf", __func__); + } + + // 通HdfDeviceSendEvent函数触发用户空间获取驱动上报数据。 + return HdfDeviceSendEvent(deviceIoClient->device, id, data); + } + + default: { + HDF_LOGE("no such cmd id"); + break; + } + } + + return HDF_FAILURE; +} + +// 驱动资源释放的接口,本例未分配需要回收的资源,因此为空。 +static void GpioTestDriverRelease(struct HdfDeviceObject *deviceObject) +{ + // release resources here + return; +} + +// 用户态获取驱动的服务,获取该服务之后通过服务中的Dispatch方法向驱动发送消息。 +static int GpioTestDriverBind(struct HdfDeviceObject *deviceObject) +{ + if (deviceObject == NULL) { + return HDF_FAILURE; + } + static struct IDeviceIoService testService = { + // Dispatch是用来处理用户态发下来的消息。 + .Dispatch = GpioSampleDriverDispatch, + }; + deviceObject->service = &testService; + return HDF_SUCCESS; +} + +// 驱动自身业务初始的接口。 +static int GpioTestDriverInit(struct HdfDeviceObject *deviceObject) +{ + if (deviceObject == NULL) { + HDF_LOGE("%s::ptr is null!", __func__); + return HDF_FAILURE; + } + HDF_LOGE("gpio test driver Init success"); + return HDF_SUCCESS; +} + +// 定义驱动入口的对象,必须为HdfDriverEntry(在hdf_device_desc.h中定义)类型的全局变量。 +struct HdfDriverEntry g_gpioTestDriverEntry = { + .moduleVersion = 1, + .moduleName = "s700_gpio_test", + .Bind = GpioTestDriverBind, + .Init = GpioTestDriverInit, + .Release = GpioTestDriverRelease, +}; + +HDF_INIT(g_gpioTestDriverEntry); diff --git a/platform/test/s700_pwm_test.c b/platform/test/s700_pwm_test.c new file mode 100755 index 0000000..ad14cec --- /dev/null +++ b/platform/test/s700_pwm_test.c @@ -0,0 +1,148 @@ +/* + * s700_pwm_test.c + * + * pwm driver test of linux + * + * Copyright (c) 2022-2022 Huawei Device Co., Ltd. + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include +#include "hdf_log.h" +#include "hdf_base.h" +#include "hdf_device_desc.h" +#include "pwm_if.h" +#include "osal_io.h" +#include "osal_irq.h" +#include "osal_time.h" + +#define HDF_LOG_TAG pwm_driver_test + +#define CMD_PWM_TEST 100 + + +void pwm_test(void) +{ + int32_t ret; + uint32_t num; + DevHandle handle = NULL; + struct PwmConfig config; + config.duty = 333; + config.period = 999; + config.number = 5; /* Number of square waves to generate */ + config.polarity = 0; + config.status = 1; + /* pwm端口号,要填写实际平台上的端口号 */ + num = 0; + + /* 获取PWM设备句柄 */ + handle = PwmOpen(num); + if (handle == NULL) { + HDF_LOGE("PwmOpen: failed!"); + return; + } + + /* 设置参数 */ + ret = PwmSetConfig(handle, &config); + if (ret != 0) { + HDF_LOGE("PwmSetConfig: failed, ret %d\n", ret); + goto _ERR; + } + + ret = PwmSetDuty(handle, config.duty); + if (ret != 0) { + HDF_LOGE("PwmSetConfig: failed, ret %d\n", ret); + goto _ERR; + } + + ret = PwmEnable(handle); + if (ret != 0) { + HDF_LOGE("PwmSetConfig: failed, ret %d\n", ret); + goto _ERR; + } + +_ERR: + /* 销毁PWM设备句柄 */ + PwmClose(handle); +} + + +static int32_t PwmSampleDriverDispatch(struct HdfDeviceIoClient *deviceIoClient, int id, struct HdfSBuf *data, struct HdfSBuf *reply) +{ + HDF_LOGE("%s: received cmd %d", __func__, id); + + switch (id) { + case CMD_PWM_TEST: { + const char *readData = HdfSbufReadString(data); + if (readData != NULL) { + HDF_LOGE("%s: read data is: %s", __func__, readData); + } + + // Pwm测试 + pwm_test(); + + // 将向用户空间返回内容修改为字符串 + char *sendData = "come from kernel sapce: CMD_PWM_TEST"; + if (!HdfSbufWriteString(reply, sendData)) { + HDF_LOGE("%s: fail to write sbuf", __func__); + } + + // 通HdfDeviceSendEvent函数触发用户空间获取驱动上报数据。 + return HdfDeviceSendEvent(deviceIoClient->device, id, data); + } + + default: { + HDF_LOGE("no such cmd id"); + break; + } + } + + return HDF_FAILURE; +} + +static void PwmTestDriverRelease(struct HdfDeviceObject *deviceObject) +{ + // release resources here + return; +} + +static int PwmTestDriverBind(struct HdfDeviceObject *deviceObject) +{ + if (deviceObject == NULL) { + return HDF_FAILURE; + } + static struct IDeviceIoService testService = { + .Dispatch = PwmSampleDriverDispatch, + }; + deviceObject->service = &testService; + return HDF_SUCCESS; +} + +static int PwmTestDriverInit(struct HdfDeviceObject *deviceObject) +{ + if (deviceObject == NULL) { + HDF_LOGE("%s::ptr is null!", __func__); + return HDF_FAILURE; + } + HDF_LOGE("pwm test driver Init success"); + return HDF_SUCCESS; +} + +struct HdfDriverEntry g_pwmTestDriverEntry = { + .moduleVersion = 1, + .moduleName = "s700_pwm_test", + .Bind = PwmTestDriverBind, + .Init = PwmTestDriverInit, + .Release = PwmTestDriverRelease, +}; + +HDF_INIT(g_pwmTestDriverEntry); \ No newline at end of file diff --git a/platform/test/s700_rtc_test.c b/platform/test/s700_rtc_test.c new file mode 100755 index 0000000..aa498e1 --- /dev/null +++ b/platform/test/s700_rtc_test.c @@ -0,0 +1,188 @@ +/* + * s700_rtc_test.c + * + * rtc driver test of linux + * + * Copyright (c) 2022-2022 Huawei Device Co., Ltd. + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include +#include +#include +#include "hdf_log.h" +#include "hdf_base.h" +#include "hdf_device_desc.h" +#include "rtc_if.h" +#include "osal_io.h" +#include "osal_irq.h" +#include "osal_time.h" + +#define HDF_LOG_TAG rtc_driver_test + + +#define CMD_RTC_TEST 100 + +int32_t RtcAlarmACallback(enum RtcAlarmIndex alarmIndex) +{ + if (alarmIndex == RTC_ALARM_INDEX_A) { + /* 报警A的处理 */ + HDF_LOGE("RTC Alarm A callback function"); + } else if (alarmIndex == RTC_ALARM_INDEX_B) { + /* 报警B的处理 */ + HDF_LOGE("RTC Alarm B callback function"); + } else { + /* 错误处理 */ + } + return 0; +} + +void RtcTestSample(void) +{ + int32_t ret; + struct RtcTime tm; + struct RtcTime alarmTime; + uint32_t freq; + DevHandle handle = NULL; + + /* 获取RTC设备句柄 */ + handle = RtcOpen(); + if (handle == NULL) { + HDF_LOGE("[owl]RtcOpen fail"); + } + /* 注册报警A的定时回调函数 */ + ret = RtcRegisterAlarmCallback(handle, RTC_ALARM_INDEX_A, RtcAlarmACallback); + if (ret != 0) { + HDF_LOGI("[owl]RtcRegisterAlarmCallback fail"); + } + /* 设置RTC外接晶体振荡频率,注意按照器件手册要求配置RTC外频 */ + freq = 32768; /* 32768 Hz */ + ret = RtcSetFreq(handle, freq); + if (ret != 0) { + HDF_LOGI("[owl]RtcSetFreq fail"); + } + /* 设置RTC报警中断使能 */ + ret = RtcAlarmInterruptEnable(handle, RTC_ALARM_INDEX_A, 1); + if (ret != 0) { + HDF_LOGI("[owl]RtcAlarmInterruptEnable fail"); + } + /* 设置RTC时间为2021/08/08 08:08:08 .888 */ + tm.year = 2021; + tm.month = 8; + tm.day = 8; + tm.hour= 8; + tm.minute = 8; + tm.second = 8; + tm.millisecond = 888; + /* 写RTC时间信息 */ + ret = RtcWriteTime(handle, &tm); + if (ret != 0) { + HDF_LOGE("[owl]RtcWriteTime fail"); + } + /* 设置RTC报警时间为2021/08/08 08:08:28 .888 */ + alarmTime.year = 2021; + alarmTime.month = 8; + alarmTime.day = 8; + alarmTime.hour = 8; + alarmTime.minute = 8; + alarmTime.second = 28; + alarmTime.millisecond = 888; + /* 设置RTC_ALARM_INDEX_A索引定时报警时间信息, 定时时间到后会打印"RTC Alarm A callback function" */ + ret = RtcWriteAlarm(handle, RTC_ALARM_INDEX_A, &alarmTime); + if (ret != 0) { + HDF_LOGE("[owl]RtcWriteAlarm fail"); + } + + /* 读取RTC实时时间 */ + ret = RtcReadTime(handle, &tm); + if (ret != 0) { + HDF_LOGE("[owl]RtcReadTime fail"); + } + msleep(5000); + HDF_LOGE("RTC read time:"); + HDF_LOGE("year-month-date-weekday hour:minute:second .millisecond %04u-%02u-%02u-%u %02u:%02u:%02u .%03u", + tm.year, tm.month, tm.day, tm.weekday, tm.hour, tm.minute, tm.second, tm.millisecond); + /* 销毁RTC设备句柄 */ + RtcClose(handle); +} + + +static int32_t RtcSampleDriverDispatch(struct HdfDeviceIoClient *deviceIoClient, int id, struct HdfSBuf *data, struct HdfSBuf *reply) +{ + HDF_LOGE("%s: received cmd %d", __func__, id); + + switch (id) { + case CMD_RTC_TEST: { + const char *readData = HdfSbufReadString(data); + if (readData != NULL) { + HDF_LOGE("%s: read data is: %s", __func__, readData); + } + + // RTC测试 + RtcTestSample(); + + // 将向用户空间返回内容修改为字符串 + char *sendData = "come from kernel sapce: CMD_RTC_TEST"; + if (!HdfSbufWriteString(reply, sendData)) { + HDF_LOGE("%s: fail to write sbuf", __func__); + } + + // 通HdfDeviceSendEvent函数触发用户空间获取驱动上报数据。 + return HdfDeviceSendEvent(deviceIoClient->device, id, data); + } + + default: { + HDF_LOGE("no such cmd id"); + break; + } + } + + return HDF_FAILURE; +} + +static void RtcTestDriverRelease(struct HdfDeviceObject *deviceObject) +{ + // release resources here + return; +} + +static int RtcTestDriverBind(struct HdfDeviceObject *deviceObject) +{ + if (deviceObject == NULL) { + return HDF_FAILURE; + } + static struct IDeviceIoService testService = { + .Dispatch = RtcSampleDriverDispatch, + }; + deviceObject->service = &testService; + return HDF_SUCCESS; +} + +static int RtcTestDriverInit(struct HdfDeviceObject *deviceObject) +{ + if (deviceObject == NULL) { + HDF_LOGE("%s::ptr is null!", __func__); + return HDF_FAILURE; + } + HDF_LOGE("rtc test driver Init success"); + return HDF_SUCCESS; +} + +struct HdfDriverEntry g_rtcTestDriverEntry = { + .moduleVersion = 1, + .moduleName = "s700_rtc_test", + .Bind = RtcTestDriverBind, + .Init = RtcTestDriverInit, + .Release = RtcTestDriverRelease, +}; + +HDF_INIT(g_rtcTestDriverEntry); \ No newline at end of file diff --git a/platform/test/s700_uart_test.c b/platform/test/s700_uart_test.c new file mode 100755 index 0000000..f904fc6 --- /dev/null +++ b/platform/test/s700_uart_test.c @@ -0,0 +1,192 @@ +/* + * s700_uart_test.c + * + * uart driver test of linux + * + * Copyright (c) 2022-2022 Huawei Device Co., Ltd. + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include +#include +#include +#include "hdf_log.h" +#include "hdf_base.h" +#include "hdf_device_desc.h" +#include "uart_if.h" +#include "osal_io.h" +#include "osal_irq.h" +#include "osal_time.h" + +#define HDF_LOG_TAG uart_driver_test + +#define CMD_UART_TEST 100 + +void uart_test(void) +{ +#if 1 + int32_t flag; +#endif + int32_t ret, i; + uint32_t port, val; + DevHandle handle = NULL; + uint8_t wbuff[5] = { 'a', 'b', 'c', 'd', 'e' }; + uint8_t rbuff[100] = { 0 }; + struct UartAttribute attribute, a; + attribute.dataBits = UART_ATTR_DATABIT_8; /* UART传输数据位宽,一次传输8个bit */ + attribute.parity = UART_ATTR_PARITY_NONE; /* UART传输数据无校检 */ + attribute.stopBits = UART_ATTR_STOPBIT_1; /* UART传输数据停止位为1位 */ + attribute.rts = UART_ATTR_RTS_DIS; /* UART禁用RTS */ + attribute.cts = UART_ATTR_CTS_DIS; /* UART禁用CTS */ + attribute.fifoRxEn = UART_ATTR_RX_FIFO_EN; /* UART使能RX FIFO */ + attribute.fifoTxEn = UART_ATTR_TX_FIFO_EN; /* UART使能TX FIFO */ + /* UART设备端口号,要填写实际平台上的端口号 */ + port = 0; + /* 获取UART设备句柄 */ + handle = UartOpen(port); + if (handle == NULL) { + HDF_LOGE("UartOpen: failed!\n"); + return; + } + /* 设置UART波特率为115200 */ + ret = UartSetBaud(handle, 115200); + if (ret != 0) { + HDF_LOGI("UartSetBaud: failed, ret %d\n", ret); + //goto _ERR; + } + + /* 获取UART波特率 */ + ret = UartGetBaud(handle, &val); + if (ret != 0) { + HDF_LOGI("UartSetBaud: failed, ret %d\n", ret); + goto _ERR; + } + + /* 设置UART设备属性 */ + ret = UartSetAttribute(handle, &attribute); + if (ret != 0) { + HDF_LOGE("UartSetAttribute: failed, ret %d\n", ret); + goto _ERR; + } + + ret = UartGetAttribute(handle, &a); + if (ret != 0) { + HDF_LOGE("UartSetAttribute: failed, ret %d\n", ret); + goto _ERR; + } + + /* 设置UART传输模式为非阻塞模式 */ + ret = UartSetTransMode(handle, UART_MODE_RD_NONBLOCK); + if (ret != 0) { + HDF_LOGI("UartSetTransMode: failed, ret %d\n", ret); + //goto _ERR; + } + + /* 向UART设备写入5字节的数据 */ + ret = UartWrite(handle, wbuff, 5); + if (ret != 0) { + HDF_LOGE("UartWrite: failed, ret %d\n", ret); + goto _ERR; + } + +/* 读数据需要再外接一个串口,打开串口助手,就可以收到此测试demo发的数据 */ +#if 1 + while (1) { + ret = UartRead(handle, rbuff, 100); + if (ret > 0) { + for (i = 0; i < ret; i++) { + HDF_LOGE("[s700] rbuff[%d] = %d", i, rbuff[i]); + } + UartWrite(handle, rbuff, 100); + flag=1; + break; + } + } + flag = 0; +#endif + +_ERR: + /* 销毁UART设备句柄 */ + UartClose(handle); +} + +static int32_t UartSampleDriverDispatch(struct HdfDeviceIoClient *deviceIoClient, int id, struct HdfSBuf *data, struct HdfSBuf *reply) +{ + HDF_LOGE("%s: received cmd %d", __func__, id); + + switch (id) { + case CMD_UART_TEST: { + const char *readData = HdfSbufReadString(data); + if (readData != NULL) { + HDF_LOGE("%s: read data is: %s", __func__, readData); + } + + // uart测试 + uart_test(); + + // 将向用户空间返回内容修改为字符串 + char *sendData = "come from kernel sapce: CMD_UART_TEST"; + if (!HdfSbufWriteString(reply, sendData)) { + HDF_LOGE("%s: fail to write sbuf", __func__); + } + + // 通HdfDeviceSendEvent函数触发用户空间获取驱动上报数据。 + return HdfDeviceSendEvent(deviceIoClient->device, id, data); + } + + default: { + HDF_LOGE("no such cmd id"); + break; + } + } + + return HDF_FAILURE; +} + +static void UartTestDriverRelease(struct HdfDeviceObject *deviceObject) +{ + // release resources here + return; +} + +static int UartTestDriverBind(struct HdfDeviceObject *deviceObject) +{ + if (deviceObject == NULL) { + return HDF_FAILURE; + } + static struct IDeviceIoService testService = { + .Dispatch = UartSampleDriverDispatch, + }; + deviceObject->service = &testService; + return HDF_SUCCESS; +} + +// 驱动自身业务初始的接口。 +static int UartTestDriverInit(struct HdfDeviceObject *deviceObject) +{ + if (deviceObject == NULL) { + HDF_LOGE("%s::ptr is null!", __func__); + return HDF_FAILURE; + } + HDF_LOGE("uart test driver Init success"); + return HDF_SUCCESS; +} + +struct HdfDriverEntry g_uartTestDriverEntry = { + .moduleVersion = 1, + .moduleName = "s700_uart_test", + .Bind = UartTestDriverBind, + .Init = UartTestDriverInit, + .Release = UartTestDriverRelease, +}; + +HDF_INIT(g_uartTestDriverEntry); \ No newline at end of file diff --git a/platform/test/s700_watchdog_test.c b/platform/test/s700_watchdog_test.c new file mode 100755 index 0000000..3183fac --- /dev/null +++ b/platform/test/s700_watchdog_test.c @@ -0,0 +1,170 @@ +/* + * s700_watchdog_test.c + * + * watchdog driver test of linux + * + * Copyright (c) 2022-2022 Huawei Device Co., Ltd. + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include +#include "hdf_log.h" +#include "hdf_base.h" +#include "hdf_device_desc.h" +#include "watchdog_if.h" +#include "osal_io.h" +#include "osal_irq.h" +#include "osal_time.h" + +#define HDF_LOG_TAG watchdog_driver_test + +#define WATCHDOG_TEST_TIMEOUT 2 +#define WATCHDOG_TEST_FEED_TIME 6 + +#define CMD_WATCHDOG_TEST 100 + +static int32_t test_case_watchdog(void) +{ + int32_t i; + int32_t ret; + uint32_t timeout; + DevHandle handle = NULL; + + /* 打开0号看门狗设备 */ + handle = WatchdogOpen(0); + if (handle == NULL) { + HDF_LOGE("Open watchdog fail!"); + return -1; + } + + /* 设置超时时间 */ + ret = WatchdogSetTimeout(handle, WATCHDOG_TEST_TIMEOUT); + if (ret != HDF_SUCCESS) { + HDF_LOGE("%s: set timeout fail! ret:%d\n", __func__, ret); + WatchdogClose(handle); + return ret; + } + + /* 回读设置的超时时间值 */ + ret = WatchdogGetTimeout(handle, &timeout); + if (ret != HDF_SUCCESS) { + HDF_LOGE("%s: get timeout fail! ret:%d\n", __func__, ret); + WatchdogClose(handle); + return ret; + } + HDF_LOGI("%s: read timeout back:%u\n", __func__, timeout); + + /* 启动看门狗,开始计时 */ + ret = WatchdogStart(handle); + if (ret != HDF_SUCCESS) { + HDF_LOGE("%s: satrt fail! ret:%d\n", __func__, ret); + WatchdogClose(handle); + return ret; + } + + /* 每隔1S喂狗一次 */ + for (i = 0; i < WATCHDOG_TEST_FEED_TIME; i++) { + HDF_LOGE("%s: feeding watchdog %d times... \n", __func__, i); + ret = WatchdogFeed(handle); + if (ret != HDF_SUCCESS) { + HDF_LOGE("%s: feed dog fail! ret:%d\n", __func__, ret); + WatchdogClose(handle); + return ret; + } + OsalSleep(1); + } + /* 由于喂狗间隔小于超时时间,系统不会发生复位,此日志可以正常打印 */ + HDF_LOGE("%s: no reset ... feeding test OK!!!\n", __func__); + + /* 接下来持续不喂狗,使得看门狗计时器超时 */ + for (i = 0; i < WATCHDOG_TEST_FEED_TIME; i++) { + HDF_LOGE("%s: watiting dog buck %d times... \n", __func__, i); + OsalSleep(1); + } + + /* 当不喂狗时间到达之前设定的超时时间的时候,系统会发生复位,理论上观察不到此日志的打印 */ + HDF_LOGE("%s: dog has't buck!!! \n", __func__, i); + WatchdogClose(handle); + return -1; +} + + +static int32_t WatchdogSampleDriverDispatch(struct HdfDeviceIoClient *deviceIoClient, int id, struct HdfSBuf *data, struct HdfSBuf *reply) +{ + HDF_LOGE("%s: received cmd %d", __func__, id); + + switch (id) { + case CMD_WATCHDOG_TEST: { + const char *readData = HdfSbufReadString(data); + if (readData != NULL) { + HDF_LOGE("%s: read data is: %s", __func__, readData); + } + + // Watchdog测试 + test_case_watchdog(); + + // 将向用户空间返回内容修改为字符串 + char *sendData = "come from kernel sapce: CMD_WATCHDOG_TEST"; + if (!HdfSbufWriteString(reply, sendData)) { + HDF_LOGE("%s: fail to write sbuf", __func__); + } + + // 通HdfDeviceSendEvent函数触发用户空间获取驱动上报数据。 + return HdfDeviceSendEvent(deviceIoClient->device, id, data); + } + + default: { + HDF_LOGE("no such cmd id"); + break; + } + } + + return HDF_FAILURE; +} + +static void WatchdogTestDriverRelease(struct HdfDeviceObject *deviceObject) +{ + // release resources here + return; +} + +static int WatchdogTestDriverBind(struct HdfDeviceObject *deviceObject) +{ + if (deviceObject == NULL) { + return HDF_FAILURE; + } + static struct IDeviceIoService testService = { + .Dispatch = WatchdogSampleDriverDispatch, + }; + deviceObject->service = &testService; + return HDF_SUCCESS; +} + +static int WatchdogTestDriverInit(struct HdfDeviceObject *deviceObject) +{ + if (deviceObject == NULL) { + HDF_LOGE("%s::ptr is null!", __func__); + return HDF_FAILURE; + } + HDF_LOGE("watchdog test driver Init success"); + return HDF_SUCCESS; +} + +struct HdfDriverEntry g_watchdogTestDriverEntry = { + .moduleVersion = 1, + .moduleName = "s700_watchdog_test", + .Bind = WatchdogTestDriverBind, + .Init = WatchdogTestDriverInit, + .Release = WatchdogTestDriverRelease, +}; + +HDF_INIT(g_watchdogTestDriverEntry); \ No newline at end of file -- Gitee