20 #include "fsl_lptmr.h" 21 #include "fsl_adc12.h" 22 #include "clock_config.h" 27 #include "Driver_USART.h" 32 #include "issdk_hal.h" 33 #include "gpio_driver.h" 36 #include "auto_detection_service.h" 42 #define dp5004_odr_callback PWT_LPTMR0_IRQHandler 44 #define adc12_irq_callback ADC0_IRQHandler 47 #define MPXV5004DP_ODR_ms 100U 49 #define MPXV5004DP_STREAM_DATA_SIZE 6U 52 #define APPLICATION_NAME "Analog Pressure Sensor Demo (MPXV5004DP)" 54 #define APPLICATION_VERSION "2.5" 84 LPTMR_ClearStatusFlags(LPTMR0, kLPTMR_TimerCompareFlag);
99 lptmr_config_t lptmrConfig;
100 adc12_config_t adc12ConfigStruct;
103 LPTMR_GetDefaultConfig(&lptmrConfig);
104 LPTMR_Init(LPTMR0, &lptmrConfig);
105 LPTMR_SetTimerPeriod(LPTMR0, MSEC_TO_COUNT(
MPXV5004DP_ODR_ms, CLOCK_GetFreq(kCLOCK_LpoClk)));
106 LPTMR_EnableInterrupts(LPTMR0, kLPTMR_TimerInterruptEnable);
107 EnableIRQ(PWT_LPTMR0_IRQn);
111 CLOCK_SetIpSrc(kCLOCK_Adc0, kCLOCK_IpSrcSircAsync);
112 EnableIRQ(ADC0_IRQn);
113 ADC12_GetDefaultConfig(&adc12ConfigStruct);
114 adc12ConfigStruct.clockSource = kADC12_ClockSourceAlt0;
115 adc12ConfigStruct.resolution = kADC12_Resolution12Bit;
116 ADC12_Init(ADC0, &adc12ConfigStruct);
118 ADC12_EnableHardwareTrigger(ADC0,
false);
120 if (kStatus_Success == ADC12_DoAutoCalibration(ADC0))
131 uint8_t tag, uint8_t *hostCommand, uint8_t *hostResponse,
size_t *hostMsgSize,
size_t respBufferSize)
133 bool success =
false;
148 if (respBufferSize >= boardNameLen + shieldNameLen + appNameLen + 3)
157 hostResponse[*hostMsgSize] = appNameLen;
160 memcpy(hostResponse + *hostMsgSize,
embAppName, appNameLen);
161 *hostMsgSize += appNameLen;
163 hostResponse[*hostMsgSize] = boardNameLen;
166 memcpy(hostResponse + *hostMsgSize,
boardString, boardNameLen);
167 *hostMsgSize += boardNameLen;
169 hostResponse[*hostMsgSize] = shieldNameLen;
172 memcpy(hostResponse + *hostMsgSize,
shieldString, shieldNameLen);
173 *hostMsgSize += shieldNameLen;
183 switch (hostCommand[0])
190 LPTMR_StartTimer(LPTMR0);
199 LPTMR_StopTimer(LPTMR0);
240 if (ARM_DRIVER_OK != status)
246 status = pUartDriver->PowerControl(ARM_POWER_FULL);
247 if (ARM_DRIVER_OK != status)
254 if (ARM_DRIVER_OK != status)
char embAppName[ADS_MAX_STRING_LENGTH]
#define MPXV5004DP_ODR_ms
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 mpxv5004dp data buffer.
adc12_channel_config_t gAdcChannelConfigStruct
The host_io_uart.h file contains the Host Protocol interface definitions and configuration.
volatile bool bAdc12ConversionCompletedFlag
int main(void)
Main function.
#define MPXV5004DP_PRESSURE_FROM_ADC_VALUE(x)
#define HOST_PRO_CMD_W_CFG_TAG
Access structure of the GPIO Driver.
#define MPXVDP5004_ADC12_CHANNEL
#define APPLICATION_VERSION
Version to distinguish between instances the same application based on target Shield and updates...
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
GENERIC_DRIVER_GPIO * pGpioDriver
#define MPXV5004DP_STREAM_DATA_SIZE
#define MPXVDP5004_ADC12_CHANNEL_GROUP
void Host_IO_Add_ISO_Header(uint8_t streamID, uint8_t *pStreamingPacket, size_t sizePayload)
#define BOARD_DEBUG_UART_BAUDRATE
#define BOARD_BootClockRUN
volatile bool bDp5004Ready
#define adc12_irq_callback
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.
void KE15Z_LPTMR0_ADC0_Initialize(void)
uint32_t BOARD_SystickElapsedTime_us(int32_t *pStart)
Function to compute the Elapsed Time.
volatile uint32_t gAdcConversionValue
#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
bool process_host_command(uint8_t tag, uint8_t *hostCommand, uint8_t *hostResponse, size_t *hostMsgSize, size_t respBufferSize)
void(* toggle_pin)(pinID_t aPinId)
#define ADS_MAX_STRING_LENGTH
void BOARD_SystickEnable(void)
Function to enable systicks framework.
#define STREAMING_HEADER_LEN
#define APPLICATION_NAME
Unique Name for this application which should match the target GUI pkg name.
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)
char shieldString[ADS_MAX_STRING_LENGTH]
gpioHandleKSDK_t GREEN_LED
volatile bool bStreamingEnabled
#define HOST_PRO_INT_CMD_TAG
Bit aligned values for Host Protocol Interface IDs (Bits 5-6).
char boardString[ADS_MAX_STRING_LENGTH]
#define dp5004_odr_callback