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 217 of file accelerometer.cpp.

217 {
218#if HAL_USE_SPI
219 static SPIDriver *bus;
220 msg_t ret = MSG_RESET;
221
223 return; // not used
224
226 if (bus == nullptr) {
227 // error already reported
228 return;
229 }
230
231 /* so far only Hellen boards share SPI device for SD card and accelerometer
232 * thus need to make sure CS pin is in a well known proper state */
235 }
238
239 /* Try to detect any of enabled accels */
240 /* Hope all device drivers know how to detect correct chip */
241#if (EFI_ONBOARD_MEMS_LIS2DW12 == TRUE)
242 if (ret != MSG_OK) {
243 lis2dw12cfg.spip = bus;
244
245 /* LIS2DW12 Object Initialization.*/
246 lis2dw12ObjectInit(&LIS2DW12);
247
248 /* Activates the LIS2DW12 driver.*/
249 ret = lis2dw12Start(&LIS2DW12, &lis2dw12cfg);
250 if (ret == MSG_OK) {
252 }
253 }
254#endif //EFI_ONBOARD_MEMS_LIS2DW12 == TRUE
255#if (EFI_ONBOARD_MEMS_LIS2DH12 == TRUE)
256 if (ret != MSG_OK) {
257 lis2dh12cfg.spip = bus;
258
259 /* LIS2DH12 Object Initialization.*/
260 lsm303agrObjectInit(&LIS2DH12);
261
262 /* Activates the LIS2DH12 driver.*/
263 ret = lsm303agrStart(&LIS2DH12, &lis2dh12cfg);
264 if (ret == MSG_OK) {
266 }
267 }
268#endif //EFI_ONBOARD_MEMS_LIS2DH12 == TRUE
269#if (EFI_ONBOARD_MEMS_LIS302DL == TRUE)
270 if (ret != MSG_OK) {
271 lis302dlcfg.spip = bus;
272
273 /* LIS302DL Object Initialization.*/
274 lis302dlObjectInit(&LIS302DL);
275
276 /* Activates the LIS302DL driver.*/
277 ret = lis302dlStart(&LIS302DL, &lis302dlcfg);
278 if (ret == MSG_OK) {
280 }
281 }
282#endif //EFI_ONBOARD_MEMS_LIS302DL == TRUE
283#if (EFI_ONBOARD_MEMS_LIS3DSH == TRUE)
284 if (ret != MSG_OK) {
285 lis3dshcfg.spip = bus;
286
287 /* LIS3DSH Object Initialization.*/
288 lis3dshObjectInit(&LIS3DSH);
289
290 /* Activates the LIS3DSH driver.*/
291 ret = lis3dshStart(&LIS3DSH, &lis3dshcfg);
292 if (ret == MSG_OK) {
294 }
295 }
296#endif //EFI_ONBOARD_MEMS_LIS3DSH == TRUE
297
298 if (ret == MSG_OK) {
299 /* 50 Hz */
300 instance.setPeriod(20 /*ms*/);
301 instance.start();
302 efiPrintf("accelerometer init OK");
303 } else {
304 efiPrintf("accelerometer init failed %d", (int)ret);
305 }
306#endif /* HAL_USE_SPI */
307}
@ 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.