1 /*
2  * Copyright (c) 2006-2020, YICHIP Development Team
3  * @file     yc_system.h
4  * @brief    source file for setting system
5  *
6  * Change Logs:
7  * Date           Author      Version        Notes
8  * 2020-11-05     wushengyan         V1.0.0         the first version
9  */
10 #ifndef __SYSTEM_H__
11 #define __SYSTEM_H__
12 
13 #define SDK_DEBUG	//Debug switch
14 
15 #include <string.h>
16 #include "yc_uart.h"
17 #include "rom_api.h"
18 #include "board_config.h"
19 
20 #define BIT_SET(a,b) ((a) |= (1<<(b)))
21 #define BIT_CLEAR(a,b) ((a) &= ~(1<<(b)))
22 #define BIT_FLIP(a,b) ((a) ^= (1<<(b)))				//bit Negation
23 #define BIT_GET(a,b) (((a) & (1<<(b)))>>(b))
24 
25 /**
26  * @brief Print format string to serial port 0.You need to initialize the serial port 0 before you use MyPrintf.
27  *
28  * @param format : format string
29  * @param ...: format parameter
30  */
31 void MyPrintf(char *format, ...);
32 
33 void printv(uint8_t *buf, uint32_t len, char *s);
34 
35 void PrintPort_Set(UART_TypeDef *UARTx);
36 
37 void Board_Init(void);
38 
39 void _assert_handler(const char *file, int line, const char *func);
40 
41 #ifdef SDK_DEBUG
42 #define _ASSERT(x)	\
43 if (!(x))                                                                    \
44 {                                                                             \
45     _assert_handler(__FILE__,__LINE__,__FUNCTION__);\
46 }
47 #else
48 #define _ASSERT(x)
49 #endif
50 
51 #define YC_DEBUG_LOG(type, message)                                          \
52 do                                                                            \
53 {                                                                             \
54     if (type)                                                                 \
55         MyPrintf message;                                                   \
56 }                                                                             \
57 while (0)
58 
59 #endif /*__SYSTEM_H__*/
60