Rev 20 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 20 | Rev 21 | ||
---|---|---|---|
Line 48... | Line 48... | ||
48 | user_delay_ms(uint32_t ms) |
48 | user_delay_ms(uint32_t ms) |
49 | { |
49 | { |
50 | HAL_Delay(ms); |
50 | HAL_Delay(ms); |
51 | } |
51 | } |
52 | 52 | ||
53 | struct bmp280_dev bmp = |
53 | struct bmp280_dev bmpManifold = |
54 | { |
54 | { |
55 | .intf = BMP280_I2C_INTF, |
55 | .intf = BMP280_I2C_INTF, |
56 | .read = user_i2c_read, |
56 | .read = user_i2c_read, |
57 | .write = user_i2c_write, |
57 | .write = user_i2c_write, |
58 | .delay_ms = user_delay_ms, |
58 | .delay_ms = user_delay_ms, |
59 | 59 | ||
60 | /* Update interface pointer with the structure that contains both device address and file descriptor */ |
60 | /* Update interface pointer with the structure that contains both device address and file descriptor */ |
61 | .dev_id = BMP280_I2C_ADDR_PRIM}; |
61 | .dev_id = BMP280_I2C_ADDR_PRIM}; |
62 | 62 | ||
63 | struct bmp280_dev bmpAtm = |
63 | struct bmp280_dev bmpAtmosphere = |
64 | { |
64 | { |
65 | .intf = BMP280_I2C_INTF, |
65 | .intf = BMP280_I2C_INTF, |
66 | .read = user_i2c_read, |
66 | .read = user_i2c_read, |
67 | .write = user_i2c_write, |
67 | .write = user_i2c_write, |
68 | .delay_ms = user_delay_ms, |
68 | .delay_ms = user_delay_ms, |
69 | 69 | ||
70 | /* Update interface pointer with the structure that contains both device address and file descriptor */ |
70 | /* Update interface pointer with the structure that contains both device address and file descriptor */ |
71 | .dev_id = BMP280_I2C_ADDR_SEC}; |
71 | .dev_id = BMP280_I2C_ADDR_SEC}; |
72 | 72 | ||
- | 73 | // config for manifold sensor |
|
73 | struct bmp280_config conf; |
74 | struct bmp280_config confManifold; |
- | 75 | // config for atmospheric sensor |
|
- | 76 | struct bmp280_config confAtmosphere; |
|
74 | 77 | ||
75 | uint8_t init_bmp(I2C_HandleTypeDef *i2c,struct bmp280_dev * bmp) |
78 | uint8_t init_bmp(I2C_HandleTypeDef *i2c,struct bmp280_dev * bmp,struct bmp280_config *conf) |
76 | { |
79 | { |
77 | // copy the I2c handle over |
80 | // copy the I2c handle over |
78 | hi2c = i2c; |
81 | hi2c = i2c; |
79 | int8_t rslt = bmp280_init(bmp); |
82 | int8_t rslt = bmp280_init(bmp); |
80 | if (rslt != BMP280_OK) |
83 | if (rslt != BMP280_OK) |
81 | return rslt; |
84 | return rslt; |
82 | 85 | ||
83 | rslt = bmp280_get_config(&conf, bmp); |
86 | rslt = bmp280_get_config(conf, bmp); |
84 | if (rslt != BMP280_OK) |
87 | if (rslt != BMP280_OK) |
85 | return rslt; |
88 | return rslt; |
86 | /* configuring the temperature oversampling, filter coefficient and output data rate */ |
89 | /* configuring the temperature oversampling, filter coefficient and output data rate */ |
87 | /* Overwrite the desired settings */ |
90 | /* Overwrite the desired settings */ |
88 | conf.filter = BMP280_FILTER_COEFF_4; |
91 | conf->filter = BMP280_FILTER_COEFF_4; |
89 | 92 | ||
90 | /* Temperature oversampling set at 1x */ |
93 | /* Temperature oversampling set at 1x */ |
91 | conf.os_temp = BMP280_OS_1X; |
94 | conf->os_temp = BMP280_OS_1X; |
92 | 95 | ||
93 | /* Pressure over sampling 4x */ |
96 | /* Pressure over sampling 4x */ |
94 | conf.os_pres = BMP280_OS_4X; |
97 | conf->os_pres = BMP280_OS_4X; |
95 | 98 | ||
96 | /* Setting the output data rate as 8HZ(500ms) */ |
99 | /* Setting the output data rate as 8HZ(500ms) */ |
97 | conf.odr = BMP280_ODR_125_MS; |
100 | conf->odr = BMP280_ODR_125_MS; |
98 | rslt = bmp280_set_config(&conf, bmp); |
101 | rslt = bmp280_set_config(conf, bmp); |
99 | if (rslt != BMP280_OK) |
102 | if (rslt != BMP280_OK) |
100 | return rslt; |
103 | return rslt; |
101 | 104 | ||
102 | /* Always set the power mode after setting the configuration */ |
105 | /* Always set the power mode after setting the configuration */ |
103 | rslt = bmp280_set_power_mode(BMP280_NORMAL_MODE, bmp); |
106 | rslt = bmp280_set_power_mode(BMP280_NORMAL_MODE, bmp); |