TLE5012B  3.1.0
The TLE5012B is a pre-calibrated 360° angle sensor that detects the orientation of a magnetic field. The raw signals (sine and cosine) are digitally processed internally to calculate the angle orientation of the magnetic field (magnet).
Tle5012b base API
Collaboration diagram for Tle5012b base API:

Data Structures

class  Tle5012b
 
struct  Tle5012b::safetyWord
 

Enumerations

enum  Tle5012b::slaveNum { Tle5012b::TLE5012B_S0 = 0x0000 , Tle5012b::TLE5012B_S1 = 0x2000 , Tle5012b::TLE5012B_S2 = 0x4000 , Tle5012b::TLE5012B_S3 = 0x6000 }
 

Functions

slaveNum Tle5012b::safetyWord::responseSlave ()
 Returns the safety word slave number to identify the sensor. More...
 
uint16_t Tle5012b::safetyWord::fetch_Safety (uint16_t reg)
 Function separates safety word bits. More...
 
errorTypes Tle5012b::begin ()
 
errorTypes Tle5012b::begin (uint8_t csPin, slaveNum slave=TLE5012B_S0)
 begin method with default assignments for the SPI bus and the slave setting. Only the csPin is needed. More...
 
errorTypes Tle5012b::readActiveStatus (uint16_t &data)
 read register offset 0x01 More...
 

Variables

SPICTle5012b::sBus
 SPI cover class as representation of the SPI bus. More...
 
GPIOTle5012b::en
 shield enable GPIO to switch sensor2go on/off More...
 
Reg Tle5012b::reg
 Register map. More...
 
slaveNum Tle5012b::mSlave
 actual set slave number More...
 
bool Tle5012b::safetyWord::STAT_RES
 < More...
 
bool Tle5012b::safetyWord::STAT_ERR
 bits 14:14 System error More...
 
bool Tle5012b::safetyWord::STAT_ACC
 bits 13:13 Interface access error More...
 
bool Tle5012b::safetyWord::STAT_ANG
 bits 12:12 Invalid angle value More...
 
uint8_t Tle5012b::safetyWord::RESP
 bits 11:8 Sensor number response indicator More...
 
uint8_t Tle5012b::safetyWord::CRC
 bits 7:0 Status ADC Test More...
 
struct Tle5012b::safetyWord Tle5012b::safetyWord_t
 constructor for the Sensor More...
 
safetyWord Tle5012b::safetyStatus
 
uint16_t Tle5012b::safetyWord
 the last fetched safety word More...
 
uint16_t Tle5012b::_command [2]
 command write data [0] = command [1] = data to write More...
 
uint16_t Tle5012b::_received [MAX_REGISTER_MEM]
 fetched data from sensor with last word = safety word More...
 
uint16_t Tle5012b::_registers [CRC_NUM_REGISTERS+1]
 keeps track of the values stored in the 8 _registers, for which the CRC is calculated More...
 

TLE5012b.cpp - core library for the TLE5012B angle sensor.

GMR-based angle sensor for angular position sensing in automotive applications Core Library

Author
Infineon Technologies AG
Version
3.1.0

SPDX-License-Identifier: MIT

 Tle5012b::Tle5012b ()
 destructor stops the Sensor More...
 
 Tle5012b::~Tle5012b ()
 default begin with standard pin setting More...
 
void Tle5012b::end ()
 
void Tle5012b::enableSensor ()
 
void Tle5012b::disableSensor ()
 
errorTypes Tle5012b::readBlockCRC ()
 
errorTypes Tle5012b::readFromSensor (uint16_t command, uint16_t &data, updTypes upd=UPD_low, safetyTypes safe=SAFE_high)
 
errorTypes Tle5012b::readMoreRegisters (uint16_t command, uint16_t data[], updTypes upd=UPD_low, safetyTypes safe=SAFE_high)
 
errorTypes Tle5012b::readStatus (uint16_t &data, updTypes upd=UPD_low, safetyTypes safe=SAFE_high)
 
errorTypes Tle5012b::readActivationStatus (uint16_t &data, updTypes upd=UPD_low, safetyTypes safe=SAFE_high)
 
errorTypes Tle5012b::readIntMode1 (uint16_t &data)
 read register offset 0x06 More...
 
errorTypes Tle5012b::readSIL (uint16_t &data)
 read register offset 0x07 More...
 
errorTypes Tle5012b::readIntMode2 (uint16_t &data)
 read register offset 0x08 More...
 
