Si72xx - Magnetic Hall Effect Sensor#

Enumerations#

enum
SI7210_20MT
SI7210_200MT
}

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

enum
SI72XX_SLEEP_MODE
SI72XX_SLTIMEENA_MODE
}

Si72xx sleep modes.

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.

Enumeration Documentation#

Si72xxFieldScale_t#

Si72xxFieldScale_t

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

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

Enumerator
SI7210_20MT
SI7210_200MT

Si72xxSleepMode_t#

Si72xxSleepMode_t

Si72xx sleep modes.

Enumerator
SI72XX_SLEEP_MODE
SI72XX_SLTIMEENA_MODE

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 **********************************.

Parameters
TypeDirectionArgument NameDescription
I2C_TypeDef *[in]i2c

Pointer to the I2C peripheral register block.

uint8_t[in]addr

The I2C address of the sensor.

uint8_t[in]reg

The register address.

uint8_t *[out]data

The data read from the sensor.

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

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.

Parameters
TypeDirectionArgument NameDescription
I2C_TypeDef *[in]i2c

Pointer to the I2C peripheral register block.

uint8_t[in]addr

The I2C address of the sensor.

uint8_t[in]reg

The register address.

uint8_t[in]data

The data to write to the sensor.

Command can only be issued if Si72xx in idle mode.

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
TypeDirectionArgument NameDescription
I2C_TypeDef *[in]i2c

Pointer to the I2C peripheral register block.

uint8_t[in]addr

The I2C address of the sensor.

int16_t *[out]magData

Mag-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).

Parameters
TypeDirectionArgument NameDescription
I2C_TypeDef *[in]i2c

Pointer to the I2C peripheral register block.

uint8_t[in]addr

The I2C address of the sensor.

Command can only be issued if Si72xx in idle mode.

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.

Parameters
TypeDirectionArgument NameDescription
I2C_TypeDef *[in]i2c

Pointer to the I2C peripheral register block.

uint8_t[in]addr

The I2C address of the sensor.

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.

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
TypeDirectionArgument NameDescription
I2C_TypeDef *[in]i2c

Pointer to the I2C peripheral register block.

uint8_t[in]addr

The 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
TypeDirectionArgument NameDescription
I2C_TypeDef *[in]i2c

Pointer to the I2C peripheral register block.

uint8_t[in]addr

The I2C address of the sensor.

Si72xxFieldScale_t[in]mTScale

mTScale= Si7210_20MT: 20mT full-scale magnetic-field range. mTScale= Si7210_200MT: 200mT full-scale magnetic-field range.

Si72xxSleepMode_t[in]sleepMode

SI72XX_SLEEP: Sleep mode. Lowest power & doesn't update output. SI72XX_SLTIMEENA: Sleep-Timer-Enabled mode. Updates output periodically.

int16_t *[out]magFieldData

Magnetic-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
TypeDirectionArgument NameDescription
Si72xxFieldScale_t[in]fieldScale

20mT or 200mT full-scale magnetic field range.

int16_t[in]dataCode

signed 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.

Parameters
TypeDirectionArgument NameDescription
I2C_TypeDef *[in]i2c

Pointer to the I2C peripheral register block.

uint8_t[in]addr

The I2C address of the sensor.

Si72xxSleepMode_t[in]sleepMode

SI72XX_SLEEP: Puts Si72xx into sleep mode. Lowest power & doesn't update. SI72XX_SLTIMEENA: Si72xx into sltimeena mode. Updates output periodically.

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.

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.

Parameters
TypeDirectionArgument NameDescription
I2C_TypeDef *[in]i2c

Pointer to the I2C peripheral register block.

uint8_t[in]addr

The I2C address of the sensor.

Switch point = 0mT w/ 0.2mT hysteresis

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
TypeDirectionArgument NameDescription
I2C_TypeDef *[in]i2c

Pointer to the I2C peripheral register block.

uint8_t[in]addr

The I2C address of the sensor.

int32_t *[out]rawTemp

Temperature 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
TypeDirectionArgument NameDescription
I2C_TypeDef *[in]i2c

Pointer to the I2C peripheral register block.

uint8_t[in]addr

The I2C address of the sensor.

int16_t *[out]offsetValue

Temperature offset correction.

int16_t *[out]gainValue

Temperature 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.

Parameters
TypeDirectionArgument NameDescription
I2C_TypeDef *[in]i2c

Pointer to the I2C peripheral register block.

uint8_t[in]addr

The I2C address of the sensor.

int16_t[out]offsetData

Temperature measurement in millidegree Celsius.

int16_t[in]gainData

Offset correction data.

int32_t *[in]correctedTemp

Gain correction data.

Temperature calculation is performed using compensation 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
TypeDirectionArgument NameDescription
I2C_TypeDef *[in]i2c

Pointer to the I2C peripheral register block.

uint8_t[in]addr

The I2C address of the sensor.

uint8_t *[out]partId

Si72xx part ID.

uint8_t *[out]partRev

Si72xx 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
TypeDirectionArgument NameDescription
I2C_TypeDef *[in]i2c

Pointer to the I2C peripheral register block.

uint8_t[in]addr

The I2C address of the sensor.

uint8_t *[out]basePn

Si72xx part ID.

uint8_t *[out]pnVariant

Si72xx part Revision.

Returns

  • Returns zero on success. Otherwise returns error codes based on the I2CSPM.