MC33816 integraion #784

progress
This commit is contained in:
rusefi 2019-05-03 21:54:38 -04:00
parent bbd703de21
commit 153380c9f3
6 changed files with 65 additions and 8 deletions

View File

@ -786,7 +786,7 @@ void initEngineContoller(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX)
// help to notice when RAM usage goes up - if a code change adds to RAM usage these variables would fail
// linking process which is the way to raise the alarm
#ifndef RAM_UNUSED_SIZE
#define RAM_UNUSED_SIZE 8600
#define RAM_UNUSED_SIZE 7600
#endif
#ifndef CCM_UNUSED_SIZE
#define CCM_UNUSED_SIZE 6800
@ -807,6 +807,6 @@ int getRusEfiVersion(void) {
if (initBootloader() != 0)
return 123;
#endif /* EFI_BOOTLOADER_INCLUDE_CODE */
return 20190502;
return 20190503;
}
#endif /* EFI_UNIT_TEST */

View File

@ -6,7 +6,9 @@ HW_LAYER_EGT_CPP = $(PROJECT_DIR)/hw_layer/can_hw.cpp \
HW_LAYER_EMS = $(HW_LAYER_EGT) \
$(PROJECT_DIR)/hw_layer/mcp3208.c \
$(PROJECT_DIR)/hw_layer/flash.c
$(PROJECT_DIR)/hw_layer/mc33816_data.c \
$(PROJECT_DIR)/hw_layer/flash.c \
HW_LAYER_EMS_CPP = $(HW_LAYER_EGT_CPP) \
$(PROJECT_DIR)/hw_layer/pin_repository.cpp \
@ -31,7 +33,8 @@ HW_LAYER_EMS_CPP = $(HW_LAYER_EGT_CPP) \
$(PROJECT_DIR)/hw_layer/io_pins.cpp \
$(PROJECT_DIR)/hw_layer/rtc_helper.cpp \
$(PROJECT_DIR)/hw_layer/cdm_ion_sense.cpp \
$(PROJECT_DIR)/hw_layer/backup_ram.cpp
$(PROJECT_DIR)/hw_layer/backup_ram.cpp \
ifeq ($(PROJECT_CPU),ARCH_STM32F7)
HW_LAYER_EMS += $(PROJECT_DIR)/hw_layer/ports/stm32/stm32f7/stm32f7xx_hal_flash.c \

View File

@ -2,7 +2,7 @@
* @file max31855.h
*
* @date Sep 17, 2014
* @author Andrey Belomutskiy, (c) 2012-2017
* @author Andrey Belomutskiy, (c) 2012-2019
*/
#ifndef MAX31855_H_

View File

@ -15,6 +15,8 @@
#include "engine_configuration.h"
#include "efi_gpio.h"
#include "hardware.h"
#include "mc33816_data.h"
#include "mpu_util.h"
EXTERN_CONFIG;
@ -24,7 +26,9 @@ static SPIConfig spiCfg = { .circular = false,
.end_cb = NULL,
.ssport = NULL,
.sspad = 0,
.cr1 = SPI_CR1_MSTR |
.cr1 =
SPI_CR1_16BIT_MODE |
SPI_CR1_MSTR |
//SPI_CR1_BR_1 // 5MHz
SPI_CR1_CPHA | SPI_CR1_BR_0 | SPI_CR1_BR_1 | SPI_CR1_BR_2,
.cr2 = 0};
@ -36,12 +40,17 @@ static void showStats() {
}
static void sentByte(int param) {
static void send_16bit_SPI(short param) {
spiSelect(driver);
// we are in 16 bit mode so '1' means 16 bits word hopefully?
spiSend(driver, 1, &param);
spiUnselect(driver);
}
static void sentWord(int word) {
send_16bit_SPI(word);
}
void initMc33816() {
// default spi3mosiPin PB5
// default spi3misoPin PB4
@ -72,7 +81,19 @@ void initMc33816() {
addConsoleAction("mc33_stats", showStats);
addConsoleActionI("mc33_send", sentByte);
addConsoleActionI("mc33_send", sentWord);
int size = 105;
unsigned short * RAM_ptr = MC33816_code_RAM1;
for (int k = 0; k < size; k++) // downloads RAM
{
short data = *RAM_ptr; // retrieves data to be sent
send_16bit_SPI(data); // sends data
RAM_ptr++;
}
}

View File

@ -0,0 +1,20 @@
/*
* mc33816_data.c
*
*/
unsigned short MC33816_code_RAM1[105] =
{
0x3629, 0x0185, 0x41F9, 0xB169, 0xF64B, 0xA77C, 0x3142, 0x028C, 0xBD43, 0x1E99,
0xC958, 0xD52F, 0xB562, 0x27CA, 0xD617, 0xA63C, 0x2596, 0xE00F, 0xB8F9, 0xF657,
0x9FB7, 0x2ACF, 0x8A60, 0x24C0, 0x7914, 0x2CED, 0x71BF, 0x5B3A, 0x0604, 0x3605,
0x3BA8, 0x7362, 0x88EA, 0xF613, 0xD6DD, 0xB055, 0xD629, 0x32C2, 0x2375, 0xE08B,
0xFA18, 0xEBC5, 0xAA8F, 0x5EAA, 0x3987, 0x106C, 0xE468, 0x64A1, 0x0FB0, 0x7879,
0x9664, 0xA0D8, 0x7AE7, 0x1512, 0x829E, 0xBB5D, 0x03FC, 0x7228, 0xE94B, 0xF458,
0x1E33, 0x83B0, 0xCE2D, 0xF930, 0xF458, 0x1F33, 0x9A9C, 0x8A34, 0x31AE, 0x6853,
0x359C, 0xAF20, 0xBA3A, 0x9E1A, 0x2F68, 0x72F5, 0x0491, 0x96FF, 0x28B8, 0xE434,
0xA72A, 0xFA05, 0x7481, 0x9721, 0x1392, 0x2167, 0x4AF1, 0xC959, 0x3A6A, 0xB248,
0xAB35, 0x094F, 0xAF6F, 0x8DFA, 0x0BA7, 0x0B26, 0x978C, 0xD0E1, 0xCDC5, 0x34C6,
0x18F8, 0x3E6C, 0x4186, 0xB14B, 0xDB33
};

View File

@ -0,0 +1,13 @@
/*
* mc33816_data.h
*
* @date May 3, 2019
* @author Andrey Belomutskiy, (c) 2012-2019
*/
#ifndef HW_LAYER_MC33816_DATA_H_
#define HW_LAYER_MC33816_DATA_H_
extern unsigned short MC33816_code_RAM1[105]; // CODE RAM CH 1
#endif /* HW_LAYER_MC33816_DATA_H_ */