1 of 1 people found this helpful
For reading n bytes of data from a device with slave address and from register address you will need to write the slave register address first and then perform a read operation.
If you are using the vendax firmware as an example, you can just use the EEPROMRead() function for reading the required data from the slave device, as the write part is also handled in the function.
Since your slave has single byte register address.
Please replace the existing EEPROMRead function in the firmware with the below function:
void EEPROMRead(BYTE addr, BYTE length, BYTE xdata *buf)
BYTE i = 1;
I2C_Addr = 0x01; //replace your slave device address here
EZUSB_WriteI2C(I2C_Addr, i, addr);
EZUSB_ReadI2C(I2C_Addr, length, buf);
Please change the prototype declaration as well in the start of VEND_AX.C firmware.
void EEPROMRead(BYTE addr, BYTE length, BYTE xdata *buf); //TPM EEPROM Read
In the EEPROMRead() function, I2C_Addr variable should be re-assigned in the start with the proper address of the slave device which you are using.
the first parameter passed to EEPROMRead() should be the register address (in BYTE format) from which you will be reading the frequency values. ()
The second parameter is the number of bytes to be starting from the register address specified.
The third parameter should be a pointer to the buffer where the read data should be stored. You can pass a pointer to the EP0 buffer EP0BUF or any other endpoint buffer which is configured as an IN end point.
Please note that in the control center you will need to do a control IN transfer with req type as vendor , target: device, req code: <your firmware switch case value where you are handling the request> , bytes to be transferred should be set to the number of bytes you are requesting from the FX2LP device.
Please refer to the screenshot below where i have requested for the chip revision.