71#define _DEFAULT_SOURCE
89static unsigned RecvData(UINTPTR BaseAddress, u8 *BufferPtr,
unsigned ByteCount,
91static unsigned SendData(UINTPTR BaseAddress, u8 *BufferPtr,
unsigned ByteCount,
117unsigned XIic_Recv(UINTPTR BaseAddress, u8 Address, u8 *BufferPtr,
118 unsigned ByteCount, u8 Option) {
120 unsigned RemainingByteCount;
121 volatile u32 StatusReg;
153 if (ByteCount == 1) {
176 CntlReg &= ~XIIC_CR_DIR_IS_TX_MASK;
177 if (ByteCount == 1) {
190 RemainingByteCount = RecvData(BaseAddress, BufferPtr, ByteCount, Option);
207 return ByteCount - RemainingByteCount;
236static unsigned RecvData(UINTPTR BaseAddress, u8 *BufferPtr,
unsigned ByteCount,
244 while (ByteCount > 0) {
250 if (ByteCount == 1) {
271 if (IntrStatus & IntrStatusMask) {
283 if (ByteCount == 1) {
301 if (ByteCount == 2) {
373unsigned XIic_Send(UINTPTR BaseAddress, u8 Address, u8 *BufferPtr,
374 unsigned ByteCount, u8 Option) {
375 unsigned RemainingByteCount;
377 volatile u32 StatusReg;
418 time_t s = time(NULL);
422 time_t n = time(NULL);
424 printf(
"IIC timeout bus not busy.\n");
443 RemainingByteCount = SendData(BaseAddress, BufferPtr, ByteCount, Option);
470 return ByteCount - RemainingByteCount;
494static unsigned SendData(UINTPTR BaseAddress, u8 *BufferPtr,
unsigned ByteCount,
502 while (ByteCount > 0) {
642 if (BusyCount++ > 10000) {
u32 XIic_CheckIsBusBusy(UINTPTR BaseAddress)
unsigned XIic_Recv(UINTPTR BaseAddress, u8 Address, u8 *BufferPtr, unsigned ByteCount, u8 Option)
unsigned XIic_Send(UINTPTR BaseAddress, u8 Address, u8 *BufferPtr, unsigned ByteCount, u8 Option)
u32 XIic_WaitBusFree(UINTPTR BaseAddress)
#define XIIC_CR_REG_OFFSET
#define XIIC_SR_BUS_BUSY_MASK
#define XIIC_INTR_BNB_MASK
#define XIIC_CR_REPEATED_START_MASK
#define XIIC_DTR_REG_OFFSET
#define XIIC_CR_NO_ACK_MASK
#define XIic_WriteReg(BaseAddress, RegOffset, RegisterValue)
#define XIic_Send7BitAddress(BaseAddress, SlaveAddress, Operation)
#define XIIC_DRR_REG_OFFSET
#define XIIC_WRITE_OPERATION
#define XIIC_SR_REG_OFFSET
#define XIIC_INTR_TX_ERROR_MASK
#define XIIC_CR_ENABLE_DEVICE_MASK
#define XIIC_SR_ADDR_AS_SLAVE_MASK
#define XIic_ReadReg(BaseAddress, RegOffset)
#define XIIC_READ_OPERATION
#define XIIC_INTR_ARB_LOST_MASK
#define XIIC_INTR_RX_FULL_MASK
#define XIIC_RFD_REG_OFFSET
#define XIIC_INTR_TX_EMPTY_MASK
#define XIIC_REPEATED_START
#define XIIC_CR_DIR_IS_TX_MASK
#define XIic_ReadIisr(BaseAddress)
#define XIic_ClearIisr(BaseAddress, InterruptMask)
#define XIIC_CR_MSMS_MASK