Macros | Functions
SensorUtil.h File Reference

Detailed Description

Utilities for sensor drivers.

Driver include

This header file should be included in an application as follows:

#include <ti/sysbios/knl/Clock.h>
#include <ti/sysbios/knl/Task.h>

Go to the source code of this file.

Macros

#define ST_ASSERT(cond)   ST( if (!(cond)) {SensorI2C_deselect(); return false;})
 
#define ST_ASSERT_V(cond)   ST( if (!(cond)) {SensorI2C_deselect(); return;} )
 
#define ST(x)   do { x } while (__LINE__ == -1)
 
#define HI_UINT16(a)   (((a) >> 8) & 0xFF)
 
#define LO_UINT16(a)   ((a) & 0xFF)
 
#define SWAP(v)   ((LO_UINT16(v) << 8) | HI_UINT16(v))
 
#define DELAY_MS(i)   (Task_sleep(((i) * 1000) / Clock_tickPeriod))
 
#define DELAY_US(i)   (Task_sleep(((i) * 1) / Clock_tickPeriod))
 
#define MS_2_TICKS(ms)   (((ms) * 1000) / Clock_tickPeriod)
 

Functions

void SensorUtil_convertToLe (uint8_t *pData, uint8_t nWords)
 Convert 16-bit words to/from big-endian to little-endian. More...
 
uint16_t SensorUtil_floatToSfloat (float data)
 Convert a float to a short float. More...
 
float SensorUtil_sfloatToFloat (uint16_t data)
 Convert a short float to a float. More...
 
uint16_t SensorUtil_intToSfloat (int data)
 Convert an integer to a short float. More...
 

Macro Definition Documentation

§ ST_ASSERT

#define ST_ASSERT (   cond)    ST( if (!(cond)) {SensorI2C_deselect(); return false;})

bool assertion; return 'false' and release I2C if condition is not met

§ ST_ASSERT_V

#define ST_ASSERT_V (   cond)    ST( if (!(cond)) {SensorI2C_deselect(); return;} )

void assertion; return and release I2C if condition is not met

§ ST

#define ST (   x)    do { x } while (__LINE__ == -1)

Loop enclosure for macros

§ HI_UINT16

#define HI_UINT16 (   a)    (((a) >> 8) & 0xFF)

Extract MSB from a 16 bit word

§ LO_UINT16

#define LO_UINT16 (   a)    ((a) & 0xFF)

Extract LSB from a 16 bit word

§ SWAP

#define SWAP (   v)    ((LO_UINT16(v) << 8) | HI_UINT16(v))

Swap bytes within a 16 bit word

§ DELAY_MS

#define DELAY_MS (   i)    (Task_sleep(((i) * 1000) / Clock_tickPeriod))

Delay task execution by (n) milliseconds

§ DELAY_US

#define DELAY_US (   i)    (Task_sleep(((i) * 1) / Clock_tickPeriod))

Delay task execution by (n) microseconds

§ MS_2_TICKS

#define MS_2_TICKS (   ms)    (((ms) * 1000) / Clock_tickPeriod)

Convert milliseconds to RTOS system ticks

Function Documentation

§ SensorUtil_convertToLe()

void SensorUtil_convertToLe ( uint8_t *  pData,
uint8_t  nWords 
)

Convert 16-bit words to/from big-endian to little-endian.

Parameters
pData- buffer to the data to be converted
nWords- number of 16-bit words to be swapped

§ SensorUtil_floatToSfloat()

uint16_t SensorUtil_floatToSfloat ( float  data)

Convert a float to a short float.

Parameters
data- floating point number to convert
Returns
converted value

§ SensorUtil_sfloatToFloat()

float SensorUtil_sfloatToFloat ( uint16_t  data)

Convert a short float to a float.

Parameters
data- short float number to convert
Returns
converted value

§ SensorUtil_intToSfloat()

uint16_t SensorUtil_intToSfloat ( int  data)

Convert an integer to a short float.

Parameters
data- integer to convert
Returns
converted value
Copyright 2017, Texas Instruments Incorporated