From db2720dfa80f67c0b0e11eb7f25ca4503bf3c633 Mon Sep 17 00:00:00 2001 From: rusefi Date: Thu, 17 Aug 2017 09:09:30 -0400 Subject: [PATCH] #473 --- firmware/hw_layer/mems.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/firmware/hw_layer/mems.cpp b/firmware/hw_layer/mems.cpp index e1c86ced57..9c4d9e5a2b 100644 --- a/firmware/hw_layer/mems.cpp +++ b/firmware/hw_layer/mems.cpp @@ -2,6 +2,7 @@ * @file mems.cpp * * stm32f4discovery has MEMS LIS302DL + * www.st.com/resource/en/datasheet/lis302dl.pdf * * SPI1 * LIS302DL_SPI_SCK PA5 @@ -22,6 +23,11 @@ EXTERN_ENGINE; void initMemsPins(DECLARE_ENGINE_PARAMETER_SIGNATURE) { engineConfiguration->LIS302DLCsPin = GPIOE_3; boardConfiguration->is_enabled_spi_1 = true; + + // stm32f4discovery defaults + boardConfiguration->spi1mosiPin = GPIOA_7; + boardConfiguration->spi1misoPin = GPIOA_6; + boardConfiguration->spi1sckPin = GPIOA_5; } #if EFI_MEMS || defined(__DOXYGEN__) @@ -42,8 +48,8 @@ void initMems(DECLARE_ENGINE_PARAMETER_SIGNATURE) { /* LIS302DL initialization.*/ - lis302dlWriteRegister(spip, LIS302DL_CTRL_REG1, 0x43); - lis302dlWriteRegister(spip, LIS302DL_CTRL_REG2, 0x00); + lis302dlWriteRegister(spip, LIS302DL_CTRL_REG1, 0x47); // enable device, enable XYZ + lis302dlWriteRegister(spip, LIS302DL_CTRL_REG2, 0x00); // 4 wire mode lis302dlWriteRegister(spip, LIS302DL_CTRL_REG3, 0x00); int8_t x = (int8_t)lis302dlReadRegister(spip, LIS302DL_OUTX);