![]() |
TLx493D 3D Hall Sensor Generic Library
1.3
Generic library for the TLx493D 3D Hall sensor family
|
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... | |
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:
The this function should be specified below as such
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!
| #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):
| addr | The I2C address of the sensor |
| data | The array that the function will read to |
| count | The number of bytes the function will read |
| #define _I2C_recover | ( | ) |
Function Header: (void)
_I2C_recover should take no parameter. It will write the recover address (FF) on the I2C bus
| #define _I2C_reset | ( | ) |
Function Header: (void)
_I2C_reset should take no parameter. It will write the reset address (00) on the I2C bus
| #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:
| addr | Is the I2C address to read from data is the; |
| data | is the array that the function will read to |
| count | is the number of bytes the function will read |
| #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)
| data | An array of unit8_t to be written |
| count | The number of bytes to be written // ============ EXAMPLE ============== // log the string 'Example' |
| #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.
| #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.
| #define _SET_ADDR_AND_WAIT | ( | high | ) |
Function Header: (bool high)
| high | A 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.
1.8.14