Classes |
struct | XIic_Config |
struct | XIicStats |
struct | XIic |
Defines |
#define | XIIC_H |
#define | XII_ADDR_TO_SEND_TYPE 1 |
#define | XII_ADDR_TO_RESPOND_TYPE 2 |
|
The following options may be specified or retrieved for the device and enable/disable additional features of the IIC bus. Each of the options are bit fields such that more than one may be specified.
|
#define | XII_GENERAL_CALL_OPTION 0x00000001 |
#define | XII_REPEATED_START_OPTION 0x00000002 |
#define | XII_SEND_10_BIT_OPTION 0x00000004 |
|
The following status events occur during IIC bus processing and are passed to the status callback. Each event is only valid during the appropriate processing of the IIC bus. Each of these events are bit fields such that more than one may be specified.
|
#define | XII_BUS_NOT_BUSY_EVENT 0x00000001 |
#define | XII_ARB_LOST_EVENT 0x00000002 |
#define | XII_SLAVE_NO_ACK_EVENT 0x00000004 |
#define | XII_MASTER_READ_EVENT 0x00000008 |
#define | XII_MASTER_WRITE_EVENT 0x00000010 |
#define | XII_GENERAL_CALL_EVENT 0x00000020 |
Typedefs |
typedef void(* | XIic_Handler )(void *CallBackRef, int ByteCount) |
typedef void(* | XIic_StatusHandler )(void *CallBackRef, int StatusEvent) |
Functions |
int | XIic_Initialize (XIic *InstancePtr, u16 DeviceId) |
XIic_Config * | XIic_LookupConfig (u16 DeviceId) |
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) |
void | XIic_InterruptHandler (void *InstancePtr) |
int | XIic_MasterRecv (XIic *InstancePtr, u8 *RxMsgPtr, int ByteCount) |
int | XIic_MasterSend (XIic *InstancePtr, u8 *TxMsgPtr, int ByteCount) |
int | XIic_DynMasterRecv (XIic *InstancePtr, u8 *RxMsgPtr, u8 ByteCount) |
int | XIic_DynMasterSend (XIic *InstancePtr, u8 *TxMsgPtr, u8 ByteCount) |
int | XIic_DynamicInitialize (XIic *InstancePtr) |
void | XIic_SlaveInclude (void) |
int | XIic_SlaveRecv (XIic *InstancePtr, u8 *RxMsgPtr, int ByteCount) |
int | XIic_SlaveSend (XIic *InstancePtr, u8 *TxMsgPtr, int ByteCount) |
void | XIic_GetStats (XIic *InstancePtr, XIicStats *StatsPtr) |
void | XIic_ClearStats (XIic *InstancePtr) |
int | XIic_SelfTest (XIic *InstancePtr) |
u32 | XIic_IsIicBusy (XIic *InstancePtr) |
void | XIic_SetOptions (XIic *InstancePtr, u32 Options) |
u32 | XIic_GetOptions (XIic *InstancePtr) |
void | XIic_MultiMasterInclude (void) |
#define XII_GENERAL_CALL_OPTION 0x00000001 |
XII_GENERAL_CALL_OPTION The general call option allows an IIC slave to
recognized the general call address. The status
handler is called as usual indicating the device
has been addressed as a slave with a general
call. It is the application's responsibility to
perform any special processing for the general
call.
XII_REPEATED_START_OPTION The repeated start option allows multiple
messages to be sent/received on the IIC bus
without rearbitrating for the bus. The messages
are sent as a series of messages such that the
option must be enabled before the 1st message of
the series, to prevent an stop condition from
being generated on the bus, and disabled before
the last message of the series, to allow the
stop condition to be generated.
XII_SEND_10_BIT_OPTION The send 10 bit option allows 10 bit addresses
to be sent on the bus when the device is a
master. The device can be configured to respond
as to 7 bit addresses even though it may be
communicating with other devices that support 10
bit addresses. When this option is not enabled,
only 7 bit addresses are sent on the bus.
int XIic_CfgInitialize |
( |
XIic * |
InstancePtr, |
|
|
XIic_Config * |
Config, |
|
|
u32 |
EffectiveAddr | |
|
) |
| | |
Initializes a specific XIic instance. The initialization entails:
- Initialize the driver to allow access to the device registers and initialize other subcomponents necessary for the operation of the device.
- Default options to:
- 7-bit slave addressing
- Send messages as a slave device
- Repeated start off
- General call recognition disabled
- Clear messageing and error statistics
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.
- Parameters:
-
| 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. |
- Returns:
- XST_SUCCESS when successful
- XST_DEVICE_IS_STARTED indicates the device is started (i.e. interrupts enabled and messaging is possible). Must stop before re-initialization is allowed.
- Note:
- None.
int XIic_Initialize |
( |
XIic * |
InstancePtr, |
|
|
u16 |
DeviceId | |
|
) |
| | |
Initializes a specific XIic instance. The initialization entails:
- Check the device has an entry in the configuration table.
- Initialize the driver to allow access to the device registers and initialize other subcomponents necessary for the operation of the device.
- Default options to:
- 7-bit slave addressing
- Send messages as a slave device
- Repeated start off
- General call recognition disabled
- Clear messageing and error statistics
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.
- Parameters:
-
| InstancePtr | is a pointer to the XIic instance to be worked on. |
| DeviceId | is the unique id of the device controlled by this XIic instance. Passing in a device id associates the generic XIic instance to a specific device, as chosen by the caller or application developer. |
- Returns:
- XST_SUCCESS when successful
- XST_DEVICE_NOT_FOUND indicates the given device id isn't found
- XST_DEVICE_IS_STARTED indicates the device is started (i.e. interrupts enabled and messaging is possible). Must stop before re-initialization is allowed.
- Note:
- None.
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.
- Parameters:
-
| 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. |
- Returns:
- XST_SUCCESS is returned if the address was successfully set.
- XST_IIC_NO_10_BIT_ADDRESSING indicates only 7 bit addressing supported.
- XST_INVALID_PARAM indicates an invalid parameter was specified.
- Note:
Upper bits of 10-bit address is written only when current device is built as a ten bit device.
void XIic_SetOptions |
( |
XIic * |
InstancePtr, |
|
|
u32 |
NewOptions | |
|
) |
| | |
This function sets the options for the IIC device driver. The options control how the device behaves relative to the IIC bus. If an option applies to how messages are sent or received on the IIC bus, it must be set prior to calling functions which send or receive data.
To set multiple options, the values must be ORed together. To not change existing options, read/modify/write with the current options using XIic_GetOptions().
USAGE EXAMPLE:
Read/modify/write to enable repeated start:
u8 Options;
Options = XIic_GetOptions(&Iic);
XIic_SetOptions(&Iic, Options | XII_REPEATED_START_OPTION);
Disabling General Call:
Options = XIic_GetOptions(&Iic);
XIic_SetOptions(&Iic, Options &= ~XII_GENERAL_CALL_OPTION);
- Parameters:
-
| InstancePtr | is a pointer to the XIic instance to be worked on. |
| NewOptions | are the options to be set. See xiic.h for a list of the available options. |
- Returns:
- None.
- Note:
Sending or receiving messages with repeated start enabled, and then disabling repeated start, will not take effect until another master transaction is completed. i.e. After using repeated start, the bus will continue to be throttled after repeated start is disabled until a master transaction occurs allowing the IIC to release the bus.
Options enabled will have a 1 in its appropriate bit position.
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.
- Parameters:
-
| 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. |
- Returns:
- None.
- Note:
- The handler is called within interrupt context .
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:
- IIC device
- Interrupts:
- Addressed as slave to allow messages from another master
- Arbitration Lost to detect Tx arbitration errors
- Global IIC interrupt
- Parameters:
-
| InstancePtr | is a pointer to the XIic instance to be worked on. |
- Returns:
- XST_SUCCESS always.
- Note:
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.
- Parameters:
-
| InstancePtr | is a pointer to the XIic instance to be worked on. |
- Returns:
- XST_SUCCESS indicates all IIC interrupts are disabled. No messages can be received or transmitted until XIic_Start() is called.
- XST_IIC_BUS_BUSY indicates this device is currently engaged in message traffic and cannot be stopped.
- Note:
- None.