LibDriver BMM150
Loading...
Searching...
No Matches
driver_bmm150.c File Reference

driver bmm150 source file More...

#include "driver_bmm150.h"
Include dependency graph for driver_bmm150.c:

Go to the source code of this file.

Macros

#define CHIP_NAME   "Bosch BMM150"
 chip register definition
#define MANUFACTURER_NAME   "Bosch"
#define SUPPLY_VOLTAGE_MIN   1.62f
#define SUPPLY_VOLTAGE_MAX   3.6f
#define MAX_CURRENT   20.0f
#define TEMPERATURE_MIN   -40.0f
#define TEMPERATURE_MAX   85.0f
#define DRIVER_VERSION   1000
#define BMM150_REG_CHIP_ID   0x40
 chip register definition
#define BMM150_REG_DATA_X_LSB   0x42
#define BMM150_REG_DATA_X_MSB   0x43
#define BMM150_REG_DATA_Y_LSB   0x44
#define BMM150_REG_DATA_Y_MSB   0x45
#define BMM150_REG_DATA_Z_LSB   0x46
#define BMM150_REG_DATA_Z_MSB   0x47
#define BMM150_REG_RHALL_LSB   0x48
#define BMM150_REG_RHALL_MSB   0x49
#define BMM150_REG_INTERRUPT_STATUS   0x4A
#define BMM150_REG_CONFIG_0   0x4B
#define BMM150_REG_CONFIG_1   0x4C
#define BMM150_REG_CONFIG_2   0x4D
#define BMM150_REG_CONFIG_3   0x4E
#define BMM150_REG_LOW_THRESHOLD   0x4F
#define BMM150_REG_HIGH_THRESHOLD   0x50
#define BMM150_REG_REPXY   0x51
#define BMM150_REG_REPZ   0x52
#define BMM150_REG_DIG_X1   0x5D
 chip trim extended register definition
#define BMM150_REG_DIG_Y1   0x5E
#define BMM150_REG_DIG_Z4_LSB   0x62
#define BMM150_REG_DIG_Z4_MSB   0x63
#define BMM150_REG_DIG_X2   0x64
#define BMM150_REG_DIG_Y2   0x65
#define BMM150_REG_DIG_Z2_LSB   0x68
#define BMM150_REG_DIG_Z2_MSB   0x69
#define BMM150_REG_DIG_Z1_LSB   0x6A
#define BMM150_REG_DIG_Z1_MSB   0x6B
#define BMM150_REG_DIG_XYZ1_LSB   0x6C
#define BMM150_REG_DIG_XYZ1_MSB   0x6D
#define BMM150_REG_DIG_Z3_LSB   0x6E
#define BMM150_REG_DIG_Z3_MSB   0x6F
#define BMM150_REG_DIG_XY2   0x70
#define BMM150_REG_DIG_XY1   0x71

Functions

uint8_t bmm150_set_interface (bmm150_handle_t *handle, bmm150_interface_t interface)
 set the chip interface
uint8_t bmm150_get_interface (bmm150_handle_t *handle, bmm150_interface_t *interface)
 get the chip interface
uint8_t bmm150_set_addr_pin (bmm150_handle_t *handle, bmm150_address_t addr_pin)
 set the iic address pin
uint8_t bmm150_get_addr_pin (bmm150_handle_t *handle, bmm150_address_t *addr_pin)
 get the iic address pin
uint8_t bmm150_get_self_test_x (bmm150_handle_t *handle, bmm150_bool_t *enable)
 get self test x result
uint8_t bmm150_get_self_test_y (bmm150_handle_t *handle, bmm150_bool_t *enable)
 get self test y result
uint8_t bmm150_get_self_test_z (bmm150_handle_t *handle, bmm150_bool_t *enable)
 get self test z result
uint8_t bmm150_get_data_ready_status (bmm150_handle_t *handle, bmm150_bool_t *enable)
 get data ready status
uint8_t bmm150_get_interrupt_status (bmm150_handle_t *handle, bmm150_interrupt_status_t status, bmm150_bool_t *enable)
 get interrupt status
uint8_t bmm150_soft_reset (bmm150_handle_t *handle)
 soft reset
uint8_t bmm150_set_power_on (bmm150_handle_t *handle, bmm150_bool_t enable)
 set power on
uint8_t bmm150_get_power_on (bmm150_handle_t *handle, bmm150_bool_t *enable)
 get power on
uint8_t bmm150_set_spi_wire (bmm150_handle_t *handle, bmm150_spi_wire_t wire)
 set spi wire
