drivers: sensor: icm42605: Fix build issues
There are several different issues when trying to build the icm42605 sensor driver: * Missing entry in drivers/sensor/CMakeLists.txt * Issues with #ifndef in header files * Issues with const usage * Missing function prototypes in headers * Fix use of LOG_MODULE_REGISTER v LOG_MODULE_DECLARE * Add missing dts node to tests/drivers/build_all/spi.dtsi Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
This commit is contained in:
parent
f183d6492f
commit
651898e13d
10 changed files with 38 additions and 18 deletions
|
@ -27,6 +27,7 @@ add_subdirectory_ifdef(CONFIG_TI_HDC ti_hdc)
|
|||
add_subdirectory_ifdef(CONFIG_HMC5883L hmc5883l)
|
||||
add_subdirectory_ifdef(CONFIG_HP206C hp206c)
|
||||
add_subdirectory_ifdef(CONFIG_HTS221 hts221)
|
||||
add_subdirectory_ifdef(CONFIG_ICM42605 icm42605)
|
||||
add_subdirectory_ifdef(CONFIG_IIS2DH iis2dh)
|
||||
add_subdirectory_ifdef(CONFIG_IIS2DLPC iis2dlpc)
|
||||
add_subdirectory_ifdef(CONFIG_IIS2ICLX iis2iclx)
|
||||
|
|
|
@ -66,7 +66,7 @@ static inline void icm42605_convert_temp(struct sensor_value *val,
|
|||
|
||||
static int icm42605_channel_get(const struct device *dev,
|
||||
enum sensor_channel chan,
|
||||
const struct sensor_value *val)
|
||||
struct sensor_value *val)
|
||||
{
|
||||
const struct icm42605_data *drv_data = dev->data;
|
||||
|
||||
|
@ -124,7 +124,7 @@ static int icm42605_channel_get(const struct device *dev,
|
|||
int icm42605_tap_fetch(const struct device *dev)
|
||||
{
|
||||
int result = 0;
|
||||
const struct icm42605_data *drv_data = dev->data;
|
||||
struct icm42605_data *drv_data = dev->data;
|
||||
|
||||
if (drv_data->tap_en &&
|
||||
(drv_data->tap_handler || drv_data->double_tap_handler)) {
|
||||
|
|
|
@ -16,9 +16,10 @@
|
|||
#include "icm42605_reg.h"
|
||||
|
||||
typedef void (*tap_fetch_t)(const struct device *dev);
|
||||
int icm42605_tap_fetch(const struct device *dev);
|
||||
|
||||
struct icm42605_data {
|
||||
struct device *spi;
|
||||
const struct device *spi;
|
||||
|
||||
uint8_t fifo_data[HARDWARE_FIFO_SIZE];
|
||||
|
||||
|
@ -44,8 +45,8 @@ struct icm42605_data {
|
|||
|
||||
bool sensor_started;
|
||||
|
||||
struct device *dev;
|
||||
struct device *gpio;
|
||||
const struct device *dev;
|
||||
const struct device *gpio;
|
||||
struct gpio_callback gpio_cb;
|
||||
|
||||
struct sensor_trigger data_ready_trigger;
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#include "icm42605_reg.h"
|
||||
#include "icm42605_spi.h"
|
||||
|
||||
LOG_MODULE_REGISTER(ICM42605, CONFIG_SENSOR_LOG_LEVEL);
|
||||
LOG_MODULE_DECLARE(ICM42605, CONFIG_SENSOR_LOG_LEVEL);
|
||||
|
||||
int icm42605_set_fs(const struct device *dev, uint16_t a_sf, uint16_t g_sf)
|
||||
{
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifdef ZEPHYR_DRIVERS_SENSOR_ICM42605_ICM42605_SETUP_H_
|
||||
#ifndef ZEPHYR_DRIVERS_SENSOR_ICM42605_ICM42605_SETUP_H_
|
||||
#define ZEPHYR_DRIVERS_SENSOR_ICM42605_ICM42605_SETUP_H_
|
||||
|
||||
#include <device.h>
|
||||
|
@ -13,6 +13,7 @@ int icm42605_sensor_init(const struct device *dev);
|
|||
int icm42605_turn_on_fifo(const struct device *dev);
|
||||
int icm42605_turn_off_fifo(const struct device *dev);
|
||||
int icm42605_turn_off_sensor(const struct device *dev);
|
||||
int icm42605_turn_on_sensor(const struct device *dev);
|
||||
int icm42605_set_odr(const struct device *dev, int a_rate, int g_rate);
|
||||
|
||||
#endif /* __SENSOR_ICM42605_ICM42605_SETUP__ */
|
||||
|
|
|
@ -9,12 +9,12 @@
|
|||
#include <logging/log.h>
|
||||
#include <sys/__assert.h>
|
||||
|
||||
LOG_MODULE_REGISTER(ICM42605, CONFIG_SENSOR_LOG_LEVEL);
|
||||
LOG_MODULE_DECLARE(ICM42605, CONFIG_SENSOR_LOG_LEVEL);
|
||||
|
||||
struct device *spi_dev;
|
||||
static struct spi_config *spi_cfg;
|
||||
static const struct device *spi_dev;
|
||||
static const struct spi_config *spi_cfg;
|
||||
|
||||
int inv_spi_single_write(uint8_t reg, const uint8_t *data)
|
||||
int inv_spi_single_write(uint8_t reg, uint8_t *data)
|
||||
{
|
||||
int result;
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifdef ZEPHYR_DRIVERS_SENSOR_ICM42605_ICM42605_SPI_H_
|
||||
#ifndef ZEPHYR_DRIVERS_SENSOR_ICM42605_ICM42605_SPI_H_
|
||||
#define ZEPHYR_DRIVERS_SENSOR_ICM42605_ICM42605_SPI_H_
|
||||
|
||||
#include <device.h>
|
||||
|
|
|
@ -74,10 +74,9 @@ static void icm42605_gpio_callback(const struct device *dev,
|
|||
k_sem_give(&drv_data->gpio_sem);
|
||||
}
|
||||
|
||||
static void icm42605_thread_cb(void *arg)
|
||||
static void icm42605_thread_cb(const struct device *dev)
|
||||
{
|
||||
const struct device *dev = arg;
|
||||
const struct icm42605_data *drv_data = dev->data;
|
||||
struct icm42605_data *drv_data = dev->data;
|
||||
const struct icm42605_config *cfg = dev->config;
|
||||
|
||||
if (drv_data->data_ready_handler != NULL) {
|
||||
|
@ -97,7 +96,7 @@ static void icm42605_thread_cb(void *arg)
|
|||
static void icm42605_thread(int dev_ptr, int unused)
|
||||
{
|
||||
const struct device *dev = INT_TO_POINTER(dev_ptr);
|
||||
const struct icm42605_data *drv_data = dev->data;
|
||||
struct icm42605_data *drv_data = dev->data;
|
||||
|
||||
ARG_UNUSED(unused);
|
||||
|
||||
|
@ -140,7 +139,7 @@ int icm42605_init_interrupt(const struct device *dev)
|
|||
|
||||
k_thread_create(&drv_data->thread, drv_data->thread_stack,
|
||||
CONFIG_ICM42605_THREAD_STACK_SIZE,
|
||||
(k_thread_entry_t)icm42605_thread, dev,
|
||||
(k_thread_entry_t)icm42605_thread, drv_data,
|
||||
0, NULL, K_PRIO_COOP(CONFIG_ICM42605_THREAD_PRIORITY),
|
||||
0, K_NO_WAIT);
|
||||
|
||||
|
|
|
@ -102,7 +102,17 @@
|
|||
<&test_gpio 0 0>,
|
||||
<&test_gpio 0 0>,
|
||||
<&test_gpio 0 0>,
|
||||
<&test_gpio 0 0>;
|
||||
<&test_gpio 0 0>,
|
||||
<&test_gpio 0 0>,
|
||||
<&test_gpio 0 0>,
|
||||
<&test_gpio 0 0>,
|
||||
<&test_gpio 0 0>,
|
||||
<&test_gpio 0 0>,
|
||||
<&test_gpio 0 0>,
|
||||
<&test_gpio 0 0>,
|
||||
<&test_gpio 0 0>,
|
||||
<&test_gpio 0 0>,
|
||||
<&test_gpio 0 0>; /* 0x40 */
|
||||
|
||||
#include "spi.dtsi"
|
||||
};
|
||||
|
|
|
@ -559,3 +559,11 @@ test_spi_iis2iclx: iis2iclx@37 {
|
|||
drdy-gpios = <&test_gpio 0 0>;
|
||||
int-pin = <1>;
|
||||
};
|
||||
|
||||
test_spi_icm42605: icm42605@38 {
|
||||
compatible = "invensense,icm42605";
|
||||
label = "ICM42605";
|
||||
reg = <0x38>;
|
||||
spi-max-frequency = <0>;
|
||||
int-gpios = <&test_gpio 0 0>;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue