Skip to main content
Glama

Rake

Calculate I2C timing

calc_i2c_timing
Read-onlyIdempotent

Computes 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

NameRequiredDescriptionDefault
modeYesstandard (up to 100 kHz), fast (up to 400 kHz) or fast-plus (up to 1 MHz).
bus_hzNoThe wanted SCL frequency in Hz. Default: the highest the mode allows.
fall_nsNoThe fall time of SCL and SDA in ns. Default: the longest the mode allows.
rise_nsNoThe rise time of SCL and SDA in ns. Default: the longest the mode allows.
timingrNostm32-timingr only: an existing I2C_TIMINGR value to check. Omit it to compute one.
clock_hzYesThe clock of the I2C controller in Hz. For stm32-timingr, the I2C kernel clock selected in RCC.
controllerYesgeneric for counts of the controller's clock, or stm32-timingr for the STM32 I2C_TIMINGR register.
analog_filterNostm32-timingr only: whether the analog noise filter is on. Default true, as after reset.
digital_filterNostm32-timingr only: the DNF field of I2C_CR1, 0 to 15. Default 0.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.3/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare readOnly, idempotent, non-destructive and closed-world, so safety is covered. The description adds real behavioral context beyond them: the check-existing-value mode, the two distinct result forms, and the hardware applicability limit that F1/F2/F4/L1 lack the TIMINGR register. It does not say what happens when the requested bus speed cannot be achieved with the given clock, which is the main remaining gap.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Four sentences, front-loaded with the core computation and followed by the use case and the two controller modes. Dense but every sentence carries information; the only slight redundancy is restating the generic/stm32-timingr split already implied by the schema enum.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a nine-parameter tool with no output schema, the description covers what is returned (clock counts vs I2C_TIMINGR), the compute-vs-check modes, and hardware applicability. It omits failure behavior when the clock/mode combination makes the target bus speed unreachable, which an agent would need to interpret errors.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the baseline is 3, but the description adds meaning on top: it explains what each controller enum value yields and constrains 'stm32-timingr' to the STM32 series that actually have I2C_TIMINGR. The distinction between computing and checking via the timingr parameter is reinforced in prose, though default-value behavior is left to the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description opens with a specific verb and resource ('Computes I2C timing from the limits of the I2C-bus specification') and immediately names the two output shapes: SCL low/high counts of the controller clock, or a controller register value. It also distinguishes the two controller modes ('generic' vs 'stm32-timingr'), so an agent can tell what this tool produces without opening the schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

It gives a concrete when-to-use case ('set up an I2C controller instead of copying a timing value from another project, where the clock differs') and a when-not-to-use case ('F1, F2, F4 and L1 do not' have I2C_TIMINGR, so the register mode is unavailable). It also states the secondary check use ('check an existing register value'). It does not compare against sibling calculators, but those cover different peripherals.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources