Skip to content

Commit faf751a

Browse files
authored
Add a generation of new-style header file. (#14)
1 parent 6086237 commit faf751a

File tree

3 files changed

+79
-8
lines changed

3 files changed

+79
-8
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ bin
1212

1313
# Ignore some generated files
1414
silabs-pti/debug-message-type-gen.h
15-
15+
silabs-pti/sl_iostream_swo_itm_8.h
1616
release/

silabs-pti/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.13.1
1+
1.13.2

silabs-pti/build.gradle

Lines changed: 77 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,21 +86,22 @@ task createDebugMessageTypes() {
8686
def javaprops = file("src/main/resources/debugMessageType.properties")
8787
def javaenum = file("src/main/java/com/silabs/pti/debugchannel/DebugMessageType.java")
8888
def cenum = file("debug-message-type-gen.h")
89+
def cenum2 = file("sl_iostream_swo_itm_8.h")
8990

9091
// Sort the types
9192
def sortedTypes = json.types.sort { a,b -> a.getValue().code <=> b.getValue().code }
9293

9394
// Write props
94-
project.logger.lifecycle("Write ${javaprops}")
9595
def text = "# !!!! This file is generated via 'gradle createDebugMessageTypes' command. Please do not edit manually!!!!!\n\n"
9696
sortedTypes.each {
9797
t ->
9898
text += "${t.getKey()}.long=${t.getValue().longDescription}\n"
9999
text += "${t.getKey()}=${t.getValue().shortDescription}\n"
100100
}
101+
project.logger.lifecycle("🎁 Write ${javaprops}")
101102
javaprops.text = text
102103

103-
// Write enum
104+
// Write java enum
104105
text = """/*******************************************************************************
105106
* # License
106107
* Copyright 2022 Silicon Laboratories Inc. www.silabs.com
@@ -187,15 +188,14 @@ public enum DebugMessageType {
187188
text = text + "\n public static int featureLevel() { return ${json.featureLevel}; }\n"
188189
text = text + "\n public static String featureDate() { return \"${json.featureDate}\"; }\n"
189190
text = text + "\n}"
190-
project.logger.lifecycle("Write ${javaenum}")
191+
project.logger.lifecycle("🎁 Write ${javaenum}")
191192
javaenum.text = text
192193

193194
// Write C enum
194-
project.logger.lifecycle("Write ${cenum}")
195-
text = """// (c) Silicon Laboratories, Inc., 2012, 2022
195+
text = """// (c) Silicon Laboratories, Inc., 2012, 2022, 2025
196196
//
197197
// !!!! This file is generated via 'gradle createDebugMessageTypes' command inside
198-
// the public repo https://github.com/SiliconLabs/java_packet_trace_library
198+
// the public repo https://github.com/SiliconLabsSoftware/java-pti
199199
//
200200
// Please do not edit manually!!!!!\n
201201
#ifndef __SL_DEBUG_MESSAGE_TYPES__
@@ -231,8 +231,79 @@ enum {
231231
}
232232

233233
text = text + "};\n\n#define SL_DEBUG_MESSAGE_TYPE_FEATURE_LEVEL (${json.featureLevel})\n\n#endif // SL_DEBUG_MESSAGE_TYPES\n"
234+
project.logger.lifecycle("🎁 Write ${cenum}")
234235
cenum.text = text
235236

237+
text = """/***************************************************************************//**
238+
* @file
239+
* @brief IO Stream SWO Component.
240+
*******************************************************************************
241+
* # License
242+
* <b>Copyright 2019 Silicon Laboratories Inc. www.silabs.com</b>
243+
*******************************************************************************
244+
*
245+
* SPDX-License-Identifier: Zlib
246+
*
247+
* The licensor of this software is Silicon Laboratories Inc.
248+
*
249+
* This software is provided 'as-is', without any express or implied
250+
* warranty. In no event will the authors be held liable for any damages
251+
* arising from the use of this software.
252+
*
253+
* Permission is granted to anyone to use this software for any purpose,
254+
* including commercial applications, and to alter it and redistribute it
255+
* freely, subject to the following restrictions:
256+
*
257+
* 1. The origin of this software must not be misrepresented; you must not
258+
* claim that you wrote the original software. If you use this software
259+
* in a product, an acknowledgment in the product documentation would be
260+
* appreciated but is not required.
261+
* 2. Altered source versions must be plainly marked as such, and must not be
262+
* misrepresented as being the original software.
263+
* 3. This notice may not be removed or altered from any source distribution.
264+
*
265+
******************************************************************************/
266+
267+
//
268+
// !!!! This file is generated via 'gradle createDebugMessageTypes' command inside
269+
// the public repo https://github.com/SiliconLabsSoftware/java-pti
270+
//
271+
// Please do not edit manually!!!!!\n
272+
273+
#ifndef SL_IOSTREAM_SWO_ITM_8_H
274+
#define SL_IOSTREAM_SWO_ITM_8_H
275+
276+
#include "sl_enum.h"
277+
278+
#ifdef __cplusplus
279+
extern "C" {
280+
#endif
281+
282+
SL_ENUM_GENERIC(sl_iostream_swo_itm_8_msg_type_t, uint16_t) {
283+
"""
284+
285+
// these are for backwards compatibility, with the EM_ prefix.
286+
sortedTypes.each {
287+
t ->
288+
def prefix = "EM_DEBUG"
289+
if ( t.getKey().startsWith("PACKET_TRACE_") || t.getKey().startsWith("FLASH_")
290+
|| t.getKey().startsWith("EEPROM_") || t.getKey().startsWith("RAM_")
291+
|| t.getKey().startsWith("SIMULATED_") || t.getKey().startsWith("AEM_")|| t.getKey().startsWith("CPU_")) {
292+
prefix = "EM"
293+
}
294+
text += " ${prefix}_${t.getKey()} = ${t.getValue().code},\n"
295+
}
296+
text = text + """\n};
297+
298+
#ifdef __cplusplus
299+
}
300+
#endif
301+
302+
#endif /* SL_IOSTREAM_SWO_ITM_8_H */
303+
304+
"""
305+
project.logger.lifecycle("🎁 Write ${cenum2}")
306+
cenum2.text = text
236307
}
237308
}
238309

0 commit comments

Comments
 (0)