auto-sync
This commit is contained in:
parent
7e2f3c16f2
commit
a66d0211ea
|
@ -184,9 +184,10 @@ typedef struct {
|
||||||
brain_pin_e o2heaterPin;
|
brain_pin_e o2heaterPin;
|
||||||
pin_output_mode_e o2heaterPinModeTodO;
|
pin_output_mode_e o2heaterPinModeTodO;
|
||||||
|
|
||||||
unsigned int is_enabled_spi_1 : 1;
|
unsigned int is_enabled_spi_1 : 1; // bit 0
|
||||||
unsigned int is_enabled_spi_2 : 1;
|
unsigned int is_enabled_spi_2 : 1; // bit 1
|
||||||
unsigned int is_enabled_spi_3 : 1;
|
unsigned int is_enabled_spi_3 : 1; // bit 2
|
||||||
|
unsigned int isSdCardEnabled : 1; // bit 3
|
||||||
|
|
||||||
int unused2[6];
|
int unused2[6];
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,9 @@
|
||||||
#include "pin_repository.h"
|
#include "pin_repository.h"
|
||||||
#include "ff.h"
|
#include "ff.h"
|
||||||
#include "hardware.h"
|
#include "hardware.h"
|
||||||
|
#include "engine_configuration.h"
|
||||||
|
|
||||||
|
extern board_configuration_s *boardConfiguration;
|
||||||
|
|
||||||
#define PUSHPULLDELAY 500
|
#define PUSHPULLDELAY 500
|
||||||
|
|
||||||
|
@ -32,15 +35,7 @@ MMCDriver MMCD1;
|
||||||
|
|
||||||
// Peripherial Clock 42MHz SPI2 SPI3
|
// Peripherial Clock 42MHz SPI2 SPI3
|
||||||
// Peripherial Clock 84MHz SPI1 SPI1 SPI2/3
|
// Peripherial Clock 84MHz SPI1 SPI1 SPI2/3
|
||||||
#define SPI_BaudRatePrescaler_2 ((uint16_t)0x0000) // 42 MHz 21 MHZ
|
#define SPI_BaudRatePrescaler_2 ((uint16_t)0x0000) // 42 MHz 21 MHZ
#define SPI_BaudRatePrescaler_4 ((uint16_t)0x0008) // 21 MHz 10.5 MHz
#define SPI_BaudRatePrescaler_8 ((uint16_t)0x0010) // 10.5 MHz 5.25 MHz
#define SPI_BaudRatePrescaler_16 ((uint16_t)0x0018) // 5.25 MHz 2.626 MHz
#define SPI_BaudRatePrescaler_32 ((uint16_t)0x0020) // 2.626 MHz 1.3125 MHz
#define SPI_BaudRatePrescaler_64 ((uint16_t)0x0028) // 1.3125 MHz 656.25 KHz
#define SPI_BaudRatePrescaler_128 ((uint16_t)0x0030) // 656.25 KHz 328.125 KHz
#define SPI_BaudRatePrescaler_256 ((uint16_t)0x0038) // 328.125 KHz 164.06 KHz
static SPIConfig hs_spicfg = { NULL, SPI_SD_MODULE_PORT, SPI_SD_MODULE_PIN,
|
||||||
#define SPI_BaudRatePrescaler_4 ((uint16_t)0x0008) // 21 MHz 10.5 MHz
|
|
||||||
#define SPI_BaudRatePrescaler_8 ((uint16_t)0x0010) // 10.5 MHz 5.25 MHz
|
|
||||||
#define SPI_BaudRatePrescaler_16 ((uint16_t)0x0018) // 5.25 MHz 2.626 MHz
|
|
||||||
#define SPI_BaudRatePrescaler_32 ((uint16_t)0x0020) // 2.626 MHz 1.3125 MHz
|
|
||||||
#define SPI_BaudRatePrescaler_64 ((uint16_t)0x0028) // 1.3125 MHz 656.25 KHz
|
|
||||||
#define SPI_BaudRatePrescaler_128 ((uint16_t)0x0030) // 656.25 KHz 328.125 KHz
|
|
||||||
#define SPI_BaudRatePrescaler_256 ((uint16_t)0x0038) // 328.125 KHz 164.06 KHz
|
|
||||||
static SPIConfig hs_spicfg = { NULL, SPI_SD_MODULE_PORT, SPI_SD_MODULE_PIN,
|
|
||||||
SPI_BaudRatePrescaler_8 };
|
SPI_BaudRatePrescaler_8 };
|
||||||
static SPIConfig ls_spicfg = { NULL, SPI_SD_MODULE_PORT, SPI_SD_MODULE_PIN,
|
static SPIConfig ls_spicfg = { NULL, SPI_SD_MODULE_PORT, SPI_SD_MODULE_PIN,
|
||||||
SPI_BaudRatePrescaler_256 };
|
SPI_BaudRatePrescaler_256 };
|
||||||
|
@ -254,6 +249,9 @@ bool isSdCardAlive(void) {
|
||||||
|
|
||||||
void initMmcCard(void) {
|
void initMmcCard(void) {
|
||||||
initLogging(&logger, "mmcCard");
|
initLogging(&logger, "mmcCard");
|
||||||
|
if (!boardConfiguration->isSdCardEnabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* FYI: SPI does not work with CCM memory, be sure to have main() stack in RAM, not in CCMRAM
|
* FYI: SPI does not work with CCM memory, be sure to have main() stack in RAM, not in CCMRAM
|
||||||
|
|
|
@ -63,11 +63,13 @@ public class EcuStimulator {
|
||||||
|
|
||||||
private final JPanel content = new JPanel(new BorderLayout());
|
private final JPanel content = new JPanel(new BorderLayout());
|
||||||
|
|
||||||
private JPanel panel = ChartHelper.create3DControl(data, model, TITLE);
|
|
||||||
|
|
||||||
private static EcuStimulator instance = new EcuStimulator();
|
private static EcuStimulator instance = new EcuStimulator();
|
||||||
|
|
||||||
|
private final JLabel statusLabel = new JLabel();
|
||||||
|
|
||||||
private EcuStimulator() {
|
private EcuStimulator() {
|
||||||
|
JPanel panel = ChartHelper.create3DControl(data, model, TITLE);
|
||||||
|
content.add(statusLabel, BorderLayout.NORTH);
|
||||||
content.add(panel, BorderLayout.CENTER);
|
content.add(panel, BorderLayout.CENTER);
|
||||||
content.add(inputs.getContent(), BorderLayout.WEST);
|
content.add(inputs.getContent(), BorderLayout.WEST);
|
||||||
}
|
}
|
||||||
|
@ -143,6 +145,8 @@ public class EcuStimulator {
|
||||||
*/
|
*/
|
||||||
sleepRuntime(SLEEP_TIME);
|
sleepRuntime(SLEEP_TIME);
|
||||||
|
|
||||||
|
statusLabel.setText("RPM " + rpm + ", el " + engineLoad);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* We are making a number of measurements and then we take the middle one
|
* We are making a number of measurements and then we take the middle one
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -52,7 +52,7 @@ public class StimulationInputs {
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getEngineLoadR2Resistance() {
|
public double getEngineLoadR2Resistance() {
|
||||||
return (double) elResistance2.getValue();
|
return (Integer) elResistance2.getValue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
package com.rusefi.test;
|
||||||
|
|
||||||
|
import com.rusefi.StimulationInputs;
|
||||||
|
import com.rusefi.ui.widgets.PotCommand;
|
||||||
|
import junit.framework.TestCase;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
public class VoltageDividerTest extends TestCase {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testR1() {
|
||||||
|
|
||||||
|
assertEquals(2000.0, PotCommand.getR1InVoltageDivider3(1, 5, 10000));
|
||||||
|
|
||||||
|
|
||||||
|
assertEquals(2040.816326530612, PotCommand.getR1InVoltageDivider3(1, 4.9, 10000));
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -26,6 +26,7 @@ public class ChartHelper {
|
||||||
|
|
||||||
public static JPanel create3DControl(final XYData data, SurfaceModel surfaceModel, String title) {
|
public static JPanel create3DControl(final XYData data, SurfaceModel surfaceModel, String title) {
|
||||||
JPanel result = new JPanel(new BorderLayout());
|
JPanel result = new JPanel(new BorderLayout());
|
||||||
|
result.setBorder(BorderFactory.createLineBorder(Color.red));
|
||||||
|
|
||||||
final JSurfacePanel jsp = new JSurfacePanel(surfaceModel);
|
final JSurfacePanel jsp = new JSurfacePanel(surfaceModel);
|
||||||
jsp.setTitleText(title);
|
jsp.setTitleText(title);
|
||||||
|
|
|
@ -86,8 +86,8 @@ public class PotCommand {
|
||||||
CommandQueue.getInstance().write("pot " + channel + " " + resistance);
|
CommandQueue.getInstance().write("pot " + channel + " " + resistance);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getPotResistance(Double vout, double vRef) {
|
public static int getPotResistance(double vout, double vRef) {
|
||||||
double r = getR1InVoltageDividor3(vout, vRef, EcuStimulator.getInstance().getInputs().getEngineLoadR2Resistance());
|
double r = getR1InVoltageDivider3(vout, vRef, EcuStimulator.getInstance().getInputs().getEngineLoadR2Resistance());
|
||||||
MessagesCentral.getInstance().postMessage(PotCommand.class, "VRef=" + vRef + ", needed resistance: " + r);
|
MessagesCentral.getInstance().postMessage(PotCommand.class, "VRef=" + vRef + ", needed resistance: " + r);
|
||||||
// pot command accept resistance and does the conversion itself
|
// pot command accept resistance and does the conversion itself
|
||||||
return (int) r;
|
return (int) r;
|
||||||
|
@ -101,8 +101,8 @@ public class PotCommand {
|
||||||
// return (int) (256 - (Rwa - 52) * 256 / 10000);
|
// return (int) (256 - (Rwa - 52) * 256 / 10000);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
private static double getR1InVoltageDividor3(double Vout, double Vin, double r2) {
|
public static double getR1InVoltageDivider3(double Vout, double Vin, double r2) {
|
||||||
return r2 * Vin / Vout - r2;
|
return r2 * Vout / Vin;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue