Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of MS5803-Demo by
main.cpp
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 * Demo Program 00021 * Barometer Sensor (Altimeter) MS5803-01BA of MEAS Switzerland (www.meas-spec.com). 00022 * The driver uses I2C mode (sensor PS pin low). 00023 * Other types of MEAS are compatible but not tested. 00024 * Written by Raig Kaufer distribute freely! 00025 * 00026 * Modified for MS5803-14BA by Francesco Adamo, Italy 00027 */ 00028 00029 #include "mbed.h" 00030 #include "MS5803_14BA.h" 00031 00032 00033 #ifdef TARGET_K64F 00034 #define SPI_SCK PTD1 00035 #define SPI_MOSI PTD2 00036 #define SPI_MISO PTD3 00037 #define SPI_CS PTD0 00038 #define I2C_SDA PTE25 00039 #define I2C_SCL PTE24 00040 #elif defined(TARGET_KL25Z) 00041 #define SPI_SCK PTD1 00042 #define SPI_MOSI PTD2 00043 #define SPI_MISO PTD3 00044 #define SPI_CS PTD0 00045 #define I2C_SDA PTE0 00046 #define I2C_SCL PTE1 00047 #endif 00048 00049 Serial pc(USBTX, USBRX); 00050 MS5803_14BA ps(I2C_SDA, I2C_SCL, MS5803_ADDRC_H, D1_OSR_4096, D2_OSR_4096); // SDA, SCL, I2C_address (0x76 or 0x77 look at MS5803.h) 00051 00052 int main() { 00053 pc.baud(115200); 00054 pc.printf("MS5803 demo\r\n"); 00055 00056 while (1) { 00057 ps.convert(); 00058 pc.printf("%4.1f, %4.1f\r\n", ps.getPressure(), ps.getTemperature()); 00059 wait(0.5); 00060 } 00061 }
Generated on Mon Aug 15 2022 04:04:56 by
1.7.2
