Ver código fonte

[add] elog

Branch_elog
huangyulong 8 meses atrás
pai
commit
53febce1be

+ 270
- 4
EWARM/stm32_broad_mini.ewp Ver arquivo

@@ -353,6 +353,7 @@
353 353
                     <state>$PROJ_DIR$/../Middlewares/rtthread/include</state>
354 354
                     <state>$PROJ_DIR$/../Middlewares/rtthread/include/libc</state>
355 355
                     <state>$PROJ_DIR$/../Middlewares/rtthread/finsh</state>
356
+                    <state>$PROJ_DIR$\..\Middlewares\elog</state>
356 357
                 </option>
357 358
                 <option>
358 359
                     <name>CCStdIncCheck</name>
@@ -642,15 +643,15 @@
642 643
                 <option>
643 644
                     <name>OOCOutputFormat</name>
644 645
                     <version>3</version>
645
-                    <state>3</state>
646
+                    <state>1</state>
646 647
                 </option>
647 648
                 <option>
648 649
                     <name>OCOutputOverride</name>
649
-                    <state>1</state>
650
+                    <state>0</state>
650 651
                 </option>
651 652
                 <option>
652 653
                     <name>OOCOutputFile</name>
653
-                    <state>project.bin</state>
654
+                    <state>stm32_broad_mini.hex</state>
654 655
                 </option>
655 656
                 <option>
656 657
                     <name>OOCCommandLineProducer</name>
@@ -668,7 +669,7 @@
668 669
             <data>
669 670
                 <extensions></extensions>
670 671
                 <cmdline></cmdline>
671
-                <hasPrio>0</hasPrio>
672
+                <hasPrio>96</hasPrio>
672 673
                 <buildSequence>inputOutputBased</buildSequence>
673 674
             </data>
674 675
         </settings>
@@ -1183,6 +1184,271 @@
1183 1184
                 <name>$PROJ_DIR$\..\Middlewares\coredump\coredump_cmd.S</name>
1184 1185
             </file>
1185 1186
         </group>
