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" 36 #include "auto_detection_service.h" 41 #define FXLS8962_DATA_SIZE 8 42 #define FXLS8962_STREAM_DATA_SIZE 12 43 #define FXLS8962_STREAM_SELF_TEST_SIZE 18 45 #define APPLICATION_NAME "FXLS8962 Accelerometer Demo" 47 #define APPLICATION_VERSION "2.5" 48 #define HOST_CMD_RESET 6 49 #define HOST_CMD_SELFTEST 7 193 uint8_t tag, uint8_t *hostCommand, uint8_t *hostResponse,
size_t *hostMsgSize,
size_t respBufferSize)
195 bool success =
false;
210 if (respBufferSize >= boardNameLen + shieldNameLen + appNameLen + 3)
219 hostResponse[*hostMsgSize] = appNameLen;
222 memcpy(hostResponse + *hostMsgSize,
embAppName, appNameLen);
223 *hostMsgSize += appNameLen;
225 hostResponse[*hostMsgSize] = boardNameLen;
228 memcpy(hostResponse + *hostMsgSize,
boardString, boardNameLen);
229 *hostMsgSize += boardNameLen;
231 hostResponse[*hostMsgSize] = shieldNameLen;
234 memcpy(hostResponse + *hostMsgSize,
shieldString, shieldNameLen);
235 *hostMsgSize += shieldNameLen;
245 switch (hostCommand[0])
304 if(hostCommand[1]==0x17)
306 if(((hostCommand[2] & 0x0F)<5))
308 hostCommand[2]= ((hostCommand[2]&0xF0) | 0x05);
310 if((((hostCommand[2] & 0xF0)>>4)<5))
312 hostCommand[2]= ((hostCommand[2]&0x0F) | 0x50);
317 if(hostCommand[1]==0x15)
319 if(((hostCommand[2] & 0x06)==0x06))
323 if(((hostCommand[2] & 0x06)==0x04))
327 if(((hostCommand[2] & 0x06)==0x02))
331 if(((hostCommand[2] & 0x06)==0x00))
338 if(hostCommand[1]==0x38 && hostCommand[2]<5)
342 if(hostCommand[1]==0x90)
352 if(hostCommand[1]==0x15)
354 if((*hostResponse & 0x06)==0x06)
358 if((*hostResponse & 0x06)==0x04)
362 if((*hostResponse & 0x06)==0x02)
366 if((*hostResponse & 0x06)==0x00)
408 if (ARM_DRIVER_OK != status)
414 status = pI2cDriver->PowerControl(ARM_POWER_FULL);
415 if (ARM_DRIVER_OK != status)
421 status = pI2cDriver->Control(ARM_I2C_BUS_SPEED, ARM_I2C_BUS_SPEED_FAST);
422 if (ARM_DRIVER_OK != status)
429 if (ARM_DRIVER_OK != status)
435 status = pUartDriver->PowerControl(ARM_POWER_FULL);
436 if (ARM_DRIVER_OK != status)
443 if (ARM_DRIVER_OK != status)
552 if (ARM_DRIVER_OK != status)
561 rawData.
accel[0] = (int16_t)(((int16_t)(((int16_t)data[3] << 8) | data[2])));
562 rawData.
accel[1] = (int16_t)(((int16_t)(((int16_t)data[5] << 8) | data[4])));
563 rawData.
accel[2] = (int16_t)(((int16_t)(((int16_t)data[7] << 8) | data[6])));
568 st_xp = (int16_t)(((int16_t)data[3] << 8) | data[2]);
572 st_xn = (int16_t)(((int16_t)data[3] << 8) | data[2]);
576 st_yp = (int16_t)(((int16_t)data[5] << 8) | data[4]);
580 st_yn = (int16_t)(((int16_t)data[5] << 8) | data[4]);
584 st_zp = (int16_t)(((int16_t)data[7] << 8) | data[6]);
588 st_zn = (int16_t)(((int16_t)data[7] << 8) | data[6]);
605 rawData.
temp = data[1]+25;
606 rawData.
sdcd = (data[0] & 0x10)>>4;
634 if (ARM_DRIVER_OK != status)
643 rawData.
accel[0] = (int16_t)(((int16_t)(((int16_t)data[3] << 8) | data[2])));
644 rawData.
accel[1] = (int16_t)(((int16_t)(((int16_t)data[5] << 8) | data[4])));
645 rawData.
accel[2] = (int16_t)(((int16_t)(((int16_t)data[7] << 8) | data[6])));
647 rawData.
temp = data[1]+25;
648 rawData.
sdcd = (data[0] & 0x10)>>4;
const registerwritelist_t cFxls8962STZN[]
Register settings for Self-Test in Z Axis (Negative polarity).
GENERIC_DRIVER_GPIO * pGpioDriver
#define FXLS8962_INT_EN_DRDY_EN_EN
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.
const registerwritelist_t cFxls8962STYP[]
Register settings for Self-Test in Y Axis (Positive polarity).
#define HOST_PRO_CMD_R_REG_TAG
status_t SMC_SetPowerModeVlpr(void *arg)
Configures the system to VLPR power mode. API name used from Kinetis family to maintain compatibility...
#define FXLS8962_SENS_CONFIG1_ST_AXIS_SEL_EN_Z
int32_t Register_I2C_Write(ARM_DRIVER_I2C *pCommDrv, registerDeviceInfo_t *devInfo, uint16_t slaveAddress, uint8_t offset, uint8_t value, uint8_t mask, bool repeatedStart)
The interface function to write a sensor register.
const registerwritelist_t cFxls8962STZP[]
Register settings for Self-Test in Z Axis (Positive polarity).
The host_io_uart.h file contains the Host Protocol interface definitions and configuration.
The fxls8962_drv.h file describes the FXLS8962AF driver interface and structures. ...
volatile bool bFxls8962DataReady
#define FXLS8962_SENS_CONFIG2_ANIC_TEMP_MASK
const registerwritelist_t cFxls8962ConfigNormal[]
Register settings for Interrupt (non buffered) mode.
#define FXLS8962_SENS_CONFIG1_FSR_16G
#define FXLS8962_INT_EN_DRDY_EN_MASK
int32_t FXLS8962_I2C_Initialize(fxls8962_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 HOST_PRO_CMD_W_CFG_TAG
Access structure of the GPIO Driver.
#define FXLS8962_SENS_CONFIG1_ST_POL_MASK
const registerreadlist_t cFxls8962OutputNormal[]
Address of Raw Accel Data in Normal Mode.
void fxls8962_int_data_ready_callback(void *pUserData)
const registerwritelist_t cFxls8962STXP[]
Register settings for Self-Test in X Axis (Positive polarity).
#define __END_WRITE_DATA__
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
#define FXLS8962_SENS_CONFIG3_WAKE_ODR_MASK
This defines the sensor specific information for I2C.
#define I2C_S_SIGNAL_EVENT
int main(void)
Main function.
void Host_IO_Add_ISO_Header(uint8_t streamID, uint8_t *pStreamingPacket, size_t sizePayload)
bool process_host_command(uint8_t tag, uint8_t *hostCommand, uint8_t *hostResponse, size_t *hostMsgSize, size_t respBufferSize)
#define HOST_PRO_CMD_W_REG_TAG
#define BOARD_DEBUG_UART_BAUDRATE
#define BOARD_BootClockRUN
fxls8962_i2c_sensorhandle_t fxls8962Driver
void(* registeridlefunction_t)(void *userParam)
This is the register idle function type.
#define FXLS8962_SENS_CONFIG3_WAKE_ODR_12_5HZ
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)
#define FXLS8962_SENS_CONFIG1_ST_POL_POSITIVE
void BOARD_SystickStart(int32_t *pStart)
Function to Record the Start systick.
const registerwritelist_t cFxls896216G[]
const registerwritelist_t cFxls8962STXN[]
Register settings for Self-Test in X Axis (Negative polarity).
const registerwritelist_t cFxls8962STYN[]
Register settings for Self-Test in Y Axis (Negative polarity).
#define FXLS8962_SENS_CONFIG1_ST_AXIS_SEL_DISABLED
uint32_t BOARD_SystickElapsedTime_us(int32_t *pStart)
Function to compute the Elapsed Time.
int32_t FXLS8962_I2C_DeInit(fxls8962_i2c_sensorhandle_t *pSensorHandle)
The interface function to De Initialize sensor..
uint8_t data[FXLS8962_DATA_SIZE]
#define 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.
#define FXLS8962_SENS_CONFIG1_ST_AXIS_SEL_MASK
uint8_t streamingPacket1[STREAMING_HEADER_LEN+FXLS8962_STREAM_SELF_TEST_SIZE]
int32_t FXLS8962_I2C_ReadData(fxls8962_i2c_sensorhandle_t *pSensorHandle, const registerreadlist_t *pReadList, uint8_t *pBuffer)
The interface function to read the sensor data.
This structure defines the fxls8962 raw data buffer.
volatile bool bFxls8962Ready
#define HOST_CMD_SELFTEST
#define FXLS8962_STREAM_DATA_SIZE
const registerwritelist_t cFxls8962ConfigNormal2[]
Register settings for Interrupt (non buffered) mode.
char boardString[ADS_MAX_STRING_LENGTH]
ARM_DRIVER_I2C * pCommDrv
#define FXLS8962_SENS_CONFIG1_ST_POL_NEGATIVE
void(* toggle_pin)(pinID_t aPinId)
#define ADS_MAX_STRING_LENGTH
#define FXLS8962_STREAM_SELF_TEST_SIZE
void BOARD_SystickEnable(void)
Function to enable systicks framework.
int32_t FXLS8962_I2C_Configure(fxls8962_i2c_sensorhandle_t *pSensorHandle, const registerwritelist_t *pRegWriteList)
The interface function to configure he sensor.
#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...
#define FXLS8962_SENS_CONFIG1_FSR_4G
char embAppName[ADS_MAX_STRING_LENGTH]
void(* pin_init)(pinID_t aPinId, gpio_direction_t dir, void *apPinConfig, gpio_isr_handler_t aIsrHandler, void *apUserData)
#define FXLS8962_SENS_CONFIG2_ANIC_TEMP_EN
This structure defines the Read command List.
#define FXLS8962_SENS_CONFIG1_FSR_MASK
gpioHandleKSDK_t GREEN_LED
#define I2C_S_DEVICE_INDEX
#define APPLICATION_NAME
Unique Name for this application which should match the target GUI pkg name.
fxls8962_acceldataUser_t rawData
void FXLS8962_I2C_SetIdleTask(fxls8962_i2c_sensorhandle_t *pSensorHandle, registeridlefunction_t idleTask, void *userParam)
: The interface function to set the I2C Idle Task.
#define FXLS8962_I2C_ADDR
fxls896x_selftest_t selftest
#define APPLICATION_VERSION
Version to distinguish between instances the same application based on target Shield and updates...
#define FXLS8962_WHOAMI_VALUE
#define HOST_PRO_INT_CMD_TAG
Bit aligned values for Host Protocol Interface IDs (Bits 5-6).
#define FXLS8962_SENS_CONFIG1_ST_AXIS_SEL_EN_X
volatile bool bStreamingEnabled
#define FXLS8962_SENS_CONFIG1_ST_AXIS_SEL_EN_Y
char shieldString[ADS_MAX_STRING_LENGTH]
registerDeviceInfo_t deviceInfo