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... | |
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.
| 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>).
| freqdiv | This 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. |
| 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.
| addr | The 7-bit address you wish to read the buffer from. |
| buf | A pointer to the BYTE buffer you wish to read to. |
| num | The number of bytes to read. |
| stop | If 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. |
| 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.
| addr | The address of the slave device we wish to communicate with on the bus. |
| Read_Not_Write | Select True to read, false to write. Note: You can use I2C_START_READ or I2C_START_WRITE as values. |
| ticks_to_wait | The 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. |
| 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.
| addr | The 7-bit address you wish to send the buffer to. |
| buf | A pointer to the BYTE buffer you wish to write from. |
| num | The number of bytes to write. |
| stop | If 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. |