1187
+        <group>
1188
+            <name>elog</name>
1189
+            <file>
1190
+                <name>$PROJ_DIR$\..\Middlewares\elog\elog.c</name>
1191
+            </file>
1192
+            <file>
1193
+                <name>$PROJ_DIR$\..\Middlewares\elog\elog_test.c</name>
1194
+            </file>
1195
+            <configuration>
1196
+                <name>stm32_broad_mini</name>
1197
+                <settings>
1198
+                    <name>ICCARM</name>
1199
+                    <data>
1200
+                        <version>37</version>
1201
+                        <wantNonLocal>0</wantNonLocal>
1202
+                        <debug>1</debug>
1203
+                        <option>
1204
+                            <name>CCOptimizationNoSizeConstraints</name>
1205
+                            <state>0</state>
1206
+                        </option>
1207
+                        <option>
1208
+                            <name>CCDefines</name>
1209
+                            <state>USE_HAL_DRIVER</state>
1210
+                            <state>STM32F103xB</state>
1211
+                        </option>
1212
+                        <option>
1213
+                            <name>CCPreprocFile</name>
1214
+                            <state>0</state>
1215
+                        </option>
1216
+                        <option>
1217
+                            <name>CCPreprocComments</name>
1218
+                            <state>0</state>
1219
+                        </option>
1220
+                        <option>
1221
+                            <name>CCPreprocLine</name>
1222
+                            <state>0</state>
1223
+                        </option>
1224
+                        <option>
1225
+                            <name>CCListCFile</name>
1226
+                            <state>0</state>
1227
+                        </option>
1228
+                        <option>
1229
+                            <name>CCListCMnemonics</name>
1230
+                            <state>0</state>
1231
+                        </option>
1232
+                        <option>
1233
+                            <name>CCListCMessages</name>
1234
+                            <state>0</state>
1235
+                        </option>
1236
+                        <option>
1237
+                            <name>CCListAssFile</name>
1238
+                            <state>0</state>
1239
+                        </option>
1240
+                        <option>
1241
+                            <name>CCListAssSource</name>
1242
+                            <state>0</state>
1243
+                        </option>
1244
+                        <option>
1245
+                            <name>CCEnableRemarks</name>
1246
+                            <state>0</state>
1247
+                        </option>
1248
+                        <option>
1249
+                            <name>CCDiagSuppress</name>
1250
+                            <state></state>
1251
+                        </option>
1252
+                        <option>
1253
+                            <name>CCDiagRemark</name>
1254
+                            <state></state>
1255
+                        </option>
1256
+                        <option>
1257
+                            <name>CCDiagWarning</name>
1258
+                            <state></state>
1259
+                        </option>
1260
+                        <option>
1261
+                            <name>CCDiagError</name>
1262
+                            <state></state>
1263
+                        </option>
1264
+                        <option>
1265
+                            <name>CCObjPrefix</name>
1266
+                            <state>1</state>
1267
+                        </option>
1268
+                        <option>
1269
+                            <name>CCAllowList</name>
1270
+                            <version>1</version>
1271
+                            <state>00000000</state>
1272
+                        </option>
1273
+                        <option>
1274
+                            <name>CCDebugInfo</name>
1275
+                            <state>1</state>
1276
+                        </option>
1277
+                        <option>
1278
+                            <name>IEndianMode</name>
1279
+                            <state>1</state>
1280
+                        </option>
1281
+                        <option>
1282
+                            <name>IProcessor</name>
1283
+                            <state>1</state>
1284
+                        </option>
1285
+                        <option>
1286
+                            <name>IExtraOptionsCheck</name>
1287
+                            <state>0</state>
1288
+                        </option>
1289
+                        <option>
1290
+                            <name>IExtraOptions</name>
1291
+                            <state></state>
1292
+                        </option>
1293
+                        <option>
1294
+                            <name>CCLangConformance</name>
1295
+                            <state>0</state>
1296
+                        </option>
1297
+                        <option>
1298
+                            <name>CCSignedPlainChar</name>
1299
+                            <state>1</state>
1300
+                        </option>
1301
+                        <option>
1302
+                            <name>CCRequirePrototypes</name>
1303
+                            <state>0</state>
1304
+                        </option>
1305
+                        <option>
1306
+                            <name>CCDiagWarnAreErr</name>
1307
+                            <state>0</state>
1308
+                        </option>
1309
+                        <option>
1310
+                            <name>CCCompilerRuntimeInfo</name>
1311
+                            <state>0</state>
1312
+                        </option>
1313
+                        <option>
1314
+                            <name>IFpuProcessor</name>
1315
+                            <state>1</state>
1316
+                        </option>
1317
+                        <option>
1318
+                            <name>OutputFile</name>
1319
+                            <state>$FILE_BNAME$.o</state>
1320
+                        </option>
1321
+                        <option>
1322
+                            <name>CCLibConfigHeader</name>
1323
+                            <state>1</state>
1324
+                        </option>
1325
+                        <option>
1326
+                            <name>PreInclude</name>
1327
+                            <state></state>
1328
+                        </option>
1329
+                        <option>
1330
+                            <name>CCIncludePath2</name>
1331
+                            <state>$PROJ_DIR$/../Core/Inc</state>
1332
+                            <state>$PROJ_DIR$/../Drivers/STM32F1xx_HAL_Driver/Inc/Legacy</state>
1333
+                            <state>$PROJ_DIR$/../Drivers/STM32F1xx_HAL_Driver/Inc</state>
1334
+                            <state>$PROJ_DIR$/../Middlewares/Third_Party/FreeRTOS/Source/include</state>
1335
+                            <state>$PROJ_DIR$/../Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2</state>
1336
+                            <state>$PROJ_DIR$/../Middlewares/Third_Party/FreeRTOS/Source/portable/IAR/ARM_CM3</state>
1337
+                            <state>$PROJ_DIR$/../Drivers/CMSIS/Device/ST/STM32F1xx/Include</state>
1338
+                            <state>$PROJ_DIR$/../Drivers/CMSIS/Include</state>
1339
+                            <state>$PROJ_DIR$/../Middlewares/segger_rtt</state>
1340
+                            <state>$PROJ_DIR$/../Middlewares/rtthread</state>
1341
+                            <state>$PROJ_DIR$/../Middlewares/rtthread/include</state>
1342
+                            <state>$PROJ_DIR$/../Middlewares/rtthread/include/libc</state>
1343
+                            <state>$PROJ_DIR$/../Middlewares/rtthread/finsh</state>
1344
+                            <state>$PROJ_DIR$\..\Middlewares\elog</state>
1345
+                        </option>
1346
+                        <option>
1347
+                            <name>CCStdIncCheck</name>
1348
+                            <state>0</state>
1349
+                        </option>
1350
+                        <option>
1351
+                            <name>CCCodeSection</name>
1352
+                            <state>.text</state>
1353
+                        </option>
1354
+                        <option>
1355
+                            <name>IProcessorMode2</name>
1356
+                            <state>1</state>
1357
+                        </option>
1358
+                        <option>
1359
+                            <name>CCOptLevel</name>
1360
+                            <state>0</state>
1361
+                        </option>
1362
+                        <option>
1363
+                            <name>CCOptStrategy</name>
1364
+                            <version>0</version>
1365
+                            <state>1</state>
1366
+                        </option>
1367
+                        <option>
1368
+                            <name>CCOptLevelSlave</name>
1369
+                            <state>0</state>
1370
+                        </option>
1371
+                        <option>
1372
+                            <name>CCPosIndRopi</name>
1373
+                            <state>0</state>
1374
+                        </option>
1375
+                        <option>
1376
+                            <name>CCPosIndRwpi</name>
1377
+                            <state>0</state>
1378
+                        </option>
1379
+                        <option>
1380
+                            <name>CCPosIndNoDynInit</name>
1381
+                            <state>0</state>
1382
+                        </option>
1383
+                        <option>
1384
+                            <name>IccLang</name>
1385
+                            <state>0</state>
1386
+                        </option>
1387
+                        <option>
1388
+                            <name>IccCDialect</name>
1389
+                            <state>1</state>
1390
+                        </option>
1391
+                        <option>
1392
+                            <name>IccAllowVLA</name>
1393
+                            <state>0</state>
1394
+                        </option>
1395
+                        <option>
1396
+                            <name>IccStaticDestr</name>
1397
+                            <state>1</state>
1398
+                        </option>
1399
+                        <option>
1400
+                            <name>IccCppInlineSemantics</name>
1401
+                            <state>0</state>
1402
+                        </option>
1403
+                        <option>
1404
+                            <name>IccCmsis</name>
1405
+                            <state>1</state>
1406
+                        </option>
1407
+                        <option>
1408
+                            <name>IccFloatSemantics</name>
1409
+                            <state>0</state>
1410
+                        </option>
1411
+                        <option>
1412
+                            <name>CCNoLiteralPool</name>
1413
+                            <state>0</state>
1414
+                        </option>
1415
+                        <option>
1416
+                            <name>CCOptStrategySlave</name>
1417
+                            <version>0</version>
1418
+                            <state>1</state>
1419
+                        </option>
1420
+                        <option>
1421
+                            <name>CCEncSource</name>
1422
+                            <state>0</state>
1423
+                        </option>
1424
+                        <option>
1425
+                            <name>CCEncOutput</name>
1426
+                            <state>0</state>
1427
+                        </option>
1428
+                        <option>
1429
+                            <name>CCEncOutputBom</name>
1430
+                            <state>1</state>
1431
+                        </option>
1432
+                        <option>
1433
+                            <name>CCEncInput</name>
1434
+                            <state>0</state>
1435
+                        </option>
1436
+                        <option>
1437
+                            <name>IccExceptions2</name>
1438
+                            <state>0</state>
1439
+                        </option>
1440
+                        <option>
1441
+                            <name>IccRTTI2</name>
1442
+                            <state>0</state>
1443
+                        </option>
1444
+                        <option>
1445
+                            <name>CCStackProtection</name>
1446
+                            <state>0</state>
1447
+                        </option>
1448
+                    </data>
1449
+                </settings>
1450
+            </configuration>
1451
+        </group>
1186 1452
         <group>
1187 1453
             <name>FreeRTOS</name>
1188 1454
             <excluded>

+ 7
- 0
EWARM/stm32f103xb_flash.icf Ver arquivo

@@ -8,6 +8,10 @@ define symbol __ICFEDIT_region_ROM_start__   = 0x08000000 ;
8 8
 define symbol __ICFEDIT_region_ROM_end__     = 0x0801FFFF;
9 9
 define symbol __ICFEDIT_region_RAM_start__   = 0x20000000;
10 10
 define symbol __ICFEDIT_region_RAM_end__     = 0x20004FFF;
11
+
12
+define symbol __ICFEDIT_region_LOG_start__   = 0x08020000;
13
+define symbol __ICFEDIT_region_LOG_end__     = 0x08030000;
14
+
11 15
 /*-Sizes-*/