errorTypes Tle5012b::readIntMode3 (uint16_t &data)
 read register offset 0x09 More...
 
errorTypes Tle5012b::readOffsetX (uint16_t &data)
 read register offset 0x0A More...
 
errorTypes Tle5012b::readOffsetY (uint16_t &data)
 read register offset 0x0B More...
 
errorTypes Tle5012b::readSynch (uint16_t &data)
 read register offset 0x0C More...
 
errorTypes Tle5012b::readIFAB (uint16_t &data)
 read register offset 0x0D More...
 
errorTypes Tle5012b::readIntMode4 (uint16_t &data)
 read register offset 0x0E More...
 
errorTypes Tle5012b::readTempCoeff (uint16_t &data)
 read register offset 0x0F More...
 
errorTypes Tle5012b::readTempDMag (uint16_t &data)
 read register offset 0x14 More...
 
errorTypes Tle5012b::readTempRaw (uint16_t &data)
 read register offset 0x15 More...
 
errorTypes Tle5012b::readTempIIFCnt (uint16_t &data)
 read register offset 0x20 More...
 
errorTypes Tle5012b::readTempT25 (uint16_t &data)
 read register offset 0x30 More...
 
errorTypes Tle5012b::readRawX (int16_t &data)
 
errorTypes Tle5012b::readRawY (int16_t &data)
 
errorTypes Tle5012b::getAngleRange (double &angleRange)
 
errorTypes Tle5012b::getAngleValue (double &angleValue)
 
errorTypes Tle5012b::getAngleValue (double &angleValue, int16_t &rawAnglevalue, updTypes upd=UPD_low, safetyTypes safe=SAFE_high)
 
errorTypes Tle5012b::getNumRevolutions (int16_t &numRev, updTypes upd=UPD_low, safetyTypes safe=SAFE_high)
 
errorTypes Tle5012b::getTemperature (double &temp)
 
errorTypes Tle5012b::getTemperature (double &temp, int16_t &rawTemp, updTypes upd=UPD_low, safetyTypes safe=SAFE_high)
 
errorTypes Tle5012b::getAngleSpeed (double &angleSpeed)
 
errorTypes Tle5012b::getAngleSpeed (double &angleSpeed, int16_t &rawSpeed, updTypes upd=UPD_low, safetyTypes safe=SAFE_high)
 
errorTypes Tle5012b::writeSlaveNumber (uint16_t dataToWrite)
 
errorTypes Tle5012b::writeToSensor (uint16_t command, uint16_t dataToWrite, bool changeCRC)
 
errorTypes Tle5012b::writeTempCoeffUpdate (uint16_t dataToWrite)
 
errorTypes Tle5012b::writeActivationStatus (uint16_t dataToWrite)
 write register offset 0x01 More...
 
errorTypes Tle5012b::writeIntMode1 (uint16_t dataToWrite)
 write register offset 0x06 More...
 
errorTypes Tle5012b::writeSIL (uint16_t dataToWrite)
 write register offset 0x07 More...
 
errorTypes Tle5012b::writeIntMode2 (uint16_t dataToWrite)
 write register offset 0x08 More...
 
errorTypes Tle5012b::writeIntMode3 (uint16_t dataToWrite)
 write register offset 0x09 More...
 
errorTypes Tle5012b::writeOffsetX (uint16_t dataToWrite)
 write register offset 0x0A More...
 
errorTypes Tle5012b::writeOffsetY (uint16_t dataToWrite)
 write register offset 0x0B More...
 
errorTypes Tle5012b::writeSynch (uint16_t dataToWrite)
 write register offset 0x0C More...
 
errorTypes Tle5012b::writeIFAB (uint16_t dataToWrite)
 write register offset 0x0D More...
 
errorTypes Tle5012b::writeIntMode4 (uint16_t dataToWrite)
 write register offset 0x0E More...
 
errorTypes Tle5012b::writeTempCoeff (uint16_t dataToWrite)
 write register offset 0x0F More...
 
errorTypes Tle5012b::resetFirmware ()
 
errorTypes Tle5012b::readRegMap ()
 
errorTypes Tle5012b::writeInterfaceType (Reg::interfaceType_t iface)
 
errorTypes Tle5012b::setCalibration (Reg::calibrationMode_t calMode)
 
errorTypes Tle5012b::regularCrcUpdate ()
 
errorTypes Tle5012b::checkSafety (uint16_t safety, uint16_t command, uint16_t *readreg, uint16_t length)
 
void Tle5012b::resetSafety ()
 

