18 #include "clock_config.h" 20 #include "fsl_debug_console.h" 21 #include "fsl_irqsteer.h" 24 #include "Driver_I2C.h" 27 #include "issdk_hal.h" 33 #define MPL3115_DATA_SIZE (5) 37 #define MPL3115_SAMPLING_EXPONENT (1) 70 int16_t tempInDegrees;
83 ipc = BOARD_InitRpc();
90 PRINTF(
"\r\n ---------------------------------------------------------------\r\n");
91 PRINTF(
"\r\n ISSDK MPL3115 sensor driver example demonstration with ALT mode\r\n");
92 PRINTF(
"\r\n ---------------------------------------------------------------\r\n");
95 if (sc_pm_set_resource_power_mode(ipc, SC_R_I2C_0, SC_PM_PW_MODE_ON) != SC_ERR_NONE)
97 PRINTF(
"Error: Failed to power on LPI2C\r\n");
101 freq = CLOCK_SetIpFreq(kCLOCK_DMA_Lpi2c0, SC_24MHZ);
104 PRINTF(
"Error: Failed to set LPI2C frequency\r\n");
108 #if (MIMX8QM_CM4_CORE0) 109 if (sc_pm_set_resource_power_mode(ipc, SC_R_IRQSTR_M4_0, SC_PM_PW_MODE_ON) != SC_ERR_NONE)
111 PRINTF(
"Error: Failed to power on IRQSTEER M4_0\r\n");
113 #elif (MIMX8QM_CM4_CORE1) 114 if (sc_pm_set_resource_power_mode(ipc, SC_R_IRQSTR_M4_1, SC_PM_PW_MODE_ON) != SC_ERR_NONE)
116 PRINTF(
"Error: Failed to power on IRQSTEER M4_1\r\n");
121 IRQSTEER_Init(IRQSTEER);
122 IRQSTEER_EnableInterrupt(IRQSTEER, DMA_I2C0_INT_IRQn);
126 if (ARM_DRIVER_OK != status)
128 PRINTF(
"\r\n I2C Initialization Failed\r\n");
133 status = I2Cdrv->PowerControl(ARM_POWER_FULL);
134 if (ARM_DRIVER_OK != status)
136 PRINTF(
"\r\n I2C Power Mode setting Failed\r\n");
141 status = I2Cdrv->Control(ARM_I2C_BUS_SPEED, ARM_I2C_BUS_SPEED_FAST);
142 if (ARM_DRIVER_OK != status)
144 PRINTF(
"\r\n I2C Control Mode setting Failed\r\n");
153 PRINTF(
"\r\n Sensor Initialization Failed\r\n");
156 PRINTF(
"\r\n Successfully Initiliazed MPL3115 Sensor\r\n");
163 PRINTF(
"\r\nMPL3115 configuration failed...\r\n");
166 PRINTF(
"\r\n Successfully Applied MPL3115 Sensor Configuration\r\n");
168 PRINTF(
"\r\n Reading MPL3115 Altitude & Temperature Values\r\n");
181 if (ARM_DRIVER_OK != status)
183 PRINTF(
"\r\n Read Failed. \r\n");
188 rawData.
altitude = (
int32_t)((data[0]) << 24) | ((data[1]) << 16) | ((data[2]) << 8);
191 rawData.
temperature = (int16_t)((data[3]) << 8) | (data[4]);
194 PRINTF(
"\r\n Altitude = %d Meters", altitudeInMeters);
195 PRINTF(
"\t Temperature = %d degC\r\n", tempInDegrees);
This structure defines the Write command List.
#define ASK_USER_TO_RESUME(x)
const registerreadlist_t cMpl3115Status[]
Address of Status Register.
This structure defines the mpl3115 data buffer in Altitude Mode.
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 MPL3115_CTRL_REG2_ST_MASK
#define __END_WRITE_DATA__
#define MPL3115_PT_DATA_CFG_TDEFE_MASK
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
#define MPL3115_DR_STATUS_PTDR_MASK
#define BOARD_BootClockRUN
#define MPL3115_TEMPERATURE_CONV_FACTOR
#define MPL3115_SAMPLING_EXPONENT
const registerwritelist_t cMpl3115ConfigAltitude[]
Register settings for Altitude readings in Normal (non buffered) mode.
#define MPL3115_PT_DATA_CFG_DREM_ENABLED
uint8_t data[FXLS8962_DATA_SIZE]
#define MPL3115_PT_DATA_CFG_PDEFE_MASK
#define __END_READ_DATA__
const registerreadlist_t cMpl3115OutputNormal[]
Address and size of Raw Altitude+Temperature Data in Normal Mode.
This defines the sensor specific information.
#define MPL3115_CTRL_REG1_OS_OSR_128
#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_PT_DATA_CFG_DREM_MASK
#define MPL3115_PT_DATA_CFG_PDEFE_ENABLED
int main(void)
Main function.
#define MPL3115_WHOAMI_VALUE
This structure defines the Read command List.
#define MPL3115_PT_DATA_CFG_TDEFE_ENABLED
#define I2C_S_DEVICE_INDEX
void BOARD_InitDebugConsole(void)
#define MPL3115_DATA_SIZE
void BOARD_InitPins(void)
Configures pin routing and optionally pin electrical features.
int32_t MPL3115_I2C_Configure(mpl3115_i2c_sensorhandle_t *pSensorHandle, const registerwritelist_t *pRegWriteList)
The interface function to configure he sensor.
#define MPL3115_CTRL_REG1_OS_MASK
#define MPL3115_CTRL_REG1_ALT_ALT
#define MPL3115_ALTITUDE_CONV_FACTOR