zephyr/drivers/i2c/i2c-priv.h
Kumar Gala a1b77fd589 zephyr: replace zephyr integer types with C99 types
git grep -l 'u\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/u\(8\|16\|32\|64\)_t/uint\1_t/g"
	git grep -l 's\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/s\(8\|16\|32\|64\)_t/int\1_t/g"

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-06-08 08:23:57 -05:00

43 lines
864 B
C

/*
* Copyright (c) 2017 Linaro Limited
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef ZEPHYR_DRIVERS_I2C_I2C_PRIV_H_
#define ZEPHYR_DRIVERS_I2C_I2C_PRIV_H_
#include <drivers/i2c.h>
#include <dt-bindings/i2c/i2c.h>
#include <logging/log.h>
#ifdef __cplusplus
extern "C" {
#endif
static inline uint32_t i2c_map_dt_bitrate(uint32_t bitrate)
{
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;
}
LOG_ERR("Invalid I2C bit rate value");
return 0;
}
#ifdef __cplusplus
}
#endif
#endif /* ZEPHYR_DRIVERS_I2C_I2C_PRIV_H_ */