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).
PAL WICED
Collaboration diagram for PAL WICED:

Data Structures

class  GPIOWiced
 
class  SPICWiced
 Wiced SPIC class. More...
 
class  TimerWiced
 
class  Tle5012Wiced
 represents a basic TLE5012b Wiced class. More...
 

Functions

 Tle5012Wiced::Tle5012Wiced ()
 
 Tle5012Wiced::Tle5012Wiced (wiced_gpio_t csPin, slaveNum slave=TLE5012B_S0)
 Construct a new Tle5012Wiced::Tle5012Wiced object with chipselect and sensor slave Use this constructor if: More...
 
errorTypes Tle5012Wiced::begin ()
 begin method with default assignments for the SPI bus and pin setting. The EN pin is only available for the Sensor2go kit, therefore we only set it in that case, otherwise it will be NULL. More...
 

Variables

uint8_t Tle5012Wiced::mSpiNum = 0
 Number of used SPI channel. More...
 

TLE5012-pal-wiced.hpp - Wiced Hardware Abstraction Layer

Author
Infineon Technologies AG
Version
3.1.0 PAL WICED

SPDX-License-Identifier: MIT

#define PIN_SPI_EN   UNUSED_PIN
 Check for XMC mcu family *‍/. More...
 
#define TLE94112_PIN_CS1   WICED_GPIO_7
 

Detailed Description


Data Structure Documentation

◆ GPIOWiced

class GPIOWiced
Inheritance diagram for GPIOWiced:
Collaboration diagram for GPIOWiced:

Public Types

enum  Error_t {
  OK = 0 , INTF_ERROR = -1 , CONF_ERROR = -2 , READ_ERROR = -3 ,
  WRITE_ERROR = -4
}
 
Interrupt event
enum  IntEvent_t { INT_FALLING_EDGE = 0 , INT_RISING_EDGE = 1 }
 
Voltage level
enum  VLevel_t { GPIO_LOW = 0 , GPIO_HIGH = 1 }
 
Voltage logic
enum  VLogic_t { NEGATIVE = 1 , POSITIVE = 2 }
 

Public Member Functions

 GPIOWiced ()
 GPIO WICED default constructor. More...
 
 GPIOWiced (wiced_gpio_t pin, wiced_gpio_config_t config, VLogic_t logic)
 GPIO WICED default constructor. More...
 
 ~GPIOWiced ()
 GPIO WICED destructor. More...
 
Error_t init ()
 Initializes the WICED GPIO. More...
 
Error_t deinit ()
 Initializes the WICED GPIO. More...
 
VLevel_t read ()
 Reads the WICED GPIO voltage level. More...
 
Error_t write (VLevel_t level)
 Writes the WICED GPIO output voltage level. More...
 
Error_t enable ()
 Enables the WICED output according to the GPIO logic. More...
 
Error_t disable ()
 Disables the WICED output according to the GPIO logic. More...
 
virtual Error_t changeMode (uint8_t mode)=0
 Changes the IN/OUT mode. More...
 
Error_t checkErrorStatus ()
 

Member Enumeration Documentation

◆ Error_t

enum GPIO::Error_t
inherited
Enumerator
OK 

No error

INTF_ERROR 

Interface error

CONF_ERROR 

Configuration error

READ_ERROR 

Read error

WRITE_ERROR 

Write error

◆ IntEvent_t

enum GPIO::IntEvent_t
inherited
Enumerator
INT_FALLING_EDGE 

Interrupt on falling edge

INT_RISING_EDGE 

Interrupt on rising edge

◆ VLevel_t

enum GPIO::VLevel_t
inherited
Enumerator
GPIO_LOW 

Level low

GPIO_HIGH 

Level high

◆ VLogic_t

enum GPIO::VLogic_t
inherited
Enumerator
NEGATIVE 

Negative logic. 0 on voltage level high, 1 on voltage low

POSITIVE 

Positive logic. 1 on voltage level high, 0 on voltage low

Constructor & Destructor Documentation

◆ GPIOWiced() [1/2]

GPIOWiced::GPIOWiced ( )

GPIO WICED default constructor.

◆ GPIOWiced() [2/2]

GPIOWiced::GPIOWiced ( wiced_gpio_t  pin,
wiced_gpio_config_t  config,
VLogic_t  logic 
)

GPIO WICED default constructor.

◆ ~GPIOWiced()

GPIOWiced::~GPIOWiced ( )

GPIO WICED destructor.

Here is the call graph for this function:

Member Function Documentation

◆ init()

GPIOWiced::Error_t GPIOWiced::init ( )
inlinevirtual

Initializes the WICED GPIO.

Returns
GPIO error code
Return values
OKif success
INTF_ERRORif initialization error

