Detailed Description

Driver for the Silicon Labs Si7210 Hall effect sensor.

Macros

#define SI7210_OTP_ADDR_BASE_PART_NUMBER 0x14
#define SI7210_OTP_ADDR_BPERVCAL 0x20
#define SI7210_OTP_ADDR_COEFFS_200MT 0x27
#define SI7210_OTP_ADDR_COEFFS_200MT_CERAMIC 0x3F
#define SI7210_OTP_ADDR_COEFFS_200MT_NEODYMIUM 0x33
#define SI7210_OTP_ADDR_COEFFS_20MT 0x21
#define SI7210_OTP_ADDR_COEFFS_20MT_CERAMIC 0x39
#define SI7210_OTP_ADDR_COEFFS_20MT_NEODYMIUM 0x2D
#define SI7210_OTP_ADDR_CTRL1 0x04
#define SI7210_OTP_ADDR_CTRL2 0x05
#define SI7210_OTP_ADDR_CTRL3 0x08
#define SI7210_OTP_ADDR_CTRL4 0x0C
#define SI7210_OTP_ADDR_POWER_UP_A0 0x09
#define SI7210_OTP_ADDR_POWER_UP_A1 0x0A
#define SI7210_OTP_ADDR_POWER_UP_A2 0x0B
#define SI7210_OTP_ADDR_POWER_UP_A3 0x0D
#define SI7210_OTP_ADDR_POWER_UP_A4 0x0E
#define SI7210_OTP_ADDR_POWER_UP_A5 0x0F
#define SI7210_OTP_ADDR_SERIAL_NUMBER 0x18
#define SI7210_OTP_ADDR_SLTIME 0x06
#define SI7210_OTP_ADDR_VARIANT 0x15
#define SI7210_REG_ADDR_A0 0xCA
#define SI7210_REG_ADDR_A1 0xCB
#define SI7210_REG_ADDR_A2 0xCC
#define SI7210_REG_ADDR_A3 0xCE
#define SI7210_REG_ADDR_A4 0xCF
#define SI7210_REG_ADDR_A5 0xD0
#define SI7210_REG_ADDR_ARAUTOINC 0xC5
#define SI7210_REG_ADDR_CTRL1 0xC6
#define SI7210_REG_ADDR_CTRL2 0xC7
#define SI7210_REG_ADDR_CTRL3 0xC9
#define SI7210_REG_ADDR_CTRL4 0xCD
#define SI7210_REG_ADDR_DSPSIGL 0xC2
#define SI7210_REG_ADDR_DSPSIGM 0xC1
#define SI7210_REG_ADDR_DSPSIGSEL 0xC3
#define SI7210_REG_ADDR_HREVID 0xC0
#define SI7210_REG_ADDR_OTP_ADDR 0xE1
#define SI7210_REG_ADDR_OTP_CTRL 0xE3
#define SI7210_REG_ADDR_OTP_DATA 0xE2
#define SI7210_REG_ADDR_POWER_CTRL 0xC4
#define SI7210_REG_ADDR_SLTIME 0xC8
#define SI7210_REG_ADDR_TM_FG 0xE4
#define SI7210_REG_CTRL1_SW_LOW4FIELD_MASK 0x80
#define SI7210_REG_CTRL1_SW_LOW4FIELD_SHIFT 7
#define SI7210_REG_CTRL1_SW_OP_MASK 0x7F
#define SI7210_REG_CTRL1_SW_OP_SHIFT 0
#define SI7210_REG_CTRL2_SW_FIELDPOLSEL_MASK 0xC0
#define SI7210_REG_CTRL2_SW_FIELDPOLSEL_SHIFT 6
#define SI7210_REG_CTRL2_SW_HYST_MASK 0x3F
#define SI7210_REG_CTRL2_SW_HYST_SHIFT 0
#define SI7210_REG_CTRL3_SLFAST_MASK 0x02
#define SI7210_REG_CTRL3_SLFAST_SHIFT 1
#define SI7210_REG_CTRL3_SLTIMEENA_MASK 0x01
#define SI7210_REG_CTRL3_SLTIMEENA_SHIFT 0
#define SI7210_REG_CTRL3_SW_TAMPER_MASK 0xFC
#define SI7210_REG_CTRL3_SW_TAMPER_SHIFT 2
#define SI7210_REG_CTRL4_DF_BURSTSIZE_MASK 0x0E
#define SI7210_REG_CTRL4_DF_BURSTSIZE_SHIFT 5
#define SI7210_REG_CTRL4_DF_BW_MASK 0x1E
#define SI7210_REG_CTRL4_DF_BW_SHIFT 1
#define SI7210_REG_CTRL4_IIR_MASK 0x01
#define SI7210_REG_CTRL4_IIR_SHIFT 0
#define SI7210_REG_DSPSIGM_DSPSIGM_MASK 0x7F
#define SI7210_REG_DSPSIGM_DSPSIGM_SHIFT 0
#define SI7210_REG_DSPSIGM_FRESH_MASK 0x80
#define SI7210_REG_DSPSIGM_FRESH_SHIFT 7
#define SI7210_REG_HREVID_CHIPID_MASK 0xF0
#define SI7210_REG_HREVID_CHIPID_SHIFT 4
#define SI7210_REG_HREVID_REVID_MASK 0x0F
#define SI7210_REG_HREVID_REVID_SHIFT 0
#define SI7210_REG_OTP_CTRL_BUSY_MASK 0x01
#define SI7210_REG_OTP_CTRL_BUSY_SHIFT 0
#define SI7210_REG_OTP_CTRL_READ_EN_MASK 0x02
#define SI7210_REG_OTP_CTRL_READ_EN_SHIFT 1
#define SI7210_REG_POWER_CTRL_MEAS_MASK 0x80
#define SI7210_REG_POWER_CTRL_MEAS_SHIFT 7
#define SI7210_REG_POWER_CTRL_ONEBURST_MASK 0x04
#define SI7210_REG_POWER_CTRL_ONEBURST_SHIFT 2
#define SI7210_REG_POWER_CTRL_SLEEP_MASK 0x01
#define SI7210_REG_POWER_CTRL_SLEEP_SHIFT 0
#define SI7210_REG_POWER_CTRL_STOP_MASK 0x02
#define SI7210_REG_POWER_CTRL_STOP_SHIFT 1
#define SI7210_REG_POWER_CTRL_USESTORE_MASK 0x08
#define SI7210_REG_POWER_CTRL_USESTORE_SHIFT 3

