20 #include "clock_config.h" 25 #include "Driver_I2C.h" 26 #include "Driver_USART.h" 31 #include "issdk_hal.h" 33 #include "gpio_driver.h" 36 #include "auto_detection_service.h" 41 #define MMA865x_ACCEL_DATA_SIZE 6 42 #define MMA865x_STREAM_DATA_SIZE 11 45 #define APPLICATION_NAME "MMA8652 Accelerometer Demo" 47 #define APPLICATION_VERSION "2.5" 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])
245 if (ARM_DRIVER_OK != status)
251 status = pI2Cdriver->PowerControl(ARM_POWER_FULL);
252 if (ARM_DRIVER_OK != status)
258 status = pI2Cdriver->Control(ARM_I2C_BUS_SPEED, ARM_I2C_BUS_SPEED_FAST);
259 if (ARM_DRIVER_OK != status)
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)
336 if (ARM_DRIVER_OK != status)
345 rawData.
accel[0] = ((int16_t)data[0] << 8) | data[1];
346 rawData.
accel[0] /= 16;
347 rawData.
accel[1] = ((int16_t)data[2] << 8) | data[3];
348 rawData.
accel[1] /= 16;
349 rawData.
accel[2] = ((int16_t)data[4] << 8) | data[5];
350 rawData.
accel[2] /= 16;
357 rawData.
intsrc = intsrcdata;
#define MMA865x_CTRL_REG1_DR_MASK
void mma865x_int_data_ready_callback(void *pUserData)
ARM_DRIVER_I2C * pCommDrv
uint8_t Host_IO_Init(ARM_DRIVER_USART *pDrv, void *pBus, void *pDevInfo, void *spiSlaveParams, uint16_t slaveAddress)
const registerreadlist_t cMma8652qStatus[]
void Host_IO_Receive(host_cmd_proc_fn_t process_host_command, uint8_t encoding)
This structure defines the Write command List.
This defines the sensor specific information.
char embAppName[ADS_MAX_STRING_LENGTH]
bool process_host_command(uint8_t tag, uint8_t *hostCommand, uint8_t *hostResponse, size_t *hostMsgSize, size_t respBufferSize)
#define MMA865x_CTRL_REG4_INT_EN_PULSE_EN
#define MMA865x_XYZ_DATA_CFG_FS_MASK
status_t SMC_SetPowerModeVlpr(void *arg)
Configures the system to VLPR power mode. API name used from Kinetis family to maintain compatibility...
#define MMA865x_STREAM_DATA_SIZE
The host_io_uart.h file contains the Host Protocol interface definitions and configuration.
#define MMA865x_CTRL_REG5_INT_CFG_DRDY_INT1
#define MMA865x_FF_MT_CFG_XEFE_EN
volatile bool bMma865xDataReady
#define HOST_PRO_CMD_W_CFG_TAG
Access structure of the GPIO Driver.
char boardString[ADS_MAX_STRING_LENGTH]
#define __END_WRITE_DATA__
#define MMA865x_CTRL_REG3_IPOL_MASK
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 APPLICATION_VERSION
Version to distinguish between instances the same application based on target Shield and updates...
#define MMA865x_FF_MT_THS_DBCNTM_INC_CLR
int32_t MMA865x_I2C_ReadData(mma865x_i2c_sensorhandle_t *pSensorHandle, const registerreadlist_t *pReadList, uint8_t *pBuffer)
The interface function to read the sensor data.
char shieldString[ADS_MAX_STRING_LENGTH]
#define MMA865x_CTRL_REG3_IPOL_ACTIVE_HIGH
#define I2C_S_SIGNAL_EVENT
#define MMA865x_FF_MT_CFG_ZEFE_EN
void Host_IO_Add_ISO_Header(uint8_t streamID, uint8_t *pStreamingPacket, size_t sizePayload)
#define MMA865x_CTRL_REG4_INT_EN_FF_MT_EN
#define BOARD_DEBUG_UART_BAUDRATE
#define MMA865x_CTRL_REG2_MODS_MASK
#define BOARD_BootClockRUN
void(* registeridlefunction_t)(void *userParam)
This is the register idle function type.
volatile bool bMma865xReady
#define MMA865x_PULSE_CFG_XSPEFE_EN
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 MMA865x_PULSE_CFG_ZSPEFE_EN
void BOARD_SystickStart(int32_t *pStart)
Function to Record the Start systick.
#define MMA865x_TRANSIENT_CFG_ZTEFE_EN
uint32_t BOARD_SystickElapsedTime_us(int32_t *pStart)
Function to compute the Elapsed Time.
uint8_t data[FXLS8962_DATA_SIZE]
int32_t MMA865x_I2C_Configure(mma865x_i2c_sensorhandle_t *pSensorHandle, const registerwritelist_t *pRegWriteList)
The interface function to configure he sensor.
#define MMA865x_TRANSIENT_THS_DBCNTM_INC_CLR
#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.
The mma865x_drv.h file describes the MMA865x driver interface and structures.
#define MMA865x_CTRL_REG4_INT_EN_LNDPRT_EN
#define MMA865x_CTRL_REG4_INT_EN_DRDY_EN
#define MMA865x_TRANSIENT_CFG_XTEFE_EN
fxos8700_accelmagdata_t rawData
const registerwritelist_t cMma865xConfigInterrupt[]
const registerreadlist_t cMma8652qPLStatus[]
registerDeviceInfo_t deviceInfo
void(* toggle_pin)(pinID_t aPinId)
#define ADS_MAX_STRING_LENGTH
#define MMA865x_PL_CFG_PL_EN_EN
#define MMA865x_CTRL_REG2_MODS_HR
#define MMA865x_CTRL_REG4_INT_EN_TRANS_EN
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...
#define MMA865x_TRANSIENT_CFG_YTEFE_EN
#define MMA865x_ACCEL_DATA_SIZE
#define MMA865x_XYZ_DATA_CFG_FS_2G
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.
#define MMA865x_PL_CFG_DBCNTM_CLEAR
gpioHandleKSDK_t GREEN_LED
#define I2C_S_DEVICE_INDEX
void MMA865x_I2C_SetIdleTask(mma865x_i2c_sensorhandle_t *pSensorHandle, registeridlefunction_t idleTask, void *userParam)
: The interface function to set the I2C Idle Task.
const registerreadlist_t cMma865xOutputValues[]
#define APPLICATION_NAME
Unique Name for this application which should match the target GUI pkg name.
#define HOST_PRO_INT_CMD_TAG
Bit aligned values for Host Protocol Interface IDs (Bits 5-6).
#define MMA8652_WHOAMI_VALUE
int32_t MMA865x_I2C_Initialize(mma865x_i2c_sensorhandle_t *pSensorHandle, ARM_DRIVER_I2C *pBus, uint8_t index, uint16_t sAddress, uint8_t whoAmi)
The interface function to initialize the sensor.
int main(void)
Main function.
#define MMA865x_FF_MT_CFG_OAE_FREEFALL
volatile bool bStreamingEnabled
#define MMA865x_PULSE_CFG_YSPEFE_EN
GENERIC_DRIVER_GPIO * pGpioDriver
#define MMA865x_CTRL_REG1_DR_100HZ
#define MMA865x_FF_MT_CFG_YEFE_EN