Implements GPIO.

◆ deinit()

GPIOWiced::Error_t GPIOWiced::deinit ( )
inlinevirtual

Initializes the WICED GPIO.

Returns
GPIO error code
Return values
OKif success
INTF_ERRORif deinitialization error

Implements GPIO.

◆ read()

GPIOWiced::VLevel_t GPIOWiced::read ( )
inlinevirtual

Reads the WICED GPIO voltage level.

Returns
GPIO voltage level
Return values
GPIO_LOWif voltage low
GPIO_HIGHif voltage high

Implements GPIO.

◆ write()

GPIOWiced::Error_t GPIOWiced::write ( VLevel_t  level)
inlinevirtual

Writes the WICED GPIO output voltage level.

Parameters
[in]levelVoltage level
Returns
GPIO error code
Return values
OKif success
INTF_ERRORif error

Implements GPIO.

◆ enable()

GPIOWiced::Error_t GPIOWiced::enable ( )
inlinevirtual

Enables the WICED output according to the GPIO logic.

  • Low if negative
  • High if positive
    Returns
    GPIO interrupt event
    Return values
    OKif success
    INTF_ERRORif error

Implements GPIO.

◆ disable()

GPIOWiced::Error_t GPIOWiced::disable ( )
inlinevirtual

Disables the WICED output according to the GPIO logic.

  • Low if positive
  • High if negative
    Returns
    GPIO error code
    Return values
    OKif success
    INTF_ERRORif error

Implements GPIO.

◆ changeMode()

virtual Error_t GPIO::changeMode ( uint8_t  mode)
pure virtualinherited

Changes the IN/OUT mode.

Parameters
[in]modeINPUT or OUTPUT mode of pin
Returns
GPIO error code
Return values
OKif success
INIT_ERRORif deinitialization error

Implemented in GPIOIno.

◆ checkErrorStatus()

GPIO::Error_t GPIO::checkErrorStatus ( )
inherited

◆ SPICWiced

class SPICWiced

Wiced SPIC class.

Inheritance diagram for SPICWiced:
Collaboration diagram for SPICWiced:

Public Types

enum  Error_t {
  OK = 0 , INTF_ERROR = -1 , CONF_ERROR = -2 , READ_ERROR = -3 ,
  WRITE_ERROR = -4
}
 

Public Member Functions

 SPICWiced (wiced_gpio_t csPin)
 Constructor of the WICED SPIC class. More...
 
 SPICWiced (wiced_spi_t port, wiced_gpio_t csPin, wiced_gpio_t misoPin, wiced_gpio_t mosiPin, wiced_gpio_t sckPin)
 Construct a new SPICWiced::SPICWiced object. More...
 
 ~SPICWiced ()
 Destructor of the WICED SPIC class. More...
 
Error_t init ()
 Initialize the SPIC. More...
 
Error_t deinit ()
 Deinitialize the SPIC. More...
 
Error_t transfer16 (uint16_t send, uint16_t &received)
 transfers a data package via the spi bus More...
 
Error_t triggerUpdate ()
 Triggers an update in the register buffer. This function should be triggered once before UPD registers where read as it generates a snapshot of the UPD register values at trigger point. More...
 
Error_t sendReceive (uint16_t *sent_data, uint16_t size_of_sent_data, uint16_t *received_data, uint16_t size_of_received_data)
 
Error_t checkErrorStatus ()
 

Member Enumeration Documentation

◆ Error_t

enum SPIC::Error_t
inherited
Enumerator
OK 

No error

INTF_ERROR 

Interface error

CONF_ERROR 

Configuration error

READ_ERROR 

Read error

WRITE_ERROR 

Write error

Constructor & Destructor Documentation

◆ SPICWiced() [1/2]

SPICWiced::SPICWiced ( wiced_gpio_t  csPin)

Constructor of the WICED SPIC class.

This function is setting the basics for a SPIC and the default spi on Arduino which is implemented as WICED_SPI_0 by patching the following:

  • <WICED_SDK>/platforms/<platform_name>/platform.h add WICED_SPI_0, to the wiced_spi_t
  • <WICED_SDK>/platforms/<platform_name>/platform.c add the following to the platform_spi_peripherals [WICED_SPI_0] = { .port = BCM4390X_SPI_0, .pin_mosi = &platform_gpio_pins[WICED_GPIO_6], .pin_miso = &platform_gpio_pins[WICED_GPIO_8], .pin_clock = &platform_gpio_pins[WICED_GPIO_5], .pin_cs = &platform_gpio_pins[WICED_GPIO_7], .driver = &spi_bb_driver, }, which sets the Arduino header GPIOs and the bit banging driver.