Functions

uint8_t SI7210_calculateSlTime (uint32_t samplePeriod, uint8_t *slFast)
Calculates the slTime value from the sleep time by finding the inverse of the formula: tsleep = (32 + slTime[4:0]) * 2^(8 + slTime[7:5]) / 12 MHz.
uint8_t SI7210_calculateSWHYST (float hysteresis, bool scale200mT)
Calculates the sw_hyst value from the hysteresis by finding the inverse of the formula: hysteresis = (8 + sw_hyst[2:0]) * 2^sw_hyst[5:3].
uint8_t SI7210_calculateSWOP (float threshold)
Calculates the sw_op value from the threshold by finding the inverse of the formula: threshold = (16 + sw_op[3:0]) * 2^sw_op[6:4].
uint8_t SI7210_calculateSWTAMPER (float tamper, bool scale200mT)
Calculates the sw_tamper value from the tamper threshold by finding the inverse of the formula: tamper = (16 + sw_tamper[3:0]) * 2^(sw_tamper[5:4] + 5)
uint32_t SI7210_dataRead (int16_t *data)
Read out Si7210 Conversion Data - 15bits.
uint32_t SI7210_enterContMode (void)
Puts sensor into continuous mode, conversions performed every 7usec.
uint32_t SI7210_identify (uint8_t *id, uint8_t *rev)
Read out Si7210 Revision and ID.
static uint32_t SI7210_loadCoeffsFromOtp (uint8_t otpAddr)
Loads the coefficients A0..A6 from the OTP memory.
uint32_t SI7210_readmTDataSleep (bool range200mT, int32_t *mTdata)
Wake-up from Sleep, perform burst-conversion(4samples), read mT-data, and then put part into sleep mode (no-measurement). Requires Wake-Up.
uint32_t SI7210_readmTDataSltimeena (bool range200mT, int32_t *mTdata)
Perform burst-conversion(4samples), read mT-data, and then put part into sltimeena-sleep mode where OUT is updated every 200msec.
uint32_t SI7210_regClearBits (uint8_t addr, uint8_t mask)
Clears the given bit(s) in a register in the Hall sensor device.
uint32_t SI7210_registerRead (uint8_t addr, uint8_t *data)
Reads register from the Hall sensor device.
uint32_t SI7210_registerWrite (uint8_t addr, uint8_t data)
Writes a register in the Hall sensor device.
uint32_t SI7210_regReadOTP (uint8_t otpAddr, uint8_t *otpData)
Reads register from the OTP area of the Si7021 device.
uint32_t SI7210_regSetBits (uint8_t addr, uint8_t mask)
Sets the given bit(s) in a register in the Hall sensor device.
uint32_t SI7210_set200mTRange (void)
Change Mag-Field scale to 200mT. If desired, must be performed after power-up or wake-up from sleep.
uint32_t SI7210_sleep (void)
Puts Si7210 into Sleep (No-measurement) Mode Wake-up command needs to be issued to become responsive.
uint32_t SI7210_sleepSltimeena (void)
Puts Si7210 into Sleep w/ Measurement Mode: OUTPUT is updated 200msec.
uint32_t SI7210_wakeUp (void)
Wakes up the Hall sensor chip.

Error Codes

#define SI7210_OK 0
#define SI7210_ERROR_I2C_TRANSFER_FAILED 0x0001
#define SI7210_ERROR_INVALID_DEVICE_ID 0x0002
#define SI7210_ERROR_CONFIG_INVALID_MODE 0x0003
#define SI7210_ERROR_OTP_BUSY 0x0004
#define SI7210_ERROR_READ_TIMEOUT 0x0005
#define SI7210_ERROR_NODATA 0x0006

Macro Definition Documentation

#define SI7210_ERROR_CONFIG_INVALID_MODE   0x0003

The chosen configuration is invalid

Definition at line 59 of file hall_si7210.h .

#define SI7210_ERROR_I2C_TRANSFER_FAILED   0x0001

I2C transaction failed

Definition at line 57 of file hall_si7210.h .

