2017-08-11 01:22:27 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2017 Linaro Limited
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
|
|
|
|
2018-09-15 01:43:44 +08:00
|
|
|
#ifndef ZEPHYR_DRIVERS_I2C_I2C_PRIV_H_
|
|
|
|
#define ZEPHYR_DRIVERS_I2C_I2C_PRIV_H_
|
2017-08-11 01:22:27 +08:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2019-06-26 03:53:54 +08:00
|
|
|
#include <drivers/i2c.h>
|
2017-08-11 01:22:27 +08:00
|
|
|
#include <dt-bindings/i2c/i2c.h>
|
2018-09-18 02:24:08 +08:00
|
|
|
#include <logging/log.h>
|
2017-08-11 01:22:27 +08:00
|
|
|
|
2019-03-13 05:15:42 +08:00
|
|
|
static inline u32_t i2c_map_dt_bitrate(u32_t bitrate)
|
2017-08-11 01:22:27 +08:00
|
|
|
{
|
|
|
|
switch (bitrate) {
|
|
|
|
case I2C_BITRATE_STANDARD:
|
|
|
|
return I2C_SPEED_STANDARD << I2C_SPEED_SHIFT;
|
|
|
|
case I2C_BITRATE_FAST:
|
|
|
|
return I2C_SPEED_FAST << I2C_SPEED_SHIFT;
|
|
|
|
case I2C_BITRATE_FAST_PLUS:
|
|
|
|
return I2C_SPEED_FAST_PLUS << I2C_SPEED_SHIFT;
|
|
|
|
case I2C_BITRATE_HIGH:
|
|
|
|
return I2C_SPEED_HIGH << I2C_SPEED_SHIFT;
|
|
|
|
case I2C_BITRATE_ULTRA:
|
|
|
|
return I2C_SPEED_ULTRA << I2C_SPEED_SHIFT;
|
|
|
|
}
|
|
|
|
|
2018-09-18 02:24:08 +08:00
|
|
|
LOG_ERR("Invalid I2C bit rate value");
|
2017-08-11 01:22:27 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2018-09-15 01:43:44 +08:00
|
|
|
#endif /* ZEPHYR_DRIVERS_I2C_I2C_PRIV_H_ */
|