firmware_registers.h
Go to the documentation of this file.
1 
12 // Define the firmware revision
13 #define UM7_FIRMWARE_REVISION (('U' << 24) | ('7' << 16) | ('1' << 8) | 'C')
14 
15 // CONFIG_ARRAY_SIZE and DATA_ARRAY_SIZE specify the number of 32 bit configuration and data registers used by the firmware
16 // (Note: The term "register" is used loosely here. These "registers" are not actually registers in the same sense of a
17 // microcontroller register. They are simply index locations into arrays stored in global memory. Data and configuration
18 // parameters are stored in arrays because it allows a common communication protocol to be used to access all data and
19 // configuration. The software communicating with the sensor needs only specify the register address, and the communication
20 // software running on the sensor knows exactly where to find it - it needn't know what the data is. The software communicatin
21 // with the sensor, on the other hand, needs to know what it is asking for (naturally...)
22 // This setup makes it easy to make more data immediately available when needed - simply increase the array size, add code in
23 // the firmware that writes data to the new array location, and then make updates to the firmware definition on the PC side.
24 #define CONFIG_ARRAY_SIZE 27
25 #define DATA_ARRAY_SIZE 52
26 #define COMMAND_COUNT 10
27 
28 #define HIDDEN_ARRAY_SIZE 127
29 
30 // Define address ranges for interpreting incoming packet data
31 #define CONFIG_REG_START_ADDRESS 0
32 #define DATA_REG_START_ADDRESS 85
33 #define COMMAND_START_ADDRESS 170
34 
35 // Definitions of configuration registers/address
36 #define CREG_COM_SETTINGS 0
37 #define CREG_COM_RATES1 1
38 #define CREG_COM_RATES2 2
39 #define CREG_COM_RATES3 3
40 #define CREG_COM_RATES4 4
41 #define CREG_COM_RATES5 5
42 #define CREG_COM_RATES6 6
43 #define CREG_COM_RATES7 7
44 #define CREG_MISC_SETTINGS 8
45 #define CREG_HOME_NORTH 9
46 #define CREG_HOME_EAST 10
47 #define CREG_HOME_UP 11
48 #define CREG_GYRO_TRIM_X 12 // Floating point trim (actual angular rate)
49 #define CREG_GYRO_TRIM_Y 13
50 #define CREG_GYRO_TRIM_Z 14
51 #define CREG_MAG_CAL1_1 15
52 #define CREG_MAG_CAL1_2 16
53 #define CREG_MAG_CAL1_3 17
54 #define CREG_MAG_CAL2_1 18
55 #define CREG_MAG_CAL2_2 19
56 #define CREG_MAG_CAL2_3 20
57 #define CREG_MAG_CAL3_1 21
58 #define CREG_MAG_CAL3_2 22
59 #define CREG_MAG_CAL3_3 23
60 #define CREG_MAG_BIAS_X 24
61 #define CREG_MAG_BIAS_Y 25
62 #define CREG_MAG_BIAS_Z 26
63 
64 // Bit definitions for COM_SETTINGS register
65 #define COM_BAUD_MASK 0x0F // Uses 4 bits
66 #define COM_BAUD_START 28 // Lowest-order bit on bit 28
67 
68 #define COM_GPS_BAUD_MASK 0x0F
69 #define COM_GPS_BAUD_START 24
70 
71 #define COM_GPS_DATA_ENABLED (1 << 8)
72 #define COM_GPS_SAT_DATA_ENABLED (1 << 4)
73 
74 // Definitions for controlling the baud rate of the USART
75 #define BAUD_9600 0
76 #define BAUD_14400 1
77 #define BAUD_19200 2
78 #define BAUD_38400 3
79 #define BAUD_57600 4
80 #define BAUD_115200 5
81 #define BAUD_128000 6
82 #define BAUD_153600 7
83 #define BAUD_230400 8
84 #define BAUD_256000 9
85 #define BAUD_460800 10
86 #define BAUD_921600 11
87 
88 // Bit definitions for COM_RATE registers
89 #define RATE1_RAW_ACCEL_MASK 0x0FF
90 #define RATE1_RAW_ACCEL_START 24
91 #define RATE1_RAW_GYRO_MASK 0x0FF
92 #define RATE1_RAW_GYRO_START 16
93 #define RATE1_RAW_MAG_MASK 0x0FF
94 #define RATE1_RAW_MAG_START 8
95 
96 #define RATE2_TEMPERATURE_MASK 0x0FF
97 #define RATE2_TEMPERATURE_START 24
98 #define RATE2_ALL_RAW_MASK 0x0FF
99 #define RATE2_ALL_RAW_START 0
100 
101 #define RATE3_PROC_ACCEL_MASK 0x0FF
102 #define RATE3_PROC_ACCEL_START 24
103 #define RATE3_PROC_GYRO_MASK 0x0FF
104 #define RATE3_PROC_GYRO_START 16
105 #define RATE3_PROC_MAG_MASK 0x0FF
106 #define RATE3_PROC_MAG_START 8
107 
108 #define RATE4_ALL_PROC_MASK 0x0FF
109 #define RATE4_ALL_PROC_START 0
110 
111 #define RATE5_QUAT_MASK 0x0FF
112 #define RATE5_QUAT_START 24
113 #define RATE5_EULER_MASK 0x0FF
114 #define RATE5_EULER_START 16
115 #define RATE5_POSITION_MASK 0x0FF
116 #define RATE5_POSITION_START 8
117 #define RATE5_VELOCITY_MASK 0x0FF
118 #define RATE5_VELOCITY_START 0
119 
120 #define RATE6_POSE_MASK 0x0FF
121 #define RATE6_POSE_START 24
122 #define RATE6_HEALTH_MASK 0x0F
123 #define RATE6_HEALTH_START 16
124 
125 #define RATE7_NMEA_HEALTH_MASK 0x0F
126 #define RATE7_NMEA_HEALTH_START 28
127 #define RATE7_NMEA_POSE_MASK 0x0F
128 #define RATE7_NMEA_POSE_START 24
129 #define RATE7_NMEA_ATTITUDE_MASK 0x0F
130 #define RATE7_NMEA_ATTITUDE_START 20
131 #define RATE7_NMEA_SENSOR_MASK 0x0F
132 #define RATE7_NMEA_SENSOR_START 16
133 #define RATE7_NMEA_RATE_MASK 0x0F
134 #define RATE7_NMEA_RATE_START 12
135 #define RATE7_NMEA_GPS_POSE_MASK 0x0F
136 #define RATE7_NMEA_GPS_POSE_START 8
137 #define RATE7_NMEA_QUATERNION_MASK 0x0F
138 #define RATE7_NMEA_QUATERNION_START 4
139 
140 // Bit definitions for filter settings register.
141 #define MAG_UPDATES_ENABLED (1 << 0)
142 #define QUATERNION_MODE_ENABLED (1 << 1)
143 #define ZERO_GYROS_ON_STARTUP (1 << 2)
144 #define USE_TX2_AS_PPS_INPUT (1 << 8)
145 
146 // Definitions of data registers/addresses
147 #define DREG_HEALTH 85
148 #define DREG_GYRO_RAW_XY 86
149 #define DREG_GYRO_RAW_Z 87
150 #define DREG_GYRO_TIME 88
151 #define DREG_ACCEL_RAW_XY 89
152 #define DREG_ACCEL_RAW_Z 90
153 #define DREG_ACCEL_TIME 91
154 #define DREG_MAG_RAW_XY 92
155 #define DREG_MAG_RAW_Z 93
156 #define DREG_MAG_RAW_TIME 94
157 #define DREG_TEMPERATURE 95
158 #define DREG_TEMPERATURE_TIME 96
159 #define DREG_GYRO_PROC_X 97
160 #define DREG_GYRO_PROC_Y 98
161 #define DREG_GYRO_PROC_Z 99
162 #define DREG_GYRO_PROC_TIME 100
163 #define DREG_ACCEL_PROC_X 101
164 #define DREG_ACCEL_PROC_Y 102
165 #define DREG_ACCEL_PROC_Z 103
166 #define DREG_ACCEL_PROC_TIME 104
167 #define DREG_MAG_PROC_X 105
168 #define DREG_MAG_PROC_Y 106
169 #define DREG_MAG_PROC_Z 107
170 #define DREG_MAG_PROC_TIME 108
171 #define DREG_QUAT_AB 109
172 #define DREG_QUAT_CD 110
173 #define DREG_QUAT_TIME 111
174 #define DREG_EULER_PHI_THETA 112
175 #define DREG_EULER_PSI 113
176 #define DREG_EULER_PHI_THETA_DOT 114
177 #define DREG_EULER_PSI_DOT 115
178 #define DREG_EULER_TIME 116
179 #define DREG_POSITION_NORTH 117
180 #define DREG_POSITION_EAST 118
181 #define DREG_POSITION_UP 119
182 #define DREG_POSITION_TIME 120
183 #define DREG_VELOCITY_NORTH 121
184 #define DREG_VELOCITY_EAST 122
185 #define DREG_VELOCITY_UP 123
186 #define DREG_VELOCITY_TIME 124
187 #define DREG_GPS_LATITUDE 125
188 #define DREG_GPS_LONGITUDE 126
189 #define DREG_GPS_ALTITUDE 127
190 #define DREG_GPS_COURSE 128
191 #define DREG_GPS_SPEED 129
192 #define DREG_GPS_TIME 130
193 #define DREG_GPS_SAT_1_2 131
194 #define DREG_GPS_SAT_3_4 132
195 #define DREG_GPS_SAT_5_6 133
196 #define DREG_GPS_SAT_7_8 134
197 #define DREG_GPS_SAT_9_10 135
198 #define DREG_GPS_SAT_11_12 136
199 
200 // Bit definitions for sensor health register
201 #define HEALTH_SATS_USED_MASK 0x3F // Uses 6 bits
202 #define HEALTH_SATS_USED_START 26 // Lowest-order bit starts at 26
203 #define HEALTH_HDOP_MASK 0x3FF // Uses 10 bits
204 #define HEALTH_HDOP_START 16 // Lowest-order bit starts at 16
205 #define HEALTH_SATS_IN_VIEW_MASK 0x3F
206 #define HEALTH_SATS_IN_VIEW_START 10
207 #define HEALTH_COM_OVERFLOW (1 << 8) // Set when the sensor was unable to transmit all the requested data
208 #define HEALTH_MAG_NORM (1 << 5)
209 #define HEALTH_ACCEL_NORM (1 << 4)
210 #define HEALTH_ACCEL (1 << 3)
211 #define HEALTH_GYRO (1 << 2)
212 #define HEALTH_MAG (1 << 1)
213 #define HEALTH_GPS (1 << 0)
214 
215 // Definition of packet address for COM error codes
216 #define CHR_BAD_CHECKSUM 253 // Sent if the module receives a packet with a bad checksum
217 #define CHR_UNKNOWN_ADDRESS 254 // Sent if the module receives a packet with an unknown address
218 #define CHR_INVALID_BATCH_SIZE 255 // Sent if a requested batch read or write operation would go beyond the bounds of the config or data array
219 
220 // Command addresses
221 #define CHR_GET_FW_VERSION (COMMAND_START_ADDRESS + 0) // Causes the device to report the firmware revision
222 #define CHR_FLASH_COMMIT (COMMAND_START_ADDRESS + 1) // Causes the device to write all configuration values to FLASH
223 #define CHR_RESET_TO_FACTORY (COMMAND_START_ADDRESS + 2) // Causes the UM6 to load default factory settings
224 #define CHR_ZERO_GYROS (COMMAND_START_ADDRESS + 3)
225 #define CHR_SET_HOME_POSITION (COMMAND_START_ADDRESS + 4)
226 #define CHR_FACTORY_COMMIT (COMMAND_START_ADDRESS + 5)
227 #define CHR_SET_MAG_REFERENCE (COMMAND_START_ADDRESS + 6)
228 #define CHR_RESET_EKF (COMMAND_START_ADDRESS + 9)
229 
230 // Some definitions for working with COM events
231 #define NMEA_HEALTH_PACKET 0
232 #define NMEA_POSE_PACKET 1
233 #define NMEA_ATTITUDE_PACKET 2
234 #define NMEA_SENSOR_PACKET 3
235 #define NMEA_RATE_PACKET 4
236 #define NMEA_GPS_POSE_PACKET 5
237 #define NMEA_QUATERNION_PACKET 6
238 
239 // Definition for zeroing rate gyros and pressure sensor
240 #define GYRO_ZERO_SAMPLES 500
241 #define GYRO_X_INDEX 0
242 #define GYRO_Y_INDEX 1
243 #define GYRO_Z_INDEX 2
244 #define ANGLE_ZERO_SAMPLES 1000
245 #define ACCEL_X_INDEX 0
246 #define ACCEL_Y_INDEX 1
247 #define ACCEL_Z_INDEX 2
248 #define PRESSURE_ZERO_SAMPLES 250
249 #define AIRSPEED_ZERO_SAMPLES 500
250 
251 #define PI 3.14159265f
252 #define PIx2 6.28318530f
253 #define PId2 1.57079633f
254 #define GRAVITY 9.80665f
255 #define GRAVITYx2 19.6133f
256 #define GRAVITYd2 4.903325f
257 #define RAW_TO_MBAR (1.0f/4096.0f)
258 #define KPA_PER_VOLT 1.0f
259 
260 #define CHR_USE_CONFIG_ADDRESS 0
261 #define CHR_USE_FACTORY_ADDRESS 1
262 
263 // Start address for writing configuration to FLASH
264 #define FLASH_START_ADDRESS (uint32_t)0x0800F000
265 // Start address for factory FLASH configuration
266 #define FACTORY_FLASH_ADDRESS (uint32_t)0x0800E000
267 
268 // Macro for determining whether FLASH has been initialized
269 #define FGET_FLASH_UNINITIALIZED() ((uint32_t)( *(__IO uint32_t*)(FLASH_START_ADDRESS) ) == 0xFFFFFFFF)
270 #define FGET_FACTORY_UNINITIALIZED() ((uint32_t)( *(__IO uint32_t*)(FACTORY_FLASH_ADDRESS) ) == 0xFFFFFFFF)
271 
272 #define GYRO_ZERO_SAMPLE_SIZE 500
273 
274 typedef struct __CHR_config
275 {
276  union
277  {
278  uint32_t r[CONFIG_ARRAY_SIZE];
280  };
281 } CHR_config;
282 
283 typedef struct __CHR_data
284 {
285  union
286  {
287  uint32_t r[DATA_ARRAY_SIZE];
289  };
290 } CHR_data;
struct __CHR_data CHR_data
#define DATA_ARRAY_SIZE
uint32_t r[CONFIG_ARRAY_SIZE]
struct __CHR_config CHR_config
float f[CONFIG_ARRAY_SIZE]
#define CONFIG_ARRAY_SIZE


um7
Author(s): Mike Purvis , Alex Brown
autogenerated on Tue Feb 11 2020 03:26:50