Parameters
csPinNumber of the desired ChipSelect pin
Attention
Yet not implemented

◆ SPICWiced() [2/2]

SPICWiced::SPICWiced ( wiced_spi_t  port,
wiced_gpio_t  csPin,
wiced_gpio_t  misoPin,
wiced_gpio_t  mosiPin,
wiced_gpio_t  sckPin 
)

Construct a new SPICWiced::SPICWiced object.

This function allows to set all parameters of the SPI master.

Parameters
portSPI channel to be used
csPinNumber of the desired ChipSelect pin
misoPinmiso pin number
mosiPinmosi pin number
sckPinsystemclock pin number
Attention
This does not set the platform_spi_peripherals structure yet

◆ ~SPICWiced()

SPICWiced::~SPICWiced ( )

Destructor of the WICED SPIC class.

Here is the call graph for this function:

Member Function Documentation

◆ init()

SPICWiced::Error_t SPICWiced::init ( )
virtual

Initialize the SPIC.

This function is initializing the chosen spi channel with the given values for lsb,clock and mode

Returns
SPICWiced::Error_t

Implements SPIC.

◆ deinit()

SPICWiced::Error_t SPICWiced::deinit ( )
virtual

Deinitialize the SPIC.

This function is deinitializing the chosen spi channel.

Returns
SPICWiced::Error_t

Implements SPIC.

◆ transfer16()

SPICWiced::Error_t SPICWiced::transfer16 ( uint16_t  send,
uint16_t &  received 
)

transfers a data package via the spi bus

Parameters
sendaddress and/or command to send as 16bit
receivedreceived data from spi bus as 16bit
Returns
SPICWiced::Error_t

◆ triggerUpdate()

SPICWiced::Error_t SPICWiced::triggerUpdate ( )
virtual

Triggers an update in the register buffer. This function should be triggered once before UPD registers where read as it generates a snapshot of the UPD register values at trigger point.

Returns
SPICIno::Error_t

Implements SPIC.

◆ sendReceive()

SPICWiced::Error_t SPICWiced::sendReceive ( uint16_t *  sent_data,
uint16_t  size_of_sent_data,
uint16_t *  received_data,
uint16_t  size_of_received_data 
)
virtual

Main SPI three wire communication functions for sending and receiving data

Parameters
sent_datapointer two 2*unit16_t value for one command word and one data word if something should be written
size_of_sent_datathe size of the command word default 1 = only command 2 = command and data word
received_datapointer to data structure buffer for the read data
size_of_received_datasize of data words to be read

Implements SPIC.

Here is the call graph for this function:

◆ checkErrorStatus()

SPIC::Error_t SPIC::checkErrorStatus ( )
inherited

◆ TimerWiced

class TimerWiced
Inheritance diagram for TimerWiced:
Collaboration diagram for TimerWiced:

Public Types

enum  Error_t { OK = 0 , ERROR = 1 }
 

Public Member Functions

 TimerWiced ()
 Constructor of the WICED Timer class. More...
 
 ~TimerWiced ()
 Destructor of the WICED Timer class. More...
 
Error_t init ()
 Initialization of the Timer. More...
 
Error_t deinit ()
 Deinitialize the Timer. More...
 
Error_t start ()
 Start the timer. More...
 
Error_t elapsed (wiced_time_t &elapsed)
 Calculate the elapsed time. More...
 
Error_t stop ()
 Stop the timer. More...
 
Error_t delayMilli (uint32_t timeout)
 Time delay. More...
 
Error_t delayMicro (uint32_t timeout)
 Time delay. More...
 
virtual Error_t elapsed (uint32_t &elapsed)=0
 Elapsed time since the timer was started. More...
 

Member Enumeration Documentation

◆ Error_t

enum Timer::Error_t
inherited
Enumerator
OK 

No error

ERROR 

Error

Constructor & Destructor Documentation

◆ TimerWiced()

TimerWiced::TimerWiced ( )

Constructor of the WICED Timer class.

◆ ~TimerWiced()

TimerWiced::~TimerWiced ( )

Destructor of the WICED Timer class.

Member Function Documentation

◆ init()

TimerWiced::Error_t TimerWiced::init ( )
virtual

Initialization of the Timer.

This function is initializing the Timer and sets the elapsed time to zero.

Returns
TimerWiced::Error_t

Implements Timer.

◆ deinit()

TimerWiced::Error_t TimerWiced::deinit ( )
virtual

Deinitialize the Timer.

This function deinitialize the Timer and also resets the elapsed time variable.

Returns
TimerWiced::Error_t

Implements Timer.

◆ start()

TimerWiced::Error_t TimerWiced::start ( )
virtual

Start the timer.

