si72xx.c File Reference

Driver for the Si72xx Hall Effect Sensor.

License

Copyright 2018 Silicon Laboratories Inc. www.silabs.com

SPDX-License-Identifier: Zlib

The licensor of this software is Silicon Laboratories Inc.

This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.

Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:

  1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
  2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
  3. This notice may not be removed or altered from any source distribution.

Definition in file si72xx.c.

#include "i2cspm.h"
#include "si72xx.h"
#include <stddef.h>
#include <stdbool.h>

Functions

int32_t Si72xx_ConvertDataCodesToMagneticField (Si72xxFieldScale_t fieldScale, int16_t dataCode)
 Convert Si7210 I2C Data Readings to Magnetic Field in microTeslas.
 
uint32_t Si72xx_EnterLatchMode (I2C_TypeDef *i2c, uint8_t addr)
 Wake-up Si72xx, and configures output for Latch mode. Switch point = 0mT w/ 0.2mT hysteresis.
 
uint32_t Si72xx_EnterSleepMode (I2C_TypeDef *i2c, uint8_t addr, Si72xxSleepMode_t sleepMode)
 Wake-up Si72xx, and set sleep-mode option. If Si72xx is in a sleep-mode, it requires a wake-up command first. Useful for placing Si72xx in SLTIMEENA mode from SLEEP mode, or vice-versa.
 
uint32_t Si72xx_FromIdle_GoToSleep (I2C_TypeDef *i2c, uint8_t addr)
 Puts Si72xx into Sleep mode (lowest power).. Command can only be issued if Si72xx is idle mode.
 
uint32_t Si72xx_FromIdle_GoToSltimeena (I2C_TypeDef *i2c, uint8_t addr)
 Puts Si72xx into Sleep-Timer-Enable mode. Si72xx periodically wakes-up, samples the magnetic field, updates the output, and goes back to sleep-timer-enabled mode. Command can only be issued if Si72xx is idle mode.
 
uint32_t Si72xx_IdentifyAndSleep (I2C_TypeDef *i2c, uint8_t addr, uint8_t *partId, uint8_t *partRev)
 
uint32_t Si72xx_Read_MagField_Data (I2C_TypeDef *i2c, uint8_t addr, int16_t *magData)
 Read out Si72xx Magnetic Field Conversion Data Command can only be issued if Si72xx is idle mode.
 
static uint32_t Si72xx_Read_OTP (I2C_TypeDef *i2c, uint8_t addr, uint8_t otpAddr, uint8_t *otpData)
 Read Si72xx OTP Data Command can only be issued if Si72xx is idle mode.
 
uint32_t Si72xx_Read_Register (I2C_TypeDef *i2c, uint8_t addr, uint8_t reg, uint8_t *data)
 Reads register from the Si72xx sensor. Command can only be issued if Si72xx is idle mode.
 
uint32_t Si72xx_ReadCorrectedTempAndSleep (I2C_TypeDef *i2c, uint8_t addr, int16_t offsetData, int16_t gainData, int32_t *correctedTemp)
 Wakes up SI72xx, performs a temperature conversion, and places sensor back to sleep. Temperature calculation is performed using compensation data.
 
uint32_t Si72xx_ReadMagFieldDataAndSleep (I2C_TypeDef *i2c, uint8_t addr, Si72xxFieldScale_t mTScale, Si72xxSleepMode_t sleepMode, int16_t *magFieldData)
 Wake-up SI72xx, performs a magnetic-field conversion with FIR, and places Si72xx back to sleep-mode.
 
uint32_t Si72xx_ReadTempCorrectionDataAndSleep (I2C_TypeDef *i2c, uint8_t addr, int16_t *offsetValue, int16_t *gainValue)
 Wakes up SI72xx, performs temperature conversion and places Si72xx into SI72XX_SLEEP sleep-mode.
 
uint32_t Si72xx_ReadTemperatureAndSleep (I2C_TypeDef *i2c, uint8_t addr, int32_t *rawTemp)
 Wakes up SI72xx, performs temperature conversion and places Si72xx into SI72XX_SLEEP sleep-mode.
 
uint32_t Si72xx_ReadVariantAndSleep (I2C_TypeDef *i2c, uint8_t addr, uint8_t *basePn, uint8_t *pnVariant)
 
static uint32_t Si72xx_Set_mT_Range (I2C_TypeDef *i2c, uint8_t addr, Si72xxFieldScale_t mTScale)
 Set magnetic-field output range, 20mT or 200mT full-scale Command can only be issued if Si72xx is idle mode.
 
uint32_t Si72xx_WakeUpAndIdle (I2C_TypeDef *i2c, uint8_t addr)
 Wake-up Si72xx and places sensor in idle-mode.
 
uint32_t Si72xx_Write_Register (I2C_TypeDef *i2c, uint8_t addr, uint8_t reg, uint8_t data)
 Writes register in the Si72xx sensor. Command can only be issued if Si72xx is idle mode.