Detailed Description


Data Structure Documentation

◆ Tle5012b

class Tle5012b
Inheritance diagram for Tle5012b:
Collaboration diagram for Tle5012b:

Public Types

enum  slaveNum { TLE5012B_S0 = 0x0000 , TLE5012B_S1 = 0x2000 , TLE5012B_S2 = 0x4000 , TLE5012B_S3 = 0x6000 }
 

Public Member Functions

errorTypes begin ()
 
errorTypes begin (uint8_t csPin, slaveNum slave=TLE5012B_S0)
 begin method with default assignments for the SPI bus and the slave setting. Only the csPin is needed. More...
 
errorTypes readActiveStatus (uint16_t &data)
 read register offset 0x01 More...
 

Data Fields

SPICsBus
 SPI cover class as representation of the SPI bus. More...
 
GPIOen
 shield enable GPIO to switch sensor2go on/off More...
 
Reg reg
 Register map. More...
 
slaveNum mSlave
 actual set slave number More...
 
struct Tle5012b::safetyWord safetyWord_t
 constructor for the Sensor More...
 
safetyWord safetyStatus
 
uint16_t safetyWord
 the last fetched safety word More...
 

Protected Attributes

uint16_t _command [2]
 command write data [0] = command [1] = data to write More...
 
uint16_t _received [MAX_REGISTER_MEM]
 fetched data from sensor with last word = safety word More...
 
uint16_t _registers [CRC_NUM_REGISTERS+1]
 keeps track of the values stored in the 8 _registers, for which the CRC is calculated More...
 

TLE5012b.cpp - core library for the TLE5012B angle sensor.

GMR-based angle sensor for angular position sensing in automotive applications Core Library

Author
Infineon Technologies AG
Version
3.1.0

SPDX-License-Identifier: MIT

 Tle5012b ()
 destructor stops the Sensor More...
 
 ~Tle5012b ()
 default begin with standard pin setting More...
 
void end ()
 
void enableSensor ()
 
void disableSensor ()
 
errorTypes readBlockCRC ()
 
errorTypes readFromSensor (uint16_t command, uint16_t &data, updTypes upd=UPD_low, safetyTypes safe=SAFE_high)
 
errorTypes readMoreRegisters (uint16_t command, uint16_t data[], updTypes upd=UPD_low, safetyTypes safe=SAFE_high)
 
errorTypes readStatus (uint16_t &data, updTypes upd=UPD_low, safetyTypes safe=SAFE_high)
 
errorTypes readActivationStatus (uint16_t &data, updTypes upd=UPD_low, safetyTypes safe=SAFE_high)
 
errorTypes readIntMode1 (uint16_t &data)
 read register offset 0x06 More...
 
errorTypes readSIL (uint16_t &data)
 read register offset 0x07 More...
 
errorTypes readIntMode2 (uint16_t &data)
 read register offset 0x08 More...
 
errorTypes readIntMode3 (uint16_t &data)
 read register offset 0x09 More...
 
errorTypes readOffsetX (uint16_t &data)
 read register offset 0x0A More...
 
errorTypes readOffsetY (uint16_t &data)
 read register offset 0x0B More...
 
errorTypes readSynch (uint16_t &data)
 read register offset 0x0C More...
 
errorTypes readIFAB (uint16_t &data)
 read register offset 0x0D More...
 
errorTypes readIntMode4 (uint16_t &data)
 read register offset 0x0E More...
 
errorTypes readTempCoeff (uint16_t &data)
 read register offset 0x0F More...
 
errorTypes readTempDMag (uint16_t &data)
 read register offset 0x14 More...
 
errorTypes readTempRaw (uint16_t &data)
 read register offset 0x15 More...
 
errorTypes readTempIIFCnt (uint16_t &data)
 read register offset 0x20 More...
 
errorTypes readTempT25 (uint16_t &data)
 read register offset 0x30 More...
 
errorTypes readRawX (int16_t &data)
 
errorTypes readRawY (int16_t &data)
 
errorTypes getAngleRange (double &angleRange)
 
errorTypes getAngleValue (double &angleValue)
 
errorTypes getAngleValue (double &angleValue, int16_t &rawAnglevalue, updTypes upd=UPD_low, safetyTypes safe=SAFE_high)
 
errorTypes getNumRevolutions (int16_t &numRev, updTypes upd=UPD_low, safetyTypes safe=SAFE_high)
 
errorTypes getTemperature (double &temp)
 
