19 #include "clock_config.h" 24 #include "Driver_I2C.h" 25 #include "Driver_USART.h" 30 #include "issdk_hal.h" 31 #include "gpio_driver.h" 35 #include "auto_detection_service.h" 40 #define MPL3115_DATA_SIZE 5 41 #define MPL3115_STREAM_DATA_SIZE 10 42 #define LED_TOGGLE_RATE 100 45 #define APPLICATION_NAME "MPL3115A2" 47 #define APPLICATION_VERSION "1.1" 99 uint8_t tag, uint8_t *hostCommand, uint8_t *hostResponse,
size_t *hostMsgSize,
size_t respBufferSize)
101 bool success =
false;
116 if (respBufferSize >= boardNameLen + shieldNameLen + appNameLen + 3)
125 hostResponse[*hostMsgSize] = appNameLen;
128 memcpy(hostResponse + *hostMsgSize,
embAppName, appNameLen);
129 *hostMsgSize += appNameLen;
131 hostResponse[*hostMsgSize] = boardNameLen;
134 memcpy(hostResponse + *hostMsgSize,
boardString, boardNameLen);
135 *hostMsgSize += boardNameLen;
137 hostResponse[*hostMsgSize] = shieldNameLen;
140 memcpy(hostResponse + *hostMsgSize,
shieldString, shieldNameLen);
141 *hostMsgSize += shieldNameLen;
151 switch (hostCommand[0])
183 uint8_t toggle_led = 0;
213 if (ARM_DRIVER_OK != status)
219 status = pI2cDriver->PowerControl(ARM_POWER_FULL);
220 if (ARM_DRIVER_OK != status)
226 status = pI2cDriver->Control(ARM_I2C_BUS_SPEED, ARM_I2C_BUS_SPEED_FAST);
227 if (ARM_DRIVER_OK != status)
234 if (ARM_DRIVER_OK != status)
240 status = pUartDriver->PowerControl(ARM_POWER_FULL);
241 if (ARM_DRIVER_OK != status)
248 if (ARM_DRIVER_OK != status)
265 if (ARM_DRIVER_OK == status)
306 if (ARM_DRIVER_OK != status)
313 if (ARM_DRIVER_OK != status)
322 rawData.
pressure = (uint32_t)((data[0]) << 16) | ((data[1]) << 8) | ((data[2]));
323 rawData.
temperature = (int16_t)((data[3]) << 8) | (data[4]);
uint8_t Host_IO_Init(ARM_DRIVER_USART *pDrv, void *pBus, void *pDevInfo, void *spiSlaveParams, uint16_t slaveAddress)
void Host_IO_Receive(host_cmd_proc_fn_t process_host_command, uint8_t encoding)
This structure defines the Write command List.
volatile bool bMpl3115Ready
void MPL3115_I2C_SetIdleTask(mpl3115_i2c_sensorhandle_t *pSensorHandle, registeridlefunction_t idleTask, void *userParam)
: The interface function to set the I2C Idle Task.
const registerreadlist_t cMpl3115OutputNormal[]
Address and size of Raw Pressure+Temperature Data in Normal Mode.
status_t SMC_SetPowerModeVlpr(void *arg)
Configures the system to VLPR power mode. API name used from Kinetis family to maintain compatibility...
The host_io_uart.h file contains the Host Protocol interface definitions and configuration.
#define APPLICATION_VERSION
Version to distinguish between instances the same application based on target Shield and updates...
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 HOST_PRO_CMD_W_CFG_TAG
Access structure of the GPIO Driver.
void mpl3115_int_data_ready_callback(void *pUserData)
#define __END_WRITE_DATA__
#define MPL3115_PT_DATA_CFG_TDEFE_MASK
void(* clr_pin)(pinID_t aPinId)
typedef int32_t(DATA_FORMAT_Append_t))(void *pData
The interface function to append the data on the formated stream.
#define HOST_S_SIGNAL_EVENT
bool process_host_command(uint8_t tag, uint8_t *hostCommand, uint8_t *hostResponse, size_t *hostMsgSize, size_t respBufferSize)
int main(void)
Main function.
#define I2C_S_SIGNAL_EVENT
#define MPL3115_CTRL_REG4_INT_EN_DRDY_MASK
void Host_IO_Add_ISO_Header(uint8_t streamID, uint8_t *pStreamingPacket, size_t sizePayload)
#define BOARD_DEBUG_UART_BAUDRATE
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 MPL3115_CTRL_REG5_INT_CFG_DRDY_MASK
#define BOARD_BootClockRUN
void(* registeridlefunction_t)(void *userParam)
This is the register idle function type.
#define MPL3115_CTRL_REG3_IPOL1_HIGH
uint8_t streamingPacket[STREAMING_HEADER_LEN+FXLS8962_STREAM_DATA_SIZE]
GENERIC_DRIVER_GPIO Driver_GPIO_KSDK
GENERIC_DRIVER_GPIO * pGpioDriver
#define MPL3115_CTRL_REG4_INT_EN_DRDY_INTENABLED
void Host_IO_Send(uint8_t *pMsg, size_t size, uint8_t encoding)
void BOARD_SystickStart(int32_t *pStart)
Function to Record the Start systick.
This structure defines the mpl3115 data buffer in Pressure Mode.
const registerwritelist_t cMpl3115SetOST[]
Register settings for Triggring One-Shot Sampling.
uint32_t BOARD_SystickElapsedTime_us(int32_t *pStart)
Function to compute the Elapsed Time.
#define MPL3115_CTRL_REG3_IPOL1_MASK
#define MPL3115_PT_DATA_CFG_DREM_ENABLED
uint8_t data[FXLS8962_DATA_SIZE]
#define MPL3115_PT_DATA_CFG_PDEFE_MASK
#define __END_READ_DATA__
#define HOST_PRO_INT_DEV_TAG
void BOARD_RunADS(const char *appName, char *boardString, char *shieldString, size_t bufferLength)
The function to register Application Name and initialte ADS.
#define MPL3115_CTRL_REG1_OST_MASK
const registerwritelist_t cMpl3115ConfigINT[]
Register settings for Interrupt (non buffered) Enablement with ONe-Shot Mode.
This defines the sensor specific information.
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 APPLICATION_NAME
Unique Name for this application which should match the target GUI pkg name.
void(* toggle_pin)(pinID_t aPinId)
#define ADS_MAX_STRING_LENGTH
#define MPL3115_CTRL_REG5_INT_CFG_DRDY_INT1
volatile bool bStreamingEnabled
#define MPL3115_PT_DATA_CFG_DREM_MASK
#define MPL3115_PT_DATA_CFG_PDEFE_ENABLED
void BOARD_SystickEnable(void)
Function to enable systicks framework.
#define MPL3115_WHOAMI_VALUE
#define STREAMING_HEADER_LEN
volatile bool bMpl3115DataReady
status_t SMC_SetPowerModeWait(void *arg)
Configures the system to WAIT power mode. API name used from Kinetis family to maintain compatibility...
void(* pin_init)(pinID_t aPinId, gpio_direction_t dir, void *apPinConfig, gpio_isr_handler_t aIsrHandler, void *apUserData)
ARM_DRIVER_I2C * pCommDrv
This structure defines the Read command List.
#define MPL3115_DATA_SIZE
gpioHandleKSDK_t GREEN_LED
#define MPL3115_PT_DATA_CFG_TDEFE_ENABLED
#define MPL3115_CTRL_REG1_OST_SET
#define MPL3115_CTRL_REG1_OS_OSR_2
#define I2C_S_DEVICE_INDEX
#define MPL3115_STREAM_DATA_SIZE
char boardString[ADS_MAX_STRING_LENGTH]
#define HOST_PRO_INT_CMD_TAG
Bit aligned values for Host Protocol Interface IDs (Bits 5-6).
char shieldString[ADS_MAX_STRING_LENGTH]
registerDeviceInfo_t deviceInfo
#define MPL3115_CTRL_REG1_OS_MASK
char embAppName[ADS_MAX_STRING_LENGTH]