-
Notifications
You must be signed in to change notification settings - Fork 45
/
Config.h
115 lines (94 loc) · 3.41 KB
/
Config.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/*
* FileName : Config.h
* Author : xiahouzuoxin
* Date : 2013.08.31
* Version : v1.0
* Brief : place global typedefs and macros here
*/
#ifndef _CONFIG_H
#define _CONFIG_H
#include <stdio.h>
#include <math.h>
/* type redefinition */
/*
typedef enum
{
FALSE = 0,
TRUE = !FALSE
} BOOL;
*/
typedef unsigned int UINT16;
typedef unsigned long UINT32;
typedef unsigned char UINT8;
typedef int INT16;
typedef long INT32;
typedef char INT8;
typedef float FP32;
typedef double FP64;
#if !defined(__stdint_h) && !defined(_STDINT_H)
typedef unsigned long uint40_t;
typedef unsigned int uint32_t;
typedef unsigned short uint16_t;
typedef unsigned char uint8_t;
typedef long int40_t;
typedef int int32_t;
typedef short int16_t;
//typedef char int8_t;
typedef float fp32_t;
typedef double fp64_t;
#else
#include <stdint.h>
#endif // #ifndef __stdint_h
typedef long long int64_t;
typedef struct {
float real;
float imag;
} COMPLEX;
/* Get a byte or word in specified address */
#define MEM_B(x) ( *( (UINT8 *)(x) ) )
#define MEM_W(x) ( *( (UINT32 *)(x) ) )
#define UPCASE( c ) ( ((c) >= ''a'' && (c) <= ''z'') ? \
( (c) - 0x20) : (c) )
/* Check wether a case is a decimal */
#define DECCHK( c ) ((c) >= ''0'' && (c) <= ''9'')
/* Check wether a case is a hex */
#define HEXCHK( c ) ( ((c) >= ''0'' && (c) <= ''9'') || \
( (c) >= ''A'' && (c) <= ''F'') || \
( (c) >= ''a'' && (c) <= ''f'') )
/* ABS/MAX/MIN */
#define ABS(x) ( ((x) > 0) ? (x) : (-x) )
#define MIN(a, b) ( ((a) < (b))?(a):(b) )
#define MAX(a, b) ( ((a) > (b))?(a):(b) )
/* Constants */
#define PI (3.1416f)
#define PI_DIV2 (1.5708f)
/* Function Define */
#ifndef ClrBit
#define ClrBit(reg, bit) reg &= ~(1 << bit)
#endif
#ifndef SetBit
#define SetBit(reg, bit) reg |= (1 << bit)
#endif
/* Constants */
#define ZX_SUCCESS (1)
#define ZX_FAILURE (0)
#define LEVEL_HIGH (1)
#define LEVEL_LOW (0)
/* ASSERT */
// uncomment line below to
#define USE_FULL_ASSERT
#ifdef USE_FULL_ASSERT
/**
* @brief The assert_param macro is used for function's parameters check.
* @param expr: If expr is false, it calls assert_failed function
* which reports the name of the source file and the source
* line number of the call that failed.
* If expr is true, it returns no value.
* @retval None
*/
#define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__))
extern void assert_failed(uint8_t* file, uint32_t line);
#else
#define assert_param(expr) ((void)0)
#endif
#endif