rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
Functions
accelerometer.h File Reference

Functions

void initAccelerometer ()
 

Function Documentation

◆ initAccelerometer()

void initAccelerometer ( )

Definition at line 222 of file accelerometer.cpp.

222 {
223#if HAL_USE_SPI
224 static SPIDriver *bus;
225 msg_t ret = MSG_RESET;
226
228 return; // not used
229
231 if (bus == nullptr) {
232 // error already reported
233 return;
234 }
235
236 /* so far only Hellen boards share SPI device for SD card and accelerometer
237 * thus need to make sure CS pin is in a well known proper state */
240 }
243
244 /* Try to detect any of enabled accels */
245 /* Hope all device drivers know how to detect correct chip */
246#if (EFI_ONBOARD_MEMS_LIS2DW12 == TRUE)
247 if (ret != MSG_OK) {
248 lis2dw12cfg.spip = bus;
249
250 /* LIS2DW12 Object Initialization.*/
251 lis2dw12ObjectInit(&LIS2DW12);
252
253 /* Activates the LIS2DW12 driver.*/
254 ret = lis2dw12Start(&LIS2DW12, &lis2dw12cfg);
255 if (ret == MSG_OK) {
257 }
258 }
259#endif //EFI_ONBOARD_MEMS_LIS2DW12 == TRUE
260#if (EFI_ONBOARD_MEMS_LIS2DH12 == TRUE)
261 if (ret != MSG_OK) {
262 lis2dh12cfg.spip = bus;
263
264 /* LIS2DH12 Object Initialization.*/
265 lsm303agrObjectInit(&LIS2DH12);
266
267 /* Activates the LIS2DH12 driver.*/
268 ret = lsm303agrStart(&LIS2DH12, &lis2dh12cfg);
269 if (ret == MSG_OK) {
271 }
272 }
273#endif //EFI_ONBOARD_MEMS_LIS2DH12 == TRUE
274#if (EFI_ONBOARD_MEMS_LIS302DL == TRUE)
275 if (ret != MSG_OK) {
276 lis302dlcfg.spip = bus;
277
278 /* LIS302DL Object Initialization.*/
279 lis302dlObjectInit(&LIS302DL);
280
281 /* Activates the LIS302DL driver.*/
282 ret = lis302dlStart(&LIS302DL, &lis302dlcfg);
283 if (ret == MSG_OK) {
285 }
286 }
287#endif //EFI_ONBOARD_MEMS_LIS302DL == TRUE
288#if (EFI_ONBOARD_MEMS_LIS3DSH == TRUE)
289 if (ret != MSG_OK) {
290 lis3dshcfg.spip = bus;
291
292 /* LIS3DSH Object Initialization.*/
293 lis3dshObjectInit(&LIS3DSH);
294
295 /* Activates the LIS3DSH driver.*/
296 ret = lis3dshStart(&LIS3DSH, &lis3dshcfg);
297 if (ret == MSG_OK) {
299 }
300 }
301#endif //EFI_ONBOARD_MEMS_LIS3DSH == TRUE
302
303 if (ret == MSG_OK) {
304 /* 50 Hz */
305 instance.setPeriod(20 /*ms*/);
306 instance.start();
307 efiPrintf("accelerometer init OK");
308 } else {
309 efiPrintf("accelerometer init failed %d", (int)ret);
310 }
311#endif /* HAL_USE_SPI */
312}
@ ACCEL_LIS2DH12
@ ACCEL_LIS3DSH
@ ACCEL_LIS302DL
@ ACCEL_LIS2DW12
static LIS2DW12Driver LIS2DW12
static LIS3DSHConfig lis3dshcfg
OutputPin accelerometerChipSelect
static LIS2DW12Config lis2dw12cfg
static AccelController instance
static LIS3DSHDriver LIS3DSH
static LIS302DLDriver LIS302DL
static SPIConfig accelerometerSpiCfg
static LSM303AGRDriver LIS2DH12
static AccelType_t AccelType
static LIS302DLConfig lis302dlcfg
static LSM303AGRConfig lis2dh12cfg
void initPin(const char *msg, brain_pin_e brainPin, pin_output_mode_e outputMode, bool forceInitWithFatalError=false)
Definition efi_gpio.cpp:711
bool isInitialized() const
Definition efi_gpio.cpp:559
ioportid_t getHwPort(const char *msg, brain_pin_e brainPin)
ioportmask_t getHwPin(const char *msg, brain_pin_e brainPin)
static constexpr engine_configuration_s * engineConfiguration
SPIDriver * getSpiDevice(spi_device_e spiDevice)
Definition hardware.cpp:149
bool isBrainPinValid(brain_pin_e brainPin)

Referenced by initHardware().

Here is the call graph for this function:
Here is the caller graph for this function:

Go to the source code of this file.