#define SI7210_ERROR_INVALID_DEVICE_ID   0x0002

The device ID is invalid

Definition at line 58 of file hall_si7210.h .

#define SI7210_ERROR_NODATA   0x0006

No measurement data available

Definition at line 62 of file hall_si7210.h .

Referenced by SI7210_dataRead() .

#define SI7210_ERROR_OTP_BUSY   0x0004

The OTP memory is busy

Definition at line 60 of file hall_si7210.h .

Referenced by SI7210_regReadOTP() .

#define SI7210_ERROR_READ_TIMEOUT   0x0005

Timeout occurred during read operation

Definition at line 61 of file hall_si7210.h .

#define SI7210_OK   0

No errors

Definition at line 56 of file hall_si7210.h .

Referenced by SI7210_loadCoeffsFromOtp() , and SI7210_set200mTRange() .

#define SI7210_OTP_ADDR_BASE_PART_NUMBER   0x14

OTP Base part number

Definition at line 132 of file hall_si7210_regs.h .

#define SI7210_OTP_ADDR_BPERVCAL   0x20

OTP On-chip field generator calibration value

Definition at line 135 of file hall_si7210_regs.h .

#define SI7210_OTP_ADDR_COEFFS_200MT   0x27

OTP 200mT scale no magnet temperature compensation value

Definition at line 138 of file hall_si7210_regs.h .

Referenced by SI7210_set200mTRange() .

#define SI7210_OTP_ADDR_COEFFS_200MT_CERAMIC   0x3F

OTP 200mT scale ceramic magnet temperature compensation value

Definition at line 142 of file hall_si7210_regs.h .

#define SI7210_OTP_ADDR_COEFFS_200MT_NEODYMIUM   0x33

OTP 200mT scale neodymium temperature compensation value

Definition at line 140 of file hall_si7210_regs.h .

#define SI7210_OTP_ADDR_COEFFS_20MT   0x21

OTP 20mT scale no magnet temperature compensation value

Definition at line 137 of file hall_si7210_regs.h .

#define SI7210_OTP_ADDR_COEFFS_20MT_CERAMIC   0x39

OTP 20mT scale ceramic magnet temperature compensation value

Definition at line 141 of file hall_si7210_regs.h .

#define SI7210_OTP_ADDR_COEFFS_20MT_NEODYMIUM   0x2D

OTP 20mT scale neodymium magnet temperature compensation value

Definition at line 139 of file hall_si7210_regs.h .

#define SI7210_OTP_ADDR_CTRL1   0x04

OTP Control register 1, output pin configuration

Definition at line 121 of file hall_si7210_regs.h .

#define SI7210_OTP_ADDR_CTRL2   0x05

OTP Control register 2, output pin configuration

Definition at line 122 of file hall_si7210_regs.h .

#define SI7210_OTP_ADDR_CTRL3   0x08

OTP Control register 3, output pin and sleep time configuration

Definition at line 124 of file hall_si7210_regs.h .

#define SI7210_OTP_ADDR_CTRL4   0x0C

OTP Control register 4, Digital filter configuration

Definition at line 128 of file hall_si7210_regs.h .

#define SI7210_OTP_ADDR_POWER_UP_A0   0x09

OTP Coefficient A0

Definition at line 125 of file hall_si7210_regs.h .

#define SI7210_OTP_ADDR_POWER_UP_A1   0x0A

OTP Coefficient A1

Definition at line 126 of file hall_si7210_regs.h .

#define SI7210_OTP_ADDR_POWER_UP_A2   0x0B

OTP Coefficient A2

Definition at line 127 of file hall_si7210_regs.h .

#define SI7210_OTP_ADDR_POWER_UP_A3   0x0D

OTP Coefficient A3

Definition at line 129 of file hall_si7210_regs.h .

#define SI7210_OTP_ADDR_POWER_UP_A4   0x0E

OTP Coefficient A4

Definition at line 130 of file hall_si7210_regs.h .

#define SI7210_OTP_ADDR_POWER_UP_A5   0x0F

OTP Coefficient A5

Definition at line 131 of file hall_si7210_regs.h .

#define SI7210_OTP_ADDR_SERIAL_NUMBER   0x18

OTP Serial number

Definition at line 134 of file hall_si7210_regs.h .

#define SI7210_OTP_ADDR_SLTIME   0x06

OTP Sleep time control register

Definition at line 123 of file hall_si7210_regs.h .

#define SI7210_OTP_ADDR_VARIANT   0x15

OTP Variant number

Definition at line 133 of file hall_si7210_regs.h .

#define SI7210_REG_ADDR_A0   0xCA

Coefficient A0

Definition at line 59 of file hall_si7210_regs.h .

Referenced by SI7210_loadCoeffsFromOtp() .

#define SI7210_REG_ADDR_A1   0xCB

Coefficient A1

Definition at line 60 of file hall_si7210_regs.h .

Referenced by SI7210_loadCoeffsFromOtp() .

#define SI7210_REG_ADDR_A2   0xCC

Coefficient A2

Definition at line 61 of file hall_si7210_regs.h .

Referenced by SI7210_loadCoeffsFromOtp() .

#define SI7210_REG_ADDR_A3   0xCE

Coefficient A3

Definition at line 63 of file hall_si7210_regs.h .