12 16
 define symbol __ICFEDIT_size_cstack__ = 0x400;
13 17
 define symbol __ICFEDIT_size_heap__ = 0x200;
@@ -17,6 +21,7 @@ define symbol __ICFEDIT_size_heap__ = 0x200;
17 21
 define memory mem with size = 4G;
18 22
 define region ROM_region   = mem:[from __ICFEDIT_region_ROM_start__   to __ICFEDIT_region_ROM_end__];
19 23
 define region RAM_region   = mem:[from __ICFEDIT_region_RAM_start__   to __ICFEDIT_region_RAM_end__];
24
+define region LOG_region   = mem:[from __ICFEDIT_region_LOG_start__   to __ICFEDIT_region_LOG_end__];
20 25
 
21 26
 define block CSTACK    with alignment = 8, size = __ICFEDIT_size_cstack__   { };
22 27
 define block HEAP      with alignment = 8, size = __ICFEDIT_size_heap__     { };
@@ -29,3 +34,5 @@ place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
29 34
 place in ROM_region   { readonly };
30 35
 place in RAM_region   { readwrite,
31 36
                         block CSTACK, block HEAP };
37
+
38
+place in LOG_region   { readonly section elog};

+ 80
- 0
Middlewares/elog/elog-cpp.h Ver arquivo

@@ -0,0 +1,80 @@
1
+#ifndef __ELOG_CPP_H__
2
+#define __ELOG_CPP_H__
3
+
4
+#define ELOG_NARG(...) \
5
+         ELOG_NARG_(__VA_ARGS__, ELOG_RSEQ_N())
6
+#define ELOG_NARG_(...) \
7
+         ELOG_ARG_N(__VA_ARGS__)
8
+#define ELOG_ARG_N( \
9
+          _1, _2, _3, _4, _5, _6, _7, _8, _9,_10, \
10
+         _11,_12,_13,_14,_15,_16,_17,_18,_19,_20, \
11
+         _21,_22,_23,_24,_25,_26,_27,_28,_29,_30, \
12
+         _31,_32,_33,_34,_35,_36,_37,_38,_39,_40, \
13
+         _41,_42,_43,_44,_45,_46,_47,_48,_49,_50, \
14
+         _51,_52,_53,_54,_55,_56,_57,_58,_59,_60, \
15
+         _61,_62,_63,N,...) N
16
+#define ELOG_RSEQ_N() \
17
+         63,62,61,60,                   \
18
+         59,58,57,56,55,54,53,52,51,50, \
19
+         49,48,47,46,45,44,43,42,41,40, \
20
+         39,38,37,36,35,34,33,32,31,30, \
21
+         29,28,27,26,25,24,23,22,21,20, \
22
+         19,18,17,16,15,14,13,12,11,10, \
23
+         9,8,7,6,5,4,3,2,1,0
24
+
25
+#define FIRST_(a, ...) a
26
+#define SECOND_(a, b, ...) b
27
+
28
+#define FIRST(...) FIRST_(__VA_ARGS__,)
29
+#define SECOND(...) SECOND_(__VA_ARGS__,)
30
+
31
+#define EMPTY()
32
+
33
+#define EVAL(...) EVAL1024(__VA_ARGS__)
34
+#define EVAL1024(...) EVAL512(EVAL512(__VA_ARGS__))
35
+#define EVAL512(...) EVAL256(EVAL256(__VA_ARGS__))
36
+#define EVAL256(...) EVAL128(EVAL128(__VA_ARGS__))
37
+#define EVAL128(...) EVAL64(EVAL64(__VA_ARGS__))
38
+#define EVAL64(...) EVAL32(EVAL32(__VA_ARGS__))
39
+#define EVAL32(...) EVAL16(EVAL16(__VA_ARGS__))
40
+#define EVAL16(...) EVAL8(EVAL8(__VA_ARGS__))
41
+#define EVAL8(...) EVAL4(EVAL4(__VA_ARGS__))
42
+#define EVAL4(...) EVAL2(EVAL2(__VA_ARGS__))
43
+#define EVAL2(...) EVAL1(EVAL1(__VA_ARGS__))
44
+#define EVAL1(...) __VA_ARGS__
45
+
46
+#define DEFER1(m) m EMPTY()
47
+#define DEFER2(m) m EMPTY EMPTY()()
48
+
49
+#define IS_PROBE(...) SECOND(__VA_ARGS__, 0)
50
+#define PROBE() ~, 1
51
+
52
+#define CAT(a,b) a ## b
53
+
54
+#define NOT(x) IS_PROBE(CAT(_NOT_, x))
55
+#define _NOT_0 PROBE()
56
+
57
+#define BOOL(x) NOT(NOT(x))
58
+
59
+#define IF_ELSE(condition) _IF_ELSE(BOOL(condition))
60
+#define _IF_ELSE(condition) CAT(_IF_, condition)
61
+
62
+#define _IF_1(...) __VA_ARGS__ _IF_1_ELSE
63
+#define _IF_0(...)             _IF_0_ELSE
64
+
65
+#define _IF_1_ELSE(...)
66
+#define _IF_0_ELSE(...) __VA_ARGS__
67
+
68
+#define HAS_ARGS(...) BOOL(FIRST(_END_OF_ARGUMENTS_ __VA_ARGS__)())
69
+#define _END_OF_ARGUMENTS_() 0
70
+
71
+#define MAP(m, first, ...)           \
72
+  m(first)                           \
73
+  IF_ELSE(HAS_ARGS(__VA_ARGS__))(    \
74
+    DEFER2(_MAP)()(m, __VA_ARGS__)   \
75
+  )(                                 \
76
+    /* Do nothing, just terminate */ \
77
+  )
78
+#define _MAP() MAP
79
+
80
+#endif /* __ELOG_CPP_H__ */

+ 32
- 0
Middlewares/elog/elog-internal.h Ver arquivo

