55 uint16_t pressure = 0x0000;
61 pressure = (uint16_t) (press_msb << 8);
62 pressure &= (0xFF00 | ((uint16_t) (press_lsb)));
63 pressure = 0x03FF & (pressure >> 6);
71 uint16_t temperature = 0x0000;
78 temperature = (uint16_t) (temp_msb << 8);
79 temperature &= (0xFF00 | ((uint16_t) (temp_lsb)));
80 temperature = 0x03FF & (temperature >> 6);
85 mpl115a_read_coefficients(
void) {
90 for (i = 0; i < 6; i++) {
91 coeff_tmp_msb =
mpl115a_cmd(coefficients[i].addr[0]);
92 coeff_tmp_lsb =
mpl115a_cmd(coefficients[i].addr[1]);
93 uart_TXchar(coeff_tmp_msb);
94 uart_TXchar(coeff_tmp_lsb);
97 coefficients[i].value = (int16_t) (coeff_tmp_msb << 8);
98 coefficients[i].value &= (0xFF00 | ((int16_t) (coeff_tmp_lsb)));
104 mpl115a_get_Pcomp(
void) {
105 int32_t tmp1_val, tmp2_val, tmp3_val;
108 uint16_t temperature = 0x0000;
109 uint16_t pressure = 0x0000;
118 temperature = (uint16_t) (msb << 8);
119 temperature &= (0xFF00 | ((uint16_t) (lsb)));
120 temperature = 0x03FF & (temperature >> 6);
124 pressure = (uint16_t) (msb << 8);
125 pressure &= (0xFF00 | ((uint16_t) (lsb)));
126 pressure = 0x03FF & (pressure >> 6);
130 tmp1_val = (int32_t) coefficients[MPL115A_C11].value;
131 tmp2_val = (int32_t) pressure;
133 tmp3_val = tmp1_val * tmp2_val;
135 tmp1_val = (int32_t) (coefficients[MPL115A_B1].value << 14);
136 tmp2_val = (int32_t) tmp3_val;
137 tmp3_val = tmp1_val + tmp2_val;
139 tmp_help = (int32_t) (tmp3_val >> 14);
141 tmp1_val = (int32_t) coefficients[MPL115A_C12].value;
142 tmp2_val = (int32_t) temperature;
144 tmp3_val = tmp1_val * tmp2_val;
146 tmp1_val = (int32_t) (tmp_help << 11);
147 tmp2_val = (int32_t) tmp3_val;
148 tmp3_val = tmp1_val + tmp2_val;
150 tmp_help = (int32_t) (tmp3_val >> 11);
152 tmp1_val = (int32_t) coefficients[MPL115A_C22].value;
153 tmp2_val = (int32_t) temperature;
155 tmp3_val = tmp1_val * tmp2_val;
157 tmp1_val = (int32_t) (coefficients[MPL115A_B2].value << 15);
158 tmp2_val = (int32_t) (tmp3_val >> 1);
159 tmp3_val = tmp1_val + tmp2_val;
161 tmp1_val = (int32_t) tmp_help;
163 tmp_help = (int32_t) (tmp3_val >> 16);
164 tmp2_val = (int32_t) pressure;
166 tmp3_val = tmp1_val * tmp2_val;
168 tmp1_val = (int32_t) (coefficients[MPL115A_A0].value << 10);
169 tmp2_val = (int32_t) tmp3_val;
170 tmp3_val = tmp1_val + tmp2_val;
172 tmp1_val = (int32_t) tmp_help;
174 tmp_help = (int32_t) (tmp3_val >> 10);
175 tmp2_val = (int32_t) temperature;
177 tmp3_val = tmp1_val * tmp2_val;
179 tmp1_val = (int32_t) (tmp_help << 10);
180 tmp2_val = (int32_t) tmp3_val;
181 tmp3_val = tmp1_val + tmp2_val;
183 return (int16_t) (tmp3_val >> 13);