@@ -33,20 +33,6 @@ Bmv080 bmv080;
33
33
#define BMV080_IRQ 14 // The BMV080 interrupt pin
34
34
#define BMV080_ADDR 0x57 // SparkFun BMV080 Breakout defaults to 0x57
35
35
36
- SET_LOOP_TASK_STACK_SIZE (60 * 1024 ); // 60KB
37
-
38
- extern " C" bmv080_handle_t bmv080_handle = NULL ;
39
-
40
- /* A unique handle is used to address a BMV080 sensor unit */
41
- // static bmv080_handle_t bmv080_handle = NULL;
42
-
43
- /* handle for print function to be used in interrupt service routine */
44
- // static print_function_t print_handle = NULL;
45
-
46
- // volatile uint32_t data_ready_callback_count = 0;
47
-
48
- // void print_to_serial(const char *format, ...);
49
-
50
36
i2c_device_t i2c_device = {};
51
37
52
38
#define IRQ_Pin 14
@@ -83,8 +69,8 @@ void setup()
83
69
/* Communication interface initialization */
84
70
85
71
i2c_init (&i2c_device);
86
-
87
- setup_sensor ( );
72
+
73
+ bmv080. init (&i2c_device );
88
74
89
75
/* Set the sensor mode to continuous mode */
90
76
if (bmv080.setMode (SFE_BMV080_MODE_CONTINUOUS) == true )
@@ -118,190 +104,130 @@ void loop()
118
104
void setup_sensor (void )
119
105
{
120
106
121
- uint16_t major = 0 ;
122
- uint16_t minor = 0 ;
123
- uint16_t patch = 0 ;
124
- char git_hash[12 ];
125
- int32_t commits_ahead = 0 ;
126
-
127
- bmv080_status_code_t bmv080_current_status = bmv080_get_driver_version (&major, &minor, &patch, git_hash, &commits_ahead);
128
-
129
- if (bmv080_current_status != E_BMV080_OK)
130
- {
131
- printf (" Error getting BMV080 driver version: %d\n " , bmv080_current_status);
132
- }
133
-
134
- printf (" BMV080 driver version: %d.%d.%d\n " , major, minor, patch);
135
-
136
- /* Open the BMV080 sensor unit */
137
- bmv080_sercom_handle_t sercom_handle = (bmv080_sercom_handle_t )&i2c_device;
138
- bmv080_callback_read_t read = (const bmv080_callback_read_t )combridge_i2c_read_16bit;
139
- bmv080_callback_write_t write = (const bmv080_callback_write_t )combridge_i2c_write_16bit;
140
- bmv080_callback_delay_t delay_ms = (const bmv080_callback_delay_t )combridge_delay;
141
-
142
- bmv080_current_status = bmv080_open (&bmv080_handle, sercom_handle, read, write, delay_ms);
143
-
144
- if (bmv080_current_status != E_BMV080_OK)
145
- {
146
- printf (" Error opening BMV080 handle: %d\n " , bmv080_current_status);
147
- }
148
- else
149
- {
150
- printf (" BMV080 handle opened successfully\n " );
151
- }
152
-
153
- bmv080.setHandle (bmv080_handle);
154
-
155
- /* Reset the BMV080 sensor unit */
156
- bmv080_current_status = bmv080_reset (bmv080_handle);
157
-
158
- if (bmv080_current_status != E_BMV080_OK)
159
- {
160
- printf (" Error resetting BMV080 sensor unit: %d\n " , bmv080_current_status);
161
- }
162
- else
163
- {
164
- printf (" BMV080 sensor unit reset successfully\n " );
165
- }
166
-
167
- /* Getting the ID of a sensor unit */
168
- char id[13 ];
169
- memset (id, 0x00 , 13 );
170
- bmv080_current_status = bmv080_get_sensor_id (bmv080_handle, id);
171
-
172
- if (bmv080_current_status != E_BMV080_OK)
173
- {
174
- printf (" Error getting BMV080 sensor ID: %d\n " , bmv080_current_status);
175
- }
176
- else
177
- {
178
- printf (" BMV080 sensor ID: %s\n " , id);
179
- }
180
-
181
- /* Getting (default) configuration parameters */
107
+ // /* Getting (default) configuration parameters */
182
108
183
- /* Get default parameter "volumetric_mass_density" */
184
- float volumetric_mass_density = 0 .0f ;
185
- bmv080_current_status = bmv080_get_parameter (bmv080_handle, " volumetric_mass_density" , (void *)&volumetric_mass_density);
109
+ // / * Get default parameter "volumetric_mass_density" */
110
+ // float volumetric_mass_density = 0.0f;
111
+ // bmv080_current_status = bmv080_get_parameter(bmv080_handle, "volumetric_mass_density", (void*)&volumetric_mass_density);
186
112
187
- if (bmv080_current_status != E_BMV080_OK)
188
- {
189
- printf (" Error getting BMV080 parameter 'volumetric_mass_density': %d\n " , bmv080_current_status);
190
- }
191
- else
192
- {
193
- printf (" BMV080 parameter 'volumetric_mass_density': %.2f\n " , volumetric_mass_density);
194
- }
195
-
196
- /* Get default parameter "integration_time" */
197
- float integration_time = 0 .0f ;
198
- bmv080_current_status = bmv080_get_parameter (bmv080_handle, " integration_time" , (void *)&integration_time);
199
-
200
- if (bmv080_current_status != E_BMV080_OK)
201
- {
202
- printf (" Error getting BMV080 parameter 'integration_time': %d\n " , bmv080_current_status);
203
- }
204
- else
205
- {
206
- printf (" BMV080 parameter 'integration_time': %.2f\n " , integration_time);
207
- }
113
+ // if (bmv080_current_status != E_BMV080_OK)
114
+ // {
115
+ // printf("Error getting BMV080 parameter 'volumetric_mass_density': %d\n", bmv080_current_status);
116
+ // }
117
+ // else
118
+ // {
119
+ // printf("BMV080 parameter 'volumetric_mass_density': %.2f\n", volumetric_mass_density);
120
+ // }
208
121
209
- /* Get default parameter "distribution_id " */
210
- uint32_t distribution_id = 0 ;
211
- bmv080_current_status = bmv080_get_parameter (bmv080_handle, " distribution_id " , (void *)&distribution_id );
122
+ // / * Get default parameter "integration_time " */
123
+ // float integration_time = 0.0f ;
124
+ // bmv080_current_status = bmv080_get_parameter(bmv080_handle, "integration_time ", (void*)&integration_time );
212
125
213
- if (bmv080_current_status != E_BMV080_OK)
214
- {
215
- printf (" Error getting BMV080 parameter 'distribution_id': %d\n " , bmv080_current_status);
216
- }
217
- else
218
- {
219
- printf (" BMV080 parameter 'distribution_id': %d\n " , distribution_id);
220
- }
126
+ // if (bmv080_current_status != E_BMV080_OK)
127
+ // {
128
+ // printf("Error getting BMV080 parameter 'integration_time': %d\n", bmv080_current_status);
129
+ // }
130
+ // else
131
+ // {
132
+ // printf("BMV080 parameter 'integration_time': %.2f\n", integration_time);
133
+ // }
134
+
135
+ // /* Get default parameter "distribution_id" */
136
+ // uint32_t distribution_id = 0;
137
+ // bmv080_current_status = bmv080_get_parameter(bmv080_handle, "distribution_id", (void*)&distribution_id);
138
+
139
+ // if (bmv080_current_status != E_BMV080_OK)
140
+ // {
141
+ // printf("Error getting BMV080 parameter 'distribution_id': %d\n", bmv080_current_status);
142
+ // }
143
+ // else
144
+ // {
145
+ // printf("BMV080 parameter 'distribution_id': %d\n", distribution_id);
146
+ // }
221
147
222
- /* Get default parameter "do_obstruction_detection" */
223
- bool do_obstruction_detection = false ;
224
- bmv080_current_status = bmv080_get_parameter (bmv080_handle, " do_obstruction_detection" , (void *)&do_obstruction_detection);
148
+ // / * Get default parameter "do_obstruction_detection" */
149
+ // bool do_obstruction_detection = false;
150
+ // bmv080_current_status = bmv080_get_parameter(bmv080_handle, "do_obstruction_detection", (void*)&do_obstruction_detection);
225
151
226
- if (bmv080_current_status != E_BMV080_OK)
227
- {
228
- printf (" Error getting BMV080 parameter 'do_obstruction_detection': %d\n " , bmv080_current_status);
229
- }
230
- else
231
- {
232
- printf (" BMV080 parameter 'do_obstruction_detection': %s\n " , do_obstruction_detection ? " true" : " false" );
233
- }
152
+ // if (bmv080_current_status != E_BMV080_OK)
153
+ // {
154
+ // printf("Error getting BMV080 parameter 'do_obstruction_detection': %d\n", bmv080_current_status);
155
+ // }
156
+ // else
157
+ // {
158
+ // printf("BMV080 parameter 'do_obstruction_detection': %s\n", do_obstruction_detection ? "true" : "false");
159
+ // }
234
160
235
- /* Get default parameter "do_vibration_filtering" */
161
+ // / * Get default parameter "do_vibration_filtering" */
236
162
237
- bool do_vibration_filtering = false ;
238
- bmv080_current_status = bmv080_get_parameter (bmv080_handle, " do_vibration_filtering" , (void *)&do_vibration_filtering);
163
+ // bool do_vibration_filtering = false;
164
+ // bmv080_current_status = bmv080_get_parameter(bmv080_handle, "do_vibration_filtering", (void*)&do_vibration_filtering);
239
165
240
- if (bmv080_current_status != E_BMV080_OK)
241
- {
242
- printf (" Error getting BMV080 parameter 'do_vibration_filtering': %d\n " , bmv080_current_status);
243
- }
244
- else
245
- {
246
- printf (" BMV080 parameter 'do_vibration_filtering': %s\n " , do_vibration_filtering ? " true" : " false" );
247
- }
166
+ // if (bmv080_current_status != E_BMV080_OK)
167
+ // {
168
+ // printf("Error getting BMV080 parameter 'do_vibration_filtering': %d\n", bmv080_current_status);
169
+ // }
170
+ // else
171
+ // {
172
+ // printf("BMV080 parameter 'do_vibration_filtering': %s\n", do_vibration_filtering ? "true" : "false");
173
+ // }
248
174
249
- /* ********************************************************************************************************************
250
- * Setting (custom) configuration parameters
251
- *********************************************************************************************************************/
175
+ // / *********************************************************************************************************************
176
+ // * Setting (custom) configuration parameters
177
+ // *********************************************************************************************************************/
252
178
253
- bmv080_current_status = bmv080_set_parameter (bmv080_handle, " volumetric_mass_density" , (void *)&volumetric_mass_density);
179
+ // bmv080_current_status = bmv080_set_parameter(bmv080_handle, "volumetric_mass_density", (void*)&volumetric_mass_density);
254
180
255
- if (bmv080_current_status != E_BMV080_OK)
256
- {
257
- printf (" Error setting BMV080 parameter 'volumetric_mass_density': %d\n " , bmv080_current_status);
258
- }
259
- else
260
- {
261
- printf (" BMV080 parameter 'volumetric_mass_density' set successfully\n " );
262
- }
181
+ // if (bmv080_current_status != E_BMV080_OK)
182
+ // {
183
+ // printf("Error setting BMV080 parameter 'volumetric_mass_density': %d\n", bmv080_current_status);
184
+ // }
185
+ // else
186
+ // {
187
+ // printf("BMV080 parameter 'volumetric_mass_density' set successfully\n");
188
+ // }
263
189
264
- bmv080_current_status = bmv080_set_parameter (bmv080_handle, " integration_time" , (void *)&integration_time);
190
+ // bmv080_current_status = bmv080_set_parameter(bmv080_handle, "integration_time", (void*)&integration_time);
265
191
266
- if (bmv080_current_status != E_BMV080_OK)
267
- {
268
- printf (" Error setting BMV080 parameter 'integration_time': %d\n " , bmv080_current_status);
269
- }
270
- else
271
- {
272
- printf (" BMV080 parameter 'integration_time' set successfully\n " );
273
- }
192
+ // if (bmv080_current_status != E_BMV080_OK)
193
+ // {
194
+ // printf("Error setting BMV080 parameter 'integration_time': %d\n", bmv080_current_status);
195
+ // }
196
+ // else
197
+ // {
198
+ // printf("BMV080 parameter 'integration_time' set successfully\n");
199
+ // }
274
200
275
- bmv080_current_status = bmv080_set_parameter (bmv080_handle, " distribution_id" , (void *)&distribution_id);
201
+ // bmv080_current_status = bmv080_set_parameter(bmv080_handle, "distribution_id", (void*)&distribution_id);
276
202
277
- if (bmv080_current_status != E_BMV080_OK)
278
- {
279
- printf (" Error setting BMV080 parameter 'distribution_id': %d\n " , bmv080_current_status);
280
- }
281
- else
282
- {
283
- printf (" BMV080 parameter 'distribution_id' set successfully\n " );
284
- }
203
+ // if (bmv080_current_status != E_BMV080_OK)
204
+ // {
205
+ // printf("Error setting BMV080 parameter 'distribution_id': %d\n", bmv080_current_status);
206
+ // }
207
+ // else
208
+ // {
209
+ // printf("BMV080 parameter 'distribution_id' set successfully\n");
210
+ // }
285
211
286
- bmv080_current_status = bmv080_set_parameter (bmv080_handle, " do_obstruction_detection" , (void *)&do_obstruction_detection);
212
+ // bmv080_current_status = bmv080_set_parameter(bmv080_handle, "do_obstruction_detection", (void*)&do_obstruction_detection);
287
213
288
- if (bmv080_current_status != E_BMV080_OK)
289
- {
290
- printf (" Error setting BMV080 parameter 'do_obstruction_detection': %d\n " , bmv080_current_status);
291
- }
292
- else
293
- {
294
- printf (" BMV080 parameter 'do_obstruction_detection' set successfully\n " );
295
- }
214
+ // if (bmv080_current_status != E_BMV080_OK)
215
+ // {
216
+ // printf("Error setting BMV080 parameter 'do_obstruction_detection': %d\n", bmv080_current_status);
217
+ // }
218
+ // else
219
+ // {
220
+ // printf("BMV080 parameter 'do_obstruction_detection' set successfully\n");
221
+ // }
296
222
297
- bmv080_current_status = bmv080_set_parameter (bmv080_handle, " do_vibration_filtering" , (void *)&do_vibration_filtering);
223
+ // bmv080_current_status = bmv080_set_parameter(bmv080_handle, "do_vibration_filtering", (void*)&do_vibration_filtering);
298
224
299
- if (bmv080_current_status != E_BMV080_OK)
300
- {
301
- printf (" Error setting BMV080 parameter 'do_vibration_filtering': %d\n " , bmv080_current_status);
302
- }
303
- else
304
- {
305
- printf (" BMV080 parameter 'do_vibration_filtering' set successfully\n " );
306
- }
225
+ // if (bmv080_current_status != E_BMV080_OK)
226
+ // {
227
+ // printf("Error setting BMV080 parameter 'do_vibration_filtering': %d\n", bmv080_current_status);
228
+ // }
229
+ // else
230
+ // {
231
+ // printf("BMV080 parameter 'do_vibration_filtering' set successfully\n");
232
+ // }
307
233
}
0 commit comments