Skip to content

Commit

Permalink
Add some missing i2c function documentation
Browse files Browse the repository at this point in the history
Add i2c_get_index for consistency - just calls i2c_hw_index
  • Loading branch information
peterharperuk committed Feb 26, 2024
1 parent 0c65e1d commit f8e2479
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/rp2_common/hardware_i2c/include/hardware/i2c.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 hardware instance number to I2C instance
* \ingroup hardware_i2c
*
* \param Number of I2C, 0 or 1
* \return I2C hardware instance
*/
static inline i2c_inst_t *i2c_get_instance(uint instance) {
static_assert(NUM_I2CS == 2, "");
invalid_params_if(I2C, instance >= NUM_I2CS);
Expand Down

0 comments on commit f8e2479

Please sign in to comment.