18 #include "fsl_lptmr.h" 19 #include "clock_config.h" 22 #include "Driver_I2C.h" 25 #include "issdk_hal.h" 26 #include "gpio_driver.h" 30 #include "auto_detection_service.h" 35 #define SAMPLING_RATE_ms (100) 36 #define MMA9553_ACCEL_DATA_SIZE (6) 37 #define mma9553_en_callback LPTMR0_IRQHandler 39 #define MMA9553_STREAM_DATA_SIZE (10) 42 #define APPLICATION_NAME "MMA9553 Pedometer Demo" 44 #define APPLICATION_VERSION "2.5" 77 LPTMR_ClearStatusFlags(LPTMR0, kLPTMR_TimerCompareFlag);
83 uint8_t tag, uint8_t *hostCommand, uint8_t *hostResponse,
size_t *hostMsgSize,
size_t respBufferSize)
100 if (respBufferSize >= boardNameLen + shieldNameLen + appNameLen + 3)
109 hostResponse[*hostMsgSize] = appNameLen;
112 memcpy(hostResponse + *hostMsgSize,
embAppName, appNameLen);
113 *hostMsgSize += appNameLen;
115 hostResponse[*hostMsgSize] = boardNameLen;
118 memcpy(hostResponse + *hostMsgSize,
boardString, boardNameLen);
119 *hostMsgSize += boardNameLen;
121 hostResponse[*hostMsgSize] = shieldNameLen;
124 memcpy(hostResponse + *hostMsgSize,
shieldString, shieldNameLen);
125 *hostMsgSize += shieldNameLen;
135 switch (hostCommand[0])
170 lptmr_config_t lptmrConfig;
194 LPTMR_GetDefaultConfig(&lptmrConfig);
195 LPTMR_Init(LPTMR0, &lptmrConfig);
196 LPTMR_EnableInterrupts(LPTMR0, kLPTMR_TimerInterruptEnable);
197 LPTMR_SetTimerPeriod(LPTMR0, MSEC_TO_COUNT(
SAMPLING_RATE_ms, CLOCK_GetFreq(kCLOCK_LpoClk)));
198 EnableIRQ(LPTMR0_IRQn);
202 if (ARM_DRIVER_OK != status)
208 status = pI2Cdriver->PowerControl(ARM_POWER_FULL);
209 if (ARM_DRIVER_OK != status)
215 status = pI2Cdriver->Control(ARM_I2C_BUS_SPEED, ARM_I2C_BUS_SPEED_FAST);
216 if (ARM_DRIVER_OK != status)
223 if (ARM_DRIVER_OK != status)
229 status = pUartDriver->PowerControl(ARM_POWER_FULL);
230 if (ARM_DRIVER_OK != status)
237 if (ARM_DRIVER_OK != status)
272 LPTMR_StartTimer(LPTMR0);
291 if (ARM_DRIVER_OK != status)
const registerreadlist_t cMma9553ReadRawOutput[]
This defines the sensor specific information for I2C.
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)
void MMA9553_I2C_SetIdleTask(mma9553_i2c_sensorhandle_t *pSensorHandle, registeridlefunction_t idleTask, void *userParam)
: The interface function to set the I2C Idle Task.
const uint8_t SetSampleRate_30Hz[5]
status_t SMC_SetPowerModeVlpr(void *arg)
Configures the system to VLPR power mode. API name used from Kinetis family to maintain compatibility...
The host_io_uart.h file contains the Host Protocol interface definitions and configuration.
This structure defines the Block command List.
#define HOST_PRO_CMD_W_CFG_TAG
Access structure of the GPIO Driver.
#define APPLICATION_NAME
Unique Name for this application which should match the target GUI pkg name.
void(* clr_pin)(pinID_t aPinId)
int32_t MMA9553_I2C_Configure(mma9553_i2c_sensorhandle_t *pSensorHandle, const registercommandlist_t *pCommandList)
The interface function to configure he sensor.
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
The mma9553_drv.h file describes the MMA9553L driver interface and structures.
This structure defines the mma9553 pedometer data buffer.
int main(void)
Main function.
#define I2C_S_SIGNAL_EVENT
const uint8_t SetFSRange_2g[5]
Full-Scale Range Selections.
volatile bool bStreamingEnabled
void Host_IO_Add_ISO_Header(uint8_t streamID, uint8_t *pStreamingPacket, size_t sizePayload)
#define MMA9553_XYZ_DATA_OFFSET
XYZ Data Register Offset.
GENERIC_DRIVER_GPIO * pGpioDriver
#define BOARD_DEBUG_UART_BAUDRATE
#define BOARD_BootClockRUN
const uint8_t SetAFEPriority_for30Hz[5]
void(* registeridlefunction_t)(void *userParam)
This is the register idle function type.
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)
void BOARD_SystickStart(int32_t *pStart)
Function to Record the Start systick.
volatile bool bMma9553DataReady
int32_t MMA9553_I2C_CommandResponse(mma9553_i2c_sensorhandle_t *pSensorHandle, const registercommandlist_t *pCommandList, const registerreadlist_t *pResponseList, uint8_t *pBuffer)
The interface function to read the sensor data.
uint32_t BOARD_SystickElapsedTime_us(int32_t *pStart)
Function to compute the Elapsed Time.
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)
volatile bool bMma9553Ready
#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 __END_WRITE_CMD__
#define MMA9553_ACCEL_DATA_SIZE
fxos8700_accelmagdata_t rawData
int32_t MMA9553_I2C_Initialize(mma9553_i2c_sensorhandle_t *pSensorHandle, ARM_DRIVER_I2C *pBus, uint8_t index, uint16_t sAddress)
The interface function to initialize the sensor.
void(* toggle_pin)(pinID_t aPinId)
#define ADS_MAX_STRING_LENGTH
#define MMA9553_STREAM_DATA_SIZE
const uint8_t SetMBoxPriority_for30Hz[5]
#define APPLICATION_VERSION
Version to distinguish between instances the same application based on target Shield and updates...
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...
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.
const registercommandlist_t cMma9553Config30Hz[]
char boardString[ADS_MAX_STRING_LENGTH]
gpioHandleKSDK_t GREEN_LED
#define I2C_S_DEVICE_INDEX
ARM_DRIVER_I2C * pCommDrv
registerDeviceInfo_t deviceInfo
#define mma9553_en_callback
#define HOST_PRO_INT_CMD_TAG
Bit aligned values for Host Protocol Interface IDs (Bits 5-6).
char shieldString[ADS_MAX_STRING_LENGTH]