-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlog.c
50 lines (43 loc) · 1.25 KB
/
log.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
45
46
47
48
49
50
/*
* log.c
*
* Created on: Dec 18, 2018
* Author: Dan Walkes
*/
#include "retargetserial.h"
#include "log.h"
#include <stdbool.h>
#if INCLUDE_LOGGING
/**
* @return a timestamp value for the logger, typically based on a free running timer.
* This will be printed at the beginning of each log message.
*/
uint32_t loggerGetTimestamp(void)
{
return timerGetRunTimeMilliseconds();
}
/**
* Initialize logging for Blue Gecko.
* See https://www.silabs.com/community/wireless/bluetooth/forum.topic.html/how_to_do_uart_loggi-ByI
*/
void logInit(void)
{
RETARGET_SerialInit();
/**
* See https://siliconlabs.github.io/Gecko_SDK_Doc/efm32g/html/group__RetargetIo.html#ga9e36c68713259dd181ef349430ba0096
* RETARGET_SerialCrLf() ensures each linefeed also includes carriage return. Without it, the first character is shifted in TeraTerm
*/
RETARGET_SerialCrLf(true);
// from https://stackoverflow.com/questions/46612044/how-do-i-clear-a-serial-screen
// to clear tera term screen on startup
LOG_INFO("\033[2J\033[H");
LOG_INFO("Initialized Logging");
}
/**
* Block for chars to be flushed out of the serial port. Important to do this before entering SLEEP() or you may see garbage chars output.
*/
void logFlush(void)
{
RETARGET_SerialFlush();
}
#endif