29 #define _I2CMULTI_H // if this include guard is changed, you must update the check in i2cmaster.h 32 #error i2cmaster.h included previously. Only one of i2cmulti.h and i2cmaster.h may be included. 37 #include <basictypes.h> 46 #define I2C_MAX_BUF_SIZE (64) 54 #define I2C_RX_TX_TIMEOUT (5) 55 #define I2C_START_TIMEOUT (20) 58 #define I2C_SLAVE_TX_TERM_CHAR (0) 66 #define I2C_NEXT_WRITE_OK (1) 67 #define I2C_NEXT_READ_OK (2) 68 #define I2C_MASTER_OK (3) 69 #define I2C_TIMEOUT (4) 70 #define I2C_BUS_NOT_AVAIL (5) 71 #define I2C_NOT_READY (6) 72 #define I2C_LOST_ARB (7) 73 #define I2C_LOST_ARB_ADD (8) 74 #define I2C_NO_LINK_RX_ACK (9) 84 #define I2CInit Multi_I2CInit 85 #define I2CSendBuf Multi_I2CSendBuf 86 #define I2CReadBuf Multi_I2CReadBuf 87 #define I2CRestart Multi_I2CRestart 88 #define I2CStart Multi_I2CStart 89 #define I2CStop Multi_I2CStop 90 #define I2CSend Multi_I2CSend 91 #define I2CRead Multi_I2CRead 92 #define I2CResetPeripheral Multi_ResetPeripheral 100 #define I2C_START_READ (1) 101 #define I2C_START_WRITE (0) 104 // Set up different platform sim references to i2c struct 105 #if defined(MCF5441X) 106 #define I2C_SR sim2.i2c0.i2sr 107 #define I2C_CR sim2.i2c0.i2cr 108 #define I2C_DR sim2.i2c0.i2dr 109 #define I2C_FDR sim2.i2c0.i2fdr 110 #define I2C_ADR sim2.i2c0.i2adr 111 #elif defined(MCF5213) 112 #define I2C_SR sim.i2c.i2sr 113 #define I2C_CR sim.i2c.i2cr 114 #define I2C_DR sim.i2c.i2dr 115 #define I2C_FDR sim.i2c.i2fdr 116 #define I2C_ADR sim.i2c.i2ar 117 #elif defined(MCF5208) 118 #define I2C_SR sim.i2c.i2sr 119 #define I2C_CR sim.i2c.i2cr 120 #define I2C_DR sim.i2c.i2dr 121 #define I2C_FDR sim.i2c.i2fdr 122 #define I2C_ADR sim.i2c.i2adr 124 #define I2C_SR sim.i2c.sr 125 #define I2C_CR sim.i2c.cr 126 #define I2C_DR sim.i2c.dr 127 #define I2C_FDR sim.i2c.fdr 128 #define I2C_ADR sim.i2c.adr 162 #if (defined MCF5270 || defined MCF5234 || defined MCF5208) 163 void Multi_I2CInit(uint8_t slave_Addr = 0x08, uint8_t freqdiv = 0x16);
164 #elif (defined MCF5213 || defined MCF5282) 165 void Multi_I2CInit(uint8_t slave_Addr = 0x08, uint8_t freqdiv = 0x15);
166 #elif (defined MCF52234) 167 void Multi_I2CInit(uint8_t slave_Addr = 0x08, uint8_t freqdiv = 0x37);
168 #elif (defined MCF5441X) 169 void Multi_I2CInit(uint8_t slave_Addr = 0x08, uint8_t freqdiv = 0x3C);
171 #error Multi_I2CInit declaration missing for defined platform 193 uint8_t
Multi_I2CSendBuf(uint8_t addr, puint8_t buf,
int num,
bool stop =
true);
215 uint8_t
Multi_I2CReadBuf(uint8_t addr, puint8_t buf,
int num,
bool stop =
true);
393 void Multi_ResetPeripheral();
396 struct I2C_Slave_Record
398 OS_SEM I2C_Slave_RX_Semaphore;
400 volatile uint8_t *pI2CRxbuf;
401 volatile uint8_t *pI2CTxbuf;
403 volatile uint32_t I2Crx_put;
404 volatile uint32_t I2Crx_get;
406 volatile uint32_t I2Ctx_put;
407 volatile uint32_t I2Ctx_get;
414 #define I2C_SR_BUSY (((0x20 & I2C_SR) == 0x20)) 415 #define I2C_CR_SLAVE (((0x20 & I2C_CR) == 0x00)) 416 #define I2C_SR_ARB_LOST (((0x10 & I2C_SR) == 0x10)) 417 #define I2C_SR_ADRES_AS_SLAVE (((0x40 & I2C_SR) == 0x40)) 418 #define I2C_SR_SLAVE_TX (((0x04 & I2C_SR) == 0x04)) 419 #define I2C_CR_TX (((0x10 & I2C_CR) == 0x10)) 420 #define I2C_SR_RX_ACK (((0x01 & I2C_SR) == 0x00)) 421 #define I2C_CR_RX_ACK (((0x08 & I2C_CR) == 0x00)) 422 #define I2C_SET_NO_ACK ((I2C_CR |= 0x08)) 423 #define I2C_SET_ACK ((I2C_CR &= 0xF7)) 424 #define I2C_SET_TX ((I2C_CR |= 0x10)) 425 #define I2C_SET_RX ((I2C_CR &= 0xEF)) 426 #define I2C_SET_REPEAT_START ((I2C_CR |= 0x04)) 427 #define I2C_CLR_ARB_LOST ((I2C_SR &= 0xEF)) 434 #endif // #ifdef _I2CMASTER_H 435 #endif // #ifndef _I2CMULTI_H NetBurner Real-Time Operating System API.
void(* I2C_SlaveRX_Callback)(uint8_t RX_Data)
If this callback is pointed to a function then it will be called when storing the data received from ...
Definition: i2cmulti.cpp:38
uint8_t Multi_I2CRead(puint8_t val, uint32_t ticks_to_wait=I2C_RX_TX_TIMEOUT)
This function reads a single byte in master mode from the I2C bus.
Definition: i2cmulti.cpp:645
uint8_t I2CFillSlaveTXBuf(puint8_t buf, uint32_t num, bool restart=true)
This function is used to fill the I2C slave TX buffer.
Definition: i2cmulti.cpp:790
uint8_t Multi_I2CRestart(uint8_t addr, bool Read_Not_Write, uint32_t ticks_to_wait=I2C_RX_TX_TIMEOUT)
Send a restart of communication with a slave device after finished communication on the bus...
Definition: i2cmulti.cpp:600
uint8_t Multi_I2CStop(uint32_t ticks_to_wait=I2C_RX_TX_TIMEOUT)
This function ends communication and releases control of the I2C bus. This function puts your NetBurn...
Definition: i2cmulti.cpp:322
Semaphores are used to control access to shared resource critical section, or to communicate between ...
Definition: nbrtos.h:293
uint8_t I2CGetByte()
This function will pend on a slave receive I2C semaphore.
Definition: i2cmulti.cpp:830
bool I2CRXAvail()
This function determines if there is data available in the I2C slave receive buffer.
Definition: i2cmulti.cpp:844
void(* I2C_SlaveTX_NAK_Callback)()
If this callback is pointed to a function, then it will be called when the receiving master device se...
Definition: i2cmulti.cpp:37
uint32_t I2CTXAvail()
This function determines the free space available in the I2C slave TX buffer.
Definition: i2cmulti.cpp:856
uint8_t Multi_I2CSend(uint8_t val, uint32_t ticks_to_wait=I2C_RX_TX_TIMEOUT)
This function sends a single byte in master mode on the I2C bus.
Definition: i2cmulti.cpp:352
uint8_t Multi_I2CSendBuf(uint8_t addr, puint8_t buf, int num, bool stop=true)
This function sends a buffer to an address on the I2C bus in master mode without the need of a start ...
Definition: i2cmulti.cpp:677
#define I2C_RX_TX_TIMEOUT
Ticks allowed before timeout of a single byte transmission.
Definition: i2cmulti.h:54
#define I2C_START_TIMEOUT
Ticks allowed before timeout when attempting start on I2C bus.
Definition: i2cmulti.h:55
uint8_t(* I2C_SlaveTX_Callback)()
If this callback is pointed to a function, then it will be called when retrieving the data to be sent...
Definition: i2cmulti.cpp:36
uint8_t Multi_I2CStart(uint8_t addr, bool Read_Not_Write, uint32_t ticks_to_wait=I2C_START_TIMEOUT)
This function is used to obtain an I2C bus and start communication in master mode.
Definition: i2cmulti.cpp:495
uint8_t Multi_I2CReadBuf(uint8_t addr, puint8_t buf, int num, bool stop=true)
This function allows a buffer to be read from an address on the I2C bus in master mode without the ne...
Definition: i2cmulti.cpp:728
void Multi_I2CInit(uint8_t slave_Addr=0x08, uint8_t freqdiv=0x3C)
This is the I2C initialization routine.
Definition: i2cmulti.cpp:399