errorTypes getTemperature (double &temp, int16_t &rawTemp, updTypes upd=UPD_low, safetyTypes safe=SAFE_high)
 
errorTypes getAngleSpeed (double &angleSpeed)
 
errorTypes getAngleSpeed (double &angleSpeed, int16_t &rawSpeed, updTypes upd=UPD_low, safetyTypes safe=SAFE_high)
 
errorTypes writeSlaveNumber (uint16_t dataToWrite)
 
errorTypes writeToSensor (uint16_t command, uint16_t dataToWrite, bool changeCRC)
 
errorTypes writeTempCoeffUpdate (uint16_t dataToWrite)
 
errorTypes writeActivationStatus (uint16_t dataToWrite)
 write register offset 0x01 More...
 
errorTypes writeIntMode1 (uint16_t dataToWrite)
 write register offset 0x06 More...
 
errorTypes writeSIL (uint16_t dataToWrite)
 write register offset 0x07 More...
 
errorTypes writeIntMode2 (uint16_t dataToWrite)
 write register offset 0x08 More...
 
errorTypes writeIntMode3 (uint16_t dataToWrite)
 write register offset 0x09 More...
 
errorTypes writeOffsetX (uint16_t dataToWrite)
 write register offset 0x0A More...
 
errorTypes writeOffsetY (uint16_t dataToWrite)
 write register offset 0x0B More...
 
errorTypes writeSynch (uint16_t dataToWrite)
 write register offset 0x0C More...
 
errorTypes writeIFAB (uint16_t dataToWrite)
 write register offset 0x0D More...
 
errorTypes writeIntMode4 (uint16_t dataToWrite)
 write register offset 0x0E More...
 
errorTypes writeTempCoeff (uint16_t dataToWrite)
 write register offset 0x0F More...
 
errorTypes resetFirmware ()
 
errorTypes readRegMap ()
 
errorTypes writeInterfaceType (Reg::interfaceType_t iface)
 
errorTypes setCalibration (Reg::calibrationMode_t calMode)
 
errorTypes regularCrcUpdate ()
 
errorTypes checkSafety (uint16_t safety, uint16_t command, uint16_t *readreg, uint16_t length)
 
void resetSafety ()
 

◆ Tle5012b::safetyWord

struct Tle5012b::safetyWord

Public Member Functions

slaveNum responseSlave ()
 Returns the safety word slave number to identify the sensor. More...
 
uint16_t fetch_Safety (uint16_t reg)
 Function separates safety word bits. More...
 

Data Fields

bool STAT_RES
 < More...
 
bool STAT_ERR
 bits 14:14 System error More...
 
bool STAT_ACC
 bits 13:13 Interface access error More...
 
bool STAT_ANG
 bits 12:12 Invalid angle value More...
 
uint8_t RESP
 bits 11:8 Sensor number response indicator More...
 
uint8_t CRC
 bits 7:0 Status ADC Test More...
 

Enumeration Type Documentation

◆ slaveNum

Offset for the slave number register to identify the right selected slave. Max 4 slaves with separated CSQ lines are possible. If more than one sensor is used on the SPI interface, than the SNR register must we written with the correct slave number

Enumerator
TLE5012B_S0 

TLE5012B_S0 default setting for only one sensor on the SPI.

TLE5012B_S1 

TLE5012B_S1 second sensor needs also a second CSQ.

TLE5012B_S2 

TLE5012B_S2 third sensor and ditto.

TLE5012B_S3 

TLE5012B_S3 fourth sensor and ditto.

Function Documentation

◆ responseSlave()

slaveNum Tle5012b::safetyWord::responseSlave ( )
inline

Returns the safety word slave number to identify the sensor.

Returns
slaveNum setting in safety word

◆ fetch_Safety()

uint16_t Tle5012b::safetyWord::fetch_Safety ( uint16_t  reg)
inline

Function separates safety word bits.

Parameters
[in,out]regactual safety or last fetched as default
Returns
safety word

◆ Tle5012b()

Tle5012b::Tle5012b ( )

destructor stops the Sensor

◆ ~Tle5012b()

Tle5012b::~Tle5012b ( )

default begin with standard pin setting

Here is the call graph for this function:

◆ begin() [1/2]

errorTypes Tle5012b::begin ( )

◆ begin() [2/2]

errorTypes Tle5012b::begin ( uint8_t  csPin,
slaveNum  slave = TLE5012B_S0 
)

begin method with default assignments for the SPI bus and the slave setting. Only the csPin is needed.

