Hellen says fix cypress build (#1818)

* fix compilation

* fresh generated files

* more files

Co-authored-by: Andrei <andreikagit@users.noreply.github.com>
This commit is contained in:
andreika-git 2020-09-23 21:06:22 +03:00 committed by GitHub
parent d904eee955
commit 2d4d34291c
13 changed files with 92 additions and 115 deletions

View File

@ -34,7 +34,7 @@ extern SERIAL_USB_DRIVER TS_USB_DEVICE;
#endif /* TS_USB_DEVICE */
#ifdef TS_CAN_DEVICE
#include "tunerstudio_can.h"
#include "serial_can.h"
#endif /* TS_CAN_DEVICE */

View File

@ -9,9 +9,9 @@
#pragma once
#include "global.h"
#if HAL_USE_SERIAL_USB
#if EFI_USB_SERIAL
#include "usbconsole.h"
#endif // HAL_USE_SERIAL_USB
#endif // EFI_USB_SERIAL
#if EFI_PROD_CODE
#include "pin_repository.h"

View File

@ -0,0 +1,8 @@
//
// was generated automatically by rusEfi tool ConfigDefinition.jar based on hellen_cypress_gen_config.bat integration/rusefi_config.txt
//
#define SIGNATURE_BOARD hellen_cypress
#define SIGNATURE_DATE 2020.09.21
#define SIGNATURE_HASH 2762854905
#define TS_SIGNATURE "rusEFI 2020.09.21.hellen_cypress.2762854905"

View File

@ -20,4 +20,8 @@ cd config/boards/kinetis/config
bash gen_config.sh
[ $? -eq 0 ] || { echo "ERROR generating board kinetis kin"; exit 1; }
#cd config/boards/hellen/cypress/config
#bash gen_config.sh
#[ $? -eq 0 ] || { echo "ERROR generating board hellen_cypress hellen_cypress"; exit 1; }
exit 0

View File

@ -1,12 +1,13 @@
/**
* @file backup_ram.cpp
* @brief NVRAM emulation using Internal Flash (flash_int driver)
*
* @date May 22, 2020
*/
#include "global.h"
#include "backup_ram.h"
#include "flash.h"
#include "flash_int.h"
#define BACKUP_NOT_INITIALIZED 0xFFFF
#define BACKUP_SAVED 0x5555
@ -23,7 +24,7 @@ static void backupInit(void) {
static_assert(backupSize <= BACKUP_FLASH_SIZE, "Backup flash overflow");
// first, load the whole buffer into the memory
flashRead((flashaddr_t)BACKUP_FLASH_ADDR, (char *)backupRam, backupSize);
intFlashRead((flashaddr_t)BACKUP_FLASH_ADDR, (char *)backupRam, backupSize);
// check if we have a reliable properly saved data
if (backupRam[backupStateOffset] != BACKUP_SAVED) {
// zero is the default value
@ -33,7 +34,7 @@ static void backupInit(void) {
// we cannot trust the saved data anymore, until it's saved in backupRamFlush()
// so we mark is as 'pending'
backupRam[backupStateOffset] = BACKUP_PENDING;
flashWrite(BACKUP_FLASH_ADDR + backupStateOffset, (char *)backupRam, sizeof(backupRam[backupStateOffset]));
intFlashWrite(BACKUP_FLASH_ADDR + backupStateOffset, (char *)backupRam, sizeof(backupRam[backupStateOffset]));
wasLoaded = true;
}
@ -64,11 +65,11 @@ void backupRamFlush(void) {
syssts_t sts = chSysGetStatusAndLockX();
// rewrite the whole sector
flashErase((flashaddr_t)BACKUP_FLASH_ADDR, BACKUP_FLASH_SIZE);
intFlashErase((flashaddr_t)BACKUP_FLASH_ADDR, BACKUP_FLASH_SIZE);
// mark the data as valid & saved
backupRam[backupStateOffset] = BACKUP_SAVED;
// save the data to the flash
flashWrite((flashaddr_t)BACKUP_FLASH_ADDR, (char *)backupRam, backupSize);
intFlashWrite((flashaddr_t)BACKUP_FLASH_ADDR, (char *)backupRam, backupSize);
// Leaving the critical zone
chSysRestoreStatusX(sts);

View File

@ -9,7 +9,7 @@
#if EFI_INTERNAL_FLASH
#include "flash.h"
#include "flash_int.h"
#include <string.h>
@ -48,7 +48,7 @@ static __attribute__((optimize("O0"))) int flashSectorEraseAtAddress(volatile u
return MFlash_SectorErase((uint16_t*)sectorStart) != Ok ? FLASH_RETURN_BAD_FLASH : FLASH_RETURN_SUCCESS;
}
int __attribute__((optimize("O0"))) flashErase(flashaddr_t address, size_t size) {
int __attribute__((optimize("O0"))) intFlashErase(flashaddr_t address, size_t size) {
// todo: this is a temporary hack
// todo: why the code below doesn't work with -O2?!
if (flashSectorEraseAtAddress(address) != FLASH_RETURN_SUCCESS) {
@ -80,13 +80,13 @@ int __attribute__((optimize("O0"))) flashErase(flashaddr_t address, size_t size
return FLASH_RETURN_SUCCESS;
}
int flashWrite(flashaddr_t address, const char* buffer, size_t size) {
int intFlashWrite(flashaddr_t address, const char* buffer, size_t size) {
uint32_t sizeInWords = alignToWord(size) >> 1;
return MFlash_WriteData16Bit((uint16_t*)address, (uint16_t*)buffer, sizeInWords) == Ok ? FLASH_RETURN_SUCCESS : FLASH_RETURN_BAD_FLASH;
//return MFlash_WriteData16Bit_Fm0Type3CrSecureArea((uint16_t*)address, (uint16_t*)buffer, sizeInWords) == Ok ? 0 : -1;
}
bool flashIsErased(flashaddr_t address, size_t size) {
bool intFlashIsErased(flashaddr_t address, size_t size) {
/* Check for default set bits in the flash memory
* For efficiency, compare flashdata_t values as much as possible,
* then, fallback to byte per byte comparison. */
@ -106,7 +106,7 @@ bool flashIsErased(flashaddr_t address, size_t size) {
return TRUE;
}
bool flashCompare(flashaddr_t address, const char* buffer, size_t size) {
bool intFlashCompare(flashaddr_t address, const char* buffer, size_t size) {
/* For efficiency, compare flashdata_t values as much as possible,
* then, fallback to byte per byte comparison. */
while (size >= sizeof(flashdata_t)) {
@ -127,7 +127,7 @@ bool flashCompare(flashaddr_t address, const char* buffer, size_t size) {
return TRUE;
}
int flashRead(flashaddr_t address, char* buffer, size_t size) {
int intFlashRead(flashaddr_t address, char* buffer, size_t size) {
memcpy(buffer, (char*) address, size);
return FLASH_RETURN_SUCCESS;
}

View File

@ -5,7 +5,7 @@ endif
HW_LAYER_EGT = $(PROJECT_DIR)/hw_layer/ports/cypress/serial_over_usb/usbconfig.c \
$(PROJECT_DIR)/hw_layer/ports/cypress/serial_over_usb/usbconsole.c
HW_LAYER_EMS += $(PROJECT_DIR)/hw_layer/ports/cypress/flash.c
HW_LAYER_EMS += $(PROJECT_DIR)/hw_layer/ports/cypress/flash_int.c
HW_LAYER_EMS_CPP += $(PROJECT_DIR)/hw_layer/ports/cypress/mpu_util.cpp \
$(PROJECT_DIR)/hw_layer/ports/cypress/cypress_pins.cpp \

View File

@ -11,7 +11,7 @@
#if EFI_PROD_CODE
#include "mpu_util.h"
#include "flash.h"
#include "flash_int.h"
#include "engine.h"
#include "pin_repository.h"
#include "os_util.h"
@ -249,5 +249,13 @@ size_t flashSectorSize(flashsector_t sector) {
return 0;
}
uintptr_t getFlashAddrFirstCopy() {
return FLASH_ADDR;
}
uintptr_t getFlashAddrSecondCopy() {
return FLASH_ADDR_SECOND_COPY;
}
#endif /* EFI_PROD_CODE */

View File

@ -1,92 +0,0 @@
/**
* @file mpu_util.h
*
* @date Jul 27, 2014
* @author Andrey Belomutskiy, (c) 2012-2020
* @author andreika <prometheus.pcb@gmail.com>
*/
#ifndef MPU_UTIL_H_
#define MPU_UTIL_H_
// we are lucky - all CAN pins use the same AF
#define EFI_CAN_RX_AF 9
#define EFI_CAN_TX_AF 9
// burnout or 'Burn Out'
typedef enum {
BOR_Level_None = 0,
BOR_Level_1 = 1,
BOR_Level_2 = 2,
BOR_Level_3 = 3
} BOR_Level_t;
typedef enum {
BOR_Result_Ok = 0x00,
BOR_Result_Error
} BOR_Result_t;
BOR_Level_t BOR_Get(void);
BOR_Result_t BOR_Set(BOR_Level_t BORValue);
#ifndef ADC_TwoSamplingDelay_5Cycles
#define ADC_TwoSamplingDelay_5Cycles ((uint32_t)0x00000000)
#endif
#ifndef ADC_TwoSamplingDelay_20Cycles
#define ADC_TwoSamplingDelay_20Cycles ((uint32_t)0x00000F00)
#endif
#ifndef ADC_CR2_SWSTART
#define ADC_CR2_SWSTART ((uint32_t)0x40000000)
#endif
#define SPI_CR1_8BIT_MODE 0
#define SPI_CR2_8BIT_MODE 0
#define SPI_CR1_16BIT_MODE SPI_CR1_DFF
#define SPI_CR2_16BIT_MODE 0
// TODO
#define SPI_CR1_24BIT_MODE 0
#define SPI_CR2_24BIT_MODE 0
void baseMCUInit(void);
void turnOnSpi(spi_device_e device);
void jump_to_bootloader();
#ifdef __cplusplus
extern "C"
{
#endif /* __cplusplus */
// these need to be declared C style for the linker magic to work
void DebugMonitorVector(void);
void UsageFaultVector(void);
void BusFaultVector(void);
void HardFaultVector(void);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#if HAL_USE_SPI
void initSpiModule(SPIDriver *driver, brain_pin_e sck, brain_pin_e miso,
brain_pin_e mosi,
int sckMode,
int mosiMode,
int misoMode);
/**
* @see getSpiDevice
*/
void initSpiCs(SPIConfig *spiConfig, brain_pin_e csPin);
#endif /* HAL_USE_SPI */
bool isValidCanTxPin(brain_pin_e pin);
bool isValidCanRxPin(brain_pin_e pin);
#if HAL_USE_CAN
CANDriver * detectCanDevice(brain_pin_e pinRx, brain_pin_e pinTx);
#endif /* HAL_USE_CAN */
#endif /* MPU_UTIL_H_ */

View File

@ -0,0 +1,42 @@
/**
* @file port_mpu_util.h
*
* @date Jul 27, 2014
* @author Andrey Belomutskiy, (c) 2012-2020
* @author andreika <prometheus.pcb@gmail.com>
*/
#pragma once
typedef enum {
BOR_Level_None = 0,
BOR_Level_1 = 1,
BOR_Level_2 = 2,
BOR_Level_3 = 3
} BOR_Level_t;
// we are lucky - all CAN pins use the same AF
#define EFI_CAN_RX_AF 9
#define EFI_CAN_TX_AF 9
#ifndef ADC_TwoSamplingDelay_5Cycles
#define ADC_TwoSamplingDelay_5Cycles ((uint32_t)0x00000000)
#endif
#ifndef ADC_TwoSamplingDelay_20Cycles
#define ADC_TwoSamplingDelay_20Cycles ((uint32_t)0x00000F00)
#endif
#ifndef ADC_CR2_SWSTART
#define ADC_CR2_SWSTART ((uint32_t)0x40000000)
#endif
#define SPI_CR1_8BIT_MODE 0
#define SPI_CR2_8BIT_MODE 0
#define SPI_CR1_16BIT_MODE SPI_CR1_DFF
#define SPI_CR2_16BIT_MODE 0
// TODO
#define SPI_CR1_24BIT_MODE 0
#define SPI_CR2_24BIT_MODE 0

View File

@ -166,9 +166,9 @@ const uint8_t au8ReportDescriptor2[1]; // Not used
const stc_usbdevice_stringdescriptor_t pstcStringDescriptors[] =
{
{"Spansion International Inc.",NULL}, //Manufacturer String
{"rusEFI ECU Comm Port",NULL}, //Product String
{"1.0",NULL}, //Serial Number String
{(uint8_t*)"Spansion International Inc.",NULL}, //Manufacturer String
{(uint8_t*)"rusEFI ECU Comm Port",NULL}, //Product String
{(uint8_t*)"1.0",NULL}, //Serial Number String
};

View File

@ -12,7 +12,13 @@
#include "drivers/gpio/tle6240.h"
#include "drivers/gpio/mc33972.h"
#include "drivers/gpio/tle8888.h"
#define BOARD_EXT_PINREPOPINS (BOARD_TLE6240_COUNT * TLE6240_OUTPUTS + BOARD_MC33972_COUNT * MC33972_INPUTS + BOARD_TLE8888_COUNT * TLE8888_OUTPUTS)
#include "drivers/gpio/drv8860.h"
#define BOARD_EXT_PINREPOPINS (\
BOARD_TLE6240_COUNT * TLE6240_OUTPUTS + \
BOARD_MC33972_COUNT * MC33972_INPUTS + \
BOARD_TLE8888_COUNT * TLE8888_OUTPUTS + \
BOARD_DRV8860_COUNT * DRV8860_OUTPUTS)
#else /* EFI_PROD_CODE */
#define BOARD_EXT_PINREPOPINS 0

View File

@ -388,15 +388,15 @@ void triggerAdcCallback(adcsample_t value) {
}
else {
//!!!!!!!!!!
toggleLed(2, 0);
//toggleLed(2, 0);
return; // both are positive/negative/zero: not interested!
}
//!!!!!!!!!!
toggleLed(2, -1);
//toggleLed(2, -1);
//!!!!!!!!!!
toggleLed(3, 0);
//toggleLed(3, 0);
if (isSignalWeak) {
if (minDeltaThresholdCntPos >= DELTA_THRESHOLD_CNT_LOW && minDeltaThresholdCntNeg >= DELTA_THRESHOLD_CNT_LOW) {