enable H7 spi (#2391)
* enable features * move MMC SPI config to port * correct word length * related cleanup * doesn't need nocache * include * enable that
This commit is contained in:
parent
deb285825e
commit
392a7539be
|
@ -7,8 +7,6 @@ echo "Entering $SCRIPT_NAME"
|
||||||
|
|
||||||
export PROJECT_BOARD=nucleo_h743
|
export PROJECT_BOARD=nucleo_h743
|
||||||
export PROJECT_CPU=ARCH_STM32H7
|
export PROJECT_CPU=ARCH_STM32H7
|
||||||
export USE_LIS302=no
|
|
||||||
export USE_FATFS=no
|
|
||||||
export EXTRA_PARAMS="-DDUMMY \
|
export EXTRA_PARAMS="-DDUMMY \
|
||||||
-DEFI_INJECTOR_PIN3=GPIO_UNASSIGNED \
|
-DEFI_INJECTOR_PIN3=GPIO_UNASSIGNED \
|
||||||
-DFIRMWARE_ID=\\\"nucleoH743\\\" \
|
-DFIRMWARE_ID=\\\"nucleoH743\\\" \
|
||||||
|
|
|
@ -150,8 +150,7 @@
|
||||||
* MCP42010 digital potentiometer support. This could be useful if you are stimulating some
|
* MCP42010 digital potentiometer support. This could be useful if you are stimulating some
|
||||||
* stock ECU
|
* stock ECU
|
||||||
*/
|
*/
|
||||||
//#define EFI_POTENTIOMETER FALSE
|
#define EFI_POTENTIOMETER FALSE
|
||||||
#define EFI_POTENTIOMETER TRUE
|
|
||||||
|
|
||||||
#ifndef BOARD_TLE6240_COUNT
|
#ifndef BOARD_TLE6240_COUNT
|
||||||
#define BOARD_TLE6240_COUNT 1
|
#define BOARD_TLE6240_COUNT 1
|
||||||
|
|
|
@ -5,9 +5,6 @@
|
||||||
#undef EFI_INTERNAL_FLASH
|
#undef EFI_INTERNAL_FLASH
|
||||||
#define EFI_INTERNAL_FLASH FALSE
|
#define EFI_INTERNAL_FLASH FALSE
|
||||||
|
|
||||||
#undef EFI_FILE_LOGGING
|
|
||||||
#define EFI_FILE_LOGGING FALSE
|
|
||||||
|
|
||||||
#undef EFI_MC33816
|
#undef EFI_MC33816
|
||||||
#define EFI_MC33816 FALSE
|
#define EFI_MC33816 FALSE
|
||||||
|
|
||||||
|
|
|
@ -74,41 +74,17 @@ spi_device_e mmcSpiDevice = SPI_NONE;
|
||||||
#else
|
#else
|
||||||
USBDriver *usb_driver = &USBD1;
|
USBDriver *usb_driver = &USBD1;
|
||||||
#endif
|
#endif
|
||||||
extern const USBConfig msdusbcfg;
|
|
||||||
#endif /* HAL_USE_USB_MSD */
|
#endif /* HAL_USE_USB_MSD */
|
||||||
|
|
||||||
// TODO: this is NO_CACHE because of https://github.com/rusefi/rusefi/issues/2356
|
static THD_WORKING_AREA(mmcThreadStack, 3 * UTILITY_THREAD_STACK_SIZE); // MMC monitor thread
|
||||||
static NO_CACHE THD_WORKING_AREA(mmcThreadStack,3 * UTILITY_THREAD_STACK_SIZE); // MMC monitor thread
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MMC driver instance.
|
* MMC driver instance.
|
||||||
*/
|
*/
|
||||||
MMCDriver MMCD1;
|
MMCDriver MMCD1;
|
||||||
|
|
||||||
// SD cards are good up to 25MHz in "slow" mode, and 50MHz in "fast" mode
|
|
||||||
// 168mhz F4:
|
|
||||||
// Slow mode is 10.5 or 5.25 MHz, depending on which SPI device
|
|
||||||
// Fast mode is 42 or 21 MHz
|
|
||||||
// 216mhz F7:
|
|
||||||
// Slow mode is 13.5 or 6.75 MHz
|
|
||||||
// Fast mode is 54 or 27 MHz (technically out of spec, needs testing!)
|
|
||||||
static SPIConfig hs_spicfg = {
|
|
||||||
.circular = false,
|
|
||||||
.end_cb = NULL,
|
|
||||||
.ssport = NULL,
|
|
||||||
.sspad = 0,
|
|
||||||
.cr1 = SPI_BaudRatePrescaler_2,
|
|
||||||
.cr2 = 0};
|
|
||||||
static SPIConfig ls_spicfg = {
|
|
||||||
.circular = false,
|
|
||||||
.end_cb = NULL,
|
|
||||||
.ssport = NULL,
|
|
||||||
.sspad = 0,
|
|
||||||
.cr1 = SPI_BaudRatePrescaler_8,
|
|
||||||
.cr2 = 0};
|
|
||||||
|
|
||||||
/* MMC/SD over SPI driver configuration.*/
|
/* MMC/SD over SPI driver configuration.*/
|
||||||
static MMCConfig mmccfg = { NULL, &ls_spicfg, &hs_spicfg };
|
static MMCConfig mmccfg = { NULL, &mmc_ls_spicfg, &mmc_hs_spicfg };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fatfs MMC/SPI
|
* fatfs MMC/SPI
|
||||||
|
@ -382,8 +358,8 @@ static BaseBlockDevice* initializeMmcBlockDevice() {
|
||||||
efiAssert(OBD_PCM_Processor_Fault, mmcSpiDevice != SPI_NONE, "SD card enabled, but no SPI device configured!", nullptr);
|
efiAssert(OBD_PCM_Processor_Fault, mmcSpiDevice != SPI_NONE, "SD card enabled, but no SPI device configured!", nullptr);
|
||||||
|
|
||||||
// todo: reuse initSpiCs method?
|
// todo: reuse initSpiCs method?
|
||||||
hs_spicfg.ssport = ls_spicfg.ssport = getHwPort("mmc", CONFIG(sdCardCsPin));
|
mmc_hs_spicfg.ssport = mmc_ls_spicfg.ssport = getHwPort("mmc", CONFIG(sdCardCsPin));
|
||||||
hs_spicfg.sspad = ls_spicfg.sspad = getHwPin("mmc", CONFIG(sdCardCsPin));
|
mmc_hs_spicfg.sspad = mmc_ls_spicfg.sspad = getHwPin("mmc", CONFIG(sdCardCsPin));
|
||||||
mmccfg.spip = getSpiDevice(mmcSpiDevice);
|
mmccfg.spip = getSpiDevice(mmcSpiDevice);
|
||||||
|
|
||||||
// We think we have everything for the card, let's try to mount it!
|
// We think we have everything for the card, let's try to mount it!
|
||||||
|
|
|
@ -37,6 +37,14 @@ void initSpiCs(SPIConfig *spiConfig, brain_pin_e csPin);
|
||||||
void turnOnSpi(spi_device_e device);
|
void turnOnSpi(spi_device_e device);
|
||||||
#endif // HAL_USE_SPI
|
#endif // HAL_USE_SPI
|
||||||
|
|
||||||
|
// MMC Card
|
||||||
|
#if HAL_USE_MMC_SPI
|
||||||
|
// HS = max 50MHz SPI
|
||||||
|
extern SPIConfig mmc_hs_spicfg;
|
||||||
|
// LS = max 25MHz SPI
|
||||||
|
extern SPIConfig mmc_ls_spicfg;
|
||||||
|
#endif
|
||||||
|
|
||||||
// Hardware PWM
|
// Hardware PWM
|
||||||
struct hardware_pwm {
|
struct hardware_pwm {
|
||||||
static hardware_pwm* tryInitPin(const char* msg, brain_pin_e pin, float frequencyHz, float duty);
|
static hardware_pwm* tryInitPin(const char* msg, brain_pin_e pin, float frequencyHz, float duty);
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include "engine_ptr.h"
|
#include "engine_ptr.h"
|
||||||
#include "efi_gpio.h"
|
#include "efi_gpio.h"
|
||||||
#include "expected.h"
|
#include "expected.h"
|
||||||
|
#include "hardware.h"
|
||||||
|
|
||||||
#ifdef STM32F4XX
|
#ifdef STM32F4XX
|
||||||
#include "stm32f4xx_hal_flash.h"
|
#include "stm32f4xx_hal_flash.h"
|
||||||
|
@ -692,6 +693,58 @@ void initSpiCs(SPIConfig *spiConfig, brain_pin_e csPin) {
|
||||||
efiSetPadMode("chip select", csPin, PAL_STM32_MODE_OUTPUT);
|
efiSetPadMode("chip select", csPin, PAL_STM32_MODE_OUTPUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef STM32H7XX
|
||||||
|
// H7 SPI clock is set to 80MHz
|
||||||
|
// fast mode is 80mhz/2 = 40MHz
|
||||||
|
SPIConfig mmc_hs_spicfg = {
|
||||||
|
.circular = false,
|
||||||
|
.end_cb = NULL,
|
||||||
|
.ssport = NULL,
|
||||||
|
.sspad = 0,
|
||||||
|
.cfg1 = 7 // 8 bits per byte
|
||||||
|
| 0 /* MBR = 0, divider = 2 */,
|
||||||
|
.cfg2 = 0
|
||||||
|
};
|
||||||
|
|
||||||
|
// Slow mode is 80mhz/4 = 20MHz
|
||||||
|
SPIConfig mmc_ls_spicfg = {
|
||||||
|
.circular = false,
|
||||||
|
.end_cb = NULL,
|
||||||
|
.ssport = NULL,
|
||||||
|
.sspad = 0,
|
||||||
|
.cfg1 = 7 // 8 bits per byte
|
||||||
|
| SPI_CFG1_MBR_0 /* MBR = 001, divider = 4 */,
|
||||||
|
.cfg2 = 0
|
||||||
|
};
|
||||||
|
|
||||||
|
#else /* not STM32H7XX */
|
||||||
|
|
||||||
|
// SD cards are good up to 25MHz in "slow" mode, and 50MHz in "fast" mode
|
||||||
|
// 168mhz F4:
|
||||||
|
// Slow mode is 10.5 or 5.25 MHz, depending on which SPI device
|
||||||
|
// Fast mode is 42 or 21 MHz
|
||||||
|
// 216mhz F7:
|
||||||
|
// Slow mode is 13.5 or 6.75 MHz
|
||||||
|
// Fast mode is 54 or 27 MHz (technically out of spec, needs testing!)
|
||||||
|
SPIConfig mmc_hs_spicfg = {
|
||||||
|
.circular = false,
|
||||||
|
.end_cb = NULL,
|
||||||
|
.ssport = NULL,
|
||||||
|
.sspad = 0,
|
||||||
|
.cr1 = SPI_BaudRatePrescaler_2,
|
||||||
|
.cr2 = 0
|
||||||
|
};
|
||||||
|
|
||||||
|
SPIConfig mmc_ls_spicfg = {
|
||||||
|
.circular = false,
|
||||||
|
.end_cb = NULL,
|
||||||
|
.ssport = NULL,
|
||||||
|
.sspad = 0,
|
||||||
|
.cr1 = SPI_BaudRatePrescaler_8,
|
||||||
|
.cr2 = 0
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* HAL_USE_SPI */
|
#endif /* HAL_USE_SPI */
|
||||||
|
|
||||||
#if EFI_CAN_SUPPORT
|
#if EFI_CAN_SUPPORT
|
||||||
|
|
|
@ -114,7 +114,7 @@
|
||||||
* @brief Enables the MMC_SPI subsystem.
|
* @brief Enables the MMC_SPI subsystem.
|
||||||
*/
|
*/
|
||||||
#if !defined(HAL_USE_MMC_SPI) || defined(__DOXYGEN__)
|
#if !defined(HAL_USE_MMC_SPI) || defined(__DOXYGEN__)
|
||||||
#define HAL_USE_MMC_SPI FALSE
|
#define HAL_USE_MMC_SPI TRUE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -163,7 +163,7 @@
|
||||||
* @brief Enables the SPI subsystem.
|
* @brief Enables the SPI subsystem.
|
||||||
*/
|
*/
|
||||||
#if !defined(HAL_USE_SPI) || defined(__DOXYGEN__)
|
#if !defined(HAL_USE_SPI) || defined(__DOXYGEN__)
|
||||||
#define HAL_USE_SPI FALSE
|
#define HAL_USE_SPI TRUE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue