extracting hw-specific enums

This commit is contained in:
rusefi 2019-06-04 12:21:28 -04:00
parent 3a10946940
commit 09767649de
8 changed files with 37 additions and 21 deletions

View File

@ -1,8 +1,10 @@
#include "global.h"
#include "rusefi_enums.h"
#include "rusefi_hw_enums.h"
// auto-generated from rusefi_hw_enums.h
// auto-generated from rusefi_enums.h
// by enum2string.jar tool
// on Sun Jun 02 16:14:34 EDT 2019
// on Tue Jun 04 12:17:32 EDT 2019
// see also gen_config_and_enums.bat

View File

@ -1,11 +1,13 @@
// auto-generated from rusefi_hw_enums.h
// auto-generated from rusefi_enums.h
// by enum2string.jar tool
// on Sun Jun 02 16:14:34 EDT 2019
// on Tue Jun 04 12:17:32 EDT 2019
// see also gen_config_and_enums.bat
#include "rusefi_enums.h"
#include "rusefi_hw_enums.h"
#ifndef _A_H_HEADER_
#define _A_H_HEADER_
const char *getPidAutoTune_AutoTunerState(PidAutoTune_AutoTunerState value);

View File

@ -13,6 +13,7 @@
#include "efifeatures.h"
#include "obd_error_codes.h"
#include "rusefi_hw_enums.h"
#define HIP_NAME "HIP"
#define TACH_NAME "tach"
@ -444,16 +445,6 @@ typedef enum __attribute__ ((__packed__)) {
OM_OPENDRAIN_INVERTED = 3
} pin_output_mode_e;
// todo: migrate/unify with pin_output_mode_e? rename? something is messy here
// this enum is currently only used for SPI pins
typedef enum __attribute__ ((__packed__)) {
// todo: here we have a rare example of stm32-specific enum, todo: make this not stm32 specific?
PO_DEFAULT = 0,
PO_OPENDRAIN = 4, // PAL_STM32_OTYPE_OPENDRAIN
PO_PULLUP = 32, // PAL_STM32_PUDR_PULLUP
PO_PULLDOWN = 64 // PAL_STM32_PUPDR_PULLDOWN
} pin_mode_e;
typedef enum __attribute__ ((__packed__)) {
PI_DEFAULT = 0,
PI_PULLUP = 1,

View File

@ -0,0 +1,21 @@
/*
* @file rusefi_hw_enums.h
*
* @date Jun 2, 2019
* @author Andrey Belomutskiy, (c) 2012-2019
*/
#ifndef RUSEFI_HW_ENUMS_H_
#define RUSEFI_HW_ENUMS_H_
// todo: migrate/unify with pin_output_mode_e? rename? something is messy here
// this enum is currently only used for SPI pins
typedef enum __attribute__ ((__packed__)) {
// todo: here we have a rare example of stm32-specific enum, todo: make this not stm32 specific?
PO_DEFAULT = 0,
PO_OPENDRAIN = 4, // PAL_STM32_OTYPE_OPENDRAIN
PO_PULLUP = 32, // PAL_STM32_PUDR_PULLUP
PO_PULLDOWN = 64 // PAL_STM32_PUPDR_PULLDOWN
} pin_mode_e;
#endif /* RUSEFI_HW_ENUMS_H_ */

View File

@ -1,3 +1,3 @@
rem This batch files reads rusefi_enums.h and produses auto_generated_enums.* files
java -jar ../java_tools/enum2string.jar -inputPath . -outputPath controllers/algo
java -jar ../java_tools/enum2string.jar -inputPath . -outputPath controllers/algo -enumInputFile controllers/algo/rusefi_enums.h -enumInputFile controllers/algo/rusefi_hw_enums.h

Binary file not shown.

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" addBOMForNewFiles="with NO BOM" />
</project>

View File

@ -24,10 +24,8 @@ public class EnumToString {
private final static StringBuilder headerFileContent = new StringBuilder();
public static final String COMMON_HEADER_RELATIVE_NAME = "controllers/algo/rusefi_enums.h";
private final static String KEY_INPUT_PATH = "-inputPath";
// private final static String KEY_INPUT_FILE = "-inputFile";
private final static String KEY_ENUM_INPUT_FILE = "-enumInputFile";
private final static String KEY_OUTPUT = "-outputPath";
public static void main(String[] args) throws IOException {
@ -46,17 +44,15 @@ public class EnumToString {
String key = args[i];
if (key.equals(KEY_INPUT_PATH)) {
inputPath = args[i + 1];
// } else if (key.equals(KEY_INPUT_FILE)) {
// String inputFile = args[i + 1];
// consumeFile(inputPath, inputFile);
} else if (key.equals(KEY_ENUM_INPUT_FILE)) {
String inputFile = args[i + 1];
consumeFile(inputPath, inputFile);
} else if (key.equals(KEY_OUTPUT)) {
outputPath = args[i + 1];
}
}
consumeFile(inputPath, COMMON_HEADER_RELATIVE_NAME);
headerFileContent.append("#ifndef _A_H_HEADER_\r\n");
headerFileContent.append("#define _A_H_HEADER_\r\n");