Void fun_regist ()
{
M_fun. Iic_read=Master_Read2Byte;
M_fun. Iic_write=Master_Write2Byte;
M_fun. Spi_read=switchchip_read;
M_fun. Spi_write=switchchip_write;
M_fun. Mdio_read=mdiobb_read;
M_fun. Mdio_write=mdiobb_write;
M_fun. Eeprom_read=AT24CXX_Read;
M_fun. Eeprom_write=AT24CXX_Write;
}
This is the corresponding structure
Typedef struct user_mgmt_fun_s
{
//unsigned short (* iic_read) (l2sw_uint32 I2Cx, l2sw_uint16 ReadAddr, l2sw_uint16 * ReadBuff);
Int (* iic_read) (l2sw_uint32 I2Cx, l2sw_uint8 SlaveAddr, l2sw_uint16 ReadAddr, l2sw_uint16 * ReadBuff);
Int (* iic_write) (l2sw_uint32 I2Cx, l2sw_uint8 SlaveAddr, l2sw_uint16 WriteAddr, l2sw_uint16 DataToWrite);
Int (* spi_read) (l2sw_uint32 SPIx, l2sw_uint16 ReadAddr, l2sw_uint8 * pBuffer, l2sw_uint16 NumByteToRead);
Int (* spi_write) (l2sw_uint32 SPIx, l2sw_uint16 WriteAddr, l2sw_uint8 * pBuffer, l2sw_uint16 NumByteToWrite);
Int (* mdio_read) (l2sw_uint32 MDIOx, l2sw_uint32 phy, l2sw_uint32 reg, l2sw_uint16 * val);
Int (* mdio_write) (l2sw_uint32 MDIOx, l2sw_uint32 phy, l2sw_uint32 reg, l2sw_uint16 val);
Eeprom_read int (*) (l2sw_uint32 I2Cx, l2sw_uint8 SlaveAddr, l2sw_uint8 ReadAddr, l2sw_uint32 num_to_read, l2sw_uint8 * ReadBuff);
Eeprom_write int (*) (l2sw_uint32 I2Cx, l2sw_uint8 SlaveAddr, l2sw_uint8 WriteAddr, l2sw_uint32 num_to_write, l2sw_uint8 * DataToWrite);
} user_mgmt_fun_t;
This is my own writing interface function
Uint32_t Master_Read2Byte (uint8_t I2C_SLAVE_ADDR, uint16_t ReadAddr, uint16_t * ReadBuff)
{
Uint8_t addr_high=0;
Uint8_t addr_low=0;
Addr_high=ReadAddr> & gt; 8;
Addr_low=ReadAddr<8;
Uint16_t temp=0;
IIC_Start ();
IIC_Send_Byte (I2C_SLAVE_ADDR);//sending device address 0 x5c, write data
IIC_Wait_Ack ();
IIC_Send_Byte (addr_high % 256);//send high address
IIC_Wait_Ack ();
IIC_Send_Byte (addr_low % 256);//send high address
IIC_Wait_Ack ();
IIC_Start ();
IIC_Send_Byte (I2C_SLAVE_ADDR + 1);//into receiving mode
IIC_Wait_Ack ();
Temp=IIC_Read_Byte (0) & gt; & gt; 8;
IIC_Wait_Ack ();
IIC_Send_Byte (I2C_SLAVE_ADDR + 1);//into receiving mode
IIC_Wait_Ack ();
Temp=IIC_Read_Byte (0) & lt; <8;
IIC_Wait_Ack ();
IIC_Stop ();//to create a stop condition
return temp;
}
Void Master_Write2Byte (uint8_t I2C_SLAVE_ADDR, uint16_t WriteAddr, uint16_t DataToWrite)
{
Uint16_t addr_high=0;
Uint16_t addr_low=0;
Addr_high=WriteAddr> & gt; 8;
Addr_low=WriteAddr<8;
IIC_Start ();
IIC_Send_Byte (I2C_SLAVE_ADDR);//sending device address 0 x5c, write data
IIC_Wait_Ack ();
IIC_Send_Byte (addr_high % 256);//send high address
IIC_Wait_Ack ();
IIC_Send_Byte (addr_low % 256);//send low address
IIC_Wait_Ack ();
IIC_Send_Byte ((DataToWrite> & gt; 8));//send the high byte
IIC_Wait_Ack ();
IIC_Send_Byte ((DataToWrite<8));//send the low byte
IIC_Wait_Ack ();
IIC_Stop ();//to create a stop condition
Delay_ms_1 (10);
}
The question now is compiled, simply by not Master_Read2Byte plus () also not line, ask an expert to help see how should change, thank you very much!
CodePudding user response:
Master_Read2Byte defined in the input parameters and structure are different, one less l2sw_uint32 I2CxUint32_t Master_Read2Byte (uint8_t I2C_SLAVE_ADDR, uint16_t ReadAddr, uint16_t * ReadBuff)
Int (* iic_read) (l2sw_uint32 I2Cx, l2sw_uint8 SlaveAddr, l2sw_uint16 ReadAddr, l2sw_uint16 * ReadBuff);
CodePudding user response: