Correction de la lib car erreur de format dans les calculs
Embed:
(wiki syntax)
Show/hide line numbers
MS5803.h
00001 /* 00002 Permission is hereby granted, free of charge, to any person obtaining a copy 00003 of this software and associated documentation files (the "Software"), to deal 00004 in the Software without restriction, including without limitation the rights 00005 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 00006 copies of the Software, and to permit persons to whom the Software is 00007 furnished to do so, subject to the following conditions: 00008 00009 The above copyright notice and this permission notice shall be included in 00010 all copies or substantial portions of the Software. 00011 00012 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00013 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00014 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00015 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00016 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00017 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 00018 THE SOFTWARE. 00019 00020 * Library for Pressure Sensors of type MS5803-x of MEAS Switzerland (www.meas-spec.com). 00021 * The driver uses I2C mode (sensor's Protocol Select (PS) pin pulled to high). 00022 * MS5803-01BA (Barometer Sensor (Altimeter)) was successfully tested by Raig Kaufer. 00023 * MS5803-14BA (Underwater Pressure Sensor 14 bar) was successfully tested by Robert Katzschmann 00024 * Other types of MEAS are compatible but not tested 00025 * Written by Raig Kaufer, distribute freely! 00026 * Revised by Robert Katzschmann 00027 */ 00028 #include "mbed.h" 00029 00030 #ifndef MS5803_H 00031 #define MS5803_H 00032 00033 #define MS5803_RX_DEPTH 3 // 00034 #define MS5803_TX_DEPTH 2 // 00035 00036 // choose your connection here 00037 #define ms5803_addrCL 0x77 //0b1110111 CSB Pin is low 00038 #define ms5803_addrCH 0x76 //0b1110110 CSB Pin is high 00039 00040 #define ms5803_reset 0x1E // Sensor Reset 00041 00042 #define ms5803_convD1_256 0x40 // Convert D1 OSR 256 00043 #define ms5803_convD1_512 0x42 // Convert D1 OSR 512 00044 #define ms5803_convD1_1024 0x44 // Convert D1 OSR 1024 00045 #define ms5803_convD1_2048 0x46 // Convert D1 OSR 2048 00046 #define ms5803_convD1_4096 0x48 // Convert D1 OSR 2048 00047 00048 #define ms5803_convD1 ms5803_convD1_4096 // choose your sampling rate here 00049 00050 #define ms5803_convD2_256 0x50 // Convert D2 OSR 256 00051 #define ms5803_convD2_512 0x52 // Convert D2 OSR 512 00052 #define ms5803_convD2_1024 0x54 // Convert D2 OSR 1024 00053 #define ms5803_convD2_2048 0x56 // Convert D2 OSR 2048 00054 #define ms5803_convD2_4096 0x58 // Convert D2 OSR 2048 00055 00056 #define ms5803_convD2 ms5803_convD2_4096 // choose your sampling rate here 00057 00058 #define ms5803_ADCread 0x00 // read ADC command 00059 #define ms5803_PROMread 0xA0 // read PROM command base address 00060 00061 class MS5803{ 00062 private: 00063 int D1, D2, Temp; 00064 unsigned int C[8]; 00065 float T_MS5803, P_MS5803; 00066 /* Data buffers */ 00067 char ms5803_rx_data[MS5803_RX_DEPTH]; 00068 char ms5803_tx_data[MS5803_TX_DEPTH]; 00069 00070 public: 00071 MS5803 (PinName sda, PinName scl, 00072 char ms5803_addr = ms5803_addrCH ) 00073 : i2c( sda, scl ), device_address( ms5803_addr << 1 ) { 00074 } 00075 void MS5803Init(void); 00076 void MS5803Reset(void); 00077 void MS5803ReadProm(void); 00078 void MS5803ConvertD1(void); 00079 void MS5803ConvertD2(void); 00080 int32_t MS5803ReadADC(void); 00081 float MS5803_Pressure (void); 00082 float MS5803_Temperature (void); 00083 void Barometer_MS5803(void); 00084 00085 00086 private: 00087 I2C i2c; 00088 char device_address; 00089 00090 }; 00091 #endif
Generated on Fri Jul 29 2022 16:25:21 by
1.7.2