Parameters
csPinpin number of the CS pin
slaveslave offset setting for the SNR register, default is TLE5012B_S0

Ends the comunication and switches the sensor off, if possible (only Sensor2go kit)

◆ end()

void Tle5012b::end ( void  )
Here is the call graph for this function:

◆ enableSensor()

void Tle5012b::enableSensor ( )

Function enables Sensor by switch on EN pin which is only possible on Sensor2go shields, but also sets chipselect high. So it is called always.

Here is the call graph for this function:

◆ disableSensor()

void Tle5012b::disableSensor ( )

Functions disables Sensor by switch off EN pin (only possible on Sensor2go shield)

Here is the call graph for this function:

◆ readBlockCRC()

errorTypes Tle5012b::readBlockCRC ( )

Reads the block of _registers from addresses 08 - 0F in order to figure out the CRC. ATTENTION: You need a memory chunk of unit16_t * CRC Registers + 1 * uint16_t for the safety word.

Returns
CRC error type
Here is the call graph for this function:

◆ readFromSensor()

errorTypes Tle5012b::readFromSensor ( uint16_t  command,
uint16_t &  data,
updTypes  upd = UPD_low,
safetyTypes  safe = SAFE_high 
)

General read function for reading _registers from the Tle5012b.

structure of command word, the numbers represent the bit position of the 2 byte command 15 - 0 write, 1 read 14:11 - 0000 for default operational access for addresses between 0x00 - 0x04, 1010 for configuration access for addresses between 0x05 - 0x11 10 - 0 access to current value, 1 access to value in update buffer 9:4 - access to 6 bit register address 3:0 - 4 bit number of data words.

Parameters
[in]commandthe command for reading
[out]datawhere the data received from the _registers will be stored
[in]updread from update (UPD_high) register or directly (default, UPD_low)
[in]safegenerate safety word (default, SAFE_high) or not (SAFE_low)
Returns
CRC error type
Here is the call graph for this function:

◆ readMoreRegisters()

errorTypes Tle5012b::readMoreRegisters ( uint16_t  command,
uint16_t  data[],
updTypes  upd = UPD_low,
safetyTypes  safe = SAFE_high 
)

Can be used to read 1 or more consecutive _registers, and the values used to read 1 or more than 1 consecutive _registers. The maximum amount of registers are limited by the bit 3-0 of the command word, which means you can read max 15 registers and one safety word at once.

Parameters
[in]commandthe command for reading
[out]datawhere the data received from the _registers will be stored
[in]updread from update (UPD_high) register or directly (default, UPD_low)
[in]safegenerate safety word (default, SAFE_high) or no (SAFE_low)
Returns
CRC error type
Here is the call graph for this function:

◆ readStatus()

errorTypes Tle5012b::readStatus ( uint16_t &  data,
updTypes  upd = UPD_low,
safetyTypes  safe = SAFE_high 
)

This functions reads the main status word for the sensor, mainly for checking with the additional safety word

Parameters
[out]datapointer with the received data word
[in]updread from update (UPD_high) register or directly (default, UPD_low)
[in]safegenerate safety word (default, SAFE_high) or no (SAFE_low)
Returns
CRC error type
Here is the call graph for this function:

◆ readActivationStatus()

errorTypes Tle5012b::readActivationStatus ( uint16_t &  data,
updTypes  upd = UPD_low,
safetyTypes  safe = SAFE_high 
)

This functions reads activation status word for the sensor, which held on/off information for all optional checks and additional functions

Parameters
[out]datapointer with the received data word
[in]updread from update (UPD_high) register or directly (default, UPD_low)
[in]safegenerate safety word (default, SAFE_high) or no (SAFE_low)
Returns
CRC error type
Here is the call graph for this function:

◆ readActiveStatus()

errorTypes Tle5012b::readActiveStatus ( uint16_t &  data)

read register offset 0x01

The next functions are used primarily for storing the parameters and control of how the sensor works. The values stored in them are used to calculate the CRC, and their values are stored in the private component of the class, _registers.

Parameters
[out]datawhere the data received from the _registers will be stored
Returns
CRC error type

◆ readIntMode1()

errorTypes Tle5012b::readIntMode1 ( uint16_t &  data)

read register offset 0x06

Here is the call graph for this function:

◆ readSIL()

errorTypes Tle5012b::readSIL ( uint16_t &  data)

read register offset 0x07

Here is the call graph for this function:

◆ readIntMode2()

errorTypes Tle5012b::readIntMode2 ( uint16_t &  data)

