Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

适配 5.0.0 改动 #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
适配 5.0.0 改动
zhkag committed Dec 9, 2022

Verified

This commit was signed with the committer’s verified signature.
AgeManning Age Manning
commit 1bcd917f08023562b8832e793ccb7ce0202ae0a4
4 changes: 4 additions & 0 deletions sensor_ti_hdc1000.c
Original file line number Diff line number Diff line change
@@ -15,7 +15,11 @@ static struct hdc1000_device *hdc1000_dev;

static rt_err_t _hdc1000_init(struct rt_sensor_intf *intf)
{
#if defined(RTTHREAD_VERSION) && (RTTHREAD_VERSION >= RT_VERSION_CHECK(5, 0, 0))
rt_uint8_t i2c_addr = (rt_uint32_t)(intf->arg) & 0xff;
#else
rt_uint8_t i2c_addr = (rt_uint32_t)(intf->user_data) & 0xff;
#endif

hdc1000_dev = hdc1000_init(intf->dev_name, i2c_addr);

6 changes: 6 additions & 0 deletions sensor_ti_hdc1000.h
Original file line number Diff line number Diff line change
@@ -2,7 +2,13 @@
#ifndef SENSOR_TI_HDC1000_H__
#define SENSOR_TI_HDC1000_H__

#include <rtthread.h>
#if defined(RTTHREAD_VERSION) && (RTTHREAD_VERSION >= RT_VERSION_CHECK(5, 0, 0))
#include "drivers/sensor.h"
#else
#include "sensor.h"
#endif

#include "hdc1000_reg.h"

#define HDC1000_SLAVE_ADDR_DEFAULT ( HDC1000_DEVICE_IIC_BUS_ADDRESS )
4 changes: 4 additions & 0 deletions sensor_ti_hdc1000_example.c
Original file line number Diff line number Diff line change
@@ -10,7 +10,11 @@ int rt_hw_hdc1000_port(void)
struct rt_sensor_config cfg;
rt_int8_t result;
cfg.intf.dev_name = "i2c1";
#if defined(RTTHREAD_VERSION) && (RTTHREAD_VERSION >= RT_VERSION_CHECK(5, 0, 0))
cfg.intf.arg = (void *)HDC1000_SLAVE_ADDR_DEFAULT;
#else
cfg.intf.user_data = (void *)HDC1000_SLAVE_ADDR_DEFAULT;
#endif
cfg.irq_pin.pin = RT_PIN_NONE;

result = rt_hw_hdc1000_init("hdc1000", &cfg);