Mercurial > public > ostc4
comparison Small_CPU/Src/compass.c @ 555:573a2bc796c8
Added HW_Info to Discovery <=> RTE data exchange:
The information if an external ADC is supported and the type of the compass is forwarded to the Firmware software. This is especially needed to enable the menu structure to support calibration of external sensors
author | Ideenmodellierer |
---|---|
date | Thu, 12 Nov 2020 19:48:28 +0100 |
parents | d9dbfa496f7e |
children | 84a4e1200726 |
comparison
equal
deleted
inserted
replaced
554:3328189786e7 | 555:573a2bc796c8 |
---|---|
33 #include "compass.h" | 33 #include "compass.h" |
34 #include "compass_LSM303D.h" | 34 #include "compass_LSM303D.h" |
35 | 35 |
36 #include "i2c.h" | 36 #include "i2c.h" |
37 #include "spi.h" | 37 #include "spi.h" |
38 #include "scheduler.h" | |
38 #include "RTE_FlashAccess.h" // to store compass_calib_data | 39 #include "RTE_FlashAccess.h" // to store compass_calib_data |
39 | 40 |
40 #include "stm32f4xx_hal.h" | 41 #include "stm32f4xx_hal.h" |
41 | 42 |
42 extern uint32_t time_elapsed_ms(uint32_t ticksstart,uint32_t ticksnow); | 43 extern uint32_t time_elapsed_ms(uint32_t ticksstart,uint32_t ticksnow); |
43 | 44 extern SGlobal global; |
44 /// split byte to bits | |
45 typedef struct{ | |
46 uint8_t bit0:1; ///< split byte to bits | |
47 uint8_t bit1:1; ///< split byte to bits | |
48 uint8_t bit2:1; ///< split byte to bits | |
49 uint8_t bit3:1; ///< split byte to bits | |
50 uint8_t bit4:1; ///< split byte to bits | |
51 uint8_t bit5:1; ///< split byte to bits | |
52 uint8_t bit6:1; ///< split byte to bits | |
53 uint8_t bit7:1; ///< split byte to bits | |
54 } ubit8_t; | |
55 | |
56 | |
57 /// split byte to bits | |
58 typedef union{ | |
59 ubit8_t ub; ///< split byte to bits | |
60 uint8_t uw; ///< split byte to bits | |
61 } bit8_Type; | |
62 | |
63 | 45 |
64 /// split word to 2 bytes | 46 /// split word to 2 bytes |
65 typedef struct{ | 47 typedef struct{ |
66 uint8_t low; ///< split word to 2 bytes | 48 uint8_t low; ///< split word to 2 bytes |
67 uint8_t hi; ///< split word to 2 bytes | 49 uint8_t hi; ///< split word to 2 bytes |
307 if(hardwareCompass == compass_generation3) //LSM303AGR) | 289 if(hardwareCompass == compass_generation3) //LSM303AGR) |
308 compass_init_LSM303AGR(fast, gain); | 290 compass_init_LSM303AGR(fast, gain); |
309 if(hardwareCompass == compass_generation1) //HMC5883L) | 291 if(hardwareCompass == compass_generation1) //HMC5883L) |
310 compass_init_HMC5883L(fast, gain); | 292 compass_init_HMC5883L(fast, gain); |
311 | 293 |
294 if(global.deviceDataSendToMaster.hw_Info.compass == 0) | |
295 { | |
296 global.deviceDataSendToMaster.hw_Info.compass = hardwareCompass; | |
297 } | |
312 tfull32 dataBlock[4]; | 298 tfull32 dataBlock[4]; |
313 if(BFA_readLastDataBlock((uint32_t *)dataBlock) == BFA_OK) | 299 if(BFA_readLastDataBlock((uint32_t *)dataBlock) == BFA_OK) |
314 { | 300 { |
315 compass_CX_f = dataBlock[0].Word16.low16; | 301 compass_CX_f = dataBlock[0].Word16.low16; |
316 compass_CY_f = dataBlock[0].Word16.hi16; | 302 compass_CY_f = dataBlock[0].Word16.hi16; |