NetBurner 3.0
Simple NetBurner I2C Functions

Functions

void Master_I2CInit (uint8_t freqdiv=0x3C)
 This is the I2C initialization routine. More...
 
uint8_t Master_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 and stop bit. More...
 
uint8_t Master_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 need of a start and stop bit. More...
 
uint8_t Master_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. More...
 

Detailed Description

The following functions are a used to easily communicate on the I2C bus without the need of configuring timeouts or terminations. These functions will send or receive buffers instead of uint8_t like the advanced functions.

Function Documentation

◆ Master_I2CInit()

void Master_I2CInit ( uint8_t  freqdiv = 0x3C)

This is the I2C initialization routine.

Will assign 'slave_Addr' to be the address when module addressed by another master on the I2C bus. Default Address if parameter not included is 0x08.

For MOD54415 Internal bus clock which = (250MHZ (sys clock)/2) / freqdiv to give max baud rate of the master mode I2C bus. Values of freqdiv are found in a the I2FDR table found in the I2C section of the MCF54415 reference manual provided by Freescale (found in <nburn_install>).

Parameters
freqdivThis value is used in the Coldfire I2FDR as a prescaler of the system clock to generate a max baud rate of the master mode I2C bus. All the processors are set to be approximately 100Kbits by default, which is the max I2C standard speed.
See also
Master_I2CSendBuf()
Master_I2CReadBuf()

◆ Master_I2CReadBuf()

uint8_t Master_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 need of a start and stop bit.

Reads 'num' uint8_tS of buffer 'buf' on the I2C bus to address 'addr'. The transmission is then terminated with a stop signal if user either calls the function with no 'stop' parameter or a stop = true. If user wishes to terminate differently, such as a restart, then 'stop' can be set false and a NetBurner advanced I2Cfunction can be used for termination.

Parameters
addrThe 7-bit address you wish to read the buffer from.
bufA pointer to the BYTE buffer you wish to read to.
numThe number of bytes to read.
stopIf true, Terminate communication with stop. Otherwise, do not terminate transmission. This is useful if the user wishes to send a restart instead of a stop.
Returns
i2cMasterReturnValues
See also
Master_I2CInit()
Master_I2CSendBuf()

◆ Master_I2CRestart()

uint8_t Master_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.

This is used instead of a 'stop' and will allow the user to communicate on bus again without giving up control of the bus first. Note: This function should only be used when in master mode and you have control of the bus.

Parameters
addrThe address of the slave device we wish to communicate with on the bus.
Read_Not_WriteSelect True to read, false to write. Note: You can use I2C_START_READ or I2C_START_WRITE as values.
ticks_to_waitThe number of ticks to wait on restart before failing. This includes the time it takes to receive an an ACK from the addressed slave device.
Returns
i2cMasterReturnValues
See also
Master_I2CStart()
Master_I2CStop()

◆ Master_I2CSendBuf()

uint8_t Master_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 and stop bit.

Sends 'num' uint8_tS of buffer 'buf' on the I2C bus to address 'addr'. The transmission is then terminated with a stop signal if user either calls the function with no 'stop' parameter or a stop = true. If the user wishes to terminate differently, such as a restart, then 'stop' can be set false and a NetBurner advanced I2Cfunction can be used for termination.

Parameters
addrThe 7-bit address you wish to send the buffer to.
bufA pointer to the BYTE buffer you wish to write from.
numThe number of bytes to write.
stopIf true, Terminate communication with stop. Otherwise, do not terminate transmission. This is useful if the user wishes to send a restart instead of a stop.
Returns
i2cMasterReturnValues
See also
Master_I2CInit()
Master_I2CReadBuf()