uint8_t bmm150_get_spi_wire (bmm150_handle_t *handle, bmm150_spi_wire_t *wire)
 get spi wire
uint8_t bmm150_set_advanced_self_test (bmm150_handle_t *handle, bmm150_advanced_self_test_t test)
 set advanced self test
uint8_t bmm150_get_advanced_self_test (bmm150_handle_t *handle, bmm150_advanced_self_test_t *test)
 get advanced self test
uint8_t bmm150_set_data_rate (bmm150_handle_t *handle, bmm150_data_rate_t rate)
 set data rate
uint8_t bmm150_get_data_rate (bmm150_handle_t *handle, bmm150_data_rate_t *rate)
 get data rate
uint8_t bmm150_set_mode (bmm150_handle_t *handle, bmm150_mode_t mode)
 set mode
uint8_t bmm150_get_mode (bmm150_handle_t *handle, bmm150_mode_t *mode)
 get mode
uint8_t bmm150_set_self_test (bmm150_handle_t *handle, bmm150_bool_t enable)
 enable or disable self test
uint8_t bmm150_get_self_test (bmm150_handle_t *handle, bmm150_bool_t *enable)
 get self test status
uint8_t bmm150_set_interrupt (bmm150_handle_t *handle, bmm150_interrupt_status_t status, bmm150_bool_t enable)
 enable or disable interrupt
uint8_t bmm150_get_interrupt (bmm150_handle_t *handle, bmm150_interrupt_status_t status, bmm150_bool_t *enable)
 get interrupt status
uint8_t bmm150_set_data_ready_pin (bmm150_handle_t *handle, bmm150_bool_t enable)
 enable or disable data ready pin
uint8_t bmm150_get_data_ready_pin (bmm150_handle_t *handle, bmm150_bool_t *enable)
 get data ready pin status
uint8_t bmm150_set_interrupt_pin (bmm150_handle_t *handle, bmm150_bool_t enable)
 enable or disable interrupt pin
uint8_t bmm150_get_interrupt_pin (bmm150_handle_t *handle, bmm150_bool_t *enable)
 get interrupt pin status
uint8_t bmm150_set_channel_z (bmm150_handle_t *handle, bmm150_bool_t enable)
 enable or disable channel z
uint8_t bmm150_get_channel_z (bmm150_handle_t *handle, bmm150_bool_t *enable)
 get channel z status
uint8_t bmm150_set_channel_y (bmm150_handle_t *handle, bmm150_bool_t enable)
 enable or disable channel y
uint8_t bmm150_get_channel_y (bmm150_handle_t *handle, bmm150_bool_t *enable)
 get channel y status
uint8_t bmm150_set_channel_x (bmm150_handle_t *handle, bmm150_bool_t enable)
 enable or disable channel x
uint8_t bmm150_get_channel_x (bmm150_handle_t *handle, bmm150_bool_t *enable)
 get channel x status
uint8_t bmm150_set_data_ready_pin_polarity (bmm150_handle_t *handle, bmm150_data_ready_pin_polarity_t polarity)
 set data ready pin polarity
uint8_t bmm150_get_data_ready_pin_polarity (bmm150_handle_t *handle, bmm150_data_ready_pin_polarity_t *polarity)
 get data ready pin polarity
uint8_t bmm150_set_interrupt_latch (bmm150_handle_t *handle, bmm150_bool_t enable)
 enable or disable interrupt latch
uint8_t bmm150_get_interrupt_latch (bmm150_handle_t *handle, bmm150_bool_t *enable)
 get interrupt latch status
uint8_t bmm150_set_interrupt_pin_polarity (bmm150_handle_t *handle, bmm150_interrupt_pin_polarity_t polarity)
 set interrupt pin polarity
uint8_t bmm150_get_interrupt_pin_polarity (bmm150_handle_t *handle, bmm150_interrupt_pin_polarity_t *polarity)
 get interrupt pin polarity
uint8_t bmm150_set_low_threshold (bmm150_handle_t *handle, int8_t threshold)
 set low threshold
uint8_t bmm150_get_low_threshold (bmm150_handle_t *handle, int8_t *threshold)
 get low threshold
uint8_t bmm150_set_high_threshold (bmm150_handle_t *handle, int8_t threshold)
 set high threshold
uint8_t bmm150_get_high_threshold (bmm150_handle_t *handle, int8_t *threshold)
 get high threshold
uint8_t bmm150_set_repxy_number (bmm150_handle_t *handle, uint8_t number)
 set repxy number
uint8_t bmm150_get_repxy_number (bmm150_handle_t *handle, uint8_t *number)
 get repxy number
