43 #include "gpio_driver.h" 86 memcpy(pWBuff + FXLC95000_SPI_CMD_LEN, pWritebuffer, size);
103 uint16_t readNumber[2];
107 if (pSensorHandle == NULL || pBus == NULL || pSpiSelect == NULL || pSlaveSelect == NULL || pReset == NULL)
130 pGPIODriver->
set_pin(pSlaveSelect);
131 pGPIODriver->
clr_pin(pSpiSelect);
138 pGPIODriver->
set_pin(pSpiSelect);
144 BootToFlash,
sizeof(BootToFlash));
147 GetDeviceInfoCmd,
sizeof(GetDeviceInfoCmd));
152 (uint8_t *)&readNumber);
153 readNumber[0] = (readNumber[0] >> 8) | (readNumber[0] << 8);
154 readNumber[1] = (readNumber[1] >> 8) | (readNumber[1] << 8);
181 if (pSensorHandle == NULL || (pCommandList == NULL && pResponseList == NULL))
192 if (pCommandList != NULL)
196 if (ARM_DRIVER_OK != status)
203 if (pResponseList != NULL)
206 pResponseList, pBuffer);
207 if (ARM_DRIVER_OK != status)
219 uint16_t readNumber[2];
227 readNumber[0] = (readNumber[0] >> 8) | (readNumber[0] << 8);
228 readNumber[1] = (readNumber[1] >> 8) | (readNumber[1] << 8);
246 if (pBus == NULL || pCommandList == NULL)
253 if (ARM_DRIVER_OK != status)
262 ARM_DRIVER_I2C *pBus, uint8_t index, uint16_t sAddress, uint8_t *pFlashBytes, uint8_t numBytes)
272 uint8_t bytesToPageBoundary = 256 - *(pFlashBytes + 3);
276 if (bytesToPageBoundary > 0 && bytesToPageBoundary < numBytes - FXLC95000_FLASH_PAYLOAD_ADDR_LEN)
281 writeFlashCommand[1] =
282 (*(pFlashBytes + 1) == 0) ? 0x1F & (bytesToPageBoundary) : 0xC0 | (bytesToPageBoundary);
287 pFlashBytes[FXLC95000_ROM_CI_READ_WRITE_ADDR_LEN + i];
290 writeFlashCommand_2[1] =
291 (*(pFlashBytes + 1) == 0) ? 0x1F & (bytesAfterPageBoundary) : 0xC0 | (bytesAfterPageBoundary);
292 uint8_t address[] = {*(pFlashBytes + FXLC95000_ROM_CI_READ_WRITE_ADDR_LEN + 1),
293 *(pFlashBytes + FXLC95000_ROM_CI_READ_WRITE_ADDR_LEN)};
294 *((uint16_t *)address) += bytesToPageBoundary;
297 for (
int i = 0; i < bytesAfterPageBoundary; i++)
300 pFlashBytes[FXLC95000_FLASH_PAYLOAD_ADDR_LEN + bytesToPageBoundary + i];
311 {writeFlashCommand, 0,
314 FXLC95000_ROM_CI_READ_WRITE_ADDR_LEN + bytesAfterPageBoundary},
318 if (ARM_DRIVER_OK != status)
327 writeFlashCommand[1] =
329 0xC0 | (numBytes - FXLC95000_FLASH_PAYLOAD_ADDR_LEN);
344 {writeFlashCommand, 0,
349 if (ARM_DRIVER_OK != status)
365 ARM_DRIVER_I2C *pBus,
371 uint16_t readNumber[2];
374 if ((pSensorHandle == NULL) || (pBus == NULL))
392 readNumber[0] = (readNumber[0] >> 8) | (readNumber[0] << 8);
393 readNumber[1] = (readNumber[1] >> 8) | (readNumber[1] << 8);
423 if (pSensorHandle == NULL || (pCommandList == NULL && pResponseList == NULL))
434 if (pCommandList != NULL)
438 if (ARM_DRIVER_OK != status)
444 if (pResponseList != NULL)
447 pResponseList, pBuffer);
448 if (ARM_DRIVER_OK != status)
void FXLC95000_SPI_SetIdleTask(fxlc95000_spi_sensorhandle_t *pSensorHandle, registeridlefunction_t idleTask, void *userParam)
: The interface function to set the SPI Idle Task.
#define FXLC95000_ROM_CI_WRITE_MIN_LEN
The MIN Length of ROM CI_WRITE Data.
#define FXLC95000_SPI_CMD_LEN
The size of the Sensor specific SPI Header.
fpSpiWritePreprocessFn_t pWritePreprocessFN
#define FXLC95000_PART_NUMBER_SIZE
The FXLC95000 Size of Part Number.
registeridlefunction_t idleFunction
#define FXLC95000_BUILD_ID_SIZE
The FXLC95000 Size of ISF1.1_95k_Build_ID.
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(* pin_init)(pinID_t aPinId, gpio_direction_t dir, void *apPinConfig, gpio_isr_handler_t aIsrHandler, void *apUserData)
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_SS_ACTIVE_VALUE
Is the Slave Select Pin Active Low or High.
#define FXLC95000_SPI_MAX_MSG_SIZE
The MAX size of SPI message.
registerDeviceInfo_t deviceInfo
#define FXLC95000_ROM_CI_WRITE_MAX_LEN
The MAX Length of ROM CI_WRITE Data.
#define FXLC95000_ROM_CI_READ_WRITE_ADDR_LEN
The Length of Address field in ROM CI_READ_WRITE Command Header.
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.
registerDeviceInfo_t deviceInfo
uint8_t fxlc95000_spiRead_CmdBuffer[FXLC95000_SPI_MAX_MSG_SIZE]
void BOARD_DELAY_ms(uint32_t delay_ms)
Function to insert delays.
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.
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.
void(* registeridlefunction_t)(void *userParam)
This is the register idle function type.
uint8_t fxlc95000_spiRead_DataBuffer[FXLC95000_SPI_MAX_MSG_SIZE]
ARM_DRIVER_I2C * pCommDrv
The fxlc95000_drv.h file describes the FXLC95000L driver interface and structures.
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_PART_NUMBER
The FXLC95000 2-byte packed BCD encoded Part Number (BCD for Last 4 characters).
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.
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_ROM_CI_READ_WRITE_HDR_LEN
The Length of ROM CI_READ_WRITE Command Header.
uint8_t fxlc95000_spiWrite_CmdDataBuffer[FXLC95000_SPI_MAX_MSG_SIZE]
#define __END_WRITE_CMD__
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.
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.
The SPI Slave Transfer Command Params SDK2.0 Driver.
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. ...
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.
ARM_DRIVER_SPI * pCommDrv
#define FXLC95000_ROM_CI_READ_WRITE_MAX_LEN
The MAX Length of ROM CI_READ_WRITE Command.
GENERIC_DRIVER_GPIO * pGPIODriver
GENERIC_DRIVER_GPIO Driver_GPIO_KSDK
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.
spiSlaveSpecificParams_t slaveParams
#define FXLC95000_FLASH_PAYLOAD_ADDR_LEN
The Length of Address field in FLASH Payload form Host.
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.
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.
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.
#define FXLC95000_RESERVED_ID
The FXLC95000 Reserved filed bytes.
This defines the sensor specific information for SPI.
This structure defines the Read command List.
#define FXLC95000_BUILD_ID_OFFSET
Offset of 2-Byte ISF1.1_95k_Build_ID in Device Info Response.
This defines the sensor specific information for I2C.
This structure defines the device specific info required by register I/O.
This structure defines the Block command List.
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.
fpSpiReadPreprocessFn_t pReadPreprocessFN
#define FXLC95000_COCO_ERROR_MASK
The Error Bit Mask in COCO Byte.