TLx493D 3D Hall Sensor Generic Library  1.3
Generic library for the TLx493D 3D Hall sensor family
Macros
interface.h File Reference

Generic Library interface to the peripheral drivers. More...

#include <stddef.h>

Go to the source code of this file.

Macros

#define _I2C_read
 Function Header: (uint8_t addr, uint8_t *data, uint8_t count) More...
 
#define _I2C_write
 Function Header: (uint8_t addr, const uint8_t* data, uint8_t count) More...
 
#define _I2C_recover()
 Function Header: (void) More...
 
#define _I2C_reset()
 Function Header: (void) More...
 
#define _SET_ADDR_AND_WAIT(high)
 Function Header: (bool high) More...
 
#define _POWER_ENABLE()
 Function Header: (void) More...
 
#define _POWER_DISABLE()
 Function Header: (void) More...
 
#define _LOG_STR(buff, len)
 Function Header: (void *data, uint32_t count) More...
 

Detailed Description

Generic Library interface to the peripheral drivers.

The purpose of this file is to connect microcontroller dependent functions to the generic TLx493D library which is microcontroller agnostic. The functions specified below are needed for the normal functioning of the sensor.

In order to interface the the TLx493D (this library) to some microcontroller, several functions need to be implemented and then they should be specified in this file (interface.h). For example, in order to implement reading from the I2C bus, which is needed by the library, a function like the following is required:

int32_t I2C_read_device_specific(uint8_t addr, uint8_t *data, uint8_t count) {
int32_t status;
// Read from I2C and assign status variable
return status;
}

The this function should be specified below as such

#define _I2C_read I2C_read_device_specific

Please refer to the following #defines for information about the required implementation.

Note: ALL I2C functions should return a positive value of type int32_t (defined in stdint.h) indicating some communication error or Zero(0) indicating a successful communication. The positive return values themselves, aside from indicating an error, are meaningless to the library and thus can be arbitrarily chosen by the user as seen fit. Negative return value are reserved and used internally by the generic library, thus no function referred in this library should return a negative error as it may collide with the library reserved return value!

Macro Definition Documentation

◆ _I2C_read

#define _I2C_read

Function Header: (uint8_t addr, uint8_t *data, uint8_t count)

I2C read command must have a header precisely of type: (uint8_t addr, uint8_t *data, uint8_t count):

Parameters
addrThe I2C address of the sensor
dataThe array that the function will read to
countThe number of bytes the function will read
// =================== EXAMPLE ===================
// Read 10 bytes from the I2C device with address 0x63
// to the array data_ptr
// The error code will be written to error. On success
// it will be 0 (Zero).
uint8_t data_ptr[10];
error = _I2C_read(0x23, data_ptr, 10);

◆ _I2C_recover

#define _I2C_recover ( )

Function Header: (void)

_I2C_recover should take no parameter. It will write the recover address (FF) on the I2C bus

// ============ EXAMPLE ==============
// Perform am I2C recovery command

◆ _I2C_reset

#define _I2C_reset ( )

Function Header: (void)

_I2C_reset should take no parameter. It will write the reset address (00) on the I2C bus

// ============ EXAMPLE ==============
// Perform am I2C reset command

◆ _I2C_write

#define _I2C_write

Function Header: (uint8_t addr, const uint8_t* data, uint8_t count)

I2C write command must have a header precisely of type: (uint8_t addr, const uint8_t* data, uint8_t count), where:

Parameters
addrIs the I2C address to read from data is the;
datais the array that the function will read to
countis the number of bytes the function will read
// =============== EXAMPLE ================
uint8_t payload[] = {5, 1, 2, 3};
// write 4 bytes from payload to the I2C device with address 0x23
error = _I2C_write(0x23, payload, 4);

◆ _LOG_STR

#define _LOG_STR (   buff,
  len 
)

Function Header: (void *data, uint32_t count)

Offers a method to log a string. The header of the method should be of type (void *data, uint32_t count)

Parameters
dataAn array of unit8_t to be written
countThe number of bytes to be written
// ============ EXAMPLE ==============
// log the string 'Example'
_LOG_STR("Example", sizeof("Example") - 1);

◆ _POWER_DISABLE

#define _POWER_DISABLE ( )

Function Header: (void)

Set the pin responsible with supplying the sensor voltage to LOW. The function will be called with no arguments.

// ============ EXAMPLE ==============
// Power Down the sensor

◆ _POWER_ENABLE

#define _POWER_ENABLE ( )

Function Header: (void)

Set the pin responsible with supplying the sensor voltage to HIGH. The function will be called with no arguments.

// ============ EXAMPLE ==============
// Power Up the sensor

◆ _SET_ADDR_AND_WAIT

#define _SET_ADDR_AND_WAIT (   high)

Function Header: (bool high)

Parameters
highA value of true will set the ADDR pin HIGH at sensor power up, and a value of false will set the ADDR pin to LOW at sensor power up.

Set the desired level on ADDR(SDA) pin and wait at least 200us. Header should be of type (bool high) where: _SET_ADDR_AND_WAIT(true) will set the ADDR(SDA) line to HIGH and then wait for at least 200us. _SET_ADDR_AND_WAIT(false) will set the ADDR(SDA) line to LOW and then wait for at least 200us. Finally, the SDA line should be set back to HIGH.

// =========== EXAMPLE ===========
// set voltage on ADDR pin to low and wait for sensor startup