Referenced by SI7210_loadCoeffsFromOtp() .

#define SI7210_REG_ADDR_A4   0xCF

Coefficient A4

Definition at line 64 of file hall_si7210_regs.h .

Referenced by SI7210_loadCoeffsFromOtp() .

#define SI7210_REG_ADDR_A5   0xD0

Coefficient A5

Definition at line 65 of file hall_si7210_regs.h .

Referenced by SI7210_loadCoeffsFromOtp() .

#define SI7210_REG_ADDR_ARAUTOINC   0xC5

Enables auto increment of the I2C register address pointer

Definition at line 54 of file hall_si7210_regs.h .

#define SI7210_REG_ADDR_CTRL1   0xC6

Control register 1, output pin configuration

Definition at line 55 of file hall_si7210_regs.h .

Referenced by HALL_configure() , and SI7210_enterContMode() .

#define SI7210_REG_ADDR_CTRL2   0xC7

Control register 2, output pin configuration

Definition at line 56 of file hall_si7210_regs.h .

Referenced by HALL_configure() , and SI7210_enterContMode() .

#define SI7210_REG_ADDR_CTRL3   0xC9

Control register 3, output pin and sleep time configuration

Definition at line 58 of file hall_si7210_regs.h .

Referenced by HALL_configure() , SI7210_enterContMode() , SI7210_sleep() , and SI7210_sleepSltimeena() .

#define SI7210_REG_ADDR_CTRL4   0xCD

Control register 4, Digital filter configuration

Definition at line 62 of file hall_si7210_regs.h .

Referenced by SI7210_readmTDataSleep() , and SI7210_readmTDataSltimeena() .

#define SI7210_REG_ADDR_DSPSIGL   0xC2

The least significant byte of the last conversion result

Definition at line 51 of file hall_si7210_regs.h .

Referenced by SI7210_dataRead() .

#define SI7210_REG_ADDR_DSPSIGM   0xC1

The most significant byte of the last conversion result

Definition at line 50 of file hall_si7210_regs.h .

Referenced by SI7210_dataRead() .

#define SI7210_REG_ADDR_DSPSIGSEL   0xC3

Select the data after filtering

Definition at line 52 of file hall_si7210_regs.h .

Referenced by SI7210_enterContMode() .

#define SI7210_REG_ADDR_HREVID   0xC0

Hardware revision ID register

Definition at line 49 of file hall_si7210_regs.h .

Referenced by SI7210_identify() .

#define SI7210_REG_ADDR_OTP_ADDR   0xE1

OTP address of the data to read

Definition at line 66 of file hall_si7210_regs.h .

Referenced by SI7210_regReadOTP() .

#define SI7210_REG_ADDR_OTP_CTRL   0xE3

OTP read control register

Definition at line 68 of file hall_si7210_regs.h .

Referenced by SI7210_regReadOTP() .

#define SI7210_REG_ADDR_OTP_DATA   0xE2

Data read from OTP

Definition at line 67 of file hall_si7210_regs.h .

Referenced by SI7210_regReadOTP() .

#define SI7210_REG_ADDR_POWER_CTRL   0xC4
#define SI7210_REG_ADDR_SLTIME   0xC8

Sleep time control register

Definition at line 57 of file hall_si7210_regs.h .

Referenced by SI7210_enterContMode() .

#define SI7210_REG_ADDR_TM_FG   0xE4

On-chip test coil control

Definition at line 69 of file hall_si7210_regs.h .

#define SI7210_REG_CTRL1_SW_LOW4FIELD_MASK   0x80

Output polarity setting bit mask, Control register 1

Definition at line 94 of file hall_si7210_regs.h .

Referenced by HALL_configure() .

#define SI7210_REG_CTRL1_SW_LOW4FIELD_SHIFT   7

Output polarity setting bit shift value, Control register 1

Definition at line 95 of file hall_si7210_regs.h .

Referenced by HALL_configure() .

#define SI7210_REG_CTRL1_SW_OP_MASK   0x7F

Switching point mask, Control register 1

Definition at line 92 of file hall_si7210_regs.h .

Referenced by HALL_configure() .

#define SI7210_REG_CTRL1_SW_OP_SHIFT   0

Switching point shift value, Control register 1

Definition at line 93 of file hall_si7210_regs.h .

Referenced by HALL_configure() .

#define SI7210_REG_CTRL2_SW_FIELDPOLSEL_MASK   0xC0

Switch polarity mask, Control register 2

Definition at line 99 of file hall_si7210_regs.h .

Referenced by HALL_configure() .

#define SI7210_REG_CTRL2_SW_FIELDPOLSEL_SHIFT   6

Switchi polarity shift value, Control register 2

Definition at line 100 of file hall_si7210_regs.h .

Referenced by HALL_configure() .

#define SI7210_REG_CTRL2_SW_HYST_MASK   0x3F

Switch hysteresis mask, Control register 2

Definition at line 97 of file hall_si7210_regs.h .

Referenced by HALL_configure() .

#define SI7210_REG_CTRL2_SW_HYST_SHIFT   0

Switch hyteresis shift value, Control register 2

Definition at line 98 of file hall_si7210_regs.h .

Referenced by HALL_configure() .

#define SI7210_REG_CTRL3_SLFAST_MASK   0x02

