ISSDK  1.8
IoT Sensing Software Development Kit
Macros | Functions | Variables
mma8491q_demo.c File Reference

The mma8491q_demo.c file implements the ISSDK MMA8491Q sensor driver demo demonstration with polling mode. More...

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

Go to the source code of this file.

Macros

#define mma8491q_en_callback   LPTMR0_IRQHandler
 
#define MMA8491Q_T_ODR_ms   100U
 
#define MMA8491Q_STREAM_DATA_SIZE   13 /* The size of Streaming Data in Host Message. */
 
#define APPLICATION_NAME   "MMA8491 Accelerometer 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...
 
#define LPTMR_T_CORRECTION_ms   2
 

Functions

void mma8491q_en_delay ()
 
void mma8491q_en_callback (void)
 
void mma8491q_timer_fwk_init (uint32_t samplingInterval)
 
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 registerreadlist_t cMma8491qStatus [] = {{.readFrom = MMA8491Q_STATUS, .numBytes = 1}, __END_READ_DATA__}
 Address of Status Register. More...
 
const registerreadlist_t cMma8491qOutput []
 Address and size of Raw Acceleration Data. More...
 
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 bMma8491qReady = false
 
volatile bool bMma849qDataReady = false
 
gpioConfigKSDK_t gGpioConfigInPins
 
uint8_t gStreamID
 
int32_t gSystick
 
GENERIC_DRIVER_GPIOpGpioDriver = &Driver_GPIO_KSDK
 

Detailed Description

The mma8491q_demo.c file implements the ISSDK MMA8491Q sensor driver demo demonstration with polling mode.

Definition in file mma8491q_demo.c.

Macro Definition Documentation

◆ APPLICATION_NAME

#define APPLICATION_NAME   "MMA8491 Accelerometer Demo"

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

Definition at line 48 of file mma8491q_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 50 of file mma8491q_demo.c.

Referenced by main().

◆ LPTMR_T_CORRECTION_ms

#define LPTMR_T_CORRECTION_ms   2

Definition at line 52 of file mma8491q_demo.c.

Referenced by mma8491q_timer_fwk_init().

◆ mma8491q_en_callback

#define mma8491q_en_callback   LPTMR0_IRQHandler

Definition at line 43 of file mma8491q_demo.c.

◆ MMA8491Q_STREAM_DATA_SIZE

#define MMA8491Q_STREAM_DATA_SIZE   13 /* The size of Streaming Data in Host Message. */

Definition at line 46 of file mma8491q_demo.c.

Referenced by main().

◆ MMA8491Q_T_ODR_ms

#define MMA8491Q_T_ODR_ms   100U

Definition at line 45 of file mma8491q_demo.c.

Referenced by main().

Function Documentation

◆ main()

int main ( void  )

Main function.

Initialize the MCU hardware.

Initialize GREEN 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.

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

Initialize streaming and assign a Stream ID.

Populate streaming header.

Initialize MMA8491_ODR Timer framework.

Process packets only if streaming has been enabled by Host

Process packets only when data ready is indicated by the MMA8491Q.

Read the raw sensor data from the MMA8491Q.

Process the sample and convert the raw sensor data.

Definition at line 204 of file mma8491q_demo.c.

References mma8491q_acceldata_t::accel, ADS_MAX_STRING_LENGTH, APPLICATION_NAME, APPLICATION_VERSION, bMma8491qReady, bMma849qDataReady, BOARD_BootClockRUN, BOARD_DEBUG_UART_BAUDRATE, BOARD_RunADS(), BOARD_SystickElapsedTime_us(), BOARD_SystickEnable(), boardString, bStreamingEnabled, GENERIC_DRIVER_GPIO::clr_pin, data, mma8491q_i2c_sensorhandle_t::deviceInfo, embAppName, GPIO_DIRECTION_IN, 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(), MMA8491_EN, MMA8491_I2C_ADDR, MMA8491_XOUT, MMA8491_YOUT, MMA8491_ZOUT, MMA8491Q_DATA_SIZE, mma8491q_en_delay(), MMA8491Q_I2C_Initialize(), MMA8491Q_I2C_ReadData(), MMA8491Q_I2C_SetIdleTask(), MMA8491Q_STATUS_ZYXDR_MASK, MMA8491Q_STREAM_DATA_SIZE, MMA8491Q_T_ODR_ms, mma8491q_timer_fwk_init(), mma8491q_i2c_sensorhandle_t::pCommDrv, GENERIC_DRIVER_GPIO::pin_init, process_host_command(), rawData, GENERIC_DRIVER_GPIO::read_pin, SENSOR_ERROR_NONE, GENERIC_DRIVER_GPIO::set_pin, SHIELD_NAME, shieldString, SMC, SMC_SetPowerModeVlpr(), SMC_SetPowerModeWait(), status, STREAMING_HEADER_LEN, streamingPacket, mma8491q_acceldata_t::tilt, mma8491q_acceldata_t::timestamp, fxos8700_accelmagdata_t::timestamp, and GENERIC_DRIVER_GPIO::toggle_pin.

