forked from xuos/xiuos
feat add sensor device support for sensor framework from Liu_weichao
it is OK
This commit is contained in:
commit
07ba66611d
|
@ -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
|
||||
|
|
|
@ -53,6 +53,10 @@ menu "sensor app"
|
|||
config APPLICATION_SENSOR_CO2_ZG09
|
||||
bool "Using sensor ZG09 apps"
|
||||
default n
|
||||
|
||||
config APPLICATION_SENSOR_CO2_G8S
|
||||
bool "Using sensor G8S apps"
|
||||
default n
|
||||
endif
|
||||
|
||||
menuconfig APPLICATION_SENSOR_PM1_0
|
||||
|
@ -122,7 +126,36 @@ 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
|
||||
|
||||
menuconfig APPLICATION_SENSOR_ALTITUDE
|
||||
bool "Using sensor altitude apps"
|
||||
default n
|
||||
|
||||
if APPLICATION_SENSOR_ALTITUDE
|
||||
config APPLICATION_SENSOR_ALTITUDE_BMP180
|
||||
bool "Using sensor BMP180 apps"
|
||||
default n
|
||||
endif
|
||||
endif
|
||||
|
||||
endmenu
|
||||
|
|
|
@ -74,6 +74,10 @@ ifeq ($(CONFIG_ADD_XIZI_FETURES),y)
|
|||
SRC_FILES += co2_zg09.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_APPLICATION_SENSOR_CO2_G8S), y)
|
||||
SRC_FILES += co2_g8s.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_APPLICATION_SENSOR_PM1_0_PS5308), y)
|
||||
SRC_FILES += pm1_0_ps5308.c
|
||||
endif
|
||||
|
@ -98,6 +102,18 @@ 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
|
||||
|
||||
ifeq ($(CONFIG_APPLICATION_SENSOR_ALTITUDE_BMP180), y)
|
||||
SRC_FILES += altitude_bmp180.c
|
||||
endif
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
|
||||
endif
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* 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 altitude_bmp180.c
|
||||
* @brief BMP180 altitude example
|
||||
* @version 1.1
|
||||
* @author AIIT XUOS Lab
|
||||
* @date 2021.12.23
|
||||
*/
|
||||
|
||||
#include <user_api.h>
|
||||
#include <sensor.h>
|
||||
|
||||
/**
|
||||
* @description: Read a altitude
|
||||
* @return 0
|
||||
*/
|
||||
void AltitudeBmp180(void)
|
||||
{
|
||||
int32 altitude;
|
||||
struct SensorQuantity *p_altitude = SensorQuantityFind(SENSOR_QUANTITY_BMP180_ALTITUDE, SENSOR_QUANTITY_ALTITUDE);
|
||||
SensorQuantityOpen(p_altitude);
|
||||
altitude = SensorQuantityRead(p_altitude);
|
||||
|
||||
printf("Altitude Pressure : %d Pa\n", altitude);
|
||||
|
||||
PrivTaskDelay(1000);
|
||||
SensorQuantityClose(p_altitude);
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* 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 co2_g8s.c
|
||||
* @brief G8S CO2 example
|
||||
* @version 1.1
|
||||
* @author AIIT XUOS Lab
|
||||
* @date 2021.12.23
|
||||
*/
|
||||
|
||||
#include <user_api.h>
|
||||
#include <sensor.h>
|
||||
|
||||
/**
|
||||
* @description: Read a CO2
|
||||
* @return 0
|
||||
*/
|
||||
void Co2G8s(void)
|
||||
{
|
||||
struct SensorQuantity *co2 = SensorQuantityFind(SENSOR_QUANTITY_G8S_CO2, SENSOR_QUANTITY_CO2);
|
||||
SensorQuantityOpen(co2);
|
||||
printf("CO2 : %d ppm\n", SensorQuantityRead(co2));
|
||||
SensorQuantityClose(co2);
|
||||
}
|
|
@ -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);
|
||||
|
|
@ -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);
|
||||
|
|
@ -66,4 +66,25 @@ 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
|
||||
|
||||
menuconfig SENSOR_ALTITUDE
|
||||
bool "Using altitude sensor device"
|
||||
default n
|
||||
if SENSOR_ALTITUDE
|
||||
source "$APP_DIR/Framework/sensor/altitude/Kconfig"
|
||||
endif
|
||||
endif
|
||||
|
|
|
@ -45,5 +45,17 @@ 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
|
||||
|
||||
ifeq ($(CONFIG_SENSOR_ALTITUDE),y)
|
||||
SRC_DIR += altitude
|
||||
endif
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
endif
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
|
||||
config SENSOR_BMP180
|
||||
bool "Using BMP180"
|
||||
default n
|
||||
|
||||
if SENSOR_BMP180
|
||||
config SENSOR_DEVICE_BMP180
|
||||
string "BMP180 sensor name"
|
||||
default "bmp180"
|
||||
|
||||
config SENSOR_QUANTITY_BMP180_ALTITUDE
|
||||
string "BMP180 quantity name"
|
||||
default "altitude_1"
|
||||
|
||||
if ADD_XIZI_FETURES
|
||||
config SENSOR_DEVICE_BMP180_DEV
|
||||
string "BMP180 device name"
|
||||
default "/dev/i2c1_dev0"
|
||||
|
||||
config SENSOR_DEVICE_BMP180_I2C_ADDR
|
||||
hex "BMP180 device i2c address"
|
||||
default 0x77
|
||||
endif
|
||||
|
||||
if ADD_NUTTX_FETURES
|
||||
|
||||
endif
|
||||
|
||||
if ADD_RTTHREAD_FETURES
|
||||
|
||||
endif
|
||||
endif
|
|
@ -0,0 +1,5 @@
|
|||
ifeq ($(CONFIG_SENSOR_BMP180),y)
|
||||
SRC_DIR += bmp180
|
||||
endif
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
|
@ -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')
|
|
@ -0,0 +1,3 @@
|
|||
SRC_FILES := bmp180.c
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
|
@ -0,0 +1,10 @@
|
|||
from building import *
|
||||
import os
|
||||
|
||||
cwd = GetCurrentDir()
|
||||
src = []
|
||||
if GetDepend(['SENSOR_BMP180']):
|
||||
src += ['bmp180.c']
|
||||
group = DefineGroup('sensor altitude bmp180', src, depend = [], CPPPATH = [cwd])
|
||||
|
||||
Return('group')
|
|
@ -0,0 +1,322 @@
|
|||
/*
|
||||
* 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 bmp180.c
|
||||
* @brief BMP180 altitude driver base sensor
|
||||
* @version 1.1
|
||||
* @author AIIT XUOS Lab
|
||||
* @date 2021.12.20
|
||||
*/
|
||||
|
||||
#include <sensor.h>
|
||||
#include <math.h>
|
||||
|
||||
static struct SensorDevice bmp180;
|
||||
|
||||
typedef struct {
|
||||
int8_t ac_data[3];
|
||||
uint8_t unsigned_ac_data[3];
|
||||
int8_t b_data[2];
|
||||
int8_t m_data[3];
|
||||
}Bmp180RegData;
|
||||
|
||||
static Bmp180RegData bmp180_reg_data;
|
||||
|
||||
const static unsigned char OSS = 0; // Oversampling Setting
|
||||
static long CalTemp_data = 0;
|
||||
|
||||
static struct SensorProductInfo info =
|
||||
{
|
||||
(SENSOR_ABILITY_ALTITUDE),
|
||||
"BOSCH",
|
||||
"BMP180",
|
||||
};
|
||||
|
||||
/**
|
||||
* @description: Open BMP180 sensor device
|
||||
* @param sdev - sensor device pointer
|
||||
* @return success : 0 error : -1
|
||||
*/
|
||||
static int SensorDeviceOpen(struct SensorDevice *sdev)
|
||||
{
|
||||
int result;
|
||||
uint16_t i2c_dev_addr = SENSOR_DEVICE_BMP180_I2C_ADDR;
|
||||
|
||||
sdev->fd = PrivOpen(SENSOR_DEVICE_BMP180_DEV, O_RDWR);
|
||||
if (sdev->fd < 0) {
|
||||
printf("open %s error\n", SENSOR_DEVICE_BMP180_DEV);
|
||||
return -1;
|
||||
}
|
||||
|
||||
struct PrivIoctlCfg ioctl_cfg;
|
||||
ioctl_cfg.ioctl_driver_type = I2C_TYPE;
|
||||
ioctl_cfg.args = &i2c_dev_addr;
|
||||
result = PrivIoctl(sdev->fd, OPE_INT, &ioctl_cfg);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: Write sensor device
|
||||
* @param sdev - sensor device pointer
|
||||
* @param len - the length of the read data
|
||||
* @return success: 0 , failure: -1
|
||||
*/
|
||||
static int SensorDeviceWrite(struct SensorDevice *sdev, const void *buf, size_t len)
|
||||
{
|
||||
if (PrivWrite(sdev->fd, buf, len) < 0)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: Read sensor device
|
||||
* @param sdev - sensor device pointer
|
||||
* @param len - the length of the read data
|
||||
* @return success: 0 , failure: -1
|
||||
*/
|
||||
static int SensorDeviceRead(struct SensorDevice *sdev, size_t len)
|
||||
{
|
||||
//Read i2c device data from i2c device address
|
||||
if (PrivRead(sdev->fd, sdev->buffer, len) < 0)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct SensorDone done =
|
||||
{
|
||||
SensorDeviceOpen,
|
||||
NULL,
|
||||
SensorDeviceRead,
|
||||
SensorDeviceWrite,
|
||||
NULL,
|
||||
};
|
||||
|
||||
/**
|
||||
* @description: Init BMP180 sensor and register
|
||||
* @return void
|
||||
*/
|
||||
static void SensorDeviceBmp180Init(void)
|
||||
{
|
||||
bmp180.name = SENSOR_DEVICE_BMP180;
|
||||
bmp180.info = &info;
|
||||
bmp180.done = &done;
|
||||
bmp180.status = SENSOR_DEVICE_PASSIVE;
|
||||
|
||||
SensorDeviceRegister(&bmp180);
|
||||
}
|
||||
|
||||
static struct SensorQuantity bmp180_altitude;
|
||||
|
||||
/**
|
||||
* @description: Stores all of the bmp180's calibration values into global variables
|
||||
* @return uint16_t reg data
|
||||
*/
|
||||
static uint16_t SensorDeviceBmp180ReadRegs(struct SensorDevice *sdev, char reg_addr)
|
||||
{
|
||||
uint8_t reg_data[2] = {0};
|
||||
|
||||
if (SensorDeviceWrite(sdev, ®_addr, 1) < 0) {
|
||||
printf("SensorDeviceBmp180ReadRegs write reg 0x%x error. return 0x0\n", reg_addr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (SensorDeviceRead(sdev, 2) < 0) {
|
||||
printf("SensorDeviceBmp180ReadRegs error. return 0x0\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
reg_data[0] = sdev->buffer[0];
|
||||
reg_data[1] = sdev->buffer[1];
|
||||
|
||||
return (uint16_t)(reg_data[0] << 8 | reg_data[1]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: Read the uncompensated temperature value(ut)
|
||||
* @return uint16_t 0xF6 reg data
|
||||
*/
|
||||
static uint16_t SensorDeviceBmp180ReadUT(struct SensorDevice *sdev)
|
||||
{
|
||||
uint8_t data[2];
|
||||
data[0] = 0xF4;
|
||||
data[1] = 0x2E;
|
||||
|
||||
if (SensorDeviceWrite(sdev, data, 2) < 0) {
|
||||
printf("SensorDeviceBmp180ReadUT write reg 0xF4 error. return 0x0\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
return SensorDeviceBmp180ReadRegs(sdev, 0xF6);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: Read the uncompensated pressure value(up)
|
||||
* @return uint16_t 0xF6 reg data
|
||||
*/
|
||||
static uint16_t SensorDeviceBmp180ReadUP(struct SensorDevice *sdev)
|
||||
{
|
||||
uint8_t data[2];
|
||||
data[0] = 0xF4;
|
||||
data[1] = 0x34 + (OSS << 6);
|
||||
|
||||
if (SensorDeviceWrite(sdev, data, 2) < 0) {
|
||||
printf("SensorDeviceBmp180ReadUP write reg 0xF4 error. return 0x0\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
return SensorDeviceBmp180ReadRegs(sdev, 0xF6);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: Calculate temperature
|
||||
* @return uint16_t reg data
|
||||
*/
|
||||
static float SensorDeviceBmp180CalTemp(struct SensorDevice *sdev, uint16_t ut, Bmp180RegData *bmp180_reg_data)
|
||||
{
|
||||
long x1, x2;
|
||||
x1 = (((long)ut - (long)bmp180_reg_data->unsigned_ac_data[2]) * (long)bmp180_reg_data->unsigned_ac_data[1]) >> 15;
|
||||
x2 = ((long)bmp180_reg_data->m_data[1] << 11) / (x1 + bmp180_reg_data->m_data[2]);
|
||||
CalTemp_data = x1 + x2;
|
||||
float temp = ((CalTemp_data + 8) >> 4);
|
||||
temp = temp / 10;
|
||||
return temp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: Calculate pressure
|
||||
* @return float pressure
|
||||
*/
|
||||
static float SensorDeviceBmp180CalPressure(struct SensorDevice *sdev, uint16_t up, Bmp180RegData *bmp180_reg_data)
|
||||
{
|
||||
long x1, x2, x3, y1, y2, pressure;
|
||||
unsigned long z1, z2;
|
||||
|
||||
y2 = CalTemp_data - 4000;
|
||||
// Calculate y1 data
|
||||
x1 = (bmp180_reg_data->b_data[1] * (y2 * y2) >> 12) >> 11;
|
||||
x2 = (bmp180_reg_data->ac_data[1] * y2)>>11;
|
||||
x3 = x1 + x2;
|
||||
y1 = (((((long)bmp180_reg_data->ac_data[0]) * 4 + x3) << OSS) + 2) >> 2;
|
||||
|
||||
// Calculate B4
|
||||
x1 = (bmp180_reg_data->ac_data[2] * y2) >> 13;
|
||||
x2 = (bmp180_reg_data->b_data[0] * ((y2 * y2) >> 12)) >> 16;
|
||||
x3 = ((x1 + x2) + 2) >> 2;
|
||||
z1 = (bmp180_reg_data->unsigned_ac_data[0] * (unsigned long)(x3 + 32768)) >> 15;
|
||||
|
||||
z2 = ((unsigned long)(up - y1) * (50000 >> OSS));
|
||||
if (z2 < 0x80000000)
|
||||
pressure = (z2 << 1) / z1;
|
||||
else
|
||||
pressure = (z2 / z1) << 1;
|
||||
|
||||
x1 = (pressure >> 8) * (pressure >> 8);
|
||||
x1 = (x1 * 3038) >> 16;
|
||||
x2 = (-7357 * pressure) >> 16;
|
||||
pressure += (x1 + x2 + 3791) >> 4;
|
||||
|
||||
return pressure;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: Calculate altitude
|
||||
* @return float Altitude
|
||||
*/
|
||||
static float SensorDeviceBmp180CalAltitude(float pressure)
|
||||
{
|
||||
float A = pressure / 101325;
|
||||
float B = 1 / 5.25588;
|
||||
float altitude = pow(A, B);
|
||||
altitude = 1 - altitude;
|
||||
altitude = altitude / 0.0000225577;
|
||||
|
||||
return altitude;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: Analysis BMP180 temperature result
|
||||
* @param quant - sensor quantity pointer
|
||||
* @return quantity value
|
||||
*/
|
||||
static int32_t ReadAltitude(struct SensorQuantity *quant)
|
||||
{
|
||||
if (!quant)
|
||||
return -1;
|
||||
|
||||
memset(&bmp180_reg_data, 0 , sizeof(Bmp180RegData));
|
||||
|
||||
uint16_t ut, up = 0;
|
||||
float bmp180_temperature, bmp180_pressure, bmp180_aititude;
|
||||
if (quant->sdev->done->read != NULL) {
|
||||
if (quant->sdev->status == SENSOR_DEVICE_PASSIVE) {
|
||||
|
||||
bmp180_reg_data.ac_data[0] = SensorDeviceBmp180ReadRegs(quant->sdev, 0xAA);
|
||||
bmp180_reg_data.ac_data[1] = SensorDeviceBmp180ReadRegs(quant->sdev, 0xAC);
|
||||
bmp180_reg_data.ac_data[2] = SensorDeviceBmp180ReadRegs(quant->sdev, 0xAE);
|
||||
bmp180_reg_data.unsigned_ac_data[0] = SensorDeviceBmp180ReadRegs(quant->sdev, 0xB0);
|
||||
bmp180_reg_data.unsigned_ac_data[1] = SensorDeviceBmp180ReadRegs(quant->sdev, 0xB2);
|
||||
bmp180_reg_data.unsigned_ac_data[2] = SensorDeviceBmp180ReadRegs(quant->sdev, 0xB4);
|
||||
bmp180_reg_data.b_data[0] = SensorDeviceBmp180ReadRegs(quant->sdev, 0xB6);
|
||||
bmp180_reg_data.b_data[1] = SensorDeviceBmp180ReadRegs(quant->sdev, 0xB8);
|
||||
bmp180_reg_data.m_data[0] = SensorDeviceBmp180ReadRegs(quant->sdev, 0xBA);
|
||||
bmp180_reg_data.m_data[1] = SensorDeviceBmp180ReadRegs(quant->sdev, 0xBC);
|
||||
bmp180_reg_data.m_data[2] = SensorDeviceBmp180ReadRegs(quant->sdev, 0xBE);
|
||||
|
||||
ut = SensorDeviceBmp180ReadUT(quant->sdev);
|
||||
up = SensorDeviceBmp180ReadUP(quant->sdev);
|
||||
|
||||
bmp180_temperature = SensorDeviceBmp180CalTemp(quant->sdev, ut, &bmp180_reg_data);
|
||||
bmp180_pressure = SensorDeviceBmp180CalPressure(quant->sdev, up, &bmp180_reg_data);
|
||||
bmp180_aititude = SensorDeviceBmp180CalAltitude(bmp180_pressure);
|
||||
|
||||
return (int32_t)bmp180_pressure;
|
||||
}
|
||||
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 BMP180 temperature quantity and register
|
||||
* @return 0
|
||||
*/
|
||||
int Bmp180AltitudeInit(void)
|
||||
{
|
||||
SensorDeviceBmp180Init();
|
||||
|
||||
bmp180_altitude.name = SENSOR_QUANTITY_BMP180_ALTITUDE;
|
||||
bmp180_altitude.type = SENSOR_QUANTITY_ALTITUDE;
|
||||
bmp180_altitude.value.decimal_places = 1;
|
||||
bmp180_altitude.value.max_std = 1000;
|
||||
bmp180_altitude.value.min_std = 0;
|
||||
bmp180_altitude.value.last_value = SENSOR_QUANTITY_VALUE_ERROR;
|
||||
bmp180_altitude.value.max_value = SENSOR_QUANTITY_VALUE_ERROR;
|
||||
bmp180_altitude.value.min_value = SENSOR_QUANTITY_VALUE_ERROR;
|
||||
bmp180_altitude.sdev = &bmp180;
|
||||
bmp180_altitude.ReadValue = ReadAltitude;
|
||||
|
||||
SensorQuantityRegister(&bmp180_altitude);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -46,3 +46,46 @@ config SENSOR_ZG09
|
|||
|
||||
endif
|
||||
endif
|
||||
|
||||
config SENSOR_G8S
|
||||
bool "Using g8-s"
|
||||
default n
|
||||
|
||||
if SENSOR_G8S
|
||||
config SENSOR_DEVICE_G8S
|
||||
string "g8-s sensor name"
|
||||
default "g8-s"
|
||||
|
||||
config SENSOR_QUANTITY_G8S_CO2
|
||||
string "g8-s quantity name"
|
||||
default "co2_2"
|
||||
|
||||
if ADD_XIZI_FETURES
|
||||
config SENSOR_G8S_DRIVER_EXTUART
|
||||
bool "Using extra uart to support g8-s"
|
||||
default n
|
||||
|
||||
config SENSOR_DEVICE_G8S_DEV
|
||||
string "g8-s device uart path"
|
||||
default "/dev/uart2_dev2"
|
||||
depends on !SENSOR_G8S_DRIVER_EXTUART
|
||||
|
||||
if SENSOR_G8S_DRIVER_EXTUART
|
||||
config SENSOR_DEVICE_G8S_DEV
|
||||
string "g8-s device extra uart path"
|
||||
default "/dev/extuart_dev4"
|
||||
|
||||
config SENSOR_DEVICE_G8S_DEV_EXT_PORT
|
||||
int "if g8-s device using extuart, choose port"
|
||||
default "4"
|
||||
endif
|
||||
endif
|
||||
|
||||
if ADD_NUTTX_FETURES
|
||||
|
||||
endif
|
||||
|
||||
if ADD_RTTHREAD_FETURES
|
||||
|
||||
endif
|
||||
endif
|
||||
|
|
|
@ -2,4 +2,8 @@ ifeq ($(CONFIG_SENSOR_ZG09),y)
|
|||
SRC_DIR += zg09
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_SENSOR_G8S),y)
|
||||
SRC_DIR += g8s
|
||||
endif
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
|
|
|
@ -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')
|
|
@ -0,0 +1,3 @@
|
|||
SRC_FILES := g8s.c
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
|
@ -0,0 +1,10 @@
|
|||
from building import *
|
||||
import os
|
||||
|
||||
cwd = GetCurrentDir()
|
||||
src = []
|
||||
if GetDepend(['SENSOR_G8S']):
|
||||
src += ['g8s.c']
|
||||
group = DefineGroup('sensor co2 g8s', src, depend = [], CPPPATH = [cwd])
|
||||
|
||||
Return('group')
|
|
@ -0,0 +1,187 @@
|
|||
/*
|
||||
* 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 g8s.c
|
||||
* @brief G8S CO2 driver base sensor
|
||||
* @version 1.1
|
||||
* @author AIIT XUOS Lab
|
||||
* @date 2021.12.23
|
||||
*/
|
||||
|
||||
#include <sensor.h>
|
||||
#include <math.h>
|
||||
|
||||
static uint8_t g8s_read_instruction[8] = {0x52, 0x36, 0x09, 0x37, 0x38, 0x0D, 0x0A};
|
||||
|
||||
static struct SensorDevice g8s;
|
||||
|
||||
static struct SensorProductInfo info =
|
||||
{
|
||||
SENSOR_ABILITY_CO2,
|
||||
"senTec",
|
||||
"G8S",
|
||||
};
|
||||
|
||||
/**
|
||||
* @description: Open G8S sensor 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_G8S_DEV, O_RDWR);
|
||||
if (sdev->fd < 0) {
|
||||
printf("open %s error\n", SENSOR_DEVICE_G8S_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 = 128;
|
||||
cfg.serial_parity_mode = PARITY_NONE;
|
||||
cfg.serial_bit_order = 0;
|
||||
cfg.serial_invert_mode = 0;
|
||||
#ifdef SENSOR_G8S_DRIVER_EXTUART
|
||||
cfg.ext_uart_no = SENSOR_DEVICE_G8S_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)
|
||||
{
|
||||
uint8_t tmp = 0;
|
||||
|
||||
PrivWrite(sdev->fd, g8s_read_instruction, sizeof(g8s_read_instruction));
|
||||
|
||||
if (PrivRead(sdev->fd, sdev->buffer, len) < 0)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct SensorDone done =
|
||||
{
|
||||
SensorDeviceOpen,
|
||||
NULL,
|
||||
SensorDeviceRead,
|
||||
NULL,
|
||||
NULL,
|
||||
};
|
||||
|
||||
/**
|
||||
* @description: Init G8S sensor and register
|
||||
* @return void
|
||||
*/
|
||||
static void SensorDeviceG8sInit(void)
|
||||
{
|
||||
g8s.name = SENSOR_DEVICE_G8S;
|
||||
g8s.info = &info;
|
||||
g8s.done = &done;
|
||||
g8s.status = SENSOR_DEVICE_PASSIVE;
|
||||
|
||||
SensorDeviceRegister(&g8s);
|
||||
}
|
||||
|
||||
static struct SensorQuantity g8s_co2;
|
||||
|
||||
/**
|
||||
* @description: Analysis G8S CO2 result
|
||||
* @param quant - sensor quantity pointer
|
||||
* @return quantity value
|
||||
*/
|
||||
static int32_t QuantityRead(struct SensorQuantity *quant)
|
||||
{
|
||||
if (!quant)
|
||||
return -1;
|
||||
|
||||
int i, ascii_length;
|
||||
int32_t result = 0;
|
||||
uint8_t result_ascii[9], result_hex[9];
|
||||
|
||||
memset(result_ascii, 0, 9);
|
||||
memset(result_hex, 0, 9);
|
||||
|
||||
if (quant->sdev->done->read != NULL) {
|
||||
if(quant->sdev->status == SENSOR_DEVICE_PASSIVE) {
|
||||
quant->sdev->done->read(quant->sdev, 9);
|
||||
|
||||
for (i = 0; i < 9; i ++) {
|
||||
if (0x09 == quant->sdev->buffer[i]) {
|
||||
ascii_length = i;
|
||||
break;
|
||||
}
|
||||
result_ascii[i] = quant->sdev->buffer[i];
|
||||
}
|
||||
|
||||
if (8 == ascii_length) {
|
||||
for (i = 0; i < ascii_length; i ++) {
|
||||
result_hex[i] = result_ascii[i] - 0x30;
|
||||
result += result_hex[i] * pow(10, ascii_length - 1 - i);
|
||||
}
|
||||
return result;
|
||||
} else {
|
||||
printf("This reading is wrong\n");
|
||||
result = SENSOR_QUANTITY_VALUE_ERROR;
|
||||
return 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 G8S CO2 quantity and register
|
||||
* @return 0
|
||||
*/
|
||||
int G8sCo2Init(void)
|
||||
{
|
||||
SensorDeviceG8sInit();
|
||||
|
||||
g8s_co2.name = SENSOR_QUANTITY_G8S_CO2;
|
||||
g8s_co2.type = SENSOR_QUANTITY_CO2;
|
||||
g8s_co2.value.decimal_places = 0;
|
||||
g8s_co2.value.max_std = 2000;
|
||||
g8s_co2.value.min_std = 0;
|
||||
g8s_co2.value.last_value = SENSOR_QUANTITY_VALUE_ERROR;
|
||||
g8s_co2.value.max_value = SENSOR_QUANTITY_VALUE_ERROR;
|
||||
g8s_co2.value.min_value = SENSOR_QUANTITY_VALUE_ERROR;
|
||||
g8s_co2.sdev = &g8s;
|
||||
g8s_co2.ReadValue = QuantityRead;
|
||||
|
||||
SensorQuantityRegister(&g8s_co2);
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -69,28 +69,11 @@ static int SensorDeviceOpen(struct SensorDevice *sdev)
|
|||
*/
|
||||
static int SensorDeviceRead(struct SensorDevice *sdev, size_t len)
|
||||
{
|
||||
#ifdef ADD_NUTTX_FETURES
|
||||
int ret;
|
||||
ret = PrivRead(sdev->fd, sdev->buffer, len);
|
||||
if (ret != len ){
|
||||
perror("Failed to read data!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
#else
|
||||
//send i2c device start signal and address, need to implemente in OS i2c driver
|
||||
if (PrivWrite(sdev->fd, NULL, 0) != 1)
|
||||
return -1;
|
||||
|
||||
PrivTaskDelay(50);
|
||||
|
||||
//Read i2c device data from i2c device address
|
||||
if (PrivRead(sdev->fd, sdev->buffer, len) != 1)
|
||||
if (PrivRead(sdev->fd, sdev->buffer, len) < 0)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static struct SensorDone done =
|
||||
|
|
|
@ -55,6 +55,9 @@ 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))
|
||||
#define SENSOR_ABILITY_ALTITUDE ((uint32_t)(1 << SENSOR_QUANTITY_ALTITUDE))
|
||||
|
||||
struct SensorProductInfo {
|
||||
uint32_t ability; /* Bitwise OR of sensor ability */
|
||||
|
@ -96,6 +99,9 @@ enum SensorQuantityType {
|
|||
SENSOR_QUANTITY_CH4,
|
||||
SENSOR_QUANTITY_IAQ,
|
||||
SENSOR_QUANTITY_TVOC,
|
||||
SENSOR_QUANTITY_WINDSPEED,
|
||||
SENSOR_QUANTITY_WINDDIRECTION,
|
||||
SENSOR_QUANTITY_ALTITUDE,
|
||||
/* ...... */
|
||||
SENSOR_QUANTITY_END,
|
||||
};
|
||||
|
|
|
@ -68,28 +68,11 @@ static int SensorDeviceOpen(struct SensorDevice *sdev)
|
|||
*/
|
||||
static int SensorDeviceRead(struct SensorDevice *sdev, size_t len)
|
||||
{
|
||||
#ifdef ADD_NUTTX_FETURES
|
||||
int ret;
|
||||
ret = PrivRead(sdev->fd, sdev->buffer, len);
|
||||
if (ret != len ){
|
||||
perror("Failed to read data!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
#else
|
||||
//send i2c device start signal and address, need to implemente in OS i2c driver
|
||||
if (PrivWrite(sdev->fd, NULL, 0) != 1)
|
||||
return -1;
|
||||
|
||||
PrivTaskDelay(50);
|
||||
|
||||
//Read i2c device data from i2c device address
|
||||
if (PrivRead(sdev->fd, sdev->buffer, len) != 1)
|
||||
if (PrivRead(sdev->fd, sdev->buffer, len) < 0)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static struct SensorDone done =
|
||||
|
|
|
@ -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
|
|
@ -0,0 +1,5 @@
|
|||
ifeq ($(CONFIG_SENSOR_QS_FX),y)
|
||||
SRC_DIR += qs-fx
|
||||
endif
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
|
@ -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')
|
|
@ -0,0 +1,3 @@
|
|||
SRC_FILES := qs-fx.c
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
|
@ -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')
|
|
@ -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;
|
||||
}
|
|
@ -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
|
|
@ -0,0 +1,5 @@
|
|||
ifeq ($(CONFIG_SENSOR_QS_FS),y)
|
||||
SRC_DIR += qs-fs
|
||||
endif
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
|
@ -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')
|
|
@ -0,0 +1,3 @@
|
|||
SRC_FILES := qs-fs.c
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
|
@ -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')
|
|
@ -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;
|
||||
}
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -34,17 +34,26 @@ static uint32 I2cDeviceWrite(void *dev, struct BusBlockWriteParam *write_param)
|
|||
NULL_PARAM_CHECK(dev);
|
||||
NULL_PARAM_CHECK(write_param);
|
||||
|
||||
uint32 ret;
|
||||
|
||||
struct I2cHardwareDevice *i2c_dev = (struct I2cHardwareDevice *)dev;
|
||||
struct I2cDataStandard i2c_msg;
|
||||
|
||||
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 = (uint8 *)x_malloc(write_param->size);
|
||||
memcpy(i2c_msg.buf, write_param->buffer, write_param->size);
|
||||
|
||||
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);
|
||||
ret = i2c_dev->i2c_dev_done->dev_write(i2c_dev, &i2c_msg);
|
||||
|
||||
x_free(i2c_msg.buf);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static uint32 I2cDeviceRead(void *dev, struct BusBlockReadParam *read_param)
|
||||
|
@ -53,16 +62,25 @@ static uint32 I2cDeviceRead(void *dev, struct BusBlockReadParam *read_param)
|
|||
NULL_PARAM_CHECK(read_param);
|
||||
|
||||
struct I2cHardwareDevice *i2c_dev = (struct I2cHardwareDevice *)dev;
|
||||
struct I2cDataStandard i2c_msg;
|
||||
struct I2cDataStandard i2c_msg_write, i2c_msg_read;
|
||||
|
||||
i2c_msg.addr = i2c_dev->i2c_dev_addr;
|
||||
i2c_msg.flags = I2C_RD;
|
||||
i2c_msg.buf = read_param->buffer;
|
||||
i2c_msg.len = read_param->size;
|
||||
i2c_msg.retries = 1;
|
||||
i2c_msg.next = NONE;
|
||||
i2c_msg_write.addr = i2c_dev->i2c_dev_addr;
|
||||
i2c_msg_write.flags = I2C_WR;
|
||||
i2c_msg_write.buf = NONE;
|
||||
i2c_msg_write.len = 0;
|
||||
i2c_msg_write.retries = 10;
|
||||
i2c_msg_write.next = NONE;
|
||||
|
||||
return i2c_dev->i2c_dev_done->dev_read(i2c_dev, &i2c_msg);
|
||||
i2c_dev->i2c_dev_done->dev_write(i2c_dev, &i2c_msg_write);
|
||||
|
||||
i2c_msg_read.addr = i2c_dev->i2c_dev_addr;
|
||||
i2c_msg_read.flags = I2C_RD;
|
||||
i2c_msg_read.buf = read_param->buffer;
|
||||
i2c_msg_read.len = read_param->size;
|
||||
i2c_msg_read.retries = 10;
|
||||
i2c_msg_read.next = NONE;
|
||||
|
||||
return i2c_dev->i2c_dev_done->dev_read(i2c_dev, &i2c_msg_read);
|
||||
}
|
||||
|
||||
static const struct HalDevDone dev_done =
|
||||
|
|
Loading…
Reference in New Issue