feat add winddirection_qs_fx and windspeed_qs_fs for sensor framework

This commit is contained in:
Liu_Weichao 2022-03-08 16:15:38 +08:00
parent a35e73e7dd
commit 6be4d4b5ca
23 changed files with 649 additions and 8 deletions

View File

@ -36,6 +36,8 @@ extern int As830Ch4Init(void);
extern int Tb600bIaq10IaqInit(void);
extern int Tb600bTvoc10TvocInit(void);
extern int Tb600bWqHcho1osInit(void);
extern int QsFxWindDirectionInit(void);
extern int QsFsWindSpeedInit(void);
extern int lv_port_init(void);
@ -104,6 +106,14 @@ static struct InitDesc sensor_desc[] =
{ "zg09_co2", Zg09Co2Init },
#endif
#ifdef SENSOR_QS_FX
{ "qs_fx_wind_direction", QsFxWindDirectionInit },
#endif
#ifdef SENSOR_QS_FS
{ "qs_fs_wind_speed", QsFsWindSpeedInit },
#endif
#ifdef SENSOR_AS830
{ "ch4_as830", As830Ch4Init },
#endif

View File

@ -122,7 +122,26 @@ menu "sensor app"
endif
endif
menuconfig APPLICATION_SENSOR_WINDDIRECTION
bool "Using sensor wind direction apps"
default n
if APPLICATION_SENSOR_WINDDIRECTION
config APPLICATION_SENSOR_WINDDIRECTION_QS_FX
bool "Using sensor QS-FX apps"
default n
endif
menuconfig APPLICATION_SENSOR_WINDSPEED
bool "Using sensor wind speed apps"
default n
if APPLICATION_SENSOR_WINDSPEED
config APPLICATION_SENSOR_WINDSPEED_QS_FS
bool "Using sensor QS-FS apps"
default n
endif
endif
endmenu

View File

@ -98,6 +98,14 @@ ifeq ($(CONFIG_ADD_XIZI_FETURES),y)
SRC_FILES += temperature_hs300x.c
endif
ifeq ($(CONFIG_APPLICATION_SENSOR_WINDDIRECTION_QS_FX), y)
SRC_FILES += winddirection_qs_fx.c
endif
ifeq ($(CONFIG_APPLICATION_SENSOR_WINDSPEED_QS_FS), y)
SRC_FILES += windspeed_qs_fs.c
endif
include $(KERNEL_ROOT)/compiler.mk
endif

View File

@ -0,0 +1,38 @@
/*
* Copyright (c) 2020 AIIT XUOS Lab
* XiOS 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 winddirection_qs_fx.c
* @brief qs-fx wind direction example
* @version 1.1
* @author AIIT XUOS Lab
* @date 2021.12.14
*/
#include <transform.h>
#include <sensor.h>
/**
* @description: Read a wind direction
* @return 0
*/
void WindDirectionQsFx(void)
{
struct SensorQuantity *wind_direction = SensorQuantityFind(SENSOR_QUANTITY_QS_FX_WINDDIRECTION, SENSOR_QUANTITY_WINDDIRECTION);
SensorQuantityOpen(wind_direction);
PrivTaskDelay(2000);
uint16 result = SensorQuantityRead(wind_direction);
printf("wind direction : %d degree\n", result);
SensorQuantityClose(wind_direction);
}
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0)|SHELL_CMD_DISABLE_RETURN, WindDirectionQsFx, WindDirectionQsFx, WindDirectionQsFx function);

View File

@ -0,0 +1,38 @@
/*
* Copyright (c) 2020 AIIT XUOS Lab
* XiOS 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 windspeed_qs_fs.c
* @brief qs-fx wind direction example
* @version 1.1
* @author AIIT XUOS Lab
* @date 2021.12.14
*/
#include <transform.h>
#include <sensor.h>
/**
* @description: Read a wind speed
* @return 0
*/
void WindSpeedQsFs(void)
{
struct SensorQuantity *wind_speed = SensorQuantityFind(SENSOR_QUANTITY_QS_FS_WINDSPEED, SENSOR_QUANTITY_WINDSPEED);
SensorQuantityOpen(wind_speed);
PrivTaskDelay(2000);
uint16 result = SensorQuantityRead(wind_speed);
printf("wind speed : %d.%d m/s\n", result/10, result%10);
SensorQuantityClose(wind_speed);
}
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0)|SHELL_CMD_DISABLE_RETURN, WindSpeedQsFs, WindSpeedQsFs, WindSpeedQsFs function);

