ISSDK  1.7
IoT Sensing Software Development Kit
Data Structures | Macros | Functions | Variables
mma845x_demo.c File Reference

The mma845x_demo.c file implements the ISSDK MMA845x sensor demo example demonstration with interrupt mode. More...

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

Go to the source code of this file.

Data Structures

struct  mma845x_acceluserdata_t
 

Macros

#define MMA845x_STREAM_DATA_SIZE   11 /* 6+1 byte Data */
 
#define APPLICATION_NAME   "MMA845x 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...
 

Functions

void mma845x_int_data_ready_callback (void *pUserData)
 
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 registerwritelist_t mma845x_Config_Isr []
 
const registerreadlist_t mma845x_Output_Values []
 
const registerreadlist_t cMma845xqStatus []
 
const registerreadlist_t cMma845xqPLStatus []
 
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 bMma845xDataReady = false
 
volatile bool bMma845xReady = false
 
uint8_t gStreamID
 
int32_t gSystick
 
GENERIC_DRIVER_GPIOpGpioDriver = &Driver_GPIO_KSDK
 

Detailed Description

The mma845x_demo.c file implements the ISSDK MMA845x sensor demo example demonstration with interrupt mode.

Definition in file mma845x_demo.c.

Macro Definition Documentation

◆ APPLICATION_NAME

#define APPLICATION_NAME   "MMA845x Accelerometer Demo"

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

Definition at line 70 of file mma845x_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 72 of file mma845x_demo.c.

Referenced by main().

◆ MMA845x_STREAM_DATA_SIZE

#define MMA845x_STREAM_DATA_SIZE   11 /* 6+1 byte Data */

Definition at line 67 of file mma845x_demo.c.

Referenced by main().

Function Documentation

◆ main()

int main ( void  )

Main function.

Initialize the MCU hardware.

Initialize INT1 MMA845x pin used by FRDM board

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.

Initialize the MMA845x sensor driver.

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

Configure the MMA845x sensor driver.

Initialize streaming and assign a Stream ID.

Populate streaming header.

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

Read raw sensor data from the MMA845x.

Convert the raw sensor data to signed 32-bit and 16-bit containers for display to the debug port.

Read INT_SRC 0x0C from MMA845x.

Definition at line 245 of file mma845x_demo.c.

References mma845x_acceluserdata_t::accel, ADS_MAX_STRING_LENGTH, APPLICATION_NAME, APPLICATION_VERSION, bMma845xDataReady, bMma845xReady, BOARD_BootClockRUN, BOARD_DEBUG_UART_BAUDRATE, BOARD_RunADS(), BOARD_SystickElapsedTime_us(), BOARD_SystickEnable(), boardString, bStreamingEnabled, GENERIC_DRIVER_GPIO::clr_pin, data, mma845x_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(), mma845x_acceluserdata_t::intsrc, MMA8451_WHO_AM_I_WHOAMI_VALUE, MMA845x_ACCEL_DATA_SIZE, MMA845x_I2C_ADDR, MMA845x_I2C_Configure(), MMA845x_I2C_Initialize(), MMA845x_I2C_ReadData(), MMA845x_I2C_SetIdleTask(), MMA845x_INT1, mma845x_int_data_ready_callback(), MMA845x_STREAM_DATA_SIZE, mma845x_i2c_sensorhandle_t::pCommDrv, GENERIC_DRIVER_GPIO::pin_init, process_host_command(), rawData, SENSOR_ERROR_NONE, SHIELD_NAME, shieldString, SMC, SMC_SetPowerModeWait(), status, STREAMING_HEADER_LEN, streamingPacket, mma845x_acceluserdata_t::timestamp, fxls8962_acceldataUser_t::timestamp, and GENERIC_DRIVER_GPIO::toggle_pin.

Here is the call graph for this function:

◆ mma845x_int_data_ready_callback()

void mma845x_int_data_ready_callback ( void *  pUserData)

Set flag to indicate Sensor has signalled data ready.

Definition at line 156 of file mma845x_demo.c.

References bMma845xDataReady.

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

◆ bMma845xDataReady

volatile bool bMma845xDataReady = false

Definition at line 147 of file mma845x_demo.c.

Referenced by main(), and mma845x_int_data_ready_callback().

◆ bMma845xReady

volatile bool bMma845xReady = false

Definition at line 147 of file mma845x_demo.c.

Referenced by main(), and process_host_command().

◆ boardString

char boardString[ADS_MAX_STRING_LENGTH] = {0}

Definition at line 145 of file mma845x_demo.c.

Referenced by main(), and process_host_command().

◆ bStreamingEnabled

volatile bool bStreamingEnabled = false

Definition at line 147 of file mma845x_demo.c.

Referenced by main(), and process_host_command().

◆ cMma845xqPLStatus

const registerreadlist_t cMma845xqPLStatus[]
Initial value:
= {
{.readFrom = MMA845x_PL_STATUS, .numBytes = 1}, __END_READ_DATA__}
#define __END_READ_DATA__
Definition: sensor_drv.h:77

Definition at line 139 of file mma845x_demo.c.

◆ cMma845xqStatus

const registerreadlist_t cMma845xqStatus[]
Initial value:
= {
{.readFrom = MMA845x_INT_SOURCE, .numBytes = 1}, __END_READ_DATA__}
#define __END_READ_DATA__
Definition: sensor_drv.h:77

Prepare the register read for Status Register.

Definition at line 137 of file mma845x_demo.c.

◆ embAppName

char embAppName[ADS_MAX_STRING_LENGTH] = {0}

Definition at line 146 of file mma845x_demo.c.

Referenced by main(), and process_host_command().

◆ gStreamID

uint8_t gStreamID

Definition at line 148 of file mma845x_demo.c.

Referenced by main(), and process_host_command().

◆ gSystick

int32_t gSystick

Definition at line 149 of file mma845x_demo.c.

Referenced by main(), and process_host_command().

◆ mma845x_Config_Isr

const registerwritelist_t mma845x_Config_Isr[]

Prepare the register write list to configure MMA845x in non-FIFO and ISR mode.

Definition at line 85 of file mma845x_demo.c.

◆ mma845x_Output_Values

const registerreadlist_t mma845x_Output_Values[]
Initial value:
= {
#define __END_READ_DATA__
Definition: sensor_drv.h:77
#define MMA845x_ACCEL_DATA_SIZE
The size of the MMA845x accel data.
Definition: mma845x_drv.h:73

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

Definition at line 134 of file mma845x_demo.c.

◆ pGpioDriver

Definition at line 150 of file mma845x_demo.c.

◆ shieldString

char shieldString[ADS_MAX_STRING_LENGTH] = {0}

Definition at line 145 of file mma845x_demo.c.

Referenced by main(), and process_host_command().