f28335 - I2c Module
f28335 - I2c Module
f28335 - I2c Module
Abstract
Skype/Gmail: phien.ntace
2
Table of Contents
1. Overview ............................................................................................................................................... 3
2. Configuration details ............................................................................................................................. 3
3. Reference .............................................................................................................................................. 7
Skype/Gmail: phien.ntace
3
1. Overview
2. Configuration details
/*===================================================================
* Description: Initial for I2C
* Parameters:
* Return: NONE
*/
void init_I2C(void)
{
EALLOW;
EDIS;
Skype/Gmail: phien.ntace
4
PieCtrlRegs.PIECTRL.bit.ENPIE = 1;
while(I2caRegs.I2CMDR.bit.STP == 1);
Skype/Gmail: phien.ntace
5
/*===================================================================
* Description: Send data via I2C bus
* Parameters:
* Return: NONE
* ------------------------------------------------------------------
* Note: Data read from I2C will be stored in i2c_read_buff[]
*/
void I2C_read_data(unsigned int slave_addr, unsigned int cmd_length)
{
// Wait until the STP bit is cleared from any previous master communication.
// Clearing of this bit by the module is delayed until after the SCD bit is
// set. If this bit is not checked prior to initiating a new message, the
// I2C could get confused.
while(I2caRegs.I2CMDR.bit.STP == 1);
I2caRegs.I2CSAR = slave_addr;
I2caRegs.I2CCNT = cmd_length;
if(cmd_length != 0)
{
// Setup data to send
for (jdex=0; jdex<cmd_length; jdex++)
Skype/Gmail: phien.ntace
6
{
I2caRegs.I2CDXR = i2c_cmd[jdex];
}
Skype/Gmail: phien.ntace
7
3. Reference
Revision
Revision Date Author Description
1.1 Oct 21, 2014 Phien NTACE - Modify section 2
Skype/Gmail: phien.ntace