Skip to content

Pinfit

Describe the shape of your C, write only the logic

Pinfit is a small, YAML-driven command line tool for embedded C projects. You describe an interface, a module, a state machine or another well-known pattern in a short YAML file, and Pinfit generates the headers and sources around it: the structs, the function-pointer tables, the null checks, the dispatch, the Doxygen comments.

Your own code lives in named user regions inside those generated files. Regenerate as often as you like — Pinfit writes the structure around your code and never touches what is inside a region.

drivers/RA/ra_iic.module.yaml
kind: module
name: ra_iic
description: RA-family I2C implementation
header: ra_iic.h
source: ra_iic.c

implements:
  - common_iic

context:
  - void *hardware
drivers/RA/ra_iic.c (generated — you fill in the region)
/*@Pinfit(private-function:ra_iic_common_iic_write)*/
static common_iic_status_t ra_iic_common_iic_write(void *context, uint32_t slave_address, const uint8_t *data, uint32_t length)
{
    ra_iic_context_t *module = (ra_iic_context_t *)context;
    common_iic_status_t pinfit_result = COMMON_IIC_INVALID_PARAM;
    (void)module;
    (void)slave_address;
    (void)data;
    (void)length;

    /*@Pinfit usercode+ function.common_iic.write.body*/
    /* Your driver code goes here and survives every regeneration. */
    /*@Pinfit usercode-*/
    return pinfit_result;
}

Get started See the generators

Why Pinfit

  • Regeneration is safe


    Hand-written code lives in usercode+ / usercode- regions. Change the YAML, regenerate, and your logic is carried over. Remove a YAML item and its region is kept as an orphan rather than deleted.

    User regions

  • Seven generators, one workflow


    Interfaces, modules, state machines, observers, command tables, status codes and adapters. Every kind is one YAML file and the same pinfit generate command.

    Generators

  • MISRA-oriented C


    Single return per function, null-checked interface dispatch, explicit consumption of unused parameters — the generated skeleton is written for safety-critical review from the start.

    MISRA notes

  • No runtime, no dependency


    Pinfit produces plain C with no library to link and nothing to allocate. A directory with its own pinfit.yaml is a self-contained project, so vendored libraries stay untouched.

    Nested projects

The workflow in four commands

pinfit init
pinfit create interface common_iic drivers/Interface
pinfit create module ra_iic drivers/RA --implements common_iic
pinfit generate

init writes a pinfit.yaml and nothing else — Pinfit never chooses a source layout for you. create scaffolds a fully commented spec file. generate scans the project tree and writes every header and source that the specs describe.

Walk through it step by step

What Pinfit is not

  • Not a build system. Pinfit writes .h and .c files; your existing Make, CMake or IDE project compiles them.
  • Not a C parser. It reads YAML, plus a light best-effort scan of your headers for @PinfitSwitch enum lookups.
  • Not a lock-in. pinfit detach strips every marker and leaves you with ordinary C source you can maintain by hand forever.