ISSDK  1.7
IoT Sensing Software Development Kit
Macros | Functions | Variables
mma9553_demo.c File Reference

The mma9553_demo.c file implements the ISSDK MMA9553L sensor driver example demonstration as a Accelerometer in I2C Mode. More...

#include "board.h"
#include "pin_mux.h"
#include "fsl_lptmr.h"
#include "clock_config.h"
#include "Driver_I2C.h"
#include "issdk_hal.h"
#include "gpio_driver.h"
#include "mma9553_drv.h"
#include "host_io_uart.h"
#include "systick_utils.h"
#include "auto_detection_service.h"
Include dependency graph for mma9553_demo.c:

Go to the source code of this file.

Macros

#define SAMPLING_RATE_ms   (100) /* Timeout for the ODR Timer. */
 
#define MMA9553_ACCEL_DATA_SIZE   (6) /* 2 byte X,Y,Z Axis Data each. */
 
#define mma9553_en_callback   LPTMR0_IRQHandler /* Timer timeout Callback. */
 
#define MMA9553_STREAM_DATA_SIZE   (10)
 
#define APPLICATION_NAME   "MMA9553 Pedometer Demo"
 Unique Name for this application which should match the target GUI pkg name. More...
 
#define APPLICATION_VERSION   "2.5"
 Version to distinguish between instances the same application based on target Shield and updates. More...
 

Functions

void mma9553_en_callback (void)
 
bool process_host_command (uint8_t tag, uint8_t *hostCommand, uint8_t *hostResponse, size_t *hostMsgSize, size_t respBufferSize)
 
int main (void)
 Main function. More...
 

Variables

const registercommandlist_t cMma9553Config30Hz []
 
const registerreadlist_t cMma9553ReadRawOutput []
 
char boardString [ADS_MAX_STRING_LENGTH] = {0}
 
char shieldString [ADS_MAX_STRING_LENGTH] = {0}
 
char embAppName [ADS_MAX_STRING_LENGTH] = {0}
 
volatile bool bStreamingEnabled = false
 
volatile bool bMma9553DataReady = false
 
volatile bool bMma9553Ready = false
 
uint8_t gStreamID
 
int32_t gSystick
 
GENERIC_DRIVER_GPIOpGpioDriver = &Driver_GPIO_KSDK
 

Detailed Description

The mma9553_demo.c file implements the ISSDK MMA9553L sensor driver example demonstration as a Accelerometer in I2C Mode.

Definition in file mma9553_demo.c.

Macro Definition Documentation

◆ APPLICATION_NAME

#define APPLICATION_NAME   "MMA9553 Pedometer Demo"

Unique Name for this application which should match the target GUI pkg name.

Definition at line 68 of file mma9553_demo.c.

Referenced by main().

◆ APPLICATION_VERSION

#define APPLICATION_VERSION   "2.5"

Version to distinguish between instances the same application based on target Shield and updates.

Definition at line 70 of file mma9553_demo.c.

Referenced by main().

◆ MMA9553_ACCEL_DATA_SIZE

#define MMA9553_ACCEL_DATA_SIZE   (6) /* 2 byte X,Y,Z Axis Data each. */

Definition at line 62 of file mma9553_demo.c.

◆ mma9553_en_callback

#define mma9553_en_callback   LPTMR0_IRQHandler /* Timer timeout Callback. */

Definition at line 63 of file mma9553_demo.c.

◆ MMA9553_STREAM_DATA_SIZE

#define MMA9553_STREAM_DATA_SIZE   (10)

Definition at line 65 of file mma9553_demo.c.

Referenced by main().

◆ SAMPLING_RATE_ms

#define SAMPLING_RATE_ms   (100) /* Timeout for the ODR Timer. */

Definition at line 61 of file mma9553_demo.c.

Referenced by main().

Function Documentation

◆ main()

int main ( void  )

Main function.

Initialize the MCU hardware

Initialize RGB LED pin used by FRDM board

Initialize the I2C driver.

Set the I2C Power mode.

Set the I2C bus speed.

Initialize the UART driver.

Set the UART Power mode.

Set UART Baud Rate.

Initialize the MMA9553 sensor driver.

Set the task to be executed while waiting for I2C transactions to complete.

Configure the MMA9553 sensor driver with 30Hz Mode settings.

Initialize streaming and assign a Stream ID.

Populate streaming header.

Clear the data ready flag, it will be set again by the ISR.

Read the raw sensor data from the MMA9553.

Definition at line 191 of file mma9553_demo.c.

