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 MMA845x_STREAM_DATA_SIZE 11 70 #define APPLICATION_NAME "MMA845x Accelerometer Demo" 72 #define APPLICATION_VERSION "2.5" 163 uint8_t tag, uint8_t *hostCommand, uint8_t *hostResponse,
size_t *hostMsgSize,
size_t respBufferSize)
165 bool success =
false;
180 if (respBufferSize >= boardNameLen + shieldNameLen + appNameLen + 3)
189 hostResponse[*hostMsgSize] = appNameLen;
192 memcpy(hostResponse + *hostMsgSize,
embAppName, appNameLen);
193 *hostMsgSize += appNameLen;
195 hostResponse[*hostMsgSize] = boardNameLen;
198 memcpy(hostResponse + *hostMsgSize,
boardString, boardNameLen);
199 *hostMsgSize += boardNameLen;
201 hostResponse[*hostMsgSize] = shieldNameLen;
204 memcpy(hostResponse + *hostMsgSize,
shieldString, shieldNameLen);
205 *hostMsgSize += shieldNameLen;
215 switch (hostCommand[0])
277 if (ARM_DRIVER_OK != status)
283 status = pI2cDriver->PowerControl(ARM_POWER_FULL);
284 if (ARM_DRIVER_OK != status)
290 status = pI2cDriver->Control(ARM_I2C_BUS_SPEED, ARM_I2C_BUS_SPEED_FAST);
291 if (ARM_DRIVER_OK != status)
298 if (ARM_DRIVER_OK != status)
304 status = pUartDriver->PowerControl(ARM_POWER_FULL);
305 if (ARM_DRIVER_OK != status)
312 if (ARM_DRIVER_OK != status)
368 if (ARM_DRIVER_OK != status)
377 rawData.
accel[0] = ((int16_t)data[0] << 8) | data[1];
378 rawData.
accel[0] /= 4;
379 rawData.
accel[1] = ((int16_t)data[2] << 8) | data[3];
380 rawData.
accel[1] /= 4;
381 rawData.
accel[2] = ((int16_t)data[4] << 8) | data[5];
382 rawData.
accel[2] /= 4;
388 rawData.
intsrc = intsrcdata;
uint32_t BOARD_SystickElapsedTime_us(int32_t *pStart)
Function to compute the Elapsed Time.
const registerwritelist_t mma845x_Config_Isr[]
volatile bool bMma845xReady
#define MMA845x_FF_MT_CFG_ZEFE_ENABLED
#define MMA845x_CTRL_REG5_INT_CFG_DRDY_INT1
#define __END_WRITE_DATA__
ARM_DRIVER_I2C * pCommDrv
int main(void)
Main function.
#define MMA845x_CTRL_REG1_DR_100HZ
#define HOST_PRO_CMD_W_CFG_TAG
const registerreadlist_t cMma845xqStatus[]
#define HOST_S_SIGNAL_EVENT
This defines the sensor specific information.
bool process_host_command(uint8_t tag, uint8_t *hostCommand, uint8_t *hostResponse, size_t *hostMsgSize, size_t respBufferSize)
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)
char embAppName[ADS_MAX_STRING_LENGTH]
#define BOARD_BootClockRUN
#define MMA845x_CTRL_REG3_IPOL_HIGH
#define MMA845x_PULSE_CFG_YSPEFE_ENABLED
#define MMA845x_TRANSIENT_CFG_ZTEFE_ENABLED
uint8_t data[FXLS8962_DATA_SIZE]
void(* toggle_pin)(pinID_t aPinId)
#define MMA845x_CTRL_REG4_INT_EN_LNDPRT_ENABLED
#define MMA845x_FF_MT_CFG_YEFE_ENABLED
#define MMA845x_PL_CFG_DBCNTM_CLR
#define MMA845x_PL_CFG_PL_EN_ENABLED
#define ADS_MAX_STRING_LENGTH
#define MMA845x_TRANSIENT_THS_DBCNTM_CLR
#define MMA845x_CTRL_REG4_INT_EN_PULSE_ENABLED
#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.
#define MMA845x_PULSE_CFG_XSPEFE_ENABLED
#define HOST_PRO_INT_CMD_TAG
Bit aligned values for Host Protocol Interface IDs (Bits 5-6).
int32_t MMA845x_I2C_Initialize(mma845x_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 __END_READ_DATA__
#define MMA845x_PULSE_CFG_ZSPEFE_ENABLED
#define MMA845x_CTRL_REG2_MODS_HIGHRES
#define MMA845x_FF_MT_THS_DBCNTM_CLR
gpioHandleKSDK_t GREEN_LED
#define MMA845x_FF_MT_CFG_XEFE_ENABLED
#define MMA845x_CTRL_REG4_INT_EN_DRDY_ENABLED
#define MMA845x_FF_MT_CFG_OAE_FREEFALL
volatile bool bStreamingEnabled
void Host_IO_Add_ISO_Header(uint8_t streamID, uint8_t *pStreamingPacket, size_t sizePayload)
const registerreadlist_t cMma845xqPLStatus[]
void Host_IO_Send(uint8_t *pMsg, size_t size, uint8_t encoding)
char shieldString[ADS_MAX_STRING_LENGTH]
GENERIC_DRIVER_GPIO * pGpioDriver
void(* clr_pin)(pinID_t aPinId)
void BOARD_SystickEnable(void)
Function to enable systicks framework.
#define MMA845x_CTRL_REG4_INT_EN_TRANS_ENABLED
#define MMA845x_STREAM_DATA_SIZE
#define I2C_S_DEVICE_INDEX
int32_t MMA845x_I2C_ReadData(mma845x_i2c_sensorhandle_t *pSensorHandle, const registerreadlist_t *pReadList, uint8_t *pBuffer)
The interface function to read the sensor data.
#define MMA845x_XYZ_DATA_CFG_FS_MASK
volatile bool bMma845xDataReady
#define MMA845x_TRANSIENT_CFG_YTEFE_ENABLED
GENERIC_DRIVER_GPIO Driver_GPIO_KSDK
#define APPLICATION_NAME
Unique Name for this application which should match the target GUI pkg name.
#define BOARD_DEBUG_UART_BAUDRATE
registerDeviceInfo_t deviceInfo
int32_t MMA845x_I2C_Configure(mma845x_i2c_sensorhandle_t *pSensorHandle, const registerwritelist_t *pRegWriteList)
The interface function to configure he sensor.
Access structure of the GPIO Driver.
void BOARD_SystickStart(int32_t *pStart)
Function to Record the Start systick.
#define MMA845x_CTRL_REG4_INT_EN_FF_MT_ENABLED
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
void mma845x_int_data_ready_callback(void *pUserData)
#define APPLICATION_VERSION
Version to distinguish between instances the same application based on target Shield and updates...
uint8_t Host_IO_Init(ARM_DRIVER_USART *pDrv, void *pBus, void *pDevInfo, void *spiSlaveParams, uint16_t slaveAddress)
#define MMA845x_XYZ_DATA_CFG_FS_FS_RANGE_2G
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 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...
void MMA845x_I2C_SetIdleTask(mma845x_i2c_sensorhandle_t *pSensorHandle, registeridlefunction_t idleTask, void *userParam)
: The interface function to set the I2C Idle Task.
#define MMA845x_ACCEL_DATA_SIZE
The size of the MMA845x accel data.
#define MMA845x_TRANSIENT_CFG_XTEFE_ENABLED
char boardString[ADS_MAX_STRING_LENGTH]
#define MMA845x_CTRL_REG1_DR_MASK
#define I2C_S_SIGNAL_EVENT
const registerreadlist_t mma845x_Output_Values[]
#define MMA8451_WHO_AM_I_WHOAMI_VALUE
The mma845x_drv.h file describes the MMA845x driver interface and structures.