Nut/OS  5.0.5
API Reference
mma745x.c File Reference
#include <string.h>
#include <stdlib.h>
#include <compiler.h>
#include <cfg/os.h>
#include <sys/heap.h>
#include <sys/timer.h>
#include <sys/event.h>
#include <dev/gpio.h>
#include <dev/twif.h>
#include <dev/mma745x.h>
Include dependency graph for mma745x.c:

Defines

#define MPRINTF(...)
#define FFLUSH(...)
#define SGN10BIT   0x0200
#define Con2Cpl(v)   if (v & SGN10BIT) { v ^= ~SGN10BIT; v += SGN10BIT; }

Functions

int Mma745xWrite (uint_fast8_t reg, void *val, size_t len)
int Mma745xRead (uint_fast8_t reg, void *val, size_t len)
int Mma745xReadVal8 (mma8bit_t *val)
int Mma745xReadVal10 (uint8_t ofs, mma10bit_t *val)
int Mma745xReadG (mma10bit_t *val)
int Mma745xReadCal (mma10bit_t *cal)
int Mma745xWriteCal (mma10bit_t *cal)
int Mma745xCtl (uint_fast8_t fkt, void *val)
int Mma745xInit (uint_fast8_t selftest, mmaInit_t *init)

Variables

const mmaInit_t mmaDefault

Define Documentation

#define MPRINTF (   ...)

Referenced by Mma745xCtl(), and Mma745xInit().

#define FFLUSH (   ...)
#define SGN10BIT   0x0200
#define Con2Cpl (   v)    if (v & SGN10BIT) { v ^= ~SGN10BIT; v += SGN10BIT; }

Referenced by Mma745xReadVal10().


Function Documentation

int Mma745xWrite ( uint_fast8_t  reg,
void *  val,
size_t  len 
)

brief write to MMA7455L via I2C.

Write one byte to a register in the sensor. reg Register in sensor to address. val Pointer to value to write.

Returns:
0 if success, -1 on error.

References I2C_SLA_MMA745x, and TwMasterRegWrite.

Referenced by Mma745xCtl(), Mma745xInit(), and Mma745xWriteCal().

int Mma745xRead ( uint_fast8_t  reg,
void *  val,
size_t  len 
)

brief read from MMA7455L via I2C.

Read one byte from a register in the sensor. reg Register in sensor to address. val Pointer to store the value.

Returns:
0 if success, -1 on error.

References I2C_SLA_MMA745x, and TwMasterRegRead.

Referenced by Mma745xCtl(), Mma745xReadVal10(), and Mma745xReadVal8().

int Mma745xReadVal8 ( mma8bit_t val)

bief read all axes of the sensor as raw value.

This function read the current sensor values. Depending on the setup the values are in range of: 2g Mode: -2g..0g..2g -> 0x80..0x00..0x7f 4g Mode: -4g..0g..4g -> 0x80..0x00..0x7f 8g Mode: -8g..0g..8g -> 0x80..0x00..0x7f

para Pointer to mma8bit_t struct to store results in. result 0 if request was successfull, else -1;

References MMA745x_REG_XOUT8, and Mma745xRead().

Referenced by Mma745xReadG().

Here is the call graph for this function:

int Mma745xReadVal10 ( uint8_t  ofs,
mma10bit_t val 
)

bief read all axes of the sensor as raw value.

This function read the current sensor values. Depending on the setup the values are in range of: 8g Mode: -8g..0g..8g -> 0x0200..0x0000..0x01ff

para Pointer to mma8bit_t struct to store results in. result 0 if request was successfull, else -1;

References Con2Cpl, Mma745xRead(), mma10bit_t::x, mma10bit_t::y, and mma10bit_t::z.

Referenced by Mma745xReadCal().

Here is the call graph for this function:

int Mma745xReadG ( mma10bit_t val)

References MMA745X_MCTL_GLVL_2G, MMA745X_MCTL_GLVL_4G, MMA745X_MCTL_GLVL_8G, MMA745X_MCTL_GLVL_MSK, Mma745xReadVal8(), mmaInit_t::rMODE, mma10bit_t::x, mma8bit_t::x, mma10bit_t::y, mma8bit_t::y, mma10bit_t::z, and mma8bit_t::z.

Here is the call graph for this function:

int Mma745xReadCal ( mma10bit_t cal)

References MMA745x_REG_XOFFL, and Mma745xReadVal10().

Here is the call graph for this function:

int Mma745xWriteCal ( mma10bit_t cal)

References MMA745x_REG_XOFFL, and Mma745xWrite().

Here is the call graph for this function:

int Mma745xCtl ( uint_fast8_t  fkt,
void *  val 
)

References MMA745x_INTRST_MSK, MMA745x_REG_DETSRC, MMA745x_REG_INTRST, MMA745x_REG_MCTL, MMA745x_REG_STATUS, Mma745xRead(), Mma745xWrite(), MMA_CLR_IRQ, MMA_GET_IRQ, MMA_GET_STATE, MMA_SET_IRQ, MMA_SET_MODE, MPRINTF, and mmaInit_t::rMODE.

Here is the call graph for this function:

int Mma745xInit ( uint_fast8_t  selftest,
mmaInit_t init 
)

brief MMA7455L Initialization

Configure GPIO connections and preset MMA7455L registers.

Returns:
0 if success, -1 on error.

References GPIO_CFG_PULLUP, GpioPinConfigSet(), memcpy(), MMA745X_MCTL_STON, MMA745x_REG_MCTL, Mma745xWrite(), MPRINTF, NULL, and NutHeapAlloc.

Here is the call graph for this function:


Variable Documentation

Initial value:
 {
         MMA745X_MODE,
       0x00,
     0x00 ,
     0x00,
        127, 
        24, 
         100, 
          0, 
             0, 
}