Rev 243 | Rev 254 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 243 | Rev 253 | ||
---|---|---|---|
Line 55... | Line 55... | ||
55 | // + POSSIBILITY OF SUCH DAMAGE. |
55 | // + POSSIBILITY OF SUCH DAMAGE. |
56 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
56 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
57 | #include "91x_lib.h" |
57 | #include "91x_lib.h" |
58 | #include "compass.h" |
58 | #include "compass.h" |
59 | #include "mk3mag.h" |
59 | #include "mk3mag.h" |
60 | #include "hmc5843.h" |
60 | #include "ncmag.h" |
61 | #include "uart1.h" |
61 | #include "uart1.h" |
Line 62... | Line 62... | ||
62 | 62 | ||
63 | volatile MagVector_t MagVector; |
63 | volatile s16vec_t MagVector; |
Line 64... | Line 64... | ||
64 | volatile s16 CompassHeading; |
64 | volatile s16 CompassHeading; |
65 | 65 | ||
66 | #define COMPASS_NONE 0 |
66 | #define COMPASS_NONE 0 |
67 | #define COMPASS_MK3MAG 1 |
- | |
68 | #define COMPASS_HMC5843 2 |
67 | #define COMPASS_MK3MAG 1 |
Line 69... | Line 68... | ||
69 | 68 | #define COMPASS_NCMAG 2 |
|
70 | u8 CompassDevice = COMPASS_NONE; |
69 | u8 CompassDevice = COMPASS_NONE; |
71 | 70 | ||
72 | void Compass_Init(void) |
71 | void Compass_Init(void) |
73 | { |
72 | { |
74 | UART1_PutString("\r\n Looking for compass"); |
73 | UART1_PutString("\r\n Looking for compass"); |
75 | if( MK3MAG_Init() ) CompassDevice = COMPASS_MK3MAG; |
- | |
76 | else if( HMC5843_Init() ) CompassDevice = COMPASS_HMC5843; |
- | |
77 | else CompassDevice = COMPASS_NONE; |
- | |
78 | if(CompassDevice == COMPASS_NONE) |
- | |
79 | { |
74 | if( MK3MAG_Init() ) CompassDevice = COMPASS_MK3MAG; |
Line 80... | Line 75... | ||
80 | UART1_PutString(" not found!"); |
75 | else if( NCMAG_Init() ) CompassDevice = COMPASS_NCMAG; |
81 | } |
76 | else CompassDevice = COMPASS_NONE; |
82 | } |
77 | } |
83 | 78 | ||
84 | 79 | ||
85 | void Compass_UpdateHeading(void) |
80 | void Compass_UpdateHeading(void) |
86 | { |
81 | { |
87 | switch(CompassDevice) |
82 | switch(CompassDevice) |
88 | { |
83 | { |
89 | case COMPASS_MK3MAG: |
84 | case COMPASS_MK3MAG: |
90 | MK3MAG_UpdateCompass(); |
85 | MK3MAG_UpdateCompass(); |
91 | break; |
86 | break; |
92 | case COMPASS_HMC5843: |
87 | case COMPASS_NCMAG: |
93 | HMC5843_UpdateCompass(); |
88 | NCMAG_UpdateCompass(); |
Line 102... | Line 97... | ||
102 | switch(CompassDevice) |
97 | switch(CompassDevice) |
103 | { |
98 | { |
104 | case COMPASS_MK3MAG: |
99 | case COMPASS_MK3MAG: |
105 | MK3MAG_SendCommand(MK3MAG_CMD_READ_MAGVECT); |
100 | MK3MAG_SendCommand(MK3MAG_CMD_READ_MAGVECT); |
106 | break; |
101 | break; |
107 | case COMPASS_HMC5843: |
102 | case COMPASS_NCMAG: |
108 | HMC5843_UpdateCompass(); |
103 | NCMAG_UpdateCompass(); |
109 | default: |
104 | default: |
110 | break; |
105 | break; |
111 | } |
106 | } |
112 | } |
107 | } |