![]() |
ISSDK
1.8
IoT Sensing Software Development Kit
|
The mma865x_demo.c file implements the ISSDK MMA865x 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 "mma865x_drv.h"
#include "gpio_driver.h"
#include "host_io_uart.h"
#include "systick_utils.h"
#include "auto_detection_service.h"
Go to the source code of this file.
Data Structures | |
struct | mma865x_acceluserdata_t |
Macros | |
#define | MMA865x_ACCEL_DATA_SIZE 6 /* 2 byte X,Y,Z Axis Data each. */ |
#define | MMA865x_STREAM_DATA_SIZE 11 |
#define | APPLICATION_NAME "MMA8652 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 | mma865x_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 | cMma865xConfigInterrupt [] |
const registerreadlist_t | cMma865xOutputValues [] |
const registerreadlist_t | cMma8652qStatus [] = {{.readFrom = MMA865x_INT_SOURCE, .numBytes = 1}, __END_READ_DATA__} |
const registerreadlist_t | cMma8652qPLStatus [] = {{.readFrom = MMA865x_PL_STATUS, .numBytes = 1}, __END_READ_DATA__} |
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 | bMma865xDataReady = false |
volatile bool | bMma865xReady = false |
uint8_t | gStreamID |
int32_t | gSystick |
GENERIC_DRIVER_GPIO * | pGpioDriver = &Driver_GPIO_KSDK |
The mma865x_demo.c file implements the ISSDK MMA865x sensor demo example demonstration with interrupt mode.
Definition in file mma865x_demo.c.
#define APPLICATION_NAME "MMA8652 Accelerometer Demo" |
Unique Name for this application which should match the target GUI pkg name.
Definition at line 45 of file mma865x_demo.c.
Referenced by main().
#define APPLICATION_VERSION "2.5" |
Version to distinguish between instances the same application based on target Shield and updates.
Definition at line 47 of file mma865x_demo.c.
Referenced by main().
#define MMA865x_ACCEL_DATA_SIZE 6 /* 2 byte X,Y,Z Axis Data each. */ |
Definition at line 41 of file mma865x_demo.c.
Referenced by main().
#define MMA865x_STREAM_DATA_SIZE 11 |
Definition at line 42 of file mma865x_demo.c.
Referenced by main().
int main | ( | void | ) |
Main function.
Initialize the MCU hardware.
Initialize MMA865x pin used by FRDM board
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 MMA865x sensor driver.
Set the task to be executed while waiting for SPI transactions to complete.
Configure the MMA865x sensor.
Initialize streaming and assign a Stream ID.
Populate streaming header.
Clear the data ready flag, it will be set again by the ISR.
Read new raw sensor data from the MMA865x.
Convert the raw sensor data to signed 16-bit container for display to the debug port.
Read INT_SRC 0x0C from MMA865x.
Read PL_STATUS 0x10 from MMA865x.
Definition at line 213 of file mma865x_demo.c.
References mma865x_acceluserdata_t::accel, ADS_MAX_STRING_LENGTH, APPLICATION_NAME, APPLICATION_VERSION, bMma865xDataReady, bMma865xReady, BOARD_BootClockRUN, BOARD_DEBUG_UART_BAUDRATE, BOARD_RunADS(), BOARD_SystickElapsedTime_us(), BOARD_SystickEnable(), boardString, bStreamingEnabled, GENERIC_DRIVER_GPIO::clr_pin, data, mma865x_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(), mma865x_acceluserdata_t::intsrc, MMA8652_I2C_ADDR, MMA8652_INT1, MMA8652_WHOAMI_VALUE, MMA865x_ACCEL_DATA_SIZE, MMA865x_I2C_Configure(), MMA865x_I2C_Initialize(), MMA865x_I2C_ReadData(), MMA865x_I2C_SetIdleTask(), mma865x_int_data_ready_callback(), MMA865x_STREAM_DATA_SIZE, mma865x_i2c_sensorhandle_t::pCommDrv, GENERIC_DRIVER_GPIO::pin_init, process_host_command(), rawData, SENSOR_ERROR_NONE, SHIELD_NAME, shieldString, SMC, SMC_SetPowerModeVlpr(), SMC_SetPowerModeWait(), status, STREAMING_HEADER_LEN, streamingPacket, mma865x_acceluserdata_t::timestamp, fxos8700_accelmagdata_t::timestamp, and GENERIC_DRIVER_GPIO::toggle_pin.
void mma865x_int_data_ready_callback | ( | void * | pUserData | ) |
Set flag to indicate Sensor has signalled data ready.
Definition at line 124 of file mma865x_demo.c.
References bMma865xDataReady.
Referenced by main().
bool process_host_command | ( | uint8_t | tag, |
uint8_t * | hostCommand, | ||
uint8_t * | hostResponse, | ||
size_t * | hostMsgSize, | ||
size_t | respBufferSize | ||
) |
Definition at line 130 of file mma865x_demo.c.
References bMma865xReady, BOARD_SystickStart(), boardString, bStreamingEnabled, GENERIC_DRIVER_GPIO::clr_pin, embAppName, GREEN_LED, gStreamID, gSystick, HOST_CMD_START, HOST_CMD_STOP, HOST_MSG_CMD_ACT_OFFSET, HOST_MSG_LEN_LSB_OFFSET, HOST_PRO_CMD_W_CFG_TAG, HOST_PRO_INT_CMD_TAG, HOST_PRO_INT_DEV_TAG, and shieldString.
Referenced by main().
volatile bool bMma865xDataReady = false |
Definition at line 115 of file mma865x_demo.c.
Referenced by main(), and mma865x_int_data_ready_callback().
volatile bool bMma865xReady = false |
Definition at line 115 of file mma865x_demo.c.
Referenced by main(), and process_host_command().
char boardString[ADS_MAX_STRING_LENGTH] = {0} |
Definition at line 113 of file mma865x_demo.c.
Referenced by main(), and process_host_command().
volatile bool bStreamingEnabled = false |
Definition at line 115 of file mma865x_demo.c.
Referenced by main(), and process_host_command().
const registerreadlist_t cMma8652qPLStatus[] = {{.readFrom = MMA865x_PL_STATUS, .numBytes = 1}, __END_READ_DATA__} |
Prepare the register read for PL Status Register.
Definition at line 108 of file mma865x_demo.c.
const registerreadlist_t cMma8652qStatus[] = {{.readFrom = MMA865x_INT_SOURCE, .numBytes = 1}, __END_READ_DATA__} |
Prepare the register read for INT Status Register.
Definition at line 106 of file mma865x_demo.c.
const registerwritelist_t cMma865xConfigInterrupt[] |
Prepare the register write list to configure MMA865x in non-FIFO and ISR mode.
Definition at line 60 of file mma865x_demo.c.
const registerreadlist_t cMma865xOutputValues[] |
Prepare the register read list to read the raw Accel data from MMA865x.
Definition at line 103 of file mma865x_demo.c.
char embAppName[ADS_MAX_STRING_LENGTH] = {0} |
Definition at line 114 of file mma865x_demo.c.
Referenced by main(), and process_host_command().
uint8_t gStreamID |
Definition at line 116 of file mma865x_demo.c.
Referenced by main(), and process_host_command().
int32_t gSystick |
Definition at line 117 of file mma865x_demo.c.
Referenced by main(), and process_host_command().
GENERIC_DRIVER_GPIO* pGpioDriver = &Driver_GPIO_KSDK |
Definition at line 118 of file mma865x_demo.c.
char shieldString[ADS_MAX_STRING_LENGTH] = {0} |
Definition at line 113 of file mma865x_demo.c.
Referenced by main(), and process_host_command().