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.
kind: module
name: ra_iic
description: RA-family I2C implementation
header: ra_iic.h
source: ra_iic.c
implements:
- common_iic
context:
- void *hardware
/*@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. -
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 generatecommand. -
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.
-
No runtime, no dependency
Pinfit produces plain C with no library to link and nothing to allocate. A directory with its own
pinfit.yamlis a self-contained project, so vendored libraries stay untouched.
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.
What Pinfit is not¶
- Not a build system. Pinfit writes
.hand.cfiles; 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
@PinfitSwitchenum lookups. - Not a lock-in.
pinfit detachstrips every marker and leaves you with ordinary C source you can maintain by hand forever.