Sleep time reduction enable bit mask, Control register 3

Definition at line 104 of file hall_si7210_regs.h .

#define SI7210_REG_CTRL3_SLFAST_SHIFT   1

Sleep time reduction bit shift value, Control register 3

Definition at line 105 of file hall_si7210_regs.h .

#define SI7210_REG_CTRL3_SLTIMEENA_MASK   0x01

Sleep timer enable bit mask, Control register 3

Definition at line 102 of file hall_si7210_regs.h .

Referenced by HALL_configure() , SI7210_sleep() , and SI7210_sleepSltimeena() .

#define SI7210_REG_CTRL3_SLTIMEENA_SHIFT   0

Sleep timer enable bit shift value, Control register 3

Definition at line 103 of file hall_si7210_regs.h .

#define SI7210_REG_CTRL3_SW_TAMPER_MASK   0xFC

Tamper switch threshold mask, Control register 3

Definition at line 106 of file hall_si7210_regs.h .

Referenced by SI7210_sleepSltimeena() .

#define SI7210_REG_CTRL3_SW_TAMPER_SHIFT   2

Tamper switch threshold shift value, Control register 3

Definition at line 107 of file hall_si7210_regs.h .

#define SI7210_REG_CTRL4_DF_BURSTSIZE_MASK   0x0E

Measurement burst size mask, Control register 4

Definition at line 113 of file hall_si7210_regs.h .

#define SI7210_REG_CTRL4_DF_BURSTSIZE_SHIFT   5

Measurement burst size shift value, Control register 4

Definition at line 114 of file hall_si7210_regs.h .

Referenced by SI7210_readmTDataSleep() , and SI7210_readmTDataSltimeena() .

#define SI7210_REG_CTRL4_DF_BW_MASK   0x1E

Number of samples to average mask, Control register 4

Definition at line 111 of file hall_si7210_regs.h .

#define SI7210_REG_CTRL4_DF_BW_SHIFT   1

Number of samples to average shift value, Control register 4

Definition at line 112 of file hall_si7210_regs.h .

Referenced by SI7210_readmTDataSleep() , and SI7210_readmTDataSltimeena() .

#define SI7210_REG_CTRL4_IIR_MASK   0x01

IIR filter enable bit mask, Control register 4

Definition at line 109 of file hall_si7210_regs.h .

#define SI7210_REG_CTRL4_IIR_SHIFT   0

IIR filter enable bit shift value, Control register 4

Definition at line 110 of file hall_si7210_regs.h .

#define SI7210_REG_DSPSIGM_DSPSIGM_MASK   0x7F

MSB bits of conversion mask, MSB of last conversion result register

Definition at line 78 of file hall_si7210_regs.h .

Referenced by SI7210_dataRead() .

#define SI7210_REG_DSPSIGM_DSPSIGM_SHIFT   0

MSB bits of conversion shift value, MSB of last conversion result register

Definition at line 79 of file hall_si7210_regs.h .

#define SI7210_REG_DSPSIGM_FRESH_MASK   0x80

New data available mask, MSB of last conversion result register

Definition at line 76 of file hall_si7210_regs.h .

#define SI7210_REG_DSPSIGM_FRESH_SHIFT   7

New data available shift value, MSB of last conversion result register

Definition at line 77 of file hall_si7210_regs.h .

Referenced by SI7210_dataRead() .

#define SI7210_REG_HREVID_CHIPID_MASK   0xF0

Chip ID mask, Hardware revision ID register

Definition at line 73 of file hall_si7210_regs.h .

#define SI7210_REG_HREVID_CHIPID_SHIFT   4

Revision ID shift value, Hardware revision ID register

Definition at line 74 of file hall_si7210_regs.h .

Referenced by SI7210_identify() .

#define SI7210_REG_HREVID_REVID_MASK   0x0F

Revision ID mask, Hardware revision ID register

Definition at line 71 of file hall_si7210_regs.h .

Referenced by SI7210_identify() .

#define SI7210_REG_HREVID_REVID_SHIFT   0

Revision ID shift value, Hardware revision ID register

Definition at line 72 of file hall_si7210_regs.h .

#define SI7210_REG_OTP_CTRL_BUSY_MASK   0x01

OTP busy indicator bit mask, OTP read control register

Definition at line 116 of file hall_si7210_regs.h .

Referenced by SI7210_regReadOTP() .

#define SI7210_REG_OTP_CTRL_BUSY_SHIFT   0

OTP busy indicator bit shift value, OTP read control register

Definition at line 117 of file hall_si7210_regs.h .

#define SI7210_REG_OTP_CTRL_READ_EN_MASK   0x02

OTP read enable bit mask, OTP read control register

Definition at line 118 of file hall_si7210_regs.h .

Referenced by SI7210_regReadOTP() .

#define SI7210_REG_OTP_CTRL_READ_EN_SHIFT   1

OTP read enable bit shift value, OTP read control register

Definition at line 119 of file hall_si7210_regs.h .

#define SI7210_REG_POWER_CTRL_MEAS_MASK   0x80

Measurement in progress bit mask, Power control register

Definition at line 89 of file hall_si7210_regs.h .

#define SI7210_REG_POWER_CTRL_MEAS_SHIFT   7

