auto-sync
This commit is contained in:
parent
a0439f9eb8
commit
8cb28b2f86
|
@ -184,9 +184,10 @@ typedef struct {
|
|||
brain_pin_e o2heaterPin;
|
||||
pin_output_mode_e o2heaterPinModeTodO;
|
||||
|
||||
unsigned int is_enabled_spi_1 : 1;
|
||||
unsigned int is_enabled_spi_2 : 1;
|
||||
unsigned int is_enabled_spi_3 : 1;
|
||||
unsigned int is_enabled_spi_1 : 1; // bit 0
|
||||
unsigned int is_enabled_spi_2 : 1; // bit 1
|
||||
unsigned int is_enabled_spi_3 : 1; // bit 2
|
||||
unsigned int isSdCardEnabled : 1; // bit 3
|
||||
|
||||
int unused2[6];
|
||||
|
||||
|
|
|
@ -20,6 +20,9 @@
|
|||
#include "pin_repository.h"
|
||||
#include "ff.h"
|
||||
#include "hardware.h"
|
||||
#include "engine_configuration.h"
|
||||
|
||||
extern board_configuration_s *boardConfiguration;
|
||||
|
||||
#define PUSHPULLDELAY 500
|
||||
|
||||
|
@ -32,15 +35,7 @@ MMCDriver MMCD1;
|
|||
|
||||
// Peripherial Clock 42MHz SPI2 SPI3
|
||||
// Peripherial Clock 84MHz SPI1 SPI1 SPI2/3
|
||||
#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_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,
|
||||
SPI_BaudRatePrescaler_8 };
|
||||
static SPIConfig ls_spicfg = { NULL, SPI_SD_MODULE_PORT, SPI_SD_MODULE_PIN,
|
||||
SPI_BaudRatePrescaler_256 };
|
||||
|
@ -227,7 +222,7 @@ static void MMCmount(void) {
|
|||
}
|
||||
|
||||
#if defined __GNUC__
|
||||
__attribute__((noreturn)) static msg_t MMCmonThread(void)
|
||||
__attribute__((noreturn)) static msg_t MMCmonThread(void)
|
||||
#else
|
||||
static msg_t MMCmonThread(void)
|
||||
#endif
|
||||
|
@ -254,6 +249,9 @@ bool isSdCardAlive(void) {
|
|||
|
||||
void initMmcCard(void) {
|
||||
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
|
||||
|
|
|
@ -63,11 +63,13 @@ public class EcuStimulator {
|
|||
|
||||
private final JPanel content = new JPanel(new BorderLayout());
|
||||
|
||||
private JPanel panel = ChartHelper.create3DControl(data, model, TITLE);
|
||||
|
||||
private static EcuStimulator instance = new EcuStimulator();
|
||||
|
||||
private final JLabel statusLabel = new JLabel();
|
||||
|
||||
private EcuStimulator() {
|
||||
JPanel panel = ChartHelper.create3DControl(data, model, TITLE);
|
||||
content.add(statusLabel, BorderLayout.NORTH);
|
||||
content.add(panel, BorderLayout.CENTER);
|
||||
content.add(inputs.getContent(), BorderLayout.WEST);
|
||||
}
|
||||
|
@ -143,6 +145,8 @@ public class EcuStimulator {
|
|||
*/
|
||||
sleepRuntime(SLEEP_TIME);
|
||||
|
||||
statusLabel.setText("RPM " + rpm + ", el " + engineLoad);
|
||||
|
||||
/**
|
||||
* We are making a number of measurements and then we take the middle one
|
||||
*/
|
||||
|
|
|
@ -52,7 +52,7 @@ public class StimulationInputs {
|
|||
}
|
||||
|
||||
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) {
|
||||
JPanel result = new JPanel(new BorderLayout());
|
||||
result.setBorder(BorderFactory.createLineBorder(Color.red));
|
||||
|
||||
final JSurfacePanel jsp = new JSurfacePanel(surfaceModel);
|
||||
jsp.setTitleText(title);
|
||||
|
|
|
@ -83,11 +83,11 @@ public class PotCommand {
|
|||
public static void requestPotChange(int channel, int resistance) {
|
||||
if (resistance < 0 || resistance > 10000)
|
||||
throw new IllegalArgumentException("resistance: " + resistance);
|
||||
CommandQueue.getInstance().write("pot" + channel + " " + resistance);
|
||||
CommandQueue.getInstance().write("pot " + channel + " " + resistance);
|
||||
}
|
||||
|
||||
public static int getPotResistance(Double vout, double vRef) {
|
||||
double r = getR1InVoltageDividor3(vout, vRef, EcuStimulator.getInstance().getInputs().getEngineLoadR2Resistance());
|
||||
public static int getPotResistance(double vout, double vRef) {
|
||||
double r = getR1InVoltageDivider3(vout, vRef, EcuStimulator.getInstance().getInputs().getEngineLoadR2Resistance());
|
||||
MessagesCentral.getInstance().postMessage(PotCommand.class, "VRef=" + vRef + ", needed resistance: " + r);
|
||||
// pot command accept resistance and does the conversion itself
|
||||
return (int) r;
|
||||
|
@ -101,8 +101,8 @@ public class PotCommand {
|
|||
// return (int) (256 - (Rwa - 52) * 256 / 10000);
|
||||
// }
|
||||
|
||||
private static double getR1InVoltageDividor3(double Vout, double Vin, double r2) {
|
||||
return r2 * Vin / Vout - r2;
|
||||
public static double getR1InVoltageDivider3(double Vout, double Vin, double r2) {
|
||||
return r2 * Vout / Vin;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue