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

The fxlc95000_flash_demo.c file implements the ISSDK FXLC95000L sensor driver example demonstration for FLASH programming and Streaming for I2C Mode using Host I/O. 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 "host_io_uart.h"
#include "systick_utils.h"
#include "fxlc95000_drv.h"
#include "auto_detection_service.h"
Include dependency graph for fxlc95000_flash_demo.c:

Go to the source code of this file.

Macros

#define fxlc95000_odrCallback   LPTMR0_IRQHandler /* Timer timeout Callback. */
 
#define SAMPLING_RATE_ms   100 /* Timeout for the ODR Timer in ms. */
 
#define FXLC95000_SAMPLE_SIZE   10 /* 4-Byte timestamp and 2-Byte X,Y,Z Data each. */
 
#define APPLICATION_NAME   "FXLC95000 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 fxlc95000_odrCallback (void)
 
int fxlc95000_enSensor (fxlc95000_i2c_sensorhandle_t *pSensorHandle)
 
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 uint8_t cFxlc95000_SetODR_Cmd []
 
const uint8_t cFxlc95000_SetResolution_Cmd []
 
const uint8_t cFxlc95000_SetRange_Cmd []
 
const registercommandlist_t cFxlc95000ConfigMBox []
 
const registercommandlist_t cFxlc95000ConfigSensor []
 
const registercommandlist_t cFxlc95000FlashPreprocess []
 
const registercommandlist_t cFxlc95000FlashPostprocess []
 
const registerreadlist_t cFxlc95000ReadSample []
 
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 bFxlc95000DataReady = false
 
volatile bool bFxlc95000Ready = false
 
volatile bool bFxlc95000Boot = false
 
volatile bool bFxlc95000Flashing = false
 
fxlc95000_i2c_sensorhandle_t fxlc95000Driver
 
uint8_t gStreamID
 
GENERIC_DRIVER_GPIOpGpioDriver = &Driver_GPIO_KSDK
 

Detailed Description

The fxlc95000_flash_demo.c file implements the ISSDK FXLC95000L sensor driver example demonstration for FLASH programming and Streaming for I2C Mode using Host I/O.

Definition in file fxlc95000_flash_demo.c.

Macro Definition Documentation

◆ APPLICATION_NAME

#define APPLICATION_NAME   "FXLC95000 Accelerometer Demo"

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

Definition at line 73 of file fxlc95000_flash_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 75 of file fxlc95000_flash_demo.c.

Referenced by main().

◆ fxlc95000_odrCallback

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

Definition at line 68 of file fxlc95000_flash_demo.c.

◆ FXLC95000_SAMPLE_SIZE

#define FXLC95000_SAMPLE_SIZE   10 /* 4-Byte timestamp and 2-Byte X,Y,Z Data each. */

Definition at line 70 of file fxlc95000_flash_demo.c.

Referenced by main().

◆ SAMPLING_RATE_ms

#define SAMPLING_RATE_ms   100 /* Timeout for the ODR Timer in ms. */

Definition at line 69 of file fxlc95000_flash_demo.c.

Referenced by main().

Function Documentation

◆ fxlc95000_enSensor()

int fxlc95000_enSensor ( fxlc95000_i2c_sensorhandle_t pSensorHandle)

Initialize the FXLC95000 sensor driver.

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

Configure the FXLC95000 with MBox settings.

Configure the FXLC95000 with Sampling settings.

Definition at line 144 of file fxlc95000_flash_demo.c.

References bFxlc95000Boot, GENERIC_DRIVER_GPIO::clr_pin, FXLC95000_BUILD_ID, FXLC95000_I2C_ADDR, FXLC95000_I2C_CommandResponse(), FXLC95000_I2C_Initialize(), FXLC95000_I2C_SetIdleTask(), GREEN_LED, I2C_S_DEVICE_INDEX, I2C_S_DRIVER, int32_t(), RED_LED, SENSOR_ERROR_NONE, GENERIC_DRIVER_GPIO::set_pin, SMC, SMC_SetPowerModeWait(), and status.

Referenced by process_host_command().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fxlc95000_odrCallback()

void fxlc95000_odrCallback ( void  )

Definition at line 137 of file fxlc95000_flash_demo.c.

References bFxlc95000DataReady.

◆ main()

int main ( void  )

Main function.

Initialize the MCU hardware.

Initialize RED LED 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.

Register with Host I/O Service and get 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 FXLC95000.

Definition at line 336 of file fxlc95000_flash_demo.c.

References ADS_MAX_STRING_LENGTH, APPLICATION_NAME, APPLICATION_VERSION, bFxlc95000DataReady, BOARD_BootClockRUN, BOARD_DEBUG_UART_BAUDRATE, BOARD_RunADS(), BOARD_SystickEnable(), boardString, bStreamingEnabled, GENERIC_DRIVER_GPIO::clr_pin, fxlc95000_i2c_sensorhandle_t::deviceInfo, embAppName, FXLC95000_I2C_ADDR, FXLC95000_I2C_CommandResponse(), FXLC95000_SAMPLE_SIZE, GPIO_DIRECTION_OUT, GREEN_LED, gStreamID, 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_DRIVER, I2C_S_SIGNAL_EVENT, int32_t(), GENERIC_DRIVER_GPIO::pin_init, process_host_command(), RED_LED, SAMPLING_RATE_ms, GENERIC_DRIVER_GPIO::set_pin, SHIELD_NAME, shieldString, SMC, SMC_SetPowerModeWait(), status, STREAMING_HEADER_LEN, streamingPacket, and GENERIC_DRIVER_GPIO::toggle_pin.

Here is the call 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

◆ bFxlc95000Boot

volatile bool bFxlc95000Boot = false

Definition at line 126 of file fxlc95000_flash_demo.c.

Referenced by fxlc95000_enSensor(), and process_host_command().

◆ bFxlc95000DataReady

volatile bool bFxlc95000DataReady = false

Definition at line 126 of file fxlc95000_flash_demo.c.

Referenced by fxlc95000_odrCallback(), and main().

◆ bFxlc95000Flashing

volatile bool bFxlc95000Flashing = false

Definition at line 127 of file fxlc95000_flash_demo.c.

Referenced by process_host_command().

◆ bFxlc95000Ready

volatile bool bFxlc95000Ready = false

Definition at line 126 of file fxlc95000_flash_demo.c.

◆ boardString

char boardString[ADS_MAX_STRING_LENGTH] = {0}

Definition at line 124 of file fxlc95000_flash_demo.c.

Referenced by main(), and process_host_command().

◆ bStreamingEnabled

volatile bool bStreamingEnabled = false

Definition at line 126 of file fxlc95000_flash_demo.c.

Referenced by main(), and process_host_command().

◆ cFxlc95000_SetODR_Cmd

const uint8_t cFxlc95000_SetODR_Cmd[]
Initial value:
#define FXLC95000_SET_ODR_CMD_HDR
The FXLC95000 Set Report Rate Command Header Bytes.
Definition: fxlc95000.h:43
#define FXLC95000_SST_ODR_PAYLOAD(x)
The FXLC95000 Set Report Rate Payload Bytes.
Definition: fxlc95000.h:52
#define SAMPLING_RATE_ms

Create commands for setting FXLC95000L desired configuration.

Definition at line 81 of file fxlc95000_flash_demo.c.

◆ cFxlc95000_SetRange_Cmd

const uint8_t cFxlc95000_SetRange_Cmd[]
Initial value:
#define FXLC95000_ACCEL_RANGE_2G
The FXLC95000 FS Range 2G.
Definition: fxlc95000.h:55
#define FXLC95000_SET_RANGE_CMD_HDR
The FXLC95000 Set Range Command Header Bytes.
Definition: fxlc95000.h:49

Definition at line 85 of file fxlc95000_flash_demo.c.

◆ cFxlc95000_SetResolution_Cmd

const uint8_t cFxlc95000_SetResolution_Cmd[]
Initial value:
#define FXLC95000_SET_RESOLUTION_CMD_HDR
The FXLC95000 Set Resolution Command Header Bytes.
Definition: fxlc95000.h:46
#define FXLC95000_ACCEL_RESOLUTION_14_BIT
The FXLC95000 Resoultion 14-Bit.
Definition: fxlc95000.h:70

Definition at line 83 of file fxlc95000_flash_demo.c.

◆ cFxlc95000ConfigMBox

const registercommandlist_t cFxlc95000ConfigMBox[]
Initial value:
= {
{QuickReadInterruptDisable, 0, sizeof(QuickReadInterruptDisable)},
{ConfigureMBoxCmd, 0, sizeof(ConfigureMBoxCmd)},
}
#define __END_WRITE_CMD__
Definition: sensor_drv.h:83

Prepare the register write list to initialize FXLC95000L with desired MBox Settings.

Definition at line 89 of file fxlc95000_flash_demo.c.

◆ cFxlc95000ConfigSensor

const registercommandlist_t cFxlc95000ConfigSensor[]
Initial value:
= {
{StopDataCmd, 0, sizeof(StopDataCmd)},
{StartDataCmd, 0, sizeof(StartDataCmd)},
const uint8_t cFxlc95000_SetResolution_Cmd[]
const uint8_t cFxlc95000_SetRange_Cmd[]
const uint8_t cFxlc95000_SetODR_Cmd[]
#define __END_WRITE_CMD__
Definition: sensor_drv.h:83

Prepare the register write list to configure FXLC95000L with desired Sampling Settings.

Definition at line 96 of file fxlc95000_flash_demo.c.

◆ cFxlc95000FlashPostprocess

const registercommandlist_t cFxlc95000FlashPostprocess[]
Initial value:
= {
{ProtectFlash, 0, sizeof(ProtectFlash)},
}
#define __END_WRITE_CMD__
Definition: sensor_drv.h:83

Prepare the register write list with Flash Postprocess Commands.

Definition at line 112 of file fxlc95000_flash_demo.c.

◆ cFxlc95000FlashPreprocess

const registercommandlist_t cFxlc95000FlashPreprocess[]
Initial value:
= {
{UnprotectFlash, 0, sizeof(UnprotectFlash)},
{EraseMainFlashArray, 0, sizeof(EraseMainFlashArray)},
}
#define __END_WRITE_CMD__
Definition: sensor_drv.h:83

Prepare the register write list with Flash Preprocess Commands.

Definition at line 105 of file fxlc95000_flash_demo.c.

◆ cFxlc95000ReadSample

const registerreadlist_t cFxlc95000ReadSample[]
Initial value:
= {
#define __END_READ_DATA__
Definition: sensor_drv.h:77
#define FXLC95000_SAMPLE_OFFSET
Time stamp and XYZ Data Register Offset.
Definition: fxlc95000.h:16
#define FXLC95000_SAMPLE_SIZE

Prepare the register read list to read the Timestamp and Accel data from FXLC95000.

Definition at line 118 of file fxlc95000_flash_demo.c.

◆ embAppName

char embAppName[ADS_MAX_STRING_LENGTH] = {0}

Definition at line 125 of file fxlc95000_flash_demo.c.

Referenced by main(), and process_host_command().

◆ fxlc95000Driver

Initial value:
=
{.deviceInfo = {.deviceInstance = I2C_S_DEVICE_INDEX, .idleFunction = NULL}}
#define I2C_S_DEVICE_INDEX
Definition: issdk_hal.h:61

Definition at line 128 of file fxlc95000_flash_demo.c.

Referenced by main().

◆ gStreamID

uint8_t gStreamID

Definition at line 130 of file fxlc95000_flash_demo.c.

Referenced by main(), and process_host_command().

◆ pGpioDriver

Definition at line 131 of file fxlc95000_flash_demo.c.

◆ shieldString

char shieldString[ADS_MAX_STRING_LENGTH] = {0}

Definition at line 124 of file fxlc95000_flash_demo.c.

Referenced by main(), and process_host_command().