20 #include "clock_config.h" 25 #include "Driver_I2C.h" 26 #include "Driver_USART.h" 31 #include "issdk_hal.h" 32 #include "gpio_driver.h" 36 #include "auto_detection_service.h" 41 #define MAG3110_DATA_SIZE 6 42 #define MAG3110_STREAM_DATA_SIZE 12 45 #define APPLICATION_NAME "MAG3110 Magnetometer Demo" 47 #define APPLICATION_VERSION "2.5" 98 uint8_t tag, uint8_t *hostCommand, uint8_t *hostResponse,
size_t *hostMsgSize,
size_t respBufferSize)
100 bool success =
false;
115 if (respBufferSize >= boardNameLen + shieldNameLen + appNameLen + 3)
124 hostResponse[*hostMsgSize] = appNameLen;
127 memcpy(hostResponse + *hostMsgSize,
embAppName, appNameLen);
128 *hostMsgSize += appNameLen;
130 hostResponse[*hostMsgSize] = boardNameLen;
133 memcpy(hostResponse + *hostMsgSize,
boardString, boardNameLen);
134 *hostMsgSize += boardNameLen;
136 hostResponse[*hostMsgSize] = shieldNameLen;
139 memcpy(hostResponse + *hostMsgSize,
shieldString, shieldNameLen);
140 *hostMsgSize += shieldNameLen;
150 switch (hostCommand[0])
212 if (ARM_DRIVER_OK != status)
218 status = pI2cDriver->PowerControl(ARM_POWER_FULL);
219 if (ARM_DRIVER_OK != status)
225 status = pI2cDriver->Control(ARM_I2C_BUS_SPEED, ARM_I2C_BUS_SPEED_FAST);
226 if (ARM_DRIVER_OK != status)
233 if (ARM_DRIVER_OK != status)
239 status = pUartDriver->PowerControl(ARM_POWER_FULL);
240 if (ARM_DRIVER_OK != status)
247 if (ARM_DRIVER_OK != status)
303 if (ARM_DRIVER_OK != status)
312 rawData.
mag[0] = ((int16_t)data[0] << 8) | data[1];
313 rawData.
mag[1] = ((int16_t)data[2] << 8) | data[3];
314 rawData.
mag[2] = ((int16_t)data[4] << 8) | data[5];
319 rawData.
temp = tempdata;
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)
This structure defines the Write command List.
int32_t MAG3110_I2C_Initialize(mag3110_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 MAG3110_CTRL_REG1_DR_ODR_2
status_t SMC_SetPowerModeVlpr(void *arg)
Configures the system to VLPR power mode. API name used from Kinetis family to maintain compatibility...
#define MAG3110_CTRL_REG2_MAG_RST_EN
The host_io_uart.h file contains the Host Protocol interface definitions and configuration.
volatile bool bMag3110Ready
This structure defines the mag3110 data buffer.
#define HOST_PRO_CMD_W_CFG_TAG
Access structure of the GPIO Driver.
int main(void)
Main function.
bool process_host_command(uint8_t tag, uint8_t *hostCommand, uint8_t *hostResponse, size_t *hostMsgSize, size_t respBufferSize)
#define MAG3110_DATA_SIZE
#define MAG3110_CTRL_REG2_MAG_RST_MASK
#define __END_WRITE_DATA__
char shieldString[ADS_MAX_STRING_LENGTH]
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
const registerreadlist_t cMag3110OutputNormal[]
Address and size of Raw Pressure+Temperature Data in Normal Mode.
#define I2C_S_SIGNAL_EVENT
int32_t MAG3110_I2C_Configure(mag3110_i2c_sensorhandle_t *pSensorHandle, const registerwritelist_t *pRegWriteList)
The interface function to configure he sensor.
void Host_IO_Add_ISO_Header(uint8_t streamID, uint8_t *pStreamingPacket, size_t sizePayload)
char boardString[ADS_MAX_STRING_LENGTH]
#define BOARD_DEBUG_UART_BAUDRATE
const registerwritelist_t cMag3110ConfigNormal[]
Register settings for Normal (non buffered) mode since Interrupt is enabled implicitly.
#define BOARD_BootClockRUN
ARM_DRIVER_I2C * pCommDrv
void(* registeridlefunction_t)(void *userParam)
This is the register idle function type.
registerDeviceInfo_t deviceInfo
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.
uint32_t BOARD_SystickElapsedTime_us(int32_t *pStart)
Function to compute the Elapsed Time.
uint8_t data[FXLS8962_DATA_SIZE]
#define MAG3110_STREAM_DATA_SIZE
const registerreadlist_t cMag3110TempOut[]
Address and size of Temperature Data in Normal Mode.
#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.
int32_t MAG3110_I2C_ReadData(mag3110_i2c_sensorhandle_t *pSensorHandle, const registerreadlist_t *pReadList, uint8_t *pBuffer)
The interface function to read the sensor data.
fxos8700_accelmagdata_t rawData
char embAppName[ADS_MAX_STRING_LENGTH]
#define MAG3110_CTRL_REG1_DR_MASK
volatile bool bMag3110DataReady
void mag3110_int_data_ready_callback(void *pUserData)
void(* toggle_pin)(pinID_t aPinId)
#define ADS_MAX_STRING_LENGTH
#define MAG3110_CTRL_REG1_OS_MASK
#define APPLICATION_NAME
Unique Name for this application which should match the target GUI pkg name.
#define MAG3110_CTRL_REG2_AUTO_MSRT_EN_MASK
void BOARD_SystickEnable(void)
Function to enable systicks framework.
#define MAG3110_CTRL_REG2_RAW_RAW
#define APPLICATION_VERSION
Version to distinguish between instances the same application based on target Shield and updates...
#define STREAMING_HEADER_LEN
#define MAG3110_CTRL_REG2_AUTO_MSRT_EN_EN
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 defines the sensor specific information.
This structure defines the Read command List.
volatile bool bStreamingEnabled
#define MAG3110_WHOAMI_VALUE
void MAG3110_CalibrateHardIronOffset(int16_t *xValue, int16_t *yValue, int16_t *zValue)
Calibrates the magnetometer reading by determining the current hard iron offset.
gpioHandleKSDK_t GREEN_LED
#define I2C_S_DEVICE_INDEX
GENERIC_DRIVER_GPIO * pGpioDriver
#define HOST_PRO_INT_CMD_TAG
Bit aligned values for Host Protocol Interface IDs (Bits 5-6).
void MAG3110_I2C_SetIdleTask(mag3110_i2c_sensorhandle_t *pSensorHandle, registeridlefunction_t idleTask, void *userParam)
: The interface function to set the I2C Idle Task.
#define MAG3110_CTRL_REG1_OS_OSR_32
#define MAG3110_CTRL_REG2_RAW_MASK
The mag3110_drv.h file describes the MAG3110 driver interface and structures.