From f0533c9a3ed7cec49401b008a7275c37b9ade52f Mon Sep 17 00:00:00 2001 From: Peter Harper Date: Mon, 26 Feb 2024 14:34:47 +0000 Subject: [PATCH] Add some missing i2c function documentation Add i2c_get_index for consistency - just calls i2c_hw_index --- .../hardware_i2c/include/hardware/i2c.h | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/rp2_common/hardware_i2c/include/hardware/i2c.h b/src/rp2_common/hardware_i2c/include/hardware/i2c.h index 33454f02a..c41822a2c 100644 --- a/src/rp2_common/hardware_i2c/include/hardware/i2c.h +++ b/src/rp2_common/hardware_i2c/include/hardware/i2c.h @@ -148,11 +148,33 @@ static inline uint i2c_hw_index(i2c_inst_t *i2c) { return i2c == i2c1 ? 1 : 0; } +/*! \brief Convert I2C instance to hardware instance number + * \ingroup hardware_i2c + * + * \param i2c I2C instance + * \return Number of I2C, 0 or 1. + */ +static inline uint i2c_get_index(i2c_inst_t *i2c) { + return i2c_hw_index(i2c); +} + +/*! \brief Return pointer to structure containing i2c hardware registers + * \ingroup hardware_i2c + * + * \param i2c I2C instance + * \return pointer to \ref i2c_hw_t + */ static inline i2c_hw_t *i2c_get_hw(i2c_inst_t *i2c) { i2c_hw_index(i2c); // check it is a hw i2c return i2c->hw; } +/*! \brief Convert I2C instance number to hardware instance + * \ingroup hardware_i2c + * + * \param instance Number of I2C, 0 or 1 + * \return the i2C instance + */ static inline i2c_inst_t *i2c_get_instance(uint instance) { static_assert(NUM_I2CS == 2, ""); invalid_params_if(I2C, instance >= NUM_I2CS);