Here is the call graph for this function:

◆ mma8491q_en_callback()

void mma8491q_en_callback ( void  )

Definition at line 98 of file mma8491q_demo.c.

References bMma849qDataReady.

◆ mma8491q_en_delay()

void mma8491q_en_delay ( )

Definition at line 85 of file mma8491q_demo.c.

References MMA8491Q_T_ON_TYPICAL.

Referenced by main().

Here is the caller graph for this function:

◆ mma8491q_timer_fwk_init()

void mma8491q_timer_fwk_init ( uint32_t  samplingInterval)

Definition at line 105 of file mma8491q_demo.c.

References LPTMR_T_CORRECTION_ms.

Referenced by main().

Here is the caller graph for this function:

◆ process_host_command()

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

Variable Documentation

◆ bMma8491qReady

volatile bool bMma8491qReady = false

Definition at line 69 of file mma8491q_demo.c.

Referenced by main(), and process_host_command().

◆ bMma849qDataReady

volatile bool bMma849qDataReady = false

Definition at line 69 of file mma8491q_demo.c.

Referenced by main(), and mma8491q_en_callback().

◆ boardString

char boardString[ADS_MAX_STRING_LENGTH] = {0}

Definition at line 67 of file mma8491q_demo.c.

Referenced by main(), and process_host_command().

◆ bStreamingEnabled

volatile bool bStreamingEnabled = false

Definition at line 69 of file mma8491q_demo.c.

Referenced by main(), and process_host_command().

◆ cMma8491qOutput

const registerreadlist_t cMma8491qOutput[]
Initial value:
= {{.readFrom = MMA8491Q_OUT_X_MSB, .numBytes = MMA8491Q_DATA_SIZE},
#define __END_READ_DATA__
Definition: sensor_drv.h:51
#define MMA8491Q_DATA_SIZE
Definition: mma8491q_drv.h:63

Address and size of Raw Acceleration Data.

Definition at line 61 of file mma8491q_demo.c.

◆ cMma8491qStatus

const registerreadlist_t cMma8491qStatus[] = {{.readFrom = MMA8491Q_STATUS, .numBytes = 1}, __END_READ_DATA__}

Address of Status Register.

Definition at line 58 of file mma8491q_demo.c.

◆ embAppName

char embAppName[ADS_MAX_STRING_LENGTH] = {0}

Definition at line 68 of file mma8491q_demo.c.

Referenced by main(), and process_host_command().

◆ gGpioConfigInPins

gpioConfigKSDK_t gGpioConfigInPins
Initial value:
=
{
.pinConfig = {kGPIO_DigitalInput, 0},
.interruptMode = kPORT_InterruptOrDMADisabled,
.portPinConfig = {0},
.portPinConfig.mux = kPORT_MuxAsGpio,
}

Definition at line 70 of file mma8491q_demo.c.

◆ gStreamID

uint8_t gStreamID

Definition at line 77 of file mma8491q_demo.c.

Referenced by main(), and process_host_command().

◆ gSystick

int32_t gSystick

Definition at line 78 of file mma8491q_demo.c.

Referenced by main(), and process_host_command().

◆ pGpioDriver

Definition at line 79 of file mma8491q_demo.c.

◆ shieldString

char shieldString[ADS_MAX_STRING_LENGTH] = {0}

Definition at line 67 of file mma8491q_demo.c.

Referenced by main(), and process_host_command().