-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsm_printf.c
44 lines (36 loc) · 1.28 KB
/
sm_printf.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*
* Copyright 2016 NXP
*
* This software is owned or controlled by NXP and may only be used
* strictly in accordance with the applicable license terms. By expressly
* accepting such terms or by downloading, installing, activating and/or
* otherwise using the software, you are agreeing that you have read, and
* that you agree to comply with and are bound by, such license terms. If
* you do not agree to be bound by the applicable license terms, then you
* may not retain, install, activate or otherwise use the software.
*/
#include <stdio.h>
#include <stdarg.h>
#include "sm_printf.h"
#if AX_EMBEDDED
# include "fsl_device_registers.h"
# include "fsl_debug_console.h"
# include "board.h"
#else
# define PRINTF printf
#endif
#define MAX_SER_BUF_SIZE (1024)
void sm_printf(uint8_t dev, const char * format, ...)
{
uint8_t buffer[MAX_SER_BUF_SIZE + 1];
va_list vArgs;
dev = dev; // avoids warning; dev can be used to determine output channel
va_start(vArgs, format);
#ifdef _WIN32
vsnprintf_s((char *)buffer, MAX_SER_BUF_SIZE, MAX_SER_BUF_SIZE, (char const *)format, vArgs);
#else
vsnprintf((char *)buffer, MAX_SER_BUF_SIZE, (char const *)format, vArgs);
#endif
va_end(vArgs);
PRINTF("%s", buffer);
}