#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) |
u32 | XIic_IsIicBusy (XIic *InstancePtr) |
Contains required functions for the XIic component. See xiic.h for more information on the driver.
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.
int XIic_CfgInitialize | ( | XIic * | InstancePtr, | |
XIic_Config * | Config, | |||
u32 | EffectiveAddr | |||
) |
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.
InstancePtr | is a pointer to the XIic instance to be worked on. | |
Config | is a reference to a structure containing information about a specific IIC device. This function can initialize multiple instance objects with the use of multiple calls giving different Config information on each call. | |
EffectiveAddr | is the device base address in the virtual memory address space. The caller is responsible for keeping the address mapping from EffectiveAddr to the device physical base address unchanged once this function is invoked. Unexpected errors may occur if the address mapping changes after this function is called. If address translation is not used, use Config->BaseAddress for this parameters, passing the physical address instead. |
u16 XIic_GetAddress | ( | XIic * | InstancePtr, | |
int | AddressType | |||
) |
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.
InstancePtr | is a pointer to the XIic instance to be worked on. | |
AddressType | indicates which address, the address which this responds to on the IIC bus as a slave, or the slave address to communicate with when this device is a master. One of the following values must be contained in this argument.
XII_ADDR_TO_SEND_TYPE Slave being addressed as a master XII_ADDR_TO_RESPOND_TYPE Slave address to respond to as a slave If neither of the two valid arguments are used, the function returns the address of the slave device |
int XIic_GetGpOutput | ( | XIic * | InstancePtr, | |
u8 * | OutputValuePtr | |||
) |
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.
InstancePtr | is a pointer to the XIic instance to be worked on. | |
OutputValuePtr | contains the value which was read from the register. |
The OutputValuePtr is also an output as it contains the value read.
u32 XIic_IsIicBusy | ( | XIic * | InstancePtr | ) |
u32 XIic_IsSlave | ( | XIic * | InstancePtr | ) |
A function to determine if the device is currently addressed as a slave.
InstancePtr | is a pointer to the XIic instance to be worked on. |
void XIic_Reset | ( | XIic * | InstancePtr | ) |
Resets the IIC device.
InstancePtr | is a pointer to the XIic instance to be worked on. |
int XIic_SetAddress | ( | XIic * | InstancePtr, | |
int | AddressType, | |||
int | Address | |||
) |
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.
InstancePtr | is a pointer to the XIic instance to be worked on. | |
AddressType | indicates which address is being modified, the address which this device responds to on the IIC bus as a slave, or the slave address to communicate with when this device is a master. One of the following values must be contained in this argument.
XII_ADDR_TO_SEND_TYPE Slave being addressed by a this master XII_ADDR_TO_RESPOND_TYPE Address to respond to as a slave device | |
Address | contains the address to be set, 7 bit or 10 bit address. A ten bit address must be within the range: 0 - 1023 and a 7 bit address must be within the range 0 - 127. |
Upper bits of 10-bit address is written only when current device is built as a ten bit device.
int XIic_SetGpOutput | ( | XIic * | InstancePtr, | |
u8 | OutputValue | |||
) |
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).
InstancePtr | is a pointer to the XIic instance to be worked on. | |
OutputValue | contains the value to be written to the register. |
void XIic_SetRecvHandler | ( | XIic * | InstancePtr, | |
void * | CallBackRef, | |||
XIic_Handler | FuncPtr | |||
) |
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.
InstancePtr | is a pointer to the XIic instance to be worked on. | |
CallBackRef | is the upper layer callback reference passed back when the callback function is invoked. | |
FuncPtr | is the pointer to the callback function. |
void XIic_SetSendHandler | ( | XIic * | InstancePtr, | |
void * | CallBackRef, | |||
XIic_Handler | FuncPtr | |||
) |
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.
InstancePtr | the pointer to the XIic instance to be worked on. | |
CallBackRef | the upper layer callback reference passed back when the callback function is invoked. | |
FuncPtr | the pointer to the callback function. |
void XIic_SetStatusHandler | ( | XIic * | InstancePtr, | |
void * | CallBackRef, | |||
XIic_StatusHandler | FuncPtr | |||
) |
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.
InstancePtr | points to the XIic instance to be worked on. | |
CallBackRef | is the upper layer callback reference passed back when the callback function is invoked. | |
FuncPtr | is the pointer to the callback function. |
int XIic_Start | ( | XIic * | InstancePtr | ) |
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:
InstancePtr | is a pointer to the XIic instance to be worked on. |
The device interrupt is connected to the interrupt controller, but no "messaging" interrupts are enabled. Addressed as Slave is enabled to reception of messages when this devices address is written to the bus. The correct messaging interrupts are enabled when sending or receiving via the IicSend() and IicRecv() functions. No action is required by the user to control any IIC interrupts as the driver completely manages all 8 interrupts. Start and Stop control the ability to use the device. Stopping the device completely stops all device interrupts from the processor.
int XIic_Stop | ( | XIic * | InstancePtr | ) |
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.
InstancePtr | is a pointer to the XIic instance to be worked on. |
Copyright © 1995-2014 Xilinx, Inc. All rights reserved.