English | 简体中文 | 繁體中文 | 日本語 | Deutsch | 한국어
LibDriver BMP388
The BMP388 is a digital sensor with pressure and temperature measurement based on proven sensing principles.The sensor module is housed in an extremely compact 10-pin metal-lid LGA package with a footprint only 2.0 x 2.0 mm2 and max 0.8 mm package height. Its small dimensions and its low power consumption of 3.4 uA@1Hz allow the implementation in battery driven devices such as mobile phones ,GPS modules or watches.
LibDriver BMP388 is a full-featured driver for BMP388, launched by LibDriver.It provides continuous reading, single reading, interrupt reading, FIFO acquisition and additional features. LibDriver is MISRA compliant.
Table of Contents
Instruction
/src includes LibDriver BMP388 source files.
/interface includes LibDriver BMP388 IIC, SPI platform independent template.
/test includes LibDriver BMP388 driver test code and this code can test the chip necessary function simply.
/example includes LibDriver BMP388 sample code.
/doc includes LibDriver BMP388 offline document.
/datasheet includes BMP388 datasheet.
/project includes the common Linux and MCU development board sample code. All projects use the shell script to debug the driver and the detail instruction can be found in each project's README.md.
/misra includes the LibDriver MISRA code scanning results.
Install
Reference /interface IIC, SPI platform independent template and finish your platform IIC, SPI driver.
Add the /src directory, the interface driver for your platform, and your own drivers to your project, if you want to use the default example drivers, add the /example directory to your project.
Usage
You can refer to the examples in the /example directory to complete your own driver. If you want to use the default programming examples, here's how to use them.
example basic
#include "driver_bmp388_basic.h"
uint8_t res;
uint8_t i;
float temperature_c;
float pressure_pa;
res = bmp388_basic_init(BMP388_INTERFACE_IIC, BMP388_ADDRESS_ADO_LOW);
if (res != 0)
{
return 1;
}
...
for (i = 0; i < 3; i++)
{
bmp388_interface_delay_ms(1000);
res = bmp388_basic_read((float *)&temperature_c, (float *)&pressure_pa);
if (res != 0)
{
(void)bmp388_basic_deinit();
return 1;
}
bmp388_interface_debug_print("bmp388: temperature is %0.2fC.\n", temperature_c);
bmp388_interface_debug_print("bmp388: pressure is %0.2fPa.\n", pressure_pa);
...
}
...
(void)bmp388_basic_deinit();
return 0;
example shot
#include "driver_bmp388_shot.h"
uint8_t res;
uint8_t i;
float temperature_c;
float pressure_pa;
res = bmp388_shot_init(BMP388_INTERFACE_IIC, BMP388_ADDRESS_ADO_LOW);
if (res != 0)
{
return 1;
}
...
for (i = 0; i < 3; i++)
{
bmp388_interface_delay_ms(1000);
res = bmp388_shot_read((float *)&temperature_c, (float *)&pressure_pa);
if (res != 0)
{
(void)bmp388_shot_deinit();
return 1;
}
bmp388_interface_debug_print("bmp388: temperature is %0.2fC.\n", temperature_c);
bmp388_interface_debug_print("bmp388: pressure is %0.2fPa.\n", pressure_pa);
...
}
...
(void)bmp388_shot_deinit();
return 0;
example interrupt
#include "driver_bmp388_interrupt.h"
uint8_t res;
uint16_t i, timeout;
uint8_t gs_data_ready_flag;
float gs_temperature_c;
float gs_pressure_pa;
void bmp388_interrupt_receive_callback(uint8_t type)
{
switch (type)
{
case BMP388_INTERRUPT_STATUS_FIFO_WATERMARK :
{
break;
}
case BMP388_INTERRUPT_STATUS_FIFO_FULL :
{
break;
}
case BMP388_INTERRUPT_STATUS_DATA_READY :
{
/* read temperature pressure */
if (bmp388_interrupt_read((float *)&gs_temperature_c, (float *)&gs_pressure_pa) != 0)
{
bmp388_interface_debug_print("bmp388: read temperature and pressure failed.\n");
return;
}
gs_data_ready_flag = 1;
break;
}
default :
{
break;
}
}
}
res = gpio_interrupt_init();
if (res != 0)
{
return 1;
}
res = bmp388_interrupt_init(BMP388_INTERFACE_IIC, BMP388_ADDRESS_ADO_LOW, bmp388_interrupt_receive_callback);
if (res != 0)
{
(void)gpio_interrupt_deinit();
return 1;
}
...
gs_data_ready_flag = 0;
timeout = 5000;
for (i = 0; i < 3; i++)
{
while (timeout != 0)
{
bmp388_interface_delay_ms(100);
timeout--;
if (gs_data_ready_flag != 0)
{
break;
}
if (timeout == 0)
{
(void)gpio_interrupt_deinit();
(void)bmp388_interrupt_deinit();
return 1;
}
}
gs_data_ready_flag = 0;
timeout = 5000;
bmp388_interface_debug_print("bmp388: temperature is %0.2fC.\n", gs_temperature_c);
bmp388_interface_debug_print("bmp388: pressure is %0.2fPa.\n", gs_pressure_pa);
...
}
...
(void)gpio_interrupt_deinit();
(void)bmp388_interrupt_deinit();
return 0;
example fifo