upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
ms5803_defs.h
1 /*
2  * Author: Jon Trulson <jtrulson@ics.com>
3  * Copyright (c) 2016 Intel Corporation.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining
6  * a copy of this software and associated documentation files (the
7  * "Software"), to deal in the Software without restriction, including
8  * without limitation the rights to use, copy, modify, merge, publish,
9  * distribute, sublicense, and/or sell copies of the Software, and to
10  * permit persons to whom the Software is furnished to do so, subject to
11  * the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be
14  * included in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23  */
24 #pragma once
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 // default I2C address
31 #define MS5803_DEFAULT_I2C_ADDR 0x76
32 
33 #define MS5803_MAX_COEFFICIENTS (8)
34 
35  // valid commands
36  typedef enum {
37  MS5803_CMD_RESET = 0x1e,
38 
39  // D1 = pressure
40  MS5803_CMD_CONVERT_D1_OSR_256 = 0x40,
41  MS5803_CMD_CONVERT_D1_OSR_512 = 0x42,
42  MS5803_CMD_CONVERT_D1_OSR_1024 = 0x44,
43  MS5803_CMD_CONVERT_D1_OSR_2048 = 0x46,
44  MS5803_CMD_CONVERT_D1_OSR_4096 = 0x48,
45 
46  // D2 = temperature
47  MS5803_CMD_CONVERT_D2_OSR_256 = 0x50,
48  MS5803_CMD_CONVERT_D2_OSR_512 = 0x52,
49  MS5803_CMD_CONVERT_D2_OSR_1024 = 0x54,
50  MS5803_CMD_CONVERT_D2_OSR_2048 = 0x56,
51  MS5803_CMD_CONVERT_D2_OSR_4096 = 0x58,
52 
53  // ADC read
54  MS5803_CMD_ADC_READ = 0x00,
55 
56  // PROM read. Bits 1, 2, and 3 indicate the address. Bit 0 is
57  // always 0 (in all commands). There are 7 PROM locations,
58  // each 2 bytes in length. These locations store factory
59  // loaded compensation coefficients.
60  MS5803_CMD_PROM_READ = 0xa0
61  } MS5803_CMD_T;
62 
63  // output sampling resolution for temperature and pressure. We
64  // set the numeric values here to indicate the required wait time
65  // for each in milliseconds (rounded up from the datasheet
66  // maximums), so do not change these numbers.
67  typedef enum {
68  MS5803_OSR_256 = 1, // 1ms
69  MS5803_OSR_512 = 2,
70  MS5803_OSR_1024 = 3,
71  MS5803_OSR_2048 = 5,
72  MS5803_OSR_4096 = 10
73  } MS5803_OSR_T;
74 
75 #ifdef __cplusplus
76 }
77 #endif