mirror of https://github.com/rusefi/rusefi.git
only:export board-specific macro for stm32 pins based on board yaml #3298
This commit is contained in:
parent
8249bbe5f9
commit
ea41455526
|
@ -133,8 +133,7 @@ public class PinoutLogic {
|
|||
SystemOut.println("Null yaml for " + yamlFile);
|
||||
return;
|
||||
}
|
||||
Map</*meta name*/String, /*native name*/String> map = processMetaHeader(yamlData);
|
||||
|
||||
Map</*meta name*/String, /*native name*/String> metaMapping = processMetaHeader(yamlData);
|
||||
|
||||
List<Map<String, Object>> data = (List<Map<String, Object>>) yamlData.get("pins");
|
||||
if (data == null) {
|
||||
|
@ -150,9 +149,9 @@ public class PinoutLogic {
|
|||
throw new IllegalStateException(pinId + " not expected with meta=" + meta);
|
||||
}
|
||||
if (meta != null) {
|
||||
pinId = map.get(meta);
|
||||
pinId = metaMapping.get(meta);
|
||||
if (pinId == null) {
|
||||
if (map.isEmpty())
|
||||
if (metaMapping.isEmpty())
|
||||
throw new IllegalStateException("Empty meta mapping");
|
||||
throw new IllegalStateException("Failing to resolve [" + meta + "]");
|
||||
}
|
||||
|
@ -176,6 +175,9 @@ public class PinoutLogic {
|
|||
throw new IllegalStateException(pinName + ": id array length should match class array length: " + pinId + " vs " + pinClassArray);
|
||||
for (int i = 0; i < pinIds.size(); i++) {
|
||||
String id = pinIds.get(i);
|
||||
// we are a bit inconsistent between single-function and array syntax:
|
||||
// for array syntax we just apply mapping on the fly while for single we use 'meta' keyword instead of 'pin' keyword
|
||||
id = applyMetaMapping(metaMapping, id);
|
||||
addPinToList(id, (String) pinTsName, pinClassArray.get(i));
|
||||
}
|
||||
} else if (pinId instanceof String) {
|
||||
|
@ -190,6 +192,10 @@ public class PinoutLogic {
|
|||
}
|
||||
}
|
||||
|
||||
private static String applyMetaMapping(Map<String, String> metaMapping, String id) {
|
||||
return metaMapping.getOrDefault(id, id);
|
||||
}
|
||||
|
||||
private Map<String, String> processMetaHeader(Map<String, Object> yamlData) {
|
||||
String metaHeader = (String) yamlData.get("meta");
|
||||
if (metaHeader == null)
|
||||
|
@ -203,9 +209,10 @@ public class PinoutLogic {
|
|||
Map</*meta name*/String, /*native name*/String> map = new HashMap<>();
|
||||
|
||||
for (String line : lines) {
|
||||
line = line.replace('\t', ' ');
|
||||
line = line.trim();
|
||||
if (ToolUtil.startsWithToken(line, VariableRegistry.DEFINE)) {
|
||||
line = line.substring(VariableRegistry.DEFINE.length() + 1);
|
||||
line = line.substring(VariableRegistry.DEFINE.length() + 1).trim();
|
||||
|
||||
int index = line.indexOf(' ');
|
||||
|
||||
|
|
|
@ -15,8 +15,9 @@ import static org.junit.Assert.assertEquals;
|
|||
|
||||
public class PinoutLogicIntegratedTest {
|
||||
|
||||
private static final List<String> META_CONTENT = Arrays.asList("#define H144_LS_1 Gpio::G7\n",
|
||||
"#define H144_LS_2 G8\n",
|
||||
private static final List<String> META_CONTENT = Arrays.asList("#define H144_LS_1 G7\n",
|
||||
"#define H144_DIGITAL\tE11\n",
|
||||
"\t\t\t\t#define\t\t\tH144_LS_2 G8\t\t\t\n",
|
||||
"// IN_O2S AIN13 A13 PA0\n",
|
||||
"#define H144_IN_O2S EFI_ADC_0\n",
|
||||
"// IN_O2S2 AIN12 PA1\n",
|
||||
|
@ -25,8 +26,9 @@ public class PinoutLogicIntegratedTest {
|
|||
@Test
|
||||
public void testMetaParsing() {
|
||||
Map</*meta name*/String, /*native name*/String> map = PinoutLogic.getStringStringMap(META_CONTENT);
|
||||
assertEquals(4, map.size());
|
||||
assertEquals(5, map.size());
|
||||
|
||||
assertEquals("G8", map.get("H144_LS_2"));
|
||||
assertEquals("EFI_ADC_0", map.get("H144_IN_O2S"));
|
||||
}
|
||||
|
||||
|
@ -65,7 +67,7 @@ public class PinoutLogicIntegratedTest {
|
|||
" function: Digital trigger/switch input for instance Hall type CAM\n" +
|
||||
" ts_name: ___ - Digital 1\n" +
|
||||
" - pin: 1\n" +
|
||||
" id: [E11, E11]\n" +
|
||||
" id: [H144_DIGITAL, H144_DIGITAL]\n" +
|
||||
" class: [event_inputs, switch_inputs]\n" +
|
||||
" function: Digital trigger/switch input for instance Hall type CAM\n" +
|
||||
" ts_name: ___ - Digital 2\n" +
|
||||
|
|
Loading…
Reference in New Issue