-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserial_printf.h
48 lines (41 loc) · 1.62 KB
/
serial_printf.h
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
/*****************************************************************************************
* Purpose:
* Providing alternate to printf with extensible functionality for any given UART
*
*
*****************************************************************************************
* Author: Usama
* Created on: Jun 10, 2022
*****************************************************************************************
* Changes:
*
* Date Changed by Description
* ---- ---------- -----------
*
*
*
*
*****************************************************************************************/
#ifndef _SERIAL_PRINTF_H_
#define _SERIAL_PRINTF_H_
#include "stm32f7xx_hal.h"
#define SERIAL_TRANSMISSION_TIMEOUT_MS 20
#define SERIAL_STRING_BUFFER_SIZE 200
/**
* Supported formats:
* %b, %B - Binary
* %0b, %0B - Binary Filled with Leading Zeros up to Nearest Byte, e.g., %0b
* %1b, %1B - Binary with 1 Byte Width - Filled with Leading Zeros, e.g., %1b
* %2b, %2B - Binary with 2 Byte Width - Filled with Leading Zeros, e.g., %2b
* %3b, %3B - Binary with 3 Byte Width - Filled with Leading Zeros, e.g., %3b
* %4b, %4B - Binary with 4 Byte Width - Filled with Leading Zeros, e.g., %4b
* %c, %C - ASCII Character
* %d, %D - Decimal
* %u, %U - Unsigned Decimal
* %x - Hex of Unsigned Decimal with Lower-case Letters
* %X - Hex of Unsigned Decimal with Upper-case Letters
*
* e.g., serial_printf(&huart1, "Binary = %4b, Hex = 0x%X", value, value);
*/
void serial_printf(UART_HandleTypeDef* uart_handle_ptr, const char* format_str, ...);
#endif /* _SERIAL_PRINTF_H_ */