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

The mag3110_poll_demo.c file implements the ISSDK MAG3110 sensor demo example demonstration with poll 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 "mag3110_drv.h"
#include "host_io_uart.h"
#include "systick_utils.h"
#include "auto_detection_service.h"
Include dependency graph for mag3110_poll_demo.c:

Go to the source code of this file.

Data Structures

struct  mag3110_magdataUser_t
 This structure defines the mag3110 data buffer. More...
 

Macros

#define MAG3110_DATA_SIZE   6 /* 2 byte X,Y,Z Axis Data each. */
 
#define MAG3110_STREAM_DATA_SIZE   12 /* 6 byte Data */
 
#define APPLICATION_NAME   "MAG3110 Magnetometer 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

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 cMag3110ConfigNormal []
 Register settings for Normal (non buffered) mode. More...
 
const registerreadlist_t cMag3110Status [] = {{.readFrom = MAG3110_DR_STATUS, .numBytes = 1}, __END_READ_DATA__}
 Address of Status Register. More...
 
const registerreadlist_t cMag3110OutputNormal []
 Address and size of Raw Pressure+Temperature Data in Normal Mode. More...
 
const registerreadlist_t cMag3110TempOut []
 Address and size of Temperature Data in Normal Mode. 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 bMag3110Ready = false
 
uint8_t gStreamID
 
int32_t gSystick
 
GENERIC_DRIVER_GPIOpGpioDriver = &Driver_GPIO_KSDK
 

Detailed Description

The mag3110_poll_demo.c file implements the ISSDK MAG3110 sensor demo example demonstration with poll mode.

Definition in file mag3110_poll_demo.c.

Macro Definition Documentation

◆ APPLICATION_NAME

#define APPLICATION_NAME   "MAG3110 Magnetometer Demo"

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

Definition at line 45 of file mag3110_poll_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 47 of file mag3110_poll_demo.c.

Referenced by main().

◆ MAG3110_DATA_SIZE

#define MAG3110_DATA_SIZE   6 /* 2 byte X,Y,Z Axis Data each. */

Definition at line 41 of file mag3110_poll_demo.c.

Referenced by main().

◆ MAG3110_STREAM_DATA_SIZE

#define MAG3110_STREAM_DATA_SIZE   12 /* 6 byte Data */

Definition at line 42 of file mag3110_poll_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.

Initialize the MAG3110 sensor driver.

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

Configure the MAG3110 sensor driver.

Initialize streaming and assign a Stream ID.

Populate streaming header.

Wait for data ready from the MAG3110.

Read raw sensor data from the MAG3110.

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

Read TEMP_SRC 0x0F from MAG3110.

Definition at line 177 of file mag3110_poll_demo.c.

References ADS_MAX_STRING_LENGTH, APPLICATION_NAME, APPLICATION_VERSION, bMag3110Ready, BOARD_BootClockRUN, BOARD_DEBUG_UART_BAUDRATE, BOARD_RunADS(), BOARD_SystickElapsedTime_us(), BOARD_SystickEnable(), boardString, bStreamingEnabled, GENERIC_DRIVER_GPIO::clr_pin, data, mag3110_i2c_sensorhandle_t::deviceInfo, embAppName, 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(), mag3110_magdataUser_t::mag, MAG3110_CalibrateHardIronOffset(), MAG3110_DATA_SIZE, MAG3110_DR_STATUS_ZYXDR_MASK, MAG3110_I2C_ADDR, MAG3110_I2C_Configure(), MAG3110_I2C_Initialize(), MAG3110_I2C_ReadData(), MAG3110_I2C_SetIdleTask(), MAG3110_STREAM_DATA_SIZE, MAG3110_WHOAMI_VALUE, mag3110_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, mag3110_magdataUser_t::temp, mag3110_magdataUser_t::timestamp, fxos8700_accelmagdata_t::timestamp, 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

◆ bMag3110Ready

volatile bool bMag3110Ready = false

Definition at line 85 of file mag3110_poll_demo.c.

Referenced by main(), and process_host_command().

◆ boardString

char boardString[ADS_MAX_STRING_LENGTH] = {0}

Definition at line 83 of file mag3110_poll_demo.c.

Referenced by main(), and process_host_command().

◆ bStreamingEnabled

volatile bool bStreamingEnabled = false

Definition at line 85 of file mag3110_poll_demo.c.

Referenced by main(), and process_host_command().

◆ cMag3110ConfigNormal

const registerwritelist_t cMag3110ConfigNormal[]
Initial value:
= {
#define MAG3110_CTRL_REG1_DR_ODR_2
Definition: mag3110.h:423
#define MAG3110_CTRL_REG2_MAG_RST_EN
Definition: mag3110.h:471
#define MAG3110_CTRL_REG2_MAG_RST_MASK
Definition: mag3110.h:458
#define __END_WRITE_DATA__
Definition: sensor_drv.h:45
#define MAG3110_CTRL_REG1_DR_MASK
Definition: mag3110.h:404
#define MAG3110_CTRL_REG1_OS_MASK
Definition: mag3110.h:401
#define MAG3110_CTRL_REG2_AUTO_MSRT_EN_MASK
Definition: mag3110.h:464
#define MAG3110_CTRL_REG2_RAW_RAW
Definition: mag3110.h:474
#define MAG3110_CTRL_REG2_AUTO_MSRT_EN_EN
Definition: mag3110.h:477
#define MAG3110_CTRL_REG1_OS_OSR_32
Definition: mag3110.h:418
#define MAG3110_CTRL_REG2_RAW_MASK
Definition: mag3110.h:461

Register settings for Normal (non buffered) mode.

Definition at line 61 of file mag3110_poll_demo.c.

◆ cMag3110OutputNormal

const registerreadlist_t cMag3110OutputNormal[]
Initial value:
= {{.readFrom = MAG3110_OUT_X_MSB, .numBytes = MAG3110_DATA_SIZE},
#define __END_READ_DATA__
Definition: sensor_drv.h:51
#define MAG3110_DATA_SIZE

Address and size of Raw Pressure+Temperature Data in Normal Mode.

Definition at line 74 of file mag3110_poll_demo.c.

◆ cMag3110Status

const registerreadlist_t cMag3110Status[] = {{.readFrom = MAG3110_DR_STATUS, .numBytes = 1}, __END_READ_DATA__}

Address of Status Register.

Definition at line 71 of file mag3110_poll_demo.c.

◆ cMag3110TempOut

const registerreadlist_t cMag3110TempOut[]
Initial value:
= {{.readFrom = MAG3110_DIE_TEMP, .numBytes = 1},
#define __END_READ_DATA__
Definition: sensor_drv.h:51

Address and size of Temperature Data in Normal Mode.

Definition at line 77 of file mag3110_poll_demo.c.

◆ embAppName

char embAppName[ADS_MAX_STRING_LENGTH] = {0}

Definition at line 84 of file mag3110_poll_demo.c.

Referenced by main(), and process_host_command().

◆ gStreamID

uint8_t gStreamID

Definition at line 86 of file mag3110_poll_demo.c.

Referenced by main(), and process_host_command().

◆ gSystick

int32_t gSystick

Definition at line 87 of file mag3110_poll_demo.c.

Referenced by main(), and process_host_command().

◆ pGpioDriver

Definition at line 88 of file mag3110_poll_demo.c.

◆ shieldString

char shieldString[ADS_MAX_STRING_LENGTH] = {0}

Definition at line 83 of file mag3110_poll_demo.c.

Referenced by main(), and process_host_command().