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,3 @@
SRC_FILES += dev_adc.c drv_adc.c bus_adc.c
include $(KERNEL_ROOT)/compiler.mk
@@ -0,0 +1,123 @@
/*
* 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_adc.c
* @brief register adc bus function using bus driver framework
* @version 1.1
* @author AIIT XUOS Lab
* @date 2021-12-28
*/
#include <bus_adc.h>
#include <dev_adc.h>
/*Register the ADC BUS*/
int AdcBusInit(struct AdcBus *adc_bus, const char *bus_name)
{
NULL_PARAM_CHECK(adc_bus);
NULL_PARAM_CHECK(bus_name);
x_err_t ret = EOK;
if (BUS_INSTALL != adc_bus->bus.bus_state) {
strncpy(adc_bus->bus.bus_name, bus_name, NAME_NUM_MAX);
adc_bus->bus.bus_type = TYPE_ADC_BUS;
adc_bus->bus.bus_state = BUS_INSTALL;
adc_bus->bus.private_data = adc_bus->private_data;
ret = BusRegister(&adc_bus->bus);
if (EOK != ret) {
KPrintf("AdcBusInit BusRegister error %u\n", ret);
return ret;
}
} else {
KPrintf("AdcBusInit BusRegister bus has been register state%u\n", adc_bus->bus.bus_state);
}
return ret;
}
/*Register the ADC Driver*/
int AdcDriverInit(struct AdcDriver *adc_driver, const char *driver_name)
{
NULL_PARAM_CHECK(adc_driver);
NULL_PARAM_CHECK(driver_name);
x_err_t ret = EOK;
if (DRV_INSTALL != adc_driver->driver.driver_state) {
adc_driver->driver.driver_type = TYPE_ADC_DRV;
adc_driver->driver.driver_state = DRV_INSTALL;
strncpy(adc_driver->driver.drv_name, driver_name, NAME_NUM_MAX);
adc_driver->driver.configure = adc_driver->configure;
adc_driver->driver.private_data = adc_driver->private_data;
ret = AdcDriverRegister(&adc_driver->driver);
if (EOK != ret) {
KPrintf("AdcDriverInit DriverRegister error %u\n", ret);
return ret;
}
} else {
KPrintf("AdcDriverInit DriverRegister driver has been register state%u\n", adc_driver->driver.driver_state);
}
return ret;
}
/*Release the ADC device*/
int AdcReleaseBus(struct AdcBus *adc_bus)
{
NULL_PARAM_CHECK(adc_bus);
return BusRelease(&adc_bus->bus);
}
/*Register the ADC Driver to the ADC BUS*/
int AdcDriverAttachToBus(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("AdcDriverAttachToBus find adc bus error!name %s\n", bus_name);
return ERROR;
}
if (TYPE_ADC_BUS == bus->bus_type) {
driver = AdcDriverFind(drv_name, TYPE_ADC_DRV);
if (NONE == driver) {
KPrintf("AdcDriverAttachToBus find adc driver error!name %s\n", drv_name);
return ERROR;
}
if (TYPE_ADC_DRV == driver->driver_type) {
ret = DriverRegisterToBus(bus, driver);
if (EOK != ret) {
KPrintf("AdcDriverAttachToBus DriverRegisterToBus error %u\n", ret);
return ERROR;
}
}
}
return ret;
}
@@ -0,0 +1,120 @@
/*
* 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_adc.c
* @brief register adc dev function using bus driver framework
* @version 1.1
* @author AIIT XUOS Lab
* @date 2021-12-28
*/
#include <bus_adc.h>
#include <dev_adc.h>
static DoubleLinklistType adcdev_linklist;
/*Create the ADC device linklist*/
static void AdcDeviceLinkInit()
{
InitDoubleLinkList(&adcdev_linklist);
}
/*Find the register ADC device*/
HardwareDevType AdcDeviceFind(const char *dev_name, enum DevType dev_type)
{
NULL_PARAM_CHECK(dev_name);
struct HardwareDev *device = NONE;
DoubleLinklistType *node = NONE;
DoubleLinklistType *head = &adcdev_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)) && (dev_type == device->dev_type)) {
return device;
}
}
KPrintf("AdcDeviceFind adcnot find the %s device.return NULL\n", dev_name);
return NONE;
}
/*Register the ADC device*/
int AdcDeviceRegister(struct AdcHardwareDevice *adc_device, void *adc_param, const char *device_name)
{
NULL_PARAM_CHECK(adc_device);
NULL_PARAM_CHECK(device_name);
x_err_t ret = EOK;
static x_bool dev_link_flag = RET_FALSE;
if (!dev_link_flag) {
AdcDeviceLinkInit();
dev_link_flag = RET_TRUE;
}
if (DEV_INSTALL != adc_device->haldev.dev_state) {
strncpy(adc_device->haldev.dev_name, device_name, NAME_NUM_MAX);
adc_device->haldev.dev_type = TYPE_ADC_DEV;
adc_device->haldev.dev_state = DEV_INSTALL;
adc_device->haldev.dev_done = (struct HalDevDone *)adc_device->adc_dev_done;
adc_device->haldev.private_data = adc_param;
DoubleLinkListInsertNodeAfter(&adcdev_linklist, &(adc_device->haldev.dev_link));
} else {
KPrintf("AdcDeviceRegister device has been register state%u\n", adc_device->haldev.dev_state);
}
return ret;
}
/*Register the ADC Device to the ADC BUS*/
int AdcDeviceAttachToBus(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("AdcDeviceAttachToBus find adc bus error!name %s\n", bus_name);
return ERROR;
}
if (TYPE_ADC_BUS == bus->bus_type) {
device = AdcDeviceFind(dev_name, TYPE_ADC_DEV);
if (NONE == device) {
KPrintf("AdcDeviceAttachToBus find adc device error!name %s\n", dev_name);
return ERROR;
}
if (TYPE_ADC_DEV == device->dev_type) {
ret = DeviceRegisterToBus(bus, device);
if (EOK != ret) {
KPrintf("AdcDeviceAttachToBus DeviceRegisterToBus error %u\n", ret);
return ERROR;
}
}
}
return EOK;
}
@@ -0,0 +1,70 @@
/*
* 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_adc.c
* @brief register adc drv function using bus driver framework
* @version 1.1
* @author AIIT XUOS Lab
* @date 2021-12-28
*/
#include <bus_adc.h>
#include <dev_adc.h>
static DoubleLinklistType adcdrv_linklist;
/*Create the driver linklist*/
static void AdcDrvLinkInit()
{
InitDoubleLinkList(&adcdrv_linklist);
}
/*Find the regiter driver*/
DriverType AdcDriverFind(const char *drv_name, enum DriverType_e drv_type)
{
NULL_PARAM_CHECK(drv_name);
struct Driver *driver = NONE;
DoubleLinklistType *node = NONE;
DoubleLinklistType *head = &adcdrv_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)) && (drv_type == driver->driver_type)) {
return driver;
}
}
KPrintf("AdcDriverFind cannot find the %s driver.return NULL\n", drv_name);
return NONE;
}
/*Register the Driver, manage with the double linklist*/
int AdcDriverRegister(struct Driver *driver)
{
NULL_PARAM_CHECK(driver);
x_err_t ret = EOK;
static x_bool driver_link_flag = RET_FALSE;
if (!driver_link_flag) {
AdcDrvLinkInit();
driver_link_flag = RET_TRUE;
}
DoubleLinkListInsertNodeAfter(&adcdrv_linklist, &(driver->driver_link));
return ret;
}