Si72xx - Magnetic Hall Effect Sensor

Description

Functions

uint32_t sl_si72xx_read_register (I2C_TypeDef *i2c, uint8_t addr, uint8_t reg, uint8_t *data)
 PROTOTYPES **********************************.
 
uint32_t sl_si72xx_write_register (I2C_TypeDef *i2c, uint8_t addr, uint8_t reg, uint8_t data)
 Writes register in the Si72xx sensor.
 
uint32_t sl_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 in idle mode.
 
uint32_t sl_si72xx_from_idle_go_to_sleep (I2C_TypeDef *i2c, uint8_t addr)
 Puts Si72xx into Sleep mode (lowest power).
 
uint32_t sl_si72xx_from_idle_go_to_sltimeena (I2C_TypeDef *i2c, uint8_t addr)
 Puts Si72xx into Sleep-Timer-Enabled mode.
 
uint32_t sl_si72xx_wake_up_and_idle (I2C_TypeDef *i2c, uint8_t addr)
 Wake-up Si72xx and places sensor in idle-mode.
 
uint32_t sl_si72xx_read_magfield_data_and_sleep (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.
 
int32_t sl_si72xx_convert_data_codes_to_magnetic_field (Si72xxFieldScale_t fieldScale, int16_t dataCode)
 Convert Si7210 I2C Data Readings to Magnetic Field in microTeslas.
 
uint32_t sl_si72xx_enter_sleep_mode (I2C_TypeDef *i2c, uint8_t addr, Si72xxSleepMode_t sleepMode)
 Wake-up Si72xx, and set sleep-mode option.
 
uint32_t sl_si72xx_enter_latch_mode (I2C_TypeDef *i2c, uint8_t addr)
 Wake-up Si72xx, and configures output for Latch mode.
 
uint32_t sl_si72xx_read_temperature_and_sleep (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 sl_si72xx_read_temp_correction_data_and_sleep (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 sl_si72xx_read_corrected_temp_and_sleep (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.
 
uint32_t sl_si72xx_identify_and_sleep (I2C_TypeDef *i2c, uint8_t addr, uint8_t *partId, uint8_t *partRev)
 Wake-up Si72xx, read out part Revision and ID, and place Si72xx back to SLEEP sleep-mode.
 
uint32_t sl_si72xx_read_variant_and_sleep (I2C_TypeDef *i2c, uint8_t addr, uint8_t *basePn, uint8_t *pnVariant)
 Wake-up Si72xx, read out Si72xx base part-number and variant, and place sensor back to SLEEP sleep-mode.
 

Enumerations

enum  Si72xxFieldScale_t {
  SI7210_20MT,
  SI7210_200MT
}
 DEFINES ***********************************.
 
enum  Si72xxSleepMode_t {
  SI72XX_SLEEP_MODE,
  SI72XX_SLTIMEENA_MODE
}
 Si72xx sleep modes.
 

Function Documentation

◆ sl_si72xx_read_register()

uint32_t sl_si72xx_read_register ( I2C_TypeDef *  i2c,
uint8_t  addr,
uint8_t  reg,
uint8_t *  data 
)

PROTOTYPES **********************************.

Reads register from the Si72xx sensor. Command can only be issued if Si72xx in idle mode.

Parameters
[in]i2cPointer to the I2C peripheral register block.
[in]addrThe I2C address of the sensor.
[in]regThe register address.
[out]dataThe data read from the sensor.
Returns
Returns zero on success. Otherwise returns error codes based on the I2CSPM.

◆ sl_si72xx_write_register()

uint32_t sl_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 in idle mode.

Parameters
[in]i2cPointer to the I2C peripheral register block.
[in]addrThe I2C address of the sensor.
[in]regThe register address.
[in]dataThe data to write to the sensor.
Returns
Returns zero on success. Otherwise returns error codes based on the I2CSPM.

◆ sl_si72xx_read_magfield_data()

uint32_t sl_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 in idle mode.

Parameters
[in]i2cPointer to the I2C peripheral register block.
[in]addrThe I2C address of the sensor.
[out]magDataMag-field conversion reading, signed 16-bit integer.
Returns
Returns zero on success. Otherwise returns error codes based on the I2CSPM.

◆ sl_si72xx_from_idle_go_to_sleep()

uint32_t sl_si72xx_from_idle_go_to_sleep ( I2C_TypeDef *  i2c,
uint8_t  addr 
)

Puts Si72xx into Sleep mode (lowest power).

Command can only be issued if Si72xx in idle mode.

Parameters
[in]i2cPointer to the I2C peripheral register block.
[in]addrThe I2C address of the sensor.
Returns
Returns zero on success. Otherwise returns error codes based on the I2CSPM.

◆ sl_si72xx_from_idle_go_to_sltimeena()

uint32_t sl_si72xx_from_idle_go_to_sltimeena ( I2C_TypeDef *  i2c,
uint8_t  addr 
)

Puts Si72xx into Sleep-Timer-Enabled 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 in idle mode.

Parameters
[in]i2cPointer to the I2C peripheral register block.
[in]addrThe I2C address of the sensor.
Returns
Returns zero on success. Otherwise returns error codes based on the I2CSPM.

◆ sl_si72xx_wake_up_and_idle()

uint32_t sl_si72xx_wake_up_and_idle ( I2C_TypeDef *  i2c,
uint8_t  addr 
)

Wake-up Si72xx and places sensor in idle-mode.

Parameters
[in]i2cPointer to the I2C peripheral register block.
[in]addrThe I2C address of the sensor.
Returns
Returns zero on success. Otherwise returns error codes based on the I2CSPM.

◆ sl_si72xx_read_magfield_data_and_sleep()

uint32_t sl_si72xx_read_magfield_data_and_sleep ( 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.

Parameters
[in]i2cPointer to the I2C peripheral register block.
[in]addrThe I2C address of the sensor.
[in]mTScalemTScale= Si7210_20MT: 20mT full-scale magnetic-field range. mTScale= Si7210_200MT: 200mT full-scale magnetic-field range.
[in]sleepModeSI72XX_SLEEP: Sleep mode. Lowest power & doesn't update output. SI72XX_SLTIMEENA: Sleep-Timer-Enabled mode. Updates output periodically.
[out]magFieldDataMagnetic-field conversion reading, signed 16-bit integer.
Returns
Returns zero on success. Otherwise returns error codes based on the I2CSPM.

◆ sl_si72xx_convert_data_codes_to_magnetic_field()

int32_t sl_si72xx_convert_data_codes_to_magnetic_field ( Si72xxFieldScale_t  fieldScale,
int16_t  dataCode 
)

Convert Si7210 I2C Data Readings to Magnetic Field in microTeslas.

Parameters
[in]fieldScale20mT or 200mT full-scale magnetic field range.
[in]dataCodesigned 15-bit value read from hall sensor after magnetic field conversion.
Returns
microTeslas.

◆ sl_si72xx_enter_sleep_mode()

uint32_t sl_si72xx_enter_sleep_mode ( 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.

Parameters
[in]i2cPointer to the I2C peripheral register block.
[in]addrThe I2C address of the sensor.
[in]sleepModeSI72XX_SLEEP: Puts Si72xx into sleep mode. Lowest power & doesn't update. SI72XX_SLTIMEENA: Si72xx into sltimeena mode. Updates output periodically.
Returns
Returns zero on success. Otherwise returns error codes based on the I2CSPM.

◆ sl_si72xx_enter_latch_mode()

uint32_t sl_si72xx_enter_latch_mode ( I2C_TypeDef *  i2c,
uint8_t  addr 
)

Wake-up Si72xx, and configures output for Latch mode.

Switch point = 0mT w/ 0.2mT hysteresis

Parameters
[in]i2cPointer to the I2C peripheral register block.
[in]addrThe I2C address of the sensor.
Returns
Returns zero on success. Otherwise returns error codes based on the I2CSPM.

◆ sl_si72xx_read_temperature_and_sleep()

uint32_t sl_si72xx_read_temperature_and_sleep ( I2C_TypeDef *  i2c,
uint8_t  addr,
int32_t *  rawTemp 
)

Wakes up SI72xx, performs temperature conversion and places Si72xx into SI72XX_SLEEP sleep-mode.

Parameters
[in]i2cPointer to the I2C peripheral register block.
[in]addrThe I2C address of the sensor.
[out]rawTempTemperature measurement in millidegree Celsius.
Returns
Returns zero on success. Otherwise returns error codes based on the I2CSPM.

◆ sl_si72xx_read_temp_correction_data_and_sleep()

uint32_t sl_si72xx_read_temp_correction_data_and_sleep ( 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.

Parameters
[in]i2cPointer to the I2C peripheral register block.
[in]addrThe I2C address of the sensor.
[out]offsetValueTemperature offset correction.
[out]gainValueTemperature gain correction.
Returns
Returns zero on success. Otherwise returns error codes based on the I2CSPM.

◆ sl_si72xx_read_corrected_temp_and_sleep()

uint32_t sl_si72xx_read_corrected_temp_and_sleep ( 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.

Parameters
[in]i2cPointer to the I2C peripheral register block.
[in]addrThe I2C address of the sensor.
[out]correctedTempTemperature measurement in millidegree Celsius.
[in]offsetDataOffset correction data.
[in]gainDataGain correction data.
Returns
Returns zero on success. Otherwise returns error codes based on the I2CSPM.

◆ sl_si72xx_identify_and_sleep()

uint32_t sl_si72xx_identify_and_sleep ( I2C_TypeDef *  i2c,
uint8_t  addr,
uint8_t *  partId,
uint8_t *  partRev 
)

Wake-up Si72xx, read out part Revision and ID, and place Si72xx back to SLEEP sleep-mode.

Parameters
[in]i2cPointer to the I2C peripheral register block.
[in]addrThe I2C address of the sensor.
[out]partIdSi72xx part ID.
[out]partRevSi72xx part Revision.
Returns
Returns zero on success. Otherwise returns error codes based on the I2CSPM.

◆ sl_si72xx_read_variant_and_sleep()

uint32_t sl_si72xx_read_variant_and_sleep ( I2C_TypeDef *  i2c,
uint8_t  addr,
uint8_t *  basePn,
uint8_t *  pnVariant 
)

Wake-up Si72xx, read out Si72xx base part-number and variant, and place sensor back to SLEEP sleep-mode.

Parameters
[in]i2cPointer to the I2C peripheral register block.
[in]addrThe I2C address of the sensor.
[out]basePnSi72xx part ID.
[out]pnVariantSi72xx part Revision.
Returns
Returns zero on success. Otherwise returns error codes based on the I2CSPM.

Enumeration Type Documentation

◆ Si72xxFieldScale_t

DEFINES ***********************************.

ENUMS ************************************ Si72xx magnetic field full-scales

◆ Si72xxSleepMode_t

Si72xx sleep modes.