This function is starting the timer.

Returns
TimerWiced::Error_t

Implements Timer.

◆ elapsed() [1/2]

TimerWiced::Error_t TimerWiced::elapsed ( wiced_time_t &  elapsed)

Calculate the elapsed time.

This function is calculating the elapsed time since the start of the timer. The value stored in the given variable is in milliseconds.

Parameters
[in]&elapsedAddress of a value where the elapsed time should be stored
Returns
TimerWiced::Error_t

◆ stop()

TimerWiced::Error_t TimerWiced::stop ( )
virtual

Stop the timer.

This function stops the timer and resets the start time variable.

Returns
TimerWiced::Error_t

Implements Timer.

◆ delayMilli()

TimerWiced::Error_t TimerWiced::delayMilli ( uint32_t  timeout)
virtual

Time delay.

This function is causing a desired delay of the application. The input value is given in milliseconds.

Parameters
[in]timeoutDesired timeout in ms
Returns
TimerWiced::Error_t

Implements Timer.

◆ delayMicro()

TimerWiced::Error_t TimerWiced::delayMicro ( uint32_t  timeout)
virtual

Time delay.

This function is causing a desired delay of the application. The input value is given in microseconds.

Parameters
[in]timeoutDesired timeout in us
Returns
TimerWiced::Error_t

Implements Timer.

◆ elapsed() [2/2]

virtual Error_t Timer::elapsed ( uint32_t &  elapsed)
pure virtualinherited

Elapsed time since the timer was started.

Parameters
[out]elapsedTime in milliseconds
Returns
Timer error code
Return values
OKif success
INIT_ERRORif hardware interface error

◆ Tle5012Wiced

class Tle5012Wiced

represents a basic TLE5012b Wiced class.

represents the TLE5012 base class

This class provides a simple API for connecting Wiced/Genuio and compatible MCUs. As the default interface for the sensor is the 3wire SSC SPI interface, the default SPIClass is extended by the SPIclass3W.

See also
Tle5012

This class provides a simple API for connecting the TLE5012 via SSC interface, which is included into all flavours the TLE5012 sensor. This setup also works with the Sens2Kit (Sensor including XMC1100 mcu), breakout board (only the Sensor from the Sens2Kit) and bulk chip (read the section on how to connect the bulk chip via 3wire SPI).

Inheritance diagram for Tle5012Wiced:
Collaboration diagram for Tle5012Wiced:

Public Types

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

Public Member Functions

 Tle5012Wiced ()
 
 Tle5012Wiced (wiced_gpio_t csPin, slaveNum slave=TLE5012B_S0)
 Construct a new Tle5012Wiced::Tle5012Wiced object with chipselect and sensor slave Use this constructor if: More...
 
errorTypes begin ()
 begin method with default assignments for the SPI bus and pin setting. The EN pin is only available for the Sensor2go kit, therefore we only set it in that case, otherwise it will be NULL. More...
 
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

uint8_t mSpiNum = 0
 Number of used SPI channel. More...
 
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

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 ()
 

Macro Definition Documentation

◆ PIN_SPI_EN

#define PIN_SPI_EN   UNUSED_PIN

Check for XMC mcu family *‍/.

TLE5012 with any other PCB has no switch on/off

◆ TLE94112_PIN_CS1

#define TLE94112_PIN_CS1   WICED_GPIO_7

Standard chip select pin for first TLE5012 sensor on Arduino header

Function Documentation

◆ Tle5012Wiced() [1/2]

Tle5012Wiced::Tle5012Wiced ( )

Construct a new Tle5012Wiced::Tle5012Wiced object with default SPI and pin assignment. Use this if:

  • you have TLE5012B Sensor2go kit (all types)
  • attached the breakout board on the default SPI of your MCU
  • attached a bulk chip with the SSC interface to the default SPI of your MCU

◆ Tle5012Wiced() [2/2]

Tle5012Wiced::Tle5012Wiced ( wiced_gpio_t  csPin,
slaveNum  slave = TLE5012B_S0 
)

Construct a new Tle5012Wiced::Tle5012Wiced object with chipselect and sensor slave Use this constructor if:

  • you use more than one sensor with one SPI channel (up to four are possible)
Parameters
csPinpin number of the CS pin
slaveoptional sensor slave setting

◆ begin()

errorTypes Tle5012Wiced::begin ( void  )

begin method with default assignments for the SPI bus and pin setting. The EN pin is only available for the Sensor2go kit, therefore we only set it in that case, otherwise it will be NULL.

Returns
errorTypes
Here is the call graph for this function:

Variable Documentation

◆ mSpiNum

uint8_t Tle5012Wiced::mSpiNum = 0

Number of used SPI channel.