Measurement in progress bit shift value, Power control register

Definition at line 90 of file hall_si7210_regs.h .

Referenced by SI7210_readmTDataSleep() , and SI7210_readmTDataSltimeena() .

#define SI7210_REG_POWER_CTRL_ONEBURST_MASK   0x04

One burst mesurement bit mask, Power control register

Definition at line 85 of file hall_si7210_regs.h .

Referenced by SI7210_identify() , SI7210_readmTDataSleep() , SI7210_readmTDataSltimeena() , SI7210_sleep() , and SI7210_sleepSltimeena() .

#define SI7210_REG_POWER_CTRL_ONEBURST_SHIFT   2

One burst mesurement bit shift value, Power control register

Definition at line 86 of file hall_si7210_regs.h .

#define SI7210_REG_POWER_CTRL_SLEEP_MASK   0x01

Sleep mode bit mask, Power control register

Definition at line 81 of file hall_si7210_regs.h .

Referenced by SI7210_identify() , SI7210_readmTDataSleep() , SI7210_readmTDataSltimeena() , SI7210_sleep() , and SI7210_sleepSltimeena() .

#define SI7210_REG_POWER_CTRL_SLEEP_SHIFT   0

Sleep mode bit shift value, Power control register

Definition at line 82 of file hall_si7210_regs.h .

#define SI7210_REG_POWER_CTRL_STOP_MASK   0x02

Stop bit mask, Power control register

Definition at line 83 of file hall_si7210_regs.h .

Referenced by HALL_configure() , SI7210_identify() , SI7210_readmTDataSleep() , SI7210_readmTDataSltimeena() , SI7210_sleep() , and SI7210_sleepSltimeena() .

#define SI7210_REG_POWER_CTRL_STOP_SHIFT   1

Stop bit shift value, Power control register

Definition at line 84 of file hall_si7210_regs.h .

#define SI7210_REG_POWER_CTRL_USESTORE_MASK   0x08

Save the current state of OTP regs bit mask, Power control register

Definition at line 87 of file hall_si7210_regs.h .

Referenced by HALL_configure() , SI7210_readmTDataSleep() , and SI7210_readmTDataSltimeena() .

#define SI7210_REG_POWER_CTRL_USESTORE_SHIFT   3

Save the current state of OTP regs bit shift value, Power control register

Definition at line 88 of file hall_si7210_regs.h .

Function Documentation

uint8_t SI7210_calculateSlTime ( uint32_t samplePeriod,
uint8_t * slFast
)

Calculates the slTime value from the sleep time by finding the inverse of the formula: tsleep = (32 + slTime[4:0]) * 2^(8 + slTime[7:5]) / 12 MHz.

Parameters
[in] samplePeriod The sleep time
[out] slFast The value of the slFast bit
Returns
The value of the slTime bitfield

Definition at line 766 of file hall_si7210.c .

uint8_t SI7210_calculateSWHYST ( float hysteresis,
bool scale200mT
)

Calculates the sw_hyst value from the hysteresis by finding the inverse of the formula: hysteresis = (8 + sw_hyst[2:0]) * 2^sw_hyst[5:3].

Parameters
[in] hysteresis Hysteresis value
[in] scale200mT scale200mT=false : full-scale equals 20mT scale200mT=true : full-scale equals 200mT
Returns
The value of the sw_hyst bitfield

Definition at line 663 of file hall_si7210.c .

Referenced by HALL_configure() .

uint8_t SI7210_calculateSWOP ( float threshold )

Calculates the sw_op value from the threshold by finding the inverse of the formula: threshold = (16 + sw_op[3:0]) * 2^sw_op[6:4].

Parameters
[in] threshold Threshold value
Returns
The value of the sw_op bitfield

Definition at line 617 of file hall_si7210.c .

Referenced by HALL_configure() .

uint8_t SI7210_calculateSWTAMPER ( float tamper,
bool scale200mT
)

Calculates the sw_tamper value from the tamper threshold by finding the inverse of the formula: tamper = (16 + sw_tamper[3:0]) * 2^(sw_tamper[5:4] + 5)

Parameters
[in] tamper Tamper value
  • Parameters
    [in] scale200mT scale200mT=false : full-scale equals 20mT scale200mT=true : full-scale equals 200mT
    Returns
    The value of the sw_tamper bitfield

Definition at line 713 of file hall_si7210.c .

uint32_t SI7210_dataRead ( int16_t * data )

Read out Si7210 Conversion Data - 15bits.

Parameters
[out] data The raw magnetic field conversion data (15 bits)
Returns
Returns zero on OK, non-zero otherwise

Definition at line 264 of file hall_si7210.c .

References SI7210_ERROR_NODATA , SI7210_REG_ADDR_DSPSIGL , SI7210_REG_ADDR_DSPSIGM , SI7210_REG_DSPSIGM_DSPSIGM_MASK , SI7210_REG_DSPSIGM_FRESH_SHIFT , and SI7210_registerRead() .

Referenced by SI7210_readmTDataSleep() , and SI7210_readmTDataSltimeena() .

uint32_t SI7210_enterContMode ( void )

Puts sensor into continuous mode, conversions performed every 7usec.

Returns
Returns zero on OK, non-zero otherwise

Definition at line 584 of file hall_si7210.c .

