Skip to content

Commit

Permalink
Implement TwoWire::setClock
Browse files Browse the repository at this point in the history
  • Loading branch information
maxgerhardt committed Jun 18, 2021
1 parent 7530ddb commit 88d1cd7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions libraries/Wire/src/Wire.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,11 @@ inline void TwoWire::resetTxBuffer(void)
}
}

void TwoWire::setClock(uint32_t clock_hz)
{
i2c_set_clock(&_i2c, clock_hz);
}

// Preinstantiate Objects //////////////////////////////////////////////////////

TwoWire Wire = TwoWire();
5 changes: 5 additions & 0 deletions libraries/Wire/src/utility/twi.c
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,11 @@ void I2C1_ER_IRQHandler(void)
}
}

void i2c_set_clock(i2c_t *obj, uint32_t clock_hz)
{
i2c_clock_config(obj->i2c, clock_hz, I2C_DTCY_2);
}

#endif
#ifdef __cplusplus
}
Expand Down
2 changes: 2 additions & 0 deletions libraries/Wire/src/utility/twi.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ void i2c_attach_slave_rx_callback(i2c_t *obj, void (*function)(uint8_t *, int));
void i2c_attach_slave_tx_callback(i2c_t *obj, void (*function)(void));
/* Write bytes to master */
i2c_status_e i2c_slave_write_buffer(i2c_t *obj, uint8_t *data, uint16_t size);
/* set I2C clock speed */
void i2c_set_clock(i2c_t *obj, uint32_t clock_hz);

#ifdef __cplusplus
}
Expand Down

0 comments on commit 88d1cd7

Please sign in to comment.