19 #include "clock_config.h" 21 #include "fsl_debug_console.h" 26 #include "Driver_I2C.h" 29 #include "issdk_hal.h" 35 #define MPL3115_DATA_SIZE (5) 67 int16_t tempInDegrees;
82 PRINTF(
"\r\n ISSDK MPL3115 sensor driver example demonstration with oneshot mode\r\n");
86 if (ARM_DRIVER_OK != status)
88 PRINTF(
"\r\n I2C Initialization Failed\r\n");
93 status = I2Cdrv->PowerControl(ARM_POWER_FULL);
94 if (ARM_DRIVER_OK != status)
96 PRINTF(
"\r\n I2C Power Mode setting Failed\r\n");
101 status = I2Cdrv->Control(ARM_I2C_BUS_SPEED, ARM_I2C_BUS_SPEED_FAST);
102 if (ARM_DRIVER_OK != status)
104 PRINTF(
"\r\n I2C Control Mode setting Failed\r\n");
113 PRINTF(
"\r\n Sensor Initialization Failed\r\n");
116 PRINTF(
"\r\n Successfully Initiliazed Sensor\r\n");
124 if (ARM_DRIVER_OK != status)
126 PRINTF(
"\r\nWrite Failed.\r\n");
129 PRINTF(
"\r\nMPL3115 will now trigger acquisition of one sample and then read the data...\r\n");
135 if (ARM_DRIVER_OK != status)
137 PRINTF(
"\r\nWrite Failed.\r\n");
144 if (ARM_DRIVER_OK != status)
146 PRINTF(
"\r\nRead Failed.\r\n");
154 if (ARM_DRIVER_OK != status)
156 PRINTF(
"\r\n Read Failed. \r\n");
161 rawData.
altitude = (
int32_t)((data[0]) << 24) | ((data[1]) << 16) | ((data[2]) << 8);
162 rawData.
temperature = (int16_t)((data[3]) << 8) | (data[4]);
166 PRINTF(
"\r\nAltitude = %d Meters\r\n", altitudeInMeters);
167 PRINTF(
"\r\nTemperature = %d degC\r\n", tempInDegrees);
int main(void)
Main function.
This structure defines the device specific info required by register I/O.
This structure defines the Write command List.
#define ASK_USER_TO_RESUME(x)
This structure defines the mpl3115 data buffer in Altitude Mode.
const registerwritelist_t cMpl3115ConfigAltitude[]
Register settings for Altitude readings in One-Shot mode.
const registerreadlist_t cMpl3115GetOST[]
Address of Register containing OST Bit.
int32_t MPL3115_I2C_ReadData(mpl3115_i2c_sensorhandle_t *pSensorHandle, const registerreadlist_t *pReadList, uint8_t *pBuffer)
The interface function to read the sensor data.
The mpl3115_drv.h file describes the MPL3115 driver interface and structures.
#define __END_WRITE_DATA__
typedef int32_t(DATA_FORMAT_Append_t))(void *pData
The interface function to append the data on the formated stream.
#define I2C_S_SIGNAL_EVENT
int32_t Sensor_I2C_Write(ARM_DRIVER_I2C *pCommDrv, registerDeviceInfo_t *devInfo, uint16_t slaveAddress, const registerwritelist_t *pRegWriteList)
Write register data to a sensor.
#define BOARD_BootClockRUN
#define MPL3115_TEMPERATURE_CONV_FACTOR
void(* registeridlefunction_t)(void *userParam)
This is the register idle function type.
const registerwritelist_t cMpl3115SetOST[]
Register settings for Triggring One-Shot Sampling.
const registerreadlist_t cMpl3115OutputNormal[]
Address and size of Raw Altitude+Temperature Data.
uint8_t data[FXLS8962_DATA_SIZE]
#define __END_READ_DATA__
#define MPL3115_CTRL_REG1_OST_MASK
#define MPL3115_DATA_SIZE
This defines the sensor specific information.
#define MPL3115_CTRL_REG1_ALT_MASK
fxos8700_accelmagdata_t rawData
int32_t MPL3115_I2C_Initialize(mpl3115_i2c_sensorhandle_t *pSensorHandle, ARM_DRIVER_I2C *pBus, uint8_t index, uint16_t sAddress, uint8_t whoAmi)
The interface function to initialize the sensor.
#define MPL3115_WHOAMI_VALUE
status_t SMC_SetPowerModeWait(void *arg)
Configures the system to WAIT power mode. API name used from Kinetis family to maintain compatibility...
ARM_DRIVER_I2C * pCommDrv
This structure defines the Read command List.
#define MPL3115_CTRL_REG1_OST_SET
#define I2C_S_DEVICE_INDEX
void BOARD_InitDebugConsole(void)
void BOARD_InitPins(void)
Configures pin routing and optionally pin electrical features.
registeridlefunction_t idleFunction
#define MPL3115_CTRL_REG1_ALT_ALT
#define MPL3115_ALTITUDE_CONV_FACTOR