References SI7210_REG_ADDR_CTRL1 , SI7210_REG_ADDR_CTRL2 , SI7210_REG_ADDR_CTRL3 , SI7210_REG_ADDR_DSPSIGSEL , SI7210_REG_ADDR_POWER_CTRL , SI7210_REG_ADDR_SLTIME , SI7210_registerRead() , SI7210_registerWrite() , and SI7210_wakeUp() .

uint32_t SI7210_identify ( uint8_t * id,
uint8_t * rev
)

Read out Si7210 Revision and ID.

Parameters
[out] id Si7210 part ID
[out] rev Si7210 part Revision
Returns
Returns zero on OK, non-zero otherwise

Definition at line 345 of file hall_si7210.c .

References SI7210_REG_ADDR_HREVID , SI7210_REG_ADDR_POWER_CTRL , SI7210_REG_HREVID_CHIPID_SHIFT , SI7210_REG_HREVID_REVID_MASK , SI7210_REG_POWER_CTRL_ONEBURST_MASK , SI7210_REG_POWER_CTRL_SLEEP_MASK , SI7210_REG_POWER_CTRL_STOP_MASK , SI7210_registerRead() , SI7210_registerWrite() , and SI7210_wakeUp() .

Referenced by HALL_initDevice() .

static uint32_t SI7210_loadCoeffsFromOtp ( uint8_t otpAddr )
static

Loads the coefficients A0..A6 from the OTP memory.

Parameters
[in] otpAddr The register address to start reading from the OTP memory
Returns
Returns zero on OK, non-zero otherwise

Definition at line 414 of file hall_si7210.c .

References HALL_OK , SI7210_OK , SI7210_REG_ADDR_A0 , SI7210_REG_ADDR_A1 , SI7210_REG_ADDR_A2 , SI7210_REG_ADDR_A3 , SI7210_REG_ADDR_A4 , SI7210_REG_ADDR_A5 , SI7210_registerWrite() , and SI7210_regReadOTP() .

Referenced by SI7210_set200mTRange() .

uint32_t SI7210_readmTDataSleep ( bool range200mT,
int32_t * mTdata
)

Wake-up from Sleep, perform burst-conversion(4samples), read mT-data, and then put part into sleep mode (no-measurement). Requires Wake-Up.

Parameters
[in] range200mT range200mT=false : full-scale equals 20mT range200mT=true : full-scale equals 200mT
[out] mTdata Mag-field conversion reading, signed 32-bit integer mTdata must be divided by 1000 to get decimal value in mT units
Returns
Returns zero on OK, non-zero otherwise

Definition at line 535 of file hall_si7210.c .

References SI7210_dataRead() , SI7210_REG_ADDR_CTRL4 , SI7210_REG_ADDR_POWER_CTRL , SI7210_REG_CTRL4_DF_BURSTSIZE_SHIFT , SI7210_REG_CTRL4_DF_BW_SHIFT , SI7210_REG_POWER_CTRL_MEAS_SHIFT , SI7210_REG_POWER_CTRL_ONEBURST_MASK , SI7210_REG_POWER_CTRL_SLEEP_MASK , SI7210_REG_POWER_CTRL_STOP_MASK , SI7210_REG_POWER_CTRL_USESTORE_MASK , SI7210_registerRead() , SI7210_registerWrite() , SI7210_set200mTRange() , SI7210_sleep() , and SI7210_wakeUp() .

uint32_t SI7210_readmTDataSltimeena ( bool range200mT,
int32_t * mTdata
)

Perform burst-conversion(4samples), read mT-data, and then put part into sltimeena-sleep mode where OUT is updated every 200msec.

Parameters
[in] range200mT range200mT=false : full-scale equals 20mT range200mT=true : full-scale equals 200mT
[out] mTdata Mag-field conversion reading, signed 32-bit integer mTdata must be divided by 1000 to get decimal value in mT units
Returns
Returns zero on OK, non-zero otherwise

Definition at line 477 of file hall_si7210.c .

References SI7210_dataRead() , SI7210_REG_ADDR_CTRL4 , SI7210_REG_ADDR_POWER_CTRL , SI7210_REG_CTRL4_DF_BURSTSIZE_SHIFT , SI7210_REG_CTRL4_DF_BW_SHIFT , SI7210_REG_POWER_CTRL_MEAS_SHIFT , SI7210_REG_POWER_CTRL_ONEBURST_MASK , SI7210_REG_POWER_CTRL_SLEEP_MASK , SI7210_REG_POWER_CTRL_STOP_MASK , SI7210_REG_POWER_CTRL_USESTORE_MASK , SI7210_registerRead() , SI7210_registerWrite() , SI7210_set200mTRange() , SI7210_sleepSltimeena() , and SI7210_wakeUp() .

Referenced by HALL_measure() .

uint32_t SI7210_regClearBits ( uint8_t addr,
uint8_t mask
)

Clears the given bit(s) in a register in the Hall sensor device.

Parameters
[in] addr The address of the register
[in] mask The mask specifies which bits should be clear. If a given bit of the mask is 1 that register bit will be cleared to 0. All the other register bits will be untouched.
Returns
Returns zero on OK, non-zero otherwise

Definition at line 927 of file hall_si7210.c .