read register offset 0x08

Here is the call graph for this function:

◆ readIntMode3()

errorTypes Tle5012b::readIntMode3 ( uint16_t &  data)

read register offset 0x09

Here is the call graph for this function:

◆ readOffsetX()

errorTypes Tle5012b::readOffsetX ( uint16_t &  data)

read register offset 0x0A

Here is the call graph for this function:

◆ readOffsetY()

errorTypes Tle5012b::readOffsetY ( uint16_t &  data)

read register offset 0x0B

Here is the call graph for this function:

◆ readSynch()

errorTypes Tle5012b::readSynch ( uint16_t &  data)

read register offset 0x0C

Here is the call graph for this function:

◆ readIFAB()

errorTypes Tle5012b::readIFAB ( uint16_t &  data)

read register offset 0x0D

Here is the call graph for this function:

◆ readIntMode4()

errorTypes Tle5012b::readIntMode4 ( uint16_t &  data)

read register offset 0x0E

Here is the call graph for this function:

◆ readTempCoeff()

errorTypes Tle5012b::readTempCoeff ( uint16_t &  data)

read register offset 0x0F

Here is the call graph for this function:

◆ readTempDMag()

errorTypes Tle5012b::readTempDMag ( uint16_t &  data)

read register offset 0x14

Here is the call graph for this function:

◆ readTempRaw()

errorTypes Tle5012b::readTempRaw ( uint16_t &  data)

read register offset 0x15

Here is the call graph for this function:

◆ readTempIIFCnt()

errorTypes Tle5012b::readTempIIFCnt ( uint16_t &  data)

read register offset 0x20

Here is the call graph for this function:

◆ readTempT25()

errorTypes Tle5012b::readTempT25 ( uint16_t &  data)

read register offset 0x30

Here is the call graph for this function:

◆ readRawX()

errorTypes Tle5012b::readRawX ( int16_t &  data)

The rawX value is signed 16 bit value

Parameters
datapointer to 16bit word
Returns
CRC error type
Here is the call graph for this function:

◆ readRawY()

errorTypes Tle5012b::readRawY ( int16_t &  data)

The rawY value is signed 16 bit value

Parameters
datapointer to 16bit word
Returns
CRC error type
Here is the call graph for this function:

◆ getAngleRange()

errorTypes Tle5012b::getAngleRange ( double &  angleRange)

Returns the Angle Range Angle Range is stored in bytes 14 - 4 of MOD_2.

Parameters
angleRangepointer to 16bit double value
Returns
CRC error type
Here is the call graph for this function:

◆ getAngleValue() [1/2]

errorTypes Tle5012b::getAngleValue ( double &  angleValue)

Returns the angleValue calculated on the base of a 15 bit signed integer. However, the register returns 16 bits, so we need to do some bit arithmetic.

Parameters
[in,out]angleValuepointer to 16bit double angle value
Returns
CRC error type

◆ getAngleValue() [2/2]

errorTypes Tle5012b::getAngleValue ( double &  angleValue,
int16_t &  rawAnglevalue,
updTypes  upd = UPD_low,
safetyTypes  safe = SAFE_high 
)

Same function as before but also returns a pointer to the raw data

Parameters
[in,out]angleValuepointer to 16bit double angle value
[in,out]rawAnglevaluepoint to an int16_t raw data value
[in]updread from update (UPD_high) register or directly (default, UPD_low)
[in]safegenerate safety word (default, SAFE_high) or no (SAFE_low)
Returns
CRC error type
Here is the call graph for this function:

◆ getNumRevolutions()

errorTypes Tle5012b::getNumRevolutions ( int16_t &  numRev,
updTypes  upd = UPD_low,
safetyTypes  safe = SAFE_high 
)

Returns the number of revolutions done from the angle value which is a 9 bit signed integer. However, the register returns 16 bits, so we need to do some bit arithmetic. Therefore the resulting revolution can b only between -256 < numRev < 256 and it will switch from positive to negative and vice versa values at the borders.

Parameters
[in,out]numRevpointer to 16bit word for the number of revolutions
[in]updread from update (UPD_high) register or directly (default, UPD_low)
[in]safegenerate safety word (default, SAFE_high) or no (SAFE_low)
Returns
CRC error type
Here is the call graph for this function:

◆ getTemperature() [1/2]

errorTypes Tle5012b::getTemperature ( double &  temp)

Return the temperature. The temperature value is a 9 bit signed integer. However, the register returns 16 bits, so we need to do some bit arithmetic.

