20 #include "clock_config.h" 25 #include "Driver_I2C.h" 26 #include "Driver_USART.h" 31 #include "issdk_hal.h" 32 #include "gpio_driver.h" 33 #include "diff_p_drv.h" 36 #include "auto_detection_service.h" 41 #define DIFF_P_DATA_SIZE (3) 42 #define DIFF_P_STREAM_DATA_SIZE (7) 45 #define APPLICATION_NAME "NPS300x Differential Pressure Demo" 47 #define APPLICATION_VERSION "2.5" 54 {DIFF_P_CTRL_REG2, DIFF_P_CTRL_REG2_ODR_ODR6P25, DIFF_P_CTRL_REG2_ODR_MASK},
55 {DIFF_P_CTRL_REG1, DIFF_P_CTRL_REG1_OSR_OSR512, DIFF_P_CTRL_REG1_OSR_MASK},
56 {DIFF_P_INT_MASK0, DIFF_P_INT_MASK0_TDR_INT_EN | DIFF_P_INT_MASK0_PDR_INT_EN,
57 DIFF_P_INT_MASK0_TDR_MASK | DIFF_P_INT_MASK0_PDR_MASK},
58 {DIFF_P_CTRL_REG3, DIFF_P_CTRL_REG3_IPOL1_ACTIVE_HIGH, DIFF_P_CTRL_REG3_IPOL1_MASK},
63 {DIFF_P_INT_STATUS_0, 0x00, DIFF_P_INT_STATUS_0_TDR_MASK | DIFF_P_INT_STATUS_0_PDR_MASK},
__END_WRITE_DATA__};
93 uint8_t tag, uint8_t *hostCommand, uint8_t *hostResponse,
size_t *hostMsgSize,
size_t respBufferSize)
110 if (respBufferSize >= boardNameLen + shieldNameLen + appNameLen + 3)
119 hostResponse[*hostMsgSize] = appNameLen;
122 memcpy(hostResponse + *hostMsgSize,
embAppName, appNameLen);
123 *hostMsgSize += appNameLen;
125 hostResponse[*hostMsgSize] = boardNameLen;
128 memcpy(hostResponse + *hostMsgSize,
boardString, boardNameLen);
129 *hostMsgSize += boardNameLen;
131 hostResponse[*hostMsgSize] = shieldNameLen;
134 memcpy(hostResponse + *hostMsgSize,
shieldString, shieldNameLen);
135 *hostMsgSize += shieldNameLen;
145 switch (hostCommand[0])
180 diff_p_i2c_sensorhandle_t diffpDriver;
207 if (ARM_DRIVER_OK != status)
213 status = pI2cDriver->PowerControl(ARM_POWER_FULL);
214 if (ARM_DRIVER_OK != status)
220 status = pI2cDriver->Control(ARM_I2C_BUS_SPEED, ARM_I2C_BUS_SPEED_FAST);
221 if (ARM_DRIVER_OK != status)
228 if (ARM_DRIVER_OK != status)
234 status = pUartDriver->PowerControl(ARM_POWER_FULL);
235 if (ARM_DRIVER_OK != status)
242 if (ARM_DRIVER_OK != status)
250 DIFF_P_NPS3000VV_WHOAMI_VALUE);
257 DIFF_P_NPS3001DV_WHOAMI_VALUE);
264 DIFF_P_NPS3002VV_WHOAMI_VALUE);
271 DIFF_P_NPS3005DV_WHOAMI_VALUE);
281 status = DIFF_P_I2C_Configure(&diffpDriver, cDiffPConfigNormal);
322 status = DIFF_P_I2C_ReadData(&diffpDriver, cDiffPStatus, &dataReady);
323 if (ARM_DRIVER_OK != status)
329 if ((DIFF_P_INT_STATUS_0_PDR_DRDY | DIFF_P_INT_STATUS_0_TDR_DRDY) !=
330 (dataReady & (DIFF_P_INT_STATUS_0_PDR_MASK | DIFF_P_INT_STATUS_0_TDR_MASK)))
336 status =
Sensor_I2C_Write(diffpDriver.pCommDrv, &diffpDriver.deviceInfo, diffpDriver.slaveAddress,
337 cDiffPClearStatusBits);
338 if (ARM_DRIVER_OK != status)
345 status = DIFF_P_I2C_ReadData(&diffpDriver, cDiffPOutputNormal, data);
346 if (ARM_DRIVER_OK != status)
355 rawData.pressure = ((int16_t)(data[1]) << 8) | data[0];
356 rawData.temperature = (int8_t)(data[2]);
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)
char embAppName[ADS_MAX_STRING_LENGTH]
This structure defines the Write command List.
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...
char boardString[ADS_MAX_STRING_LENGTH]
#define HOST_PRO_CMD_W_CFG_TAG
Access structure of the GPIO Driver.
#define APPLICATION_NAME
Unique Name for this application which should match the target GUI pkg name.
#define __END_WRITE_DATA__
volatile bool bDiffPReady
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
const registerwritelist_t cDiffPConfigNormal[]
Register settings for Normal (non buffered) mode.
#define DIFF_P_STREAM_DATA_SIZE
#define I2C_S_SIGNAL_EVENT
volatile bool bStreamingEnabled
void diffp_int_data_ready_callback(void *pUserData)
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 BOARD_BootClockRUN
uint8_t streamingPacket[STREAMING_HEADER_LEN+FXLS8962_STREAM_DATA_SIZE]
GENERIC_DRIVER_GPIO Driver_GPIO_KSDK
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.
const registerwritelist_t cDiffPClearStatusBits[]
Register settings for Clearing Pressure and Temperature Data Ready Bits.
uint32_t BOARD_SystickElapsedTime_us(int32_t *pStart)
Function to compute the Elapsed Time.
uint8_t data[FXLS8962_DATA_SIZE]
#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.
fxos8700_accelmagdata_t rawData
int main(void)
Main function.
void(* toggle_pin)(pinID_t aPinId)
#define ADS_MAX_STRING_LENGTH
volatile bool bDiffPDataReady
char shieldString[ADS_MAX_STRING_LENGTH]
GENERIC_DRIVER_GPIO * pGpioDriver
const registerreadlist_t cDiffPOutputNormal[]
Address and size of Raw Pressure+Temperature Data in Normal Mode.
void BOARD_SystickEnable(void)
Function to enable systicks framework.
#define STREAMING_HEADER_LEN
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)
This structure defines the Read command List.
bool process_host_command(uint8_t tag, uint8_t *hostCommand, uint8_t *hostResponse, size_t *hostMsgSize, size_t respBufferSize)
gpioHandleKSDK_t GREEN_LED
#define I2C_S_DEVICE_INDEX
#define HOST_PRO_INT_CMD_TAG
Bit aligned values for Host Protocol Interface IDs (Bits 5-6).
const registerreadlist_t cDiffPStatus[]
Address of Status Register.