Add more portability to smart_gpio & SPI (#754)

This commit is contained in:
andreika-git 2019-04-14 20:35:30 +03:00 committed by rusefi
parent d4413a79b9
commit 4e7715fab2
5 changed files with 18 additions and 48 deletions

View File

@ -28,6 +28,7 @@ EXTERN_CONFIG;
#include "gpio/tle8888.h"
#include "pin_repository.h"
#include "rfiutil.h"
#include "mpu_util.h"
#if EFI_TUNER_STUDIO
#include "tunerstudio.h"
@ -537,7 +538,6 @@ static struct tle8888_config tle8888_cfg = {
.end_cb = NULL,
.ssport = GPIOF,
.sspad = 0U,
#if defined(STM_F4_FAMILY)
.cr1 =
SPI_CR1_16BIT_MODE |
SPI_CR1_SSM |
@ -548,22 +548,6 @@ static struct tle8888_config tle8888_cfg = {
SPI_CR1_CPHA |
0,
.cr2 = SPI_CR2_16BIT_MODE
#elif defined(STM_F7_FAMILY)
.cr1 =
SPI_CR1_16BIT_MODE |
SPI_CR1_SSM |
SPI_CR1_SSI |
SPI_CR1_LSBFIRST |
SPI_CR1_MSTR |
((3 << SPI_CR1_BR_Pos) & SPI_CR1_BR) |
SPI_CR1_CPHA |
0,
.cr2 = SPI_CR2_16BIT_MODE
#else
unexpected platform
#endif
},
.direct_io = {
[0] = {.port = NULL, .pad = 0, .output = 9},

View File

@ -65,6 +65,13 @@ BOR_Result_t BOR_Set(BOR_Level_t BORValue);
#define ADC_CR2_SWSTART ((uint32_t)0x40000000)
#endif
#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 baseHardwareInit(void);
void turnOnSpi(spi_device_e device);

View File

@ -65,6 +65,14 @@ BOR_Result_t BOR_Set(BOR_Level_t BORValue);
#define ADC_CR2_SWSTART ((uint32_t)0x40000000)
#endif
#define SPI_CR1_16BIT_MODE 0
#define SPI_CR2_16BIT_MODE SPI_CR2_DS_3 | SPI_CR2_DS_2 | SPI_CR2_DS_1 | SPI_CR2_DS_0
#define SPI_CR1_24BIT_MODE 0
/* 3 x 8-bit transfer */
#define SPI_CR2_24BIT_MODE SPI_CR2_DS_2 | SPI_CR2_DS_1 | SPI_CR2_DS_0
void baseHardwareInit(void);
void turnOnSpi(spi_device_e device);

View File

@ -12,6 +12,7 @@
#include "efi_gpio.h"
#include "engine_configuration.h"
#include "hardware.h"
#include "mpu_util.h"
#include "gpio_ext.h"
#include "drivers/gpio/tle6240.h"
#include "drivers/gpio/mc33972.h"
@ -28,6 +29,7 @@ struct tle6240_config tle6240 = {
.ssport = GPIOF,
.sspad = 0U,
.cr1 =
SPI_CR1_16BIT_MODE |
SPI_CR1_SSM |
SPI_CR1_SSI |
/* SPI_CR1_LSBFIRST | */

View File

@ -15,35 +15,4 @@
void initSmartGpio(void);
#if (defined(STM32F405xx) || defined(STM32F407xx) || defined (STM32F469xx))
#define STM_F4_FAMILY
#elif (defined(STM32F765xx) || defined(STM32F767xx) || defined(STM32F746xx))
#define STM_F7_FAMILY
#else
unexpected platform
#endif
#if (BOARD_EXT_GPIOCHIPS > 0)
#if defined(STM_F4_FAMILY)
#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
#elif defined(STM_F7_FAMILY)
#define SPI_CR1_16BIT_MODE 0
#define SPI_CR2_16BIT_MODE SPI_CR2_DS_3 | SPI_CR2_DS_2 | SPI_CR2_DS_1 | SPI_CR2_DS_0
#define SPI_CR1_24BIT_MODE 0
/* 3 x 8-bit transfer */
#define SPI_CR2_24BIT_MODE SPI_CR2_DS_2 | SPI_CR2_DS_1 | SPI_CR2_DS_0
#else
unexpected platform
#endif
#endif /* (BOARD_EXT_GPIOCHIPS > 0) */
#endif /* HW_LAYER_SMART_GPIO_H_ */