Calculate I2C timing
calc_i2c_timingComputes I2C timing from the limits of the I2C-bus specification: the SCL low and high times for a bus speed as counts of the controller's clock, or the register value of a controller it knows. It can also check an existing register value against the limits. Use it to set up an I2C controller instead of copying a timing value from another project, where the clock differs. The controller generic gives counts for any controller that takes SCL low and high times. The controller stm32-timingr gives I2C_TIMINGR for the STM32 series that have that register, which F1, F2, F4 and L1 do not.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"controller": "<controller>",
"clock_hz": "<clock_hz>",
"mode": "<mode>"
},
"name": "calc_i2c_timing"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| mode | Yes | standard (up to 100 kHz), fast (up to 400 kHz) or fast-plus (up to 1 MHz). | |
| bus_hz | No | The wanted SCL frequency in Hz. Default: the highest the mode allows. | |
| fall_ns | No | The fall time of SCL and SDA in ns. Default: the longest the mode allows. | |
| rise_ns | No | The rise time of SCL and SDA in ns. Default: the longest the mode allows. | |
| timingr | No | stm32-timingr only: an existing I2C_TIMINGR value to check. Omit it to compute one. | |
| clock_hz | Yes | The clock of the I2C controller in Hz. For stm32-timingr, the I2C kernel clock selected in RCC. | |
| controller | Yes | generic for counts of the controller's clock, or stm32-timingr for the STM32 I2C_TIMINGR register. | |
| analog_filter | No | stm32-timingr only: whether the analog noise filter is on. Default true, as after reset. | |
| digital_filter | No | stm32-timingr only: the DNF field of I2C_CR1, 0 to 15. Default 0. |