MODIFICATION HISTORY:
Ver Who Date Changes ----- --- ------- ----------------------------------------------- 1.01a rfp 10/19/01 release 1.01c ecm 12/05/02 new rev 1.01c rmm 05/14/03 Fixed diab compiler warnings relating to asserts. 1.01d jhl 10/08/03 Added general purpose output feature 1.02a jvb 12/13/05 Added CfgInitialize(), and made CfgInitialize() take a pointer to a config structure instead of a device id. Moved Initialize() into xiic_sinit.c, and have Initialize() call CfgInitialize() after it retrieved the config structure using the device id. Removed include of xparameters.h along with any dependencies on xparameters.h and the _g.c config table. 1.02a mta 03/09/06 Added a new function XIic_IsIicBusy() which returns whether IIC Bus is Busy or Free. 1.13a wgr 03/22/07 Converted to new coding style. 1.15a ktn 02/17/09 Fixed XIic_GetAddress() to return correct device address. 1.16a ktn 07/18/09 Updated the notes in XIic_Reset function to clearly indicate that only the Interrupt Registers are reset. 1.16a ktn 10/16/09 Updated the notes in the XIic_SelfTest() API to mention that the complete IIC core is Reset on giving a software reset to the IIC core. This issue is fixed in the latest version of the IIC core (some previous versions of the core only reset the Interrupt Logic/Registers), please see the Hw specification for further information. 2.00a ktn 10/22/09 Converted all register accesses to 32 bit access. Some of the macros have been renamed to remove _m from the name see the xiic_i.h and xiic_l.h file for further information (Example XIic_mClearIntr is now XIic_ClearIntr). Some of the macros have been renamed to be consistent, see the xiic_l.h file for further information (Example XIIC_WRITE_IIER is renamed as XIic_WriteIier). The driver has been updated to use the HAL APIs/macros. 2.07a adk 18/04/13 Updated the code to avoid unused variable warnings when compiling with the -Wextra -Wall flags. Changes done if files xiic.c and xiic_i.h. CR:705001.
#include "xiic.h"
#include "xiic_i.h"
Functions | |
int | XIic_CfgInitialize (XIic *InstancePtr, XIic_Config *Config, u32 EffectiveAddr) |
int | XIic_Start (XIic *InstancePtr) |
int | XIic_Stop (XIic *InstancePtr) |
void | XIic_Reset (XIic *InstancePtr) |
int | XIic_SetAddress (XIic *InstancePtr, int AddressType, int Address) |
u16 | XIic_GetAddress (XIic *InstancePtr, int AddressType) |
int | XIic_SetGpOutput (XIic *InstancePtr, u8 OutputValue) |
int | XIic_GetGpOutput (XIic *InstancePtr, u8 *OutputValuePtr) |
u32 | XIic_IsSlave (XIic *InstancePtr) |
void | XIic_SetRecvHandler (XIic *InstancePtr, void *CallBackRef, XIic_Handler FuncPtr) |
void | XIic_SetSendHandler (XIic *InstancePtr, void *CallBackRef, XIic_Handler FuncPtr) |
void | XIic_SetStatusHandler (XIic *InstancePtr, void *CallBackRef, XIic_StatusHandler FuncPtr) |
|
Initializes a specific XIic instance. The initialization entails:
The XIic_Start() function must be called after this function before the device is ready to send and receive data on the IIC bus. Before XIic_Start() is called, the interrupt control must connect the ISR routine to the interrupt handler. This is done by the user, and not XIic_Start() to allow the user to use an interrupt controller of their choice.
|
|
This function gets the addresses for the IIC device driver. The addresses include the device address that the device responds to as a slave, or the slave address to communicate with on the bus. The address returned has the same format whether 7 or 10 bits.
|
|
This function gets the contents of the General Purpose Output register for the IIC device driver. Note that the number of bits in this register is parameterizable in the hardware such that it may not exist. This function checks to ensure that it does exist to prevent bus errors.
|
|
A function to determine if the device is currently addressed as a slave.
|
|
Resets the IIC device.
|
|
This function sets the bus addresses. The addresses include the device address that the device responds to as a slave, or the slave address to communicate with on the bus. The IIC device hardware is built to allow either 7 or 10 bit slave addressing only at build time rather than at run time. When this device is a master, slave addressing can be selected at run time to match addressing modes for other bus devices. Addresses are represented as hex values with no adjustment for the data direction bit as the software manages address bit placement. Example: For a 7 address written to the device of 1010 011X where X is the transfer direction (send/recv), the address parameter for this function needs to be 01010011 or 0x53 where the correct bit alllignment will be handled for 7 as well as 10 bit devices. This is especially important as the bit placement is not handled the same depending on which options are used such as repeated start.
|
|
This function sets the contents of the General Purpose Output register for the IIC device driver. Note that the number of bits in this register is parameterizable in the hardware such that it may not exist. This function checks to ensure that it does exist to prevent bus errors, but does not ensure that the number of bits in the register are sufficient for the value being written (won't cause a bus error).
|
|
Sets the receive callback function, the receive handler, which the driver calls when it finishes receiving data. The number of bytes used to signal when the receive is complete is the number of bytes set in the XIic_Recv function. The handler executes in an interrupt context such that it must minimize the amount of processing performed such as transferring data to a thread context. The number of bytes received is passed to the handler as an argument.
|
|
Sets the send callback function, the send handler, which the driver calls when it receives confirmation of sent data. The handler executes in an interrupt context such that it must minimize the amount of processing performed such as transferring data to a thread context.
|
|
Sets the status callback function, the status handler, which the driver calls when it encounters conditions which are not data related. The handler executes in an interrupt context such that it must minimize the amount of processing performed such as transferring data to a thread context. The status events that can be returned are described in xiic.h.
|
|
This function starts the IIC device and driver by enabling the proper interrupts such that data may be sent and received on the IIC bus. This function must be called before the functions to send and receive data. Before XIic_Start() is called, the interrupt control must connect the ISR routine to the interrupt handler. This is done by the user, and not XIic_Start() to allow the user to use an interrupt controller of their choice. Start enables:
|
|
This function stops the IIC device and driver such that data is no longer sent or received on the IIC bus. This function stops the device by disabling interrupts. This function only disables interrupts within the device such that the caller is responsible for disconnecting the interrupt handler of the device from the interrupt source and disabling interrupts at other levels. Due to bus throttling that could hold the bus between messages when using repeated start option, stop will not occur when the device is actively sending or receiving data from the IIC bus or the bus is being throttled by this device, but instead return XST_IIC_BUS_BUSY.
|