Microchip® Advanced Software Framework

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
MEMS Sensors - Accelerometer MMA7341L

Low-level driver for the Accelerometer MMA7341L.

This driver provides access to the main features of the Accelerometer MMA7341L.

Macros

#define MMA7341L_SAMPLES   16
 
#define TAN15   17
 

Functions

void mma7341l_calibration (void)
 Calibrate MMA7341L component and set the present axis value. More...
 
xyz_g_t mma7341l_get_gravity_value (void)
 Get the gravity value of x,y,z axis. More...
 
uint32_t mma7341l_get_rotation_dir (void)
 Check if the tilt angle is big enough. More...
 
static xyz_t mma7341l_get_value (void)
 Get converted data from x,y,z axis. More...
 
void mma7341l_init (void)
 Initialize MMA7341L. More...
 
void mma7341l_set_mode (uint8_t uc_mode)
 Set MMA7341L working mode. More...
 
static void mma7341l_update (void)
 Update ADC channel conversion value. More...
 
static xyz_t mma7341l_xyz_add (xyz_t p, xyz_t q)
 Addition of two Position axis values. More...
 
static xyz_t mma7341l_xyz_diff (xyz_t p, xyz_t q)
 Subtraction of two Position axis values. More...
 

Variables

acc_t acc
 
static float f_volt_0g
 
static float f_volt_1g
 
static uint8_t uc_adc_channel_x
 
static uint8_t uc_adc_channel_y
 
static uint8_t uc_adc_channel_z
 

#define MMA7341L_SAMPLES   16

Referenced by mma7341l_calibration().

#define TAN15   17

void mma7341l_calibration ( void  )

Calibrate MMA7341L component and set the present axis value.

References acc_t::k, acc_t::m, mma7341l_get_value(), MMA7341L_SAMPLES, mma7341l_xyz_add(), xyz_t::x, xyz_t::y, and xyz_t::z.

xyz_g_t mma7341l_get_gravity_value ( void  )

Get the gravity value of x,y,z axis.

Returns
Gravity value of x,y,z axis.

References f_volt_0g, acc_t::m, mma7341l_update(), xyz_t::x, xyz_g_t::x_g, xyz_t::y, xyz_g_t::y_g, xyz_t::z, and xyz_g_t::z_g.

uint32_t mma7341l_get_rotation_dir ( void  )

Check if the tilt angle is big enough.

If yes, get rotation direction according to the sign of two axes.

Returns
Rotation direction.

References acc_t::ak, acc_t::k, acc_t::m, MMA7341L_1G, MMA7341L_DOWM_RIGHT, MMA7341L_DOWN, MMA7341L_DOWN_LEFT, MMA7341L_LEFT, MMA7341L_RIGHT, MMA7341L_UNCHANGED, MMA7341L_UP, MMA7341L_UP_LEFT, MMA7341L_UP_RIGHT, mma7341l_update(), mma7341l_xyz_diff(), TAN15, xyz_t::x, xyz_t::y, and xyz_t::z.

static xyz_t mma7341l_get_value ( void  )
static

Get converted data from x,y,z axis.

Returns
Converted data for three channels.

References MMA7341L_SHIFT, xyz_t::x, xyz_t::y, and xyz_t::z.

Referenced by mma7341l_calibration(), and mma7341l_update().

void mma7341l_init ( void  )
void mma7341l_set_mode ( uint8_t  uc_mode)

Set MMA7341L working mode.

Parameters
uc_modeWorking mode value (1 is normal and 0 is sleep).

References gpio_set_pin_high, and gpio_set_pin_low.

static void mma7341l_update ( void  )
static

Update ADC channel conversion value.

References acc_t::m, and mma7341l_get_value().

Referenced by mma7341l_get_gravity_value(), and mma7341l_get_rotation_dir().

static xyz_t mma7341l_xyz_add ( xyz_t  p,
xyz_t  q 
)
static

Addition of two Position axis values.

Returns
The addition value.

References xyz_t::x, xyz_t::y, and xyz_t::z.

Referenced by mma7341l_calibration().

static xyz_t mma7341l_xyz_diff ( xyz_t  p,
xyz_t  q 
)
static

Subtraction of two Position axis values.

Returns
The subtraction value.

References xyz_t::x, xyz_t::y, and xyz_t::z.

Referenced by mma7341l_get_rotation_dir().

acc_t acc
Initial value:
= {
.m = {.x = 0,.y = 0,.z = 0},
.ak = {.x = 0,.y = 0,.z = 0},
}
#define MMA7341L_ZERO_Z
Definition: mma7341l.h:61
#define MMA7341L_ZERO_X
Definition: mma7341l.h:59
#define MMA7341L_ZERO_Y
Definition: mma7341l.h:60

Referenced by inet_chksum_pbuf(), inet_chksum_pseudo(), and inet_chksum_pseudo_partial().

float f_volt_0g
static
float f_volt_1g
static
uint8_t uc_adc_channel_x
static
uint8_t uc_adc_channel_y
static
uint8_t uc_adc_channel_z
static