46 #include "fsl_lptmr.h" 47 #include "fsl_adc12.h" 48 #include "clock_config.h" 53 #include "Driver_USART.h" 58 #include "issdk_hal.h" 59 #include "gpio_driver.h" 62 #include "auto_detection_service.h" 68 #define dp5004_odr_callback PWT_LPTMR0_IRQHandler 70 #define adc12_irq_callback ADC0_IRQHandler 73 #define MPXV5004DP_ODR_ms 100U 75 #define MPXV5004DP_STREAM_DATA_SIZE 6U 78 #define APPLICATION_NAME "Analog Pressure Sensor Demo (MPXV5004DP)" 80 #define APPLICATION_VERSION "2.5" 110 LPTMR_ClearStatusFlags(LPTMR0, kLPTMR_TimerCompareFlag);
125 lptmr_config_t lptmrConfig;
126 adc12_config_t adc12ConfigStruct;
129 LPTMR_GetDefaultConfig(&lptmrConfig);
130 LPTMR_Init(LPTMR0, &lptmrConfig);
131 LPTMR_SetTimerPeriod(LPTMR0, MSEC_TO_COUNT(
MPXV5004DP_ODR_ms, CLOCK_GetFreq(kCLOCK_LpoClk)));
132 LPTMR_EnableInterrupts(LPTMR0, kLPTMR_TimerInterruptEnable);
133 EnableIRQ(PWT_LPTMR0_IRQn);
137 CLOCK_SetIpSrc(kCLOCK_Adc0, kCLOCK_IpSrcSircAsync);
138 EnableIRQ(ADC0_IRQn);
139 ADC12_GetDefaultConfig(&adc12ConfigStruct);
140 adc12ConfigStruct.clockSource = kADC12_ClockSourceAlt0;
141 adc12ConfigStruct.resolution = kADC12_Resolution12Bit;
142 ADC12_Init(ADC0, &adc12ConfigStruct);
144 ADC12_EnableHardwareTrigger(ADC0,
false);
146 if (kStatus_Success == ADC12_DoAutoCalibration(ADC0))
157 uint8_t tag, uint8_t *hostCommand, uint8_t *hostResponse,
size_t *hostMsgSize,
size_t respBufferSize)
159 bool success =
false;
174 if (respBufferSize >= boardNameLen + shieldNameLen + appNameLen + 3)
183 hostResponse[*hostMsgSize] = appNameLen;
186 memcpy(hostResponse + *hostMsgSize,
embAppName, appNameLen);
187 *hostMsgSize += appNameLen;
189 hostResponse[*hostMsgSize] = boardNameLen;
192 memcpy(hostResponse + *hostMsgSize,
boardString, boardNameLen);
193 *hostMsgSize += boardNameLen;
195 hostResponse[*hostMsgSize] = shieldNameLen;
198 memcpy(hostResponse + *hostMsgSize,
shieldString, shieldNameLen);
199 *hostMsgSize += shieldNameLen;
209 switch (hostCommand[0])
216 LPTMR_StartTimer(LPTMR0);
225 LPTMR_StopTimer(LPTMR0);
266 if (ARM_DRIVER_OK != status)
272 status = pUartDriver->PowerControl(ARM_POWER_FULL);
273 if (ARM_DRIVER_OK != status)
280 if (ARM_DRIVER_OK != status)
uint32_t BOARD_SystickElapsedTime_us(int32_t *pStart)
Function to compute the Elapsed Time.
volatile bool bDp5004Ready
#define HOST_PRO_CMD_W_CFG_TAG
#define dp5004_odr_callback
#define APPLICATION_VERSION
Version to distinguish between instances the same application based on target Shield and updates...
#define HOST_S_SIGNAL_EVENT
char embAppName[ADS_MAX_STRING_LENGTH]
void Host_IO_Receive(host_cmd_proc_fn_t process_host_command, uint8_t encoding)
void(* pin_init)(pinID_t aPinId, gpio_direction_t dir, void *apPinConfig, gpio_isr_handler_t aIsrHandler, void *apUserData)
#define BOARD_BootClockRUN
void(* toggle_pin)(pinID_t aPinId)
char shieldString[ADS_MAX_STRING_LENGTH]
#define ADS_MAX_STRING_LENGTH
#define HOST_PRO_INT_DEV_TAG
uint8_t streamingPacket[STREAMING_HEADER_LEN+FXLS8962_STREAM_DATA_SIZE]
#define HOST_PRO_INT_CMD_TAG
Bit aligned values for Host Protocol Interface IDs (Bits 5-6).
#define MPXV5004DP_STREAM_DATA_SIZE
bool process_host_command(uint8_t tag, uint8_t *hostCommand, uint8_t *hostResponse, size_t *hostMsgSize, size_t respBufferSize)
GENERIC_DRIVER_GPIO * pGpioDriver
gpioHandleKSDK_t GREEN_LED
volatile uint32_t gAdcConversionValue
#define MPXVDP5004_ADC12_CHANNEL
char boardString[ADS_MAX_STRING_LENGTH]
void Host_IO_Add_ISO_Header(uint8_t streamID, uint8_t *pStreamingPacket, size_t sizePayload)
void Host_IO_Send(uint8_t *pMsg, size_t size, uint8_t encoding)
void(* clr_pin)(pinID_t aPinId)
#define adc12_irq_callback
#define APPLICATION_NAME
Unique Name for this application which should match the target GUI pkg name.
void BOARD_SystickEnable(void)
Function to enable systicks framework.
#define MPXVDP5004_ADC12_CHANNEL_GROUP
GENERIC_DRIVER_GPIO Driver_GPIO_KSDK
#define BOARD_DEBUG_UART_BAUDRATE
volatile bool bStreamingEnabled
adc12_channel_config_t gAdcChannelConfigStruct
Access structure of the GPIO Driver.
void BOARD_SystickStart(int32_t *pStart)
Function to Record the Start systick.
#define MPXV5004DP_ODR_ms
void BOARD_RunADS(const char *appName, char *boardString, char *shieldString, size_t bufferLength)
The function to register Application Name and initialte ADS.
#define MPXV5004DP_PRESSURE_FROM_ADC_VALUE(x)
fxls8962_acceldataUser_t rawData
This structure defines the mpxv5004dp data buffer.
int main(void)
Main function.
uint8_t Host_IO_Init(ARM_DRIVER_USART *pDrv, void *pBus, void *pDevInfo, void *spiSlaveParams, uint16_t slaveAddress)
The host_io_uart.h file contains the Host Protocol interface definitions and configuration.
#define STREAMING_HEADER_LEN
volatile bool bAdc12ConversionCompletedFlag
void KE15Z_LPTMR0_ADC0_Initialize(void)
status_t SMC_SetPowerModeWait(void *arg)
Configures the system to WAIT power mode. API name used from Kinetis family to maintain compatibility...