62 #include <inc/hw_types.h>
63 #include <inc/hw_ints.h>
64 #include <inc/hw_memmap.h>
65 #include <inc/hw_i2c.h>
66 #include <inc/hw_sysctl.h>
86 #ifndef DRIVERLIB_GENERATE_ROM
87 #define I2CMasterInitExpClk NOROM_I2CMasterInitExpClk
88 #define I2CMasterErr NOROM_I2CMasterErr
89 #define I2CIntRegister NOROM_I2CIntRegister
90 #define I2CIntUnregister NOROM_I2CIntUnregister
98 #define I2C_MASTER_CMD_SINGLE_SEND \
100 #define I2C_MASTER_CMD_SINGLE_RECEIVE \
102 #define I2C_MASTER_CMD_BURST_SEND_START \
104 #define I2C_MASTER_CMD_BURST_SEND_CONT \
106 #define I2C_MASTER_CMD_BURST_SEND_FINISH \
108 #define I2C_MASTER_CMD_BURST_SEND_ERROR_STOP \
110 #define I2C_MASTER_CMD_BURST_RECEIVE_START \
112 #define I2C_MASTER_CMD_BURST_RECEIVE_CONT \
114 #define I2C_MASTER_CMD_BURST_RECEIVE_FINISH \
116 #define I2C_MASTER_CMD_BURST_RECEIVE_ERROR_STOP \
124 #define I2C_MASTER_ERR_NONE 0
125 #define I2C_MASTER_ERR_ADDR_ACK 0x00000004
126 #define I2C_MASTER_ERR_DATA_ACK 0x00000008
127 #define I2C_MASTER_ERR_ARB_LOST 0x00000010
134 #define I2C_SLAVE_ACT_NONE 0
135 #define I2C_SLAVE_ACT_RREQ 0x00000001 // Master has sent data
136 #define I2C_SLAVE_ACT_TREQ 0x00000002 // Master has requested data
137 #define I2C_SLAVE_ACT_RREQ_FBR 0x00000005 // Master has sent first byte
144 #define I2C_SLAVE_INT_STOP 0x00000004 // Stop Condition Interrupt.
145 #define I2C_SLAVE_INT_START 0x00000002 // Start Condition Interrupt.
146 #define I2C_SLAVE_INT_DATA 0x00000001 // Data Interrupt.
154 #ifdef DRIVERLIB_DEBUG
170 I2CBaseValid(uint32_t ui32Base)
233 ASSERT(I2CBaseValid(ui32Base));
283 ASSERT(I2CBaseValid(ui32Base));
284 ASSERT(!(ui8SlaveAddr & 0x80));
289 HWREG(ui32Base +
I2C_O_MSA) = (ui8SlaveAddr << 1) | bReceive;
309 ASSERT(I2CBaseValid(ui32Base));
339 ASSERT(I2CBaseValid(ui32Base));
372 ASSERT(I2CBaseValid(ui32Base));
408 ASSERT(I2CBaseValid(ui32Base));
435 __STATIC_INLINE uint32_t
441 ASSERT(I2CBaseValid(ui32Base));
467 ASSERT(I2CBaseValid(ui32Base));
510 ASSERT(I2CBaseValid(ui32Base));
535 ASSERT(I2CBaseValid(ui32Base));
571 ASSERT(I2CBaseValid(ui32Base));
603 ASSERT(I2CBaseValid(ui32Base));
611 return((HWREG(ui32Base +
I2C_O_MMIS)) ?
true :
false);
615 return((HWREG(ui32Base +
I2C_O_MRIS)) ?
true :
false);
636 ASSERT(I2CBaseValid(ui32Base));
672 ASSERT(I2CBaseValid(ui32Base));
673 ASSERT(!(ui8SlaveAddr & 0x80));
704 ASSERT(I2CBaseValid(ui32Base));
705 ASSERT(!(ui8SlaveAddr & 0x80));
730 ASSERT(I2CBaseValid(ui32Base));
759 __STATIC_INLINE uint32_t
765 ASSERT(I2CBaseValid(ui32Base));
785 __STATIC_INLINE uint32_t
791 ASSERT(I2CBaseValid(ui32Base));
817 ASSERT(I2CBaseValid(ui32Base));
851 ASSERT(I2CBaseValid(ui32Base));
859 ui32Val |= ui32IntFlags;
889 ASSERT(I2CBaseValid(ui32Base));
897 ui32Val &= ~ui32IntFlags;
934 ASSERT(I2CBaseValid(ui32Base));
962 __STATIC_INLINE uint32_t
968 ASSERT(I2CBaseValid(ui32Base));
1005 extern void I2CIntRegister(uint32_t ui32Base,
void (*pfnHandler)(
void));
1031 #ifndef DRIVERLIB_NOROM
1033 #ifdef ROM_I2CMasterInitExpClk
1034 #undef I2CMasterInitExpClk
1035 #define I2CMasterInitExpClk ROM_I2CMasterInitExpClk
1037 #ifdef ROM_I2CMasterErr
1039 #define I2CMasterErr ROM_I2CMasterErr
1041 #ifdef ROM_I2CIntRegister
1042 #undef I2CIntRegister
1043 #define I2CIntRegister ROM_I2CIntRegister
1045 #ifdef ROM_I2CIntUnregister
1046 #undef I2CIntUnregister
1047 #define I2CIntUnregister ROM_I2CIntUnregister
__STATIC_INLINE void I2CSlaveIntEnable(uint32_t ui32Base, uint32_t ui32IntFlags)
Enables individual I2C Slave interrupt sources.
#define I2C_SLAVE_INT_STOP
__STATIC_INLINE uint32_t I2CSlaveIntStatus(uint32_t ui32Base, bool bMasked)
Gets the current I2C Slave interrupt status.
__STATIC_INLINE void I2CSlaveDisable(uint32_t ui32Base)
Disables the I2C slave block.
#define I2C_MASTER_CMD_BURST_SEND_START
__STATIC_INLINE void I2CMasterControl(uint32_t ui32Base, uint32_t ui32Cmd)
Controls the state of the I2C Master module.
__STATIC_INLINE void I2CMasterDisable(uint32_t ui32Base)
Disables the I2C master block.
#define I2C_MASTER_CMD_BURST_SEND_ERROR_STOP
__STATIC_INLINE void I2CSlaveEnable(uint32_t ui32Base)
Enables the I2C Slave block.
__STATIC_INLINE void I2CSlaveIntClear(uint32_t ui32Base, uint32_t ui32IntFlags)
Clears I2C Slave interrupt sources.
__STATIC_INLINE void I2CMasterSlaveAddrSet(uint32_t ui32Base, uint8_t ui8SlaveAddr, bool bReceive)
Sets the address that the I2C Master will place on the bus.
#define I2C_SLAVE_INT_START
void I2CMasterInitExpClk(uint32_t ui32Base, uint32_t ui32I2CClk, bool bFast)
Initializes the I2C Master block.
__STATIC_INLINE uint32_t I2CSlaveDataGet(uint32_t ui32Base)
Receives a byte that has been sent to the I2C Slave.
#define I2C_SLAVE_INT_DATA
__STATIC_INLINE void I2CMasterIntEnable(uint32_t ui32Base)
Enables the I2C Master interrupt.
__STATIC_INLINE bool I2CMasterIntStatus(uint32_t ui32Base, bool bMasked)
Gets the current I2C Master interrupt status.
__STATIC_INLINE bool I2CMasterBusBusy(uint32_t ui32Base)
Indicates whether or not the I2C bus is busy.
#define I2C_MASTER_CMD_SINGLE_SEND
__STATIC_INLINE void I2CSlaveIntDisable(uint32_t ui32Base, uint32_t ui32IntFlags)
Disables individual I2C Slave interrupt sources.
#define I2C_MASTER_CMD_BURST_RECEIVE_CONT
__STATIC_INLINE void I2CMasterEnable(uint32_t ui32Base)
Enables the I2C Master block.
__STATIC_INLINE void I2CMasterIntDisable(uint32_t ui32Base)
Disables the I2C Master interrupt.
__STATIC_INLINE uint32_t I2CSlaveStatus(uint32_t ui32Base)
Gets the I2C Slave module status.
#define I2C_MASTER_CMD_BURST_SEND_FINISH
#define I2C_MASTER_CMD_BURST_SEND_CONT
#define I2C_MASTER_CMD_BURST_RECEIVE_FINISH
uint32_t I2CMasterErr(uint32_t ui32Base)
Gets the error status of the I2C Master module.
__STATIC_INLINE void I2CSlaveInit(uint32_t ui32Base, uint8_t ui8SlaveAddr)
Initializes the I2C Slave block.
#define I2C_MASTER_CMD_BURST_RECEIVE_START
__STATIC_INLINE uint32_t I2CMasterDataGet(uint32_t ui32Base)
Receives a byte that has been sent to the I2C Master.
__STATIC_INLINE bool I2CMasterBusy(uint32_t ui32Base)
Indicates whether or not the I2C Master is busy.
__STATIC_INLINE void I2CMasterDataPut(uint32_t ui32Base, uint8_t ui8Data)
Transmits a byte from the I2C Master.
void I2CIntRegister(uint32_t ui32Base, void(*pfnHandler)(void))
Registers an interrupt handler for the I2C module.
__STATIC_INLINE void I2CSlaveDataPut(uint32_t ui32Base, uint8_t ui8Data)
Transmits a byte from the I2C Slave.
__STATIC_INLINE void I2CSlaveAddressSet(uint32_t ui32Base, uint8_t ui8SlaveAddr)
Sets the I2C slave address.
#define I2C_MASTER_CMD_BURST_RECEIVE_ERROR_STOP
void CPUdelay(uint32_t ui32Count)
Provide a small delay.
__STATIC_INLINE void I2CMasterIntClear(uint32_t ui32Base)
Clears I2C Master interrupt sources.
void I2CIntUnregister(uint32_t ui32Base)
Unregisters an interrupt handler for the I2C module.