References mma9553_acceldata_t::accel, ADS_MAX_STRING_LENGTH, APPLICATION_NAME, APPLICATION_VERSION, bMma9553DataReady, bMma9553Ready, BOARD_BootClockRUN, BOARD_DEBUG_UART_BAUDRATE, BOARD_RunADS(), BOARD_SystickElapsedTime_us(), BOARD_SystickEnable(), boardString, bStreamingEnabled, GENERIC_DRIVER_GPIO::clr_pin, mma9553_i2c_sensorhandle_t::deviceInfo, embAppName, GPIO_DIRECTION_OUT, GREEN_LED, gStreamID, gSystick, HOST_FORMAT_HDLC, Host_IO_Add_ISO_Header(), Host_IO_Init(), Host_IO_Receive(), Host_IO_Send(), HOST_S_DRIVER, HOST_S_SIGNAL_EVENT, I2C_S_DEVICE_INDEX, I2C_S_DRIVER, I2C_S_SIGNAL_EVENT, int32_t(), MMA9553_I2C_ADDR, MMA9553_I2C_CommandResponse(), MMA9553_I2C_Configure(), MMA9553_I2C_Initialize(), MMA9553_I2C_SetIdleTask(), MMA9553_STREAM_DATA_SIZE, mma9553_i2c_sensorhandle_t::pCommDrv, GENERIC_DRIVER_GPIO::pin_init, process_host_command(), rawData, SAMPLING_RATE_ms, SENSOR_ERROR_NONE, SHIELD_NAME, shieldString, SMC, SMC_SetPowerModeWait(), status, STREAMING_HEADER_LEN, streamingPacket, fxls8962_acceldataUser_t::timestamp, mma9553_acceldata_t::timestamp, and GENERIC_DRIVER_GPIO::toggle_pin.

Here is the call graph for this function:

◆ mma9553_en_callback()

void mma9553_en_callback ( void  )

Definition at line 101 of file mma9553_demo.c.

References bMma9553DataReady.

◆ process_host_command()

bool process_host_command ( uint8_t  tag,
uint8_t *  hostCommand,
uint8_t *  hostResponse,
size_t *  hostMsgSize,
size_t  respBufferSize 
)

Variable Documentation

◆ bMma9553DataReady

volatile bool bMma9553DataReady = false

Definition at line 92 of file mma9553_demo.c.

Referenced by main(), and mma9553_en_callback().

◆ bMma9553Ready

volatile bool bMma9553Ready = false

Definition at line 92 of file mma9553_demo.c.

Referenced by main(), and process_host_command().

◆ boardString

char boardString[ADS_MAX_STRING_LENGTH] = {0}

Definition at line 90 of file mma9553_demo.c.

Referenced by main(), and process_host_command().

◆ bStreamingEnabled

volatile bool bStreamingEnabled = false

Definition at line 92 of file mma9553_demo.c.

Referenced by main(), and process_host_command().

◆ cMma9553Config30Hz

const registercommandlist_t cMma9553Config30Hz[]
Initial value:
= {
{SetFSRange_2g, 0, sizeof(SetFSRange_2g)},
const uint8_t SetFSRange_2g[5]
Full-Scale Range Selections.
Definition: mma9553_drv.c:89
const uint8_t SetMBoxPriority_for30Hz[5]
Definition: mma9553_drv.c:118
const uint8_t SetAFEPriority_for30Hz[5]
Definition: mma9553_drv.c:108
const uint8_t SetSampleRate_30Hz[5]
Definition: mma9553_drv.c:98
#define __END_WRITE_CMD__
Definition: sensor_drv.h:83

Prepare the register write list to configure MMA9553L in 30Hz Mode.

Definition at line 76 of file mma9553_demo.c.

◆ cMma9553ReadRawOutput

const registerreadlist_t cMma9553ReadRawOutput[]
Initial value:
= {
#define MMA9553_ACCEL_DATA_SIZE
Definition: mma9553_demo.c:62
#define MMA9553_XYZ_DATA_OFFSET
XYZ Data Register Offset.
Definition: mma9553.h:22
#define __END_READ_DATA__
Definition: sensor_drv.h:77

Prepare the register read list to read the raw Accel data from MMA9553.

Definition at line 84 of file mma9553_demo.c.

◆ embAppName

char embAppName[ADS_MAX_STRING_LENGTH] = {0}

Definition at line 91 of file mma9553_demo.c.

Referenced by main(), and process_host_command().

◆ gStreamID

uint8_t gStreamID

Definition at line 93 of file mma9553_demo.c.

Referenced by main(), and process_host_command().

◆ gSystick

int32_t gSystick

Definition at line 94 of file mma9553_demo.c.

Referenced by main(), and process_host_command().

◆ pGpioDriver

Definition at line 95 of file mma9553_demo.c.

◆ shieldString

char shieldString[ADS_MAX_STRING_LENGTH] = {0}

Definition at line 90 of file mma9553_demo.c.

Referenced by main(), and process_host_command().