17 #include "gpio_driver.h" 60 memcpy(pWBuff + FXLC95000_SPI_CMD_LEN, pWritebuffer, size);
77 uint16_t readNumber[2];
81 if (pSensorHandle == NULL || pBus == NULL || pSpiSelect == NULL || pSlaveSelect == NULL || pReset == NULL)
104 pGPIODriver->
set_pin(pSlaveSelect);
105 pGPIODriver->
clr_pin(pSpiSelect);
112 pGPIODriver->
set_pin(pSpiSelect);
118 BootToFlash,
sizeof(BootToFlash));
121 GetDeviceInfoCmd,
sizeof(GetDeviceInfoCmd));
126 (uint8_t *)&readNumber);
127 readNumber[0] = (readNumber[0] >> 8) | (readNumber[0] << 8);
128 readNumber[1] = (readNumber[1] >> 8) | (readNumber[1] << 8);
155 if (pSensorHandle == NULL || (pCommandList == NULL && pResponseList == NULL))
166 if (pCommandList != NULL)
170 if (ARM_DRIVER_OK != status)
177 if (pResponseList != NULL)
180 pResponseList, pBuffer);
181 if (ARM_DRIVER_OK != status)
193 uint16_t readNumber[2];
201 readNumber[0] = (readNumber[0] >> 8) | (readNumber[0] << 8);
202 readNumber[1] = (readNumber[1] >> 8) | (readNumber[1] << 8);
220 if (pBus == NULL || pCommandList == NULL)
227 if (ARM_DRIVER_OK != status)
236 ARM_DRIVER_I2C *pBus, uint8_t index, uint16_t sAddress, uint8_t *pFlashBytes, uint8_t numBytes)
246 uint8_t bytesToPageBoundary = 256 - *(pFlashBytes + 3);
250 if (bytesToPageBoundary > 0 && bytesToPageBoundary < numBytes - FXLC95000_FLASH_PAYLOAD_ADDR_LEN)
255 writeFlashCommand[1] =
256 (*(pFlashBytes + 1) == 0) ? 0x1F & (bytesToPageBoundary) : 0xC0 | (bytesToPageBoundary);
261 pFlashBytes[FXLC95000_ROM_CI_READ_WRITE_ADDR_LEN + i];
264 writeFlashCommand_2[1] =
265 (*(pFlashBytes + 1) == 0) ? 0x1F & (bytesAfterPageBoundary) : 0xC0 | (bytesAfterPageBoundary);
266 uint8_t address[] = {*(pFlashBytes + FXLC95000_ROM_CI_READ_WRITE_ADDR_LEN + 1),
267 *(pFlashBytes + FXLC95000_ROM_CI_READ_WRITE_ADDR_LEN)};
268 *((uint16_t *)address) += bytesToPageBoundary;
271 for (
int i = 0; i < bytesAfterPageBoundary; i++)
274 pFlashBytes[FXLC95000_FLASH_PAYLOAD_ADDR_LEN + bytesToPageBoundary + i];
285 {writeFlashCommand, 0,
288 FXLC95000_ROM_CI_READ_WRITE_ADDR_LEN + bytesAfterPageBoundary},
292 if (ARM_DRIVER_OK != status)
301 writeFlashCommand[1] =
303 0xC0 | (numBytes - FXLC95000_FLASH_PAYLOAD_ADDR_LEN);
318 {writeFlashCommand, 0,
323 if (ARM_DRIVER_OK != status)
339 ARM_DRIVER_I2C *pBus,
345 uint16_t readNumber[2];
348 if ((pSensorHandle == NULL) || (pBus == NULL))
366 readNumber[0] = (readNumber[0] >> 8) | (readNumber[0] << 8);
367 readNumber[1] = (readNumber[1] >> 8) | (readNumber[1] << 8);
397 if (pSensorHandle == NULL || (pCommandList == NULL && pResponseList == NULL))
408 if (pCommandList != NULL)
412 if (ARM_DRIVER_OK != status)
418 if (pResponseList != NULL)
421 pResponseList, pBuffer);
422 if (ARM_DRIVER_OK != status)
void(* set_pin)(pinID_t aPinId)
uint8_t fxlc95000_spiWrite_CmdDataBuffer[FXLC95000_SPI_MAX_MSG_SIZE]
This structure defines the device specific info required by register I/O.
void FXLC95000_SPI_SetIdleTask(fxlc95000_spi_sensorhandle_t *pSensorHandle, registeridlefunction_t idleTask, void *userParam)
: The interface function to set the SPI Idle Task.
int32_t Sensor_I2C_Read(ARM_DRIVER_I2C *pCommDrv, registerDeviceInfo_t *devInfo, uint16_t slaveAddress, const registerreadlist_t *pReadList, uint8_t *pOutBuffer)
Read register data from a sensor.
int32_t FXLC95000_SPI_Initialize(fxlc95000_spi_sensorhandle_t *pSensorHandle, ARM_DRIVER_SPI *pBus, uint8_t index, void *pSpiSelect, void *pSlaveSelect, void *pReset, uint16_t buildId)
The interface function to initialize the sensor.
GENERIC_DRIVER_GPIO * pGPIODriver
ARM_DRIVER_SPI * pCommDrv
int32_t Register_I2C_Read(ARM_DRIVER_I2C *pCommDrv, registerDeviceInfo_t *devInfo, uint16_t slaveAddress, uint8_t offset, uint8_t length, uint8_t *pOutBuffer)
The interface function to read a sensor register.
void BOARD_DELAY_ms(uint32_t delay_ms)
Function to insert delays.
#define FXLC95000_ROM_CI_READ_WRITE_ADDR_LEN
The Length of Address field in ROM CI_READ_WRITE Command Header.
This structure defines the Block command List.
void FXLC95000_SPI_WritePreprocess(void *pCmdOut, uint32_t offset, uint32_t size, void *pWritebuffer)
The SPI Write Pre-Process function to generate Sensor specific SPI Message Header.
registerDeviceInfo_t deviceInfo
Access structure of the GPIO Driver.
#define FXLC95000_ROM_CI_READ_WRITE_HDR_LEN
The Length of ROM CI_READ_WRITE Command Header.
int32_t Sensor_I2C_BlockWrite(ARM_DRIVER_I2C *pCommDrv, registerDeviceInfo_t *devInfo, uint16_t slaveAddress, const registercommandlist_t *pCommandList, uint8_t error_mask)
Write commands to a sensor.
#define FXLC95000_SPI_MAX_MSG_SIZE
The MAX size of SPI message.
#define FXLC95000_COCO_ERROR_MASK
The Error Bit Mask in COCO Byte.
#define FXLC95000_ROM_CI_WRITE_MAX_LEN
The MAX Length of ROM CI_WRITE Data.
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 FXLC95000_SS_ACTIVE_VALUE
Is the Slave Select Pin Active Low or High.
registerDeviceInfo_t deviceInfo
int32_t Sensor_SPI_Read(ARM_DRIVER_SPI *pCommDrv, registerDeviceInfo_t *devInfo, void *pReadParams, const registerreadlist_t *pReadList, uint8_t *pOutBuffer)
Read register data from a sensor.
#define FXLC95000_BUILD_ID_OFFSET
Offset of 2-Byte ISF1.1_95k_Build_ID in Device Info Response.
The fxlc95000_drv.h file describes the FXLC95000L driver interface and structures.
This defines the sensor specific information for I2C.
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.
#define FXLC95000_FLASH_PAYLOAD_ADDR_LEN
The Length of Address field in FLASH Payload form Host.
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.
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.
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 FXLC95000_SPI_CMD_LEN
The size of the Sensor specific SPI Header.
fpSpiReadPreprocessFn_t pReadPreprocessFN
The SPI Slave Transfer Command Params SDK2.0 Driver.
GENERIC_DRIVER_GPIO Driver_GPIO_KSDK
#define FXLC95000_RESERVED_ID
The FXLC95000 Reserved filed bytes.
#define FXLC95000_ROM_CI_WRITE_MIN_LEN
The MIN Length of ROM CI_WRITE Data.
#define __END_WRITE_CMD__
int32_t Sensor_SPI_BlockWrite(ARM_DRIVER_SPI *pCommDrv, registerDeviceInfo_t *devInfo, void *pWriteParams, const registercommandlist_t *pCommandList, uint8_t error_mask)
Write commands to a sensor.
#define FXLC95000_ROM_CI_READ_WRITE_MAX_LEN
The MAX Length of ROM CI_READ_WRITE Command.
int32_t Register_SPI_BlockWrite(ARM_DRIVER_SPI *pCommDrv, registerDeviceInfo_t *devInfo, void *pWriteParams, uint8_t offset, const uint8_t *pBuffer, uint8_t bytesToWrite)
The interface function to block write to a sensor register.
uint8_t fxlc95000_spiRead_CmdBuffer[FXLC95000_SPI_MAX_MSG_SIZE]
int32_t Register_I2C_BlockWrite(ARM_DRIVER_I2C *pCommDrv, registerDeviceInfo_t *devInfo, uint16_t slaveAddress, uint8_t offset, const uint8_t *pBuffer, uint8_t bytesToWrite)
The interface function to write a sensor register.
#define FXLC95000_PART_NUMBER_SIZE
The FXLC95000 Size of Part Number.
ARM_DRIVER_I2C * pCommDrv
#define FXLC95000_PART_NUMBER
The FXLC95000 2-byte packed BCD encoded Part Number (BCD for Last 4 characters).
fpSpiWritePreprocessFn_t pWritePreprocessFN
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.
uint8_t fxlc95000_spiRead_DataBuffer[FXLC95000_SPI_MAX_MSG_SIZE]
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.
int32_t Register_SPI_Read(ARM_DRIVER_SPI *pCommDrv, registerDeviceInfo_t *devInfo, void *pReadParams, uint8_t offset, uint8_t length, uint8_t *pOutBuffer)
The interface function to read a sensor register.
This defines the sensor specific information for SPI.
int32_t FXLC95000_SPI_CommandResponse(fxlc95000_spi_sensorhandle_t *pSensorHandle, const registercommandlist_t *pCommandList, const registerreadlist_t *pResponseList, uint8_t *pBuffer)
The interface function to read the sensor data.
registeridlefunction_t idleFunction
void FXLC95000_SPI_ReadPreprocess(void *pCmdOut, uint32_t offset, uint32_t size)
The SPI Read Pre-Process function to generate Sensor specific SPI Message Header. ...
#define FXLC95000_BUILD_ID_SIZE
The FXLC95000 Size of ISF1.1_95k_Build_ID.
spiSlaveSpecificParams_t slaveParams