firmware_registers.h
Go to the documentation of this file.
1 
10 // Define the firmware revision
11 #define UM6_FIRMWARE_REVISION (('U' << 24) | ('M' << 16) | ('2' << 8) | 'B')
12 
13 // CONFIG_ARRAY_SIZE and DATA_ARRAY_SIZE specify the number of 32 bit configuration and data registers used by the firmware
14 // (Note: The term "register" is used loosely here. These "registers" are not actually registers in the same sense of a
15 // microcontroller register. They are simply index locations into arrays stored in global memory. Data and configuration
16 // parameters are stored in arrays because it allows a common communication protocol to be used to access all data and
17 // configuration. The software communicating with the sensor needs only specify the register address, and the communication
18 // software running on the sensor knows exactly where to find it - it needn't know what the data is. The software communicatin
19 // with the sensor, on the other hand, needs to know what it is asking for (naturally...)
20 // This setup makes it easy to make more data immediately available when needed - simply increase the array size, add code in
21 // the firmware that writes data to the new array location, and then make updates to the firmware definition on the PC side.
22 #define CONFIG_ARRAY_SIZE 59
23 #define DATA_ARRAY_SIZE 48
24 #define COMMAND_COUNT 10
25 
26 //
27 #define CONFIG_REG_START_ADDRESS 0
28 #define DATA_REG_START_ADDRESS 85
29 #define COMMAND_START_ADDRESS 170
30 
31 // These preprocessor definitions make it easier to access specific configuration parameters in code
32 // They specify array locations associated with each register name. Note that in the comments below, many of the values are
33 // said to be 32-bit IEEE floating point. Obviously this isn't directly the case, since the arrays are actually 32-bit unsigned
34 // integer arrays. Bit for bit, the data does correspond to the correct floating point value. Since you can't cast ints as floats,
35 // special conversion has to happen to copy the float data to and from the array.
36 // Starting with configuration register locations...
37 #define UM6_COMMUNICATION CONFIG_REG_START_ADDRESS // Stores settings in individual bits
38 #define UM6_MISC_CONFIG (CONFIG_REG_START_ADDRESS + 1) // Stores settings in individual bits
39 #define UM6_MAG_REF_X (CONFIG_REG_START_ADDRESS + 2) // Mag reference values are stored as 32-bit IEEE floating point values (these reflect data AFTER scale factors and compensation are applied)
40 #define UM6_MAG_REF_Y (CONFIG_REG_START_ADDRESS + 3)
41 #define UM6_MAG_REF_Z (CONFIG_REG_START_ADDRESS + 4)
42 #define UM6_ACCEL_REF_X (CONFIG_REG_START_ADDRESS + 5) // Accel reference values are stored as 32-bit IEEE floating point values (these reflect data AFTER scale factors and compensation are applied)
43 #define UM6_ACCEL_REF_Y (CONFIG_REG_START_ADDRESS + 6)
44 #define UM6_ACCEL_REF_Z (CONFIG_REG_START_ADDRESS + 7)
45 #define UM6_EKF_MAG_VARIANCE (CONFIG_REG_START_ADDRESS + 8) // Variances are stored as 32-bit IEEE floating point values.
46 #define UM6_EKF_ACCEL_VARIANCE (CONFIG_REG_START_ADDRESS + 9)
47 #define UM6_EKF_PROCESS_VARIANCE (CONFIG_REG_START_ADDRESS + 10)
48 #define UM6_GYRO_BIAS_XY (CONFIG_REG_START_ADDRESS + 11) // Gyro biases are stored as 16-bit signed integers. Bias correction is applied BEFORE scale factors are applied
49 #define UM6_GYRO_BIAS_Z (CONFIG_REG_START_ADDRESS + 12)
50 #define UM6_ACCEL_BIAS_XY (CONFIG_REG_START_ADDRESS + 13) // Accel biases are stored as 16-bit signed integers. Bias correction is applied BEFORE scale factors are applied
51 #define UM6_ACCEL_BIAS_Z (CONFIG_REG_START_ADDRESS + 14)
52 #define UM6_MAG_BIAS_XY (CONFIG_REG_START_ADDRESS + 15) // Mag biases are stored as 16-bit signed integers. Bias correction is applied BEFORE magnetometer adjustment
53 #define UM6_MAG_BIAS_Z (CONFIG_REG_START_ADDRESS + 16)
54 #define UM6_ACCEL_CAL_00 (CONFIG_REG_START_ADDRESS + 17) // The accelerometer alignment matrix is a 3x3 matrix with 32-bit IEEE floating point entries
55 #define UM6_ACCEL_CAL_01 (CONFIG_REG_START_ADDRESS + 18)
56 #define UM6_ACCEL_CAL_02 (CONFIG_REG_START_ADDRESS + 19)
57 #define UM6_ACCEL_CAL_10 (CONFIG_REG_START_ADDRESS + 20)
58 #define UM6_ACCEL_CAL_11 (CONFIG_REG_START_ADDRESS + 21)
59 #define UM6_ACCEL_CAL_12 (CONFIG_REG_START_ADDRESS + 22)
60 #define UM6_ACCEL_CAL_20 (CONFIG_REG_START_ADDRESS + 23)
61 #define UM6_ACCEL_CAL_21 (CONFIG_REG_START_ADDRESS + 24)
62 #define UM6_ACCEL_CAL_22 (CONFIG_REG_START_ADDRESS + 25)
63 #define UM6_GYRO_CAL_00 (CONFIG_REG_START_ADDRESS + 26) // The gyro alignment matrix is a 3x3 matrix with 32-bit IEEE floating point entries
64 #define UM6_GYRO_CAL_01 (CONFIG_REG_START_ADDRESS + 27)
65 #define UM6_GYRO_CAL_02 (CONFIG_REG_START_ADDRESS + 28)
66 #define UM6_GYRO_CAL_10 (CONFIG_REG_START_ADDRESS + 29)
67 #define UM6_GYRO_CAL_11 (CONFIG_REG_START_ADDRESS + 30)
68 #define UM6_GYRO_CAL_12 (CONFIG_REG_START_ADDRESS + 31)
69 #define UM6_GYRO_CAL_20 (CONFIG_REG_START_ADDRESS + 32)
70 #define UM6_GYRO_CAL_21 (CONFIG_REG_START_ADDRESS + 33)
71 #define UM6_GYRO_CAL_22 (CONFIG_REG_START_ADDRESS + 34)
72 #define UM6_MAG_CAL_00 (CONFIG_REG_START_ADDRESS + 35) // The magnetometer calibration matrix is a 3x3 matrix with 32-bit IEEE floating point entries
73 #define UM6_MAG_CAL_01 (CONFIG_REG_START_ADDRESS + 36)
74 #define UM6_MAG_CAL_02 (CONFIG_REG_START_ADDRESS + 37)
75 #define UM6_MAG_CAL_10 (CONFIG_REG_START_ADDRESS + 38)
76 #define UM6_MAG_CAL_11 (CONFIG_REG_START_ADDRESS + 39)
77 #define UM6_MAG_CAL_12 (CONFIG_REG_START_ADDRESS + 40)
78 #define UM6_MAG_CAL_20 (CONFIG_REG_START_ADDRESS + 41)
79 #define UM6_MAG_CAL_21 (CONFIG_REG_START_ADDRESS + 42)
80 #define UM6_MAG_CAL_22 (CONFIG_REG_START_ADDRESS + 43)
81 
82 #define UM6_GYROX_BIAS_0 (CONFIG_REG_START_ADDRESS + 44) // Terms used for gyro temperature compensation. Each item is a floating point number, to be
83 #define UM6_GYROX_BIAS_1 (CONFIG_REG_START_ADDRESS + 45) // applied to the raw data directly.
84 #define UM6_GYROX_BIAS_2 (CONFIG_REG_START_ADDRESS + 46)
85 #define UM6_GYROX_BIAS_3 (CONFIG_REG_START_ADDRESS + 47)
86 #define UM6_GYROY_BIAS_0 (CONFIG_REG_START_ADDRESS + 48)
87 #define UM6_GYROY_BIAS_1 (CONFIG_REG_START_ADDRESS + 49)
88 #define UM6_GYROY_BIAS_2 (CONFIG_REG_START_ADDRESS + 50)
89 #define UM6_GYROY_BIAS_3 (CONFIG_REG_START_ADDRESS + 51)
90 #define UM6_GYROZ_BIAS_0 (CONFIG_REG_START_ADDRESS + 52)
91 #define UM6_GYROZ_BIAS_1 (CONFIG_REG_START_ADDRESS + 53)
92 #define UM6_GYROZ_BIAS_2 (CONFIG_REG_START_ADDRESS + 54)
93 #define UM6_GYROZ_BIAS_3 (CONFIG_REG_START_ADDRESS + 55)
94 #define UM6_GPS_HOME_LAT (CONFIG_REG_START_ADDRESS + 56)
95 #define UM6_GPS_HOME_LONG (CONFIG_REG_START_ADDRESS + 57)
96 #define UM6_GPS_HOME_ALTITUDE (CONFIG_REG_START_ADDRESS + 58)
97 
98 // Now for data register locations.
99 // In the communication protocol, data registers are labeled with number ranging from 128 to 255. The value of 128 will be subtracted from these numbers
100 // to produce the actual array index labeled below
101 #define UM6_STATUS DATA_REG_START_ADDRESS // Status register defines error codes with individual bits
102 #define UM6_GYRO_RAW_XY (DATA_REG_START_ADDRESS + 1) // Raw gyro data is stored in 16-bit signed integers
103 #define UM6_GYRO_RAW_Z (DATA_REG_START_ADDRESS + 2)
104 #define UM6_ACCEL_RAW_XY (DATA_REG_START_ADDRESS + 3) // Raw accel data is stored in 16-bit signed integers
105 #define UM6_ACCEL_RAW_Z (DATA_REG_START_ADDRESS + 4)
106 #define UM6_MAG_RAW_XY (DATA_REG_START_ADDRESS + 5) // Raw mag data is stored in 16-bit signed integers
107 #define UM6_MAG_RAW_Z (DATA_REG_START_ADDRESS + 6)
108 #define UM6_GYRO_PROC_XY (DATA_REG_START_ADDRESS + 7) // Processed gyro data has scale factors applied and alignment correction performed. Data is 16-bit signed integer.
109 #define UM6_GYRO_PROC_Z (DATA_REG_START_ADDRESS + 8)
110 #define UM6_ACCEL_PROC_XY (DATA_REG_START_ADDRESS + 9) // Processed accel data has scale factors applied and alignment correction performed. Data is 16-bit signed integer.
111 #define UM6_ACCEL_PROC_Z (DATA_REG_START_ADDRESS + 10)
112 #define UM6_MAG_PROC_XY (DATA_REG_START_ADDRESS + 11) // Processed mag data has scale factors applied and alignment correction performed. Data is 16-bit signed integer.
113 #define UM6_MAG_PROC_Z (DATA_REG_START_ADDRESS + 12)
114 #define UM6_EULER_PHI_THETA (DATA_REG_START_ADDRESS + 13) // Euler angles are 32-bit IEEE floating point
115 #define UM6_EULER_PSI (DATA_REG_START_ADDRESS + 14)
116 #define UM6_QUAT_AB (DATA_REG_START_ADDRESS + 15) // Quaternions are 16-bit signed integers.
117 #define UM6_QUAT_CD (DATA_REG_START_ADDRESS + 16)
118 #define UM6_ERROR_COV_00 (DATA_REG_START_ADDRESS + 17) // Error covariance is a 4x4 matrix of 32-bit IEEE floating point values
119 #define UM6_ERROR_COV_01 (DATA_REG_START_ADDRESS + 18)
120 #define UM6_ERROR_COV_02 (DATA_REG_START_ADDRESS + 19)
121 #define UM6_ERROR_COV_03 (DATA_REG_START_ADDRESS + 20)
122 #define UM6_ERROR_COV_10 (DATA_REG_START_ADDRESS + 21)
123 #define UM6_ERROR_COV_11 (DATA_REG_START_ADDRESS + 22)
124 #define UM6_ERROR_COV_12 (DATA_REG_START_ADDRESS + 23)
125 #define UM6_ERROR_COV_13 (DATA_REG_START_ADDRESS + 24)
126 #define UM6_ERROR_COV_20 (DATA_REG_START_ADDRESS + 25)
127 #define UM6_ERROR_COV_21 (DATA_REG_START_ADDRESS + 26)
128 #define UM6_ERROR_COV_22 (DATA_REG_START_ADDRESS + 27)
129 #define UM6_ERROR_COV_23 (DATA_REG_START_ADDRESS + 28)
130 #define UM6_ERROR_COV_30 (DATA_REG_START_ADDRESS + 29)
131 #define UM6_ERROR_COV_31 (DATA_REG_START_ADDRESS + 30)
132 #define UM6_ERROR_COV_32 (DATA_REG_START_ADDRESS + 31)
133 #define UM6_ERROR_COV_33 (DATA_REG_START_ADDRESS + 32)
134 #define UM6_TEMPERATURE (DATA_REG_START_ADDRESS + 33) // Temperature measured by onboard temperature sensors
135 #define UM6_GPS_LONGITUDE (DATA_REG_START_ADDRESS + 34) // GPS longitude
136 #define UM6_GPS_LATITUDE (DATA_REG_START_ADDRESS + 35) // GPS latitude
137 #define UM6_GPS_ALTITUDE (DATA_REG_START_ADDRESS + 36) // GPS altitude
138 #define UM6_GPS_POSITION_N (DATA_REG_START_ADDRESS + 37) // GPS position (meters north of home position)
139 #define UM6_GPS_POSITION_E (DATA_REG_START_ADDRESS + 38) // GPS position (meters east of home position)
140 #define UM6_GPS_POSITION_H (DATA_REG_START_ADDRESS + 39) // GPS position (meters east of home position)
141 #define UM6_GPS_COURSE_SPEED (DATA_REG_START_ADDRESS + 40) // GPS course over ground in degrees and speed in m/s
142 #define UM6_GPS_SAT_SUMMARY (DATA_REG_START_ADDRESS + 41) // Summarizes GPS satellite data (mode, satellite count, HDOP, and VDOP)
143 #define UM6_GPS_SAT_1_2 (DATA_REG_START_ADDRESS + 42) // ID and SNR for satellites being tracked
144 #define UM6_GPS_SAT_3_4 (DATA_REG_START_ADDRESS + 43) // ID and SNR for satellites being tracked
145 #define UM6_GPS_SAT_5_6 (DATA_REG_START_ADDRESS + 44) // ID and SNR for satellites being tracked
146 #define UM6_GPS_SAT_7_8 (DATA_REG_START_ADDRESS + 45) // ID and SNR for satellites being tracked
147 #define UM6_GPS_SAT_9_10 (DATA_REG_START_ADDRESS + 46) // ID and SNR for satellites being tracked
148 #define UM6_GPS_SAT_11_12 (DATA_REG_START_ADDRESS + 47) // ID and SNR for satellites being tracked
149 
150 // Define some stuff to organize the contents of the UM6_GPS_SAT_SUMMARY register
151 #define UM6_GPS_MODE_START_BIT 30
152 #define UM6_GPS_MODE_MASK 0x03 // 2 bits
153 
154 #define UM6_GPS_SAT_COUNT_START_BIT 26
155 #define UM6_GPS_SAT_COUNT_MASK 0x0F // 4 bits
156 
157 #define UM6_GPS_HDOP_START_BIT 16
158 #define UM6_GPS_HDOP_MASK 0x03FF // 10 bits
159 
160 #define UM6_GPS_VDOP_START_BIT 6
161 #define UM6_GPS_VDOP_MASK 0x03FF // 10 bits
162 
163 // Finally, define some non-register registers... sometimes commands must be sent to the sensor - commands that don't involve the transmission of any data.
164 // Like, for example, a command to zero rate gyros. Or whatever. These commands are given "register" addresses so that they can be sent using the same
165 // communication framework used to set and read registers. The only difference is that when a command is received and no data is attached, the communication
166 // code doesn't set any registers.
167 //
168 // The communication code will do two things for every packet received:
169 // 1. Copy data to the relevant register if data was provided in the packet
170 // 2. Call a "dispatch packet" function that performs additional functions if the packet requires it.
171 // Step 2 is what handles commands and causes status packets to be returned.
172 #define UM6_GET_FW_VERSION COMMAND_START_ADDRESS // Causes the UM6 to report the firmware revision
173 #define UM6_FLASH_COMMIT (COMMAND_START_ADDRESS + 1) // Causes the UM6 to write all configuration values to FLASH
174 #define UM6_ZERO_GYROS (COMMAND_START_ADDRESS + 2) // Causes the UM6 to start a zero gyros command
175 #define UM6_RESET_EKF (COMMAND_START_ADDRESS + 3) // Causes the UM6 to reset the EKF
176 #define UM6_GET_DATA (COMMAND_START_ADDRESS + 4) // Causes the UM6 to transmit a data packet containing data from all enabled channels
177 #define UM6_SET_ACCEL_REF (COMMAND_START_ADDRESS + 5) // Causes the UM6 to set the current measured accel data to the reference vector
178 #define UM6_SET_MAG_REF (COMMAND_START_ADDRESS + 6) // Causes the UM6 to set the current measured magnetometer data to the reference vector
179 #define UM6_RESET_TO_FACTORY (COMMAND_START_ADDRESS + 7) // Causes the UM6 to load default factory settings
180 
181 #define UM6_SAVE_FACTORY (COMMAND_START_ADDRESS + 8) // Causes the UM6 to save the current settings to the factory flash location
182 
183 #define UM6_SET_HOME_POSITION (COMMAND_START_ADDRESS + 9) // Causes the UM6 to save the current GPS position as the "home" position (used to compute relative position)
184 
185 #define UM6_USE_CONFIG_ADDRESS 0
186 #define UM6_USE_FACTORY_ADDRESS 1
187 
188 #define UM6_BAD_CHECKSUM 253 // Sent if the UM6 receives a packet with a bad checksum
189 #define UM6_UNKNOWN_ADDRESS 254 // Sent if the UM6 receives a packet with an unknown address
190 #define UM6_INVALID_BATCH_SIZE 255 // Sent if a requested batch read or write operation would go beyond the bounds of the config or data array
191 
192 // Now make even more definitions for writing data to specific registers
193 // Start with the UM6_COMMUNICATION register. These definitions specify what individual bits in the regist mean
194 #define UM6_BROADCAST_ENABLED (1 << 30) // Enable serial data transmission
195 #define UM6_GYROS_RAW_ENABLED (1 << 29) // Enable transmission of raw gyro data
196 #define UM6_ACCELS_RAW_ENABLED (1 << 28) // Enable transmission of raw accelerometer data
197 #define UM6_MAG_RAW_ENABLED (1 << 27) // Enable transmission of raw magnetometer data
198 #define UM6_GYROS_PROC_ENABLED (1 << 26) // Enable transmission of processed gyro data (biases removed, scale factor applied, rotation correction applied)
199 #define UM6_ACCELS_PROC_ENABLED (1 << 25) // Enable transmission of processed accel data (biases removed, scale factor applied, rotation correction applied)
200 #define UM6_MAG_PROC_ENABLED (1 << 24) // Enable transmission of processed mag data (biases removed, scale factor applied, rotation correction applied)
201 #define UM6_QUAT_ENABLED (1 << 23) // Enable transmission of quaternion data
202 #define UM6_EULER_ENABLED (1 << 22) // Enable transmission of euler angle data
203 #define UM6_COV_ENABLED (1 << 21) // Enable transmission of state covariance data
204 #define UM6_TEMPERATURE_ENABLED (1 << 20) // Enable transmission of gyro temperature readings
205 #define UM6_GPS_POSITION_ENABLED (1 << 19) // Enable transmission of latitude and longitude data
206 #define UM6_GPS_REL_POSITION_ENABLED (1 << 18) // Enable transmission of computed North and East position (with respect to home position)
207 #define UM6_GPS_COURSE_SPEED_ENABLED (1 << 17) // Enable transmission of computed GPS course and speed
208 #define UM6_GPS_SAT_SUMMARY_ENABLED (1 << 16) // Enable transmission of satellite summary data (count, HDOP, VDP, mode)
209 #define UM6_GPS_SAT_DATA_ENABLED (1 << 15) // Enable transmission of satellite data (ID and SNR of each satellite)
210 
211 #define UM6_GPS_BAUD_RATE_MASK (0x07)
212 #define UM6_GPS_BAUD_START_BIT 11
213 
214 #define UM6_BAUD_RATE_MASK (0x07) // Mask specifying the number of bits used to set the serial baud rate
215 #define UM6_BAUD_START_BIT 8 // Specifies the start location of the baud rate bits
216 
217 #define UM6_SERIAL_RATE_MASK (0x000FF) // Mask specifying which bits in this register are used to indicate the broadcast frequency
218 
219 // MISC Configuration register
220 #define UM6_MAG_UPDATE_ENABLED (1 << 31) // Enable magnetometer-based updates in the EKF
221 #define UM6_ACCEL_UPDATE_ENABLED (1 << 30) // Enable accelerometer-based updates in the EKF
222 #define UM6_GYRO_STARTUP_CAL (1 << 29) // Enable automatic gyro calibration on startup
223 #define UM6_QUAT_ESTIMATE_ENABLED (1 << 28) // Enable quaternion-based state estimation
224 
225 // UM6 Status Register
226 #define UM6_MAG_INIT_FAILED (1 << 31) // Indicates magnetometer initialization failed
227 #define UM6_ACCEL_INIT_FAILED (1 << 30) // Indicates accelerometer initialization failed
228 #define UM6_GYRO_INIT_FAILED (1 << 29) // Indicates gyro initialization failed
229 #define UM6_GYRO_ST_FAILED_X (1 << 28) // Indicates that the x-axis gyro self test failed
230 #define UM6_GYRO_ST_FAILED_Y (1 << 27) // Indicates that the y-axis gyro self test failed
231 #define UM6_GYRO_ST_FAILED_Z (1 << 26) // Indicates that the z-axis gyro self test failed
232 #define UM6_ACCEL_ST_FAILED_X (1 << 25) // Indicates that the x-axis accel self test failed
233 #define UM6_ACCEL_ST_FAILED_Y (1 << 24) // Indicates that the y-axis accel self test failed
234 #define UM6_ACCEL_ST_FAILED_Z (1 << 23) // Indicates that the z-axis accel self test failed
235 #define UM6_MAG_ST_FAILED_X (1 << 22) // Indicates that the x-axis mag self test failed
236 #define UM6_MAG_ST_FAILED_Y (1 << 21) // Indicates that the y-axis mag self test failed
237 #define UM6_MAG_ST_FAILED_Z (1 << 20) // Indicates that the z-axis mag self test failed
238 #define UM6_I2C_GYRO_BUS_ERROR (1 << 19) // Indicates that there was an i2c bus error while communicating with the rate gyros
239 #define UM6_I2C_ACCEL_BUS_ERROR (1 << 18) // Indicates that there was an i2c bus error while communicating with the accelerometers
240 #define UM6_I2C_MAG_BUS_ERROR (1 << 17) // Indicates that there was an i2c bus error while communicating with the magnetometer
241 #define UM6_EKF_DIVERGENT (1 << 16) // Indicates that the EKF estimate failed and had to be restarted
242 #define UM6_GYRO_UNRESPONSIVE (1 << 15) // Inidicates that the rate gyros failed to signal new data for longer than expected
243 #define UM6_ACCEL_UNRESPONSIVE (1 << 14) // Indicates that the accelerometer failed to signal new data for longer than expected
244 #define UM6_MAG_UNRESPONSIVE (1 << 13) // Indicates that the magnetometer failed to signal new data for longer than expected
245 #define UM6_FLASH_WRITE_FAILED (1 << 12) // Indicates that a write to flash command failed to complete properly
246 
247 #define UM6_SELF_TEST_COMPLETE (1 << 0) // Indicates that a self-test was completed
248 
249 
250 


um6
Author(s): Mike Purvis
autogenerated on Thu Sep 26 2019 03:18:02