References HALL_OK , SI7210_registerRead() , and SI7210_registerWrite() .

Referenced by HALL_configure() .

uint32_t SI7210_registerRead ( uint8_t addr,
uint8_t * data
)

Reads register from the Hall sensor device.

Parameters
[in] addr The register address to read from in the sensor
[out] data The data read from the device
Returns
Returns zero on OK, non-zero otherwise

Definition at line 821 of file hall_si7210.c .

References BOARD_i2cBusSelect() , HALL_ERROR_I2C_TRANSACTION_FAILED , HALL_OK , and I2CSPM_Transfer() .

Referenced by SI7210_dataRead() , SI7210_enterContMode() , SI7210_identify() , SI7210_readmTDataSleep() , SI7210_readmTDataSltimeena() , SI7210_regClearBits() , SI7210_regReadOTP() , SI7210_regSetBits() , SI7210_sleep() , and SI7210_sleepSltimeena() .

uint32_t SI7210_registerWrite ( uint8_t addr,
uint8_t data
)

Writes a register in the Hall sensor device.

Parameters
[in] addr The register address to write
[in] data The data to write to the register
Returns
Returns zero on OK, non-zero otherwise

Definition at line 857 of file hall_si7210.c .

References BOARD_i2cBusSelect() , HALL_ERROR_I2C_TRANSACTION_FAILED , HALL_OK , and I2CSPM_Transfer() .

Referenced by HALL_configure() , SI7210_enterContMode() , SI7210_identify() , SI7210_loadCoeffsFromOtp() , SI7210_readmTDataSleep() , SI7210_readmTDataSltimeena() , SI7210_regClearBits() , SI7210_regReadOTP() , SI7210_regSetBits() , SI7210_sleep() , and SI7210_sleepSltimeena() .

uint32_t SI7210_regReadOTP ( uint8_t otpAddr,
uint8_t * otpData
)

Reads register from the OTP area of the Si7021 device.

Parameters
[in] otpAddr The register address to read from in the sensor
[out] otpData The data read from the device
Returns
Returns zero on OK, non-zero otherwise

Definition at line 375 of file hall_si7210.c .

References HALL_OK , SI7210_ERROR_OTP_BUSY , SI7210_REG_ADDR_OTP_ADDR , SI7210_REG_ADDR_OTP_CTRL , SI7210_REG_ADDR_OTP_DATA , SI7210_REG_OTP_CTRL_BUSY_MASK , SI7210_REG_OTP_CTRL_READ_EN_MASK , SI7210_registerRead() , and SI7210_registerWrite() .

Referenced by SI7210_loadCoeffsFromOtp() .

uint32_t SI7210_regSetBits ( uint8_t addr,
uint8_t mask
)

Sets the given bit(s) in a register in the Hall sensor device.

Parameters
[in] addr The address of the register
[in] mask The mask specifies which bits should be set. If a given bit of the mask is 1 that register bit will be set to 1. All the other register bits will be untouched.
Returns
Returns zero on OK, non-zero otherwise

Definition at line 895 of file hall_si7210.c .

References HALL_OK , SI7210_registerRead() , and SI7210_registerWrite() .

Referenced by HALL_configure() .

uint32_t SI7210_set200mTRange ( void )

Change Mag-Field scale to 200mT. If desired, must be performed after power-up or wake-up from sleep.

Returns
Returns zero on OK, non-zero otherwise

Definition at line 454 of file hall_si7210.c .

References SI7210_loadCoeffsFromOtp() , SI7210_OK , and SI7210_OTP_ADDR_COEFFS_200MT .

Referenced by SI7210_readmTDataSleep() , and SI7210_readmTDataSltimeena() .

uint32_t SI7210_sleep ( void )

Puts Si7210 into Sleep (No-measurement) Mode Wake-up command needs to be issued to become responsive.

Returns
Returns zero on OK, non-zero otherwise

Definition at line 292 of file hall_si7210.c .

References SI7210_REG_ADDR_CTRL3 , SI7210_REG_ADDR_POWER_CTRL , SI7210_REG_CTRL3_SLTIMEENA_MASK , SI7210_REG_POWER_CTRL_ONEBURST_MASK , SI7210_REG_POWER_CTRL_SLEEP_MASK , SI7210_REG_POWER_CTRL_STOP_MASK , SI7210_registerRead() , and SI7210_registerWrite() .

Referenced by SI7210_readmTDataSleep() .

uint32_t SI7210_sleepSltimeena ( void )

Puts Si7210 into Sleep w/ Measurement Mode: OUTPUT is updated 200msec.

Returns
Returns zero on OK, non-zero otherwise

Definition at line 315 of file hall_si7210.c .

References SI7210_REG_ADDR_CTRL3 , SI7210_REG_ADDR_POWER_CTRL , SI7210_REG_CTRL3_SLTIMEENA_MASK , SI7210_REG_CTRL3_SW_TAMPER_MASK , SI7210_REG_POWER_CTRL_ONEBURST_MASK , SI7210_REG_POWER_CTRL_SLEEP_MASK , SI7210_REG_POWER_CTRL_STOP_MASK , SI7210_registerRead() , and SI7210_registerWrite() .

Referenced by SI7210_readmTDataSltimeena() .

uint32_t SI7210_wakeUp ( void )