EasyManua.ls Logo

Texas Instruments MSP430

Texas Instruments MSP430
413 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
284
USISRL = data_byte;
USICNT = (USICNT & 0xE0) + 8;
// wait until USIIFG is set
i2c_usi_mst_wait_usi_cnt_flag();
// check NACK/ACK
SET_SDA_AS_INPUT();
USICNT = (USICNT & 0xE0) + 1;
// wait for USIIFG is set
i2c_usi_mst_wait_usi_cnt_flag();
if(USISRL & 0x01)
{
// NACK received returns FALSE
return FALSE;
}
return TRUE;
}
// function to read a byte
unsigned char i2c_usi_mst_read_byte(void)
{
SET_SDA_AS_INPUT();
USICNT = (USICNT & 0xE0) + 8;
// wait for USIIFG is set
i2c_usi_mst_wait_usi_cnt_flag();
return USISRL;
}
// function to send (N)ACK bit
void i2c_usi_mst_send_n_ack(unsigned char ack)
{
// send (N)ack bit
SET_SDA_AS_OUTPUT();
if(ack)
{
USISRL = 0x00;
}
else
{
USISRL = 0xFF;
}
USICNT = (USICNT & 0xE0) + 1;
// wait until USIIFG is set
i2c_usi_mst_wait_usi_cnt_flag();
// set SDA as input
SET_SDA_AS_INPUT();
}

Table of Contents

Other manuals for Texas Instruments MSP430

Related product manuals