uint8_t bmm150_set_repz_number (bmm150_handle_t *handle, uint8_t number)
 set repz number
uint8_t bmm150_get_repz_number (bmm150_handle_t *handle, uint8_t *number)
 get repz number
uint8_t bmm150_read (bmm150_handle_t *handle, int16_t raw[3], float ut[3])
 read data
uint8_t bmm150_irq_handler (bmm150_handle_t *handle)
 irq handler
uint8_t bmm150_interrupt_threshold_convert_to_register (bmm150_handle_t *handle, float ut, int8_t *reg)
 convert the interrupt threshold to the register raw data
uint8_t bmm150_interrupt_threshold_convert_to_data (bmm150_handle_t *handle, int8_t reg, float *ut)
 convert the register raw data to the interrupt threshold
uint8_t bmm150_init (bmm150_handle_t *handle)
 initialize the chip
uint8_t bmm150_deinit (bmm150_handle_t *handle)
 close the chip
uint8_t bmm150_set_reg (bmm150_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
 set the chip register
uint8_t bmm150_get_reg (bmm150_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
 get the chip register
uint8_t bmm150_info (bmm150_info_t *info)
 get chip's information

Detailed Description

driver bmm150 source file

Copyright (c) 2015 - present LibDriver All rights reserved

The MIT License (MIT)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Version
1.0.0
Author
Shifeng Li
Date
2025-12-23

history

Date Version Author Description
2025/12/23 1.0 Shifeng Li first upload

Definition in file driver_bmm150.c.

Macro Definition Documentation

◆ BMM150_REG_CHIP_ID

#define BMM150_REG_CHIP_ID   0x40

chip register definition

chip id register

Definition at line 54 of file driver_bmm150.c.

◆ BMM150_REG_CONFIG_0

#define BMM150_REG_CONFIG_0   0x4B

config0 register

Definition at line 64 of file driver_bmm150.c.

◆ BMM150_REG_CONFIG_1

#define BMM150_REG_CONFIG_1   0x4C

config1 register

Definition at line 65 of file driver_bmm150.c.

◆ BMM150_REG_CONFIG_2

#define BMM150_REG_CONFIG_2   0x4D

config2 register

Definition at line 66 of file driver_bmm150.c.

◆ BMM150_REG_CONFIG_3

#define BMM150_REG_CONFIG_3   0x4E

config3 register

Definition at line 67 of file driver_bmm150.c.

◆ BMM150_REG_DATA_X_LSB

#define BMM150_REG_DATA_X_LSB   0x42

data x lsb register

Definition at line 55 of file driver_bmm150.c.

◆ BMM150_REG_DATA_X_MSB

#define BMM150_REG_DATA_X_MSB   0x43

data x msb register

Definition at line 56 of file driver_bmm150.c.

◆ BMM150_REG_DATA_Y_LSB

#define BMM150_REG_DATA_Y_LSB   0x44

data y lsb register

Definition at line 57 of file driver_bmm150.c.

◆ BMM150_REG_DATA_Y_MSB

#define BMM150_REG_DATA_Y_MSB   0x45

data y msb register

Definition at line 58 of file driver_bmm150.c.

◆ BMM150_REG_DATA_Z_LSB

#define BMM150_REG_DATA_Z_LSB   0x46

data z lsb register

Definition at line 59 of file driver_bmm150.c.

◆ BMM150_REG_DATA_Z_MSB

#define BMM150_REG_DATA_Z_MSB   0x47

data z msb register

Definition at line 60 of file driver_bmm150.c.

◆ BMM150_REG_DIG_X1

#define BMM150_REG_DIG_X1   0x5D

chip trim extended register definition

dig x1 register

Definition at line 76 of file driver_bmm150.c.

◆ BMM150_REG_DIG_X2

#define BMM150_REG_DIG_X2   0x64

dig x2 register

Definition at line 80 of file driver_bmm150.c.

◆ BMM150_REG_DIG_XY1

#define BMM150_REG_DIG_XY1   0x71

dig xy1 register

Definition at line 91 of file driver_bmm150.c.

◆ BMM150_REG_DIG_XY2

#define BMM150_REG_DIG_XY2   0x70

dig xy2 register

Definition at line 90 of file driver_bmm150.c.

◆ BMM150_REG_DIG_XYZ1_LSB

#define BMM150_REG_DIG_XYZ1_LSB   0x6C

dig xyz1 lsb register

Definition at line 86 of file driver_bmm150.c.

◆ BMM150_REG_DIG_XYZ1_MSB

#define BMM150_REG_DIG_XYZ1_MSB   0x6D

dig xyz1 msb register

Definition at line 87 of file driver_bmm150.c.

◆ BMM150_REG_DIG_Y1

#define BMM150_REG_DIG_Y1   0x5E

dig y1 register

Definition at line 77 of file driver_bmm150.c.

◆ BMM150_REG_DIG_Y2

#define BMM150_REG_DIG_Y2   0x65

dig y2 register

Definition at line 81 of file driver_bmm150.c.

◆ BMM150_REG_DIG_Z1_LSB

#define BMM150_REG_DIG_Z1_LSB   0x6A

dig z1 lsb register

Definition at line 84 of file driver_bmm150.c.

◆ BMM150_REG_DIG_Z1_MSB

#define BMM150_REG_DIG_Z1_MSB   0x6B

dig z1 msb register

Definition at line 85 of file driver_bmm150.c.

◆ BMM150_REG_DIG_Z2_LSB

#define BMM150_REG_DIG_Z2_LSB   0x68

dig z2 lsb register

Definition at line 82 of file driver_bmm150.c.

◆ BMM150_REG_DIG_Z2_MSB

#define BMM150_REG_DIG_Z2_MSB   0x69

dig z2 msb register

Definition at line 83 of file driver_bmm150.c.

◆ BMM150_REG_DIG_Z3_LSB

#define BMM150_REG_DIG_Z3_LSB   0x6E

dig z3 lsb register

Definition at line 88 of file driver_bmm150.c.

◆ BMM150_REG_DIG_Z3_MSB

#define BMM150_REG_DIG_Z3_MSB   0x6F

dig z3 msb register

Definition at line 89 of file driver_bmm150.c.

◆ BMM150_REG_DIG_Z4_LSB

#define BMM150_REG_DIG_Z4_LSB   0x62

dig z4 lsb register

Definition at line 78 of file driver_bmm150.c.

◆ BMM150_REG_DIG_Z4_MSB

#define BMM150_REG_DIG_Z4_MSB   0x63

dig z4 msb register

Definition at line 79 of file driver_bmm150.c.

◆ BMM150_REG_HIGH_THRESHOLD

#define BMM150_REG_HIGH_THRESHOLD   0x50

high threshold register

Definition at line 69 of file driver_bmm150.c.

◆ BMM150_REG_INTERRUPT_STATUS

#define BMM150_REG_INTERRUPT_STATUS   0x4A

interrupt status register

Definition at line 63 of file driver_bmm150.c.

◆ BMM150_REG_LOW_THRESHOLD

#define BMM150_REG_LOW_THRESHOLD   0x4F

low threshold register

Definition at line 68 of file driver_bmm150.c.

◆ BMM150_REG_REPXY

#define BMM150_REG_REPXY   0x51

repxy register

Definition at line 70 of file driver_bmm150.c.

◆ BMM150_REG_REPZ

#define BMM150_REG_REPZ   0x52

repz register

Definition at line 71 of file driver_bmm150.c.

◆ BMM150_REG_RHALL_LSB

#define BMM150_REG_RHALL_LSB   0x48

rhall lsb register

Definition at line 61 of file driver_bmm150.c.

◆ BMM150_REG_RHALL_MSB

#define BMM150_REG_RHALL_MSB   0x49

rhall msb register

Definition at line 62 of file driver_bmm150.c.

◆ CHIP_NAME

#define CHIP_NAME   "Bosch BMM150"

chip register definition

chip name

Definition at line 42 of file driver_bmm150.c.

◆ DRIVER_VERSION

#define DRIVER_VERSION   1000

driver version

Definition at line 49 of file driver_bmm150.c.

◆ MANUFACTURER_NAME

#define MANUFACTURER_NAME   "Bosch"

manufacturer name

Definition at line 43 of file driver_bmm150.c.

◆ MAX_CURRENT

#define MAX_CURRENT   20.0f

chip max current

Definition at line 46 of file driver_bmm150.c.

◆ SUPPLY_VOLTAGE_MAX

#define SUPPLY_VOLTAGE_MAX   3.6f

chip max supply voltage

Definition at line 45 of file driver_bmm150.c.

◆ SUPPLY_VOLTAGE_MIN

#define SUPPLY_VOLTAGE_MIN   1.62f

chip min supply voltage

Definition at line 44 of file driver_bmm150.c.

◆ TEMPERATURE_MAX

#define TEMPERATURE_MAX   85.0f

chip max operating temperature

Definition at line 48 of file driver_bmm150.c.

◆ TEMPERATURE_MIN

#define TEMPERATURE_MIN   -40.0f

chip min operating temperature

Definition at line 47 of file driver_bmm150.c.