Demo fro training

Dependencies:   X_NUCLEO_IKS01A1 d7a_1x mbed-rtos mbed wizzi-utils

Committer:
mikl_andre
Date:
Mon Nov 21 07:24:34 2016 +0000
Revision:
0:429446fe396d
Initial Revision

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mikl_andre 0:429446fe396d 1 #ifndef _SENSORS_H_
mikl_andre 0:429446fe396d 2 #define _SENSORS_H_
mikl_andre 0:429446fe396d 3
mikl_andre 0:429446fe396d 4 #include "hts221/hts221_class.h"
mikl_andre 0:429446fe396d 5 #include "lis3mdl/lis3mdl_class.h"
mikl_andre 0:429446fe396d 6 #include "lps25h/lps25h_class.h"
mikl_andre 0:429446fe396d 7 #include "lsm6ds0/lsm6ds0_class.h"
mikl_andre 0:429446fe396d 8 #include "d7a.h"
mikl_andre 0:429446fe396d 9
mikl_andre 0:429446fe396d 10 // Simulate the sensors (if X_NUCLEO_IKS01A1 not connected)
mikl_andre 0:429446fe396d 11 //#define _SENSORS_SIMU_ 1
mikl_andre 0:429446fe396d 12
mikl_andre 0:429446fe396d 13 extern LIS3MDL *magnetometer;
mikl_andre 0:429446fe396d 14 extern LSM6DS0 *accelerometer;
mikl_andre 0:429446fe396d 15 extern LSM6DS0 *gyroscope;
mikl_andre 0:429446fe396d 16 extern LPS25H *pressure_sensor;
mikl_andre 0:429446fe396d 17 extern LPS25H *temp_sensor2;
mikl_andre 0:429446fe396d 18 extern HTS221 *humidity_sensor;
mikl_andre 0:429446fe396d 19 extern HTS221 *temp_sensor1;
mikl_andre 0:429446fe396d 20
mikl_andre 0:429446fe396d 21
mikl_andre 0:429446fe396d 22 // Types of reporting
mikl_andre 0:429446fe396d 23 typedef enum {
mikl_andre 0:429446fe396d 24 REPORT_ALWAYS,
mikl_andre 0:429446fe396d 25 REPORT_ON_DIFFERENCE,
mikl_andre 0:429446fe396d 26 REPORT_ON_THRESHOLD,
mikl_andre 0:429446fe396d 27 } report_type_t;
mikl_andre 0:429446fe396d 28
mikl_andre 0:429446fe396d 29 // Sensor reporting configuration
mikl_andre 0:429446fe396d 30 TYPEDEF_STRUCT_PACKED {
mikl_andre 0:429446fe396d 31 uint8_t report_type; // Type of report asked
mikl_andre 0:429446fe396d 32 uint32_t period; // Measure period (ms)
mikl_andre 0:429446fe396d 33 uint32_t max_period; // Maximum time between reports (s)
mikl_andre 0:429446fe396d 34 uint32_t max_diff; // Maximum difference allowed between two reported values
mikl_andre 0:429446fe396d 35 int32_t threshold_high; // High threshold value triggering a report
mikl_andre 0:429446fe396d 36 int32_t threshold_low; // Low threshold value triggering a report
mikl_andre 0:429446fe396d 37 } sensor_config_t;
mikl_andre 0:429446fe396d 38
mikl_andre 0:429446fe396d 39 typedef struct
mikl_andre 0:429446fe396d 40 {
mikl_andre 0:429446fe396d 41 // Number of data fields
mikl_andre 0:429446fe396d 42 uint32_t nb_values;
mikl_andre 0:429446fe396d 43 // Total size of data
mikl_andre 0:429446fe396d 44 uint32_t data_size;
mikl_andre 0:429446fe396d 45 // Read value function
mikl_andre 0:429446fe396d 46 bool (*read_value)(int32_t*);
mikl_andre 0:429446fe396d 47 // Last reported value
mikl_andre 0:429446fe396d 48 int32_t* last_report_value;
mikl_andre 0:429446fe396d 49 // Current measured value
mikl_andre 0:429446fe396d 50 int32_t* current_value;
mikl_andre 0:429446fe396d 51 // Time elapsed since last report (ms)
mikl_andre 0:429446fe396d 52 uint32_t last_report_time;
mikl_andre 0:429446fe396d 53
mikl_andre 0:429446fe396d 54 // File ID of the sensor value file
mikl_andre 0:429446fe396d 55 uint8_t value_file_id;
mikl_andre 0:429446fe396d 56 // Sensor configuration file ID
mikl_andre 0:429446fe396d 57 uint8_t cfg_file_id;
mikl_andre 0:429446fe396d 58 // Sensor configuration context
mikl_andre 0:429446fe396d 59 sensor_config_t cfg;
mikl_andre 0:429446fe396d 60 } sensor_thread_ctx_t;
mikl_andre 0:429446fe396d 61
mikl_andre 0:429446fe396d 62
mikl_andre 0:429446fe396d 63 bool Init_HTS221(HTS221* ht_sensor);
mikl_andre 0:429446fe396d 64 bool Init_LIS3MDL(LIS3MDL* magnetometer);
mikl_andre 0:429446fe396d 65 bool Init_LPS25H(LPS25H* pt_sensor);
mikl_andre 0:429446fe396d 66 bool Init_LSM6DS0(LSM6DS0* gyro_lsm6ds0);
mikl_andre 0:429446fe396d 67
mikl_andre 0:429446fe396d 68 bool mag_get_value(int32_t* buf);
mikl_andre 0:429446fe396d 69 bool acc_get_value(int32_t* buf);
mikl_andre 0:429446fe396d 70 bool gyr_get_value(int32_t* buf);
mikl_andre 0:429446fe396d 71 bool pre_get_value(int32_t* buf);
mikl_andre 0:429446fe396d 72 bool hum_get_value(int32_t* buf);
mikl_andre 0:429446fe396d 73 bool tem1_get_value(int32_t* buf);
mikl_andre 0:429446fe396d 74 bool tem2_get_value(int32_t* buf);
mikl_andre 0:429446fe396d 75
mikl_andre 0:429446fe396d 76 #endif // _SENSORS_H_