46 #include "fsl_lptmr.h" 47 #include "clock_config.h" 52 #include "Driver_I2C.h" 53 #include "Driver_USART.h" 58 #include "issdk_hal.h" 59 #include "gpio_driver.h" 63 #include "auto_detection_service.h" 68 #define fxlc95000_odrCallback LPTMR0_IRQHandler 69 #define SAMPLING_RATE_ms 100 70 #define FXLC95000_SAMPLE_SIZE 10 73 #define APPLICATION_NAME "FXLC95000 Accelerometer Demo" 75 #define APPLICATION_VERSION "2.5" 90 {QuickReadInterruptDisable, 0,
sizeof(QuickReadInterruptDisable)},
91 {ConfigureMBoxCmd, 0,
sizeof(ConfigureMBoxCmd)},
97 {StopDataCmd, 0,
sizeof(StopDataCmd)},
101 {StartDataCmd, 0,
sizeof(StartDataCmd)},
106 {UnprotectFlash, 0,
sizeof(UnprotectFlash)},
107 {EraseMainFlashArray, 0,
sizeof(EraseMainFlashArray)},
113 {ProtectFlash, 0,
sizeof(ProtectFlash)},
139 LPTMR_ClearStatusFlags(LPTMR0, kLPTMR_TimerCompareFlag);
172 LPTMR_StartTimer(LPTMR0);
181 uint8_t tag, uint8_t *hostCommand, uint8_t *hostResponse,
size_t *hostMsgSize,
size_t respBufferSize)
183 static uint8_t toggle_led = 0;
184 bool success =
false;
185 size_t rxMsgSize = *hostMsgSize;
201 if (respBufferSize >= boardNameLen + shieldNameLen + appNameLen + 3)
210 hostResponse[*hostMsgSize] = appNameLen;
213 memcpy(hostResponse + *hostMsgSize,
embAppName, appNameLen);
214 *hostMsgSize += appNameLen;
216 hostResponse[*hostMsgSize] = boardNameLen;
219 memcpy(hostResponse + *hostMsgSize,
boardString, boardNameLen);
220 *hostMsgSize += boardNameLen;
222 hostResponse[*hostMsgSize] = shieldNameLen;
225 memcpy(hostResponse + *hostMsgSize,
shieldString, shieldNameLen);
226 *hostMsgSize += shieldNameLen;
244 switch (hostCommand[0])
279 switch (hostCommand[0])
305 if (toggle_led++ % 32 == 0 ?
true :
false)
317 cFxlc95000FlashPostprocess))
340 lptmr_config_t lptmrConfig;
359 LPTMR_GetDefaultConfig(&lptmrConfig);
360 LPTMR_Init(LPTMR0, &lptmrConfig);
361 LPTMR_EnableInterrupts(LPTMR0, kLPTMR_TimerInterruptEnable);
362 LPTMR_SetTimerPeriod(LPTMR0, MSEC_TO_COUNT(
SAMPLING_RATE_ms, CLOCK_GetFreq(kCLOCK_LpoClk)));
363 EnableIRQ(LPTMR0_IRQn);
375 if (ARM_DRIVER_OK != status)
381 status = I2Cdrv->PowerControl(ARM_POWER_FULL);
382 if (ARM_DRIVER_OK != status)
388 status = I2Cdrv->Control(ARM_I2C_BUS_SPEED, ARM_I2C_BUS_SPEED_FAST);
389 if (ARM_DRIVER_OK != status)
396 if (ARM_DRIVER_OK != status)
402 status = pUartDriver->PowerControl(ARM_POWER_FULL);
403 if (ARM_DRIVER_OK != status)
410 if (ARM_DRIVER_OK != status)
445 if (ARM_DRIVER_OK != status)
#define FXLC95000_SET_RESOLUTION_CMD_HDR
The FXLC95000 Set Resolution Command Header Bytes.
const uint8_t cFxlc95000_SetResolution_Cmd[]
const registercommandlist_t cFxlc95000ConfigMBox[]
#define FXLC95000_I2C_ADDR
#define HOST_PRO_CMD_W_CFG_TAG
int32_t FXLC95000_I2C_CheckRomMode(ARM_DRIVER_I2C *pBus, uint8_t index, uint16_t sAddress)
The interface function to check if the sensor is in ROM CI Mode.
const uint8_t cFxlc95000_SetRange_Cmd[]
#define HOST_S_SIGNAL_EVENT
#define FXLC95000_ACCEL_RANGE_2G
The FXLC95000 FS Range 2G.
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 BOARD_BootClockRUN
char shieldString[ADS_MAX_STRING_LENGTH]
registerDeviceInfo_t deviceInfo
char embAppName[ADS_MAX_STRING_LENGTH]
void(* toggle_pin)(pinID_t aPinId)
int fxlc95000_enSensor(fxlc95000_i2c_sensorhandle_t *pSensorHandle)
#define ADS_MAX_STRING_LENGTH
#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 HOST_PRO_INT_CMD_TAG
Bit aligned values for Host Protocol Interface IDs (Bits 5-6).
const uint8_t cFxlc95000_SetODR_Cmd[]
#define __END_READ_DATA__
GENERIC_DRIVER_GPIO * pGpioDriver
volatile bool bFxlc95000Boot
#define APPLICATION_VERSION
Version to distinguish between instances the same application based on target Shield and updates...
const registercommandlist_t cFxlc95000ConfigSensor[]
#define FXLC95000_SET_RANGE_CMD_HDR
The FXLC95000 Set Range Command Header Bytes.
const registercommandlist_t cFxlc95000FlashPostprocess[]
The fxlc95000_drv.h file describes the FXLC95000L driver interface and structures.
gpioHandleKSDK_t GREEN_LED
volatile bool bFxlc95000Ready
volatile bool bStreamingEnabled
int32_t FXLC95000_I2C_FlashPayload(ARM_DRIVER_I2C *pBus, uint8_t index, uint16_t sAddress, uint8_t *pFlashBytes, uint8_t numBytes)
The interface function to write ROM CI Data Payload.
int32_t FXLC95000_I2C_FlashCommands(ARM_DRIVER_I2C *pBus, uint8_t index, uint16_t sAddress, const registercommandlist_t *pCommandList)
The interface function to write ROM CI Commands.
#define fxlc95000_odrCallback
#define FXLC95000_SAMPLE_OFFSET
Time stamp and XYZ Data Register Offset.
#define __END_WRITE_CMD__
void Host_IO_Add_ISO_Header(uint8_t streamID, uint8_t *pStreamingPacket, size_t sizePayload)
#define APPLICATION_NAME
Unique Name for this application which should match the target GUI pkg name.
void Host_IO_Send(uint8_t *pMsg, size_t size, uint8_t encoding)
void(* set_pin)(pinID_t aPinId)
void(* clr_pin)(pinID_t aPinId)
void FXLC95000_I2C_SetIdleTask(fxlc95000_i2c_sensorhandle_t *pSensorHandle, registeridlefunction_t idleTask, void *userParam)
: The interface function to set the I2C Idle Task.
void BOARD_SystickEnable(void)
Function to enable systicks framework.
int32_t FXLC95000_I2C_CommandResponse(fxlc95000_i2c_sensorhandle_t *pSensorHandle, const registercommandlist_t *pCommandList, const registerreadlist_t *pResponseList, uint8_t *pBuffer)
The interface function to read the sensor data.
#define I2C_S_DEVICE_INDEX
#define FXLC95000_SET_ODR_CMD_HDR
The FXLC95000 Set Report Rate Command Header Bytes.
fxlc95000_i2c_sensorhandle_t fxlc95000Driver
volatile bool bFxlc95000DataReady
#define FXLC95000_SAMPLE_SIZE
char boardString[ADS_MAX_STRING_LENGTH]
GENERIC_DRIVER_GPIO Driver_GPIO_KSDK
volatile bool bFxlc95000Flashing
#define BOARD_DEBUG_UART_BAUDRATE
Access structure of the GPIO Driver.
int32_t FXLC95000_I2C_Initialize(fxlc95000_i2c_sensorhandle_t *pSensorHandle, ARM_DRIVER_I2C *pBus, uint8_t index, uint16_t sAddress, uint16_t buildId)
The interface function to initialize the sensor.
bool process_host_command(uint8_t tag, uint8_t *hostCommand, uint8_t *hostResponse, size_t *hostMsgSize, size_t respBufferSize)
void BOARD_RunADS(const char *appName, char *boardString, char *shieldString, size_t bufferLength)
The function to register Application Name and initialte ADS.
const registercommandlist_t cFxlc95000FlashPreprocess[]
#define FXLC95000_BUILD_ID
The FXLC95000 BCD encoded ISF1.1_95k_Build_ID.
uint8_t Host_IO_Init(ARM_DRIVER_USART *pDrv, void *pBus, void *pDevInfo, void *spiSlaveParams, uint16_t slaveAddress)
int main(void)
Main function.
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
const registerreadlist_t cFxlc95000ReadSample[]
This defines the sensor specific information for I2C.
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 Block command List.
#define FXLC95000_SST_ODR_PAYLOAD(x)
The FXLC95000 Set Report Rate Payload Bytes.
#define I2C_S_SIGNAL_EVENT
#define FXLC95000_ACCEL_RESOLUTION_14_BIT
The FXLC95000 Resoultion 14-Bit.