WizziLab / Mbed 2 deprecated D7A_1x_TRAINING

Dependencies:   X_NUCLEO_IKS01A1 d7a_1x mbed-rtos mbed wizzi-utils

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers sensors.h Source File

sensors.h

00001 #ifndef _SENSORS_H_
00002 #define _SENSORS_H_
00003 
00004 #include "hts221/hts221_class.h"
00005 #include "lis3mdl/lis3mdl_class.h"
00006 #include "lps25h/lps25h_class.h"
00007 #include "lsm6ds0/lsm6ds0_class.h"
00008 #include "d7a.h"
00009 
00010 // Simulate the sensors (if X_NUCLEO_IKS01A1 not connected)
00011 //#define _SENSORS_SIMU_    1
00012 
00013 extern LIS3MDL *magnetometer;
00014 extern LSM6DS0 *accelerometer;
00015 extern LSM6DS0 *gyroscope;
00016 extern LPS25H *pressure_sensor;
00017 extern LPS25H *temp_sensor2;
00018 extern HTS221 *humidity_sensor;
00019 extern HTS221 *temp_sensor1;
00020 
00021 
00022 // Types of reporting
00023 typedef enum {
00024     REPORT_ALWAYS,
00025     REPORT_ON_DIFFERENCE,
00026     REPORT_ON_THRESHOLD,
00027 } report_type_t;
00028 
00029 // Sensor reporting configuration
00030 TYPEDEF_STRUCT_PACKED {
00031     uint8_t  report_type; // Type of report asked
00032     uint32_t period; // Measure period (ms)
00033     uint32_t max_period; // Maximum time between reports (s)
00034     uint32_t max_diff; // Maximum difference allowed between two reported values
00035     int32_t  threshold_high; // High threshold value triggering a report
00036     int32_t  threshold_low; // Low threshold value triggering a report
00037 } sensor_config_t;
00038 
00039 typedef struct
00040 {
00041     // Number of data fields
00042     uint32_t nb_values;
00043     // Total size of data
00044     uint32_t data_size;
00045     // Read value function
00046     bool (*read_value)(int32_t*);
00047     // Last reported value
00048     int32_t* last_report_value;
00049     // Current measured value
00050     int32_t* current_value;
00051     // Time elapsed since last report (ms)
00052     uint32_t last_report_time;
00053     
00054     // File ID of the sensor value file
00055     uint8_t value_file_id;
00056     // Sensor configuration file ID
00057     uint8_t cfg_file_id;
00058     // Sensor configuration context
00059     sensor_config_t cfg;
00060 } sensor_thread_ctx_t;
00061 
00062 
00063 bool Init_HTS221(HTS221* ht_sensor);
00064 bool Init_LIS3MDL(LIS3MDL* magnetometer);
00065 bool Init_LPS25H(LPS25H* pt_sensor);
00066 bool Init_LSM6DS0(LSM6DS0* gyro_lsm6ds0);
00067 
00068 bool mag_get_value(int32_t* buf);
00069 bool acc_get_value(int32_t* buf);
00070 bool gyr_get_value(int32_t* buf);
00071 bool pre_get_value(int32_t* buf);
00072 bool hum_get_value(int32_t* buf);
00073 bool tem1_get_value(int32_t* buf);
00074 bool tem2_get_value(int32_t* buf);
00075 
00076 #endif // _SENSORS_H_