Arduino SPIClass extension to use 3wire SSC SPI interfaces. More...
Data Structures | |
class | GPIOIno |
Arduino GPIO class. More... | |
class | SPIClass3W |
class | SPICIno |
Arduino SPIC class This function is setting the basics for a SPIC and the default spi. More... | |
class | Tle5012Ino |
represents a basic TLE5012b Arduino class. More... | |
Macros | |
#define | SPI3W_ARD 1 |
Arduino SPIClass3W extends the default SPIClass The extension allows the use of 3wire SSC SPI interfaces for default Arduino/Genuino and for XMC, special for the Sensor2go kit Therefore via the correct code is loaded via SPI3W_INO macro settings. More... | |
#define | SPI3W_XMC 2 |
#define | MAX_SLAVE_NUM 4 |
Maximum numbers of slaves on one SPI bus. More... | |
#define | SPEED 1000000U |
default speed of SPI transfer More... | |
Functions | |
Tle5012Ino::Tle5012Ino () | |
Tle5012Ino::Tle5012Ino (uint8_t csPin, slaveNum slave=TLE5012B_S0) | |
Construct a new Tle5012Ino::Tle5012Ino object with chipselect and sensor slave Use this constructor if: More... | |
Tle5012Ino::Tle5012Ino (SPIClass3W &bus, uint8_t csPin, uint8_t misoPin, uint8_t mosiPin, uint8_t sckPin, slaveNum slave=TLE5012B_S0) | |
errorTypes | Tle5012Ino::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... | |
SPIClass3W::SPIClass3W () | |
Construct a new SPIClass3W::SPIClass3W object. More... | |
SPIClass3W::~SPIClass3W () | |
Destroy the SPIClass3W::SPIClass3W object. More... | |
void | SPIClass3W::begin (uint8_t miso, uint8_t mosi, uint8_t sck, uint8_t cs) |
New for fetching SPI parameter. More... | |
void | SPIClass3W::setCSPin (uint8_t cs) |
Set the chipselect pin. This function is needed if more than one sensor is in the SPI bus. More... | |
void | SPIClass3W::sendReceiveSpi (uint16_t *sent_data, uint16_t size_of_sent_data, uint16_t *received_data, uint16_t size_of_received_data) |
Main SPI three wire communication functions for sending and receiving data. More... | |
SPICIno::SPICIno (uint8_t csPin=PIN_SPI_SS) | |
Construct a new SPICIno::SPICIno object. More... | |
SPICIno::SPICIno (SPIClass3W &port, uint8_t csPin=PIN_SPI_SS, uint8_t misoPin=PIN_SPI_MISO, uint8_t mosiPin=PIN_SPI_MOSI, uint8_t sckPin=PIN_SPI_SCK) | |
Construct a new SPICIno::SPICIno object of the Arduino SPIC class. More... | |
Error_t | SPICIno::init () |
Initialize the SPIC. More... | |
Error_t | SPICIno::deinit () |
Deinitialize the SPIC. More... | |
Error_t | SPICIno::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 | SPICIno::sendReceive (uint16_t *sent_data, uint16_t size_of_sent_data, uint16_t *received_data, uint16_t size_of_received_data) |
Variables | |
SPIClass3W | SPI3W |
define a new SPI3W macro for handling more than the default SPI channel More... | |
uint8_t | Tle5012Ino::mSpiNum = 0 |
Number of used SPI channel. More... | |
TLE5012-pal-ino.hpp - Arduino Hardware Abstraction Layer | |
SPDX-License-Identifier: MIT | |
#define | PIN_SPI_EN UNUSED_PIN |
Check for XMC mcu family */. More... | |
Arduino SPIClass extension to use 3wire SSC SPI interfaces.
class GPIOIno |
Arduino GPIO class.
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 | |
GPIOIno () | |
Constructor of the Arduino GPIO class. More... | |
GPIOIno (uint8_t pin, uint8_t mode, VLogic_t logic) | |
Constructor of the Arduino GPIO class. More... | |
~GPIOIno () | |
Error_t | init () |
Initialize the GPIO. More... | |
Error_t | changeMode (uint8_t mode) |
Changes the GPIO mode. More... | |
Error_t | deinit () |
Deinitialize the GPIO. More... | |
VLevel_t | read () |
Read GPIO logic level. More... | |
Error_t | write (VLevel_t level) |
Set GPIO logic level. More... | |
Error_t | enable () |
Enable the GPIO. More... | |
Error_t | disable () |
Disable the GPIO. More... | |
Error_t | checkErrorStatus () |
|
inherited |
|
inherited |
|
inherited |
|
inherited |
GPIOIno::GPIOIno | ( | ) |
GPIOIno::GPIOIno | ( | uint8_t | pin, |
uint8_t | mode, | ||
VLogic_t | logic | ||
) |
Constructor of the Arduino GPIO class.
This function is setting the basics for a GPIO. It allows to set the pin number, mode of the pin and the logic level.
[in] | pin | Number of the desired pin |
[in] | mode | Defines the mode of the pin (INPUT, OUTPUT, etc.) |
[in] | logic | Defines the logic level of the pin |
GPIOIno::~GPIOIno | ( | ) |
|
virtual |
Initialize the GPIO.
This function is initializing the chosen pin.
Implements GPIO.
|
virtual |
Changes the GPIO mode.
This function changes the mode of the chosen pin.
Implements GPIO.
|
virtual |
Deinitialize the GPIO.
This function is deinitializing the chosen pin.
Implements GPIO.
|
virtual |
Read GPIO logic level.
This function reads the logic level of the chosen pin and returns the logic level value.
0 | = GPIO_LOW |
1 | = GPIO_HIGH |
Implements GPIO.
|
virtual |
Set GPIO logic level.
This functions sets the logic level of the chosen pin.
[in] | level | Desired logic level of the pin |
Implements GPIO.
|
virtual |
Enable the GPIO.
This functions enable the chosen pin. Depending on the chosen logic of the pin it sets the right logic level of the pin.
Implements GPIO.
|
virtual |
Disable the GPIO.
This functions disables the chosen pin. Depending on the chosen logic of the pin it sets the right logic level of the pin.
Implements GPIO.
|
inherited |
class SPIClass3W |
Public Member Functions | |
SPIClass3W () | |
Construct a new SPIClass3W::SPIClass3W object. More... | |
~SPIClass3W () | |
Destroy the SPIClass3W::SPIClass3W object. More... | |
void | begin (uint8_t miso, uint8_t mosi, uint8_t sck, uint8_t cs) |
New for fetching SPI parameter. More... | |
void | setCSPin (uint8_t cs) |
Set the chipselect pin. This function is needed if more than one sensor is in the SPI bus. More... | |
void | sendReceiveSpi (uint16_t *sent_data, uint16_t size_of_sent_data, uint16_t *received_data, uint16_t size_of_received_data) |
Main SPI three wire communication functions for sending and receiving data. More... | |
Data Fields | |
uint8_t | mCS |
Pin for chip select. More... | |
uint8_t | mSpiNum |
Number of used SPI channel. More... | |
uint8_t SPIClass3W::mCS |
Pin for chip select.
uint8_t SPIClass3W::mSpiNum |
Number of used SPI channel.
class SPICIno |
Public Types | |
enum | Error_t { OK = 0 , INTF_ERROR = -1 , CONF_ERROR = -2 , READ_ERROR = -3 , WRITE_ERROR = -4 } |
Public Member Functions | |
SPICIno (uint8_t csPin=PIN_SPI_SS) | |
Construct a new SPICIno::SPICIno object. More... | |
SPICIno (SPIClass3W &port, uint8_t csPin=PIN_SPI_SS, uint8_t misoPin=PIN_SPI_MISO, uint8_t mosiPin=PIN_SPI_MOSI, uint8_t sckPin=PIN_SPI_SCK) | |
Construct a new SPICIno::SPICIno object of the Arduino SPIC class. More... | |
~SPICIno () | |
Error_t | init () |
Initialize the SPIC. More... | |
Error_t | deinit () |
Deinitialize the SPIC. 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 () |
|
inherited |
SPICIno::~SPICIno | ( | ) |
|
inherited |
class Tle5012Ino |
represents a basic TLE5012b Arduino class.
represents the TLE5012 base class This file is only a startup wrapper for Arduino IDE so that the framework setup can be handeld without any special setup.
represents the TLE5012 base class
This class provides a simple API for connecting Arduino/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.
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).
Public Types | |
enum | slaveNum { TLE5012B_S0 = 0x0000 , TLE5012B_S1 = 0x2000 , TLE5012B_S2 = 0x4000 , TLE5012B_S3 = 0x6000 } |
Public Member Functions | |
Tle5012Ino () | |
Tle5012Ino (uint8_t csPin, slaveNum slave=TLE5012B_S0) | |
Construct a new Tle5012Ino::Tle5012Ino object with chipselect and sensor slave Use this constructor if: More... | |
Tle5012Ino (SPIClass3W &bus, uint8_t csPin, uint8_t misoPin, uint8_t mosiPin, uint8_t sckPin, slaveNum slave=TLE5012B_S0) | |
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... | |
SPIC * | sBus |
SPI cover class as representation of the SPI bus. More... | |
GPIO * | en |
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
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 () |
#define SPI3W_ARD 1 |
Arduino SPIClass3W extends the default SPIClass The extension allows the use of 3wire SSC SPI interfaces for default Arduino/Genuino and for XMC, special for the Sensor2go kit Therefore via the correct code is loaded via SPI3W_INO macro settings.
#define SPI3W_XMC 2 |
#define MAX_SLAVE_NUM 4 |
Maximum numbers of slaves on one SPI bus.
#define SPEED 1000000U |
default speed of SPI transfer
#define PIN_SPI_EN UNUSED_PIN |
Check for XMC mcu family */.
TLE5012 with any other PCB has no switch on/off
Tle5012Ino::Tle5012Ino | ( | ) |
Construct a new Tle5012Ino::Tle5012Ino object with default SPI and pin assignment. Use this if:
Tle5012Ino::Tle5012Ino | ( | uint8_t | csPin, |
slaveNum | slave = TLE5012B_S0 |
||
) |
Construct a new Tle5012Ino::Tle5012Ino object with chipselect and sensor slave Use this constructor if:
csPin | pin number of the CS pin |
slave | optional sensor slave setting |
Tle5012Ino::Tle5012Ino | ( | SPIClass3W & | bus, |
uint8_t | csPin, | ||
uint8_t | misoPin, | ||
uint8_t | mosiPin, | ||
uint8_t | sckPin, | ||
slaveNum | slave = TLE5012B_S0 |
||
) |
Construct a new Tle5012Ino::Tle5012Ino object with individual SPI and pin assignment Use this if:
bus | void pointer to the object representing the SPI class |
csPin | pin number of the CS pin |
misoPin | MISO pin for the SPI/SSC interface |
mosiPin | MOSI pin for the SPI/SSC interface |
sckPin | system clock pin for external sensor clock setting |
slave | optional sensor slave setting |
errorTypes Tle5012Ino::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.
SPIClass3W::SPIClass3W | ( | ) |
Construct a new SPIClass3W::SPIClass3W object.
SPIClass3W::~SPIClass3W | ( | ) |
Destroy the SPIClass3W::SPIClass3W object.
void SPIClass3W::begin | ( | uint8_t | miso, |
uint8_t | mosi, | ||
uint8_t | sck, | ||
uint8_t | cs | ||
) |
New for fetching SPI parameter.
miso | [in] pin number for miso, on sensor2go boards the same than mosi |
mosi | [in] pin number for mosi, on sensor2go boards the same than miso |
sck | [in] the system clock pin for external clock driver |
cs | [in] chipselect pin, up to four different cs pins can be used together with the slave number |
void SPIClass3W::setCSPin | ( | uint8_t | cs | ) |
Set the chipselect pin. This function is needed if more than one sensor is in the SPI bus.
cs | [in] Pin number of the sensors chip select |
void SPIClass3W::sendReceiveSpi | ( | uint16_t * | sent_data, |
uint16_t | size_of_sent_data, | ||
uint16_t * | received_data, | ||
uint16_t | size_of_received_data | ||
) |
Main SPI three wire communication functions for sending and receiving data.
sent_data | pointer two 2*unit16_t value for one command word and one data word if something should be written |
size_of_sent_data | the size of the command word default 1 = only command 2 = command and data word |
received_data | pointer to data structure buffer for the read data |
size_of_received_data | size of data words to be read |
SPICIno::SPICIno | ( | uint8_t | csPin = PIN_SPI_SS | ) |
Construct a new SPICIno::SPICIno object.
This function is setting the basics for a SPIC and the default spi. Use this call if:
csPin | optional chipselect pin. If not set it will be default PIN_SPI_SS |
SPICIno::SPICIno | ( | SPIClass3W & | port, |
uint8_t | csPin = PIN_SPI_SS , |
||
uint8_t | misoPin = PIN_SPI_MISO , |
||
uint8_t | mosiPin = PIN_SPI_MOSI , |
||
uint8_t | sckPin = PIN_SPI_SCK |
||
) |
Construct a new SPICIno::SPICIno object of the Arduino SPIC class.
This function sets all pins for a given SPI port, allowing a free setting of the SPI interface Use this call of:
port | SPI port if not default |
csPin | chipselect pin for the SPI port |
misoPin | miso pin number |
mosiPin | mosi pin number |
sckPin | systemclock pin number |
|
virtual |
Initialize the SPIC.
This function is initializing the chosen spi channel with the given values for lsb, clock and mode
Implements SPIC.
|
virtual |
Deinitialize the SPIC.
This function is deinitializing the chosen spi channel.
Implements SPIC.
|
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.
Implements SPIC.
|
virtual |
Main SPI three wire communication functions for sending and receiving data
sent_data | pointer two 2*unit16_t value for one command word and one data word if something should be written |
size_of_sent_data | the size of the command word default 1 = only command 2 = command and data word |
received_data | pointer to data structure buffer for the read data |
size_of_received_data | size of data words to be read |
Implements SPIC.
|
extern |
define a new SPI3W macro for handling more than the default SPI channel
uint8_t Tle5012Ino::mSpiNum = 0 |
Number of used SPI channel.