This repository was archived by the owner on Nov 16, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcl_calc.h
126 lines (119 loc) · 3.59 KB
/
cl_calc.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
116
117
118
119
120
121
122
123
124
125
126
/**
* @file cl_calc.h
* @author [email protected]
* @date April 2018
* @brief File containing example of calc functions with vairous input/output types.
* \n\n The name of parameter informs where it belongs to : request or response.
* \n 1. API request with [in] and [inout]
* \n 2. API response with [inout] and [out]
*
**/
#ifndef _CL_CALC_
#define _CL_CALC_
/**
* @brief platform-specific data types.
*
*/
typedef short cl_int16_t;
typedef int cl_int32_t;
typedef long cl_int64_t;
typedef unsigned short cl_uint16_t;
typedef unsigned int cl_uint32_t;
typedef unsigned long cl_uint64_t;
/**
* @brief return types.
*
*/
typedef cl_int32_t cl_return_t;
/**
* @brief user-defined request struct type.
*
*/
typedef struct cl_msg_t {
cl_int16_t addr;
cl_int16_t flags;
cl_int32_t len;
} cl_msg_t;
/**
* @brief user-defined response struct type.
*
*/
typedef struct cl_bus_t {
cl_int32_t info;
cl_int32_t src;
cl_int32_t dst;
cl_int32_t length;
cl_int32_t stride;
cl_int32_t next;
//cl_int32_t pad[2];
} cl_bus_t;
/**
* @brief calculation 1. 2 inputs X 1 output.
*
* @param [in] None - the first input parameter.
* @param [in] in - the second input parameter.
* @param [out] out - the output parameter after calculation.
* @return cl_return_t SUCCESS or error code.
*/
cl_return_t cl_calc_freq( int , int in, unsigned int *out );
/**
* @brief calculation 2. 2 inputs X 1 output. Unnamed parameter becomes [in]
*
* @param [in] None - the first input parameter.
* @param [in] in - the second input parameter.
* @param [in] [out] inout - the third input parameter & the output parameter after calculation.
* @return cl_return_t SUCCESS or error code.
*/
cl_return_t cl_calc_alert( int , int in, unsigned int *inout );
/**
* @brief calculation 3. 2 inputs X 1 output.
*
* @param [in] None - the first input parameter.
* @param [in] in - the second input parameter.
* @param [out] out - the output parameter after calculation.
* @return cl_return_t SUCCESS or error code.
*/
cl_return_t cl_calc_read( cl_int16_t , cl_uint16_t in, cl_uint32_t *out);
/**
* @brief calculation 4. 1 inputs X 1 output
*
* @param [in] in - the input parameter.
* @param [out] out - the output parameter after calculation.
* @return cl_return_t SUCCESS or error code.
*/
cl_return_t cl_calc_write( cl_msg_t in, cl_bus_t *out );
/**
* @brief calculation 5. 1 inputs X 1 output
*
* @param [in] in - the input parameter.
* @param [out] out - the output parameter after calculation.
* @return cl_return_t SUCCESS or error code.
*/
cl_return_t cl_calc_timer( cl_msg_t *in, cl_bus_t *out );
/**
* @brief calculation 6. 1 inputs X 1 output
*
* @param [in] in - the input parameter.
* @param [out] out1 - the output parameter after calculation.
* @param [out] out2 - the output parameter after calculation.
* @return int SUCCESS or error code.
*/
int cl_calc_filter( cl_msg_t *in, cl_bus_t *out1 , cl_bus_t *out2);
/**
* @brief calculation 7. 1 inputs X 1 output
*
* @param [in] in1 - the input parameter.
* @param [in] in2 - the input parameter.
* @param [out] out - the output parameter after calculation.
* @return void.
*/
void cl_calc_serial( cl_msg_t *in1, cl_msg_t *in2, cl_bus_t *out );
/**
* @brief calculation 8. 1 inputs X 2 output
*
* @param [in] [out] inout - the input parameter & output parameter.
* @param [out] out - the output parameter after calculation.
* @return int SUCCESS or error code.
*/
int cl_calc_servo( cl_msg_t *inout, cl_bus_t *out );
#endif /* _CL_CALC_ */