-
Notifications
You must be signed in to change notification settings - Fork 0
/
wcdli.h
299 lines (256 loc) · 6.72 KB
/
wcdli.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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
/*
* WC&DLI - Warcomeb Command & Debug Line Interface
* Copyright (C) 2020 Marco Giammarini <http://www.warcomeb.it>
*
* Authors:
* Marco Giammarini <m.giammarini@warcomeb.it>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
/*!
* \file /wets.h
* \brief
*/
#ifndef __WARCOMEB_WCDLI_H
#define __WARCOMEB_WCDLI_H
#ifdef __cplusplus
extern "C"
{
#endif
/*!
* \mainpage WC&DLI - Warcomeb Command & Debug Line Interface
*
* This library is developed in order to ...
*
* \section changelog ChangeLog
*
* \li v1.0.0 of 2020/08/xx - First release
*
* \section library External Library
*
* The library use the following external library:
* \li libohiboard https://github.com/ohilab/libohiboard a multiplatform C
* framework for multi microcontroller.
*
* \section example Example
*
* \section credits Credits
* \li Marco Giammarini (warcomeb)
*/
/*!
* \defgroup WCDLI WC&DLI Module APIs
* \{
*/
#include "wcdli-types.h"
#include <stdarg.h>
#include <stdio.h>
#if !defined (LIBOHIBOARD_VERSION)
#if defined (__MCUXPRESSO)
#if defined (__MCUXPRESSO_UART)
#include "fsl_uart.h"
#elif defined (__MCUXPRESSO_USART)
#include "fsl_usart.h"
#else
#error "[ERROR] You must define the correct serial peripheral!"
#endif
#elif defined (__NUECLIPSE)
#include "uart.h"
#endif
#endif
#if !defined (LIBOHIBOARD_VERSION)
typedef struct _Utility_VersionFields_t
{
uint8_t major;
uint8_t minor;
uint16_t subminor;
uint32_t time;
} __packed Utility_VersionFields_t;
typedef union _Utility_Version_t
{
Utility_VersionFields_t f;
uint8_t b[sizeof (Utility_VersionFields_t)];
} __packed Utility_Version_t;
#endif
/*!
*
* \note The device handle must be just configured!
*
* \param[in] dev: The peripheral device handle to use.
*/
#if defined (LIBOHIBOARD_VERSION)
void WCDLI_init (Uart_DeviceHandle dev);
#else
#if defined (__MCUXPRESSO)
#if defined (__MCUXPRESSO_UART)
void WCDLI_init (UART_Type* dev);
#elif defined (__MCUXPRESSO_USART)
void WCDLI_init (USART_Type* dev);
#endif
#elif defined (__NUECLIPSE)
void WCDLI_init (UART_T* dev);
#else
#error "[ERROR] Peripheral not defined!"
#endif
#endif
#if !defined (LIBOHIBOARD_VERSION)
#if defined (__MCUXPRESSO)
#if defined (__MCUXPRESSO_UART)
void WCDLI_callbackRx (UART_Type* base, void* obj);
#elif defined (__MCUXPRESSO_USART)
void WCDLI_callbackRx (USART_Type* base, void* obj);
#endif
#elif defined (__NUECLIPSE)
void WCDLI_callbackRx (UART_T* base, void* obj);
#else
#error "[ERROR] Peripheral callback not defined!"
#endif
#endif
/*!
* \defgroup WCDLI_Command WC&DLI Command APIs
* \{
*/
/*!
*
*/
void WCDLI_printProjectVersion (void* app, int argc, char argv[][WCDLI_BUFFER_SIZE]);
/*!
*
*/
void WCDLI_printStatus (void* app, int argc, char argv[][WCDLI_BUFFER_SIZE]);
void WCDLI_save (void* app, int argc, char argv[][WCDLI_BUFFER_SIZE]);
/*!
*
*/
void WCDLI_ckeck (void);
/*!
*
* \param[in] name:
* \param[in] description:
* \param[in] callback:
* \return
*/
WCDLI_Error_t WCDLI_addCommandByParam (const char* name,
const char* description,
WCDLI_CommandCallback_t callback);
/*!
*
*
* \param[in] command:
* \return
*/
WCDLI_Error_t WCDLI_addCommand (WCDLI_Command_t* command);
/*!
*
* \param[in] name:
* \param[in] description:
* \param[in] callback:
* \param[in] dev:
* \return
*/
WCDLI_Error_t WCDLI_addAppByParam (const char* name,
const char* description,
void* app,
WCDLI_CommandCallback_t callback);
/*!
* \param[in] app:
* \return
*/
WCDLI_Error_t WCDLI_addApp (WCDLI_Command_t* app);
/*!
*
* \param[in] name:
* \param[in] description:
*/
void WCDLI_helpLine (const char* name, const char* description);
/*!
* \}
*/
/*!
* \defgroup WCDLI_Debug WC&DLI Debug APIs
* \{
*/
/*!
*
* \param[in] level:
* \param[in] str:
*/
void WCDLI_debug (WCDLI_MessageLevel_t level, const char* str);
/*!
*
* \param[in] level:
* \param[in] format:
*/
void WCDLI_debugByFormat (WCDLI_MessageLevel_t level, const char* format, ...);
/*!
* \}
*/
/*!
* \defgroup WCDLI_Utility WC&DLI Utility functions
* \{
*/
#define WCDLI_PRINT_CMD_MESSAGE(MESSAGE) \
do { \
WCDLI_debug(WCDLI_MESSAGELEVEL_NONE,MESSAGE);\
} while (0)
#define WCDLI_PRINT_MESSAGE(LEVELSTRING,MESSAGE) \
do { \
WCDLI_debug(LEVELSTRING,MESSAGE); \
} while (0)
#define WCDLI_PRINT_INFO_MESSAGE(MESSAGE) \
do { \
WCDLI_debug(WCDLI_MESSAGELEVEL_INFO,MESSAGE);\
} while (0)
#define WCDLI_PRINT_WARNING_MESSAGE(MESSAGE) \
do { \
WCDLI_debug(WCDLI_MESSAGELEVEL_WARNING,MESSAGE);\
} while (0)
#define WCDLI_PRINT_ERROR_MESSAGE(MESSAGE) \
do { \
WCDLI_debug(WCDLI_MESSAGELEVEL_DANGER,MESSAGE);\
} while (0)
/*!
*
*/
#define WCDLI_PRINT_SUCCESS() WCDLI_PRINT_CMD_MESSAGE("Command Success!")
/*!
*
*/
#define WCDLI_PRINT_WRONG_COMMAND() WCDLI_PRINT_CMD_MESSAGE("Error: Wrong Command!")
/*!
*
*/
#define WCDLI_PRINT_NO_COMMAND() WCDLI_PRINT_CMD_MESSAGE("Error: Command not found!")
/*!
*
*/
#define WCDLI_PRINT_WRONG_PARAM() WCDLI_PRINT_CMD_MESSAGE("Error: Wrong Params!")
/*!
*
*/
#define WCDLI_PRINT_COMMAND_NOT_IMPLEMENTED() WCDLI_PRINT_CMD_MESSAGE("Error: Command not implemented!")
/*!
* \}
*/
/*!
* \}
*/
#ifdef __cplusplus
}
#endif
#endif // __WARCOMEB_WCDLI_H