46 #include "clock_config.h" 51 #include "Driver_I2C.h" 52 #include "Driver_USART.h" 57 #include "issdk_hal.h" 58 #include "gpio_driver.h" 62 #include "auto_detection_service.h" 67 #define FXLS8962_DATA_SIZE 8 68 #define FXLS8962_STREAM_DATA_SIZE 12 69 #define FXLS8962_STREAM_SELF_TEST_SIZE 18 71 #define APPLICATION_NAME "FXLS8962 Accelerometer Demo" 73 #define APPLICATION_VERSION "2.5" 74 #define HOST_CMD_RESET 6 75 #define HOST_CMD_SELFTEST 7 219 uint8_t tag, uint8_t *hostCommand, uint8_t *hostResponse,
size_t *hostMsgSize,
size_t respBufferSize)
221 bool success =
false;
236 if (respBufferSize >= boardNameLen + shieldNameLen + appNameLen + 3)
245 hostResponse[*hostMsgSize] = appNameLen;
248 memcpy(hostResponse + *hostMsgSize,
embAppName, appNameLen);
249 *hostMsgSize += appNameLen;
251 hostResponse[*hostMsgSize] = boardNameLen;
254 memcpy(hostResponse + *hostMsgSize,
boardString, boardNameLen);
255 *hostMsgSize += boardNameLen;
257 hostResponse[*hostMsgSize] = shieldNameLen;
260 memcpy(hostResponse + *hostMsgSize,
shieldString, shieldNameLen);
261 *hostMsgSize += shieldNameLen;
271 switch (hostCommand[0])
330 if(hostCommand[1]==0x17)
332 if(((hostCommand[2] & 0x0F)<5))
334 hostCommand[2]= ((hostCommand[2]&0xF0) | 0x05);
336 if((((hostCommand[2] & 0xF0)>>4)<5))
338 hostCommand[2]= ((hostCommand[2]&0x0F) | 0x50);
343 if(hostCommand[1]==0x15)
345 if(((hostCommand[2] & 0x06)==0x06))
349 if(((hostCommand[2] & 0x06)==0x04))
353 if(((hostCommand[2] & 0x06)==0x02))
357 if(((hostCommand[2] & 0x06)==0x00))
364 if(hostCommand[1]==0x38 && hostCommand[2]<5)
368 if(hostCommand[1]==0x90)
378 if(hostCommand[1]==0x15)
380 if((*hostResponse & 0x06)==0x06)
384 if((*hostResponse & 0x06)==0x04)
388 if((*hostResponse & 0x06)==0x02)
392 if((*hostResponse & 0x06)==0x00)
437 if (ARM_DRIVER_OK != status)
443 status = pI2cDriver->PowerControl(ARM_POWER_FULL);
444 if (ARM_DRIVER_OK != status)
450 status = pI2cDriver->Control(ARM_I2C_BUS_SPEED, ARM_I2C_BUS_SPEED_FAST);
451 if (ARM_DRIVER_OK != status)
458 if (ARM_DRIVER_OK != status)
464 status = pUartDriver->PowerControl(ARM_POWER_FULL);
465 if (ARM_DRIVER_OK != status)
472 if (ARM_DRIVER_OK != status)
581 if (ARM_DRIVER_OK != status)
590 rawData.
accel[0] = (int16_t)(((int16_t)(((int16_t)data[3] << 8) | data[2])));
591 rawData.
accel[1] = (int16_t)(((int16_t)(((int16_t)data[5] << 8) | data[4])));
592 rawData.
accel[2] = (int16_t)(((int16_t)(((int16_t)data[7] << 8) | data[6])));
597 st_xp = (int16_t)(((int16_t)data[3] << 8) | data[2]);
601 st_xn = (int16_t)(((int16_t)data[3] << 8) | data[2]);
605 st_yp = (int16_t)(((int16_t)data[5] << 8) | data[4]);
609 st_yn = (int16_t)(((int16_t)data[5] << 8) | data[4]);
613 st_zp = (int16_t)(((int16_t)data[7] << 8) | data[6]);
617 st_zn = (int16_t)(((int16_t)data[7] << 8) | data[6]);
634 rawData.
temp = data[1]+25;
635 rawData.
sdcd = (data[0] & 0x10)>>4;
663 if (ARM_DRIVER_OK != status)
672 rawData.
accel[0] = (int16_t)(((int16_t)(((int16_t)data[3] << 8) | data[2])));
673 rawData.
accel[1] = (int16_t)(((int16_t)(((int16_t)data[5] << 8) | data[4])));
674 rawData.
accel[2] = (int16_t)(((int16_t)(((int16_t)data[7] << 8) | data[6])));
676 rawData.
temp = data[1]+25;
677 rawData.
sdcd = (data[0] & 0x10)>>4;
uint32_t BOARD_SystickElapsedTime_us(int32_t *pStart)
Function to compute the Elapsed Time.
const registerwritelist_t cFxls8962STZP[]
Register settings for Self-Test in Z Axis (Positive polarity).
char boardString[ADS_MAX_STRING_LENGTH]
uint8_t streamingPacket1[STREAMING_HEADER_LEN+FXLS8962_STREAM_SELF_TEST_SIZE]
#define __END_WRITE_DATA__
#define FXLS8962_SENS_CONFIG1_FSR_16G
#define HOST_PRO_CMD_W_CFG_TAG
#define FXLS8962_SENS_CONFIG2_ANIC_TEMP_EN
bool process_host_command(uint8_t tag, uint8_t *hostCommand, uint8_t *hostResponse, size_t *hostMsgSize, size_t respBufferSize)
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_CMD_SELFTEST
char embAppName[ADS_MAX_STRING_LENGTH]
#define HOST_S_SIGNAL_EVENT
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 HOST_PRO_CMD_W_REG_TAG
#define BOARD_BootClockRUN
const registerreadlist_t cFxls8962OutputNormal[]
Address of Raw Accel Data in Normal Mode.
This defines the sensor specific information for I2C.
uint8_t data[FXLS8962_DATA_SIZE]
int32_t FXLS8962_I2C_Configure(fxls8962_i2c_sensorhandle_t *pSensorHandle, const registerwritelist_t *pRegWriteList)
The interface function to configure he sensor.
const registerwritelist_t cFxls8962STYP[]
Register settings for Self-Test in Y Axis (Positive polarity).
#define FXLS8962_SENS_CONFIG1_ST_AXIS_SEL_MASK
#define FXLS8962_SENS_CONFIG1_ST_AXIS_SEL_EN_Z
void(* toggle_pin)(pinID_t aPinId)
volatile bool bFxls8962Ready
void fxls8962_int_data_ready_callback(void *pUserData)
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_SENS_CONFIG3_WAKE_ODR_12_5HZ
volatile bool bFxls8962DataReady
#define ADS_MAX_STRING_LENGTH
registerDeviceInfo_t deviceInfo
#define HOST_PRO_INT_DEV_TAG
uint8_t streamingPacket[STREAMING_HEADER_LEN+FXLS8962_STREAM_DATA_SIZE]
void(* registeridlefunction_t)(void *userParam)
This is the register idle function type.
fxls8962_i2c_sensorhandle_t fxls8962Driver
#define HOST_PRO_INT_CMD_TAG
Bit aligned values for Host Protocol Interface IDs (Bits 5-6).
const registerwritelist_t cFxls8962STYN[]
Register settings for Self-Test in Y Axis (Negative polarity).
const registerwritelist_t cFxls8962STZN[]
Register settings for Self-Test in Z Axis (Negative polarity).
int32_t FXLS8962_I2C_DeInit(fxls8962_i2c_sensorhandle_t *pSensorHandle)
The interface function to De Initialize sensor..
#define __END_READ_DATA__
#define FXLS8962_STREAM_DATA_SIZE
const registerwritelist_t cFxls8962ConfigNormal[]
Register settings for Interrupt (non buffered) mode.
#define APPLICATION_NAME
Unique Name for this application which should match the target GUI pkg name.
#define FXLS8962_DATA_SIZE
#define FXLS8962_I2C_ADDR
GENERIC_DRIVER_GPIO * pGpioDriver
gpioHandleKSDK_t GREEN_LED
#define FXLS8962_SENS_CONFIG3_WAKE_ODR_MASK
#define FXLS8962_SENS_CONFIG1_FSR_4G
const registerwritelist_t cFxls8962STXN[]
Register settings for Self-Test in X Axis (Negative polarity).
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)
#define FXLS8962_SENS_CONFIG1_ST_POL_MASK
void(* clr_pin)(pinID_t aPinId)
#define HOST_PRO_CMD_R_REG_TAG
The fxls8962_drv.h file describes the FXLS8962AF driver interface and structures. ...
void BOARD_SystickEnable(void)
Function to enable systicks framework.
#define FXLS8962_SENS_CONFIG1_ST_AXIS_SEL_EN_Y
#define FXLS8962_INT_EN_DRDY_EN_MASK
#define I2C_S_DEVICE_INDEX
#define FXLS8962_SENS_CONFIG1_ST_AXIS_SEL_EN_X
GENERIC_DRIVER_GPIO Driver_GPIO_KSDK
#define FXLS8962_WHOAMI_VALUE
#define BOARD_DEBUG_UART_BAUDRATE
const registerwritelist_t cFxls8962ConfigNormal2[]
Register settings for Interrupt (non buffered) mode.
ARM_DRIVER_I2C * pCommDrv
Access structure of the GPIO Driver.
#define FXLS8962_SENS_CONFIG2_ANIC_TEMP_MASK
void BOARD_SystickStart(int32_t *pStart)
Function to Record the Start systick.
void BOARD_RunADS(const char *appName, char *boardString, char *shieldString, size_t bufferLength)
The function to register Application Name and initialte ADS.
fxls8962_acceldataUser_t rawData
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.
uint8_t Host_IO_Init(ARM_DRIVER_USART *pDrv, void *pBus, void *pDevInfo, void *spiSlaveParams, uint16_t slaveAddress)
This structure defines the Write command List.
This structure defines the Read command List.
The host_io_uart.h file contains the Host Protocol interface definitions and configuration.
#define FXLS8962_SENS_CONFIG1_ST_POL_POSITIVE
#define STREAMING_HEADER_LEN
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.
status_t SMC_SetPowerModeWait(void *arg)
Configures the system to WAIT power mode. API name used from Kinetis family to maintain compatibility...
This structure defines the fxls8962 raw data buffer.
#define FXLS8962_STREAM_SELF_TEST_SIZE
#define FXLS8962_SENS_CONFIG1_ST_AXIS_SEL_DISABLED
#define FXLS8962_SENS_CONFIG1_FSR_MASK
#define APPLICATION_VERSION
Version to distinguish between instances the same application based on target Shield and updates...
#define FXLS8962_INT_EN_DRDY_EN_EN
#define FXLS8962_SENS_CONFIG1_ST_POL_NEGATIVE
int main(void)
Main function.
#define I2C_S_SIGNAL_EVENT
const registerwritelist_t cFxls8962STXP[]
Register settings for Self-Test in X Axis (Positive polarity).
volatile bool bStreamingEnabled
const registerwritelist_t cFxls896216G[]
char shieldString[ADS_MAX_STRING_LENGTH]