@@ -0,0 +1,32 @@
1
+#ifndef __ELOG_INTERNAL_H__
2
+#define __ELOG_INTERNAL_H__
3
+
4
+#include <stddef.h>
5
+#include <stdint.h>
6
+#include <limits.h>
7
+
8
+#define MSGPTR_LEN_BITS (CHAR_BIT / 2)
9
+#define MSGPTR_LEN_BITS_OFFSET ((sizeof(msgptr_t) * CHAR_BIT) - MSGPTR_LEN_BITS)
10
+#define MSGPTR_MSG_MASK ((1 << MSGPTR_LEN_BITS_OFFSET) - 1)
11
+#define MSGPTR_LEN_MASK ((1 << MSGPTR_LEN_BITS) - 1)
12
+#define MSGPTR_LEN(v) (((v) >> MSGPTR_LEN_BITS_OFFSET) & MSGPTR_LEN_MASK)
13
+#define MSGPTR_MSG(v) ((v) & MSGPTR_MSG_MASK)
14
+#define MSGPTR_MAKE(l, p) (((p) & MSGPTR_MSG_MASK) | (((l) & MSGPTR_LEN_MASK) << MSGPTR_LEN_BITS_OFFSET))
15
+
16
+#ifdef __cplusplus
17
+extern "C" {
18
+#endif
19
+
20
+typedef uint32_t msgptr_t;
21
+typedef uint32_t msgparam_t;
22
+
23
+typedef struct {
24
+    msgptr_t msgid;
25
+    msgparam_t data[0];
26
+} __attribute__((__packed__)) elog_entry_t;
27
+
28
+#ifdef __cplusplus
29
+}
30
+#endif
31
+
32
+#endif /* __ELOG_INTERNAL_H__ */

+ 44
- 0
Middlewares/elog/elog.c Ver arquivo

@@ -0,0 +1,44 @@
1
+#include <elog.h>
2
+
3
+#include <string.h>
4
+
5
+elog_t *elog_init(void *arena, size_t size)
6
+{
7
+    elog_t *ptr = (elog_t *)arena;
8
+    ptr->buflen = size - sizeof(elog_t); // Adjust for the size of the elog_t structure
9
+    ptr->offset = 0;
10
+    return ptr;
11
+}
12
+
13
+int elog_put(elog_t *log, const char *const msg, int n, msgparam_t args[])
14
+{
15
+    elog_entry_t *e = (elog_entry_t *)(log->buffer + log->offset); // 计算当前可写的位置e(即log->buffer)
16
+    long esize = n * sizeof(msgparam_t); // 参数占用字节数
17
+    long newoff = log->offset + sizeof(elog_entry_t) + esize; // 计算新的偏移量,开始是elog_entry_t头 + n个msg(id和长度组成)
18
+
19
+    if (newoff < log->buflen)
20
+    {
21
+        e->msgid = MSGPTR_MAKE(n, (msgptr_t)msg); // 通过字符串地址和个数生成msgid,并写入e
22
+        memcpy(e->data, args, esize); // 参数列表写入e
23
+        log->offset = newoff;
24
+        return 1;
25
+    }
26
+
27
+    return 0;
28
+}
29
+
30
+void elog_flush(elog_t *log, elog_flush_func_t func, void *ctx)
31
+{
32
+    long off = 0;
33
+
34
+    while (off < log->offset) // 也可以直接发送出去上位机,在上位机端解码
35
+    {
36
+        elog_entry_t *e = ((elog_entry_t *)(log->buffer + off));
37
+        size_t len = MSGPTR_LEN(e->msgid) * sizeof(long);
38
+        size_t incr = sizeof(elog_entry_t) + len;
39
+        off += incr;
40
+        func(e, incr, ctx); // 解出一个e[id + data]
41
+    }
42
+
43
+    log->offset = 0;
44
+}

+ 42
- 0
Middlewares/elog/elog.h Ver arquivo

@@ -0,0 +1,42 @@
1
+#ifndef __ELOG_H__
2
+#define __ELOG_H__
3
+
4
+#include <stddef.h>
5
+
6
+#include "elog-cpp.h"
7
+#include "elog-internal.h"
8
+
9
+#ifdef __cplusplus
10
+extern "C" {
11
+#endif
12
+
13
+typedef struct {
14
+    ptrdiff_t buflen;
15
+    ptrdiff_t offset;
16
+    char buffer[0];
17
+} __attribute__((__packed__)) elog_t;
18
+
19
+#define _msgparam_cast_apply(x) ((long) (x)),
20
+#define msgparam_cast_apply(...) EVAL(MAP(_msgparam_cast_apply, __VA_ARGS__))
21
+
22
+#define ELOG(o, msg, ...) do { \
23
+    __attribute__((section("elog"))) static const char p_msg[] = msg;  \
24
+    IF_ELSE(HAS_ARGS(__VA_ARGS__))(    \
25
+        elog_put(o, p_msg, ELOG_NARG(__VA_ARGS__)/*计算出有多少个参数*/, (msgparam_t[]){ msgparam_cast_apply(__VA_ARGS__) }/*参数数组*/); \
26
+    )(                                 \
27
+        elog_put(o, p_msg, 0, (msgparam_t[]){}); \
28
+    ) \
29
+} while(0)
30
+
31
+typedef void (elog_flush_func_t)(elog_entry_t *e, int len, void *ctx);
32
+
33
+extern elog_t *elog_init(void *arena, size_t size);
34
+extern int elog_put(elog_t *log, const char *const msg, int n, msgparam_t args[]);
35
+extern elog_entry_t *elog_peek(elog_t *log);
36
+extern void elog_flush(elog_t *log, elog_flush_func_t func, void *ctx);
37
+
38
+#ifdef __cplusplus
39
+}
40
+#endif
41
+
42
+#endif /* __ELOG_H__ */

+ 33
- 0
Middlewares/elog/elog_test.c Ver arquivo

@@ -0,0 +1,33 @@
1
+#include <elog.h>
2
+
3
+static elog_t *logger;
4
+static char arena[1024];
5
+
6
+static void log_to_semihost(elog_entry_t *e, int len, void *ctx)
7
+{
8
+    // 发送出去
9
+    uint32_t *p = (void *)e;
10
+    int num = len / sizeof(uint32_t);
11
+    rt_kprintf("num:%d\n", num);
12
+    rt_kprintf("len:%d\n", MSGPTR_LEN(p[0])); // 通过msg->id解出参数个数
13
+
14
+    for(int i = 0; i < num; i++)
15
+    {
16
+        if(0 == i)
17
+            rt_kprintf("0x%08X ", MSGPTR_MSG(p[i])); // 通过msg_id解出参数内容
18
+
19
+        rt_kprintf("%d ", p[i]);
20
+    }
21
+
22
+    rt_kprintf("\n\n");
23
+}
24
+
25
+int elog_test(void)
26
+{
27
+    logger = elog_init(arena, sizeof(arena));
28
+    ELOG(logger, "Hello world %d\n", 10);  // 把字符串和参数放到内存中,(通过字符串 + 长度算法生成msg_id)和会形成一条msg_id和长度
29
+    ELOG(logger, "test %d %d %c\n", 1, 2, 3);
30
+
31
+    elog_flush(logger, log_to_semihost, NULL);  // 将内存中的日志刷新到文件,也可以是传输到上位机。也就是之前(字符串和参数)生成的msg_id和长度
32
+    return 0;
33
+}

