![]() |
ISSDK
1.8
IoT Sensing Software Development Kit
|
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"
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_GPIO * | pGpioDriver = &Driver_GPIO_KSDK |
The mma8491q_demo.c file implements the ISSDK MMA8491Q sensor driver demo demonstration with polling mode.
Definition in file mma8491q_demo.c.
#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().
#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().
#define LPTMR_T_CORRECTION_ms 2 |
Definition at line 52 of file mma8491q_demo.c.
Referenced by mma8491q_timer_fwk_init().
#define mma8491q_en_callback LPTMR0_IRQHandler |
Definition at line 43 of file mma8491q_demo.c.
#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().
#define MMA8491Q_T_ODR_ms 100U |
Definition at line 45 of file mma8491q_demo.c.
Referenced by 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.
void mma8491q_en_callback | ( | void | ) |
Definition at line 98 of file mma8491q_demo.c.
References bMma849qDataReady.
void mma8491q_en_delay | ( | ) |
Definition at line 85 of file mma8491q_demo.c.
References MMA8491Q_T_ON_TYPICAL.
Referenced by main().
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().
bool process_host_command | ( | uint8_t | tag, |
uint8_t * | hostCommand, | ||
uint8_t * | hostResponse, | ||
size_t * | hostMsgSize, | ||
size_t | respBufferSize | ||
) |
Definition at line 119 of file mma8491q_demo.c.
References bMma8491qReady, 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 bMma8491qReady = false |
Definition at line 69 of file mma8491q_demo.c.
Referenced by main(), and process_host_command().
volatile bool bMma849qDataReady = false |
Definition at line 69 of file mma8491q_demo.c.
Referenced by main(), and mma8491q_en_callback().
char boardString[ADS_MAX_STRING_LENGTH] = {0} |
Definition at line 67 of file mma8491q_demo.c.
Referenced by main(), and process_host_command().
volatile bool bStreamingEnabled = false |
Definition at line 69 of file mma8491q_demo.c.
Referenced by main(), and process_host_command().
const registerreadlist_t cMma8491qOutput[] |
Address and size of Raw Acceleration Data.
Definition at line 61 of file mma8491q_demo.c.
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.
char embAppName[ADS_MAX_STRING_LENGTH] = {0} |
Definition at line 68 of file mma8491q_demo.c.
Referenced by main(), and process_host_command().
gpioConfigKSDK_t gGpioConfigInPins |
Definition at line 70 of file mma8491q_demo.c.
uint8_t gStreamID |
Definition at line 77 of file mma8491q_demo.c.
Referenced by main(), and process_host_command().
int32_t gSystick |
Definition at line 78 of file mma8491q_demo.c.
Referenced by main(), and process_host_command().
GENERIC_DRIVER_GPIO* pGpioDriver = &Driver_GPIO_KSDK |
Definition at line 79 of file mma8491q_demo.c.
char shieldString[ADS_MAX_STRING_LENGTH] = {0} |
Definition at line 67 of file mma8491q_demo.c.
Referenced by main(), and process_host_command().