20 #include "fsl_lptmr.h" 21 #include "clock_config.h" 26 #include "Driver_I2C.h" 27 #include "Driver_USART.h" 32 #include "issdk_hal.h" 33 #include "gpio_driver.h" 37 #include "auto_detection_service.h" 42 #define fxlc95000_odrCallback LPTMR0_IRQHandler 43 #define SAMPLING_RATE_ms 100 44 #define FXLC95000_SAMPLE_SIZE 10 47 #define APPLICATION_NAME "FXLC95000 Accelerometer Demo" 49 #define APPLICATION_VERSION "2.5" 64 {QuickReadInterruptDisable, 0,
sizeof(QuickReadInterruptDisable)},
65 {ConfigureMBoxCmd, 0,
sizeof(ConfigureMBoxCmd)},
71 {StopDataCmd, 0,
sizeof(StopDataCmd)},
75 {StartDataCmd, 0,
sizeof(StartDataCmd)},
80 {UnprotectFlash, 0,
sizeof(UnprotectFlash)},
81 {EraseMainFlashArray, 0,
sizeof(EraseMainFlashArray)},
87 {ProtectFlash, 0,
sizeof(ProtectFlash)},
113 LPTMR_ClearStatusFlags(LPTMR0, kLPTMR_TimerCompareFlag);
146 LPTMR_StartTimer(LPTMR0);
155 uint8_t tag, uint8_t *hostCommand, uint8_t *hostResponse,
size_t *hostMsgSize,
size_t respBufferSize)
157 static uint8_t toggle_led = 0;
158 bool success =
false;
159 size_t rxMsgSize = *hostMsgSize;
175 if (respBufferSize >= boardNameLen + shieldNameLen + appNameLen + 3)
184 hostResponse[*hostMsgSize] = appNameLen;
187 memcpy(hostResponse + *hostMsgSize,
embAppName, appNameLen);
188 *hostMsgSize += appNameLen;
190 hostResponse[*hostMsgSize] = boardNameLen;
193 memcpy(hostResponse + *hostMsgSize,
boardString, boardNameLen);
194 *hostMsgSize += boardNameLen;
196 hostResponse[*hostMsgSize] = shieldNameLen;
199 memcpy(hostResponse + *hostMsgSize,
shieldString, shieldNameLen);
200 *hostMsgSize += shieldNameLen;
218 switch (hostCommand[0])
253 switch (hostCommand[0])
279 if (toggle_led++ % 32 == 0 ?
true :
false)
291 cFxlc95000FlashPostprocess))
314 lptmr_config_t lptmrConfig;
333 LPTMR_GetDefaultConfig(&lptmrConfig);
334 LPTMR_Init(LPTMR0, &lptmrConfig);
335 LPTMR_EnableInterrupts(LPTMR0, kLPTMR_TimerInterruptEnable);
336 LPTMR_SetTimerPeriod(LPTMR0, MSEC_TO_COUNT(
SAMPLING_RATE_ms, CLOCK_GetFreq(kCLOCK_LpoClk)));
337 EnableIRQ(LPTMR0_IRQn);
349 if (ARM_DRIVER_OK != status)
355 status = I2Cdrv->PowerControl(ARM_POWER_FULL);
356 if (ARM_DRIVER_OK != status)
362 status = I2Cdrv->Control(ARM_I2C_BUS_SPEED, ARM_I2C_BUS_SPEED_FAST);
363 if (ARM_DRIVER_OK != status)
370 if (ARM_DRIVER_OK != status)
376 status = pUartDriver->PowerControl(ARM_POWER_FULL);
377 if (ARM_DRIVER_OK != status)
384 if (ARM_DRIVER_OK != status)
419 if (ARM_DRIVER_OK != status)
void(* set_pin)(pinID_t aPinId)
const registerreadlist_t cFxlc95000ReadSample[]
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)
const registercommandlist_t cFxlc95000ConfigMBox[]
status_t SMC_SetPowerModeVlpr(void *arg)
Configures the system to VLPR power mode. API name used from Kinetis family to maintain compatibility...
int main(void)
Main function.
The host_io_uart.h file contains the Host Protocol interface definitions and configuration.
#define FXLC95000_SET_RESOLUTION_CMD_HDR
The FXLC95000 Set Resolution Command Header Bytes.
This structure defines the Block command List.
const uint8_t cFxlc95000_SetResolution_Cmd[]
const uint8_t cFxlc95000_SetODR_Cmd[]
const uint8_t cFxlc95000_SetRange_Cmd[]
#define HOST_PRO_CMD_W_CFG_TAG
registerDeviceInfo_t deviceInfo
Access structure of the GPIO Driver.
#define FXLC95000_I2C_ADDR
char boardString[ADS_MAX_STRING_LENGTH]
#define FXLC95000_BUILD_ID
The FXLC95000 BCD encoded ISF1.1_95k_Build_ID.
volatile bool bFxlc95000Flashing
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
The fxlc95000_drv.h file describes the FXLC95000L driver interface and structures.
This defines the sensor specific information for I2C.
#define I2C_S_SIGNAL_EVENT
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.
void Host_IO_Add_ISO_Header(uint8_t streamID, uint8_t *pStreamingPacket, size_t sizePayload)
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.
void FXLC95000_I2C_SetIdleTask(fxlc95000_i2c_sensorhandle_t *pSensorHandle, registeridlefunction_t idleTask, void *userParam)
: The interface function to set the I2C Idle Task.
#define BOARD_DEBUG_UART_BAUDRATE
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 BOARD_BootClockRUN
#define FXLC95000_ACCEL_RESOLUTION_14_BIT
The FXLC95000 Resoultion 14-Bit.
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.
void(* registeridlefunction_t)(void *userParam)
This is the register idle function type.
#define APPLICATION_NAME
Unique Name for this application which should match the target GUI pkg name.
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)
volatile bool bStreamingEnabled
#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.
char embAppName[ADS_MAX_STRING_LENGTH]
volatile bool bFxlc95000Ready
const registercommandlist_t cFxlc95000FlashPostprocess[]
#define __END_WRITE_CMD__
char shieldString[ADS_MAX_STRING_LENGTH]
#define fxlc95000_odrCallback
#define FXLC95000_SAMPLE_SIZE
#define FXLC95000_SST_ODR_PAYLOAD(x)
The FXLC95000 Set Report Rate Payload Bytes.
#define FXLC95000_SAMPLE_OFFSET
Time stamp and XYZ Data Register Offset.
volatile bool bFxlc95000Boot
const registercommandlist_t cFxlc95000ConfigSensor[]
void(* toggle_pin)(pinID_t aPinId)
#define ADS_MAX_STRING_LENGTH
void BOARD_SystickEnable(void)
Function to enable systicks framework.
#define STREAMING_HEADER_LEN
#define FXLC95000_SET_RANGE_CMD_HDR
The FXLC95000 Set Range Command Header Bytes.
#define APPLICATION_VERSION
Version to distinguish between instances the same application based on target Shield and updates...
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.
GENERIC_DRIVER_GPIO * pGpioDriver
volatile bool bFxlc95000DataReady
gpioHandleKSDK_t GREEN_LED
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
int fxlc95000_enSensor(fxlc95000_i2c_sensorhandle_t *pSensorHandle)
bool process_host_command(uint8_t tag, uint8_t *hostCommand, uint8_t *hostResponse, size_t *hostMsgSize, size_t respBufferSize)
#define FXLC95000_SET_ODR_CMD_HDR
The FXLC95000 Set Report Rate Command Header Bytes.
#define HOST_PRO_INT_CMD_TAG
Bit aligned values for Host Protocol Interface IDs (Bits 5-6).
const registercommandlist_t cFxlc95000FlashPreprocess[]
fxlc95000_i2c_sensorhandle_t fxlc95000Driver
#define FXLC95000_ACCEL_RANGE_2G
The FXLC95000 FS Range 2G.