View File

@ -66,4 +66,18 @@ if SUPPORT_SENSOR_FRAMEWORK
if SENSOR_HUMIDITY
source "$APP_DIR/Framework/sensor/humidity/Kconfig"
endif
menuconfig SENSOR_WINDSPEED
bool "Using wind speed sensor device"
default n
if SENSOR_WINDSPEED
source "$APP_DIR/Framework/sensor/windspeed/Kconfig"
endif
menuconfig SENSOR_WINDDIRECTION
bool "Using wind direction sensor device"
default n
if SENSOR_WINDDIRECTION
source "$APP_DIR/Framework/sensor/winddirection/Kconfig"
endif
endif

View File

@ -45,5 +45,13 @@ ifeq ($(CONFIG_ADD_XIZI_FETURES),y)
SRC_DIR += humidity
endif
ifeq ($(CONFIG_SENSOR_WINDSPEED),y)
SRC_DIR += windspeed
endif
ifeq ($(CONFIG_SENSOR_WINDDIRECTION),y)
SRC_DIR += winddirection
endif
include $(KERNEL_ROOT)/compiler.mk
endif

View File

@ -55,6 +55,8 @@ extern "C" {
#define SENSOR_ABILITY_IAQ ((uint32_t)(1 << SENSOR_QUANTITY_IAQ))
#define SENSOR_ABILITY_TVOC ((uint32_t)(1 << SENSOR_QUANTITY_TVOC))
#define SENSOR_ABILITY_HCHO ((uint32_t)(1 << SENSOR_QUANTITY_HCHO))
#define SENSOR_ABILITY_WINDSPEED ((uint32_t)(1 << SENSOR_QUANTITY_WINDSPEED))
#define SENSOR_ABILITY_WINDDIRECTION ((uint32_t)(1 << SENSOR_QUANTITY_WINDDIRECTION))
struct SensorProductInfo {
uint32_t ability; /* Bitwise OR of sensor ability */
@ -96,6 +98,8 @@ enum SensorQuantityType {
SENSOR_QUANTITY_CH4,
SENSOR_QUANTITY_IAQ,
SENSOR_QUANTITY_TVOC,
SENSOR_QUANTITY_WINDSPEED,
SENSOR_QUANTITY_WINDDIRECTION,
/* ...... */
SENSOR_QUANTITY_END,
};

View File

@ -0,0 +1,43 @@
config SENSOR_QS_FX
bool "Using qs-fx wind direction sensor"
default n
if SENSOR_QS_FX
config SENSOR_DEVICE_QS_FX
string "qs-fx sensor name"
default "qs_fx"
config SENSOR_QUANTITY_QS_FX_WINDDIRECTION
string "qs-fx quantity name"
default "winddirection_1"
if ADD_XIZI_FETURES
config SENSOR_QS_FX_DRIVER_EXTUART
bool "Using extra uart to support qs-fx"
default y
config SENSOR_DEVICE_QS_FX_DEV
string "qs-fx device name"
default "/dev/uart2_dev2"
depends on !SENSOR_QS_FX_DRIVER_EXTUART
if SENSOR_QS_FX_DRIVER_EXTUART
config SENSOR_DEVICE_QS_FX_DEV
string "qs-fx device extra uart path"
default "/dev/extuart_dev2"
config SENSOR_DEVICE_QS_FX_DEV_EXT_PORT
int "if qs-fx device using extuart, choose port"
default "2"
endif
endif
if ADD_NUTTX_FETURES
endif
if ADD_RTTHREAD_FETURES
endif
endif

View File

@ -0,0 +1,5 @@
ifeq ($(CONFIG_SENSOR_QS_FX),y)
SRC_DIR += qs-fx
endif
include $(KERNEL_ROOT)/compiler.mk

View File

@ -0,0 +1,14 @@
import os
Import('RTT_ROOT')
from building import *
cwd = GetCurrentDir()
objs = []
list = os.listdir(cwd)
for d in list:
path = os.path.join(cwd, d)
if os.path.isfile(os.path.join(path, 'SConscript')):
objs = objs + SConscript(os.path.join(path, 'SConscript'))
Return('objs')

View File

@ -0,0 +1,3 @@
SRC_FILES := qs-fx.c
include $(KERNEL_ROOT)/compiler.mk

View File

@ -0,0 +1,10 @@
from building import *
import os
cwd = GetCurrentDir()
src = []
if GetDepend(['SENSOR_QS_FX']):
src += ['qs-fx.c']
group = DefineGroup('sensor wind direction qs-fx', src, depend = [], CPPPATH = [cwd])
Return('group')

View File

@ -0,0 +1,162 @@
/*
* 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 qs-fx.c
* @brief qs-fx wind direction driver base sensor
* @version 1.1
* @author AIIT XUOS Lab
* @date 2021.12.10
*/
#include <sensor.h>
static struct SensorDevice qs_fx;
static char instructions[] = {0x02, 0x03, 0x00, 0x00, 0x00, 0x01, 0x84, 0x39};
static struct SensorProductInfo info =
{
SENSOR_ABILITY_WINDDIRECTION,
"清易电子",
"QS-FX",
};
/**
* @description: Open QS-FX voice device
* @param sdev - sensor device pointer
* @return success: 1 , failure: other
*/
static int SensorDeviceOpen(struct SensorDevice *sdev)
{
int result = 0;
sdev->fd = PrivOpen(SENSOR_DEVICE_QS_FX_DEV, O_RDWR);
if (sdev->fd < 0) {
printf("open %s error\n", SENSOR_DEVICE_QS_FX_DEV);
return -1;
}
struct SerialDataCfg cfg;
cfg.serial_baud_rate = BAUD_RATE_9600;
cfg.serial_data_bits = DATA_BITS_8;
cfg.serial_stop_bits = STOP_BITS_1;
cfg.serial_buffer_size = 64;
cfg.serial_parity_mode = PARITY_NONE;
cfg.serial_bit_order = 0;
cfg.serial_invert_mode = 0;
#ifdef SENSOR_QS_FX_DRIVER_EXTUART
cfg.ext_uart_no = SENSOR_DEVICE_QS_FX_DEV_EXT_PORT;
cfg.port_configure = PORT_CFG_INIT;
#endif
struct PrivIoctlCfg ioctl_cfg;
ioctl_cfg.ioctl_driver_type = SERIAL_TYPE;
ioctl_cfg.args = &cfg;
result = PrivIoctl(sdev->fd, OPE_INT, &ioctl_cfg);
return result;
}
/**
* @description: Read sensor device
* @param sdev - sensor device pointer
* @param len - the length of the read data
* @return get data length
*/
static int SensorDeviceRead(struct SensorDevice *sdev, size_t len)
{
if (PrivWrite(sdev->fd, instructions, sizeof(instructions)) < 0)
return -1;
if (PrivRead(sdev->fd, sdev->buffer, len) < 0)
return -1;
return 0;
}
static struct SensorDone done =
{
SensorDeviceOpen,
NULL,
SensorDeviceRead,
NULL,
NULL,
};
/**
* @description: Init QS-FX sensor and register
* @return void
*/
static void QsFxInit(void)
{
qs_fx.name = SENSOR_DEVICE_QS_FX;
qs_fx.info = &info;
qs_fx.done = &done;
qs_fx.status = SENSOR_DEVICE_PASSIVE;
SensorDeviceRegister(&qs_fx);
}
static struct SensorQuantity qs_fx_wind_direction;
/**
* @description: Analysis QS-FX wind direction
* @param quant - sensor quantity pointer
* @return quantity value
*/
static int32_t ReadWindDirection(struct SensorQuantity *quant)
{
if (!quant)
return -1;
short result;
if (quant->sdev->done->read != NULL) {
if (quant->sdev->status == SENSOR_DEVICE_PASSIVE) {
quant->sdev->done->read(quant->sdev, 6);
result = (quant->sdev->buffer[3] << 8) | quant->sdev->buffer[4];
return (int32_t)result;
}
if (quant->sdev->status == SENSOR_DEVICE_ACTIVE) {
printf("Please set passive mode.\n");
}
}else{
printf("%s don't have read done.\n", quant->name);
}
return -1;
}
/**
* @description: Init QS-FX voice quantity and register
* @return 0
*/
int QsFxWindDirectionInit(void)
{
QsFxInit();
qs_fx_wind_direction.name = SENSOR_QUANTITY_QS_FX_WINDDIRECTION;
qs_fx_wind_direction.type = SENSOR_QUANTITY_WINDDIRECTION;
qs_fx_wind_direction.value.decimal_places = 1;
qs_fx_wind_direction.value.max_std = 600;
qs_fx_wind_direction.value.min_std = 0;
qs_fx_wind_direction.value.last_value = SENSOR_QUANTITY_VALUE_ERROR;
qs_fx_wind_direction.value.max_value = SENSOR_QUANTITY_VALUE_ERROR;
qs_fx_wind_direction.value.min_value = SENSOR_QUANTITY_VALUE_ERROR;
qs_fx_wind_direction.sdev = &qs_fx;
qs_fx_wind_direction.ReadValue = ReadWindDirection;
SensorQuantityRegister(&qs_fx_wind_direction);
return 0;
}

View File

@ -0,0 +1,43 @@
config SENSOR_QS_FS
bool "Using qs-fs wind speed sensor"
default n
if SENSOR_QS_FS
config SENSOR_DEVICE_QS_FS
string "qs-fs sensor name"
default "qs-fs"
config SENSOR_QUANTITY_QS_FS_WINDSPEED
string "qs-fs quantity name"
default "windspeed_1"
if ADD_XIZI_FETURES
config SENSOR_QS_FS_DRIVER_EXTUART
bool "Using extra uart to support qs-fx"
default y
config SENSOR_DEVICE_QS_FS_DEV
string "qs-fx device name"
default "/dev/uart2_dev2"
depends on !SENSOR_QS_FS_DRIVER_EXTUART
if SENSOR_QS_FS_DRIVER_EXTUART
config SENSOR_DEVICE_QS_FS_DEV
string "qs-fx device extra uart path"
default "/dev/extuart_dev7"
config SENSOR_DEVICE_QS_FS_DEV_EXT_PORT
int "if qs-fx device using extuart, choose port"
default "7"
endif
endif
if ADD_NUTTX_FETURES
endif
if ADD_RTTHREAD_FETURES
endif
endif

View File

@ -0,0 +1,5 @@
ifeq ($(CONFIG_SENSOR_QS_FS),y)
SRC_DIR += qs-fs
endif
include $(KERNEL_ROOT)/compiler.mk

View File

@ -0,0 +1,14 @@
import os
Import('RTT_ROOT')
from building import *
cwd = GetCurrentDir()
objs = []
list = os.listdir(cwd)
for d in list:
path = os.path.join(cwd, d)
if os.path.isfile(os.path.join(path, 'SConscript')):
objs = objs + SConscript(os.path.join(path, 'SConscript'))
Return('objs')

View File

@ -0,0 +1,3 @@
SRC_FILES := qs-fs.c
include $(KERNEL_ROOT)/compiler.mk

View File

@ -0,0 +1,10 @@
from building import *
import os
cwd = GetCurrentDir()
src = []
if GetDepend(['SENSOR_QS_FS']):
src += ['qs-fs.c']
group = DefineGroup('sensor wind speed qs-fs', src, depend = [], CPPPATH = [cwd])
Return('group')

View File

@ -0,0 +1,162 @@
/*
* 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 qs-fs.c
* @brief qs-fs wind speed driver base sensor
* @version 1.1
* @author AIIT XUOS Lab
* @date 2021.12.10
*/
#include <sensor.h>
static struct SensorDevice qs_fs;
static const unsigned char instructions[] = {0x01, 0x03, 0x00, 0x00, 0x00, 0x01, 0x84, 0x0A};
static struct SensorProductInfo info =
{
SENSOR_ABILITY_WINDSPEED,
"清易电子",
"QS-FS",
};
/**
* @description: Open QS-FS voice device
* @param sdev - sensor device pointer
* @return success: 1 , failure: other
*/
static int SensorDeviceOpen(struct SensorDevice *sdev)
{
int result = 0;
sdev->fd = PrivOpen(SENSOR_DEVICE_QS_FS_DEV, O_RDWR);
if (sdev->fd < 0) {
printf("open %s error\n", SENSOR_DEVICE_QS_FS_DEV);
return -1;
}
struct SerialDataCfg cfg;
cfg.serial_baud_rate = BAUD_RATE_9600;
cfg.serial_data_bits = DATA_BITS_8;
cfg.serial_stop_bits = STOP_BITS_1;
cfg.serial_buffer_size = 64;
cfg.serial_parity_mode = PARITY_NONE;
cfg.serial_bit_order = 0;
cfg.serial_invert_mode = 0;
#ifdef SENSOR_QS_FS_DRIVER_EXTUART
cfg.ext_uart_no = SENSOR_DEVICE_QS_FS_DEV_EXT_PORT;
cfg.port_configure = PORT_CFG_INIT;
#endif
struct PrivIoctlCfg ioctl_cfg;
ioctl_cfg.ioctl_driver_type = SERIAL_TYPE;
ioctl_cfg.args = &cfg;
result = PrivIoctl(sdev->fd, OPE_INT, &ioctl_cfg);
return result;
}
/**
* @description: Read sensor device
* @param sdev - sensor device pointer
* @param len - the length of the read data
* @return get data length
*/
static int SensorDeviceRead(struct SensorDevice *sdev, size_t len)
{
if (PrivWrite(sdev->fd, instructions, sizeof(instructions)) < 0)
return -1;
if (PrivRead(sdev->fd, sdev->buffer, len) < 0)
return -1;
return 0;
}
static struct SensorDone done =
{
SensorDeviceOpen,
NULL,
SensorDeviceRead,
NULL,
NULL,
};
/**
* @description: Init QS-FS sensor and register
* @return void
*/
static void QsFsInit(void)
{
qs_fs.name = SENSOR_DEVICE_QS_FS;
qs_fs.info = &info;
qs_fs.done = &done;
qs_fs.status = SENSOR_DEVICE_PASSIVE;
SensorDeviceRegister(&qs_fs);
}
static struct SensorQuantity qs_fs_wind_speed;
/**
* @description: Analysis QS-FS wind speed
* @param quant - sensor quantity pointer
* @return quantity value
*/
static int32_t ReadWindSpeed(struct SensorQuantity *quant)
{
if (!quant)
return -1;
short result;
if (quant->sdev->done->read != NULL) {
if (quant->sdev->status == SENSOR_DEVICE_PASSIVE) {
quant->sdev->done->read(quant->sdev, 6);
result = (quant->sdev->buffer[3] << 8) | quant->sdev->buffer[4];
return (int32_t)result;
}
if (quant->sdev->status == SENSOR_DEVICE_ACTIVE) {
printf("Please set passive mode.\n");
}
}else{
printf("%s don't have read done.\n", quant->name);
}
return -1;
}
/**
* @description: Init QS-FS voice quantity and register
* @return 0
*/
int QsFsWindSpeedInit(void)
{
QsFsInit();
qs_fs_wind_speed.name = SENSOR_QUANTITY_QS_FS_WINDSPEED;
qs_fs_wind_speed.type = SENSOR_QUANTITY_WINDSPEED;
qs_fs_wind_speed.value.decimal_places = 1;
qs_fs_wind_speed.value.max_std = 600;
qs_fs_wind_speed.value.min_std = 0;
qs_fs_wind_speed.value.last_value = SENSOR_QUANTITY_VALUE_ERROR;
qs_fs_wind_speed.value.max_value = SENSOR_QUANTITY_VALUE_ERROR;
qs_fs_wind_speed.value.min_value = SENSOR_QUANTITY_VALUE_ERROR;
qs_fs_wind_speed.sdev = &qs_fs;
qs_fs_wind_speed.ReadValue = ReadWindSpeed;
SensorQuantityRegister(&qs_fs_wind_speed);
return 0;
}

View File

@ -1046,8 +1046,30 @@ static uint32 Stm32Ch438WriteData(void *dev, struct BusBlockWriteParam *write_pa
struct SerialHardwareDevice *serial_dev = (struct SerialHardwareDevice *)dev;
struct SerialDevParam *dev_param = (struct SerialDevParam *)serial_dev->haldev.private_data;
if (2 == dev_param->ext_uart_no) {
Set485Output(2);
Stm32Udelay(20000);
} else if (3 == dev_param->ext_uart_no) {
Set485Output(1);
Stm32Udelay(20000);
} else if (7 == dev_param->ext_uart_no) {
Set485Output(3);
Stm32Udelay(20000);
}
Ch438UartSend(dev_param->ext_uart_no, (uint8 *)write_param->buffer, write_param->size);
if (2 == dev_param->ext_uart_no) {
Stm32Udelay(20000);
Set485Input(2);
} else if (3 == dev_param->ext_uart_no) {
Stm32Udelay(20000);
Set485Input(1);
} else if (7 == dev_param->ext_uart_no) {
Stm32Udelay(20000);
Set485Input(3);
}
return EOK;
}
@ -1224,8 +1246,6 @@ static void Stm32Ch438InitDefault(struct SerialDriver *serial_drv)
serial_cfg.data_cfg.ext_uart_no = 7;
serial_cfg.data_cfg.serial_baud_rate = BAUD_RATE_9600;
BusDrvConfigure(&serial_drv->driver, &configure_info);
Set485Input(1);
}
static uint32 Stm32Ch438DevRegister(struct SerialHardwareDevice *serial_dev, char *dev_name)

View File

@ -982,8 +982,18 @@ static uint32 Ch438WriteData(void *dev, struct BusBlockWriteParam *write_param)
struct SerialHardwareDevice *serial_dev = (struct SerialHardwareDevice *)dev;
struct SerialDevParam *dev_param = (struct SerialDevParam *)serial_dev->haldev.private_data;
if (4 == dev_param->ext_uart_no) {
Set485Output(1);
MdelayKTask(20);
}
CH438UartSend(dev_param->ext_uart_no, (uint8 *)write_param->buffer, write_param->size);
if (4 == dev_param->ext_uart_no) {
MdelayKTask(20);
Set485Input(1);
}
return EOK;
}
@ -1162,8 +1172,6 @@ static void Ch438InitDefault(struct SerialDriver *serial_drv)
serial_cfg.data_cfg.ext_uart_no = 7;
serial_cfg.data_cfg.serial_baud_rate = BAUD_RATE_9600;
BusDrvConfigure(&serial_drv->driver, &configure_info);
Set485Input(1);
}
static uint32 Ch438DevRegister(struct SerialHardwareDevice *serial_dev, char *dev_name)

View File

@ -39,9 +39,9 @@ static uint32 I2cDeviceWrite(void *dev, struct BusBlockWriteParam *write_param)
i2c_msg.addr = i2c_dev->i2c_dev_addr;
i2c_msg.flags = I2C_WR;
i2c_msg.buf = NONE;
i2c_msg.len = 0;
i2c_msg.retries = 1;
i2c_msg.buf = write_param->buffer;
i2c_msg.len = write_param->size;
i2c_msg.retries = 10;
i2c_msg.next = NONE;
return i2c_dev->i2c_dev_done->dev_write(i2c_dev, &i2c_msg);
@ -59,7 +59,7 @@ static uint32 I2cDeviceRead(void *dev, struct BusBlockReadParam *read_param)
i2c_msg.flags = I2C_RD;
i2c_msg.buf = read_param->buffer;
i2c_msg.len = read_param->size;
i2c_msg.retries = 1;
i2c_msg.retries = 10;
i2c_msg.next = NONE;
return i2c_dev->i2c_dev_done->dev_read(i2c_dev, &i2c_msg);