+ 274
- 0
Middlewares/elog/ucmsis.h Ver arquivo

@@ -0,0 +1,274 @@
1
+#ifndef __UCMSIS_H__
2
+#define __UCMSIS_H__
3
+
4
+#include <stdint.h>
5
+
6
+#ifdef __cplusplus
7
+extern "C" {
8
+#endif
9
+
10
+#define     __I     volatile const       /*!< Defines 'read only' permissions */
11
+#define     __O     volatile             /*!< Defines 'write only' permissions */
12
+#define     __IO    volatile             /*!< Defines 'read / write' permissions */
13
+
14
+/* following defines should be used for structure members */
15
+#define     __IM     volatile const      /*! Defines 'read only' structure member permissions */
16
+#define     __OM     volatile            /*! Defines 'write only' structure member permissions */
17
+#define     __IOM    volatile            /*! Defines 'read / write' structure member permissions */
18
+
19
+#define __NVIC_PRIO_BITS          8U
20
+
21
+#define WEAK __attribute__((weak))
22
+#define ALIAS(sym) __attribute__((weak, alias (sym)))
23
+#define NORETURN __attribute__((noreturn))
24
+#define SECTION(name) __attribute__ ((section(name)))
25
+#define INLINE __attribute__((always_inline)) inline 
26
+#define STATIC_INLINE static INLINE
27
+
28
+typedef enum IRQn
29
+{
30
+/* -------------------  Processor Exceptions Numbers  ----------------------------- */
31
+  NonMaskableInt_IRQn           = -14,     /*  2 Non Maskable Interrupt */
32
+  HardFault_IRQn                = -13,     /*  3 HardFault Interrupt */
33
+
34
+
35
+
36
+  SVCall_IRQn                   =  -5,     /* 11 SV Call Interrupt */
37
+
38
+  PendSV_IRQn                   =  -2,     /* 14 Pend SV Interrupt */
39
+  SysTick_IRQn                  =  -1,     /* 15 System Tick Interrupt */
40
+
41
+} IRQn_Type;
42
+
43
+/* Memory mapping of Core Hardware */
44
+#define SCS_BASE            (0xE000E000UL)                            /*!< System Control Space Base Address */
45
+#define ITM_BASE            (0xE0000000UL)                            /*!< ITM Base Address */
46
+#define DWT_BASE            (0xE0001000UL)                            /*!< DWT Base Address */
47
+#define TPI_BASE            (0xE0040000UL)                            /*!< TPI Base Address */
48
+#define CoreDebug_BASE      (0xE000EDF0UL)                            /*!< Core Debug Base Address */
49
+#define SysTick_BASE        (SCS_BASE +  0x0010UL)                    /*!< SysTick Base Address */
50
+#define NVIC_BASE           (SCS_BASE +  0x0100UL)                    /*!< NVIC Base Address */
51
+#define SCB_BASE            (SCS_BASE +  0x0D00UL)                    /*!< System Control Block Base Address */
52
+
53
+#define SCnSCB              ((SCnSCB_Type    *)     SCS_BASE      )   /*!< System control Register not in SCB */
54
+#define SCB                 ((SCB_Type       *)     SCB_BASE      )   /*!< SCB configuration struct */
55
+#define SysTick             ((SysTick_Type   *)     SysTick_BASE  )   /*!< SysTick configuration struct */
56
+#define NVIC                ((NVIC_Type      *)     NVIC_BASE     )   /*!< NVIC configuration struct */
57
+#define ITM                 ((ITM_Type       *)     ITM_BASE      )   /*!< ITM configuration struct */
58
+#define DWT                 ((DWT_Type       *)     DWT_BASE      )   /*!< DWT configuration struct */
59
+#define TPI                 ((TPI_Type       *)     TPI_BASE      )   /*!< TPI configuration struct */
60
+#define CoreDebug           ((CoreDebug_Type *)     CoreDebug_BASE)   /*!< Core Debug configuration struct */
61
+
62
+/**
63
+  \brief  Structure type to access the Nested Vectored Interrupt Controller (NVIC).
64
+ */
65
+typedef struct {
66
+   __IOM uint32_t ISER[8U];               /*!< Offset: 0x000 (R/W)  Interrupt Set Enable Register */
67
+   uint32_t RESERVED0[24U];
68
+   __IOM uint32_t ICER[8U];               /*!< Offset: 0x080 (R/W)  Interrupt Clear Enable Register */
69
+   uint32_t RESERVED1[24U];
70
+   __IOM uint32_t ISPR[8U];               /*!< Offset: 0x100 (R/W)  Interrupt Set Pending Register */
71
+   uint32_t RESERVED2[24U];
72
+   __IOM uint32_t ICPR[8U];               /*!< Offset: 0x180 (R/W)  Interrupt Clear Pending Register */
73
+   uint32_t RESERVED3[24U];
74
+   __IOM uint32_t IABR[8U];               /*!< Offset: 0x200 (R/W)  Interrupt Active bit Register */
75
+   uint32_t RESERVED4[56U];
76
+   __IOM uint8_t  IP[240U];               /*!< Offset: 0x300 (R/W)  Interrupt Priority Register (8Bit wide) */
77
+   uint32_t RESERVED5[644U];
78
+   __OM  uint32_t STIR;                   /*!< Offset: 0xE00 ( /W)  Software Trigger Interrupt Register */
79
+}  NVIC_Type;
80
+
81
+#define SCB_ICSR_PENDSVSET_Pos             28U                                            /*!< SCB ICSR: PENDSVSET Position */
82
+#define SCB_ICSR_PENDSVSET_Msk             (1UL << SCB_ICSR_PENDSVSET_Pos)                /*!< SCB ICSR: PENDSVSET Mask */
83
+
84
+/**
85
+  \brief  Structure type to access the System Control Block (SCB).
86
+ */
87
+typedef struct {
88
+   __IM  uint32_t CPUID;                  /*!< Offset: 0x000 (R/ )  CPUID Base Register */
89
+   __IOM uint32_t ICSR;                   /*!< Offset: 0x004 (R/W)  Interrupt Control and State Register */
90
+   __IOM uint32_t VTOR;                   /*!< Offset: 0x008 (R/W)  Vector Table Offset Register */
91
+   __IOM uint32_t AIRCR;                  /*!< Offset: 0x00C (R/W)  Application Interrupt and Reset Control Register */
92
+   __IOM uint32_t SCR;                    /*!< Offset: 0x010 (R/W)  System Control Register */
93
+   __IOM uint32_t CCR;                    /*!< Offset: 0x014 (R/W)  Configuration Control Register */
94
+   __IOM uint8_t  SHP[12U];               /*!< Offset: 0x018 (R/W)  System Handlers Priority Registers (4-7, 8-11, 12-15) */
95
+   __IOM uint32_t SHCSR;                  /*!< Offset: 0x024 (R/W)  System Handler Control and State Register */
96
+   __IOM uint32_t CFSR;                   /*!< Offset: 0x028 (R/W)  Configurable Fault Status Register */
97
+   __IOM uint32_t HFSR;                   /*!< Offset: 0x02C (R/W)  HardFault Status Register */
98
+   __IOM uint32_t DFSR;                   /*!< Offset: 0x030 (R/W)  Debug Fault Status Register */
99
+   __IOM uint32_t MMFAR;                  /*!< Offset: 0x034 (R/W)  MemManage Fault Address Register */
100
+   __IOM uint32_t BFAR;                   /*!< Offset: 0x038 (R/W)  BusFault Address Register */
101
+   __IOM uint32_t AFSR;                   /*!< Offset: 0x03C (R/W)  Auxiliary Fault Status Register */
102
+   __IM  uint32_t PFR[2U];                /*!< Offset: 0x040 (R/ )  Processor Feature Register */
103
+   __IM  uint32_t DFR;                    /*!< Offset: 0x048 (R/ )  Debug Feature Register */
104
+   __IM  uint32_t ADR;                    /*!< Offset: 0x04C (R/ )  Auxiliary Feature Register */
105
+   __IM  uint32_t MMFR[4U];               /*!< Offset: 0x050 (R/ )  Memory Model Feature Register */
106
+   __IM  uint32_t ISAR[5U];               /*!< Offset: 0x060 (R/ )  Instruction Set Attributes Register */
107
+   uint32_t RESERVED0[5U];
108
+   __IOM uint32_t CPACR;                  /*!< Offset: 0x088 (R/W)  Coprocessor Access Control Register */
109
+} SCB_Type;
110
+
111
+/* SCB System Handler Control and State Register Definitions */
112
+#define SCB_SHCSR_USGFAULTENA_Pos          18U                                            /*!< SCB SHCSR: USGFAULTENA Position */
113
+#define SCB_SHCSR_USGFAULTENA_Msk          (1UL << SCB_SHCSR_USGFAULTENA_Pos)             /*!< SCB SHCSR: USGFAULTENA Mask */
114
+
115
+#define SCB_SHCSR_BUSFAULTENA_Pos          17U                                            /*!< SCB SHCSR: BUSFAULTENA Position */
116
+#define SCB_SHCSR_BUSFAULTENA_Msk          (1UL << SCB_SHCSR_BUSFAULTENA_Pos)             /*!< SCB SHCSR: BUSFAULTENA Mask */
117
+
118
+#define SCB_SHCSR_MEMFAULTENA_Pos          16U                                            /*!< SCB SHCSR: MEMFAULTENA Position */
119
+#define SCB_SHCSR_MEMFAULTENA_Msk          (1UL << SCB_SHCSR_MEMFAULTENA_Pos)             /*!< SCB SHCSR: MEMFAULTENA Mask */
120
+
121
+#define SCB_SHCSR_SVCALLPENDED_Pos         15U                                            /*!< SCB SHCSR: SVCALLPENDED Position */
122
+#define SCB_SHCSR_SVCALLPENDED_Msk         (1UL << SCB_SHCSR_SVCALLPENDED_Pos)            /*!< SCB SHCSR: SVCALLPENDED Mask */
123
+
124
+#define SCB_SHCSR_BUSFAULTPENDED_Pos       14U                                            /*!< SCB SHCSR: BUSFAULTPENDED Position */
125
+#define SCB_SHCSR_BUSFAULTPENDED_Msk       (1UL << SCB_SHCSR_BUSFAULTPENDED_Pos)          /*!< SCB SHCSR: BUSFAULTPENDED Mask */
126
+
127
+#define SCB_SHCSR_MEMFAULTPENDED_Pos       13U                                            /*!< SCB SHCSR: MEMFAULTPENDED Position */
128
+#define SCB_SHCSR_MEMFAULTPENDED_Msk       (1UL << SCB_SHCSR_MEMFAULTPENDED_Pos)          /*!< SCB SHCSR: MEMFAULTPENDED Mask */
129
+
130
+#define SCB_SHCSR_USGFAULTPENDED_Pos       12U                                            /*!< SCB SHCSR: USGFAULTPENDED Position */
131
+#define SCB_SHCSR_USGFAULTPENDED_Msk       (1UL << SCB_SHCSR_USGFAULTPENDED_Pos)          /*!< SCB SHCSR: USGFAULTPENDED Mask */
132
+
133
+#define SCB_SHCSR_SYSTICKACT_Pos           11U                                            /*!< SCB SHCSR: SYSTICKACT Position */
134
+#define SCB_SHCSR_SYSTICKACT_Msk           (1UL << SCB_SHCSR_SYSTICKACT_Pos)              /*!< SCB SHCSR: SYSTICKACT Mask */
135
+
136
+#define SCB_SHCSR_PENDSVACT_Pos            10U                                            /*!< SCB SHCSR: PENDSVACT Position */
137
+#define SCB_SHCSR_PENDSVACT_Msk            (1UL << SCB_SHCSR_PENDSVACT_Pos)               /*!< SCB SHCSR: PENDSVACT Mask */
138
+
139
+#define SCB_SHCSR_MONITORACT_Pos            8U                                            /*!< SCB SHCSR: MONITORACT Position */
140
+#define SCB_SHCSR_MONITORACT_Msk           (1UL << SCB_SHCSR_MONITORACT_Pos)              /*!< SCB SHCSR: MONITORACT Mask */
141
+
142
+#define SCB_SHCSR_SVCALLACT_Pos             7U                                            /*!< SCB SHCSR: SVCALLACT Position */
143
+#define SCB_SHCSR_SVCALLACT_Msk            (1UL << SCB_SHCSR_SVCALLACT_Pos)               /*!< SCB SHCSR: SVCALLACT Mask */
144
+
145
+#define SCB_SHCSR_USGFAULTACT_Pos           3U                                            /*!< SCB SHCSR: USGFAULTACT Position */
146
+#define SCB_SHCSR_USGFAULTACT_Msk          (1UL << SCB_SHCSR_USGFAULTACT_Pos)             /*!< SCB SHCSR: USGFAULTACT Mask */
147
+
148
+#define SCB_SHCSR_BUSFAULTACT_Pos           1U                                            /*!< SCB SHCSR: BUSFAULTACT Position */
149
+#define SCB_SHCSR_BUSFAULTACT_Msk          (1UL << SCB_SHCSR_BUSFAULTACT_Pos)             /*!< SCB SHCSR: BUSFAULTACT Mask */
150
+
151
+#define SCB_SHCSR_MEMFAULTACT_Pos           0U                                            /*!< SCB SHCSR: MEMFAULTACT Position */
152
+#define SCB_SHCSR_MEMFAULTACT_Msk          (1UL /*<< SCB_SHCSR_MEMFAULTACT_Pos*/)         /*!< SCB SHCSR: MEMFAULTACT Mask */
153
+
154
+
155
+/**
156
+  \brief  Structure type to access the Data Watchpoint and Trace Register (DWT).
157
+ */
158
+typedef struct {
159
+   __IOM uint32_t CTRL;                   /*!< Offset: 0x000 (R/W)  Control Register */
160
+   __IOM uint32_t CYCCNT;                 /*!< Offset: 0x004 (R/W)  Cycle Count Register */
161
+   __IOM uint32_t CPICNT;                 /*!< Offset: 0x008 (R/W)  CPI Count Register */
162
+   __IOM uint32_t EXCCNT;                 /*!< Offset: 0x00C (R/W)  Exception Overhead Count Register */
163
+   __IOM uint32_t SLEEPCNT;               /*!< Offset: 0x010 (R/W)  Sleep Count Register */
164
+   __IOM uint32_t LSUCNT;                 /*!< Offset: 0x014 (R/W)  LSU Count Register */
165
+   __IOM uint32_t FOLDCNT;                /*!< Offset: 0x018 (R/W)  Folded-instruction Count Register */
166
+   __IM  uint32_t PCSR;                   /*!< Offset: 0x01C (R/ )  Program Counter Sample Register */
167
+   __IOM uint32_t COMP0;                  /*!< Offset: 0x020 (R/W)  Comparator Register 0 */
168
+   __IOM uint32_t MASK0;                  /*!< Offset: 0x024 (R/W)  Mask Register 0 */
169
+   __IOM uint32_t FUNCTION0;              /*!< Offset: 0x028 (R/W)  Function Register 0 */
170
+   uint32_t RESERVED0[1U];
171
+   __IOM uint32_t COMP1;                  /*!< Offset: 0x030 (R/W)  Comparator Register 1 */
172
+   __IOM uint32_t MASK1;                  /*!< Offset: 0x034 (R/W)  Mask Register 1 */
173
+   __IOM uint32_t FUNCTION1;              /*!< Offset: 0x038 (R/W)  Function Register 1 */
174
+   uint32_t RESERVED1[1U];
175
+   __IOM uint32_t COMP2;                  /*!< Offset: 0x040 (R/W)  Comparator Register 2 */
176
+   __IOM uint32_t MASK2;                  /*!< Offset: 0x044 (R/W)  Mask Register 2 */
177
+   __IOM uint32_t FUNCTION2;              /*!< Offset: 0x048 (R/W)  Function Register 2 */
178
+   uint32_t RESERVED2[1U];
179
+   __IOM uint32_t COMP3;                  /*!< Offset: 0x050 (R/W)  Comparator Register 3 */
180
+   __IOM uint32_t MASK3;                  /*!< Offset: 0x054 (R/W)  Mask Register 3 */
181
+   __IOM uint32_t FUNCTION3;              /*!< Offset: 0x058 (R/W)  Function Register 3 */
182
+} DWT_Type;
183
+
184
+/**
185
+  \brief  Structure type to access the Memory Protection Unit (MPU).
186
+ */
187
+typedef struct {
188
+   __IM  uint32_t TYPE;                   /*!< Offset: 0x000 (R/ )  MPU Type Register */
189
+   __IOM uint32_t CTRL;                   /*!< Offset: 0x004 (R/W)  MPU Control Register */
190
+   __IOM uint32_t RNR;                    /*!< Offset: 0x008 (R/W)  MPU Region RNRber Register */
191
+   __IOM uint32_t RBAR;                   /*!< Offset: 0x00C (R/W)  MPU Region Base Address Register */
192
+   __IOM uint32_t RASR;                   /*!< Offset: 0x010 (R/W)  MPU Region Attribute and Size Register */
193
+   __IOM uint32_t RBAR_A1;                /*!< Offset: 0x014 (R/W)  MPU Alias 1 Region Base Address Register */
194
+   __IOM uint32_t RASR_A1;                /*!< Offset: 0x018 (R/W)  MPU Alias 1 Region Attribute and Size Register */
195
+   __IOM uint32_t RBAR_A2;                /*!< Offset: 0x01C (R/W)  MPU Alias 2 Region Base Address Register */
196
+   __IOM uint32_t RASR_A2;                /*!< Offset: 0x020 (R/W)  MPU Alias 2 Region Attribute and Size Register */
197
+   __IOM uint32_t RBAR_A3;                /*!< Offset: 0x024 (R/W)  MPU Alias 3 Region Base Address Register */
198
+   __IOM uint32_t RASR_A3;                /*!< Offset: 0x028 (R/W)  MPU Alias 3 Region Attribute and Size Register */
199
+} MPU_Type;
200
+
201
+/**
202
+  \brief  Structure type to access the Core Debug Register (CoreDebug).
203
+ */
204
+typedef struct {
205
+   __IOM uint32_t DHCSR;                  /*!< Offset: 0x000 (R/W)  Debug Halting Control and Status Register */
206
+   __OM  uint32_t DCRSR;                  /*!< Offset: 0x004 ( /W)  Debug Core Register Selector Register */
207
+   __IOM uint32_t DCRDR;                  /*!< Offset: 0x008 (R/W)  Debug Core Register Data Register */
208
+   __IOM uint32_t DEMCR;                  /*!< Offset: 0x00C (R/W)  Debug Exception and Monitor Control Register */
209
+} CoreDebug_Type;
210
+
211
+
212
+STATIC_INLINE uint32_t __get_CONTROL(void)
213
+{
214
+   uint32_t tmp;
215
+   __asm__ volatile("mrs\t%0, CONTROL\n":"=r" (tmp));
216
+   return tmp;
217
+}
218
+
219
+STATIC_INLINE void __set_CONTROL(uint32_t tmp)
220
+{
221
+   __asm__ volatile("msr\tCONTROL, %0\n"::"r" (tmp));
222
+}
223
+
224
+STATIC_INLINE void __set_MSP(uint32_t tmp)
225
+{
226
+   __asm__ volatile("msr\tMSP, %0\n"::"r" (tmp));
227
+}
228
+
229
+/**
230
+  \brief   Set Interrupt Priority
231
+  \details Sets the priority of a device specific interrupt or a processor exception.
232
+           The interrupt number can be positive to specify a device specific interrupt,
233
+           or negative to specify a processor exception.
234
+  \param [in]      IRQn  Interrupt number.
235
+  \param [in]  priority  Priority to set.
236
+  \note    The priority cannot be set for every processor exception.
237
+ */
238
+STATIC_INLINE void __NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority)
239
+{
240
+  if ((int32_t)(IRQn) >= 0)
241
+  {
242
+    NVIC->IP[((uint32_t)IRQn)]               = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL);
243
+  }
244
+  else
245
+  {
246
+    SCB->SHP[(((uint32_t)IRQn) & 0xFUL)-4UL] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL);
247
+  }
248
+}
249
+
250
+STATIC_INLINE void __WFI(void)
251
+{
252
+   __asm__ volatile("wfi");
253
+}
254
+
255
+STATIC_INLINE void __BKPT(uint8_t n)
256
+{
257
+   __asm__ volatile("bkpt %0" : : "i" (n & 0xFF));
258
+}
259
+
260
+STATIC_INLINE void __disable_irq(void)
261
+{
262
+  __asm__ volatile ("cpsid i" : : : "memory");
263
+}
264
+
265
+STATIC_INLINE void __enable_irq(void)
266
+{
267
+   __asm__ volatile("cpsie i" : : : "memory");
268
+}
269
+
270
+#ifdef __cplusplus
271
+}
272
+#endif
273
+
274
+#endif /* __UCMSIS_H__ */

