c++: Fix compilation of C++ file that includes i2c.h
Within a C++ file I include i2c.h and got 6 of the following errors: zephyr/include/i2c.h:199:42: error: invalid conversion from ‘const void*’ to ‘const i2c_driver_api*’ [-fpermissive] const struct i2c_driver_api *api = dev->driver_api; ~~~~~^~~~~~~~~~ I fixed it with a c style conversion for each instance, so const struct i2c_driver_api *api = dev->driver_api; becomes const struct i2c_driver_api *api = (const struct i2c_driver_api *)dev->driver_api; I handled the instances for i2c_slave_driver_api alike. I tested this with a one of my own boards and communication with a I2C sensor. Signed-off-by: Alexander Polleti <metapsycholo@gmail.com>
This commit is contained in:
parent
72e7bfa680
commit
f568673e1b
|
@ -199,7 +199,8 @@ __syscall int i2c_configure(struct device *dev, u32_t dev_config);
|
|||
|
||||
static inline int _impl_i2c_configure(struct device *dev, u32_t dev_config)
|
||||
{
|
||||
const struct i2c_driver_api *api = dev->driver_api;
|
||||
const struct i2c_driver_api *api =
|
||||
(const struct i2c_driver_api *)dev->driver_api;
|
||||
|
||||
return api->configure(dev, dev_config);
|
||||
}
|
||||
|
@ -230,7 +231,8 @@ static inline int _impl_i2c_transfer(struct device *dev,
|
|||
struct i2c_msg *msgs, u8_t num_msgs,
|
||||
u16_t addr)
|
||||
{
|
||||
const struct i2c_driver_api *api = dev->driver_api;
|
||||
const struct i2c_driver_api *api =
|
||||
(const struct i2c_driver_api *)dev->driver_api;
|
||||
|
||||
return api->transfer(dev, msgs, num_msgs, addr);
|
||||
}
|
||||
|
@ -264,7 +266,8 @@ __syscall int i2c_slave_register(struct device *dev,
|
|||
static inline int _impl_i2c_slave_register(struct device *dev,
|
||||
struct i2c_slave_config *cfg)
|
||||
{
|
||||
const struct i2c_driver_api *api = dev->driver_api;
|
||||
const struct i2c_driver_api *api =
|
||||
(const struct i2c_driver_api *)dev->driver_api;
|
||||
|
||||
if (!api->slave_register) {
|
||||
return -ENOTSUP;
|
||||
|
@ -294,7 +297,8 @@ __syscall int i2c_slave_unregister(struct device *dev,
|
|||
static inline int _impl_i2c_slave_unregister(struct device *dev,
|
||||
struct i2c_slave_config *cfg)
|
||||
{
|
||||
const struct i2c_driver_api *api = dev->driver_api;
|
||||
const struct i2c_driver_api *api =
|
||||
(const struct i2c_driver_api *)dev->driver_api;
|
||||
|
||||
if (!api->slave_unregister) {
|
||||
return -ENOTSUP;
|
||||
|
@ -319,7 +323,8 @@ __syscall int i2c_slave_driver_register(struct device *dev);
|
|||
|
||||
static inline int _impl_i2c_slave_driver_register(struct device *dev)
|
||||
{
|
||||
const struct i2c_slave_driver_api *api = dev->driver_api;
|
||||
const struct i2c_slave_driver_api *api =
|
||||
(const struct i2c_slave_driver_api *)dev->driver_api;
|
||||
|
||||
return api->driver_register(dev);
|
||||
}
|
||||
|
@ -340,7 +345,8 @@ __syscall int i2c_slave_driver_unregister(struct device *dev);
|
|||
|
||||
static inline int _impl_i2c_slave_driver_unregister(struct device *dev)
|
||||
{
|
||||
const struct i2c_slave_driver_api *api = dev->driver_api;
|
||||
const struct i2c_slave_driver_api *api =
|
||||
(const struct i2c_slave_driver_api *)dev->driver_api;
|
||||
|
||||
return api->driver_unregister(dev);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue