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