1+ /*
2+ SSCMANN060PG2A3 Air Pressure Sensor I2C Driver
3+ Datasheet: https://datasheet.octopart.com/SSCMANN060PG2A3-Honeywell-datasheet-36842084.pdf?src-supplier=IHS
4+ Honeywell I2C Doc: https://prod-edam.honeywell.com/content/dam/honeywell-edam/sps/siot/ja/products/sensors/pressure-sensors/board-mount-pressure-sensors/common/documents/sps-siot-i2c-comms-digital-output-pressure-sensors-tn-008201-3-en-ciid-45841.pdf
5+
6+ SSCMANN060PG2A3
7+ Product series - SSC: Standard Accuracy, Compensated/Amplified
8+ Package - M: SMT (Surface Mount Technology)
9+ Pressure port - AN: Single axial barbed port
10+ Options - N: Dry gasses only, no diagnostics
11+ Pressure range - 060PG: 0 psi to 60 psi
12+ Output type - 2: I2C, Address 0x28
13+ Transfer function - A: 10% to 90% of Vsupply (analog), 2^14 counts (digital)
14+ Supply voltage - 3: 3.3 Vdc
15+
16+ Pressure Range Specs:
17+ Pressure Range: 0 to 60 psi
18+ Over Pressure: 120 psi
19+ Burst Pressure: 240 psi
20+ Common Mode Pressure: 250 psi
21+ Total Error Band: ±2% FFS
22+ Long-term Stability: ±0.25% FFS
23+ */
24+
25+ #ifndef honeywellSSC_H
26+ #define honeywellSSC_H
27+ #include <stdint.h>
28+ #include <math.h>
29+
30+ // I2C DEVICE ADDRESS
31+ #define SSC_I2C_ADDR 0x28 // Output type 2
32+
33+ // STATUS BIT VALUES (bits S1 S0 from first byte)
34+ #define SSC_STATUS_NORMAL 0x00 // normal operation, valid data
35+ #define SSC_STATUS_COMMAND_MODE \
36+ 0x01 // used for programming, should not be seen in normal operation
37+ #define SSC_STATUS_STALE_DATA 0x02 // data is old
38+ #define SSC_STATUS_DIAGNOSTIC 0x03 // hardware error
39+
40+ // BIT MASKS
41+ #define SSC_STATUS_MASK 0xC000 // Bits 14-15 for 2-bit status in first 2 bytes
42+ #define SSC_PRESSURE_MASK \
43+ 0x3FFF // Bits 0-13 for 14-bit pressure data in first 2 bytes
44+ #define SSC_TEMP_MASK \
45+ 0xFFE0 // Bits 6-16 for 11-bit temperature data in last 2 bytes
46+
47+ #define SSC_DATA_LENGTH \
48+ 4 // first 2 bytes for pressure (and status), 2 bytes for temperature (and junk)
49+
50+ /*
51+ Pressure is calculated from the reading as:
52+ Pressure = ((output - output_min) * (pressure_max - pressure_min)) / (output_max - output_min) + pressure_min
53+ The following are the constants for that equation
54+ */
55+ // TRANSFER FUNCTION VALUES (2^14 counts)
56+ #define SSC_OUTPUT_MIN 0 // 0% of 2^14
57+ #define SSC_OUTPUT_MAX 16384 // 100% of 2^14
58+
59+ // PRESSURE RANGE VALUES (0 to 60 psi)
60+ #define SSC_PRESSURE_MIN 0.0f // 0 psi
61+ #define SSC_PRESSURE_MAX 60.0f // 60 psi
62+
63+ /*
64+ Temperature is calculated drom the reading as:
65+ Temperature (celcius) = (Output(dec)/2047 * 200) - 50
66+ The following are constants for that equation
67+ */
68+ // TEMPERATURE CONVERSION CONSTANTS
69+ #define SSC_TEMP_COUNTS_MAX 2047.0f // 11-bit max value
70+ #define SSC_TEMP_OFFSET -50.0f // Offset in equation
71+ #define SSC_TEMP_SCALE 200.0f // Scale factor in equation
72+
73+ // Function pointer
74+ typedef int (* ReadPtr )(
75+ uint16_t dev_addr , uint8_t * data ,
76+ uint16_t data_size ); // if data_size == 2: just reads pressure data, if data_size == 4 reads temp data too
77+ // I think the sensor is read-only so no WritePtr needed
78+
79+ // struct that records the current information
80+ typedef struct {
81+ uint16_t dev_addr ;
82+ ReadPtr read ;
83+ uint8_t min_pressure ;
84+ uint8_t max_pressure ;
85+ } honeywellSSC_t ;
86+
87+ // sets stuff up
88+ void honeywellSSC_init (honeywellSSC_t * ssc , ReadPtr read , uint16_t dev_addr ,
89+ uint8_t min_pressure , uint8_t max_pressure );
90+
91+ // Reads the data into the provided data pointer
92+ // expects honeywellSSC_t and a pointer to a uint8_t array of length 2 or 4
93+ int honeywellSSC_read_data (honeywellSSC_t * ssc , uint8_t * data ,
94+ uint8_t data_size );
95+
96+ // Reads the status message
97+ void honeywellSSC_read_status (uint16_t data , uint8_t * result );
98+
99+ // Reads the pressure in psi
100+ int honeywellSSC_read_pressure (honeywellSSC_t * ssc , float * result );
101+
102+ // Reads the temperature in celcius
103+ int honeywellSSC_read_temp (honeywellSSC_t * ssc , float * result );
104+
105+ #endif
0 commit comments