Parameters
[in,out]temppointer to 16bit double value of the temperature
Returns
CRC error type

◆ getTemperature() [2/2]

errorTypes Tle5012b::getTemperature ( double &  temp,
int16_t &  rawTemp,
updTypes  upd = UPD_low,
safetyTypes  safe = SAFE_high 
)

Same as above but also returns a pointer to the raw data

Parameters
[in,out]temppointer to 16bit double value of the temperature
[in,out]rawTemppointer to int16_t raw value data
[in]updread from update (UPD_high) register or directly (default, UPD_low)
[in]safegenerate safety word (default, SAFE_high) or no (SAFE_low)
Returns
CRC error type
Here is the call graph for this function:

◆ getAngleSpeed() [1/2]

errorTypes Tle5012b::getAngleSpeed ( double &  angleSpeed)

Returns the calculated angle speed. The angle speed is a 15 bit signed integer, however, the register returns 16 bits, so we need to do some bit arithmetic.

Parameters
[in,out]angleSpeedpointer to 16bit double value
Returns
CRC error type

◆ getAngleSpeed() [2/2]

errorTypes Tle5012b::getAngleSpeed ( double &  angleSpeed,
int16_t &  rawSpeed,
updTypes  upd = UPD_low,
safetyTypes  safe = SAFE_high 
)

Same as above but also returns a pointer to the raw data

Parameters
[in,out]angleSpeedangleSpeed pointer to 16bit double value
[in,out]rawSpeedpointer to int16_t raw value data
[in]updread from update (UPD_high) register or directly (default, UPD_low)
[in]safegenerate safety word (default, SAFE_high) or no (SAFE_low)
Returns
CRC error type
Here is the call graph for this function:

◆ writeSlaveNumber()

errorTypes Tle5012b::writeSlaveNumber ( uint16_t  dataToWrite)

Function sets the SNR register with the correct slave number

Parameters
[in]dataToWritethe new data that will be written to the register
Returns
CRC error type
Here is the call graph for this function:

◆ writeToSensor()

errorTypes Tle5012b::writeToSensor ( uint16_t  command,
uint16_t  dataToWrite,
bool  changeCRC 
)

General write function for writing registers to the Tle5012b. The safety flag will be set always and only some of all registers are writable. See documentation for further information.

Parameters
[in]commandthe command to execute the write
[in]dataToWritethe new data that will be written to the register
[in]changeCRCthe registerIndex helps figure out in which register the value changed, so that we don't need to read all the register again to calculate the CRC
Returns
CRC error type
Here is the call graph for this function:

◆ writeTempCoeffUpdate()

errorTypes Tle5012b::writeTempCoeffUpdate ( uint16_t  dataToWrite)

This function is used in order to update the CRC in the register 0F(second byte)

Parameters
[in]dataToWritethe new data that will be written to the register
Returns
CRC error type
Here is the call graph for this function:

◆ writeActivationStatus()

errorTypes Tle5012b::writeActivationStatus ( uint16_t  dataToWrite)

write register offset 0x01

Standard function used for updating the CRC

Parameters
[in]dataToWritethe new data that will be written to the register
Returns
CRC error type
Here is the call graph for this function:

◆ writeIntMode1()

errorTypes Tle5012b::writeIntMode1 ( uint16_t  dataToWrite)

write register offset 0x06

Here is the call graph for this function:

◆ writeSIL()

errorTypes Tle5012b::writeSIL ( uint16_t  dataToWrite)

write register offset 0x07

Here is the call graph for this function:

◆ writeIntMode2()

errorTypes Tle5012b::writeIntMode2 ( uint16_t  dataToWrite)

write register offset 0x08

Here is the call graph for this function:

◆ writeIntMode3()

errorTypes Tle5012b::writeIntMode3 ( uint16_t  dataToWrite)

write register offset 0x09

Here is the call graph for this function:

◆ writeOffsetX()

errorTypes Tle5012b::writeOffsetX ( uint16_t  dataToWrite)

write register offset 0x0A

Here is the call graph for this function:

◆ writeOffsetY()

errorTypes Tle5012b::writeOffsetY ( uint16_t  dataToWrite)

write register offset 0x0B

Here is the call graph for this function:

◆ writeSynch()

errorTypes Tle5012b::writeSynch ( uint16_t  dataToWrite)

write register offset 0x0C

Here is the call graph for this function:

◆ writeIFAB()

errorTypes Tle5012b::writeIFAB ( uint16_t  dataToWrite)

