API Reference
TLx493D 3D Magnetic Sensor API
The following section shows you the API of the TLx493D base class.
-
class TLx493DBase
The class
TLx493DBaseis the base class of the different TLx493D sensors variants. It defines all available functions of the sensors and routes the member function calls to the underlying c-function calls, which will be executed in the end.Subclassed by ifx::tlx493d::TLx493D< BoardSupportClass, BusWrapper, sensorType >, ifx::tlx493d::TLx493D< BoardSupport, SPIClassWrapper, sensorType >, ifx::tlx493d::TLx493D< BoardSupport, TwoWireWrapper, sensorType >
Public Functions
-
inline ~TLx493DBase()
The function
~TLx493DBaseis the destructor of the TLx493DBase class object.
-
inline bool readRegisters()
The function
readRegistersreads registers from a TLx493D sensor. It is reading out the complete register map of the sensor and is saving the current values to the “internal” register map of the sensor object.- Return values:
false – Error.
true – Function execution was successful.
- Returns:
The function
readRegistersis returning a boolean value.
-
inline bool getRawTemperature(int16_t *temperature)
The function
getRawTemperatureretrieves the raw temperature from a TLx493D sensor. It is reading out the temperature registers of the sensor and is returning its value as LSB.- Parameters:
temperature – [inout] A pointer to an int16_t variable where the raw temperature value will be stored.
- Return values:
false – Error.
true – Function execution was successful.
- Returns:
The function
tlx493d_getRawTemperatureis returning a boolean value.
-
inline bool getRawMagneticField(int16_t *x, int16_t *y, int16_t *z)
The function
getRawMagneticFieldretrieves the raw magnetic field values from a TLx493D sensor. It is reading the magnetic field value registers of the sensor and is returning them as LSB for the X, Y, Z-direction.- Parameters:
x – [inout] A pointer to a variable where the raw magnetic field value along the x-axis will be stored.
y – [inout] A pointer to a variable where the raw magnetic field value along the y-axis will be stored.
z – [inout] A pointer to a variable where the raw magnetic field value along the z-axis will be stored.
- Return values:
false – Error.
true – Function execution was successful.
- Returns:
The function
getRawMagneticFieldis returning a boolean value.
-
inline bool getRawMagneticFieldAndTemperature(int16_t *x, int16_t *y, int16_t *z, int16_t *temp)
The function
getRawMagneticFieldAndTemperatureretrieves the raw magnetic field and temperature values from a TLx493D sensor. It is reading out the magnetic field value registers, as well as the temperature value registers of the sensor and is returning them as LSB.- Parameters:
x – [inout] A pointer to a variable where the raw magnetic field value along the x-axis will be stored.
y – [inout] A pointer to a variable where the raw magnetic field value along the y-axis will be stored.
z – [inout] A pointer to a variable where the raw magnetic field value along the z-axis will be stored.
temp – [inout] A pointer to a variable where the raw temperature value will be stored.
- Return values:
false – Error.
true – Function execution was successful.
- Returns:
The function
getRawMagneticFieldAndTemperatureis returning a boolean value.
-
inline bool getTemperature(double *temperature)
The function
getTemperatureretrieves the temperature from a TLx493D sensor in °C. It is reading out the temperature registers of the sensor and converts the values into °C with the formula that is provided in the datasheet of the sensor.- Parameters:
temperature – [inout] A pointer to a double variable where the temperature value will be stored in °C.
- Return values:
false – Error.
true – Function execution was successful.
- Returns:
The function
getTemperatureis returning a boolean value.
-
inline bool getMagneticField(double *x, double *y, double *z)
The function
getMagneticFieldretrieves the magnetic field values from a TLx493D sensor. It is reading out the magnetic field value registers of the sensor and is converting the retrieved data into values in mT for each magnetic field axis.- Parameters:
x – [inout] A pointer to a variable where the magnetic field value in mT along the x-axis will be stored.
y – [inout] A pointer to a variable where the magnetic field value in mT along the y-axis will be stored.
z – [inout] A pointer to a variable where the magnetic field value in mT along the z-axis will be stored.
- Return values:
false – Error.
true – Function execution was successful.
- Returns:
The function
getMagneticFieldis returning a boolean value.
-
inline bool getMagneticFieldAndTemperature(double *x, double *y, double *z, double *temp)
The function
getMagneticFieldAndTemperatureretrieves the magnetic field and temperature readings from a TLx493D sensor. It combines the two functionsgetMagneticFieldAndTemperatureandtlx493d_getMagneticFieldin order to have one function which is providing the temperature as well as the magnetic field values of the sensor.- Parameters:
x – [inout] A pointer to a variable where the magnetic field value in mT along the x-axis will be stored.
y – [inout] A pointer to a variable where the magnetic field value in mT along the y-axis will be stored.
z – [inout] A pointer to a variable where the magnetic field value in mT along the z-axis will be stored.
temp – [inout] A pointer to a double variable where the temperature value in °C will be stored.
- Return values:
false – Error.
true – Function execution was successful.
- Returns:
The function
getMagneticFieldAndTemperatureis returning a boolean value.
-
inline bool setMeasurement(TLx493D_MeasurementType_t meas)
The function
setMeasurementsets the measurement type for a TLx493D sensor. It is writing to the corresponding bitfields in the config-register in order to set the desired measuring mode of the sensor.- Parameters:
meas – [in] The
measparameter is of typeTLx493D_MeasurementType_t, which is an enumeration type representing different measurement types for the TLx493D sensor. All available options can be found in the enumTLx493D_MeasurementType_tin the library filetlx493d_types.h.- Return values:
false – Error.
true – Function execution was successful.
- Returns:
The function
setMeasurementis returning a boolean value.
-
inline bool setTrigger(TLx493D_TriggerType_t bits)
The function
setTriggersets the trigger type for a TLx493D sensor. It is writing to the corresponding bitfields in the config-register in order to set the desired trigger mode of the sensor.- Parameters:
bits – [in] The
bitsparameter is of typeTLx493D_TriggerType_t, which is an enumeration type representing different trigger types for the TLx493D sensor. All the available options can be found in the enumTLx493D_TriggerType_tin the library filetlx493d_types.- Return values:
false – Error.
true – Function execution was successful.
- Returns:
The function
setTriggeris returning a boolean value.
-
inline bool setSensitivity(TLx493D_SensitivityType_t range)
The function
setSensitivitysets the sensitivity of a TLx493D sensor. It is writing to the corresponding bitfields in the registers of the sensor in order to set the desired measuring range.- Parameters:
range – [in] The
rangeparameter is of type `TLx493D_SensitivityType_t, which is an enumeration type that represents the sensitivity range of the sensor. All available options can be found in the enumTLx493D_SensitivityType_tin the library filetlx493d_types.- Return values:
false – Error.
true – Function execution was successful.
- Returns:
The function
setSensitivityis returning a boolean value.
-
inline bool setDefaultConfig()
The function
setDefaultConfigsets the default configuration for a TLx493D sensor. It puts the sensor into the 1-Byte-Read-Mode and turns off the interrupt. This is required to guarantee the proper functionality of the sensor.- Return values:
false – Error.
true – Function execution was successful.
- Returns:
The function
setDefaultConfigis returning a boolean value.
-
inline bool setIICAddress(TLx493D_IICAddressType_t addr)
The function
setIICAddresssets the IIC address of a TLx493D sensor. It is writing to the corresponding bitfields of the sensor in order to change the I2C-Default-Address of the sensor to the desired address of the user.- Parameters:
addr – [in] The
addrparameter is of typeTLx493D_IICAddressType_t, which is an enumeration type representing the I2C address of the sensor. You can see all available addresses in the enumTLx493D_IICAddressType_tin the library filetlx493d_types.h.- Return values:
false – Error.
true – Function execution was successful.
- Returns:
The function
setIICAddressis returning a boolean value.
-
inline bool enableCollisionAvoidance()
The function
enableCollisionAvoidanceenables collision avoidance for a TLx493D sensor.- Return values:
false – Error.
true – Function execution was successful.
- Returns:
The function
enableCollisionAvoidanceis returning a boolean value.
-
inline bool disableCollisionAvoidance()
The function
disableCollisionAvoidancedisables collision avoidance for a TLx493D sensor.- Return values:
false – Error.
true – Function execution was successful.
- Returns:
The function
disableCollisionAvoidanceis returning a boolean value.
-
inline bool enableInterrupt()
The function
enableInterruptenables interrupts for a TLx493D sensor.- Return values:
false – Error.
true – Function execution was successful.
- Returns:
The function
enableInterruptis returning a boolean value.
-
inline bool disableInterrupt()
The function
disableInterruptis used to disable interrupts for a TLx493D sensor.- Return values:
false – Error.
true – Function execution was successful.
- Returns:
The function
disableInterruptis returning a boolean value.
-
inline bool setPowerMode(TLx493D_PowerModeType_t mode)
The function
setPowerModesets the power mode of a TLx493D sensor. It is writing to the corresponding bitfields of the sensor in order to set one of the three available power modes of the sensor.- Parameters:
mode – [in] The
modeparameter is of typeTLx493D_PowerModeType_t, which is an enumeration type representing different power modes for the TLx493D sensor. All available options can be found in the enumTLx493D_PowerModeType_tin the library filetlx493d_types.h.- Return values:
false – Error.
true – Function execution was successful.
- Returns:
The function
setPowerModeis returning a boolean value.
-
inline bool setUpdateRate(TLx493D_UpdateRateType_t bit)
The function
setUpdateRatesets the update rate of a TLx493D sensor. It is writing to the corresponding bitfields of the sensor in order to set the desired update frequency, with which the sensor will update his measured values.- Parameters:
bit – [in] The
bitparameter is of typeTLx493D_UpdateRateType_t, which is an enumeration type representing different update rates for the sensor. All available options can be found in the enumTLx493D_UpdateRateType_tin the library file ´tlx493d_types.h`.- Return values:
false – Error.
true – Function execution was successful.
- Returns:
The function
setUpdateRateis returning a boolean value.
-
inline bool hasValidData()
The function
hasValidDatachecks if the TLx493D sensor has valid data. It is checking the corresponding bitfield of the sensor which indicates if the acquired measurement data is valid or not.- Return values:
false – Error.
true – Function execution was successful.
- Returns:
The function
hasValidDatais returning a boolean value.
-
inline bool isFunctional()
The function
isFunctionalchecks if a TLx493D sensor is functional. It checks the internal fuse parity bit as well as the config parity bit in order to confirm that the sensor is still functional.- Return values:
false – Error.
true – Function execution was successful.
- Returns:
The function
isFunctionalis returning a boolean value.
-
inline bool hasWakeUp()
The function
hasWakeUpchecks if a TLx493D sensor has wake-up functionality. It simply checks the bitfield which indicates if the sensor has a wake-up functionality or not.- Return values:
false – Error.
true – Function execution was successful.
- Returns:
The function
hasWakeUpis returning a boolean value.
-
inline bool isWakeUpEnabled()
The function
isWakeUpEnabledchecks if wake-up mode is enabled for a TLx493D sensor. It checks the bitfield of the sensor which gives you the information if the wake-up is enabled or not.- Return values:
false – Error.
true – Function execution was successful.
- Returns:
The function
isWakeUpEnabledis returning a boolean value.
-
inline bool enableWakeUpMode()
The function
enableWakeUpModeenables the wake-up mode for the TLx493D sensor.- Return values:
false – Error.
true – Function execution was successful.
- Returns:
The function
enableWakeUpModeis returning a boolean value.
-
inline bool disableWakeUpMode()
The function
disableWakeUpModedisables the wake-up mode of a TLx493D sensor.- Return values:
false – Error.
true – Function execution was successful.
- Returns:
The function
disableWakeUpModeis returning a boolean value.
-
inline bool setWakeUpThresholdsAsInteger(int16_t xl_th, int16_t xh_th, int16_t yl_th, int16_t yh_th, int16_t zl_th, int16_t zh_th)
The function
setWakeUpThresholdsAsIntegersets the wake-up thresholds for a TLx493D sensor using integer values. It sets the lower and upper threshold for each of three axis. If one of these thresholds is exceeded the sensor will trigger an interrupt. It will continue to trigger interrupts as long as the threshold is exceeded.- Parameters:
xl_th – [in] The lower threshold value for the magnetic field in x-axis.
xh_th – [in] The upper threshold value for the magnetic field in x-axis.
yl_th – [in] The lower threshold value for the magnetic field in y-axis.
yh_th – [in] The upper threshold value for the magnetic field in y-axis.
zl_th – [in] The lower threshold value for the magnetic field in z-axis.
zh_th – [in] The upper threshold value for the magnetic field in z-axis.
- Return values:
false – Error.
true – Function execution was successful.
- Returns:
The function
setWakeUpThresholdsAsIntegeris returning a boolean value.
-
inline bool setWakeUpThresholds(double temperature, double xl_th, double xh_th, double yl_th, double yh_th, double zl_th, double zh_th)
The function
setWakeUpThresholdssets the wake-up thresholds for the TLx493D sensor in mT. It sets the lower and upper threshold for each of three axis in mT. If one of these thresholds is exceeded the sensor will trigger an interrupt. It will continue to trigger interrupts as long as the threshold is exceeded.- Parameters:
temperature – [in] The temperature to be used for derating the field values.
xl_th – [in] The lower threshold value for the magnetic field in x-axis.
xh_th – [in] The upper threshold value for the magnetic field in x-axis.
yl_th – [in] The lower threshold value for the magnetic field in y-axis.
yh_th – [in] The upper threshold value for the magnetic field in y-axis.
zl_th – [in] The lower threshold value for the magnetic field in z-axis.
zh_th – [in] The upper threshold value for the magnetic field in z-axis.
- Return values:
false – Error.
true – Function execution was successful.
- Returns:
The function
setWakeUpThresholdsis returning a boolean value.
-
inline bool softwareReset()
The function
softwareResetperforms a software reset on the TLx493D sensor.- Return values:
false – Error.
true – Function execution was successful.
- Returns:
The function
softwareResetis returning a boolean value.
-
inline const char *getTypeAsString()
The function
getTypeAsStringreturns the type of the TLx493D sensor as a string.- Returns:
The function
tlx493d_getTypeAsStringreturns a pointer to a constant character string.
-
inline void calculateRawMagneticFieldAtTemperature(int16_t rawTemp, TLx493D_SensitivityType_t sens, double xInmT, double yInmT, double zInmT, int16_t *x, int16_t *y, int16_t *z)
The function
calculateRawMagneticFieldAtTemperaturecalculates the raw magnetic field at a given temperature.- Parameters:
rawTemp – [in] The raw temperature value obtained from the sensor.
sens – [in] The parameter
sensis of typeTLx493D_SensitivityType_t, which is an enumeration type representing the sensitivity level of the sensor. It is used to specify the desired sensitivity level for calculating the raw magnetic field.xInmT – [in] The parameter
xInmTrepresents the magnetic field strength in Millitesla (mT) along the x-axis.yInmT – [in] The parameter
yInmTrepresents the magnetic field strength in Millitesla (mT) along the y-axis.zInmT – [in] The parameter
zInmTrepresents the magnetic field strength in Millitesla (mT) along the z-axis.x – [inout] A pointer to a variable where the calculated raw magnetic field in the x-axis will be stored.
y – [inout] A pointer to a variable where the calculated raw magnetic field in the y-axis will be stored.
z – [inout] A pointer to a variable where the calculated raw magnetic field in the z-axis will be stored.
-
inline void printRegisters()
The function
printRegistersprints out the internal registers of the sensor object. It can be used to check certain values of the sensor register map.
-
inline TLx493D_t *getSensor()
The function
getSensorretrieves the sensor object of the class.- Returns:
A pointer to the sensor structure
TLx493D_t.
-
inline TLx493D_SupportedSensorType_t getSensorType()
The function
getSensorTyperetrieves the specific sensor type from the sensor object.- Returns:
A
TLx493D_SupportedSensorType_tenum which contains the specific sensor type.
-
inline TLx493D_SupportedComLibraryInterfaceType_t getComLibIFType()
The function
getComLibIFTypeis returning the communication interface of the sensor. It is reading out the corresponding structure member of the sensor object.- Return values:
TLx493D_I2C_e – If the sensor communication interface is set to I2C.
TLx493D_SPI_e – If the sensor communication interface is set to SPI.
- Returns:
A
TLx493D_SupportedComLibraryInterfaceType_tenum which contains the communication interface type.
-
inline uint8_t *getRegisterMap()
The function
getRegisterMapgets the internal register map of the sensor object.- Returns:
A pointer to the register map array with its saved values.
-
inline uint8_t getRegisterMapSize()
The function
getRegisterMapSizereturns the register map size of the internal register map of the sensor object.- Returns:
Size of the internal register map.
-
inline uint8_t getI2CAddress()
The function
getI2CAddressis returning the I2C address of the sensor. It is reading out the I2C address stored within the sensor object.- Returns:
I2C address of the sensor.
Protected Functions
-
inline TLx493DBase()
The function
TLx493DBaseis the constructor of the class.
-
inline ~TLx493DBase()
TLx493D 3D Magnetic Sensor Arduino API
The following sections shows you the specific implementation of the Tlx493d classes for Arduino. The classes are inheriting most of their functionality from the Tlx493Base class, but also define the necessary interfaces (SPI, I2C) depending on the sensor.
-
namespace ifx
std includes. project c includes.
std includes. project cpp includes. project c includes.
Arduino includes.
-
namespace tlx493d
-
template<typename BoardSupport, TLx493D_SupportedSensorType_t sensorType>
class TLx493D<BoardSupport, TwoWireWrapper, sensorType> : public ifx::tlx493d::TLx493DBase - #include <TLx493D.hpp>
Specialization of the template class
TLx493Dfor the IIC interface.- Template Parameters:
BoardSupport – A helper class, which takes care of needed power pins as well user defined pins.
TwoWireWrapper – A wrapper for the I2C-class.
sensorType – Specific sensor type of the used sensor.
Public Types
-
using BoardSupportType = BoardSupport
-
using BusWrapperType = TwoWireWrapper
-
using BusType = typename BusWrapperType::BusType
Public Functions
-
inline explicit TLx493D(BusType &busObj, TLx493D_IICAddressType_t iicAdr = TLx493D_IIC_ADDR_A0_e)
Class constructor.
-
inline ~TLx493D()
The function
~TLx493Dis the destructor of the template class.
-
inline bool init(bool enablePower = true, bool enableSelect = false, bool enableExtendedAdress = false, bool executeInit = true)
The function
initinitializes all necessary peripherals of the chosen sensor board. It initializes the BoardSupportClass, the communication interface and calls thesetDefaultConfigfunction in order to disable the interrupt of the sensor and putting it into 1-Byte-Read-Mode.- Parameters:
enablePower – [in] Tells the BoardSupportClass, whether it should turn the power pins on or keep them off at initialization.
enableSelect – [in] Tells the BoardSupportClass, whether it should turn the select pins on or keep them off at initialization.
enableExtendedAdress – [in] Enable or disable the extended address feature of the sensor.
executeInit – [in] Whether to execute the bus objects init method upon initializing the communication. True - by default.
- Return values:
false – Error.
true – Function execution was successful.
- Returns:
The function
initreturns a boolean value.
-
inline bool begin(bool enablePower = true, bool enableSelect = false, bool enableExtendedAdress = false, bool executeInit = true)
The function
begincalls theinitfunction with the corresponding parameters. Detailed description seeinitfunction.- Parameters:
enablePower – [in] Tells the BoardSupportClass, whether it should turn the power pins on or keep them off at initialization. True - by default.
enableSelect – [in] Tells the BoardSupportClass, whether it should turn the select pins on or keep them off at initialization. False - by default.
enableExtendedAdress – [in] Enable or disable the extended address feature of the sensor. False - by default.
executeInit – [in] Whether to execute the bus objects init method upon initializing the communication. True - by default.
- Return values:
false – Error.
true – Function execution was successful.
- Returns:
The function
beginreturns a boolean value.
-
inline bool deinit(bool executeDeinit = false)
The function
deinitde-initializes the sensor and its peripherals. It de-initializes the communication interface, the BoardSupportClass as well as all allocated memory (free the memory to be precise).- Parameters:
executeDeinit – [in] Whether to execute the bus objects deinit method upon deinitializing the communication.
- Return values:
false – Error.
true – Function execution was successful.
- Returns:
The function
deinitreturns a boolean value.
-
inline bool end(bool executeDeinit = false)
The function
endcalls thedeinitfunction. For details take a look at thedeinitfunction.- Parameters:
executeDeinit – [in] Whether to execute the bus objects deinit method upon deinitializing the communication.
- Return values:
false – Error.
true – Function execution was successful.
- Returns:
The function
endreturns a boolean value.
-
inline void setPowerPin(uint8_t pinNumber, uint8_t pinDriveDirection, uint8_t pinTristateDirection, uint8_t pinEnableValue, uint8_t pinDisableValue, uint32_t delayAfterEnable = 0, uint32_t delayAfterDisable = 0)
The function
setPowerPindefines a power pin, which can be used to power up the sensor.- Parameters:
pinNumber – [in] Pin number of the desired pin.
pinDirection – [in] Pin direction of the pin (OUTPUT, INPUT, INPUT-PULLUP).
pinEnableValue – [in] Value to enable the power pin, depends on the pin (Active high or low).
pinDisableValue – [in] Value to disable the power pin, depends on the pin (Active high or low).
delayAfterEnable – [in] Delay after enabling the power pin in [ms].
delayAfterDisable – [in] Delay after disabling the power pin in [ms].
-
inline void unsetPowerPin()
The function
unsetPowerPindoes remove the power pin from the BoardSupportClass.
-
inline void setSelectPin(uint8_t pinNumber, uint8_t pinDriveDirection, uint8_t pinTristateDirection, uint8_t pinEnableValue, uint8_t pinDisableValue, uint32_t delayAfterEnable = 0, uint32_t delayAfterDisable = 0)
The function
setSelectPindefines a select pin, which can be used as chip select for the SPI communication or similar purposes.- Parameters:
pinNumber – [in] Pin number of the desired pin.
pinDirection – [in] Pin direction of the pin (OUTPUT, INPUT, INPUT-PULLUP).
pinEnableValue – [in] Value to enable the power pin, depends on the pin (Active high or low).
pinDisableValue – [in] Value to disable the power pin, depends on the pin (Active high or low).
delayAfterEnable – [in] Delay after enabling the power pin in [ms].
delayAfterDisable – [in] Delay after disabling the power pin in [ms].
-
inline void unsetSelectPin()
The function
unsetSelectPindoes remove the select pin from the BoardSupportClass.
-
inline void setAddressPin(uint8_t pinNumber, uint8_t pinDriveDirection, uint8_t pinTristateDirection, uint8_t pinEnableValue, uint8_t pinDisableValue, uint32_t delayAfterEnable = 0, uint32_t delayAfterDisable = 0)
The function
setAdressPindefines a pin, which can be used for the extended address feature of the first sensor generation. Here the SDA-line of the I2C bus has to be pulled low in order to use the second half of addresses.- Parameters:
pinNumber – [in] Pin number of the desired pin.
pinDirection – [in] Pin direction of the pin (OUTPUT, INPUT, INPUT-PULLUP).
pinEnableValue – [in] Value to enable the power pin, depends on the pin (Active high or low).
pinDisableValue – [in] Value to disable the power pin, depends on the pin (Active high or low).
delayAfterEnable – [in] Delay after enabling the power pin in [ms].
delayAfterDisable – [in] Delay after disabling the power pin in [ms].
-
inline void unsetAddressPin()
The function
unsetAdressPindoes remove the address pin from the BoardSupportClass.
-
inline void enablePower()
The function
enablePowerenables the defined power pin.
-
inline void disablePower()
The function
disablePowerdisables the defined power pin.
-
inline void reset(bool executeInit = false)
The function
resetset the sensor’s registers to its reset values, does a power down/up cycle, and reinitializes the bus interface if requested. Then the default sensor configuration is set.- Parameters:
executeInit – [in] Whether to execute the bus objects init method after reset.
-
inline void enableSelect()
The function
enableSelectenables the defined select pin.
-
inline void disableSelect()
The function
disableSelectdisables the defined select pin.
-
inline void enableAddress()
The function
enableAdressenables the defined address pin.
-
inline void disableAddress()
The function
disableAdressdisables the defined address pin.
Private Functions
Private Members
-
BoardSupportType bsc
BoardSupportClass
-
BusWrapperType busWrapper
BusWrapperClass
-
TLx493D_IICAddressType_t iicAddress
I2C-Address of the sensor
-
template<typename BoardSupport, TLx493D_SupportedSensorType_t sensorType>
class TLx493D<BoardSupport, SPIClassWrapper, sensorType> : public ifx::tlx493d::TLx493DBase - #include <TLx493D.hpp>
Specialization of the template class
TLx493Dfor the SPI interface.- Template Parameters:
BoardSupport – A helper class, which takes care of needed power pins as well user defined pins.
sensorType – Specific sensor type of the used sensor.
Public Types
-
using BoardSupportType = BoardSupport
-
using BusWrapperType = SPIClassWrapper
-
using BusType = typename BusWrapperType::BusType
Public Functions
-
inline ~TLx493D()
The function
~TLx493Dis the constructor of the template class.
-
inline void init(bool enablePower = false, bool enableSelect = true)
The function
initinitializes all necessary peripherals of the chosen sensor board. It initializes the BoardSupportClass, the communication interface and calls thesetDefaultConfigfunction.
-
inline void begin(bool enablePower = false, bool enableSelect = true)
The function
begincalls theinitfunction. For details seeinitfunction.
-
inline void deinit()
The function
deinitde-initializes the sensor and its peripherals. It de-initializes the communication interface, the BoardSupportClass as well as all allocated memory (free the memory to be precise).
-
inline void end()
The function
endcalls thedeinitfunction. For details seedeinitfunction.
-
inline void setPowerPin(uint8_t pinNumber, uint8_t pinDriveDirection, uint8_t pinTristateDirection, uint8_t pinEnableValue, uint8_t pinDisableValue, uint32_t delayAfterEnable = 0, uint32_t delayAfterDisable = 0)
The function
setPowerPindefines a power pin, which can be used to power up the sensor.- Parameters:
pinNumber – [in] Pin number of the desired pin.
pinDirection – [in] Pin direction of the pin (OUTPUT, INPUT, INPUT-PULLUP).
pinEnableValue – [in] Value to enable the power pin, depends on the pin (Active high or low).
pinDisableValue – [in] Value to disable the power pin, depends on the pin (Active high or low).
delayAfterEnable – [in] Delay after enabling the power pin in [ms].
delayAfterDisable – [in] Delay after disabling the power pin in [ms].
-
inline void unsetPowerPin()
The function
unsetPowerPindoes remove the power pin from the BoardSupportClass.
-
inline void setSelectPin(uint8_t pinNumber, uint8_t pinDriveDirection, uint8_t pinTristateDirection, uint8_t pinEnableValue, uint8_t pinDisableValue, uint32_t delayAfterEnable = 0, uint32_t delayAfterDisable = 0)
The function
setSelectPindefines a select pin, which can be used as chip select for the SPI communication.- Parameters:
pinNumber – [in] Pin number of the desired pin.
pinDirection – [in] Pin direction of the pin (OUTPUT, INPUT, INPUT-PULLUP).
pinEnableValue – [in] Value to enable the power pin, depends on the pin (Active high or low).
pinDisableValue – [in] Value to disable the power pin, depends on the pin (Active high or low).
delayAfterEnable – [in] Delay after enabling the power pin in [ms].
delayAfterDisable – [in] Delay after disabling the power pin in [ms].
-
inline void unsetSelectPin()
The function
unsetSelectPindoes remove the select pin from the BoardSupportClass.
-
inline void enablePower()
The function
enablePowerenables the defined power pin.
-
inline void disablePower()
The function
disablePowerdisables the defined power pin.
-
inline void reset()
The function
resetdoes a software reset as power down is not available with the current experimental board for the P3I8 sensor.
-
inline void enableSelect()
The function
enableSelectenables the defined select pin.
-
inline void disableSelect()
The function
disableSelectdisables the defined select pin.
-
template<typename BoardSupport, TLx493D_SupportedSensorType_t sensorType>
-
namespace tlx493d
Logger API
The following section shows you all the available logger functions, which can be utilized for debugging or printing out important information of the sensors, for example the internal register map.
-
void logPrintRegisters(const TLx493D_t *sensor, const char *headLine)
The function
logPrintRegistersprints out all the internal registers of the passed sensor object.- Parameters:
sensor – [in] A pointer to a TLx493D_t structure, which represents the TLx493D sensor.
headLine – [in] A string with register names to be printed above the registers for easier reading.
-
void logPrintDouble(double d)
The function
logPrintDoubleprints out a value in the double format.- Parameters:
d – [in] Value which will be printed to the serial monitor.
-
void logPrint(const char *format, ...)
The function
logPrintis used to print out a formatted string - without prefix - to the serial output.- Parameters:
format – [in] Actual string, which should be printed to the serial output.
-
void logPrintln(const char *prefix, const char *format, ...)
The function
logPrintlnis used to print out a formatted string - without prefix - to the serial output plus a trailing linefeed.- Parameters:
format – [in] Actual string, which should be printed to the serial output.
Warning
doxygenfunction: Cannot find function “logInfo” in doxygen xml output for project “XENSIV™ 3D Magnetic Sensor TLx493D Arduino Library” from directory: build/xml/
Warning
doxygenfunction: Cannot find function “logWarn” in doxygen xml output for project “XENSIV™ 3D Magnetic Sensor TLx493D Arduino Library” from directory: build/xml/
Warning
doxygenfunction: Cannot find function “logError” in doxygen xml output for project “XENSIV™ 3D Magnetic Sensor TLx493D Arduino Library” from directory: build/xml/
-
void logFlush(void)
The function
flushis used to send a new line character to ther serial output.
Communication Interface
The following section shows you the important high-level functions of the communication interface. The tlx493d_transfer() function is implemented for every sensor depending on its available interface (I2C, SPI).
Typedefs
Functions
-
bool tlx493d_transfer(TLx493D_t *sensor, uint8_t *txBuffer, uint8_t txLen, uint8_t *rxBuffer, uint8_t rxLen)
The function
tlx493d_transferis a generic function to transfer data. It is implemented for each communication interface offered by the different senors (SPI, I2C, etc.).- Parameters:
sensor – [inout] A pointer to a TLx493D_t struct, which represents the TLx493D sensor.
txBuffer – [inout] Buffer for the data that should be transferred.
txLen – [in] Length of the transfer buffer.
rxBuffer – [inout] Buffer for the data that should be received.
rxLen – [in] Length of the receive buffer.
- Return values:
false – Error.
true – Transfer of the data was successful.
- Returns:
The function
tlx493d_transferis returning a boolean value.
-
void tlx493d_setReadAddress(TLx493D_t *sensor, uint8_t address)
The function
tlx493d_setReadAddresssets the address for the communication interface. This address will be used to communicate with the used sensor device.- Parameters:
sensor – [inout] A pointer to a TLx493D_t struct, which represents the TLx493D sensor.
address – [in] Desired read address for the communication interface.
-
void deinitCommunication(TLx493D_t *sensor, bool executeDeinit)
The function
deinitCommunicationis used to de-initialize the communication interface of the used sensor.- Parameters:
sensor – [inout] A pointer to a TLx493D_t struct, which represents the TLx493D sensor.
executeDeinit – [in] Boolean value to determine if the communication interface should be de-initialzed or not.
Kit2GoBoardSupport
The following section shows you how you can utilize the board support class for your applications. The Kit2GoBoardSupport class eases the usage of Kit2Go boards by giving the opportunity define for example power pins, which can be used to power up and power down the sensor. Or by defining chip select pins in case of a SPI interface.
-
namespace ifx
std includes. project c includes.
std includes. project cpp includes. project c includes.
Arduino includes.
-
namespace tlx493d
-
class Kit2GoBoardSupport
- #include <Kit2GoBoardSupport.hpp>
The Kit2GoBoardSupport class used for custom board bring up, for control of SPI slave select lines and for controlling address lines for extended addressing of certain devices.
Public Functions
-
Kit2GoBoardSupport()
Default constructor with no parameters.
Create a new Kit2GoBoardSupport object with initialised data structures of type PinCtrl to hold parameters for powerPins, selectPins and addressPins.
-
~Kit2GoBoardSupport()
Destructor of the Kit2GoBoardSupport class.
-
void init(bool isEnablePower = true, bool isEnableSelect = false, bool isEnableExtendedAddress = false)
The function
initsets/resets the board pin modes and/or values based on the values of the data structures set in the main code.- Parameters:
enablePower – [in] Whether to power up the board using this class. In this case the board 3V3 is routed through a GPIO of the host MCU.
enableSelect – [in] Whether SPI slaves SELECT lines need to be controlled using this class. A particular slave is selected by pulling its corresponding SELECT line low.
enableExtendedAddress – [in] (Only relevant for Generation 1, A1B6 devices) Whether to use extended addressing feature. In this case, the pin stored in addressPins structure is activated and later isolated in a prescribed way to enable the 4 extended addresses of the said device.
-
void begin(bool enablePower = true, bool enableSelect = false, bool enableExtendedAddress = false)
The
beginfunction recursively calls theinitfunction of the same class.- Parameters:
enablePower – [in] Whether to power up the board using this class. In this case the board 3V3 is routed through a GPIO of the host MCU.
enableSelect – [in] Whether SPI slaves SELECT lines need to be controlled using this class. A particular slave is selected by pulling its corresponding SELECT line low.
enableExtendedAddress – [in] (Only relevant for Generation 1, A1B6 devices) Whether to use extended addressing feature. In this case, the pin stored in addressPins structure is activated and later isolated in a prescribed way to enable the 4 extended addresses of the said device.
-
void deinit()
The
deinitfunction sets all the pins to their disable value.
-
void end()
The
endfunction recursively calls thedeinitfunction of the same class.
-
void setPowerPin(uint8_t pinNumber, uint8_t pinDriveDirection, uint8_t pinTristateDirection, uint8_t pinEnableValue, uint8_t pinDisableValue, uint32_t delayAfterEnable = 0, uint32_t delayAfterDisable = 0)
The
setPowerPinfunction is setter function to route pin parameters from the main code into the data structures/variables of this class.- Parameters:
pinNumber – [in] Arduino pin number of the GPIO to be used as 3V3 POWER pin for the sensor.
pinDriveDirection – [in] Direction of the Arduino pin to be used as the 3V3 POWER pin.
pinTristateDirection – [in] Direction of the Arduino pin when in tristate.
pinEnableValue – [in] Value of the pin in enabled state.
pinDisableValue – [in] Value of the pin in disabled state.
delayAfterEnable – [in] delay in ms after the pin is enabled. Needed to meet settling time constraints.
delayAfterDisable – [in] delay in ms after the pin is disabled. Needed to meet settling time constraints.
-
void unsetPowerPin()
The
unsetPowerPinfunction disables all actions on the pins set in powerPins that would otherwise be performed by theinitfunction.
-
void setSelectPin(uint8_t pinNumber, uint8_t pinDriveDirection, uint8_t pinTristateDirection, uint8_t pinEnableValue, uint8_t pinDisableValue, uint32_t delayAfterEnable = 0, uint32_t delayAfterDisable = 0)
The
setSelectPinfunction is setter function to route pin parameters from the main code into the data structures/variables of this class.- Parameters:
pinNumber – [in] Arduino pin number of the GPIO to be used as SELECT pin for the sensor used as SPI slave.
pinDirection – [in] Direction of the Arduino pin to be used as the select pin for the sensor used as SPI slave.
pinTristateDirection – [in] Direction of the Arduino pin when in tristate.
pinEnableValue – [in] Value of the pin in enabled state.
pinDisableValue – [in] Value of the pin in disabled state.
delayAfterEnable – [in] delay in ms after the pin is enabled. Needed to meet settling time constraints.
delayAfterDisable – [in] delay in ms after the pin is disabled. Needed to meet settling time constraints.
-
void unsetSelectPin()
The
unsetSelectPinfunction disables all actions on the pins set in selectPins that would otherwise be performed by theinitfunction.
-
void setAddressPin(uint8_t pinNumber, uint8_t pinDriveDirection, uint8_t pinTristateDirection, uint8_t pinEnableValue, uint8_t pinDisableValue, uint32_t delayAfterEnable = 0, uint32_t delayAfterDisable = 0)
The
setAddressPinfunction is setter function to route pin parameters from the main code into the data structures/variables of this class.- Parameters:
pinNumber – [in] Arduino pin number of the GPIO to be used as the ADDR pin for the sensor used as SPI slave.
pinDirection – [in] Direction of the Arduino pin to be used as the ADDR pin for the sensor used as SPI slave.
pinTristateDirection – [in] Direction of the Arduino pin when in tristate.
pinEnableValue – [in] Value of the pin in enabled state.
pinDisableValue – [in] Value of the pin in disabled state.
delayAfterEnable – [in] delay in ms after the pin is enabled. Needed to meet settling time constraints.
delayAfterDisable – [in] delay in ms after the pin is disabled. Needed to meet settling time constraints.
-
void unsetAddressPin()
The
unsetAddressPinfunction disables all actions on the pins set in selectPins that would otherwise be performed by theinitfunction.
-
void enablePower(bool enable)
The
enablePowerfunction sets/resets the pins in powerPins based on argument.- Parameters:
enable – [in] Sets pin to pinEnableValue if true, else to pinDisableValue.
-
void enableSelect(bool enable)
The
enableSelectfunction sets/resets the pins in selectPins based on argument.- Parameters:
enable – [in] Sets pin to pinEnableValue if true, else to pinDisableValue.
-
void enableAddress(bool enable)
The
enableAddressfunction sets/resets the pins in selectPins based on argument.- Parameters:
enable – Sets pin to pinEnableValue if true, else to pinDisableValue.
-
void reset()
The
resetfunction resets the power pin by going through a disable / enable cycle.
Private Types
-
typedef struct ifx::tlx493d::Kit2GoBoardSupport::pinCtrl pinCtrl
A structure to represent pins with all necessary parameters.
Private Functions
-
void enablePin(const pinCtrl &p, bool enable)
The
enablePinfunction sets/resets the pin on the basis of parameters in the structurepinCtrl.- Parameters:
p – [in] Structure of type
pinCtrl.enable – [in] Sets pin to pinEnableValue if true, else to pinDisableValue.
-
void initPin(const pinCtrl &p)
The
initPinfunction sets the direction and value of the pin on the basis of parameters in the structurepinCtrl.- Parameters:
p – [in] Structure of type
pinCtrl.
Private Members
-
struct pinCtrl
A structure to represent pins with all necessary parameters.
Public Members
-
bool isSet
the state of the pin, to be activated or not at
init.
-
uint8_t pinNumber
the Arduino pin number of the pin.
-
uint8_t driveDirection
the direction for the Arduino pin when actively driving.
-
uint8_t tristateDirection
the direction for the Arduino pin when in tristate.
-
uint8_t enableValue
the value of the pin to be enabled or set by the
initfunction.
-
uint8_t disableValue
the value of the pin when the pin is disabled.
-
uint32_t delayAfterEnable
the delay in us after the pin is enabled.
-
uint32_t delayAfterDisable
the delay in us after the pin is disabled.
-
bool isSet
-
Kit2GoBoardSupport()
-
class Kit2GoBoardSupport
-
namespace tlx493d