94 lines
2.3 KiB
C
94 lines
2.3 KiB
C
#include "board.h"
|
|
#include "clock_config.h"
|
|
#include "peripherals.h"
|
|
#include "pin_mux.h"
|
|
|
|
/* Debug console */
|
|
#include "fsl_debug_console.h"
|
|
|
|
/* Utils */
|
|
#include "util_systick.h"
|
|
|
|
/* Sensors */
|
|
#include "imsensors/dht/dht_bme280.h"
|
|
#include "imsensors/ppg/ppg_pah8001.h"
|
|
|
|
ims_ret_t sensors_impl_i2c_xfer(void *pdev, ims_i2c_xfer_desc_t *xfer);
|
|
ims_ret_t sensors_impl_delay(void *pdev, uint32_t msec);
|
|
|
|
ims_pah8001_t s_pah = {
|
|
.pdev = (void *)0x33,
|
|
.cb =
|
|
{
|
|
.i2c_xfer = sensors_impl_i2c_xfer,
|
|
.delay = sensors_impl_delay,
|
|
},
|
|
};
|
|
|
|
ims_bme280_t s_bme = {
|
|
.pdev = (void *)0x77,
|
|
.cb =
|
|
{
|
|
.i2c_xfer = sensors_impl_i2c_xfer,
|
|
.delay = sensors_impl_delay,
|
|
},
|
|
};
|
|
|
|
ims_bme280_t s_bmp = {
|
|
.pdev = (void *)0x76,
|
|
.cb =
|
|
{
|
|
.i2c_xfer = sensors_impl_i2c_xfer,
|
|
.delay = sensors_impl_delay,
|
|
},
|
|
};
|
|
|
|
int main(void) {
|
|
BOARD_InitBootPins();
|
|
BOARD_InitBootClocks();
|
|
BOARD_InitBootPeripherals();
|
|
|
|
BOARD_InitDebugConsole();
|
|
|
|
util_systick_init();
|
|
|
|
PRINTF("Hello world!!\r\n");
|
|
|
|
ims_pah8001_init(&s_pah);
|
|
|
|
ims_pah8001_power(&s_pah, true);
|
|
|
|
ims_bme280_init(&s_bme);
|
|
ims_bme280_init(&s_bmp);
|
|
|
|
ims_bme280_config_t dht_cfg;
|
|
|
|
ims_bme280_preset_config(&dht_cfg, IMS_BME280_PRESET_WEATHER);
|
|
ims_bme280_config(&s_bme, &dht_cfg);
|
|
ims_bme280_config(&s_bmp, &dht_cfg);
|
|
ims_bme280_result_t r_bme_float;
|
|
ims_bme280_result_t r_bmp_float;
|
|
|
|
bool ppg_touched;
|
|
uint8_t hr_alg;
|
|
|
|
for (;;) {
|
|
ims_bme280_read_forced(&s_bme, &r_bme_float);
|
|
ims_bme280_read_forced(&s_bmp, &r_bmp_float);
|
|
|
|
ims_pah8001_touched(&s_pah, &ppg_touched);
|
|
|
|
if(ppg_touched) {
|
|
ims_pah8001_read_alg_hr(&s_pah, IMS_PPG_ALG_A, &hr_alg);
|
|
PRINTF("PPG: Touched, ALG_A: %d, ", hr_alg);
|
|
ims_pah8001_read_alg_hr(&s_pah, IMS_PPG_ALG_C, &hr_alg);
|
|
PRINTF("ALG_C: %d\r\n", hr_alg);
|
|
}
|
|
|
|
PRINTF("BME: %03.02f %03.02f %05.02f\r\n", r_bme_float.temperature, r_bme_float.humidity, r_bme_float.pressure);
|
|
PRINTF("BMP: %03.02f --.-- %05.02f\r\n", r_bmp_float.temperature, r_bmp_float.pressure);
|
|
|
|
util_systick_delay(100);
|
|
GPIO_PortToggle(BOARD_INITPINS_LED_R_GPIO, BOARD_INITPINS_LED_R_PORT, BOARD_INITPINS_LED_R_GPIO_PIN_MASK);
|
|
}
|
|
} |