modify XiUOS DIR : (1.add plc_demo in APP_Framework/control_app; 2.add industrial_network、industrial_fieldbus and industrial_wlan; 3.add XiZi_AIoT and modify XiZi as XiZi_IIoT.)

This commit is contained in:
Liu_Weichao
2022-09-27 20:39:52 +08:00
parent dbca22a1a6
commit e14fa6ff8e
5009 changed files with 1019 additions and 3084 deletions
@@ -0,0 +1,5 @@
SRC_FILES +=bus_wdt.c dev_wdt.c drv_wdt.c
include $(KERNEL_ROOT)/compiler.mk
@@ -0,0 +1,117 @@
/*
* Copyright (c) 2020 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file bus_wdt.c
* @brief register wdt bus function using bus driver framework
* @version 1.0
* @author AIIT XUOS Lab
* @date 2021-04-24
*/
#include <bus_wdt.h>
#include <dev_wdt.h>
int WdtBusInit(struct WdtBus *wdt_bus, const char *bus_name)
{
NULL_PARAM_CHECK(wdt_bus);
NULL_PARAM_CHECK(bus_name);
x_err_t ret = EOK;
if (BUS_INSTALL != wdt_bus->bus.bus_state) {
strncpy(wdt_bus->bus.bus_name, bus_name, NAME_NUM_MAX);
wdt_bus->bus.bus_type = TYPE_WDT_BUS;
wdt_bus->bus.bus_state = BUS_INSTALL;
wdt_bus->bus.private_data = wdt_bus->private_data;
ret = BusRegister(&wdt_bus->bus);
if (EOK != ret) {
KPrintf("WdtBusInit BusRegister error %u\n", ret);
return ret;
}
} else {
KPrintf("WdtBusInit BusRegister bus has been register state%u\n", wdt_bus->bus.bus_state);
}
return ret;
}
int WdtDriverInit(struct WdtDriver *wdt_driver, const char *driver_name)
{
NULL_PARAM_CHECK(wdt_driver);
NULL_PARAM_CHECK(driver_name);
x_err_t ret = EOK;
if (DRV_INSTALL != wdt_driver->driver.driver_state) {
wdt_driver->driver.driver_type = TYPE_WDT_DRV;
wdt_driver->driver.driver_state = DRV_INSTALL;
strncpy(wdt_driver->driver.drv_name, driver_name, NAME_NUM_MAX);
wdt_driver->driver.configure = wdt_driver->configure;
ret = WdtDriverRegister(&wdt_driver->driver);
if (EOK != ret) {
KPrintf("WdtDriverInit DriverRegister error %u\n", ret);
return ret;
}
} else {
KPrintf("WdtDriverInit DriverRegister driver has been register state%u\n", wdt_driver->driver.driver_state);
}
return ret;
}
int WdtReleaseBus(struct WdtBus *wdt_bus)
{
NULL_PARAM_CHECK(wdt_bus);
return BusRelease(&wdt_bus->bus);
}
int WdtDriverAttachToBus(const char *drv_name, const char *bus_name)
{
NULL_PARAM_CHECK(drv_name);
NULL_PARAM_CHECK(bus_name);
x_err_t ret = EOK;
struct Bus *bus;
struct Driver *driver;
bus = BusFind(bus_name);
if (NONE == bus) {
KPrintf("WdtDriverAttachToBus find watchdog bus error!name %s\n", bus_name);
return ERROR;
}
if (TYPE_WDT_BUS == bus->bus_type) {
driver = WdtDriverFind(drv_name);
if (NONE == driver) {
KPrintf("WdtDriverAttachToBus find watchdog driver error!name %s\n", drv_name);
return ERROR;
}
if (TYPE_WDT_DRV == driver->driver_type) {
ret = DriverRegisterToBus(bus, driver);
if (EOK != ret) {
KPrintf("WdtDriverAttachToBus DriverRegisterToBus error %u\n", ret);
return ERROR;
}
}
}
return ret;
}
@@ -0,0 +1,113 @@
/*
* Copyright (c) 2020 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file dev_wdt.c
* @brief register wdt dev function using bus driver framework
* @version 1.0
* @author AIIT XUOS Lab
* @date 2021-04-24
*/
#include <bus_wdt.h>
#include <dev_wdt.h>
static DoubleLinklistType wdtdev_linklist;
/*Create the wdt device linklist*/
static void WdtDeviceLinkInit()
{
InitDoubleLinkList(&wdtdev_linklist);
}
HardwareDevType WdtDeviceFind(const char *dev_name)
{
NULL_PARAM_CHECK(dev_name);
struct HardwareDev *device = NONE;
DoubleLinklistType *node = NONE;
DoubleLinklistType *head = &wdtdev_linklist;
for (node = head->node_next; node != head; node = node->node_next) {
device = SYS_DOUBLE_LINKLIST_ENTRY(node, struct HardwareDev, dev_link);
if (!strcmp(device->dev_name, dev_name)) {
return device;
}
}
KPrintf("WdtDeviceFind cannot find the %s device.return NULL\n", dev_name);
return NONE;
}
int WdtDeviceRegister(struct WdtHardwareDevice *wdt_device, const char *device_name)
{
NULL_PARAM_CHECK(wdt_device);
NULL_PARAM_CHECK(device_name);
x_err_t ret = EOK;
static x_bool dev_link_flag = RET_FALSE;
if (!dev_link_flag) {
WdtDeviceLinkInit();
dev_link_flag = RET_TRUE;
}
if (DEV_INSTALL != wdt_device->haldev.dev_state) {
strncpy(wdt_device->haldev.dev_name, device_name, NAME_NUM_MAX);
wdt_device->haldev.dev_type = TYPE_WDT_DEV;
wdt_device->haldev.dev_state = DEV_INSTALL;
wdt_device->haldev.dev_done = (struct HalDevDone *)wdt_device->dev_done;
DoubleLinkListInsertNodeAfter(&wdtdev_linklist, &(wdt_device->haldev.dev_link));
} else {
KPrintf("WdtDeviceRegister device has been register state%u\n", wdt_device->haldev.dev_state);
}
return ret;
}
int WdtDeviceAttachToBus(const char *dev_name, const char *bus_name)
{
NULL_PARAM_CHECK(dev_name);
NULL_PARAM_CHECK(bus_name);
x_err_t ret = EOK;
struct Bus *bus;
struct HardwareDev *device;
bus = BusFind(bus_name);
if (NONE == bus) {
KPrintf("WdtDeviceAttachToBus find wdt bus error!name %s\n", bus_name);
return ERROR;
}
if (TYPE_WDT_BUS == bus->bus_type) {
device = WdtDeviceFind(dev_name);
if (NONE == device) {
KPrintf("WdtDeviceAttachToBus find wdt device error!name %s\n", dev_name);
return ERROR;
}
if (TYPE_WDT_DEV == device->dev_type) {
ret = DeviceRegisterToBus(bus, device);
if (EOK != ret) {
KPrintf("WdtDeviceAttachToBus DeviceRegisterToBus error %u\n", ret);
return ERROR;
}
}
}
return EOK;
}
@@ -0,0 +1,67 @@
/*
* Copyright (c) 2020 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file drv_wdt.c
* @brief register wdt drv function using bus driver framework
* @version 1.0
* @author AIIT XUOS Lab
* @date 2021-04-24
*/
#include <bus_wdt.h>
#include <dev_wdt.h>
static DoubleLinklistType wdtdrv_linklist;
/*Create the driver linklist*/
static void WdtDrvLinkInit()
{
InitDoubleLinkList(&wdtdrv_linklist);
}
DriverType WdtDriverFind(const char *drv_name)
{
NULL_PARAM_CHECK(drv_name);
struct Driver *driver = NONE;
DoubleLinklistType *node = NONE;
DoubleLinklistType *head = &wdtdrv_linklist;
for (node = head->node_next; node != head; node = node->node_next) {
driver = SYS_DOUBLE_LINKLIST_ENTRY(node, struct Driver, driver_link);
if (!strcmp(driver->drv_name, drv_name)) {
return driver;
}
}
KPrintf("WdtDriverFind cannot find the %s driver.return NULL\n", drv_name);
return NONE;
}
int WdtDriverRegister(struct Driver *driver)
{
NULL_PARAM_CHECK(driver);
x_err_t ret = EOK;
static x_bool driver_link_flag = RET_FALSE;
if (!driver_link_flag) {
WdtDrvLinkInit();
driver_link_flag = RET_TRUE;
}
DoubleLinkListInsertNodeAfter(&wdtdrv_linklist, &(driver->driver_link));
return ret;
}