forked from xuos/xiuos
sync upstream
This commit is contained in:
@@ -151,3 +151,15 @@ if BSP_USING_WDT
|
||||
bool "Using Watch Dog bus drivers"
|
||||
default n
|
||||
endif
|
||||
|
||||
if BSP_USING_ADC
|
||||
config RESOURCES_ADC
|
||||
bool "Using ADC bus drivers"
|
||||
default n
|
||||
endif
|
||||
|
||||
if BSP_USING_DAC
|
||||
config RESOURCES_DAC
|
||||
bool "Using DAC bus drivers"
|
||||
default n
|
||||
endif
|
||||
|
||||
@@ -57,4 +57,12 @@ ifeq ($(CONFIG_RESOURCES_WDT),y)
|
||||
SRC_DIR += watchdog
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_RESOURCES_ADC),y)
|
||||
SRC_DIR += adc
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_RESOURCES_DAC),y)
|
||||
SRC_DIR += dac
|
||||
endif
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
|
||||
3
Ubiquitous/XiUOS/resources/adc/Makefile
Normal file
3
Ubiquitous/XiUOS/resources/adc/Makefile
Normal file
@@ -0,0 +1,3 @@
|
||||
SRC_FILES += dev_adc.c drv_adc.c bus_adc.c
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
122
Ubiquitous/XiUOS/resources/adc/bus_adc.c
Normal file
122
Ubiquitous/XiUOS/resources/adc/bus_adc.c
Normal file
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
* 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;
|
||||
}
|
||||
119
Ubiquitous/XiUOS/resources/adc/dev_adc.c
Normal file
119
Ubiquitous/XiUOS/resources/adc/dev_adc.c
Normal file
@@ -0,0 +1,119 @@
|
||||
/*
|
||||
* 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;
|
||||
}
|
||||
69
Ubiquitous/XiUOS/resources/adc/drv_adc.c
Normal file
69
Ubiquitous/XiUOS/resources/adc/drv_adc.c
Normal file
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* 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;
|
||||
}
|
||||
3
Ubiquitous/XiUOS/resources/dac/Makefile
Normal file
3
Ubiquitous/XiUOS/resources/dac/Makefile
Normal file
@@ -0,0 +1,3 @@
|
||||
SRC_FILES += dev_dac.c drv_dac.c bus_dac.c
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
122
Ubiquitous/XiUOS/resources/dac/bus_dac.c
Normal file
122
Ubiquitous/XiUOS/resources/dac/bus_dac.c
Normal file
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
* 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_dac.c
|
||||
* @brief register dac bus function using bus driver framework
|
||||
* @version 2.0
|
||||
* @author AIIT XUOS Lab
|
||||
* @date 2022-1-11
|
||||
*/
|
||||
|
||||
#include <bus_dac.h>
|
||||
#include <dev_dac.h>
|
||||
|
||||
/*Register the DAC BUS*/
|
||||
int DacBusInit(struct DacBus *dac_bus, const char *bus_name)
|
||||
{
|
||||
NULL_PARAM_CHECK(dac_bus);
|
||||
NULL_PARAM_CHECK(bus_name);
|
||||
|
||||
x_err_t ret = EOK;
|
||||
|
||||
if (BUS_INSTALL != dac_bus->bus.bus_state) {
|
||||
strncpy(dac_bus->bus.bus_name, bus_name, NAME_NUM_MAX);
|
||||
|
||||
dac_bus->bus.bus_type = TYPE_DAC_BUS;
|
||||
dac_bus->bus.bus_state = BUS_INSTALL;
|
||||
dac_bus->bus.private_data = dac_bus->private_data;
|
||||
|
||||
ret = BusRegister(&dac_bus->bus);
|
||||
if (EOK != ret) {
|
||||
KPrintf("DacBusInit BusRegister error %u\n", ret);
|
||||
return ret;
|
||||
}
|
||||
} else {
|
||||
KPrintf("DacBusInit BusRegister bus has been register state%u\n", dac_bus->bus.bus_state);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*Register the DAC Driver*/
|
||||
int DacDriverInit(struct DacDriver *dac_driver, const char *driver_name)
|
||||
{
|
||||
NULL_PARAM_CHECK(dac_driver);
|
||||
NULL_PARAM_CHECK(driver_name);
|
||||
|
||||
x_err_t ret = EOK;
|
||||
|
||||
if (DRV_INSTALL != dac_driver->driver.driver_state) {
|
||||
dac_driver->driver.driver_type = TYPE_DAC_DRV;
|
||||
dac_driver->driver.driver_state = DRV_INSTALL;
|
||||
|
||||
strncpy(dac_driver->driver.drv_name, driver_name, NAME_NUM_MAX);
|
||||
|
||||
dac_driver->driver.configure = dac_driver->configure;
|
||||
dac_driver->driver.private_data = dac_driver->private_data;
|
||||
|
||||
ret = DacDriverRegister(&dac_driver->driver);
|
||||
if (EOK != ret) {
|
||||
KPrintf("DacDriverInit DriverRegister error %u\n", ret);
|
||||
return ret;
|
||||
}
|
||||
} else {
|
||||
KPrintf("DacDriverInit DriverRegister driver has been register state%u\n", dac_driver->driver.driver_state);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*Release the DAC device*/
|
||||
int DacReleaseBus(struct DacBus *dac_bus)
|
||||
{
|
||||
NULL_PARAM_CHECK(dac_bus);
|
||||
|
||||
return BusRelease(&dac_bus->bus);
|
||||
}
|
||||
|
||||
/*Register the DAC Driver to the DAC BUS*/
|
||||
int DacDriverAttachToBus(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("DacDriverAttachToBus find dac bus error!name %s\n", bus_name);
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
if (TYPE_DAC_BUS == bus->bus_type) {
|
||||
driver = DacDriverFind(drv_name, TYPE_DAC_DRV);
|
||||
if (NONE == driver) {
|
||||
KPrintf("DacDriverAttachToBus find dac driver error!name %s\n", drv_name);
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
if (TYPE_DAC_DRV == driver->driver_type) {
|
||||
ret = DriverRegisterToBus(bus, driver);
|
||||
if (EOK != ret) {
|
||||
KPrintf("DacDriverAttachToBus DriverRegisterToBus error %u\n", ret);
|
||||
return ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
119
Ubiquitous/XiUOS/resources/dac/dev_dac.c
Normal file
119
Ubiquitous/XiUOS/resources/dac/dev_dac.c
Normal file
@@ -0,0 +1,119 @@
|
||||
/*
|
||||
* 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_dac.c
|
||||
* @brief register dac dev function using bus driver framework
|
||||
* @version 1.1
|
||||
* @author AIIT XUOS Lab
|
||||
* @date 2021-12-28
|
||||
*/
|
||||
|
||||
#include <bus_dac.h>
|
||||
#include <dev_dac.h>
|
||||
|
||||
static DoubleLinklistType dacdev_linklist;
|
||||
|
||||
/*Create the DAC device linklist*/
|
||||
static void DacDeviceLinkInit()
|
||||
{
|
||||
InitDoubleLinkList(&dacdev_linklist);
|
||||
}
|
||||
|
||||
/*Find the register DAC device*/
|
||||
HardwareDevType DacDeviceFind(const char *dev_name, enum DevType dev_type)
|
||||
{
|
||||
NULL_PARAM_CHECK(dev_name);
|
||||
|
||||
struct HardwareDev *device = NONE;
|
||||
|
||||
DoubleLinklistType *node = NONE;
|
||||
DoubleLinklistType *head = &dacdev_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("DacDeviceFind dacnot find the %s device.return NULL\n", dev_name);
|
||||
return NONE;
|
||||
}
|
||||
|
||||
/*Register the DAC device*/
|
||||
int DacDeviceRegister(struct DacHardwareDevice *dac_device, void *dac_param, const char *device_name)
|
||||
{
|
||||
NULL_PARAM_CHECK(dac_device);
|
||||
NULL_PARAM_CHECK(device_name);
|
||||
|
||||
x_err_t ret = EOK;
|
||||
static x_bool dev_link_flag = RET_FALSE;
|
||||
|
||||
if (!dev_link_flag) {
|
||||
DacDeviceLinkInit();
|
||||
dev_link_flag = RET_TRUE;
|
||||
}
|
||||
|
||||
if (DEV_INSTALL != dac_device->haldev.dev_state) {
|
||||
strncpy(dac_device->haldev.dev_name, device_name, NAME_NUM_MAX);
|
||||
dac_device->haldev.dev_type = TYPE_DAC_DEV;
|
||||
dac_device->haldev.dev_state = DEV_INSTALL;
|
||||
|
||||
dac_device->haldev.dev_done = (struct HalDevDone *)dac_device->dac_dev_done;
|
||||
|
||||
dac_device->haldev.private_data = dac_param;
|
||||
|
||||
DoubleLinkListInsertNodeAfter(&dacdev_linklist, &(dac_device->haldev.dev_link));
|
||||
} else {
|
||||
KPrintf("DacDeviceRegister device has been register state%u\n", dac_device->haldev.dev_state);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*Register the DAC Device to the DAC BUS*/
|
||||
int DacDeviceAttachToBus(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("DacDeviceAttachToBus find dac bus error!name %s\n", bus_name);
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
if (TYPE_DAC_BUS == bus->bus_type) {
|
||||
device = DacDeviceFind(dev_name, TYPE_DAC_DEV);
|
||||
|
||||
if (NONE == device) {
|
||||
KPrintf("DacDeviceAttachToBus find dac device error!name %s\n", dev_name);
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
if (TYPE_DAC_DEV == device->dev_type) {
|
||||
ret = DeviceRegisterToBus(bus, device);
|
||||
|
||||
if (EOK != ret) {
|
||||
KPrintf("DacDeviceAttachToBus DeviceRegisterToBus error %u\n", ret);
|
||||
return ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return EOK;
|
||||
}
|
||||
69
Ubiquitous/XiUOS/resources/dac/drv_dac.c
Normal file
69
Ubiquitous/XiUOS/resources/dac/drv_dac.c
Normal file
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* 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_dac.c
|
||||
* @brief register dac drv function using bus driver framework
|
||||
* @version 2.0
|
||||
* @author AIIT XUOS Lab
|
||||
* @date 2022-1-11
|
||||
*/
|
||||
|
||||
#include <bus_dac.h>
|
||||
#include <dev_dac.h>
|
||||
|
||||
static DoubleLinklistType dacdrv_linklist;
|
||||
|
||||
/*Create the driver linklist*/
|
||||
static void DacDrvLinkInit()
|
||||
{
|
||||
InitDoubleLinkList(&dacdrv_linklist);
|
||||
}
|
||||
|
||||
/*Find the regiter driver*/
|
||||
DriverType DacDriverFind(const char *drv_name, enum DriverType_e drv_type)
|
||||
{
|
||||
NULL_PARAM_CHECK(drv_name);
|
||||
|
||||
struct Driver *driver = NONE;
|
||||
|
||||
DoubleLinklistType *node = NONE;
|
||||
DoubleLinklistType *head = &dacdrv_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("DacDriverFind cannot find the %s driver.return NULL\n", drv_name);
|
||||
return NONE;
|
||||
}
|
||||
|
||||
/*Register the Driver, manage with the double linklist*/
|
||||
int DacDriverRegister(struct Driver *driver)
|
||||
{
|
||||
NULL_PARAM_CHECK(driver);
|
||||
|
||||
x_err_t ret = EOK;
|
||||
static x_bool driver_link_flag = RET_FALSE;
|
||||
|
||||
if (!driver_link_flag) {
|
||||
DacDrvLinkInit();
|
||||
driver_link_flag = RET_TRUE;
|
||||
}
|
||||
|
||||
DoubleLinkListInsertNodeAfter(&dacdrv_linklist, &(driver->driver_link));
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -81,20 +81,13 @@
|
||||
#include "enet_ethernetif.h"
|
||||
#include <transform.h>
|
||||
|
||||
/* MAC address configuration. */
|
||||
#define configMAC_ADDR { 0x02, 0x12, 0x13, 0x10, 0x15, 0x11}
|
||||
|
||||
char lwip_ipaddr[] = {192, 168, 250, 253};
|
||||
char lwip_netmask[] = {255, 255, 255, 0};
|
||||
char lwip_gwaddr[] = {192, 168, 250, 252};
|
||||
|
||||
int errno;
|
||||
int is_lwip_test = 0; //for lwip input thread
|
||||
char lwip_flag = 0;
|
||||
|
||||
x_ticks_t lwip_sys_now;
|
||||
|
||||
static int lwip_init_flag = 0;
|
||||
|
||||
struct sys_timeouts {
|
||||
struct sys_timeo *next;
|
||||
};
|
||||
@@ -389,7 +382,7 @@ ip4_addr_t ipaddr;
|
||||
ip4_addr_t netmask;
|
||||
ip4_addr_t gw;
|
||||
|
||||
void TcpIpInit(void)
|
||||
void lwip_tcp_init(void)
|
||||
{
|
||||
tcpip_init(NULL, NULL);
|
||||
|
||||
@@ -400,14 +393,9 @@ void TcpIpInit(void)
|
||||
ip_addr_set_zero_ip4(&netmask);
|
||||
ip_addr_set_zero_ip4(&gw);
|
||||
#else
|
||||
#ifdef SET_AS_SERVER
|
||||
IP4_ADDR(&ipaddr,IP_ADDR0_SERVER,IP_ADDR1_SERVER,IP_ADDR2_SERVER,IP_ADDR3_SERVER);
|
||||
#else
|
||||
IP4_ADDR(&ipaddr,IP_ADDR0_ClIENT,IP_ADDR1_ClIENT,IP_ADDR2_ClIENT,IP_ADDR3_ClIENT);
|
||||
#endif
|
||||
|
||||
IP4_ADDR(&netmask,NETMASK_ADDR0,NETMASK_ADDR1,NETMASK_ADDR2,NETMASK_ADDR3);
|
||||
IP4_ADDR(&gw,GW_ADDR0,GW_ADDR1,GW_ADDR2,GW_ADDR3);
|
||||
IP4_ADDR(&ipaddr, lwip_ipaddr[0], lwip_ipaddr[1], lwip_ipaddr[2], lwip_ipaddr[3]);
|
||||
IP4_ADDR(&netmask, lwip_netmask[0], lwip_netmask[1], lwip_netmask[2], lwip_netmask[3]);
|
||||
IP4_ADDR(&gw, lwip_gwaddr[0], lwip_gwaddr[1], lwip_gwaddr[2], lwip_gwaddr[3]);
|
||||
#endif /* USE_DHCP */
|
||||
/* USER CODE END 0 */
|
||||
/* Initilialize the LwIP stack without RTOS */
|
||||
@@ -420,13 +408,13 @@ void TcpIpInit(void)
|
||||
if (netif_is_link_up(&gnetif))
|
||||
{
|
||||
/* When the netif is fully configured this function must be called */
|
||||
KPrintf("TcpIpInit : netif_set_up\n");
|
||||
KPrintf("%s : netif_set_up\n", __func__);
|
||||
netif_set_up(&gnetif);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* When the netif link is down this function must be called */
|
||||
KPrintf("TcpIpInit : netif_set_down\n");
|
||||
KPrintf("%s : netif_set_down\n", __func__);
|
||||
netif_set_down(&gnetif);
|
||||
}
|
||||
|
||||
@@ -462,10 +450,14 @@ void lwip_input_thread(void *param)
|
||||
|
||||
while (1)
|
||||
{
|
||||
/* Poll the driver, get any outstanding frames */
|
||||
ethernetif_input(net);
|
||||
sys_check_timeouts(); /* Handle all system timeouts for all core protocols */
|
||||
// DelayKTask(1);
|
||||
#ifdef FSL_RTOS_XIUOS
|
||||
if (lwip_obtain_semaphore(net) == EOK)
|
||||
#endif
|
||||
{
|
||||
/* Poll the driver, get any outstanding frames */
|
||||
ethernetif_input(net);
|
||||
sys_check_timeouts(); /* Handle all system timeouts for all core protocols */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -497,7 +489,7 @@ void lwip_config_net(char *ip, char *mask, char *gw)
|
||||
#endif /* FSL_FEATURE_SOC_LPC_ENET_COUNT */
|
||||
};
|
||||
|
||||
if(lwip_init_flag)
|
||||
if(chk_lwip_bit(LWIP_INIT_FLAG))
|
||||
{
|
||||
lw_print("lw: [%s] already ...\n", __func__);
|
||||
|
||||
@@ -505,6 +497,7 @@ void lwip_config_net(char *ip, char *mask, char *gw)
|
||||
IP4_ADDR(&net_netmask, mask[0], mask[1], mask[2], mask[3]);
|
||||
IP4_ADDR(&net_gw, gw[0], gw[1], gw[2], gw[3]);
|
||||
|
||||
// update ip addr
|
||||
netif_set_down(&gnetif);
|
||||
netif_set_gw(&gnetif, &net_gw);
|
||||
netif_set_netmask(&gnetif, &net_netmask);
|
||||
@@ -512,7 +505,7 @@ void lwip_config_net(char *ip, char *mask, char *gw)
|
||||
netif_set_up(&gnetif);
|
||||
return;
|
||||
}
|
||||
lwip_init_flag = 1;
|
||||
set_lwip_bit(LWIP_INIT_FLAG);
|
||||
|
||||
lw_print("lw: [%s] start ...\n", __func__);
|
||||
|
||||
@@ -527,7 +520,7 @@ void lwip_config_net(char *ip, char *mask, char *gw)
|
||||
netif_set_default(&gnetif);
|
||||
netif_set_up(&gnetif);
|
||||
|
||||
if(is_lwip_test)
|
||||
if(chk_lwip_bit(LWIP_PRINT_FLAG))
|
||||
{
|
||||
lw_pr_info("\r\n************************************************\r\n");
|
||||
lw_pr_info(" Network Configuration\r\n");
|
||||
@@ -558,12 +551,13 @@ void lwip_config_tcp(char *ip, char *mask, char *gw)
|
||||
#endif /* FSL_FEATURE_SOC_LPC_ENET_COUNT */
|
||||
};
|
||||
|
||||
if(lwip_init_flag)
|
||||
if(chk_lwip_bit(LWIP_INIT_FLAG))
|
||||
{
|
||||
lw_print("lw: [%s] already ...\n", __func__);
|
||||
return;
|
||||
}
|
||||
lwip_init_flag = 1;
|
||||
|
||||
set_lwip_bit(LWIP_INIT_FLAG);
|
||||
|
||||
tcpip_init(NULL, NULL);
|
||||
|
||||
|
||||
@@ -60,38 +60,18 @@
|
||||
|
||||
#include <xs_base.h>
|
||||
|
||||
/* USER CODE BEGIN 0 */
|
||||
// #define SET_AS_SERVER 1 /* define this terminal is udp server or not*/
|
||||
/* LWIP task parameter */
|
||||
#define LWIP_LOCAL_PORT 4840
|
||||
#define LWIP_TARGET_PORT LWIP_LOCAL_PORT
|
||||
|
||||
#define LOCAL_PORT_SERVER 4840
|
||||
#define TARGET_PORT_CLIENT LOCAL_PORT_SERVER
|
||||
#define LWIP_DEMO_TIMES 3
|
||||
#define LWIP_TASK_STACK_SIZE 4096
|
||||
#define LWIP_DEMO_TASK_PRIO 20
|
||||
|
||||
#define TEST_LWIP_TIMES 3
|
||||
/* MAC address configuration. */
|
||||
#define configMAC_ADDR {0x02, 0x12, 0x13, 0x10, 0x15, 0x11}
|
||||
|
||||
/*Static IP ADDRESS: IP_ADDR0.IP_ADDR1.IP_ADDR2.IP_ADDR3 */
|
||||
#define IP_ADDR0_SERVER 192
|
||||
#define IP_ADDR1_SERVER 168
|
||||
#define IP_ADDR2_SERVER 250
|
||||
#define IP_ADDR3_SERVER 252
|
||||
|
||||
#define IP_ADDR0_ClIENT 192
|
||||
#define IP_ADDR1_ClIENT 168
|
||||
#define IP_ADDR2_ClIENT 250
|
||||
#define IP_ADDR3_ClIENT 253
|
||||
|
||||
/*NETMASK*/
|
||||
#define NETMASK_ADDR0 255
|
||||
#define NETMASK_ADDR1 255
|
||||
#define NETMASK_ADDR2 255
|
||||
#define NETMASK_ADDR3 0
|
||||
|
||||
/*Gateway Address*/
|
||||
#define GW_ADDR0 192
|
||||
#define GW_ADDR1 168
|
||||
#define GW_ADDR2 250
|
||||
#define GW_ADDR3 5
|
||||
/* USER CODE END 0 */
|
||||
|
||||
#define SYS_MBOX_NULL -1
|
||||
#define SYS_SEM_NULL 0
|
||||
#define SYS_MRTEX_NULL SYS_SEM_NULL
|
||||
@@ -100,18 +80,28 @@ typedef int32 sys_sem_t;
|
||||
typedef int32 sys_mutex_t;
|
||||
typedef int32 sys_mbox_t;
|
||||
typedef int32 sys_thread_t;
|
||||
|
||||
typedef x_base sys_prot_t;
|
||||
|
||||
#define MS_PER_SYSTICK_F407 1000/TICK_PER_SECOND
|
||||
#define MS_PER_SYSTICK_F407 (1000 / TICK_PER_SECOND)
|
||||
|
||||
//debug rtos with IRQ
|
||||
//#define FSL_RTOS_XIUOS
|
||||
|
||||
extern char lwip_flag;
|
||||
|
||||
#define LWIP_INIT_FLAG (1 << 0)
|
||||
#define LWIP_PRINT_FLAG (1 << 1)
|
||||
|
||||
#define set_lwip_bit(__bit) lwip_flag |= (__bit)
|
||||
#define clr_lwip_bit(__bit) lwip_flag &= ~(__bit)
|
||||
#define chk_lwip_bit(__bit) ((lwip_flag & (__bit)) == (__bit))
|
||||
|
||||
extern char lwip_ipaddr[];
|
||||
extern char lwip_netmask[];
|
||||
extern char lwip_gwaddr[];
|
||||
extern int is_lwip_test;
|
||||
extern struct netif gnetif;
|
||||
|
||||
void TcpIpInit(void);
|
||||
void lwip_tcp_init(void);
|
||||
void lwip_config_net(char *ip, char *mask, char *gw);
|
||||
void lwip_config_tcp(char *ip, char *mask, char *gw);
|
||||
|
||||
|
||||
@@ -107,8 +107,10 @@ SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) |
|
||||
setip, lwip_setip_thread, SetIp [IP] [Netmask] [Gateway]);
|
||||
|
||||
|
||||
void lwip_getip_thread(int argc, char *argv[])
|
||||
void lwip_showip_thread(int argc, char *argv[])
|
||||
{
|
||||
char mac_addr[] = configMAC_ADDR;
|
||||
|
||||
lw_pr_info("\r\n************************************************\r\n");
|
||||
lw_pr_info(" Network Configuration\r\n");
|
||||
lw_pr_info("************************************************\r\n");
|
||||
@@ -118,10 +120,12 @@ void lwip_getip_thread(int argc, char *argv[])
|
||||
((u8_t *)&lwip_netmask)[2], ((u8_t *)&lwip_netmask)[3]);
|
||||
lw_pr_info(" IPv4 Gateway : %u.%u.%u.%u\r\n", ((u8_t *)&lwip_gwaddr)[0], ((u8_t *)&lwip_gwaddr)[1],
|
||||
((u8_t *)&lwip_gwaddr)[2], ((u8_t *)&lwip_gwaddr)[3]);
|
||||
lw_pr_info(" MAC Address : %x:%x:%x:%x:%x:%x\r\n", mac_addr[0], mac_addr[1], mac_addr[2],
|
||||
mac_addr[3], mac_addr[4], mac_addr[5]);
|
||||
lw_pr_info("************************************************\r\n");
|
||||
}
|
||||
|
||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) | SHELL_CMD_PARAM_NUM(0),
|
||||
showip, lwip_getip_thread, GetIp [IP] [Netmask] [Gateway]);
|
||||
showip, lwip_showip_thread, GetIp [IP] [Netmask] [Gateway]);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#ifndef __LWIP_DEMO_H__
|
||||
#define __LWIP_DEMO_H__
|
||||
|
||||
void *eth_input_thread(void *param);
|
||||
#define LWIP_TEST_STACK_SIZE 4096
|
||||
#define LWIP_TEST_TASK_PRIO 20
|
||||
|
||||
#endif /* __LWIP_DEMO_H__ */
|
||||
|
||||
@@ -133,7 +133,7 @@ void lwip_dhcp_test(void)
|
||||
ETH_BSP_Config();
|
||||
|
||||
lwip_config_net(ip_addr, ip_addr, ip_addr);
|
||||
is_lwip_test = 1;
|
||||
set_lwip_bit(LWIP_PRINT_FLAG);
|
||||
|
||||
dhcp_start(&gnetif);
|
||||
|
||||
@@ -167,7 +167,7 @@ void lwip_dhcp_test(void)
|
||||
}
|
||||
}
|
||||
|
||||
is_lwip_test = 0;
|
||||
clr_lwip_bit(LWIP_PRINT_FLAG);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -101,11 +101,13 @@ void lwip_ping_thread(int argc, char *argv[])
|
||||
return;
|
||||
}
|
||||
}
|
||||
#if (LWIP_DHCP) && (PING_USE_SOCKETS)
|
||||
else
|
||||
{
|
||||
get_url_ip(argv[1]);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
lw_print("lw: [%s] argc %d\n", __func__, argc);
|
||||
|
||||
@@ -29,6 +29,8 @@
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
|
||||
#define MSG_SIZE 128
|
||||
|
||||
/*******************************************************************************
|
||||
* Prototypes
|
||||
******************************************************************************/
|
||||
@@ -37,10 +39,9 @@
|
||||
* Variables
|
||||
******************************************************************************/
|
||||
|
||||
char tcp_target[] = {192, 168, 250, 252};
|
||||
#define MSG_SIZE 128
|
||||
// this is for test in shell, in fact, shell restrict the length of input string, which is less then 128
|
||||
char tcp_send_msg[MSG_SIZE] = {0};
|
||||
char tcp_target[] = {192, 168, 250, 252};
|
||||
|
||||
/*******************************************************************************
|
||||
* Code
|
||||
@@ -60,7 +61,7 @@ static void lwip_tcp_send_thread(void *arg)
|
||||
|
||||
struct sockaddr_in tcp_sock;
|
||||
tcp_sock.sin_family = AF_INET;
|
||||
tcp_sock.sin_port = htons(TARGET_PORT_CLIENT);
|
||||
tcp_sock.sin_port = htons(LWIP_TARGET_PORT);
|
||||
tcp_sock.sin_addr.s_addr = PP_HTONL(LWIP_MAKEU32(tcp_target[0], tcp_target[1], tcp_target[2], tcp_target[3]));
|
||||
memset(&(tcp_sock.sin_zero), 0, sizeof(tcp_sock.sin_zero));
|
||||
|
||||
@@ -104,7 +105,7 @@ void lwip_tcp_send_run(int argc, char *argv[])
|
||||
|
||||
ETH_BSP_Config();
|
||||
lwip_config_tcp(lwip_ipaddr, lwip_netmask, lwip_gwaddr);
|
||||
sys_thread_new("tcp send", lwip_tcp_send_thread, NULL, 4096, 25);
|
||||
sys_thread_new("tcp send", lwip_tcp_send_thread, NULL, LWIP_TASK_STACK_SIZE, LWIP_DEMO_TASK_PRIO);
|
||||
}
|
||||
|
||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) | SHELL_CMD_PARAM_NUM(3),
|
||||
|
||||
@@ -53,7 +53,7 @@ char udp_send_msg[] = "\n\nThis one is UDP pkg. Congratulations on you.\n\n";
|
||||
|
||||
static void lwip_udp_send(void *arg)
|
||||
{
|
||||
int cnt = TEST_LWIP_TIMES;
|
||||
int cnt = LWIP_DEMO_TIMES;
|
||||
|
||||
lw_print("udp_send_demo start.\n");
|
||||
|
||||
@@ -67,7 +67,7 @@ static void lwip_udp_send(void *arg)
|
||||
|
||||
struct sockaddr_in udp_sock;
|
||||
udp_sock.sin_family = AF_INET;
|
||||
udp_sock.sin_port = htons(TARGET_PORT_CLIENT);
|
||||
udp_sock.sin_port = htons(LWIP_TARGET_PORT);
|
||||
udp_sock.sin_addr.s_addr = PP_HTONL(LWIP_MAKEU32(udp_target[0],udp_target[1],udp_target[2],udp_target[3]));
|
||||
memset(&(udp_sock.sin_zero), 0, sizeof(udp_sock.sin_zero));
|
||||
|
||||
@@ -170,7 +170,7 @@ void udpecho_raw_init(void)
|
||||
return;
|
||||
}
|
||||
|
||||
err = udp_bind(udpecho_raw_pcb, IP_ANY_TYPE, LOCAL_PORT_SERVER);
|
||||
err = udp_bind(udpecho_raw_pcb, IP_ANY_TYPE, LWIP_LOCAL_PORT);
|
||||
if (err == ERR_OK)
|
||||
{
|
||||
udp_recv(udpecho_raw_pcb, udpecho_raw_recv, NULL);
|
||||
|
||||
@@ -105,10 +105,6 @@ static u32_t ping_time;
|
||||
static struct raw_pcb *ping_pcb;
|
||||
#endif /* PING_USE_SOCKETS */
|
||||
|
||||
#define PING_THREAD_STACKSIZE 4096
|
||||
#define PING_THREAD_PRIO 15
|
||||
|
||||
|
||||
/** Prepare a echo ICMP request */
|
||||
static void
|
||||
ping_prepare_echo( struct icmp_echo_hdr *iecho, u16_t len)
|
||||
@@ -248,7 +244,7 @@ ping_thread(void *arg)
|
||||
{
|
||||
int s;
|
||||
int ret;
|
||||
int cnt = TEST_LWIP_TIMES;
|
||||
int cnt = LWIP_DEMO_TIMES;
|
||||
|
||||
#if LWIP_SO_SNDRCVTIMEO_NONSTANDARD
|
||||
int timeout = PING_RCV_TIMEO;
|
||||
@@ -268,7 +264,7 @@ ping_thread(void *arg)
|
||||
s = lwip_socket(AF_INET6, SOCK_RAW, IP6_NEXTH_ICMP6);
|
||||
}
|
||||
#else
|
||||
s = lwip_socket(AF_INET, SOCK_RAW, IP_PROTO_ICMP);
|
||||
s = lwip_socket(AF_INET, SOCK_RAW, IP_PROTO_ICMP);
|
||||
#endif
|
||||
if (s < 0) {
|
||||
lw_print("lw: [%s] ping failed %d!\n", __func__, s);
|
||||
@@ -367,7 +363,7 @@ ping_send(struct raw_pcb *raw, const ip_addr_t *addr)
|
||||
static void
|
||||
ping_timeout(void *arg)
|
||||
{
|
||||
static int cnt = TEST_LWIP_TIMES;
|
||||
static int cnt = LWIP_DEMO_TIMES;
|
||||
struct raw_pcb *pcb = (struct raw_pcb*)arg;
|
||||
|
||||
LWIP_ASSERT("ping_timeout: no pcb given!", pcb != NULL);
|
||||
@@ -380,7 +376,7 @@ ping_timeout(void *arg)
|
||||
}
|
||||
else
|
||||
{
|
||||
cnt = TEST_LWIP_TIMES;
|
||||
cnt = LWIP_DEMO_TIMES;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -412,7 +408,7 @@ ping_init(const ip_addr_t* ping_addr)
|
||||
ping_target = ping_addr;
|
||||
|
||||
#if PING_USE_SOCKETS
|
||||
th = sys_thread_new("ping_thread", ping_thread, NULL, PING_THREAD_STACKSIZE, PING_THREAD_PRIO);
|
||||
th = sys_thread_new("ping_thread", ping_thread, NULL, LWIP_TASK_STACK_SIZE, LWIP_DEMO_TASK_PRIO);
|
||||
lw_print("lw: [%s] new thread %d addr %#x\n", __func__, th, (*ping_addr).addr);
|
||||
#else /* PING_USE_SOCKETS */
|
||||
ping_raw_init();
|
||||
@@ -476,6 +472,7 @@ int lwip_ping_recv(int s, int *ttl)
|
||||
return len;
|
||||
}
|
||||
|
||||
#if (LWIP_DHCP) && (PING_USE_SOCKETS)
|
||||
int get_url_ip(char* url)
|
||||
{
|
||||
#if LWIP_VERSION_MAJOR >= 2U
|
||||
@@ -483,7 +480,7 @@ int get_url_ip(char* url)
|
||||
#else
|
||||
int timeout = PING_RCV_TIMEO * 1000UL / TICK_PER_SECOND;
|
||||
#endif
|
||||
int cnt = TEST_LWIP_TIMES;
|
||||
int cnt = LWIP_DEMO_TIMES;
|
||||
|
||||
int s, ttl, recv_len;
|
||||
ip_addr_t target_addr;
|
||||
@@ -539,6 +536,6 @@ int get_url_ip(char* url)
|
||||
lwip_close(s);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_RAW */
|
||||
|
||||
@@ -49,7 +49,10 @@
|
||||
|
||||
#if LWIP_TCP && LWIP_CALLBACK_API
|
||||
|
||||
#define MAX_TESTED_TCP_SEND_SIZE (56000)
|
||||
#define MAX_TCP_RECV_SIZE (56000)
|
||||
#define MAX_TCP_SHOW_SIZE 80
|
||||
#define TCP_ACK_MSG_SIZE 20
|
||||
#define TCP_EOF_CH '\n'
|
||||
|
||||
static struct tcp_pcb *tcpecho_raw_pcb;
|
||||
|
||||
@@ -109,70 +112,73 @@ tcpecho_raw_error(void *arg, err_t err)
|
||||
tcpecho_raw_free(es);
|
||||
}
|
||||
|
||||
#define SHELL_TCP_LENGTH 80
|
||||
char* recved_msg;
|
||||
int recved_msg_length;
|
||||
static void
|
||||
tcpecho_raw_ack_size(struct tcp_pcb *tpcb, int ack_len)
|
||||
{
|
||||
struct pbuf *ack_buf = NULL;
|
||||
|
||||
// ack message
|
||||
ack_buf = pbuf_alloc(PBUF_TRANSPORT, TCP_ACK_MSG_SIZE, PBUF_RAM);
|
||||
snprintf(ack_buf->payload, TCP_ACK_MSG_SIZE, "%d\n\0", ack_len);
|
||||
ack_buf->len = strlen(ack_buf->payload);
|
||||
ack_buf->tot_len = strlen(ack_buf->payload);
|
||||
ack_buf->next = NULL;
|
||||
|
||||
tcp_write(tpcb, ack_buf->payload, ack_buf->len, 1);
|
||||
pbuf_free(ack_buf);
|
||||
}
|
||||
|
||||
// compute received message length until '\n'
|
||||
static void record_msg(struct tcp_pcb *tpcb, struct tcpecho_raw_state* es){
|
||||
struct pbuf* ptr = es->p;
|
||||
int plen = ptr->len;
|
||||
if(es==NULL||ptr==NULL||plen==0){
|
||||
if(recved_msg){
|
||||
free(recved_msg);
|
||||
recved_msg = NULL;
|
||||
}
|
||||
recved_msg_length = 0;
|
||||
static void
|
||||
tcpecho_raw_ack(struct tcp_pcb *tpcb, struct tcpecho_raw_state* es){
|
||||
struct pbuf *ptr = es->p;
|
||||
char *recv_buf = ptr->payload;
|
||||
int recv_len = ptr->len;
|
||||
static char *g_buf = NULL; //global received buffer
|
||||
static int g_buf_size = 0;
|
||||
|
||||
lw_print("lw: [%s] recv %d tot %d next %p ref %d tye %d id %d %s\n", __func__, ptr->len, ptr->tot_len,
|
||||
ptr->next, ptr->ref, ptr->type_internal,
|
||||
ptr->if_idx, ptr->payload);
|
||||
|
||||
if(g_buf == NULL)
|
||||
{
|
||||
g_buf = (char *)malloc(MAX_TCP_RECV_SIZE);
|
||||
memset(g_buf, 0, MAX_TCP_RECV_SIZE);
|
||||
memcpy(g_buf, recv_buf, recv_len);
|
||||
}
|
||||
int new_size = plen+1;
|
||||
char* temp = recved_msg;
|
||||
if(temp!=NULL){
|
||||
new_size += strlen(temp);
|
||||
}
|
||||
recved_msg = malloc(new_size);
|
||||
memset(recved_msg, 0, new_size);
|
||||
if(temp!=NULL){
|
||||
memcpy(recved_msg,temp,strlen(temp));
|
||||
}
|
||||
memcpy(recved_msg+new_size-plen-1, ptr->payload, plen);
|
||||
free(temp);
|
||||
recved_msg_length += plen;
|
||||
if(recved_msg_length>=SHELL_TCP_LENGTH){
|
||||
if(recved_msg){
|
||||
free(recved_msg);
|
||||
recved_msg = NULL;
|
||||
else
|
||||
{
|
||||
if(g_buf_size + recv_len <= MAX_TCP_RECV_SIZE)
|
||||
{
|
||||
memcpy(g_buf + g_buf_size, recv_buf, recv_len);
|
||||
}
|
||||
}
|
||||
if(((char*)ptr->payload)[plen-1]=='\n'){
|
||||
if(recved_msg_length>MAX_TESTED_TCP_SEND_SIZE){
|
||||
KPrintf("Recved_msg_length is larger than %d, which may lead to unexpected exceptions.\n",MAX_TESTED_TCP_SEND_SIZE);
|
||||
}
|
||||
if(recved_msg_length<SHELL_TCP_LENGTH){
|
||||
KPrintf("Received: %s\n", recved_msg);
|
||||
KPrintf("Received: %s\n", recved_msg);
|
||||
g_buf_size += recv_len;
|
||||
|
||||
if((recv_len != TCP_MSS) || (recv_buf[recv_len - 1] == TCP_EOF_CH))
|
||||
{
|
||||
if(g_buf_size < MAX_TCP_SHOW_SIZE){
|
||||
lw_pr_info("Received: %s\n", g_buf);
|
||||
}else{
|
||||
KPrintf("Received a string of length %d\n", recved_msg_length);
|
||||
lw_pr_info("Received a string of length %d\n", g_buf_size);
|
||||
}
|
||||
struct pbuf* reply_pbuf = pbuf_alloc(PBUF_TRANSPORT, 20, PBUF_RAM); // only reply received message length
|
||||
sprintf(reply_pbuf->payload,"%d\n\0",recved_msg_length);
|
||||
reply_pbuf->len = strlen(reply_pbuf->payload);
|
||||
reply_pbuf->tot_len = strlen(reply_pbuf->payload);
|
||||
reply_pbuf->next = NULL;
|
||||
|
||||
tcp_write(tpcb, reply_pbuf->payload, reply_pbuf->len, 1);
|
||||
|
||||
pbuf_free(reply_pbuf);
|
||||
free(recved_msg);
|
||||
recved_msg = NULL;
|
||||
recved_msg_length = 0;
|
||||
|
||||
tcpecho_raw_ack_size(tpcb, g_buf_size);
|
||||
|
||||
free(g_buf);
|
||||
g_buf = NULL;
|
||||
g_buf_size = 0;
|
||||
}
|
||||
|
||||
es->p = ptr->next;
|
||||
if(es->p != NULL) {
|
||||
/* new reference! */
|
||||
pbuf_ref(es->p);
|
||||
}
|
||||
pbuf_free(ptr);
|
||||
tcp_recved(tpcb, plen);
|
||||
}
|
||||
tcp_recved(tpcb, recv_len);
|
||||
}
|
||||
|
||||
static err_t
|
||||
tcpecho_raw_poll(void *arg, struct tcp_pcb *tpcb)
|
||||
@@ -184,7 +190,7 @@ tcpecho_raw_poll(void *arg, struct tcp_pcb *tpcb)
|
||||
if (es != NULL) {
|
||||
if (es->p != NULL) {
|
||||
/* there is a remaining pbuf (chain) */
|
||||
record_msg(tpcb, es);
|
||||
tcpecho_raw_ack(tpcb, es);
|
||||
} else {
|
||||
/* no remaining pbuf (chain) */
|
||||
if(es->state == ES_CLOSING) {
|
||||
@@ -233,7 +239,7 @@ tcpecho_raw_recv(void *arg, struct tcp_pcb *tpcb, struct pbuf *p, err_t err)
|
||||
tcpecho_raw_close(tpcb, es);
|
||||
} else {
|
||||
/* we're not done yet */
|
||||
record_msg(tpcb, es);
|
||||
tcpecho_raw_ack(tpcb, es);
|
||||
}
|
||||
ret_err = ERR_OK;
|
||||
} else if(err != ERR_OK) {
|
||||
@@ -248,13 +254,13 @@ tcpecho_raw_recv(void *arg, struct tcp_pcb *tpcb, struct pbuf *p, err_t err)
|
||||
es->state = ES_RECEIVED;
|
||||
/* store reference to incoming pbuf (chain) */
|
||||
es->p = p;
|
||||
record_msg(tpcb, es);
|
||||
tcpecho_raw_ack(tpcb, es);
|
||||
ret_err = ERR_OK;
|
||||
} else if (es->state == ES_RECEIVED) {
|
||||
/* read some more data */
|
||||
if(es->p == NULL) {
|
||||
es->p = p;
|
||||
record_msg(tpcb, es);
|
||||
tcpecho_raw_ack(tpcb, es);
|
||||
} else {
|
||||
struct pbuf *ptr;
|
||||
|
||||
@@ -277,8 +283,6 @@ tcpecho_raw_accept(void *arg, struct tcp_pcb *newpcb, err_t err)
|
||||
{
|
||||
err_t ret_err;
|
||||
struct tcpecho_raw_state *es;
|
||||
recved_msg = NULL;
|
||||
recved_msg_length = 0;
|
||||
|
||||
LWIP_UNUSED_ARG(arg);
|
||||
if ((err != ERR_OK) || (newpcb == NULL)) {
|
||||
|
||||
@@ -52,6 +52,8 @@ enum BusType_e
|
||||
TYPE_PIN_BUS,
|
||||
TYPE_RTC_BUS,
|
||||
TYPE_SERIAL_BUS,
|
||||
TYPE_ADC_BUS,
|
||||
TYPE_DAC_BUS,
|
||||
TYPE_BUS_END,
|
||||
};
|
||||
|
||||
@@ -76,6 +78,8 @@ enum DevType
|
||||
TYPE_PIN_DEV,
|
||||
TYPE_RTC_DEV,
|
||||
TYPE_SERIAL_DEV,
|
||||
TYPE_ADC_DEV,
|
||||
TYPE_DAC_DEV,
|
||||
TYPE_DEV_END,
|
||||
};
|
||||
|
||||
@@ -100,6 +104,8 @@ enum DriverType_e
|
||||
TYPE_PIN_DRV,
|
||||
TYPE_RTC_DRV,
|
||||
TYPE_SERIAL_DRV,
|
||||
TYPE_ADC_DRV,
|
||||
TYPE_DAC_DRV,
|
||||
TYPE_DRV_END,
|
||||
};
|
||||
|
||||
|
||||
67
Ubiquitous/XiUOS/resources/include/bus_adc.h
Normal file
67
Ubiquitous/XiUOS/resources/include/bus_adc.h
Normal file
@@ -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 bus_adc.h
|
||||
* @brief define adc bus and drv function using bus driver framework
|
||||
* @version 1.1
|
||||
* @author AIIT XUOS Lab
|
||||
* @date 2021-12-28
|
||||
*/
|
||||
|
||||
#ifndef BUS_ADC_H
|
||||
#define BUS_ADC_H
|
||||
|
||||
#include <bus.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct AdcDriver
|
||||
{
|
||||
struct Driver driver;
|
||||
uint32 (*configure) (void *drv, struct BusConfigureInfo *configure_info);
|
||||
|
||||
void *private_data;
|
||||
};
|
||||
|
||||
struct AdcBus
|
||||
{
|
||||
struct Bus bus;
|
||||
|
||||
void *private_data;
|
||||
};
|
||||
|
||||
/*Register the ADC bus*/
|
||||
int AdcBusInit(struct AdcBus *adc_bus, const char *bus_name);
|
||||
|
||||
/*Register the ADC driver*/
|
||||
int AdcDriverInit(struct AdcDriver *adc_driver, const char *driver_name);
|
||||
|
||||
/*Release the ADC device*/
|
||||
int AdcReleaseBus(struct AdcBus *adc_bus);
|
||||
|
||||
/*Register the ADC driver to the ADC bus*/
|
||||
int AdcDriverAttachToBus(const char *drv_name, const char *bus_name);
|
||||
|
||||
/*Register the driver, manage with the double linklist*/
|
||||
int AdcDriverRegister(struct Driver *driver);
|
||||
|
||||
/*Find the register driver*/
|
||||
DriverType AdcDriverFind(const char *drv_name, enum DriverType_e drv_type);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
67
Ubiquitous/XiUOS/resources/include/bus_dac.h
Normal file
67
Ubiquitous/XiUOS/resources/include/bus_dac.h
Normal file
@@ -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 bus_dac.h
|
||||
* @brief define dac bus and drv function using bus driver framework
|
||||
* @version 2.0
|
||||
* @author AIIT XUOS Lab
|
||||
* @date 2022-1-11
|
||||
*/
|
||||
|
||||
#ifndef BUS_DAC_H
|
||||
#define BUS_DAC_H
|
||||
|
||||
#include <bus.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct DacDriver
|
||||
{
|
||||
struct Driver driver;
|
||||
uint32 (*configure) (void *drv, struct BusConfigureInfo *configure_info);
|
||||
|
||||
void *private_data;
|
||||
};
|
||||
|
||||
struct DacBus
|
||||
{
|
||||
struct Bus bus;
|
||||
|
||||
void *private_data;
|
||||
};
|
||||
|
||||
/*Register the DAC bus*/
|
||||
int DacBusInit(struct DacBus *dac_bus, const char *bus_name);
|
||||
|
||||
/*Register the DAC driver*/
|
||||
int DacDriverInit(struct DacDriver *dac_driver, const char *driver_name);
|
||||
|
||||
/*Release the DAC device*/
|
||||
int DacReleaseBus(struct DacBus *dac_bus);
|
||||
|
||||
/*Register the DAC driver to the DAC bus*/
|
||||
int DacDriverAttachToBus(const char *drv_name, const char *bus_name);
|
||||
|
||||
/*Register the driver, manage with the double linklist*/
|
||||
int DacDriverRegister(struct Driver *driver);
|
||||
|
||||
/*Find the register driver*/
|
||||
DriverType DacDriverFind(const char *drv_name, enum DriverType_e drv_type);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
61
Ubiquitous/XiUOS/resources/include/dev_adc.h
Normal file
61
Ubiquitous/XiUOS/resources/include/dev_adc.h
Normal file
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* 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.h
|
||||
* @brief define adc dev function using bus driver framework
|
||||
* @version 1.1
|
||||
* @author AIIT XUOS Lab
|
||||
* @date 2021-12-28
|
||||
*/
|
||||
|
||||
#ifndef DEV_ADC_H
|
||||
#define DEV_ADC_H
|
||||
|
||||
#include <bus.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct AdcHardwareDevice;
|
||||
|
||||
struct AdcDevDone
|
||||
{
|
||||
uint32 (*open) (void *dev);
|
||||
uint32 (*close) (void *dev);
|
||||
uint32 (*write) (void *dev,struct BusBlockWriteParam *write_param);
|
||||
uint32 (*read) (void *dev, struct BusBlockReadParam *read_param);
|
||||
};
|
||||
|
||||
struct AdcHardwareDevice
|
||||
{
|
||||
struct HardwareDev haldev;
|
||||
const struct AdcDevDone *adc_dev_done;
|
||||
|
||||
void *private_data;
|
||||
};
|
||||
|
||||
/*Register the ADC device*/
|
||||
int AdcDeviceRegister(struct AdcHardwareDevice *adc_device, void *adc_param, const char *device_name);
|
||||
|
||||
/*Register the ADC device to the ADC bus*/
|
||||
int AdcDeviceAttachToBus(const char *dev_name, const char *bus_name);
|
||||
|
||||
/*Find the register ADC device*/
|
||||
HardwareDevType AdcDeviceFind(const char *dev_name, enum DevType dev_type);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
61
Ubiquitous/XiUOS/resources/include/dev_dac.h
Normal file
61
Ubiquitous/XiUOS/resources/include/dev_dac.h
Normal file
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* 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_dac.h
|
||||
* @brief define dac dev function using bus driver framework
|
||||
* @version 2.0
|
||||
* @author AIIT XUOS Lab
|
||||
* @date 2022-1-11
|
||||
*/
|
||||
|
||||
#ifndef DEV_DAC_H
|
||||
#define DEV_DAC_H
|
||||
|
||||
#include <bus.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct DacHardwareDevice;
|
||||
|
||||
struct DacDevDone
|
||||
{
|
||||
uint32 (*open) (void *dev);
|
||||
uint32 (*close) (void *dev);
|
||||
uint32 (*write) (void *dev,struct BusBlockWriteParam *write_param);
|
||||
uint32 (*read) (void *dev, struct BusBlockReadParam *read_param);
|
||||
};
|
||||
|
||||
struct DacHardwareDevice
|
||||
{
|
||||
struct HardwareDev haldev;
|
||||
const struct DacDevDone *dac_dev_done;
|
||||
|
||||
void *private_data;
|
||||
};
|
||||
|
||||
/*Register the DAC device*/
|
||||
int DacDeviceRegister(struct DacHardwareDevice *dac_device, void *dac_param, const char *device_name);
|
||||
|
||||
/*Register the DAC device to the DAC bus*/
|
||||
int DacDeviceAttachToBus(const char *dev_name, const char *bus_name);
|
||||
|
||||
/*Find the register DAC device*/
|
||||
HardwareDevType DacDeviceFind(const char *dev_name, enum DevType dev_type);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -94,4 +94,14 @@ HardwareDevType ObtainConsole(void);
|
||||
#include <dev_hwtimer.h>
|
||||
#endif
|
||||
|
||||
#ifdef RESOURCES_ADC
|
||||
#include <bus_adc.h>
|
||||
#include <dev_adc.h>
|
||||
#endif
|
||||
|
||||
#ifdef RESOURCES_DAC
|
||||
#include <bus_dac.h>
|
||||
#include <dev_dac.h>
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -303,6 +303,7 @@ static inline int SerialDevDMARead(struct SerialHardwareDevice *serial_dev, stru
|
||||
serial_dev->serial_fifo.serial_rx->serial_rx_buffer, read_dma_length + serial_dev->serial_fifo.serial_rx->serial_recv_num - serial_cfg->data_cfg.serial_buffer_size);
|
||||
}
|
||||
SerialDmaRxSetRecvLength(serial_dev, read_dma_length);
|
||||
read_param->read_length = read_dma_length;
|
||||
CriticalAreaUnLock(lock);
|
||||
return EOK;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user