write register offset 0x0D

Here is the call graph for this function:

◆ writeIntMode4()

errorTypes Tle5012b::writeIntMode4 ( uint16_t  dataToWrite)

write register offset 0x0E

Here is the call graph for this function:

◆ writeTempCoeff()

errorTypes Tle5012b::writeTempCoeff ( uint16_t  dataToWrite)

write register offset 0x0F

Here is the call graph for this function:

◆ resetFirmware()

errorTypes Tle5012b::resetFirmware ( )

Function reset the Sensor to fuse defaults

Returns
CRC error type
Here is the call graph for this function:

◆ readRegMap()

errorTypes Tle5012b::readRegMap ( )

Function reads all readable sensor registers and separates the information fields. This function is needed for finding the selected interface type.

Returns
CRC error type
Here is the call graph for this function:

◆ writeInterfaceType()

errorTypes Tle5012b::writeInterfaceType ( Reg::interfaceType_t  iface)

Functions switches between all possible interface types. ATTENTION: The different interfaces support not always all values, see documentation for the ability of each interface. If you want to be save, than choose the default SSC interface which always supports all possible parameter.

Parameters
ifacetype of interface to switch to
Returns
CRC error type
Here is the call graph for this function:

◆ setCalibration()

errorTypes Tle5012b::setCalibration ( Reg::calibrationMode_t  calMode)

Function set the sensors calibration mode. Keep in mind, not all Sensor interface setups have the autocalibration switched on, so maybe you have to set it explicitly.

Parameters
[in]calModethe auto calibration mode to set
Returns
CRC error type
Here is the call graph for this function:

◆ regularCrcUpdate()

errorTypes Tle5012b::regularCrcUpdate ( )
protected

This function is called each time any register in the range 08 - 0F(first byte) is changed. It calculates the new CRC based on the value of all the _registers and then stores the value in 0F(second byte)

Returns
CRC error type
Here is the call graph for this function:

◆ checkSafety()

errorTypes Tle5012b::checkSafety ( uint16_t  safety,
uint16_t  command,
uint16_t *  readreg,
uint16_t  length 
)
protected

checks the safety by looking at the safety word and calculating the CRC such that the data received is valid

Parameters
safetyregister with the CRC check data
commandthe command to execute the write
readregpointer to the read data
lengththe length of the data structure
Returns
CRC error type
Here is the call graph for this function:

◆ resetSafety()

void Tle5012b::resetSafety ( )
protected

When an error occurs in the safety word, the error bit remains 0(error), until the status register is read again. Flushes out safety errors, that might have occurred by reading the register without a safety word. In case the safety word sends an error, this function is called so that the error bit is reset to 1.

Here is the call graph for this function:

Variable Documentation

◆ sBus

SPIC* Tle5012b::sBus

SPI cover class as representation of the SPI bus.

◆ en

GPIO* Tle5012b::en

shield enable GPIO to switch sensor2go on/off

◆ reg

Reg Tle5012b::reg

Register map.

◆ mSlave

slaveNum Tle5012b::mSlave

actual set slave number

◆ STAT_RES

bool Tle5012b::safetyWord::STAT_RES

<

Safety word bit setting

bits 15:15 Indication of chip reset or watchdog overflow

◆ STAT_ERR

bool Tle5012b::safetyWord::STAT_ERR

bits 14:14 System error

◆ STAT_ACC

bool Tle5012b::safetyWord::STAT_ACC

bits 13:13 Interface access error

◆ STAT_ANG

bool Tle5012b::safetyWord::STAT_ANG

bits 12:12 Invalid angle value

◆ RESP

uint8_t Tle5012b::safetyWord::RESP

bits 11:8 Sensor number response indicator

◆ CRC

uint8_t Tle5012b::safetyWord::CRC

bits 7:0 Status ADC Test

◆ safetyWord_t

struct Tle5012b::safetyWord Tle5012b::safetyWord_t

constructor for the Sensor

◆ safetyStatus

safetyWord Tle5012b::safetyStatus

◆ safetyWord

the last fetched safety word

◆ _command

uint16_t Tle5012b::_command[2]
protected

command write data [0] = command [1] = data to write

◆ _received

uint16_t Tle5012b::_received[MAX_REGISTER_MEM]
protected

fetched data from sensor with last word = safety word

◆ _registers

uint16_t Tle5012b::_registers[CRC_NUM_REGISTERS+1]
protected

keeps track of the values stored in the 8 _registers, for which the CRC is calculated