+ 88
- 0
Middlewares/elog/usemihosting.h Ver arquivo

@@ -0,0 +1,88 @@
1
+#ifndef __USEMIHOSTING_H__
2
+#define __USEMIHOSTING_H__
3
+
4
+#include <string.h>
5
+
6
+typedef enum {
7
+    SYS_CLOSE = 0x02,
8
+    SYS_CLOCK = 0x10,
9
+    SYS_ELAPSED = 0x30,
10
+    SYS_ERRNO = 0x13,
11
+    SYS_FLEN = 0x0C,
12
+    SYS_GET_CMDLINE = 0x15,
13
+    SYS_HEAPINFO = 0x16,
14
+    SYS_ISERROR = 0x08,
15
+    SYS_ISTTY = 0x09,
16
+    SYS_OPEN = 0x01,
17
+    SYS_READ = 0x06,
18
+    SYS_READC = 0x07,
19
+    SYS_REMOVE = 0x0E,
20
+    SYS_RENAME = 0x0F,
21
+    SYS_SEEK = 0x0A,
22
+    SYS_SYSTEM = 0x12,
23
+    SYS_TICKFREQ = 0x31,
24
+    SYS_TIME = 0x11,
25
+    SYS_TMPNAM = 0x0D,
26
+    SYS_WRITE = 0x05,
27
+    SYS_WRITEC = 0x03,
28
+    SYS_WRITE0 = 0x04,
29
+} SemihostFunction_t;
30
+
31
+//              mode	0	1	2	3	4	5	6	7	8	9	10	11
32
+// ISO C fopen modea	r	rb	r+	r+b	w	wb	w+	w+b	a	ab	a+	a+b
33
+typedef enum {
34
+    SYS_OPEN_RO = 0,
35
+    SYS_OPEN_ROB = 1,
36
+    SYS_OPEN_RW = 2,
37
+    SYS_OPEN_RWB = 3,
38
+    SYS_OPEN_WO = 4,
39
+    SYS_OPEN_WOB = 5,
40
+    SYS_OPEN_WA = 6,
41
+    SYS_OPEN_WAB = 7,
42
+    SYS_OPEN_AC = 8,
43
+    SYS_OPEN_AB = 9,
44
+    SYS_OPEN_AR = 10,
45
+    SYS_OPEN_ARB = 11,
46
+} SemihostOpenMode_t;
47
+
48
+__attribute__((naked))
49
+static unsigned int call_semihosting(unsigned int func, void *params)
50
+{
51
+    (void) func;
52
+    (void) params;
53
+    __asm__ volatile("bkpt #0xAB\nbx lr");
54
+}
55
+
56
+static inline void write(int fd, const void *p, size_t n)
57
+{
58
+    void *params[] = {
59
+        (void*) fd,
60
+        (void*) p,
61
+        (void*) n,
62
+    };
63
+    call_semihosting(SYS_WRITE, params);
64
+}
65
+
66
+static inline int open(const char *path, int mode)
67
+{
68
+    void *params[] = {
69
+        (void*) path,
70
+        (void*) mode,
71
+        (void*) strlen(path)
72
+    };
73
+    return call_semihosting(SYS_OPEN, params);
74
+}
75
+
76
+static inline void close(int fd)
77
+{
78
+    void *params[] = { (void*) fd };
79
+    call_semihosting(SYS_CLOSE, params);
80
+}
81
+
82
+static inline void writestr(const char *s)
83
+{
84
+    void *params[] = { (void*) s };
85
+    call_semihosting(SYS_WRITE0, params);
86
+}
87
+
88
+#endif /* __USEMIHOSTING_H__ */

+ 2
- 4
Middlewares/rtthread/board.c Ver arquivo

@@ -95,11 +95,9 @@ void SysInit(void)
95 95
 
96 96
 int main(void)
97 97
 {
98
-    int i = 1;
99
-    int q = 58;
100
-    int d = i + q;
98
+    extern int elog_test(void);
99
+    elog_test();
101 100
     //rt_kprintf("%s\n", __func__);
102
-    test_softbreakpoint();
103 101
     return 0;
104 102
 }
105 103
 

Carregando…
Cancelar
Salvar