PrintF_SWO_Bridge.h


1
#pragma once
2
// ***********************************************************************
3
extern "C"
4
{           // helper functions to redirect printf() to SWD/SWO trace output
5
// ***********************************************************************
6
int __io_putchar(int ch)
7
{
8
    ITM_SendChar(ch);
9
    return(ch);
10
}
11
// ***********************************************************************
12
int _write(int file, char *ptr, int len)
13
{
14
    for (int i = 0; i < len; i++)
15
    {
16
        __io_putchar(*ptr++);
17
    }
18
    return len;
19
}
20
}
21
// ***********************************************************************