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

[sensor_v1]lps22hb pkg adapt sensor_v1 frame #4

Merged
merged 1 commit into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
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
4 changes: 3 additions & 1 deletion SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ src = []
cwd = GetCurrentDir()

# add lps22hb src files.
src += Glob('sensor_st_lps22hb.c')
src += Glob('libraries/lps22hb.c')
src += Glob('libraries/lps22hb_reg.c')

if GetDepend('PKG_LPS22HB_USING_SENSOR_V1'):
src += Glob('st_lps22hb_sensor_v1.c')

# add lps22hb include path.
path = [cwd, cwd + '/libraries']

Expand Down
13 changes: 0 additions & 13 deletions sensor_st_lps22hb.h

This file was deleted.

8 changes: 4 additions & 4 deletions sensor_st_lps22hb.c → st_lps22hb_sensor_v1.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

#include "sensor_st_lps22hb.h"
#include "st_lps22hb_sensor_v1.h"

#define DBG_ENABLE
#define DBG_LEVEL DBG_LOG
Expand All @@ -20,7 +20,7 @@ static int32_t lps22hb_get_tick(void)
return rt_tick_get();
}

static int rt_i2c_write_reg(uint16_t addr, uint16_t reg, uint8_t *data, uint16_t len)
static int32_t rt_i2c_write_reg(uint16_t addr, uint16_t reg, uint8_t *data, uint16_t len)
{
rt_uint8_t tmp = reg;
struct rt_i2c_msg msgs[2];
Expand All @@ -43,7 +43,7 @@ static int rt_i2c_write_reg(uint16_t addr, uint16_t reg, uint8_t *data, uint16_t
return RT_EOK;
}

static int rt_i2c_read_reg(uint16_t addr, uint16_t reg, uint8_t *data, uint16_t len)
static int32_t rt_i2c_read_reg(uint16_t addr, uint16_t reg, uint8_t *data, uint16_t len)
{
rt_uint8_t tmp = reg;
struct rt_i2c_msg msgs[2];
Expand Down Expand Up @@ -261,7 +261,7 @@ static rt_err_t _lps22hb_baro_init(struct rt_sensor_intf *intf)

return RT_EOK;
}
static rt_size_t lps22hb_fetch_data(struct rt_sensor_device *sensor, void *buf, rt_size_t len)
static RT_SIZE_TYPE lps22hb_fetch_data(struct rt_sensor_device *sensor, void *buf, rt_size_t len)
{
if (sensor->config.mode == RT_SENSOR_MODE_POLLING)
{
Expand Down
21 changes: 21 additions & 0 deletions st_lps22hb_sensor_v1.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@


#ifndef SENSOR_ST_LPS22HB_H__
#define SENSOR_ST_LPS22HB_H__
#include <rtthread.h>
#include <rtdevice.h>

#if defined(RT_VERSION_CHECK)
#if (RTTHREAD_VERSION >= RT_VERSION_CHECK(5, 0, 2))
#define RT_SIZE_TYPE rt_ssize_t
#else
#define RT_SIZE_TYPE rt_size_t
#endif
#endif
#include "lps22hb.h"

#define LPS22HB_ADDR_DEFAULT (0xBA >> 1)

int rt_hw_lps22hb_init(const char *name, struct rt_sensor_config *cfg);

#endif
Loading