# TraxProbe BareMetal Integration

Guide for using TraxProbe without an RTOS (bare-metal / super-loop).

## Configuration

In `App/Config/trax_config.h`:

```c
#define TRAX_CFG_RTOS_TYPE  TRAX_RTOS_NONE   // default, can be omitted
```

## No Additional Files Required

BareMetal mode does not require any files from the `os/common/` or `os/FreeRTOS/` directories. The RTOS table management and trace hooks are automatically excluded when `TRAX_CFG_RTOS_TYPE == TRAX_RTOS_NONE`.

## Polling

Without an RTOS task to drain the ring buffer, your application must call `trax_process()` periodically from the main loop:

```c
int main(void)
{
    trax_init();

    for (;;) {
        // Application work...
        app_run();

        // Drain trace buffer and process host commands
        trax_process();
    }
}
```

## Timing Recommendations

- Call `trax_process()` at least every 10 ms for responsive host communication
- At 921600 baud UART, each call can transmit ~920 bytes
- If using DMA transport, less frequent calls are acceptable

## Timestamp Hook

The tick counter must be incremented from the SysTick ISR (or equivalent periodic interrupt):

```c
void SysTick_Handler(void)
{
    trax_timestamp_tick();
    // ... other SysTick work ...
}
```

The order of `trax_timestamp_tick()` relative to other tracing inside the
handler does not matter for timestamp correctness. The host (Traxcope)
detects and compensates for the tick-boundary race that used to require
calling `trax_timestamp_tick()` first — see the per-core stale-tick branch
in `MessageDecoder::calculateDeviceTime`. Place the call wherever it reads
naturally for your application.

## ISR Tracing

User ISR tracing macros (`TRAX_ISR_ENTER` / `TRAX_ISR_EXIT`) work identically in BareMetal mode. No RTOS hooks are involved.

It is safe to bracket `SysTick_Handler` itself with `TRAX_ISR_ENTER` /
`TRAX_ISR_EXIT` in any order relative to `trax_timestamp_tick()`:

```c
TRAX_ISR_DEFINE(TRAX_TID_ISR_TICK, "SysTick", 15);

void SysTick_Handler(void)
{
    TRAX_ISR_ENTER(TRAX_TID_ISR_TICK);
    trax_timestamp_tick();
    // ... other SysTick work ...
    TRAX_ISR_EXIT(TRAX_TID_ISR_TICK);
}
```

Both the ENTER and EXIT timestamps are reconstructed correctly on the
host even if `trax_timestamp_tick()` is called between them.
